aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-03-23 10:05:55 +0100
committermarha <marha@users.sourceforge.net>2012-03-23 10:05:55 +0100
commit0f834b91a4768673833ab4917e87d86c237bb1a6 (patch)
tree363489504ed4b2d360259b8de4c9e392918e5d02 /xorg-server/hw/xfree86
parentfc72edebf875378459368c5383d9023730cbca54 (diff)
downloadvcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.gz
vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.bz2
vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.zip
libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update
23 Mar 2012
Diffstat (limited to 'xorg-server/hw/xfree86')
-rw-r--r--xorg-server/hw/xfree86/common/compiler.h1524
-rw-r--r--xorg-server/hw/xfree86/common/vidmodeproc.h39
-rw-r--r--xorg-server/hw/xfree86/common/xf86.h377
-rw-r--r--xorg-server/hw/xfree86/common/xf86AutoConfig.c172
-rw-r--r--xorg-server/hw/xfree86/common/xf86Bus.c296
-rw-r--r--xorg-server/hw/xfree86/common/xf86Config.c2163
-rw-r--r--xorg-server/hw/xfree86/common/xf86Configure.c827
-rw-r--r--xorg-server/hw/xfree86/common/xf86Cursor.c1170
-rw-r--r--xorg-server/hw/xfree86/common/xf86DGA.c1382
-rw-r--r--xorg-server/hw/xfree86/common/xf86Events.c519
-rw-r--r--xorg-server/hw/xfree86/common/xf86Globals.c95
-rw-r--r--xorg-server/hw/xfree86/common/xf86Helper.c1339
-rw-r--r--xorg-server/hw/xfree86/common/xf86Init.c2146
-rw-r--r--xorg-server/hw/xfree86/common/xf86Mode.c2339
-rw-r--r--xorg-server/hw/xfree86/common/xf86Module.h110
-rw-r--r--xorg-server/hw/xfree86/common/xf86Opt.h135
-rw-r--r--xorg-server/hw/xfree86/common/xf86Option.c817
-rw-r--r--xorg-server/hw/xfree86/common/xf86Optionstr.h16
-rw-r--r--xorg-server/hw/xfree86/common/xf86PM.c223
-rw-r--r--xorg-server/hw/xfree86/common/xf86Priv.h136
-rw-r--r--xorg-server/hw/xfree86/common/xf86RandR.c505
-rw-r--r--xorg-server/hw/xfree86/common/xf86VGAarbiter.c626
-rw-r--r--xorg-server/hw/xfree86/common/xf86VGAarbiterPriv.h521
-rw-r--r--xorg-server/hw/xfree86/common/xf86VidMode.c357
-rw-r--r--xorg-server/hw/xfree86/common/xf86Xinput.c468
-rw-r--r--xorg-server/hw/xfree86/common/xf86Xinput.h177
-rw-r--r--xorg-server/hw/xfree86/common/xf86cmap.c2364
-rw-r--r--xorg-server/hw/xfree86/common/xf86cmap.h146
-rw-r--r--xorg-server/hw/xfree86/common/xf86fbman.c2877
-rw-r--r--xorg-server/hw/xfree86/common/xf86fbman.h221
-rw-r--r--xorg-server/hw/xfree86/common/xf86pciBus.c1440
-rw-r--r--xorg-server/hw/xfree86/common/xf86sbusBus.c711
-rw-r--r--xorg-server/hw/xfree86/common/xf86sbusBus.h215
-rw-r--r--xorg-server/hw/xfree86/common/xf86str.h898
-rw-r--r--xorg-server/hw/xfree86/common/xf86xv.c3153
-rw-r--r--xorg-server/hw/xfree86/common/xf86xv.h559
-rw-r--r--xorg-server/hw/xfree86/common/xf86xvmc.c456
-rw-r--r--xorg-server/hw/xfree86/common/xf86xvmc.h112
-rw-r--r--xorg-server/hw/xfree86/common/xisb.c342
-rw-r--r--xorg-server/hw/xfree86/common/xisb.h30
-rw-r--r--xorg-server/hw/xfree86/ddc/ddc.c351
-rw-r--r--xorg-server/hw/xfree86/ddc/ddcProperty.c31
-rw-r--r--xorg-server/hw/xfree86/ddc/edid.h327
-rw-r--r--xorg-server/hw/xfree86/ddc/interpret_edid.c1399
-rw-r--r--xorg-server/hw/xfree86/ddc/print_edid.c644
-rw-r--r--xorg-server/hw/xfree86/ddc/xf86DDC.h64
-rw-r--r--xorg-server/hw/xfree86/dixmods/dbemodule.c25
-rw-r--r--xorg-server/hw/xfree86/dixmods/extmod/dgaproc.h128
-rw-r--r--xorg-server/hw/xfree86/dixmods/extmod/modinit.c361
-rw-r--r--xorg-server/hw/xfree86/dixmods/extmod/modinit.h179
-rw-r--r--xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c552
-rw-r--r--xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c2458
-rw-r--r--xorg-server/hw/xfree86/dixmods/fbmodule.c28
-rw-r--r--xorg-server/hw/xfree86/dixmods/glxmodule.c51
-rw-r--r--xorg-server/hw/xfree86/dixmods/shmodule.c23
-rw-r--r--xorg-server/hw/xfree86/dri/dri.c2423
-rw-r--r--xorg-server/hw/xfree86/dri/dri.h295
-rw-r--r--xorg-server/hw/xfree86/dri/drimodule.c40
-rw-r--r--xorg-server/hw/xfree86/dri/dristruct.h253
-rw-r--r--xorg-server/hw/xfree86/dri/xf86dri.c473
-rw-r--r--xorg-server/hw/xfree86/dri2/dri2.c946
-rw-r--r--xorg-server/hw/xfree86/dri2/dri2.h178
-rw-r--r--xorg-server/hw/xfree86/dri2/dri2ext.c228
-rw-r--r--xorg-server/hw/xfree86/exa/examodule.c153
-rw-r--r--xorg-server/hw/xfree86/fbdevhw/fbdevhw.c1173
-rw-r--r--xorg-server/hw/xfree86/fbdevhw/fbdevhw.h98
-rw-r--r--xorg-server/hw/xfree86/fbdevhw/fbdevhwstub.c92
-rw-r--r--xorg-server/hw/xfree86/i2c/bt829.c1566
-rw-r--r--xorg-server/hw/xfree86/i2c/bt829_module.c41
-rw-r--r--xorg-server/hw/xfree86/i2c/fi1236.c277
-rw-r--r--xorg-server/hw/xfree86/i2c/fi1236_module.c49
-rw-r--r--xorg-server/hw/xfree86/i2c/msp3430.c1184
-rw-r--r--xorg-server/hw/xfree86/i2c/msp3430_module.c49
-rw-r--r--xorg-server/hw/xfree86/i2c/tda8425.c161
-rw-r--r--xorg-server/hw/xfree86/i2c/tda8425.h29
-rw-r--r--xorg-server/hw/xfree86/i2c/tda8425_module.c49
-rw-r--r--xorg-server/hw/xfree86/i2c/tda9850.c248
-rw-r--r--xorg-server/hw/xfree86/i2c/tda9850_module.c49
-rw-r--r--xorg-server/hw/xfree86/i2c/tda9885.c204
-rw-r--r--xorg-server/hw/xfree86/i2c/tda9885_module.c49
-rw-r--r--xorg-server/hw/xfree86/i2c/uda1380.c379
-rw-r--r--xorg-server/hw/xfree86/i2c/uda1380_module.c49
-rw-r--r--xorg-server/hw/xfree86/i2c/xf86i2c.c1745
-rw-r--r--xorg-server/hw/xfree86/i2c/xf86i2c.h103
-rw-r--r--xorg-server/hw/xfree86/int10/generic.c262
-rw-r--r--xorg-server/hw/xfree86/int10/helper_exec.c547
-rw-r--r--xorg-server/hw/xfree86/int10/helper_mem.c182
-rw-r--r--xorg-server/hw/xfree86/int10/xf86int10.c1238
-rw-r--r--xorg-server/hw/xfree86/int10/xf86int10.h70
-rw-r--r--xorg-server/hw/xfree86/int10/xf86int10module.c75
-rw-r--r--xorg-server/hw/xfree86/loader/loader.c55
-rw-r--r--xorg-server/hw/xfree86/loader/loadext.c880
-rw-r--r--xorg-server/hw/xfree86/loader/loadmod.c1097
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Crtc.c3693
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Crtc.h496
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Cursors.c632
-rw-r--r--xorg-server/hw/xfree86/modes/xf86DiDGA.c431
-rw-r--r--xorg-server/hw/xfree86/modes/xf86DisplayIDModes.c889
-rw-r--r--xorg-server/hw/xfree86/modes/xf86EdidModes.c1068
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Modes.c636
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Modes.h70
-rw-r--r--xorg-server/hw/xfree86/modes/xf86RandR12.c2146
-rw-r--r--xorg-server/hw/xfree86/modes/xf86RandR12.h89
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Rotate.c658
-rw-r--r--xorg-server/hw/xfree86/modes/xf86cvt.c63
-rw-r--r--xorg-server/hw/xfree86/modes/xf86gtf.c84
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/alpha_video.c606
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/arm_video.c741
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c96
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/bsd_axp.c65
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/bsd_bell.c48
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/bsd_init.c778
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/bsd_kmod.c7
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c134
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/i386_video.c1113
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/memrange.h57
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/ppc_video.c105
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c40
-rw-r--r--xorg-server/hw/xfree86/os-support/bus/Sbus.c627
-rw-r--r--xorg-server/hw/xfree86/os-support/bus/nobus.c6
-rw-r--r--xorg-server/hw/xfree86/os-support/bus/xf86Pci.h11
-rw-r--r--xorg-server/hw/xfree86/os-support/hurd/hurd_init.c43
-rw-r--r--xorg-server/hw/xfree86/os-support/hurd/hurd_mmap.c188
-rw-r--r--xorg-server/hw/xfree86/os-support/hurd/hurd_video.c307
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/int10/linux.c544
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/int10/vm86/linux_vm86.c390
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/lnx_agp.c745
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/lnx_apm.c153
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/lnx_axp.c166
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/lnx_init.c342
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/lnx_video.c808
-rw-r--r--xorg-server/hw/xfree86/os-support/misc/SlowBcopy.c87
-rw-r--r--xorg-server/hw/xfree86/os-support/shared/bios_mmap.c128
-rw-r--r--xorg-server/hw/xfree86/os-support/shared/kmod_noop.c5
-rw-r--r--xorg-server/hw/xfree86/os-support/shared/posix_tty.c847
-rw-r--r--xorg-server/hw/xfree86/os-support/shared/sigio.c610
-rw-r--r--xorg-server/hw/xfree86/os-support/shared/vidmem.c317
-rw-r--r--xorg-server/hw/xfree86/os-support/shared/xf86Axp.c41
-rw-r--r--xorg-server/hw/xfree86/os-support/solaris/sun_VTsw.c271
-rw-r--r--xorg-server/hw/xfree86/os-support/solaris/sun_apm.c453
-rw-r--r--xorg-server/hw/xfree86/os-support/solaris/sun_bell.c363
-rw-r--r--xorg-server/hw/xfree86/os-support/solaris/sun_init.c502
-rw-r--r--xorg-server/hw/xfree86/os-support/solaris/sun_vid.c505
-rw-r--r--xorg-server/hw/xfree86/os-support/xf86_OSproc.h101
-rw-r--r--xorg-server/hw/xfree86/parser/Configint.h17
-rw-r--r--xorg-server/hw/xfree86/parser/DRI.c101
-rw-r--r--xorg-server/hw/xfree86/parser/Device.c531
-rw-r--r--xorg-server/hw/xfree86/parser/Extensions.c66
-rw-r--r--xorg-server/hw/xfree86/parser/Files.c299
-rw-r--r--xorg-server/hw/xfree86/parser/Flags.c649
-rw-r--r--xorg-server/hw/xfree86/parser/Input.c217
-rw-r--r--xorg-server/hw/xfree86/parser/InputClass.c24
-rw-r--r--xorg-server/hw/xfree86/parser/Layout.c838
-rw-r--r--xorg-server/hw/xfree86/parser/Module.c329
-rw-r--r--xorg-server/hw/xfree86/parser/Monitor.c1465
-rw-r--r--xorg-server/hw/xfree86/parser/Pointer.c290
-rw-r--r--xorg-server/hw/xfree86/parser/Screen.c874
-rw-r--r--xorg-server/hw/xfree86/parser/Vendor.c270
-rw-r--r--xorg-server/hw/xfree86/parser/Video.c346
-rw-r--r--xorg-server/hw/xfree86/parser/configProcs.h86
-rw-r--r--xorg-server/hw/xfree86/parser/read.c610
-rw-r--r--xorg-server/hw/xfree86/parser/scan.c1541
-rw-r--r--xorg-server/hw/xfree86/parser/write.c421
-rw-r--r--xorg-server/hw/xfree86/parser/xf86Optrec.h24
-rw-r--r--xorg-server/hw/xfree86/parser/xf86Parser.h721
-rw-r--r--xorg-server/hw/xfree86/ramdac/BT.c158
-rw-r--r--xorg-server/hw/xfree86/ramdac/BT.h15
-rw-r--r--xorg-server/hw/xfree86/ramdac/IBM.c1282
-rw-r--r--xorg-server/hw/xfree86/ramdac/IBM.h73
-rw-r--r--xorg-server/hw/xfree86/ramdac/TI.c1442
-rw-r--r--xorg-server/hw/xfree86/ramdac/TI.h41
-rw-r--r--xorg-server/hw/xfree86/ramdac/xf86Cursor.c366
-rw-r--r--xorg-server/hw/xfree86/ramdac/xf86Cursor.h21
-rw-r--r--xorg-server/hw/xfree86/ramdac/xf86HWCurs.c433
-rw-r--r--xorg-server/hw/xfree86/ramdac/xf86RamDac.h103
-rw-r--r--xorg-server/hw/xfree86/sdksyms.sh5
-rw-r--r--xorg-server/hw/xfree86/shadowfb/sfbmodule.c23
-rw-r--r--xorg-server/hw/xfree86/shadowfb/shadow.c3322
-rw-r--r--xorg-server/hw/xfree86/shadowfb/shadowfb.h18
-rw-r--r--xorg-server/hw/xfree86/utils/cvt/cvt.c100
-rw-r--r--xorg-server/hw/xfree86/utils/gtf/gtf.c324
-rw-r--r--xorg-server/hw/xfree86/vbe/vbe.c1032
-rw-r--r--xorg-server/hw/xfree86/vbe/vbe.h698
-rw-r--r--xorg-server/hw/xfree86/vbe/vbeModes.c902
-rw-r--r--xorg-server/hw/xfree86/vbe/vbeModes.h30
-rw-r--r--xorg-server/hw/xfree86/vbe/vbe_module.c45
-rw-r--r--xorg-server/hw/xfree86/vgahw/vgaCmap.c580
-rw-r--r--xorg-server/hw/xfree86/vgahw/vgaHW.c1385
-rw-r--r--xorg-server/hw/xfree86/vgahw/vgaHW.h184
-rw-r--r--xorg-server/hw/xfree86/x86emu/debug.c507
-rw-r--r--xorg-server/hw/xfree86/x86emu/decode.c1068
-rw-r--r--xorg-server/hw/xfree86/x86emu/fpu.c449
-rw-r--r--xorg-server/hw/xfree86/x86emu/ops.c24059
-rw-r--r--xorg-server/hw/xfree86/x86emu/ops2.c1877
-rw-r--r--xorg-server/hw/xfree86/x86emu/prim_ops.c3147
-rw-r--r--xorg-server/hw/xfree86/x86emu/sys.c427
-rw-r--r--xorg-server/hw/xfree86/x86emu/validate.c50
-rw-r--r--xorg-server/hw/xfree86/x86emu/x86emu/prim_x86_gcc.h36
-rw-r--r--xorg-server/hw/xfree86/xaa/xaa.h2432
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaBitBlt.c450
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaBitmap.c653
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaCpyArea.c796
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaCpyPlane.c412
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaCpyWin.c160
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaDashLine.c687
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaFallback.c632
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaFillArc.c415
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaFillPoly.c1953
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaFillRect.c2196
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaGC.c710
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaGCmisc.c709
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaImage.c1055
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaInit.c1272
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaInitAccel.c3069
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaLine.c816
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaLineMisc.c299
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaNonTEGlyph.c194
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaNonTEText.c1182
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaOffscreen.c325
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaOverlay.c251
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaOverlayDF.c1959
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaPCache.c4901
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaPict.c1309
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaROP.c242
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaRect.c257
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaSpans.c1758
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaStateChange.c3292
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaStipple.c1197
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaTEGlyph.c2160
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaTEText.c606
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaTables.c198
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaWideLine.c1845
-rw-r--r--xorg-server/hw/xfree86/xaa/xaalocal.h2582
-rw-r--r--xorg-server/hw/xfree86/xaa/xaarop.h10
234 files changed, 88010 insertions, 87813 deletions
diff --git a/xorg-server/hw/xfree86/common/compiler.h b/xorg-server/hw/xfree86/common/compiler.h
index 34e60c52a..0abdfb6c3 100644
--- a/xorg-server/hw/xfree86/common/compiler.h
+++ b/xorg-server/hw/xfree86/common/compiler.h
@@ -49,61 +49,58 @@
#ifndef _COMPILER_H
-# define _COMPILER_H
+#define _COMPILER_H
#if defined(__SUNPRO_C)
-# define DO_PROTOTYPES
+#define DO_PROTOTYPES
#endif
/* Map Sun compiler platform defines to gcc-style used in the code */
#if defined(__amd64) && !defined(__amd64__)
-# define __amd64__
+#define __amd64__
#endif
#if defined(__i386) && !defined(__i386__)
-# define __i386__
+#define __i386__
#endif
#if defined(__sparc) && !defined(__sparc__)
-# define __sparc__
+#define __sparc__
#endif
#if defined(__sparcv9) && !defined(__sparc64__)
-# define __sparc64__
+#define __sparc64__
#endif
#ifndef _X_EXPORT
-# include <X11/Xfuncproto.h>
+#include <X11/Xfuncproto.h>
#endif
-# include <pixman.h> /* for uint*_t types */
+#include <pixman.h> /* for uint*_t types */
/* Allow drivers to use the GCC-supported __inline__ and/or __inline. */
-# ifndef __inline__
-# if defined(__GNUC__)
+#ifndef __inline__
+#if defined(__GNUC__)
/* gcc has __inline__ */
-# elif defined(__HIGHC__)
-# define __inline__ _Inline
-# else
-# define __inline__ /**/
-# endif
-# endif /* __inline__ */
-# ifndef __inline
-# if defined(__GNUC__)
+#elif defined(__HIGHC__)
+#define __inline__ _Inline
+#else
+#define __inline__ /**/
+#endif
+#endif /* __inline__ */
+#ifndef __inline
+#if defined(__GNUC__)
/* gcc has __inline */
-# elif defined(__HIGHC__)
-# define __inline _Inline
-# else
-# define __inline /**/
-# endif
-# endif /* __inline */
-
+#elif defined(__HIGHC__)
+#define __inline _Inline
+#else
+#define __inline /**/
+#endif
+#endif /* __inline */
/* Support gcc's __FUNCTION__ for people using other compilers */
#if !defined(__GNUC__) && !defined(__FUNCTION__)
-# define __FUNCTION__ __func__ /* C99 */
+#define __FUNCTION__ __func__ /* C99 */
#endif
-
-# if defined(NO_INLINE) || defined(DO_PROTOTYPES)
-
-# if !defined(__arm__)
-# if !defined(__sparc__) && !defined(__sparc) && !defined(__arm32__) && !defined(__nds32__) \
+#if defined(NO_INLINE) || defined(DO_PROTOTYPES)
+#if !defined(__arm__)
+#if !defined(__sparc__) && !defined(__sparc) && !defined(__arm32__) && !defined(__nds32__) \
&& !(defined(__alpha__) && defined(linux)) \
&& !(defined(__ia64__) && defined(linux)) \
@@ -114,8 +111,7 @@ extern _X_EXPORT unsigned int inb(unsigned short);
extern _X_EXPORT unsigned int inw(unsigned short);
extern _X_EXPORT unsigned int inl(unsigned short);
-# else /* __sparc__, __arm32__, __alpha__, __nds32__ */
-
+#else /* __sparc__, __arm32__, __alpha__, __nds32__ */
extern _X_EXPORT void outb(unsigned long, unsigned char);
extern _X_EXPORT void outw(unsigned long, unsigned short);
extern _X_EXPORT void outl(unsigned long, unsigned int);
@@ -123,10 +119,10 @@ extern _X_EXPORT unsigned int inb(unsigned long);
extern _X_EXPORT unsigned int inw(unsigned long);
extern _X_EXPORT unsigned int inl(unsigned long);
-# endif /* __sparc__, __arm32__, __alpha__, __nds32__ */
-# endif /* __arm__ */
+#endif /* __sparc__, __arm32__, __alpha__, __nds32__ */
+#endif /* __arm__ */
-# if defined(__powerpc__) && !defined(__OpenBSD__)
+#if defined(__powerpc__) && !defined(__OpenBSD__)
extern unsigned long ldq_u(unsigned long *);
extern unsigned long ldl_u(unsigned int *);
extern unsigned long ldw_u(unsigned short *);
@@ -139,50 +135,50 @@ extern void stl_brx(unsigned long, volatile unsigned char *, int);
extern void stw_brx(unsigned short, volatile unsigned char *, int);
extern unsigned long ldl_brx(volatile unsigned char *, int);
extern unsigned short ldw_brx(volatile unsigned char *, int);
-# endif /* __powerpc__ && !__OpenBSD */
+#endif /* __powerpc__ && !__OpenBSD */
-# endif /* NO_INLINE || DO_PROTOTYPES */
+#endif /* NO_INLINE || DO_PROTOTYPES */
-# ifndef NO_INLINE
-# ifdef __GNUC__
-# ifdef __i386__
+#ifndef NO_INLINE
+#ifdef __GNUC__
+#ifdef __i386__
-# ifdef __SSE__
-# define write_mem_barrier() __asm__ __volatile__ ("sfence" : : : "memory")
-# else
-# define write_mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
-# endif
+#ifdef __SSE__
+#define write_mem_barrier() __asm__ __volatile__ ("sfence" : : : "memory")
+#else
+#define write_mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
+#endif
-# ifdef __SSE2__
-# define mem_barrier() __asm__ __volatile__ ("mfence" : : : "memory")
-# else
-# define mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
-# endif
+#ifdef __SSE2__
+#define mem_barrier() __asm__ __volatile__ ("mfence" : : : "memory")
+#else
+#define mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
+#endif
-# elif defined __alpha__
+#elif defined __alpha__
-# define mem_barrier() __asm__ __volatile__ ("mb" : : : "memory")
-# define write_mem_barrier() __asm__ __volatile__ ("wmb" : : : "memory")
+#define mem_barrier() __asm__ __volatile__ ("mb" : : : "memory")
+#define write_mem_barrier() __asm__ __volatile__ ("wmb" : : : "memory")
-# elif defined __amd64__
+#elif defined __amd64__
-# define mem_barrier() __asm__ __volatile__ ("mfence" : : : "memory")
-# define write_mem_barrier() __asm__ __volatile__ ("sfence" : : : "memory")
+#define mem_barrier() __asm__ __volatile__ ("mfence" : : : "memory")
+#define write_mem_barrier() __asm__ __volatile__ ("sfence" : : : "memory")
-# elif defined __ia64__
+#elif defined __ia64__
-# ifndef __INTEL_COMPILER
-# define mem_barrier() __asm__ __volatile__ ("mf" : : : "memory")
-# define write_mem_barrier() __asm__ __volatile__ ("mf" : : : "memory")
-# else
-# include "ia64intrin.h"
-# define mem_barrier() __mf()
-# define write_mem_barrier() __mf()
-# endif
+#ifndef __INTEL_COMPILER
+#define mem_barrier() __asm__ __volatile__ ("mf" : : : "memory")
+#define write_mem_barrier() __asm__ __volatile__ ("mf" : : : "memory")
+#else
+#include "ia64intrin.h"
+#define mem_barrier() __mf()
+#define write_mem_barrier() __mf()
+#endif
-# elif defined __mips__
+#elif defined __mips__
/* Note: sync instruction requires MIPS II instruction set */
-# define mem_barrier() \
+#define mem_barrier() \
__asm__ __volatile__( \
".set push\n\t" \
".set noreorder\n\t" \
@@ -192,140 +188,169 @@ extern unsigned short ldw_brx(volatile unsigned char *, int);
: /* no output */ \
: /* no input */ \
: "memory")
-# define write_mem_barrier() mem_barrier()
-
-# elif defined __powerpc__
+#define write_mem_barrier() mem_barrier()
-# if defined(linux) && defined(__powerpc64__)
-# include <linux/version.h>
-# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
-# include <asm/memory.h>
-# endif
-# endif /* defined(linux) && defined(__powerpc64__) */
+#elif defined __powerpc__
-# ifndef eieio /* We deal with arch-specific eieio() routines above... */
-# define eieio() __asm__ __volatile__ ("eieio" ::: "memory")
-# endif /* eieio */
-# define mem_barrier() eieio()
-# define write_mem_barrier() eieio()
+#if defined(linux) && defined(__powerpc64__)
+#include <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
+#include <asm/memory.h>
+#endif
+#endif /* defined(linux) && defined(__powerpc64__) */
-# elif defined __sparc__
+#ifndef eieio /* We deal with arch-specific eieio() routines above... */
+#define eieio() __asm__ __volatile__ ("eieio" ::: "memory")
+#endif /* eieio */
+#define mem_barrier() eieio()
+#define write_mem_barrier() eieio()
-# define barrier() __asm__ __volatile__ (".word 0x8143e00a" : : : "memory")
-# define mem_barrier() /* XXX: nop for now */
-# define write_mem_barrier() /* XXX: nop for now */
-# endif
-# endif /* __GNUC__ */
-# endif /* NO_INLINE */
+#elif defined __sparc__
-# ifndef mem_barrier
-# define mem_barrier() /* NOP */
-# endif
+#define barrier() __asm__ __volatile__ (".word 0x8143e00a" : : : "memory")
+#define mem_barrier() /* XXX: nop for now */
+#define write_mem_barrier() /* XXX: nop for now */
+#endif
+#endif /* __GNUC__ */
+#endif /* NO_INLINE */
-# ifndef write_mem_barrier
-# define write_mem_barrier() /* NOP */
-# endif
+#ifndef mem_barrier
+#define mem_barrier() /* NOP */
+#endif
+#ifndef write_mem_barrier
+#define write_mem_barrier() /* NOP */
+#endif
-# ifndef NO_INLINE
-# ifdef __GNUC__
+#ifndef NO_INLINE
+#ifdef __GNUC__
/* Define some packed structures to use with unaligned accesses */
-struct __una_u64 { uint64_t x __attribute__((packed)); };
-struct __una_u32 { uint32_t x __attribute__((packed)); };
-struct __una_u16 { uint16_t x __attribute__((packed)); };
+struct __una_u64 {
+ uint64_t x __attribute__ ((packed));
+};
+struct __una_u32 {
+ uint32_t x __attribute__ ((packed));
+};
+struct __una_u16 {
+ uint16_t x __attribute__ ((packed));
+};
/* Elemental unaligned loads */
-static __inline__ uint64_t ldq_u(uint64_t *p)
+static __inline__ uint64_t
+ldq_u(uint64_t * p)
{
- const struct __una_u64 *ptr = (const struct __una_u64 *) p;
- return ptr->x;
+ const struct __una_u64 *ptr = (const struct __una_u64 *) p;
+
+ return ptr->x;
}
-static __inline__ uint32_t ldl_u(uint32_t *p)
+static __inline__ uint32_t
+ldl_u(uint32_t * p)
{
- const struct __una_u32 *ptr = (const struct __una_u32 *) p;
- return ptr->x;
+ const struct __una_u32 *ptr = (const struct __una_u32 *) p;
+
+ return ptr->x;
}
-static __inline__ uint16_t ldw_u(uint16_t *p)
+static __inline__ uint16_t
+ldw_u(uint16_t * p)
{
- const struct __una_u16 *ptr = (const struct __una_u16 *) p;
- return ptr->x;
+ const struct __una_u16 *ptr = (const struct __una_u16 *) p;
+
+ return ptr->x;
}
/* Elemental unaligned stores */
-static __inline__ void stq_u(uint64_t val, uint64_t *p)
+static __inline__ void
+stq_u(uint64_t val, uint64_t * p)
{
- struct __una_u64 *ptr = (struct __una_u64 *) p;
- ptr->x = val;
+ struct __una_u64 *ptr = (struct __una_u64 *) p;
+
+ ptr->x = val;
}
-static __inline__ void stl_u(uint32_t val, uint32_t *p)
+static __inline__ void
+stl_u(uint32_t val, uint32_t * p)
{
- struct __una_u32 *ptr = (struct __una_u32 *) p;
- ptr->x = val;
+ struct __una_u32 *ptr = (struct __una_u32 *) p;
+
+ ptr->x = val;
}
-static __inline__ void stw_u(uint16_t val, uint16_t *p)
+static __inline__ void
+stw_u(uint16_t val, uint16_t * p)
{
- struct __una_u16 *ptr = (struct __una_u16 *) p;
- ptr->x = val;
+ struct __una_u16 *ptr = (struct __una_u16 *) p;
+
+ ptr->x = val;
}
-# else /* !__GNUC__ */
+#else /* !__GNUC__ */
-#include <string.h> /* needed for memmove */
+#include <string.h> /* needed for memmove */
-static __inline__ uint64_t ldq_u(uint64_t *p)
+static __inline__ uint64_t
+ldq_u(uint64_t * p)
{
- uint64_t ret;
- memmove(&ret, p, sizeof(*p));
- return ret;
+ uint64_t ret;
+
+ memmove(&ret, p, sizeof(*p));
+ return ret;
}
-static __inline__ uint32_t ldl_u(uint32_t *p)
+static __inline__ uint32_t
+ldl_u(uint32_t * p)
{
- uint32_t ret;
- memmove(&ret, p, sizeof(*p));
- return ret;
+ uint32_t ret;
+
+ memmove(&ret, p, sizeof(*p));
+ return ret;
}
-static __inline__ uint16_t ldw_u(uint16_t *p)
+static __inline__ uint16_t
+ldw_u(uint16_t * p)
{
- uint16_t ret;
- memmove(&ret, p, sizeof(*p));
- return ret;
+ uint16_t ret;
+
+ memmove(&ret, p, sizeof(*p));
+ return ret;
}
-static __inline__ void stq_u(uint64_t val, uint64_t *p)
+static __inline__ void
+stq_u(uint64_t val, uint64_t * p)
{
- uint64_t tmp = val;
- memmove(p, &tmp, sizeof(*p));
+ uint64_t tmp = val;
+
+ memmove(p, &tmp, sizeof(*p));
}
-static __inline__ void stl_u(uint32_t val, uint32_t *p)
+static __inline__ void
+stl_u(uint32_t val, uint32_t * p)
{
- uint32_t tmp = val;
- memmove(p, &tmp, sizeof(*p));
+ uint32_t tmp = val;
+
+ memmove(p, &tmp, sizeof(*p));
}
-static __inline__ void stw_u(uint16_t val, uint16_t *p)
+static __inline__ void
+stw_u(uint16_t val, uint16_t * p)
{
- uint16_t tmp = val;
- memmove(p, &tmp, sizeof(*p));
+ uint16_t tmp = val;
+
+ memmove(p, &tmp, sizeof(*p));
}
-# endif /* __GNUC__ */
-# endif /* NO_INLINE */
+#endif /* __GNUC__ */
+#endif /* NO_INLINE */
-# ifndef NO_INLINE
-# ifdef __GNUC__
-# if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) && (defined(__alpha__))
+#ifndef NO_INLINE
+#ifdef __GNUC__
+#if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) && (defined(__alpha__))
-# ifdef linux
+#ifdef linux
/* for Linux on Alpha, we use the LIBC _inx/_outx routines */
/* note that the appropriate setup via "ioperm" needs to be done */
/* *before* any inx/outx is done. */
@@ -358,24 +383,24 @@ outl(unsigned long port, unsigned int val)
static __inline__ unsigned int
inb(unsigned long port)
{
- return _inb(port);
+ return _inb(port);
}
static __inline__ unsigned int
inw(unsigned long port)
{
- return _inw(port);
+ return _inw(port);
}
static __inline__ unsigned int
inl(unsigned long port)
{
- return _inl(port);
+ return _inl(port);
}
-# endif /* linux */
+#endif /* linux */
-# if (defined(__FreeBSD__) || defined(__OpenBSD__)) \
+#if (defined(__FreeBSD__) || defined(__OpenBSD__)) \
&& !defined(DO_PROTOTYPES)
/* for FreeBSD and OpenBSD on Alpha, we use the libio (resp. libalpha) */
@@ -390,583 +415,567 @@ extern _X_EXPORT unsigned char inb(unsigned int port);
extern _X_EXPORT unsigned short inw(unsigned int port);
extern _X_EXPORT unsigned int inl(unsigned int port);
-# endif /* (__FreeBSD__ || __OpenBSD__ ) && !DO_PROTOTYPES */
-
+#endif /* (__FreeBSD__ || __OpenBSD__ ) && !DO_PROTOTYPES */
#if defined(__NetBSD__)
#include <machine/pio.h>
-#endif /* __NetBSD__ */
+#endif /* __NetBSD__ */
+
+#elif (defined(linux) || defined(__FreeBSD__)) && defined(__amd64__)
-# elif (defined(linux) || defined(__FreeBSD__)) && defined(__amd64__)
-
-# include <inttypes.h>
+#include <inttypes.h>
static __inline__ void
outb(unsigned short port, unsigned char val)
{
- __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
+ __asm__ __volatile__("outb %0,%1"::"a"(val), "d"(port));
}
-
static __inline__ void
outw(unsigned short port, unsigned short val)
{
- __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
+ __asm__ __volatile__("outw %0,%1"::"a"(val), "d"(port));
}
static __inline__ void
outl(unsigned short port, unsigned int val)
{
- __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
+ __asm__ __volatile__("outl %0,%1"::"a"(val), "d"(port));
}
static __inline__ unsigned int
inb(unsigned short port)
{
- unsigned char ret;
- __asm__ __volatile__("inb %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
+ unsigned char ret;
+ __asm__ __volatile__("inb %1,%0":"=a"(ret):"d"(port));
+
+ return ret;
}
static __inline__ unsigned int
inw(unsigned short port)
{
- unsigned short ret;
- __asm__ __volatile__("inw %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
+ unsigned short ret;
+ __asm__ __volatile__("inw %1,%0":"=a"(ret):"d"(port));
+
+ return ret;
}
static __inline__ unsigned int
inl(unsigned short port)
{
- unsigned int ret;
- __asm__ __volatile__("inl %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
+ unsigned int ret;
+ __asm__ __volatile__("inl %1,%0":"=a"(ret):"d"(port));
+
+ return ret;
}
-# elif (defined(linux) || defined(sun) || defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc__)
+#elif (defined(linux) || defined(sun) || defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc__)
-# ifndef ASI_PL
-# define ASI_PL 0x88
-# endif
+#ifndef ASI_PL
+#define ASI_PL 0x88
+#endif
static __inline__ void
outb(unsigned long port, unsigned char val)
{
- __asm__ __volatile__("stba %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (port), "i" (ASI_PL));
- barrier();
+ __asm__ __volatile__("stba %0, [%1] %2": /* No outputs */
+ :"r"(val), "r"(port), "i"(ASI_PL));
+
+ barrier();
}
static __inline__ void
outw(unsigned long port, unsigned short val)
{
- __asm__ __volatile__("stha %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (port), "i" (ASI_PL));
- barrier();
+ __asm__ __volatile__("stha %0, [%1] %2": /* No outputs */
+ :"r"(val), "r"(port), "i"(ASI_PL));
+
+ barrier();
}
static __inline__ void
outl(unsigned long port, unsigned int val)
{
- __asm__ __volatile__("sta %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (port), "i" (ASI_PL));
- barrier();
+ __asm__ __volatile__("sta %0, [%1] %2": /* No outputs */
+ :"r"(val), "r"(port), "i"(ASI_PL));
+
+ barrier();
}
static __inline__ unsigned int
inb(unsigned long port)
{
- unsigned int ret;
- __asm__ __volatile__("lduba [%1] %2, %0"
- : "=r" (ret)
- : "r" (port), "i" (ASI_PL));
- return ret;
+ unsigned int ret;
+ __asm__ __volatile__("lduba [%1] %2, %0":"=r"(ret)
+ :"r"(port), "i"(ASI_PL));
+
+ return ret;
}
static __inline__ unsigned int
inw(unsigned long port)
{
- unsigned int ret;
- __asm__ __volatile__("lduha [%1] %2, %0"
- : "=r" (ret)
- : "r" (port), "i" (ASI_PL));
- return ret;
+ unsigned int ret;
+ __asm__ __volatile__("lduha [%1] %2, %0":"=r"(ret)
+ :"r"(port), "i"(ASI_PL));
+
+ return ret;
}
static __inline__ unsigned int
inl(unsigned long port)
{
- unsigned int ret;
- __asm__ __volatile__("lda [%1] %2, %0"
- : "=r" (ret)
- : "r" (port), "i" (ASI_PL));
- return ret;
+ unsigned int ret;
+ __asm__ __volatile__("lda [%1] %2, %0":"=r"(ret)
+ :"r"(port), "i"(ASI_PL));
+
+ return ret;
}
static __inline__ unsigned char
xf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned char ret;
+ unsigned long addr = ((unsigned long) base) + offset;
+ unsigned char ret;
+
+ __asm__ __volatile__("lduba [%1] %2, %0":"=r"(ret)
+ :"r"(addr), "i"(ASI_PL));
- __asm__ __volatile__("lduba [%1] %2, %0"
- : "=r" (ret)
- : "r" (addr), "i" (ASI_PL));
- return ret;
+ return ret;
}
static __inline__ unsigned short
xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset)
{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned short ret;
+ unsigned long addr = ((unsigned long) base) + offset;
+ unsigned short ret;
- __asm__ __volatile__("lduh [%1], %0"
- : "=r" (ret)
- : "r" (addr));
- return ret;
+ __asm__ __volatile__("lduh [%1], %0":"=r"(ret)
+ :"r"(addr));
+
+ return ret;
}
static __inline__ unsigned short
xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset)
{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned short ret;
+ unsigned long addr = ((unsigned long) base) + offset;
+ unsigned short ret;
+
+ __asm__ __volatile__("lduha [%1] %2, %0":"=r"(ret)
+ :"r"(addr), "i"(ASI_PL));
- __asm__ __volatile__("lduha [%1] %2, %0"
- : "=r" (ret)
- : "r" (addr), "i" (ASI_PL));
- return ret;
+ return ret;
}
static __inline__ unsigned int
xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned int ret;
+ unsigned long addr = ((unsigned long) base) + offset;
+ unsigned int ret;
- __asm__ __volatile__("ld [%1], %0"
- : "=r" (ret)
- : "r" (addr));
- return ret;
+ __asm__ __volatile__("ld [%1], %0":"=r"(ret)
+ :"r"(addr));
+
+ return ret;
}
static __inline__ unsigned int
xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned int ret;
+ unsigned long addr = ((unsigned long) base) + offset;
+ unsigned int ret;
+
+ __asm__ __volatile__("lda [%1] %2, %0":"=r"(ret)
+ :"r"(addr), "i"(ASI_PL));
- __asm__ __volatile__("lda [%1] %2, %0"
- : "=r" (ret)
- : "r" (addr), "i" (ASI_PL));
- return ret;
+ return ret;
}
static __inline__ void
xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- unsigned long addr = ((unsigned long)base) + offset;
+ unsigned long addr = ((unsigned long) base) + offset;
- __asm__ __volatile__("stba %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
- barrier();
+ __asm__ __volatile__("stba %0, [%1] %2": /* No outputs */
+ :"r"(val), "r"(addr), "i"(ASI_PL));
+
+ barrier();
}
static __inline__ void
xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- unsigned long addr = ((unsigned long)base) + offset;
+ unsigned long addr = ((unsigned long) base) + offset;
+
+ __asm__ __volatile__("sth %0, [%1]": /* No outputs */
+ :"r"(val), "r"(addr));
- __asm__ __volatile__("sth %0, [%1]"
- : /* No outputs */
- : "r" (val), "r" (addr));
- barrier();
+ barrier();
}
static __inline__ void
xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- unsigned long addr = ((unsigned long)base) + offset;
+ unsigned long addr = ((unsigned long) base) + offset;
+
+ __asm__ __volatile__("stha %0, [%1] %2": /* No outputs */
+ :"r"(val), "r"(addr), "i"(ASI_PL));
- __asm__ __volatile__("stha %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
- barrier();
+ barrier();
}
static __inline__ void
xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- unsigned long addr = ((unsigned long)base) + offset;
+ unsigned long addr = ((unsigned long) base) + offset;
+
+ __asm__ __volatile__("st %0, [%1]": /* No outputs */
+ :"r"(val), "r"(addr));
- __asm__ __volatile__("st %0, [%1]"
- : /* No outputs */
- : "r" (val), "r" (addr));
- barrier();
+ barrier();
}
static __inline__ void
xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- unsigned long addr = ((unsigned long)base) + offset;
+ unsigned long addr = ((unsigned long) base) + offset;
+
+ __asm__ __volatile__("sta %0, [%1] %2": /* No outputs */
+ :"r"(val), "r"(addr), "i"(ASI_PL));
- __asm__ __volatile__("sta %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
- barrier();
+ barrier();
}
static __inline__ void
xf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- unsigned long addr = ((unsigned long)base) + offset;
+ unsigned long addr = ((unsigned long) base) + offset;
- __asm__ __volatile__("stba %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
+ __asm__ __volatile__("stba %0, [%1] %2": /* No outputs */
+ :"r"(val), "r"(addr), "i"(ASI_PL));
}
static __inline__ void
xf86WriteMmio16BeNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- unsigned long addr = ((unsigned long)base) + offset;
+ unsigned long addr = ((unsigned long) base) + offset;
- __asm__ __volatile__("sth %0, [%1]"
- : /* No outputs */
- : "r" (val), "r" (addr));
+ __asm__ __volatile__("sth %0, [%1]": /* No outputs */
+ :"r"(val), "r"(addr));
}
static __inline__ void
xf86WriteMmio16LeNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- unsigned long addr = ((unsigned long)base) + offset;
+ unsigned long addr = ((unsigned long) base) + offset;
- __asm__ __volatile__("stha %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
+ __asm__ __volatile__("stha %0, [%1] %2": /* No outputs */
+ :"r"(val), "r"(addr), "i"(ASI_PL));
}
static __inline__ void
xf86WriteMmio32BeNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- unsigned long addr = ((unsigned long)base) + offset;
+ unsigned long addr = ((unsigned long) base) + offset;
- __asm__ __volatile__("st %0, [%1]"
- : /* No outputs */
- : "r" (val), "r" (addr));
+ __asm__ __volatile__("st %0, [%1]": /* No outputs */
+ :"r"(val), "r"(addr));
}
static __inline__ void
xf86WriteMmio32LeNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- unsigned long addr = ((unsigned long)base) + offset;
+ unsigned long addr = ((unsigned long) base) + offset;
- __asm__ __volatile__("sta %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
+ __asm__ __volatile__("sta %0, [%1] %2": /* No outputs */
+ :"r"(val), "r"(addr), "i"(ASI_PL));
}
-# elif defined(__mips__) || (defined(__arm32__) && !defined(__linux__))
-# ifdef __arm32__
-# define PORT_SIZE long
-# else
-# define PORT_SIZE short
-# endif
+#elif defined(__mips__) || (defined(__arm32__) && !defined(__linux__))
+#ifdef __arm32__
+#define PORT_SIZE long
+#else
+#define PORT_SIZE short
+#endif
-_X_EXPORT unsigned int IOPortBase; /* Memory mapped I/O port area */
+_X_EXPORT unsigned int IOPortBase; /* Memory mapped I/O port area */
static __inline__ void
outb(unsigned PORT_SIZE port, unsigned char val)
{
- *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
+ *(volatile unsigned char *) (((unsigned PORT_SIZE) (port)) + IOPortBase) =
+ val;
}
static __inline__ void
outw(unsigned PORT_SIZE port, unsigned short val)
{
- *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
+ *(volatile unsigned short *) (((unsigned PORT_SIZE) (port)) + IOPortBase) =
+ val;
}
static __inline__ void
outl(unsigned PORT_SIZE port, unsigned int val)
{
- *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
+ *(volatile unsigned int *) (((unsigned PORT_SIZE) (port)) + IOPortBase) =
+ val;
}
static __inline__ unsigned int
inb(unsigned PORT_SIZE port)
{
- return *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase);
+ return *(volatile unsigned char *) (((unsigned PORT_SIZE) (port)) +
+ IOPortBase);
}
static __inline__ unsigned int
inw(unsigned PORT_SIZE port)
{
- return *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase);
+ return *(volatile unsigned short *) (((unsigned PORT_SIZE) (port)) +
+ IOPortBase);
}
static __inline__ unsigned int
inl(unsigned PORT_SIZE port)
{
- return *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase);
+ return *(volatile unsigned int *) (((unsigned PORT_SIZE) (port)) +
+ IOPortBase);
}
-
-# if defined(__mips__)
-# ifdef linux /* don't mess with other OSs */
-# if X_BYTE_ORDER == X_BIG_ENDIAN
+#if defined(__mips__)
+#ifdef linux /* don't mess with other OSs */
+#if X_BYTE_ORDER == X_BIG_ENDIAN
static __inline__ unsigned int
xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned int ret;
+ unsigned long addr = ((unsigned long) base) + offset;
+ unsigned int ret;
- __asm__ __volatile__("lw %0, 0(%1)"
- : "=r" (ret)
- : "r" (addr));
- return ret;
+ __asm__ __volatile__("lw %0, 0(%1)":"=r"(ret)
+ :"r"(addr));
+
+ return ret;
}
static __inline__ void
xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- unsigned long addr = ((unsigned long)base) + offset;
+ unsigned long addr = ((unsigned long) base) + offset;
- __asm__ __volatile__("sw %0, 0(%1)"
- : /* No outputs */
- : "r" (val), "r" (addr));
+ __asm__ __volatile__("sw %0, 0(%1)": /* No outputs */
+ :"r"(val), "r"(addr));
}
-# endif
-# endif /* !linux */
-# endif /* __mips__ */
+#endif
+#endif /* !linux */
+#endif /* __mips__ */
-# elif (defined(linux) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)) && defined(__powerpc__)
+#elif (defined(linux) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)) && defined(__powerpc__)
-# ifndef MAP_FAILED
-# define MAP_FAILED ((void *)-1)
-# endif
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
extern _X_EXPORT volatile unsigned char *ioBase;
static __inline__ unsigned char
xf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
{
- register unsigned char val;
- __asm__ __volatile__(
- "lbzx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (base), "r" (offset),
- "m" (*((volatile unsigned char *)base+offset)));
- return val;
+ register unsigned char val;
+ __asm__ __volatile__("lbzx %0,%1,%2\n\t" "eieio":"=r"(val)
+ :"b"(base), "r"(offset),
+ "m"(*((volatile unsigned char *) base + offset)));
+ return val;
}
static __inline__ unsigned short
xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset)
{
- register unsigned short val;
- __asm__ __volatile__(
- "lhzx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (base), "r" (offset),
- "m" (*((volatile unsigned char *)base+offset)));
- return val;
+ register unsigned short val;
+ __asm__ __volatile__("lhzx %0,%1,%2\n\t" "eieio":"=r"(val)
+ :"b"(base), "r"(offset),
+ "m"(*((volatile unsigned char *) base + offset)));
+ return val;
}
static __inline__ unsigned short
xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset)
{
- register unsigned short val;
- __asm__ __volatile__(
- "lhbrx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (base), "r" (offset),
- "m" (*((volatile unsigned char *)base+offset)));
- return val;
+ register unsigned short val;
+ __asm__ __volatile__("lhbrx %0,%1,%2\n\t" "eieio":"=r"(val)
+ :"b"(base), "r"(offset),
+ "m"(*((volatile unsigned char *) base + offset)));
+ return val;
}
static __inline__ unsigned int
xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
{
- register unsigned int val;
- __asm__ __volatile__(
- "lwzx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (base), "r" (offset),
- "m" (*((volatile unsigned char *)base+offset)));
- return val;
+ register unsigned int val;
+ __asm__ __volatile__("lwzx %0,%1,%2\n\t" "eieio":"=r"(val)
+ :"b"(base), "r"(offset),
+ "m"(*((volatile unsigned char *) base + offset)));
+ return val;
}
static __inline__ unsigned int
xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
{
- register unsigned int val;
- __asm__ __volatile__(
- "lwbrx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (base), "r" (offset),
- "m" (*((volatile unsigned char *)base+offset)));
- return val;
+ register unsigned int val;
+ __asm__ __volatile__("lwbrx %0,%1,%2\n\t" "eieio":"=r"(val)
+ :"b"(base), "r"(offset),
+ "m"(*((volatile unsigned char *) base + offset)));
+ return val;
}
static __inline__ void
xf86WriteMmioNB8(__volatile__ void *base, const unsigned long offset,
- const unsigned char val)
+ const unsigned char val)
{
- __asm__ __volatile__(
- "stbx %1,%2,%3\n\t"
- : "=m" (*((volatile unsigned char *)base+offset))
- : "r" (val), "b" (base), "r" (offset));
+ __asm__
+ __volatile__("stbx %1,%2,%3\n\t":"=m"
+ (*((volatile unsigned char *) base + offset))
+ :"r"(val), "b"(base), "r"(offset));
}
static __inline__ void
xf86WriteMmioNB16Le(__volatile__ void *base, const unsigned long offset,
- const unsigned short val)
+ const unsigned short val)
{
- __asm__ __volatile__(
- "sthbrx %1,%2,%3\n\t"
- : "=m" (*((volatile unsigned char *)base+offset))
- : "r" (val), "b" (base), "r" (offset));
+ __asm__
+ __volatile__("sthbrx %1,%2,%3\n\t":"=m"
+ (*((volatile unsigned char *) base + offset))
+ :"r"(val), "b"(base), "r"(offset));
}
static __inline__ void
xf86WriteMmioNB16Be(__volatile__ void *base, const unsigned long offset,
- const unsigned short val)
+ const unsigned short val)
{
- __asm__ __volatile__(
- "sthx %1,%2,%3\n\t"
- : "=m" (*((volatile unsigned char *)base+offset))
- : "r" (val), "b" (base), "r" (offset));
+ __asm__
+ __volatile__("sthx %1,%2,%3\n\t":"=m"
+ (*((volatile unsigned char *) base + offset))
+ :"r"(val), "b"(base), "r"(offset));
}
static __inline__ void
xf86WriteMmioNB32Le(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- __asm__ __volatile__(
- "stwbrx %1,%2,%3\n\t"
- : "=m" (*((volatile unsigned char *)base+offset))
- : "r" (val), "b" (base), "r" (offset));
+ __asm__
+ __volatile__("stwbrx %1,%2,%3\n\t":"=m"
+ (*((volatile unsigned char *) base + offset))
+ :"r"(val), "b"(base), "r"(offset));
}
static __inline__ void
xf86WriteMmioNB32Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- __asm__ __volatile__(
- "stwx %1,%2,%3\n\t"
- : "=m" (*((volatile unsigned char *)base+offset))
- : "r" (val), "b" (base), "r" (offset));
+ __asm__
+ __volatile__("stwx %1,%2,%3\n\t":"=m"
+ (*((volatile unsigned char *) base + offset))
+ :"r"(val), "b"(base), "r"(offset));
}
static __inline__ void
xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
const unsigned char val)
{
- xf86WriteMmioNB8(base, offset, val);
- eieio();
+ xf86WriteMmioNB8(base, offset, val);
+ eieio();
}
static __inline__ void
xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
const unsigned short val)
{
- xf86WriteMmioNB16Le(base, offset, val);
- eieio();
+ xf86WriteMmioNB16Le(base, offset, val);
+ eieio();
}
static __inline__ void
xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
const unsigned short val)
{
- xf86WriteMmioNB16Be(base, offset, val);
- eieio();
+ xf86WriteMmioNB16Be(base, offset, val);
+ eieio();
}
static __inline__ void
xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
const unsigned int val)
{
- xf86WriteMmioNB32Le(base, offset, val);
- eieio();
+ xf86WriteMmioNB32Le(base, offset, val);
+ eieio();
}
static __inline__ void
xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
const unsigned int val)
{
- xf86WriteMmioNB32Be(base, offset, val);
- eieio();
+ xf86WriteMmioNB32Be(base, offset, val);
+ eieio();
}
-
static __inline__ void
outb(unsigned short port, unsigned char value)
{
- if(ioBase == MAP_FAILED) return;
- xf86WriteMmio8((void *)ioBase, port, value);
+ if (ioBase == MAP_FAILED)
+ return;
+ xf86WriteMmio8((void *) ioBase, port, value);
}
static __inline__ void
outw(unsigned short port, unsigned short value)
{
- if(ioBase == MAP_FAILED) return;
- xf86WriteMmio16Le((void *)ioBase, port, value);
+ if (ioBase == MAP_FAILED)
+ return;
+ xf86WriteMmio16Le((void *) ioBase, port, value);
}
static __inline__ void
outl(unsigned short port, unsigned int value)
{
- if(ioBase == MAP_FAILED) return;
- xf86WriteMmio32Le((void *)ioBase, port, value);
+ if (ioBase == MAP_FAILED)
+ return;
+ xf86WriteMmio32Le((void *) ioBase, port, value);
}
static __inline__ unsigned int
inb(unsigned short port)
{
- if(ioBase == MAP_FAILED) return 0;
- return xf86ReadMmio8((void *)ioBase, port);
+ if (ioBase == MAP_FAILED)
+ return 0;
+ return xf86ReadMmio8((void *) ioBase, port);
}
static __inline__ unsigned int
inw(unsigned short port)
{
- if(ioBase == MAP_FAILED) return 0;
- return xf86ReadMmio16Le((void *)ioBase, port);
+ if (ioBase == MAP_FAILED)
+ return 0;
+ return xf86ReadMmio16Le((void *) ioBase, port);
}
static __inline__ unsigned int
inl(unsigned short port)
{
- if(ioBase == MAP_FAILED) return 0;
- return xf86ReadMmio32Le((void *)ioBase, port);
+ if (ioBase == MAP_FAILED)
+ return 0;
+ return xf86ReadMmio32Le((void *) ioBase, port);
}
#elif defined(__arm__) && defined(__linux__)
@@ -999,7 +1008,7 @@ xf_outl(unsigned short port, unsigned int val)
#define outw xf_outw
#define outl xf_outl
-# elif defined(__nds32__)
+#elif defined(__nds32__)
/*
* Assume all port access are aligned. We need to revise this implementation
@@ -1007,352 +1016,326 @@ xf_outl(unsigned short port, unsigned int val)
* stw_u, they are assumed unaligned.
*/
-#define barrier() /* no barrier */
+#define barrier() /* no barrier */
#define PORT_SIZE long
static __inline__ unsigned char
xf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
{
- return *(volatile unsigned char *)((unsigned char *)base + offset) ;
+ return *(volatile unsigned char *) ((unsigned char *) base + offset);
}
static __inline__ void
xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- *(volatile unsigned char *)((unsigned char *)base + offset) = val ;
- barrier();
+ *(volatile unsigned char *) ((unsigned char *) base + offset) = val;
+ barrier();
}
static __inline__ void
xf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- *(volatile unsigned char *)((unsigned char *)base + offset) = val ;
+ *(volatile unsigned char *) ((unsigned char *) base + offset) = val;
}
static __inline__ unsigned short
xf86ReadMmio16Swap(__volatile__ void *base, const unsigned long offset)
{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned short ret;
+ unsigned long addr = ((unsigned long) base) + offset;
+ unsigned short ret;
- __asm__ __volatile__(
- "lhi %0, [%1];\n\t"
- "wsbh %0, %0;\n\t"
- : "=r" (ret)
- : "r" (addr));
- return ret;
+ __asm__ __volatile__("lhi %0, [%1];\n\t" "wsbh %0, %0;\n\t":"=r"(ret)
+ :"r"(addr));
+
+ return ret;
}
static __inline__ unsigned short
xf86ReadMmio16(__volatile__ void *base, const unsigned long offset)
{
- return *(volatile unsigned short *)((char *)base + offset) ;
+ return *(volatile unsigned short *) ((char *) base + offset);
}
static __inline__ void
xf86WriteMmio16Swap(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- unsigned long addr = ((unsigned long)base) + offset;
+ unsigned long addr = ((unsigned long) base) + offset;
+
+ __asm__ __volatile__("wsbh %0, %0;\n\t" "shi %0, [%1];\n\t": /* No outputs */
+ :"r"(val), "r"(addr));
- __asm__ __volatile__(
- "wsbh %0, %0;\n\t"
- "shi %0, [%1];\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
- barrier();
+ barrier();
}
static __inline__ void
xf86WriteMmio16(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- *(volatile unsigned short *)((unsigned char *)base + offset) = val ;
- barrier();
+ *(volatile unsigned short *) ((unsigned char *) base + offset) = val;
+ barrier();
}
static __inline__ void
xf86WriteMmio16SwapNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- unsigned long addr = ((unsigned long)base) + offset;
+ unsigned long addr = ((unsigned long) base) + offset;
- __asm__ __volatile__(
- "wsbh %0, %0;\n\t"
- "shi %0, [%1];\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
+ __asm__ __volatile__("wsbh %0, %0;\n\t" "shi %0, [%1];\n\t": /* No outputs */
+ :"r"(val), "r"(addr));
}
static __inline__ void
xf86WriteMmio16NB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- *(volatile unsigned short *)((unsigned char *)base + offset) = val ;
+ *(volatile unsigned short *) ((unsigned char *) base + offset) = val;
}
static __inline__ unsigned int
xf86ReadMmio32Swap(__volatile__ void *base, const unsigned long offset)
{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned int ret;
+ unsigned long addr = ((unsigned long) base) + offset;
+ unsigned int ret;
+
+ __asm__ __volatile__("lwi %0, [%1];\n\t"
+ "wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t":"=r"(ret)
+ :"r"(addr));
- __asm__ __volatile__(
- "lwi %0, [%1];\n\t"
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- : "=r" (ret)
- : "r" (addr));
- return ret;
+ return ret;
}
static __inline__ unsigned int
xf86ReadMmio32(__volatile__ void *base, const unsigned long offset)
{
- return *(volatile unsigned int *)((unsigned char *)base + offset) ;
+ return *(volatile unsigned int *) ((unsigned char *) base + offset);
}
static __inline__ void
xf86WriteMmio32Swap(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- unsigned long addr = ((unsigned long)base) + offset;
+ unsigned long addr = ((unsigned long) base) + offset;
- __asm__ __volatile__(
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- "swi %0, [%1];\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
- barrier();
+ __asm__ __volatile__("wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t" "swi %0, [%1];\n\t": /* No outputs */
+ :"r"(val), "r"(addr));
+
+ barrier();
}
static __inline__ void
xf86WriteMmio32(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- *(volatile unsigned int *)((unsigned char *)base + offset) = val ;
- barrier();
+ *(volatile unsigned int *) ((unsigned char *) base + offset) = val;
+ barrier();
}
static __inline__ void
xf86WriteMmio32SwapNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- unsigned long addr = ((unsigned long)base) + offset;
+ unsigned long addr = ((unsigned long) base) + offset;
- __asm__ __volatile__(
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- "swi %0, [%1];\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
+ __asm__ __volatile__("wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t" "swi %0, [%1];\n\t": /* No outputs */
+ :"r"(val), "r"(addr));
}
static __inline__ void
xf86WriteMmio32NB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+ const unsigned int val)
{
- *(volatile unsigned int *)((unsigned char *)base + offset) = val ;
+ *(volatile unsigned int *) ((unsigned char *) base + offset) = val;
}
-# if defined(NDS32_MMIO_SWAP)
+#if defined(NDS32_MMIO_SWAP)
static __inline__ void
outb(unsigned PORT_SIZE port, unsigned char val)
{
- xf86WriteMmio8(IOPortBase, port, val);
+ xf86WriteMmio8(IOPortBase, port, val);
}
static __inline__ void
outw(unsigned PORT_SIZE port, unsigned short val)
{
- xf86WriteMmio16Swap(IOPortBase, port, val);
+ xf86WriteMmio16Swap(IOPortBase, port, val);
}
static __inline__ void
outl(unsigned PORT_SIZE port, unsigned int val)
{
- xf86WriteMmio32Swap(IOPortBase, port, val);
+ xf86WriteMmio32Swap(IOPortBase, port, val);
}
static __inline__ unsigned int
inb(unsigned PORT_SIZE port)
{
- return xf86ReadMmio8(IOPortBase, port);
+ return xf86ReadMmio8(IOPortBase, port);
}
static __inline__ unsigned int
inw(unsigned PORT_SIZE port)
{
- return xf86ReadMmio16Swap(IOPortBase, port);
+ return xf86ReadMmio16Swap(IOPortBase, port);
}
static __inline__ unsigned int
inl(unsigned PORT_SIZE port)
{
- return xf86ReadMmio32Swap(IOPortBase, port);
+ return xf86ReadMmio32Swap(IOPortBase, port);
}
-static __inline__ unsigned long ldq_u(unsigned long *p)
+static __inline__ unsigned long
+ldq_u(unsigned long *p)
{
- unsigned long addr = (unsigned long)p;
- unsigned int ret;
+ unsigned long addr = (unsigned long) p;
+ unsigned int ret;
+
+ __asm__ __volatile__("lmw.bi %0, [%1], %0, 0;\n\t"
+ "wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t":"=r"(ret)
+ :"r"(addr));
- __asm__ __volatile__(
- "lmw.bi %0, [%1], %0, 0;\n\t"
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- : "=r" (ret)
- : "r" (addr));
- return ret;
+ return ret;
}
-static __inline__ unsigned long ldl_u(unsigned int *p)
+static __inline__ unsigned long
+ldl_u(unsigned int *p)
{
- unsigned long addr = (unsigned long)p;
- unsigned int ret;
+ unsigned long addr = (unsigned long) p;
+ unsigned int ret;
- __asm__ __volatile__(
- "lmw.bi %0, [%1], %0, 0;\n\t"
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- : "=r" (ret)
- : "r" (addr));
- return ret;
+ __asm__ __volatile__("lmw.bi %0, [%1], %0, 0;\n\t"
+ "wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t":"=r"(ret)
+ :"r"(addr));
+
+ return ret;
}
-static __inline__ void stq_u(unsigned long val, unsigned long *p)
+static __inline__ void
+stq_u(unsigned long val, unsigned long *p)
{
- unsigned long addr = (unsigned long)p;
+ unsigned long addr = (unsigned long) p;
- __asm__ __volatile__(
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- "smw.bi %0, [%1], %0, 0;\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
+ __asm__ __volatile__("wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t" "smw.bi %0, [%1], %0, 0;\n\t": /* No outputs */
+ :"r"(val), "r"(addr));
}
-static __inline__ void stl_u(unsigned long val, unsigned int *p)
+static __inline__ void
+stl_u(unsigned long val, unsigned int *p)
{
- unsigned long addr = (unsigned long)p;
+ unsigned long addr = (unsigned long) p;
- __asm__ __volatile__(
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- "smw.bi %0, [%1], %0, 0;\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
+ __asm__ __volatile__("wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t" "smw.bi %0, [%1], %0, 0;\n\t": /* No outputs */
+ :"r"(val), "r"(addr));
}
-# else /* !NDS32_MMIO_SWAP */
+#else /* !NDS32_MMIO_SWAP */
static __inline__ void
outb(unsigned PORT_SIZE port, unsigned char val)
{
- *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))) = val;
- barrier();
+ *(volatile unsigned char *) (((unsigned PORT_SIZE) (port))) = val;
+ barrier();
}
static __inline__ void
outw(unsigned PORT_SIZE port, unsigned short val)
{
- *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))) = val;
- barrier();
+ *(volatile unsigned short *) (((unsigned PORT_SIZE) (port))) = val;
+ barrier();
}
static __inline__ void
outl(unsigned PORT_SIZE port, unsigned int val)
{
- *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))) = val;
- barrier();
+ *(volatile unsigned int *) (((unsigned PORT_SIZE) (port))) = val;
+ barrier();
}
+
static __inline__ unsigned int
inb(unsigned PORT_SIZE port)
{
- return *(volatile unsigned char*)(((unsigned PORT_SIZE)(port)));
+ return *(volatile unsigned char *) (((unsigned PORT_SIZE) (port)));
}
static __inline__ unsigned int
inw(unsigned PORT_SIZE port)
{
- return *(volatile unsigned short*)(((unsigned PORT_SIZE)(port)));
+ return *(volatile unsigned short *) (((unsigned PORT_SIZE) (port)));
}
static __inline__ unsigned int
inl(unsigned PORT_SIZE port)
{
- return *(volatile unsigned int*)(((unsigned PORT_SIZE)(port)));
+ return *(volatile unsigned int *) (((unsigned PORT_SIZE) (port)));
}
-static __inline__ unsigned long ldq_u(unsigned long *p)
+static __inline__ unsigned long
+ldq_u(unsigned long *p)
{
- unsigned long addr = (unsigned long)p;
- unsigned int ret;
+ unsigned long addr = (unsigned long) p;
+ unsigned int ret;
- __asm__ __volatile__(
- "lmw.bi %0, [%1], %0, 0;\n\t"
- : "=r" (ret)
- : "r" (addr));
- return ret;
+ __asm__ __volatile__("lmw.bi %0, [%1], %0, 0;\n\t":"=r"(ret)
+ :"r"(addr));
+
+ return ret;
}
-static __inline__ unsigned long ldl_u(unsigned int *p)
+static __inline__ unsigned long
+ldl_u(unsigned int *p)
{
- unsigned long addr = (unsigned long)p;
- unsigned int ret;
+ unsigned long addr = (unsigned long) p;
+ unsigned int ret;
- __asm__ __volatile__(
- "lmw.bi %0, [%1], %0, 0;\n\t"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
+ __asm__ __volatile__("lmw.bi %0, [%1], %0, 0;\n\t":"=r"(ret)
+ :"r"(addr));
+ return ret;
+}
-static __inline__ void stq_u(unsigned long val, unsigned long *p)
+static __inline__ void
+stq_u(unsigned long val, unsigned long *p)
{
- unsigned long addr = (unsigned long)p;
+ unsigned long addr = (unsigned long) p;
- __asm__ __volatile__(
- "smw.bi %0, [%1], %0, 0;\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
+ __asm__ __volatile__("smw.bi %0, [%1], %0, 0;\n\t": /* No outputs */
+ :"r"(val), "r"(addr));
}
-static __inline__ void stl_u(unsigned long val, unsigned int *p)
+static __inline__ void
+stl_u(unsigned long val, unsigned int *p)
{
- unsigned long addr = (unsigned long)p;
+ unsigned long addr = (unsigned long) p;
- __asm__ __volatile__(
- "smw.bi %0, [%1], %0, 0;\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
+ __asm__ __volatile__("smw.bi %0, [%1], %0, 0;\n\t": /* No outputs */
+ :"r"(val), "r"(addr));
}
-# endif /* NDS32_MMIO_SWAP */
+#endif /* NDS32_MMIO_SWAP */
-# if (((X_BYTE_ORDER == X_BIG_ENDIAN) && !defined(NDS32_MMIO_SWAP)) || ((X_BYTE_ORDER != X_BIG_ENDIAN) && defined(NDS32_MMIO_SWAP)))
-# define ldw_u(p) ((*(unsigned char *)(p)) << 8 | \
+#if (((X_BYTE_ORDER == X_BIG_ENDIAN) && !defined(NDS32_MMIO_SWAP)) || ((X_BYTE_ORDER != X_BIG_ENDIAN) && defined(NDS32_MMIO_SWAP)))
+#define ldw_u(p) ((*(unsigned char *)(p)) << 8 | \
(*((unsigned char *)(p)+1)))
-# define stw_u(v,p) (*(unsigned char *)(p)) = ((v) >> 8); \
+#define stw_u(v,p) (*(unsigned char *)(p)) = ((v) >> 8); \
(*((unsigned char *)(p)+1)) = (v)
-# else
-# define ldw_u(p) ((*(unsigned char *)(p)) | \
+#else
+#define ldw_u(p) ((*(unsigned char *)(p)) | \
(*((unsigned char *)(p)+1)<<8))
-# define stw_u(v,p) (*(unsigned char *)(p)) = (v); \
+#define stw_u(v,p) (*(unsigned char *)(p)) = (v); \
(*((unsigned char *)(p)+1)) = ((v) >> 8)
-# endif
+#endif
-# define mem_barrier() /* XXX: nop for now */
-# define write_mem_barrier() /* XXX: nop for now */
+#define mem_barrier() /* XXX: nop for now */
+#define write_mem_barrier() /* XXX: nop for now */
-# else /* ix86 */
+#else /* ix86 */
-# if !defined(__SUNPRO_C)
-# if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__m32r__)
-# ifdef GCCUSESGAS
+#if !defined(__SUNPRO_C)
+#if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__m32r__)
+#ifdef GCCUSESGAS
/*
* If gcc uses gas rather than the native assembler, the syntax of these
@@ -1362,105 +1345,98 @@ static __inline__ void stl_u(unsigned long val, unsigned int *p)
static __inline__ void
outb(unsigned short port, unsigned char val)
{
- __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
+ __asm__ __volatile__("outb %0,%1"::"a"(val), "d"(port));
}
-
static __inline__ void
outw(unsigned short port, unsigned short val)
{
- __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
+ __asm__ __volatile__("outw %0,%1"::"a"(val), "d"(port));
}
static __inline__ void
outl(unsigned short port, unsigned int val)
{
- __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
+ __asm__ __volatile__("outl %0,%1"::"a"(val), "d"(port));
}
static __inline__ unsigned int
inb(unsigned short port)
{
- unsigned char ret;
- __asm__ __volatile__("inb %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
+ unsigned char ret;
+ __asm__ __volatile__("inb %1,%0":"=a"(ret):"d"(port));
+
+ return ret;
}
static __inline__ unsigned int
inw(unsigned short port)
{
- unsigned short ret;
- __asm__ __volatile__("inw %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
+ unsigned short ret;
+ __asm__ __volatile__("inw %1,%0":"=a"(ret):"d"(port));
+
+ return ret;
}
static __inline__ unsigned int
inl(unsigned short port)
{
- unsigned int ret;
- __asm__ __volatile__("inl %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
+ unsigned int ret;
+ __asm__ __volatile__("inl %1,%0":"=a"(ret):"d"(port));
+
+ return ret;
}
-# else /* GCCUSESGAS */
+#else /* GCCUSESGAS */
static __inline__ void
outb(unsigned short port, unsigned char val)
{
- __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port));
+ __asm__ __volatile__("out%B0 (%1)"::"a"(val), "d"(port));
}
static __inline__ void
outw(unsigned short port, unsigned short val)
{
- __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port));
+ __asm__ __volatile__("out%W0 (%1)"::"a"(val), "d"(port));
}
static __inline__ void
outl(unsigned short port, unsigned int val)
{
- __asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port));
+ __asm__ __volatile__("out%L0 (%1)"::"a"(val), "d"(port));
}
static __inline__ unsigned int
inb(unsigned short port)
{
- unsigned char ret;
- __asm__ __volatile__("in%B0 (%1)" :
- "=a" (ret) :
- "d" (port));
- return ret;
+ unsigned char ret;
+ __asm__ __volatile__("in%B0 (%1)":"=a"(ret):"d"(port));
+
+ return ret;
}
static __inline__ unsigned int
inw(unsigned short port)
{
- unsigned short ret;
- __asm__ __volatile__("in%W0 (%1)" :
- "=a" (ret) :
- "d" (port));
- return ret;
+ unsigned short ret;
+ __asm__ __volatile__("in%W0 (%1)":"=a"(ret):"d"(port));
+
+ return ret;
}
static __inline__ unsigned int
inl(unsigned short port)
{
- unsigned int ret;
- __asm__ __volatile__("in%L0 (%1)" :
- "=a" (ret) :
- "d" (port));
- return ret;
+ unsigned int ret;
+ __asm__ __volatile__("in%L0 (%1)":"=a"(ret):"d"(port));
+
+ return ret;
}
-# endif /* GCCUSESGAS */
+#endif /* GCCUSESGAS */
-# else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__m32r__) */
+#else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__m32r__) */
static __inline__ void
outb(unsigned short port, unsigned char val)
@@ -1480,141 +1456,143 @@ outl(unsigned short port, unsigned int val)
static __inline__ unsigned int
inb(unsigned short port)
{
- return 0;
+ return 0;
}
static __inline__ unsigned int
inw(unsigned short port)
{
- return 0;
+ return 0;
}
static __inline__ unsigned int
inl(unsigned short port)
{
- return 0;
+ return 0;
}
-# endif /* FAKEIT */
-# endif /* __SUNPRO_C */
+#endif /* FAKEIT */
+#endif /* __SUNPRO_C */
-# endif /* ix86 */
+#endif /* ix86 */
-# else /* !GNUC */
-# if defined(__STDC__) && (__STDC__ == 1)
-# ifndef asm
-# define asm __asm
-# endif
-# endif
-# if !defined(__SUNPRO_C)
-# include <sys/inline.h>
-# endif
-# if !defined(__HIGHC__) && !defined(__SUNPRO_C) || \
+#else /* !GNUC */
+#if defined(__STDC__) && (__STDC__ == 1)
+#ifndef asm
+#define asm __asm
+#endif
+#endif
+#if !defined(__SUNPRO_C)
+#include <sys/inline.h>
+#endif
+#if !defined(__HIGHC__) && !defined(__SUNPRO_C) || \
defined(__USLC__)
-# pragma asm partial_optimization outl
-# pragma asm partial_optimization outw
-# pragma asm partial_optimization outb
-# pragma asm partial_optimization inl
-# pragma asm partial_optimization inw
-# pragma asm partial_optimization inb
-# endif
-# endif /* __GNUC__ */
-
-# endif /* NO_INLINE */
-
-# ifdef __alpha__
+#pragma asm partial_optimization outl
+#pragma asm partial_optimization outw
+#pragma asm partial_optimization outb
+#pragma asm partial_optimization inl
+#pragma asm partial_optimization inw
+#pragma asm partial_optimization inb
+#endif
+#endif /* __GNUC__ */
+
+#endif /* NO_INLINE */
+
+#ifdef __alpha__
/* entry points for Mmio memory access routines */
-extern _X_EXPORT int (*xf86ReadMmio8)(void *, unsigned long);
-extern _X_EXPORT int (*xf86ReadMmio16)(void *, unsigned long);
-# ifndef STANDALONE_MMIO
-extern _X_EXPORT int (*xf86ReadMmio32)(void *, unsigned long);
-# else
+extern _X_EXPORT int (*xf86ReadMmio8) (void *, unsigned long);
+extern _X_EXPORT int (*xf86ReadMmio16) (void *, unsigned long);
+
+#ifndef STANDALONE_MMIO
+extern _X_EXPORT int (*xf86ReadMmio32) (void *, unsigned long);
+#else
/* Some DRI 3D drivers need MMIO_IN32. */
static __inline__ int
xf86ReadMmio32(void *Base, unsigned long Offset)
{
- mem_barrier();
- return *(volatile unsigned int*)((unsigned long)Base+(Offset));
-}
-# endif
-extern _X_EXPORT void (*xf86WriteMmio8)(int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmio16)(int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmio32)(int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmioNB8)(int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmioNB16)(int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmioNB32)(int, void *, unsigned long);
-extern _X_EXPORT void xf86SlowBCopyFromBus(unsigned char *, unsigned char *, int);
+ mem_barrier();
+ return *(volatile unsigned int *) ((unsigned long) Base + (Offset));
+}
+#endif
+extern _X_EXPORT void (*xf86WriteMmio8) (int, void *, unsigned long);
+extern _X_EXPORT void (*xf86WriteMmio16) (int, void *, unsigned long);
+extern _X_EXPORT void (*xf86WriteMmio32) (int, void *, unsigned long);
+extern _X_EXPORT void (*xf86WriteMmioNB8) (int, void *, unsigned long);
+extern _X_EXPORT void (*xf86WriteMmioNB16) (int, void *, unsigned long);
+extern _X_EXPORT void (*xf86WriteMmioNB32) (int, void *, unsigned long);
+extern _X_EXPORT void xf86SlowBCopyFromBus(unsigned char *, unsigned char *,
+ int);
extern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int);
/* Some macros to hide the system dependencies for MMIO accesses */
/* Changed to kill noise generated by gcc's -Wcast-align */
-# define MMIO_IN8(base, offset) (*xf86ReadMmio8)(base, offset)
-# define MMIO_IN16(base, offset) (*xf86ReadMmio16)(base, offset)
-# ifndef STANDALONE_MMIO
-# define MMIO_IN32(base, offset) (*xf86ReadMmio32)(base, offset)
-# else
-# define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset)
-# endif
-
-# define MMIO_OUT32(base, offset, val) \
+#define MMIO_IN8(base, offset) (*xf86ReadMmio8)(base, offset)
+#define MMIO_IN16(base, offset) (*xf86ReadMmio16)(base, offset)
+#ifndef STANDALONE_MMIO
+#define MMIO_IN32(base, offset) (*xf86ReadMmio32)(base, offset)
+#else
+#define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset)
+#endif
+
+#define MMIO_OUT32(base, offset, val) \
do { \
write_mem_barrier(); \
*(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val); \
} while (0)
-# define MMIO_ONB32(base, offset, val) \
+#define MMIO_ONB32(base, offset, val) \
*(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
-# define MMIO_OUT8(base, offset, val) \
+#define MMIO_OUT8(base, offset, val) \
(*xf86WriteMmio8)((CARD8)(val), base, offset)
-# define MMIO_OUT16(base, offset, val) \
+#define MMIO_OUT16(base, offset, val) \
(*xf86WriteMmio16)((CARD16)(val), base, offset)
-# define MMIO_ONB8(base, offset, val) \
+#define MMIO_ONB8(base, offset, val) \
(*xf86WriteMmioNB8)((CARD8)(val), base, offset)
-# define MMIO_ONB16(base, offset, val) \
+#define MMIO_ONB16(base, offset, val) \
(*xf86WriteMmioNB16)((CARD16)(val), base, offset)
-# define MMIO_MOVE32(base, offset, val) \
+#define MMIO_MOVE32(base, offset, val) \
MMIO_OUT32(base, offset, val)
-# elif defined(__powerpc__)
+#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) \
+#define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
+#define MMIO_OUT8(base, offset, val) \
xf86WriteMmio8(base, offset, (CARD8)(val))
-# define MMIO_ONB8(base, offset, val) \
+#define MMIO_ONB8(base, offset, val) \
xf86WriteMmioNB8(base, offset, (CARD8)(val))
-# if defined(PPC_MMIO_IS_BE) /* No byteswapping */
-# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
-# define MMIO_OUT16(base, offset, val) \
+#if defined(PPC_MMIO_IS_BE) /* No byteswapping */
+#define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
+#define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
+#define MMIO_OUT16(base, offset, val) \
xf86WriteMmio16Be(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
+#define MMIO_OUT32(base, offset, val) \
xf86WriteMmio32Be(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
+#define MMIO_ONB16(base, offset, val) \
xf86WriteMmioNB16Be(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
+#define MMIO_ONB32(base, offset, val) \
xf86WriteMmioNB32Be(base, offset, (CARD32)(val))
-# else /* byteswapping is the default */
-# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
-# define MMIO_OUT16(base, offset, val) \
+#else /* byteswapping is the default */
+#define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
+#define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
+#define MMIO_OUT16(base, offset, val) \
xf86WriteMmio16Le(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
+#define MMIO_OUT32(base, offset, val) \
xf86WriteMmio32Le(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
+#define MMIO_ONB16(base, offset, val) \
xf86WriteMmioNB16Le(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
+#define MMIO_ONB32(base, offset, val) \
xf86WriteMmioNB32Le(base, offset, (CARD32)(val))
-# endif
+#endif
-# define MMIO_MOVE32(base, offset, val) \
+#define MMIO_MOVE32(base, offset, val) \
xf86WriteMmio32Be(base, offset, (CARD32)(val))
-# elif defined(__sparc__) || defined(sparc) || defined(__sparc)
+#elif defined(__sparc__) || defined(sparc) || defined(__sparc)
/*
* Like powerpc, we provide byteswapping and no byteswapping functions
* here with byteswapping as default, drivers that don't need byteswapping
@@ -1622,133 +1600,129 @@ extern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int);
* do not need to use PPC_MMIO_IS_BE and the sparc one in all the same places
* of drivers?).
*/
-# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
-# define MMIO_OUT8(base, offset, val) \
+#define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
+#define MMIO_OUT8(base, offset, val) \
xf86WriteMmio8(base, offset, (CARD8)(val))
-# define MMIO_ONB8(base, offset, val) \
+#define MMIO_ONB8(base, offset, val) \
xf86WriteMmio8NB(base, offset, (CARD8)(val))
-# if defined(SPARC_MMIO_IS_BE) /* No byteswapping */
-# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
-# define MMIO_OUT16(base, offset, val) \
+#if defined(SPARC_MMIO_IS_BE) /* No byteswapping */
+#define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
+#define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
+#define MMIO_OUT16(base, offset, val) \
xf86WriteMmio16Be(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
+#define MMIO_OUT32(base, offset, val) \
xf86WriteMmio32Be(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
+#define MMIO_ONB16(base, offset, val) \
xf86WriteMmio16BeNB(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
+#define MMIO_ONB32(base, offset, val) \
xf86WriteMmio32BeNB(base, offset, (CARD32)(val))
-# else /* byteswapping is the default */
-# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
-# define MMIO_OUT16(base, offset, val) \
+#else /* byteswapping is the default */
+#define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
+#define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
+#define MMIO_OUT16(base, offset, val) \
xf86WriteMmio16Le(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
+#define MMIO_OUT32(base, offset, val) \
xf86WriteMmio32Le(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
+#define MMIO_ONB16(base, offset, val) \
xf86WriteMmio16LeNB(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
+#define MMIO_ONB32(base, offset, val) \
xf86WriteMmio32LeNB(base, offset, (CARD32)(val))
-# endif
+#endif
-# define MMIO_MOVE32(base, offset, val) \
+#define MMIO_MOVE32(base, offset, val) \
xf86WriteMmio32Be(base, offset, (CARD32)(val))
-# elif defined(__nds32__)
+#elif defined(__nds32__)
/*
* we provide byteswapping and no byteswapping functions here
* with no byteswapping as default; when endianness of CPU core
* and I/O devices don't match, byte swapping is necessary
* drivers that need byteswapping should define NDS32_MMIO_SWAP
*/
-# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
-# define MMIO_OUT8(base, offset, val) \
+#define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
+#define MMIO_OUT8(base, offset, val) \
xf86WriteMmio8(base, offset, (CARD8)(val))
-# define MMIO_ONB8(base, offset, val) \
+#define MMIO_ONB8(base, offset, val) \
xf86WriteMmioNB8(base, offset, (CARD8)(val))
-# if defined(NDS32_MMIO_SWAP) /* byteswapping */
-# define MMIO_IN16(base, offset) xf86ReadMmio16Swap(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32Swap(base, offset)
-# define MMIO_OUT16(base, offset, val) \
+#if defined(NDS32_MMIO_SWAP) /* byteswapping */
+#define MMIO_IN16(base, offset) xf86ReadMmio16Swap(base, offset)
+#define MMIO_IN32(base, offset) xf86ReadMmio32Swap(base, offset)
+#define MMIO_OUT16(base, offset, val) \
xf86WriteMmio16Swap(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
+#define MMIO_OUT32(base, offset, val) \
xf86WriteMmio32Swap(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
+#define MMIO_ONB16(base, offset, val) \
xf86WriteMmioNB16Swap(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
+#define MMIO_ONB32(base, offset, val) \
xf86WriteMmioNB32Swap(base, offset, (CARD32)(val))
-# else /* no byteswapping is the default */
-# define MMIO_IN16(base, offset) xf86ReadMmio16(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset)
-# define MMIO_OUT16(base, offset, val) \
+#else /* no byteswapping is the default */
+#define MMIO_IN16(base, offset) xf86ReadMmio16(base, offset)
+#define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset)
+#define MMIO_OUT16(base, offset, val) \
xf86WriteMmio16(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
+#define MMIO_OUT32(base, offset, val) \
xf86WriteMmio32(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
+#define MMIO_ONB16(base, offset, val) \
xf86WriteMmioNB16(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
+#define MMIO_ONB32(base, offset, val) \
xf86WriteMmioNB32(base, offset, (CARD32)(val))
-# endif
+#endif
-# define MMIO_MOVE32(base, offset, val) \
+#define MMIO_MOVE32(base, offset, val) \
xf86WriteMmio32(base, offset, (CARD32)(val))
-#ifdef N1213_HC /* for NDS32 N1213 hardcore */
-static __inline__ void nds32_flush_icache(char *addr)
+#ifdef N1213_HC /* for NDS32 N1213 hardcore */
+static __inline__ void
+nds32_flush_icache(char *addr)
{
- __asm__ volatile (
- "isync %0;"
- "msync;"
- "isb;"
- "cctl %0,L1I_VA_INVAL;"
- "isb;"
- : : "r"(addr) : "memory");
+ __asm__ volatile ("isync %0;"
+ "msync;"
+ "isb;"
+ "cctl %0,L1I_VA_INVAL;" "isb;"::"r" (addr):"memory");
}
#else
-static __inline__ void nds32_flush_icache(char *addr)
+static __inline__ void
+nds32_flush_icache(char *addr)
{
- __asm__ volatile (
- "isync %0;"
- "isb;"
- : : "r"(addr) : "memory");
+ __asm__ volatile ("isync %0;" "isb;"::"r" (addr):"memory");
}
#endif
-# else /* !__alpha__ && !__powerpc__ && !__sparc__ */
+#else /* !__alpha__ && !__powerpc__ && !__sparc__ */
-# define MMIO_IN8(base, offset) \
+#define MMIO_IN8(base, offset) \
*(volatile CARD8 *)(((CARD8*)(base)) + (offset))
-# define MMIO_IN16(base, offset) \
+#define MMIO_IN16(base, offset) \
*(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset))
-# define MMIO_IN32(base, offset) \
+#define MMIO_IN32(base, offset) \
*(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset))
-# define MMIO_OUT8(base, offset, val) \
+#define MMIO_OUT8(base, offset, val) \
*(volatile CARD8 *)(((CARD8*)(base)) + (offset)) = (val)
-# define MMIO_OUT16(base, offset, val) \
+#define MMIO_OUT16(base, offset, val) \
*(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
-# define MMIO_OUT32(base, offset, val) \
+#define MMIO_OUT32(base, offset, val) \
*(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
-# define MMIO_ONB8(base, offset, val) MMIO_OUT8(base, offset, val)
-# define MMIO_ONB16(base, offset, val) MMIO_OUT16(base, offset, val)
-# define MMIO_ONB32(base, offset, val) MMIO_OUT32(base, offset, val)
+#define MMIO_ONB8(base, offset, val) MMIO_OUT8(base, offset, val)
+#define MMIO_ONB16(base, offset, val) MMIO_OUT16(base, offset, val)
+#define MMIO_ONB32(base, offset, val) MMIO_OUT32(base, offset, val)
-# define MMIO_MOVE32(base, offset, val) MMIO_OUT32(base, offset, val)
+#define MMIO_MOVE32(base, offset, val) MMIO_OUT32(base, offset, val)
-# endif /* __alpha__ */
+#endif /* __alpha__ */
/*
* With Intel, the version in os-support/misc/SlowBcopy.s is used.
* This avoids port I/O during the copy (which causes problems with
* some hardware).
*/
-# ifdef __alpha__
-# define slowbcopy_tobus(src,dst,count) xf86SlowBCopyToBus(src,dst,count)
-# define slowbcopy_frombus(src,dst,count) xf86SlowBCopyFromBus(src,dst,count)
-# else /* __alpha__ */
-# define slowbcopy_tobus(src,dst,count) xf86SlowBcopy(src,dst,count)
-# define slowbcopy_frombus(src,dst,count) xf86SlowBcopy(src,dst,count)
-# endif /* __alpha__ */
-
-#endif /* _COMPILER_H */
+#ifdef __alpha__
+#define slowbcopy_tobus(src,dst,count) xf86SlowBCopyToBus(src,dst,count)
+#define slowbcopy_frombus(src,dst,count) xf86SlowBCopyFromBus(src,dst,count)
+#else /* __alpha__ */
+#define slowbcopy_tobus(src,dst,count) xf86SlowBcopy(src,dst,count)
+#define slowbcopy_frombus(src,dst,count) xf86SlowBcopy(src,dst,count)
+#endif /* __alpha__ */
+
+#endif /* _COMPILER_H */
diff --git a/xorg-server/hw/xfree86/common/vidmodeproc.h b/xorg-server/hw/xfree86/common/vidmodeproc.h
index da4d05e1c..aa43237d4 100644
--- a/xorg-server/hw/xfree86/common/vidmodeproc.h
+++ b/xorg-server/hw/xfree86/common/vidmodeproc.h
@@ -8,7 +8,6 @@
#ifndef _VIDMODEPROC_H_
#define _VIDMODEPROC_H_
-
typedef enum {
VIDMODE_H_DISPLAY,
VIDMODE_H_SYNCSTART,
@@ -35,17 +34,20 @@ typedef enum {
} VidModeSelectMonitor;
typedef union {
- pointer ptr;
- int i;
- float f;
+ pointer ptr;
+ int i;
+ float f;
} vidMonitorValue;
extern _X_EXPORT void XFree86VidModeExtensionInit(void);
extern _X_EXPORT Bool VidModeAvailable(int scrnIndex);
-extern _X_EXPORT Bool VidModeGetCurrentModeline(int scrnIndex, pointer *mode, int *dotClock);
-extern _X_EXPORT Bool VidModeGetFirstModeline(int scrnIndex, pointer *mode, int *dotClock);
-extern _X_EXPORT Bool VidModeGetNextModeline(int scrnIndex, pointer *mode, int *dotClock);
+extern _X_EXPORT Bool VidModeGetCurrentModeline(int scrnIndex, pointer *mode,
+ int *dotClock);
+extern _X_EXPORT Bool VidModeGetFirstModeline(int scrnIndex, pointer *mode,
+ int *dotClock);
+extern _X_EXPORT Bool VidModeGetNextModeline(int scrnIndex, pointer *mode,
+ int *dotClock);
extern _X_EXPORT Bool VidModeDeleteModeline(int scrnIndex, pointer mode);
extern _X_EXPORT Bool VidModeZoomViewport(int scrnIndex, int zoom);
extern _X_EXPORT Bool VidModeGetViewPort(int scrnIndex, int *x, int *y);
@@ -55,23 +57,28 @@ extern _X_EXPORT Bool VidModeLockZoom(int scrnIndex, Bool lock);
extern _X_EXPORT Bool VidModeGetMonitor(int scrnIndex, pointer *monitor);
extern _X_EXPORT int VidModeGetNumOfClocks(int scrnIndex, Bool *progClock);
extern _X_EXPORT Bool VidModeGetClocks(int scrnIndex, int *Clocks);
-extern _X_EXPORT ModeStatus VidModeCheckModeForMonitor(int scrnIndex, pointer mode);
-extern _X_EXPORT ModeStatus VidModeCheckModeForDriver(int scrnIndex, pointer mode);
+extern _X_EXPORT ModeStatus VidModeCheckModeForMonitor(int scrnIndex,
+ pointer mode);
+extern _X_EXPORT ModeStatus VidModeCheckModeForDriver(int scrnIndex,
+ pointer mode);
extern _X_EXPORT void VidModeSetCrtcForMode(int scrnIndex, pointer mode);
extern _X_EXPORT Bool VidModeAddModeline(int scrnIndex, pointer mode);
extern _X_EXPORT int VidModeGetDotClock(int scrnIndex, int Clock);
extern _X_EXPORT int VidModeGetNumOfModes(int scrnIndex);
-extern _X_EXPORT Bool VidModeSetGamma(int scrnIndex, float red, float green, float blue);
-extern _X_EXPORT Bool VidModeGetGamma(int scrnIndex, float *red, float *green, float *blue);
+extern _X_EXPORT Bool VidModeSetGamma(int scrnIndex, float red, float green,
+ float blue);
+extern _X_EXPORT Bool VidModeGetGamma(int scrnIndex, float *red, float *green,
+ float *blue);
extern _X_EXPORT pointer VidModeCreateMode(void);
extern _X_EXPORT void VidModeCopyMode(pointer modefrom, pointer modeto);
extern _X_EXPORT int VidModeGetModeValue(pointer mode, int valtyp);
extern _X_EXPORT void VidModeSetModeValue(pointer mode, int valtyp, int val);
-extern _X_EXPORT vidMonitorValue VidModeGetMonitorValue(pointer monitor, int valtyp, int indx);
-extern _X_EXPORT Bool VidModeSetGammaRamp(int, int, CARD16 *, CARD16 *, CARD16 *);
-extern _X_EXPORT Bool VidModeGetGammaRamp(int, int, CARD16 *, CARD16 *, CARD16 *);
+extern _X_EXPORT vidMonitorValue VidModeGetMonitorValue(pointer monitor,
+ int valtyp, int indx);
+extern _X_EXPORT Bool VidModeSetGammaRamp(int, int, CARD16 *, CARD16 *,
+ CARD16 *);
+extern _X_EXPORT Bool VidModeGetGammaRamp(int, int, CARD16 *, CARD16 *,
+ CARD16 *);
extern _X_EXPORT int VidModeGetGammaRampSize(int scrnIndex);
#endif
-
-
diff --git a/xorg-server/hw/xfree86/common/xf86.h b/xorg-server/hw/xfree86/common/xf86.h
index b711f0555..fc4c34e92 100644
--- a/xorg-server/hw/xfree86/common/xf86.h
+++ b/xorg-server/hw/xfree86/common/xf86.h
@@ -57,21 +57,24 @@ extern _X_EXPORT int xf86DoShowOptions;
extern _X_EXPORT Bool xf86DoConfigurePass1;
extern _X_EXPORT DevPrivateKeyRec xf86ScreenKeyRec;
+
#define xf86ScreenKey (&xf86ScreenKeyRec)
extern _X_EXPORT DevPrivateKeyRec xf86CreateRootWindowKeyRec;
+
#define xf86CreateRootWindowKey (&xf86CreateRootWindowKeyRec)
-extern _X_EXPORT ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */
+extern _X_EXPORT ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */
extern _X_EXPORT const unsigned char byte_reversed[256];
extern _X_EXPORT Bool fbSlotClaimed;
+
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
extern _X_EXPORT Bool sbusSlotClaimed;
#endif
extern _X_EXPORT confDRIRec xf86ConfigDRI;
extern _X_EXPORT Bool xf86DRI2Enabled(void);
-extern _X_EXPORT Bool VTSwitchEnabled; /* kbd driver */
+extern _X_EXPORT Bool VTSwitchEnabled; /* kbd driver */
#define XF86SCRNINFO(p) ((ScrnInfoPtr)dixLookupPrivate(&(p)->devPrivates, \
xf86ScreenKey))
@@ -104,20 +107,30 @@ extern _X_EXPORT Bool xf86ParsePciBusString(const char *busID, int *bus,
int *device, int *func);
extern _X_EXPORT Bool xf86ComparePciBusString(const char *busID, int bus,
int device, int func);
-extern _X_EXPORT Bool xf86IsPrimaryPci(struct pci_device * pPci);
-extern _X_EXPORT Bool xf86CheckPciMemBase(struct pci_device * pPci,
+extern _X_EXPORT Bool xf86IsPrimaryPci(struct pci_device *pPci);
+extern _X_EXPORT Bool xf86CheckPciMemBase(struct pci_device *pPci,
memType base);
-extern _X_EXPORT struct pci_device * xf86GetPciInfoForEntity(int entityIndex);
+extern _X_EXPORT struct pci_device *xf86GetPciInfoForEntity(int entityIndex);
extern _X_EXPORT int xf86MatchPciInstances(const char *driverName,
- int vendorID, SymTabPtr chipsets, PciChipsets *PCIchipsets,
- GDevPtr *devList, int numDevs, DriverPtr drvp, int **foundEntities);
+ int vendorID, SymTabPtr chipsets,
+ PciChipsets * PCIchipsets,
+ GDevPtr * devList, int numDevs,
+ DriverPtr drvp, int **foundEntities);
extern _X_EXPORT ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn,
- int scrnFlag, int entityIndex,PciChipsets *p_chip, void *dummy,
- EntityProc init, EntityProc enter, EntityProc leave, pointer private);
+ int scrnFlag, int entityIndex,
+ PciChipsets * p_chip,
+ void *dummy, EntityProc init,
+ EntityProc enter,
+ EntityProc leave,
+ pointer private);
/* Obsolete! don't use */
extern _X_EXPORT Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn,
- int entityIndex,PciChipsets *p_chip, void *dummy, EntityProc init,
- EntityProc enter, EntityProc leave, pointer private);
+ int entityIndex,
+ PciChipsets * p_chip,
+ void *dummy, EntityProc init,
+ EntityProc enter,
+ EntityProc leave,
+ pointer private);
#else
#define xf86VGAarbiterInit() do {} while (0)
#define xf86VGAarbiterFini() do {} while (0)
@@ -130,19 +143,24 @@ extern _X_EXPORT Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn,
/* xf86Bus.c */
-extern _X_EXPORT int xf86GetFbInfoForScreen(int scrnIndex);
-extern _X_EXPORT int xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
-extern _X_EXPORT int xf86ClaimNoSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
+extern _X_EXPORT int xf86GetFbInfoForScreen(int scrnIndex);
+extern _X_EXPORT int xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev,
+ Bool active);
+extern _X_EXPORT int xf86ClaimNoSlot(DriverPtr drvp, int chipset, GDevPtr dev,
+ Bool active);
extern _X_EXPORT Bool xf86DriverHasEntities(DriverPtr drvp);
extern _X_EXPORT void xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex);
-extern _X_EXPORT void xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex,
- int instance);
+extern _X_EXPORT void xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn,
+ int entityIndex,
+ int instance);
extern _X_EXPORT int xf86GetNumEntityInstances(int entityIndex);
extern _X_EXPORT GDevPtr xf86GetDevFromEntity(int entityIndex, int instance);
-extern _X_EXPORT void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex);
+extern _X_EXPORT void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn,
+ int entityIndex);
extern _X_EXPORT EntityInfoPtr xf86GetEntityInfo(int entityIndex);
extern _X_EXPORT Bool xf86SetEntityFuncs(int entityIndex, EntityProc init,
- EntityProc enter, EntityProc leave, pointer);
+ EntityProc enter, EntityProc leave,
+ pointer);
extern _X_EXPORT Bool xf86IsEntityPrimary(int entityIndex);
extern _X_EXPORT ScrnInfoPtr xf86FindScreenForEntity(int entityIndex);
@@ -159,8 +177,9 @@ extern _X_EXPORT int xf86AllocateEntityPrivateIndex(void);
extern _X_EXPORT DevUnion *xf86GetEntityPrivate(int entityIndex, int privIndex);
/* xf86Configure.c */
-extern _X_EXPORT GDevPtr xf86AddBusDeviceToConfigure(const char *driver, BusType bus,
- void *busData, int chipset);
+extern _X_EXPORT GDevPtr xf86AddBusDeviceToConfigure(const char *driver,
+ BusType bus, void *busData,
+ int chipset);
/* xf86Cursor.c */
@@ -174,56 +193,63 @@ extern _X_EXPORT void xf86InitOrigins(void);
extern _X_EXPORT void xf86ReconfigureLayout(void);
/* xf86cvt.c */
-extern _X_EXPORT DisplayModePtr xf86CVTMode(int HDisplay, int VDisplay, float VRefresh,
- Bool Reduced, Bool Interlaced);
+extern _X_EXPORT DisplayModePtr xf86CVTMode(int HDisplay, int VDisplay,
+ float VRefresh, Bool Reduced,
+ Bool Interlaced);
/* xf86DPMS.c */
-extern _X_EXPORT Bool xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags);
+extern _X_EXPORT Bool xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set,
+ int flags);
#ifdef DPMSExtension
extern _X_EXPORT int DPMSSet(ClientPtr client, int level);
extern _X_EXPORT Bool DPMSSupported(void);
#endif
-
/* xf86DGA.c */
#ifdef XFreeXDGA
-extern _X_EXPORT Bool DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs, DGAModePtr modes,
- int num);
-extern _X_EXPORT Bool DGAReInitModes(ScreenPtr pScreen, DGAModePtr modes, int num);
+extern _X_EXPORT Bool DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs,
+ DGAModePtr modes, int num);
+extern _X_EXPORT Bool DGAReInitModes(ScreenPtr pScreen, DGAModePtr modes,
+ int num);
extern _X_EXPORT xf86SetDGAModeProc xf86SetDGAMode;
#endif
/* xf86Events.c */
extern _X_EXPORT void SetTimeSinceLastInputEvent(void);
-extern _X_EXPORT pointer xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data);
+extern _X_EXPORT pointer xf86AddInputHandler(int fd, InputHandlerProc proc,
+ pointer data);
extern _X_EXPORT int xf86RemoveInputHandler(pointer handler);
extern _X_EXPORT void xf86DisableInputHandler(pointer handler);
extern _X_EXPORT void xf86EnableInputHandler(pointer handler);
-extern _X_EXPORT pointer xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data);
+extern _X_EXPORT pointer xf86AddGeneralHandler(int fd, InputHandlerProc proc,
+ pointer data);
extern _X_EXPORT int xf86RemoveGeneralHandler(pointer handler);
extern _X_EXPORT void xf86DisableGeneralHandler(pointer handler);
extern _X_EXPORT void xf86EnableGeneralHandler(pointer handler);
-extern _X_EXPORT InputHandlerProc xf86SetConsoleHandler(InputHandlerProc handler, pointer data);
+extern _X_EXPORT InputHandlerProc xf86SetConsoleHandler(InputHandlerProc
+ handler, pointer data);
extern _X_EXPORT void xf86InterceptSignals(int *signo);
-extern _X_EXPORT void xf86InterceptSigIll(void (*sigillhandler)(void));
+extern _X_EXPORT void xf86InterceptSigIll(void (*sigillhandler) (void));
extern _X_EXPORT Bool xf86EnableVTSwitch(Bool new);
extern _X_EXPORT void xf86ProcessActionEvent(ActionEvent action, void *arg);
extern _X_EXPORT void xf86PrintBacktrace(void);
/* xf86Helper.c */
-extern _X_EXPORT void xf86AddDriver(DriverPtr driver, pointer module, int flags);
+extern _X_EXPORT void xf86AddDriver(DriverPtr driver, pointer module,
+ int flags);
extern _X_EXPORT void xf86DeleteDriver(int drvIndex);
extern _X_EXPORT ScrnInfoPtr xf86AllocateScreen(DriverPtr drv, int flags);
extern _X_EXPORT void xf86DeleteScreen(int scrnIndex, int flags);
extern _X_EXPORT int xf86AllocateScrnInfoPrivateIndex(void);
-extern _X_EXPORT Bool xf86AddPixFormat(ScrnInfoPtr pScrn, int depth, int bpp, int pad);
-extern _X_EXPORT Bool xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int bpp, int fbbpp,
- int depth24flags);
+extern _X_EXPORT Bool xf86AddPixFormat(ScrnInfoPtr pScrn, int depth, int bpp,
+ int pad);
+extern _X_EXPORT Bool xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int bpp,
+ int fbbpp, int depth24flags);
extern _X_EXPORT void xf86PrintDepthBpp(ScrnInfoPtr scrp);
extern _X_EXPORT Bool xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask);
extern _X_EXPORT Bool xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual);
@@ -231,125 +257,198 @@ extern _X_EXPORT Bool xf86SetGamma(ScrnInfoPtr scrp, Gamma newGamma);
extern _X_EXPORT void xf86SetDpi(ScrnInfoPtr pScrn, int x, int y);
extern _X_EXPORT void xf86SetBlackWhitePixels(ScreenPtr pScreen);
extern _X_EXPORT void xf86EnableDisableFBAccess(int scrnIndex, Bool enable);
-extern _X_EXPORT void xf86VDrvMsgVerb(int scrnIndex, MessageType type, int verb,
- const char *format, va_list args) _X_ATTRIBUTE_PRINTF(4,0);
-extern _X_EXPORT void xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb,
- const char *format, ...) _X_ATTRIBUTE_PRINTF(4,5);
-extern _X_EXPORT void xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...)
- _X_ATTRIBUTE_PRINTF(3,4);
-extern _X_EXPORT void xf86MsgVerb(MessageType type, int verb, const char *format, ...)
- _X_ATTRIBUTE_PRINTF(3,4);
-extern _X_EXPORT void xf86Msg(MessageType type, const char *format, ...) _X_ATTRIBUTE_PRINTF(2,3);
-extern _X_EXPORT void xf86ErrorFVerb(int verb, const char *format, ...) _X_ATTRIBUTE_PRINTF(2,3);
-extern _X_EXPORT void xf86ErrorF(const char *format, ...) _X_ATTRIBUTE_PRINTF(1,2);
-extern _X_EXPORT const char *xf86TokenToString(SymTabPtr table, int token);
-extern _X_EXPORT int xf86StringToToken(SymTabPtr table, const char *string);
-extern _X_EXPORT void xf86ShowClocks(ScrnInfoPtr scrp, MessageType from);
-extern _X_EXPORT void xf86PrintChipsets(const char *drvname, const char *drvmsg,
- SymTabPtr chips);
-extern _X_EXPORT int xf86MatchDevice(const char *drivername, GDevPtr **driversectlist);
-extern _X_EXPORT const char *xf86GetVisualName(int visual);
-extern _X_EXPORT int xf86GetVerbosity(void);
-extern _X_EXPORT Pix24Flags xf86GetPix24(void);
-extern _X_EXPORT int xf86GetDepth(void);
-extern _X_EXPORT rgb xf86GetWeight(void);
-extern _X_EXPORT Gamma xf86GetGamma(void);
-extern _X_EXPORT Bool xf86GetFlipPixels(void);
-extern _X_EXPORT const char *xf86GetServerName(void);
-extern _X_EXPORT Bool xf86ServerIsExiting(void);
-extern _X_EXPORT Bool xf86ServerIsResetting(void);
-extern _X_EXPORT Bool xf86ServerIsInitialising(void);
-extern _X_EXPORT Bool xf86ServerIsOnlyDetecting(void);
-extern _X_EXPORT Bool xf86CaughtSignal(void);
-extern _X_EXPORT Bool xf86GetVidModeAllowNonLocal(void);
-extern _X_EXPORT Bool xf86GetVidModeEnabled(void);
-extern _X_EXPORT Bool xf86GetModInDevAllowNonLocal(void);
-extern _X_EXPORT Bool xf86GetModInDevEnabled(void);
-extern _X_EXPORT Bool xf86GetAllowMouseOpenFail(void);
-extern _X_EXPORT void xf86DisableRandR(void);
-extern _X_EXPORT CARD32 xorgGetVersion(void);
-extern _X_EXPORT CARD32 xf86GetModuleVersion(pointer module);
-extern _X_EXPORT pointer xf86LoadDrvSubModule(DriverPtr drv, const char *name);
-extern _X_EXPORT pointer xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name);
-extern _X_EXPORT pointer xf86LoadOneModule(char *name, pointer optlist);
-extern _X_EXPORT void xf86UnloadSubModule(pointer mod);
-extern _X_EXPORT Bool xf86LoaderCheckSymbol(const char *name);
-extern _X_EXPORT void xf86SetBackingStore(ScreenPtr pScreen);
-extern _X_EXPORT void xf86SetSilkenMouse(ScreenPtr pScreen);
-extern _X_EXPORT pointer xf86FindXvOptions(int scrnIndex, int adapt_index, char *port_name,
- char **adaptor_name, pointer *adaptor_options);
-extern _X_EXPORT void xf86GetOS(const char **name, int *major, int *minor, int *teeny);
-extern _X_EXPORT ScrnInfoPtr xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag,
- int entityIndex, EntityProc init,
- EntityProc enter, EntityProc leave,
- pointer private);
-
-extern _X_EXPORT Bool xf86IsScreenPrimary(int scrnIndex);
-extern _X_EXPORT int xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
- int format, unsigned long len,
- pointer value);
-extern _X_EXPORT Bool xf86IsUnblank(int mode);
+extern _X_EXPORT void
+xf86VDrvMsgVerb(int scrnIndex, MessageType type, int verb,
+ const char *format, va_list args)
+_X_ATTRIBUTE_PRINTF(4, 0);
+extern _X_EXPORT void
+xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb,
+ const char *format, ...)
+_X_ATTRIBUTE_PRINTF(4, 5);
+extern _X_EXPORT void
+xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...)
+_X_ATTRIBUTE_PRINTF(3, 4);
+extern _X_EXPORT void
+xf86MsgVerb(MessageType type, int verb, const char *format, ...)
+_X_ATTRIBUTE_PRINTF(3, 4);
+extern _X_EXPORT void
+xf86Msg(MessageType type, const char *format, ...)
+_X_ATTRIBUTE_PRINTF(2, 3);
+extern _X_EXPORT void
+xf86ErrorFVerb(int verb, const char *format, ...)
+_X_ATTRIBUTE_PRINTF(2, 3);
+extern _X_EXPORT void
+xf86ErrorF(const char *format, ...)
+_X_ATTRIBUTE_PRINTF(1, 2);
+extern _X_EXPORT const char *
+xf86TokenToString(SymTabPtr table, int token);
+extern _X_EXPORT int
+xf86StringToToken(SymTabPtr table, const char *string);
+extern _X_EXPORT void
+xf86ShowClocks(ScrnInfoPtr scrp, MessageType from);
+extern _X_EXPORT void
+xf86PrintChipsets(const char *drvname, const char *drvmsg, SymTabPtr chips);
+extern _X_EXPORT int
+xf86MatchDevice(const char *drivername, GDevPtr ** driversectlist);
+extern _X_EXPORT const char *
+xf86GetVisualName(int visual);
+extern _X_EXPORT int
+xf86GetVerbosity(void);
+extern _X_EXPORT Pix24Flags
+xf86GetPix24(void);
+extern _X_EXPORT int
+xf86GetDepth(void);
+extern _X_EXPORT rgb
+xf86GetWeight(void);
+extern _X_EXPORT Gamma
+xf86GetGamma(void);
+extern _X_EXPORT Bool
+xf86GetFlipPixels(void);
+extern _X_EXPORT const char *
+xf86GetServerName(void);
+extern _X_EXPORT Bool
+xf86ServerIsExiting(void);
+extern _X_EXPORT Bool
+xf86ServerIsResetting(void);
+extern _X_EXPORT Bool
+xf86ServerIsInitialising(void);
+extern _X_EXPORT Bool
+xf86ServerIsOnlyDetecting(void);
+extern _X_EXPORT Bool
+xf86CaughtSignal(void);
+extern _X_EXPORT Bool
+xf86GetVidModeAllowNonLocal(void);
+extern _X_EXPORT Bool
+xf86GetVidModeEnabled(void);
+extern _X_EXPORT Bool
+xf86GetModInDevAllowNonLocal(void);
+extern _X_EXPORT Bool
+xf86GetModInDevEnabled(void);
+extern _X_EXPORT Bool
+xf86GetAllowMouseOpenFail(void);
+extern _X_EXPORT void
+xf86DisableRandR(void);
+extern _X_EXPORT CARD32
+xorgGetVersion(void);
+extern _X_EXPORT CARD32
+xf86GetModuleVersion(pointer module);
+extern _X_EXPORT pointer
+xf86LoadDrvSubModule(DriverPtr drv, const char *name);
+extern _X_EXPORT pointer
+xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name);
+extern _X_EXPORT pointer
+xf86LoadOneModule(char *name, pointer optlist);
+extern _X_EXPORT void
+xf86UnloadSubModule(pointer mod);
+extern _X_EXPORT Bool
+xf86LoaderCheckSymbol(const char *name);
+extern _X_EXPORT void
+xf86SetBackingStore(ScreenPtr pScreen);
+extern _X_EXPORT void
+xf86SetSilkenMouse(ScreenPtr pScreen);
+extern _X_EXPORT pointer
+xf86FindXvOptions(int scrnIndex, int adapt_index, char *port_name,
+ char **adaptor_name, pointer *adaptor_options);
+extern _X_EXPORT void
+xf86GetOS(const char **name, int *major, int *minor, int *teeny);
+extern _X_EXPORT ScrnInfoPtr
+xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag,
+ int entityIndex, EntityProc init,
+ EntityProc enter, EntityProc leave, pointer private);
+
+extern _X_EXPORT Bool
+xf86IsScreenPrimary(int scrnIndex);
+extern _X_EXPORT int
+xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
+ int format, unsigned long len, pointer value);
+extern _X_EXPORT Bool
+xf86IsUnblank(int mode);
/* xf86Init.c */
-extern _X_EXPORT PixmapFormatPtr xf86GetPixFormat(ScrnInfoPtr pScrn, int depth);
-extern _X_EXPORT int xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth);
+extern _X_EXPORT PixmapFormatPtr
+xf86GetPixFormat(ScrnInfoPtr pScrn, int depth);
+extern _X_EXPORT int
+xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth);
/* xf86Mode.c */
-extern _X_EXPORT int xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2,
- int DivFactor, int MulFactor, int *divider);
-extern _X_EXPORT const char *xf86ModeStatusToString(ModeStatus status);
-extern _X_EXPORT ModeStatus xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
- ClockRangePtr clockRanges, LookupModeFlags strategy);
-extern _X_EXPORT ModeStatus xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor);
-extern _X_EXPORT ModeStatus xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
- ClockRangePtr clockRanges,
- LookupModeFlags strategy,
- int maxPitch, int virtualX,
- int virtualY);
-extern _X_EXPORT ModeStatus xf86CheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
- int flags);
-extern _X_EXPORT int xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
- char **modeNames, ClockRangePtr clockRanges,
- int *linePitches, int minPitch, int maxPitch,
- int minHeight, int maxHeight, int pitchInc,
- int virtualX, int virtualY, int apertureSize,
- LookupModeFlags strategy);
-extern _X_EXPORT void xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode);
-extern _X_EXPORT void xf86PruneDriverModes(ScrnInfoPtr scrp);
-extern _X_EXPORT void xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags);
-extern _X_EXPORT void xf86PrintModes(ScrnInfoPtr scrp);
-extern _X_EXPORT void xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges);
-extern _X_EXPORT double xf86ModeHSync(const DisplayModeRec *mode);
-extern _X_EXPORT double xf86ModeVRefresh(const DisplayModeRec *mode);
-extern _X_EXPORT void xf86SetModeDefaultName(DisplayModePtr mode);
-extern _X_EXPORT void xf86SetModeCrtc(DisplayModePtr p, int adjustFlags);
-extern _X_EXPORT DisplayModePtr xf86DuplicateMode(const DisplayModeRec *pMode);
-extern _X_EXPORT DisplayModePtr xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList);
-extern _X_EXPORT Bool xf86ModesEqual(const DisplayModeRec *pMode1,
- const DisplayModeRec *pMode2);
-extern _X_EXPORT void xf86PrintModeline(int scrnIndex,DisplayModePtr mode);
-extern _X_EXPORT DisplayModePtr xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new);
+extern _X_EXPORT int
+xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2,
+ int DivFactor, int MulFactor, int *divider);
+extern _X_EXPORT const char *
+xf86ModeStatusToString(ModeStatus status);
+extern _X_EXPORT ModeStatus
+xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
+ ClockRangePtr clockRanges, LookupModeFlags strategy);
+extern _X_EXPORT ModeStatus
+xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor);
+extern _X_EXPORT ModeStatus
+xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
+ ClockRangePtr clockRanges,
+ LookupModeFlags strategy,
+ int maxPitch, int virtualX, int virtualY);
+extern _X_EXPORT ModeStatus
+xf86CheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode, int flags);
+extern _X_EXPORT int
+xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
+ char **modeNames, ClockRangePtr clockRanges,
+ int *linePitches, int minPitch, int maxPitch,
+ int minHeight, int maxHeight, int pitchInc,
+ int virtualX, int virtualY, int apertureSize,
+ LookupModeFlags strategy);
+extern _X_EXPORT void
+xf86DeleteMode(DisplayModePtr * modeList, DisplayModePtr mode);
+extern _X_EXPORT void
+xf86PruneDriverModes(ScrnInfoPtr scrp);
+extern _X_EXPORT void
+xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags);
+extern _X_EXPORT void
+xf86PrintModes(ScrnInfoPtr scrp);
+extern _X_EXPORT void
+xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges);
+extern _X_EXPORT double
+xf86ModeHSync(const DisplayModeRec * mode);
+extern _X_EXPORT double
+xf86ModeVRefresh(const DisplayModeRec * mode);
+extern _X_EXPORT void
+xf86SetModeDefaultName(DisplayModePtr mode);
+extern _X_EXPORT void
+xf86SetModeCrtc(DisplayModePtr p, int adjustFlags);
+extern _X_EXPORT DisplayModePtr
+xf86DuplicateMode(const DisplayModeRec * pMode);
+extern _X_EXPORT DisplayModePtr
+xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList);
+extern _X_EXPORT Bool
+xf86ModesEqual(const DisplayModeRec * pMode1, const DisplayModeRec * pMode2);
+extern _X_EXPORT void
+xf86PrintModeline(int scrnIndex, DisplayModePtr mode);
+extern _X_EXPORT DisplayModePtr
+xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new);
/* xf86Option.c */
-extern _X_EXPORT void xf86CollectOptions(ScrnInfoPtr pScrn, XF86OptionPtr extraOpts);
-
+extern _X_EXPORT void
+xf86CollectOptions(ScrnInfoPtr pScrn, XF86OptionPtr extraOpts);
/* xf86RandR.c */
#ifdef RANDR
-extern _X_EXPORT Bool xf86RandRInit (ScreenPtr pScreen);
-extern _X_EXPORT Rotation xf86GetRotation(ScreenPtr pScreen);
-extern _X_EXPORT Bool xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
- int newvirtX, int newvirtY,
- int newmmWidth, int newmmHeight, Bool resetMode);
+extern _X_EXPORT Bool
+xf86RandRInit(ScreenPtr pScreen);
+extern _X_EXPORT Rotation
+xf86GetRotation(ScreenPtr pScreen);
+extern _X_EXPORT Bool
+xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
+ int newvirtX, int newvirtY,
+ int newmmWidth, int newmmHeight,
+ Bool resetMode);
#endif
/* xf86VidModeExtentionInit.c */
-extern _X_EXPORT Bool VidModeExtensionInit(ScreenPtr pScreen);
+extern _X_EXPORT Bool
+VidModeExtensionInit(ScreenPtr pScreen);
-#endif /* _NO_XF86_PROTOTYPES */
+#endif /* _NO_XF86_PROTOTYPES */
-#endif /* _XF86_H */
+#endif /* _XF86_H */
diff --git a/xorg-server/hw/xfree86/common/xf86AutoConfig.c b/xorg-server/hw/xfree86/common/xf86AutoConfig.c
index 0c465682a..43c746b7f 100644
--- a/xorg-server/hw/xfree86/common/xf86AutoConfig.c
+++ b/xorg-server/hw/xfree86/common/xf86AutoConfig.c
@@ -41,12 +41,12 @@
#include "xf86_OSlib.h"
#include "xf86pciBus.h"
#ifdef __sparc__
-# include "xf86sbusBus.h"
+#include "xf86sbusBus.h"
#endif
#ifdef sun
-# include <sys/visual_io.h>
-# include <ctype.h>
+#include <sys/visual_io.h>
+#include <ctype.h>
#endif
/* Sections for the default built-in configuration. */
@@ -103,13 +103,13 @@ AppendToList(const char *s, const char ***list, int *lines)
str = xnfstrdup(s);
for (p = strtok(str, "\n"); p; p = strtok(NULL, "\n")) {
- (*lines)++;
- *list = xnfrealloc(*list, (*lines + 1) * sizeof(**list));
- newstr = xnfalloc(strlen(p) + 2);
- strcpy(newstr, p);
- strcat(newstr, "\n");
- (*list)[*lines - 1] = newstr;
- (*list)[*lines] = NULL;
+ (*lines)++;
+ *list = xnfrealloc(*list, (*lines + 1) * sizeof(**list));
+ newstr = xnfalloc(strlen(p) + 2);
+ strcpy(newstr, p);
+ strcat(newstr, "\n");
+ (*list)[*lines - 1] = newstr;
+ (*list)[*lines] = NULL;
}
free(str);
}
@@ -120,7 +120,7 @@ FreeList(const char ***list, int *lines)
int i;
for (i = 0; i < *lines; i++) {
- free((char *)((*list)[i]));
+ free((char *) ((*list)[i]));
}
free(*list);
*list = NULL;
@@ -151,30 +151,30 @@ xf86AutoConfig(void)
listPossibleVideoDrivers(deviceList, 20);
for (p = deviceList; *p; p++) {
- snprintf(buf, sizeof(buf), BUILTIN_DEVICE_SECTION, *p, 0, *p);
- AppendToConfig(buf);
- snprintf(buf, sizeof(buf), BUILTIN_SCREEN_SECTION, *p, 0, *p, 0);
- AppendToConfig(buf);
+ snprintf(buf, sizeof(buf), BUILTIN_DEVICE_SECTION, *p, 0, *p);
+ AppendToConfig(buf);
+ snprintf(buf, sizeof(buf), BUILTIN_SCREEN_SECTION, *p, 0, *p, 0);
+ AppendToConfig(buf);
}
AppendToConfig(BUILTIN_LAYOUT_SECTION_PRE);
for (p = deviceList; *p; p++) {
- snprintf(buf, sizeof(buf), BUILTIN_LAYOUT_SCREEN_LINE, *p, 0);
- AppendToConfig(buf);
+ snprintf(buf, sizeof(buf), BUILTIN_LAYOUT_SCREEN_LINE, *p, 0);
+ AppendToConfig(buf);
}
AppendToConfig(BUILTIN_LAYOUT_SECTION_POST);
for (p = deviceList; *p; p++) {
- free(*p);
+ free(*p);
}
xf86MsgVerb(X_DEFAULT, 0,
- "Using default built-in configuration (%d lines)\n",
- builtinLines);
+ "Using default built-in configuration (%d lines)\n",
+ builtinLines);
xf86MsgVerb(X_DEFAULT, 3, "--- Start of built-in configuration ---\n");
for (cp = builtinConfig; *cp; cp++)
- xf86ErrorFVerb(3, "\t%s", *cp);
+ xf86ErrorFVerb(3, "\t%s", *cp);
xf86MsgVerb(X_DEFAULT, 3, "--- End of built-in configuration ---\n");
xf86initConfigFiles();
@@ -183,7 +183,7 @@ xf86AutoConfig(void)
FreeConfig();
if (ret != CONFIG_OK)
- xf86Msg(X_ERROR, "Error parsing the built-in default configuration.\n");
+ xf86Msg(X_ERROR, "Error parsing the built-in default configuration.\n");
return ret == CONFIG_OK;
}
@@ -192,8 +192,8 @@ static void
listPossibleVideoDrivers(char *matches[], int nmatches)
{
int i;
-
- for (i = 0 ; i < nmatches ; i++) {
+
+ for (i = 0; i < nmatches; i++) {
matches[i] = NULL;
}
i = 0;
@@ -202,57 +202,60 @@ listPossibleVideoDrivers(char *matches[], int nmatches)
/* Check for driver type based on /dev/fb type and if valid, use
it instead of PCI bus probe results */
if (xf86Info.consoleFd >= 0) {
- struct vis_identifier visid;
- const char *cp;
- extern char xf86SolarisFbDev[PATH_MAX];
- int iret;
-
- SYSCALL(iret = ioctl(xf86Info.consoleFd, VIS_GETIDENTIFIER, &visid));
- if (iret < 0) {
- int fbfd;
-
- fbfd = open(xf86SolarisFbDev, O_RDONLY);
- if (fbfd >= 0) {
- SYSCALL(iret = ioctl(fbfd, VIS_GETIDENTIFIER, &visid));
- close(fbfd);
- }
- }
-
- if (iret < 0) {
- xf86Msg(X_WARNING,
- "could not get frame buffer identifier from %s\n",
- xf86SolarisFbDev);
- } else {
- xf86Msg(X_PROBED, "console driver: %s\n", visid.name);
-
- /* Special case from before the general case was set */
- if (strcmp(visid.name, "NVDAnvda") == 0) {
- matches[i++] = xnfstrdup("nvidia");
- }
-
- /* General case - split into vendor name (initial all-caps
- prefix) & driver name (rest of the string). */
- if (strcmp(visid.name, "SUNWtext") != 0) {
- for (cp = visid.name; (*cp != '\0') && isupper(*cp); cp++) {
- /* find end of all uppercase vendor section */
- }
- if ((cp != visid.name) && (*cp != '\0')) {
- char *driverName = xnfstrdup(cp);
- char *vendorName = xnfstrdup(visid.name);
- vendorName[cp - visid.name] = '\0';
-
- matches[i++] = vendorName;
- matches[i++] = driverName;
- }
- }
- }
+ struct vis_identifier visid;
+ const char *cp;
+ extern char xf86SolarisFbDev[PATH_MAX];
+ int iret;
+
+ SYSCALL(iret = ioctl(xf86Info.consoleFd, VIS_GETIDENTIFIER, &visid));
+ if (iret < 0) {
+ int fbfd;
+
+ fbfd = open(xf86SolarisFbDev, O_RDONLY);
+ if (fbfd >= 0) {
+ SYSCALL(iret = ioctl(fbfd, VIS_GETIDENTIFIER, &visid));
+ close(fbfd);
+ }
+ }
+
+ if (iret < 0) {
+ xf86Msg(X_WARNING,
+ "could not get frame buffer identifier from %s\n",
+ xf86SolarisFbDev);
+ }
+ else {
+ xf86Msg(X_PROBED, "console driver: %s\n", visid.name);
+
+ /* Special case from before the general case was set */
+ if (strcmp(visid.name, "NVDAnvda") == 0) {
+ matches[i++] = xnfstrdup("nvidia");
+ }
+
+ /* General case - split into vendor name (initial all-caps
+ prefix) & driver name (rest of the string). */
+ if (strcmp(visid.name, "SUNWtext") != 0) {
+ for (cp = visid.name; (*cp != '\0') && isupper(*cp); cp++) {
+ /* find end of all uppercase vendor section */
+ }
+ if ((cp != visid.name) && (*cp != '\0')) {
+ char *driverName = xnfstrdup(cp);
+ char *vendorName = xnfstrdup(visid.name);
+
+ vendorName[cp - visid.name] = '\0';
+
+ matches[i++] = vendorName;
+ matches[i++] = driverName;
+ }
+ }
+ }
}
#endif
#ifdef __sparc__
{
- char *sbusDriver = sparcDriverName();
- if (sbusDriver)
- matches[i++] = xnfstrdup(sbusDriver);
+ char *sbusDriver = sparcDriverName();
+
+ if (sbusDriver)
+ matches[i++] = xnfstrdup(sbusDriver);
}
#endif
#ifdef XSERVER_LIBPCIACCESS
@@ -261,9 +264,9 @@ listPossibleVideoDrivers(char *matches[], int nmatches)
/* Fallback to platform default hardware */
if (i < (nmatches - 1)) {
#if defined(__i386__) || defined(__amd64__) || defined(__hurd__)
- matches[i++] = xnfstrdup("vesa");
+ matches[i++] = xnfstrdup("vesa");
#elif defined(__sparc__) && !defined(sun)
- matches[i++] = xnfstrdup("sunffb");
+ matches[i++] = xnfstrdup("sunffb");
#endif
}
@@ -271,12 +274,12 @@ listPossibleVideoDrivers(char *matches[], int nmatches)
/* Fallback to platform default frame buffer driver */
if (i < (nmatches - 1)) {
#if !defined(__linux__) && defined(__sparc__)
- matches[i++] = xnfstrdup("wsfb");
+ matches[i++] = xnfstrdup("wsfb");
#else
- matches[i++] = xnfstrdup("fbdev");
+ matches[i++] = xnfstrdup("fbdev");
#endif
}
-#endif /* !sun */
+#endif /* !sun */
}
/* copy a screen section and enter the desired driver
@@ -320,7 +323,7 @@ GDevPtr
autoConfigDevice(GDevPtr preconf_device)
{
GDevPtr ptr = NULL;
- char *matches[20]; /* If we have more than 20 drivers we're in trouble */
+ char *matches[20]; /* If we have more than 20 drivers we're in trouble */
int num_matches = 0, num_screens = 0, i;
screenLayoutPtr slp;
@@ -331,7 +334,8 @@ autoConfigDevice(GDevPtr preconf_device)
/* If there's a configured section with no driver chosen, use it */
if (preconf_device) {
ptr = preconf_device;
- } else {
+ }
+ else {
ptr = calloc(1, sizeof(GDevRec));
if (!ptr) {
return NULL;
@@ -361,7 +365,7 @@ autoConfigDevice(GDevPtr preconf_device)
* plus one for the terminating NULL */
for (; slp[num_screens].screen; num_screens++);
xf86ConfigLayout.screens = xnfcalloc(num_screens + num_matches,
- sizeof(screenLayoutRec));
+ sizeof(screenLayoutRec));
xf86ConfigLayout.screens[0] = slp[0];
/* do the first match and set that for the original first screen */
@@ -384,14 +388,16 @@ autoConfigDevice(GDevPtr preconf_device)
*
* TODO Handle rest of multiple screen sections */
for (i = 1; i < num_screens; i++) {
- xf86ConfigLayout.screens[i+num_matches] = slp[i];
+ xf86ConfigLayout.screens[i + num_matches] = slp[i];
}
- xf86ConfigLayout.screens[num_screens+num_matches-1].screen = NULL;
+ xf86ConfigLayout.screens[num_screens + num_matches - 1].screen =
+ NULL;
free(slp);
- } else {
+ }
+ else {
/* layout does not have any screens, not much to do */
ptr->driver = matches[0];
- for (i = 1; matches[i] ; i++) {
+ for (i = 1; matches[i]; i++) {
if (matches[i] != matches[0]) {
free(matches[i]);
}
diff --git a/xorg-server/hw/xfree86/common/xf86Bus.c b/xorg-server/hw/xfree86/common/xf86Bus.c
index c665a2019..b176e8cc4 100644
--- a/xorg-server/hw/xfree86/common/xf86Bus.c
+++ b/xorg-server/hw/xfree86/common/xf86Bus.c
@@ -51,11 +51,11 @@
#include "xf86VGAarbiter.h"
#endif
/* Entity data */
-EntityPtr *xf86Entities = NULL; /* Bus slots claimed by drivers */
+EntityPtr *xf86Entities = NULL; /* Bus slots claimed by drivers */
int xf86NumEntities = 0;
static int xf86EntityPrivateCount = 0;
-BusRec primaryBus = { BUS_NONE, { 0 } };
+BusRec primaryBus = { BUS_NONE, {0} };
/**
* Call the driver's correct probe function.
@@ -73,9 +73,10 @@ BusRec primaryBus = { BUS_NONE, { 0 } };
* returned. Otherwise, \c FALSE is returned.
*/
Bool
-xf86CallDriverProbe( DriverPtr drv, Bool detect_only )
+xf86CallDriverProbe(DriverPtr drv, Bool detect_only)
{
- Bool foundScreen = FALSE;
+ Bool foundScreen = FALSE;
+
#ifdef XSERVER_LIBPCIACCESS
if (drv->PciProbe != NULL) {
if (xf86DoConfigure && xf86DoConfigurePass1) {
@@ -83,16 +84,16 @@ xf86CallDriverProbe( DriverPtr drv, Bool detect_only )
foundScreen = xf86PciAddMatchingDev(drv);
}
else {
- assert(! detect_only);
+ assert(!detect_only);
foundScreen = xf86PciProbeDev(drv);
}
}
#endif
if (!foundScreen && (drv->Probe != NULL)) {
- xf86Msg( X_WARNING, "Falling back to old probe method for %s\n",
- drv->driverName);
- foundScreen = (*drv->Probe)(drv, (detect_only) ? PROBE_DETECT
- : PROBE_DEFAULT);
+ xf86Msg(X_WARNING, "Falling back to old probe method for %s\n",
+ drv->driverName);
+ foundScreen = (*drv->Probe) (drv, (detect_only) ? PROBE_DETECT
+ : PROBE_DEFAULT);
}
return foundScreen;
@@ -119,13 +120,14 @@ xf86BusConfig(void)
*/
for (i = 0; i < xf86NumDrivers; i++) {
xorgHWFlags flags;
+
if (!xorgHWAccess) {
if (!xf86DriverList[i]->driverFunc
- || !xf86DriverList[i]->driverFunc(NULL,
- GET_REQUIRED_HW_INTERFACES,
- &flags)
- || NEED_IO_ENABLED(flags))
- continue;
+ || !xf86DriverList[i]->driverFunc(NULL,
+ GET_REQUIRED_HW_INTERFACES,
+ &flags)
+ || NEED_IO_ENABLED(flags))
+ continue;
}
xf86CallDriverProbe(xf86DriverList[i], FALSE);
@@ -155,11 +157,13 @@ xf86BusConfig(void)
for (layout = xf86ConfigLayout.screens; layout->screen != NULL;
layout++) {
Bool found = FALSE;
+
for (j = 0; j < xf86Screens[i]->numEntities; j++) {
- GDevPtr dev = xf86GetDevFromEntity(
- xf86Screens[i]->entityList[j],
- xf86Screens[i]->entityInstanceList[j]);
+ 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;
@@ -167,12 +171,14 @@ xf86BusConfig(void)
break;
}
}
- if (found) break;
+ if (found)
+ break;
}
if (layout->screen == NULL) {
/* No match found */
xf86Msg(X_ERROR,
- "Screen %d deleted because of no matching config section.\n", i);
+ "Screen %d deleted because of no matching config section.\n",
+ i);
xf86DeleteScreen(i--, 0);
}
}
@@ -180,7 +186,7 @@ xf86BusConfig(void)
/* If no screens left, return now. */
if (xf86NumScreens == 0) {
xf86Msg(X_ERROR,
- "Device(s) detected, but none match those in the config file.\n");
+ "Device(s) detected, but none match those in the config file.\n");
return FALSE;
}
@@ -210,31 +216,31 @@ xf86BusProbe(void)
*/
BusType
-StringToBusType(const char* busID, const char **retID)
+StringToBusType(const char *busID, const char **retID)
{
char *p, *s;
BusType ret = BUS_NONE;
/* If no type field, Default to PCI */
if (isdigit(busID[0])) {
- if (retID)
- *retID = busID;
- return BUS_PCI;
+ if (retID)
+ *retID = busID;
+ return BUS_PCI;
}
s = xstrdup(busID);
p = strtok(s, ":");
if (p == NULL || *p == 0) {
- free(s);
- return BUS_NONE;
+ free(s);
+ return BUS_NONE;
}
if (!xf86NameCmp(p, "pci") || !xf86NameCmp(p, "agp"))
- ret = BUS_PCI;
+ ret = BUS_PCI;
if (!xf86NameCmp(p, "sbus"))
- ret = BUS_SBUS;
+ ret = BUS_SBUS;
if (ret != BUS_NONE)
- if (retID)
- *retID = busID + strlen(p) + 1;
+ if (retID)
+ *retID = busID + strlen(p) + 1;
free(s);
return ret;
}
@@ -244,10 +250,10 @@ xf86AllocateEntity(void)
{
xf86NumEntities++;
xf86Entities = xnfrealloc(xf86Entities,
- sizeof(EntityPtr) * xf86NumEntities);
- xf86Entities[xf86NumEntities - 1] = xnfcalloc(1,sizeof(EntityRec));
+ sizeof(EntityPtr) * xf86NumEntities);
+ xf86Entities[xf86NumEntities - 1] = xnfcalloc(1, sizeof(EntityRec));
xf86Entities[xf86NumEntities - 1]->entityPrivates =
- xnfcalloc(sizeof(DevUnion) * xf86EntityPrivateCount, 1);
+ xnfcalloc(sizeof(DevUnion) * xf86EntityPrivateCount, 1);
return xf86NumEntities - 1;
}
@@ -255,25 +261,26 @@ Bool
xf86IsEntityPrimary(int entityIndex)
{
EntityPtr pEnt = xf86Entities[entityIndex];
-
- if (primaryBus.type != pEnt->bus.type) return FALSE;
+
+ if (primaryBus.type != pEnt->bus.type)
+ return FALSE;
switch (pEnt->bus.type) {
case BUS_PCI:
- return pEnt->bus.id.pci == primaryBus.id.pci;
+ return pEnt->bus.id.pci == primaryBus.id.pci;
case BUS_SBUS:
- return pEnt->bus.id.sbus.fbNum == primaryBus.id.sbus.fbNum;
+ return pEnt->bus.id.sbus.fbNum == primaryBus.id.sbus.fbNum;
default:
- return FALSE;
+ return FALSE;
}
}
-
+
Bool
xf86SetEntityFuncs(int entityIndex, EntityProc init, EntityProc enter,
- EntityProc leave, pointer private)
+ EntityProc leave, pointer private)
{
if (entityIndex >= xf86NumEntities)
- return FALSE;
+ return FALSE;
xf86Entities[entityIndex]->entityInit = init;
xf86Entities[entityIndex]->entityEnter = enter;
xf86Entities[entityIndex]->entityLeave = leave;
@@ -285,9 +292,10 @@ Bool
xf86DriverHasEntities(DriverPtr drvp)
{
int i;
+
for (i = 0; i < xf86NumEntities; i++) {
- if (xf86Entities[i]->driver == drvp)
- return TRUE;
+ if (xf86Entities[i]->driver == drvp)
+ return TRUE;
}
return FALSE;
}
@@ -296,20 +304,20 @@ void
xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex)
{
if (entityIndex == -1)
- return;
+ return;
if (xf86Entities[entityIndex]->inUse &&
- !(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL)) {
- ErrorF("Requested Entity already in use!\n");
- return;
+ !(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL)) {
+ ErrorF("Requested Entity already in use!\n");
+ return;
}
pScrn->numEntities++;
pScrn->entityList = xnfrealloc(pScrn->entityList,
- pScrn->numEntities * sizeof(int));
+ pScrn->numEntities * sizeof(int));
pScrn->entityList[pScrn->numEntities - 1] = entityIndex;
xf86Entities[entityIndex]->inUse = TRUE;
pScrn->entityInstanceList = xnfrealloc(pScrn->entityInstanceList,
- pScrn->numEntities * sizeof(int));
+ pScrn->numEntities * sizeof(int));
pScrn->entityInstanceList[pScrn->numEntities - 1] = 0;
}
@@ -319,13 +327,13 @@ xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex, int instance)
int i;
if (entityIndex == -1 || entityIndex >= xf86NumEntities)
- return;
+ return;
for (i = 0; i < pScrn->numEntities; i++) {
- if (pScrn->entityList[i] == entityIndex) {
- pScrn->entityInstanceList[i] = instance;
- break;
- }
+ if (pScrn->entityList[i] == entityIndex) {
+ pScrn->entityInstanceList[i] = instance;
+ break;
+ }
}
}
@@ -336,17 +344,18 @@ xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex, int instance)
ScrnInfoPtr
xf86FindScreenForEntity(int entityIndex)
{
- int i,j;
+ int i, j;
+
+ if (entityIndex == -1)
+ return NULL;
- if (entityIndex == -1) return NULL;
-
if (xf86Screens) {
- for (i = 0; i < xf86NumScreens; i++) {
- for (j = 0; j < xf86Screens[i]->numEntities; j++) {
- if ( xf86Screens[i]->entityList[j] == entityIndex )
- return xf86Screens[i];
- }
- }
+ for (i = 0; i < xf86NumScreens; i++) {
+ for (j = 0; j < xf86Screens[i]->numEntities; j++) {
+ if (xf86Screens[i]->entityList[j] == entityIndex)
+ return xf86Screens[i];
+ }
+ }
}
return NULL;
}
@@ -355,15 +364,15 @@ void
xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex)
{
int i;
-
+
for (i = 0; i < pScrn->numEntities; i++) {
- if (pScrn->entityList[i] == entityIndex) {
- for (i++; i < pScrn->numEntities; i++)
- pScrn->entityList[i-1] = pScrn->entityList[i];
- pScrn->numEntities--;
- xf86Entities[entityIndex]->inUse = FALSE;
- break;
- }
+ if (pScrn->entityList[i] == entityIndex) {
+ for (i++; i < pScrn->numEntities; i++)
+ pScrn->entityList[i - 1] = pScrn->entityList[i];
+ pScrn->numEntities--;
+ xf86Entities[entityIndex]->inUse = FALSE;
+ break;
+ }
}
}
@@ -376,13 +385,14 @@ xf86ClearEntityListForScreen(int scrnIndex)
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
int i, entityIndex;
-
- if (pScrn->entityList == NULL || pScrn->numEntities == 0) return;
-
+
+ if (pScrn->entityList == NULL || pScrn->numEntities == 0)
+ return;
+
for (i = 0; i < pScrn->numEntities; i++) {
- entityIndex = pScrn->entityList[i];
- xf86Entities[entityIndex]->inUse = FALSE;
- /* disable resource: call the disable function */
+ entityIndex = pScrn->entityList[i];
+ xf86Entities[entityIndex]->inUse = FALSE;
+ /* disable resource: call the disable function */
}
free(pScrn->entityList);
free(pScrn->entityInstanceList);
@@ -398,14 +408,14 @@ void
xf86AddDevToEntity(int entityIndex, GDevPtr dev)
{
EntityPtr pEnt;
-
+
if (entityIndex >= xf86NumEntities)
- return;
-
+ return;
+
pEnt = xf86Entities[entityIndex];
pEnt->numInstances++;
pEnt->devices = xnfrealloc(pEnt->devices,
- pEnt->numInstances * sizeof(GDevPtr));
+ pEnt->numInstances * sizeof(GDevPtr));
pEnt->devices[pEnt->numInstances - 1] = dev;
dev->claimed = TRUE;
}
@@ -420,28 +430,29 @@ xf86GetEntityInfo(int entityIndex)
{
EntityInfoPtr pEnt;
int i;
-
+
if (entityIndex == -1)
- return NULL;
+ return NULL;
if (entityIndex >= xf86NumEntities)
- return NULL;
-
- pEnt = xnfcalloc(1,sizeof(EntityInfoRec));
+ return NULL;
+
+ pEnt = xnfcalloc(1, sizeof(EntityInfoRec));
pEnt->index = entityIndex;
pEnt->location = xf86Entities[entityIndex]->bus;
pEnt->active = xf86Entities[entityIndex]->active;
pEnt->chipset = xf86Entities[entityIndex]->chipset;
pEnt->driver = xf86Entities[entityIndex]->driver;
- if ( (xf86Entities[entityIndex]->devices) &&
- (xf86Entities[entityIndex]->devices[0]) ) {
- for (i = 0; i < xf86Entities[entityIndex]->numInstances; i++)
- if (xf86Entities[entityIndex]->devices[i]->screen == 0)
- break;
- pEnt->device = xf86Entities[entityIndex]->devices[i];
- } else
- pEnt->device = NULL;
-
+ if ((xf86Entities[entityIndex]->devices) &&
+ (xf86Entities[entityIndex]->devices[0])) {
+ for (i = 0; i < xf86Entities[entityIndex]->numInstances; i++)
+ if (xf86Entities[entityIndex]->devices[i]->screen == 0)
+ break;
+ pEnt->device = xf86Entities[entityIndex]->devices[i];
+ }
+ else
+ pEnt->device = NULL;
+
return pEnt;
}
@@ -449,8 +460,8 @@ int
xf86GetNumEntityInstances(int entityIndex)
{
if (entityIndex >= xf86NumEntities)
- return -1;
-
+ return -1;
+
return xf86Entities[entityIndex]->numInstances;
}
@@ -458,19 +469,19 @@ GDevPtr
xf86GetDevFromEntity(int entityIndex, int instance)
{
int i;
-
+
/* We might not use AddDevtoEntity */
- if ( (!xf86Entities[entityIndex]->devices) ||
- (!xf86Entities[entityIndex]->devices[0]) )
- return NULL;
+ if ((!xf86Entities[entityIndex]->devices) ||
+ (!xf86Entities[entityIndex]->devices[0]))
+ return NULL;
if (entityIndex >= xf86NumEntities ||
- instance >= xf86Entities[entityIndex]->numInstances)
- return NULL;
-
+ instance >= xf86Entities[entityIndex]->numInstances)
+ return NULL;
+
for (i = 0; i < xf86Entities[entityIndex]->numInstances; i++)
- if (xf86Entities[entityIndex]->devices[i]->screen == instance)
- break;
+ if (xf86Entities[entityIndex]->devices[i]->screen == instance)
+ break;
return xf86Entities[entityIndex]->devices[i];
}
@@ -485,7 +496,7 @@ xf86AccessEnter(void)
for (i = 0; i < xf86NumEntities; i++)
if (xf86Entities[i]->entityEnter)
- xf86Entities[i]->entityEnter(i,xf86Entities[i]->private);
+ xf86Entities[i]->entityEnter(i, xf86Entities[i]->private);
}
void
@@ -495,7 +506,7 @@ xf86AccessLeave(void)
for (i = 0; i < xf86NumEntities; i++)
if (xf86Entities[i]->entityLeave)
- xf86Entities[i]->entityLeave(i,xf86Entities[i]->private);
+ xf86Entities[i]->entityLeave(i, xf86Entities[i]->private);
}
/*
@@ -509,28 +520,29 @@ xf86PostProbe(void)
if (fbSlotClaimed && (
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
- sbusSlotClaimed ||
+ sbusSlotClaimed ||
#endif
#ifdef XSERVER_LIBPCIACCESS
- pciSlotClaimed
+ pciSlotClaimed
#else
- TRUE
+ TRUE
#endif
- ))
- FatalError("Cannot run in framebuffer mode. Please specify busIDs "
- " for all framebuffer devices\n");
+ ))
+ FatalError("Cannot run in framebuffer mode. Please specify busIDs "
+ " for all framebuffer devices\n");
for (i = 0; i < xf86NumEntities; i++)
if (xf86Entities[i]->entityInit)
- xf86Entities[i]->entityInit(i,xf86Entities[i]->private);
+ xf86Entities[i]->entityInit(i, xf86Entities[i]->private);
}
int
xf86GetLastScrnFlag(int entityIndex)
{
- if(entityIndex < xf86NumEntities) {
+ if (entityIndex < xf86NumEntities) {
return xf86Entities[entityIndex]->lastScrnFlag;
- } else {
+ }
+ else {
return -1;
}
}
@@ -538,7 +550,7 @@ xf86GetLastScrnFlag(int entityIndex)
void
xf86SetLastScrnFlag(int entityIndex, int scrnIndex)
{
- if(entityIndex < xf86NumEntities) {
+ if (entityIndex < xf86NumEntities) {
xf86Entities[entityIndex]->lastScrnFlag = scrnIndex;
}
}
@@ -546,10 +558,10 @@ xf86SetLastScrnFlag(int entityIndex, int scrnIndex)
Bool
xf86IsEntityShared(int entityIndex)
{
- if(entityIndex < xf86NumEntities) {
- if(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL) {
- return TRUE;
- }
+ if (entityIndex < xf86NumEntities) {
+ if (xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL) {
+ return TRUE;
+ }
}
return FALSE;
}
@@ -557,7 +569,7 @@ xf86IsEntityShared(int entityIndex)
void
xf86SetEntityShared(int entityIndex)
{
- if(entityIndex < xf86NumEntities) {
+ if (entityIndex < xf86NumEntities) {
xf86Entities[entityIndex]->entityProp |= IS_SHARED_ACCEL;
}
}
@@ -565,10 +577,10 @@ xf86SetEntityShared(int entityIndex)
Bool
xf86IsEntitySharable(int entityIndex)
{
- if(entityIndex < xf86NumEntities) {
- if(xf86Entities[entityIndex]->entityProp & ACCEL_IS_SHARABLE) {
- return TRUE;
- }
+ if (entityIndex < xf86NumEntities) {
+ if (xf86Entities[entityIndex]->entityProp & ACCEL_IS_SHARABLE) {
+ return TRUE;
+ }
}
return FALSE;
}
@@ -576,7 +588,7 @@ xf86IsEntitySharable(int entityIndex)
void
xf86SetEntitySharable(int entityIndex)
{
- if(entityIndex < xf86NumEntities) {
+ if (entityIndex < xf86NumEntities) {
xf86Entities[entityIndex]->entityProp |= ACCEL_IS_SHARABLE;
}
}
@@ -584,10 +596,10 @@ xf86SetEntitySharable(int entityIndex)
Bool
xf86IsPrimInitDone(int entityIndex)
{
- if(entityIndex < xf86NumEntities) {
- if(xf86Entities[entityIndex]->entityProp & SA_PRIM_INIT_DONE) {
- return TRUE;
- }
+ if (entityIndex < xf86NumEntities) {
+ if (xf86Entities[entityIndex]->entityProp & SA_PRIM_INIT_DONE) {
+ return TRUE;
+ }
}
return FALSE;
}
@@ -595,7 +607,7 @@ xf86IsPrimInitDone(int entityIndex)
void
xf86SetPrimInitDone(int entityIndex)
{
- if(entityIndex < xf86NumEntities) {
+ if (entityIndex < xf86NumEntities) {
xf86Entities[entityIndex]->entityProp |= SA_PRIM_INIT_DONE;
}
}
@@ -603,12 +615,11 @@ xf86SetPrimInitDone(int entityIndex)
void
xf86ClearPrimInitDone(int entityIndex)
{
- if(entityIndex < xf86NumEntities) {
+ if (entityIndex < xf86NumEntities) {
xf86Entities[entityIndex]->entityProp &= ~SA_PRIM_INIT_DONE;
}
}
-
/*
* Allocate a private in the entities.
*/
@@ -622,12 +633,12 @@ xf86AllocateEntityPrivateIndex(void)
idx = xf86EntityPrivateCount++;
for (i = 0; i < xf86NumEntities; i++) {
- pEnt = xf86Entities[i];
- nprivs = xnfrealloc(pEnt->entityPrivates,
- xf86EntityPrivateCount * sizeof(DevUnion));
- /* Zero the new private */
- memset(&nprivs[idx], 0, sizeof(DevUnion));
- pEnt->entityPrivates = nprivs;
+ pEnt = xf86Entities[i];
+ nprivs = xnfrealloc(pEnt->entityPrivates,
+ xf86EntityPrivateCount * sizeof(DevUnion));
+ /* Zero the new private */
+ memset(&nprivs[idx], 0, sizeof(DevUnion));
+ pEnt->entityPrivates = nprivs;
}
return idx;
}
@@ -636,8 +647,7 @@ DevUnion *
xf86GetEntityPrivate(int entityIndex, int privIndex)
{
if (entityIndex >= xf86NumEntities || privIndex >= xf86EntityPrivateCount)
- return NULL;
+ return NULL;
return &(xf86Entities[entityIndex]->entityPrivates[privIndex]);
}
-
diff --git a/xorg-server/hw/xfree86/common/xf86Config.c b/xorg-server/hw/xfree86/common/xf86Config.c
index f51be7e9c..ec679df16 100644
--- a/xorg-server/hw/xfree86/common/xf86Config.c
+++ b/xorg-server/hw/xfree86/common/xf86Config.c
@@ -109,36 +109,36 @@
#endif
static ModuleDefault ModuleDefaults[] = {
- {.name = "extmod", .toLoad = TRUE, .load_opt=NULL},
+ {.name = "extmod",.toLoad = TRUE,.load_opt = NULL},
#ifdef DBE
- {.name = "dbe", .toLoad = TRUE, .load_opt=NULL},
+ {.name = "dbe",.toLoad = TRUE,.load_opt = NULL},
#endif
#ifdef GLXEXT
- {.name = "glx", .toLoad = TRUE, .load_opt=NULL},
+ {.name = "glx",.toLoad = TRUE,.load_opt = NULL},
#endif
#ifdef XRECORD
- {.name = "record", .toLoad = TRUE, .load_opt=NULL},
+ {.name = "record",.toLoad = TRUE,.load_opt = NULL},
#endif
#ifdef XF86DRI
- {.name = "dri", .toLoad = TRUE, .load_opt=NULL},
+ {.name = "dri",.toLoad = TRUE,.load_opt = NULL},
#endif
#ifdef DRI2
- {.name = "dri2", .toLoad = TRUE, .load_opt=NULL},
+ {.name = "dri2",.toLoad = TRUE,.load_opt = NULL},
#endif
- {.name = NULL, .toLoad = FALSE, .load_opt=NULL}
+ {.name = NULL,.toLoad = FALSE,.load_opt = NULL}
};
-
/* Forward declarations */
static Bool configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen,
- int scrnum, MessageType from);
+ int scrnum, MessageType from);
static Bool configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor);
static Bool configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device,
- Bool active);
+ Bool active);
static Bool configInput(InputInfoPtr pInfo, XF86ConfInputPtr conf_input,
- MessageType from);
+ MessageType from);
static Bool configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display);
static Bool addDefaultModes(MonPtr monitorp);
+
#ifdef XF86DRI
static void configDRI(XF86ConfDRIPtr drip);
#endif
@@ -154,15 +154,15 @@ static void configExtensions(XF86ConfExtensionsPtr conf_ext);
static char *
xf86GetPathElem(char **pnt)
{
- char *p1;
-
- p1 = *pnt;
- *pnt = index(*pnt, ',');
- if (*pnt != NULL) {
- **pnt = '\0';
- *pnt += 1;
- }
- return p1;
+ char *p1;
+
+ p1 = *pnt;
+ *pnt = index(*pnt, ',');
+ if (*pnt != NULL) {
+ **pnt = '\0';
+ *pnt += 1;
+ }
+ return p1;
}
/*
@@ -178,67 +178,67 @@ xf86GetPathElem(char **pnt)
static char *
xf86ValidateFontPath(char *path)
{
- char *tmp_path, *out_pnt, *path_elem, *next, *p1, *dir_elem;
- struct stat stat_buf;
- int flag;
- int dirlen;
-
- tmp_path = calloc(1,strlen(path)+1);
- out_pnt = tmp_path;
- path_elem = NULL;
- next = path;
- while (next != NULL) {
- path_elem = xf86GetPathElem(&next);
- if (*path_elem == '/') {
- dir_elem = xnfcalloc(1, strlen(path_elem) + 1);
- if ((p1 = strchr(path_elem, ':')) != 0)
- dirlen = p1 - path_elem;
- else
- dirlen = strlen(path_elem);
- strlcpy(dir_elem, path_elem, dirlen + 1);
- flag = stat(dir_elem, &stat_buf);
- if (flag == 0)
- if (!S_ISDIR(stat_buf.st_mode))
- flag = -1;
- if (flag != 0) {
- xf86Msg(X_WARNING, "The directory \"%s\" does not exist.\n", dir_elem);
- xf86ErrorF("\tEntry deleted from font path.\n");
- free(dir_elem);
- continue;
- }
- else {
- XNFasprintf(&p1, "%s%s", dir_elem, DIR_FILE);
- flag = stat(p1, &stat_buf);
- if (flag == 0)
- if (!S_ISREG(stat_buf.st_mode))
- flag = -1;
- free(p1);
- if (flag != 0) {
- xf86Msg(X_WARNING,
- "`fonts.dir' not found (or not valid) in \"%s\".\n",
- dir_elem);
- xf86ErrorF("\tEntry deleted from font path.\n");
- xf86ErrorF("\t(Run 'mkfontdir' on \"%s\").\n", dir_elem);
- free(dir_elem);
- continue;
- }
- }
- free(dir_elem);
- }
+ char *tmp_path, *out_pnt, *path_elem, *next, *p1, *dir_elem;
+ struct stat stat_buf;
+ int flag;
+ int dirlen;
+
+ tmp_path = calloc(1, strlen(path) + 1);
+ out_pnt = tmp_path;
+ path_elem = NULL;
+ next = path;
+ while (next != NULL) {
+ path_elem = xf86GetPathElem(&next);
+ if (*path_elem == '/') {
+ dir_elem = xnfcalloc(1, strlen(path_elem) + 1);
+ if ((p1 = strchr(path_elem, ':')) != 0)
+ dirlen = p1 - path_elem;
+ else
+ dirlen = strlen(path_elem);
+ strlcpy(dir_elem, path_elem, dirlen + 1);
+ flag = stat(dir_elem, &stat_buf);
+ if (flag == 0)
+ if (!S_ISDIR(stat_buf.st_mode))
+ flag = -1;
+ if (flag != 0) {
+ xf86Msg(X_WARNING, "The directory \"%s\" does not exist.\n",
+ dir_elem);
+ xf86ErrorF("\tEntry deleted from font path.\n");
+ free(dir_elem);
+ continue;
+ }
+ else {
+ XNFasprintf(&p1, "%s%s", dir_elem, DIR_FILE);
+ flag = stat(p1, &stat_buf);
+ if (flag == 0)
+ if (!S_ISREG(stat_buf.st_mode))
+ flag = -1;
+ free(p1);
+ if (flag != 0) {
+ xf86Msg(X_WARNING,
+ "`fonts.dir' not found (or not valid) in \"%s\".\n",
+ dir_elem);
+ xf86ErrorF("\tEntry deleted from font path.\n");
+ xf86ErrorF("\t(Run 'mkfontdir' on \"%s\").\n", dir_elem);
+ free(dir_elem);
+ continue;
+ }
+ }
+ free(dir_elem);
+ }
- /*
- * Either an OK directory, or a font server name. So add it to
- * the path.
- */
- if (out_pnt != tmp_path)
- *out_pnt++ = ',';
- strcat(out_pnt, path_elem);
- out_pnt += strlen(path_elem);
- }
- return tmp_path;
+ /*
+ * Either an OK directory, or a font server name. So add it to
+ * the path.
+ */
+ if (out_pnt != tmp_path)
+ *out_pnt++ = ',';
+ strcat(out_pnt, path_elem);
+ out_pnt += strlen(path_elem);
+ }
+ return tmp_path;
}
-
/*
* use the datastructure that the parser provides and pick out the parts
* that we need at this point
@@ -248,13 +248,15 @@ xf86ModulelistFromConfig(pointer **optlist)
{
int count = 0, i = 0;
char **modulearray;
+
const char *ignore[] = { "GLcore", "speedo", "bitmap", "drm",
- "freetype", "type1",
- NULL };
+ "freetype", "type1",
+ NULL
+ };
pointer *optarray;
XF86LoadPtr modp;
Bool found;
-
+
/*
* make sure the config file has been parsed and that we have a
* ModulePath set; if no ModulePath was given, use the default
@@ -264,15 +266,17 @@ xf86ModulelistFromConfig(pointer **optlist)
xf86Msg(X_ERROR, "Cannot access global config data structure\n");
return NULL;
}
-
+
if (xf86configptr->conf_modules) {
/* Walk the disable list and let people know what we've parsed to
* not be loaded
*/
modp = xf86configptr->conf_modules->mod_disable_lst;
while (modp) {
- xf86Msg(X_WARNING, "\"%s\" will not be loaded unless you've specified it to be loaded elsewhere.\n", modp->load_name);
- modp = (XF86LoadPtr) modp->list.next;
+ xf86Msg(X_WARNING,
+ "\"%s\" will not be loaded unless you've specified it to be loaded elsewhere.\n",
+ modp->load_name);
+ modp = (XF86LoadPtr) modp->list.next;
}
/*
* Walk the default settings table. For each module listed to be
@@ -280,90 +284,103 @@ xf86ModulelistFromConfig(pointer **optlist)
* sure it's not in the mod_no_load_lst. If it's not disabled,
* append it to mod_load_lst
*/
- for (i=0 ; ModuleDefaults[i].name != NULL ; i++) {
+ for (i = 0; ModuleDefaults[i].name != NULL; i++) {
if (ModuleDefaults[i].toLoad == FALSE) {
- xf86Msg(X_WARNING, "\"%s\" is not to be loaded by default. Skipping.\n", ModuleDefaults[i].name);
+ xf86Msg(X_WARNING,
+ "\"%s\" is not to be loaded by default. Skipping.\n",
+ ModuleDefaults[i].name);
continue;
}
found = FALSE;
modp = xf86configptr->conf_modules->mod_load_lst;
while (modp) {
if (strcmp(modp->load_name, ModuleDefaults[i].name) == 0) {
- xf86Msg(X_INFO, "\"%s\" will be loaded. This was enabled by default and also specified in the config file.\n", ModuleDefaults[i].name);
+ xf86Msg(X_INFO,
+ "\"%s\" will be loaded. This was enabled by default and also specified in the config file.\n",
+ ModuleDefaults[i].name);
found = TRUE;
break;
}
- modp = (XF86LoadPtr) modp->list.next;
+ modp = (XF86LoadPtr) modp->list.next;
}
if (found == FALSE) {
modp = xf86configptr->conf_modules->mod_disable_lst;
while (modp) {
if (strcmp(modp->load_name, ModuleDefaults[i].name) == 0) {
- xf86Msg(X_INFO, "\"%s\" will be loaded even though the default is to disable it.\n", ModuleDefaults[i].name);
+ xf86Msg(X_INFO,
+ "\"%s\" will be loaded even though the default is to disable it.\n",
+ ModuleDefaults[i].name);
found = TRUE;
break;
}
- modp = (XF86LoadPtr) modp->list.next;
+ modp = (XF86LoadPtr) modp->list.next;
}
}
if (found == FALSE) {
- XF86LoadPtr ptr = (XF86LoadPtr)xf86configptr->conf_modules;
- xf86addNewLoadDirective(ptr, ModuleDefaults[i].name, XF86_LOAD_MODULE, ModuleDefaults[i].load_opt);
- xf86Msg(X_INFO, "\"%s\" will be loaded by default.\n", ModuleDefaults[i].name);
+ XF86LoadPtr ptr = (XF86LoadPtr) xf86configptr->conf_modules;
+
+ xf86addNewLoadDirective(ptr, ModuleDefaults[i].name,
+ XF86_LOAD_MODULE,
+ ModuleDefaults[i].load_opt);
+ xf86Msg(X_INFO, "\"%s\" will be loaded by default.\n",
+ ModuleDefaults[i].name);
}
- }
- } else {
- xf86configptr->conf_modules = xnfcalloc(1, sizeof(XF86ConfModuleRec));
- for (i=0 ; ModuleDefaults[i].name != NULL ; i++) {
- if (ModuleDefaults[i].toLoad == TRUE) {
- XF86LoadPtr ptr = (XF86LoadPtr)xf86configptr->conf_modules;
- xf86addNewLoadDirective(ptr, ModuleDefaults[i].name, XF86_LOAD_MODULE, ModuleDefaults[i].load_opt);
- }
- }
- }
-
- /*
- * Walk the list of modules in the "Module" section to determine how
- * many we have.
- */
- modp = xf86configptr->conf_modules->mod_load_lst;
- while (modp) {
- for (i = 0; ignore[i]; i++) {
- if (strcmp(modp->load_name, ignore[i]) == 0)
- modp->ignore = 1;
- }
- if (!modp->ignore)
- count++;
- modp = (XF86LoadPtr) modp->list.next;
- }
+ }
+ }
+ else {
+ xf86configptr->conf_modules = xnfcalloc(1, sizeof(XF86ConfModuleRec));
+ for (i = 0; ModuleDefaults[i].name != NULL; i++) {
+ if (ModuleDefaults[i].toLoad == TRUE) {
+ XF86LoadPtr ptr = (XF86LoadPtr) xf86configptr->conf_modules;
+
+ xf86addNewLoadDirective(ptr, ModuleDefaults[i].name,
+ XF86_LOAD_MODULE,
+ ModuleDefaults[i].load_opt);
+ }
+ }
+ }
+
+ /*
+ * Walk the list of modules in the "Module" section to determine how
+ * many we have.
+ */
+ modp = xf86configptr->conf_modules->mod_load_lst;
+ while (modp) {
+ for (i = 0; ignore[i]; i++) {
+ if (strcmp(modp->load_name, ignore[i]) == 0)
+ modp->ignore = 1;
+ }
+ if (!modp->ignore)
+ count++;
+ modp = (XF86LoadPtr) modp->list.next;
+ }
/*
* allocate the memory and walk the list again to fill in the pointers
*/
- modulearray = xnfalloc((count + 1) * sizeof(char*));
+ modulearray = xnfalloc((count + 1) * sizeof(char *));
optarray = xnfalloc((count + 1) * sizeof(pointer));
count = 0;
if (xf86configptr->conf_modules) {
- modp = xf86configptr->conf_modules->mod_load_lst;
- while (modp) {
+ modp = xf86configptr->conf_modules->mod_load_lst;
+ while (modp) {
if (!modp->ignore) {
- modulearray[count] = modp->load_name;
- optarray[count] = modp->load_opt;
- count++;
+ modulearray[count] = modp->load_name;
+ optarray[count] = modp->load_opt;
+ count++;
}
- modp = (XF86LoadPtr) modp->list.next;
- }
+ modp = (XF86LoadPtr) modp->list.next;
+ }
}
modulearray[count] = NULL;
optarray[count] = NULL;
if (optlist)
- *optlist = optarray;
+ *optlist = optarray;
else
- free(optarray);
+ free(optarray);
return modulearray;
}
-
char **
xf86DriverlistFromConfig(void)
{
@@ -371,7 +388,7 @@ xf86DriverlistFromConfig(void)
int j;
char **modulearray;
screenLayoutPtr slp;
-
+
/*
* make sure the config file has been parsed and that we have a
* ModulePath set; if no ModulePath was given, use the default
@@ -381,7 +398,7 @@ xf86DriverlistFromConfig(void)
xf86Msg(X_ERROR, "Cannot access global config data structure\n");
return NULL;
}
-
+
/*
* Walk the list of driver lines in active "Device" sections to
* determine now many implicitly loaded modules there are.
@@ -390,7 +407,7 @@ xf86DriverlistFromConfig(void)
if (xf86ConfigLayout.screens) {
slp = xf86ConfigLayout.screens;
while ((slp++)->screen) {
- count++;
+ count++;
}
}
@@ -399,39 +416,39 @@ xf86DriverlistFromConfig(void)
*/
j = 0;
while (xf86ConfigLayout.inactives[j++].identifier)
- count++;
+ count++;
if (count == 0)
- return NULL;
+ return NULL;
/*
* allocate the memory and walk the list again to fill in the pointers
*/
- modulearray = xnfalloc((count + 1) * sizeof(char*));
+ modulearray = xnfalloc((count + 1) * sizeof(char *));
count = 0;
slp = xf86ConfigLayout.screens;
while (slp->screen) {
- modulearray[count] = slp->screen->device->driver;
- count++;
- slp++;
+ modulearray[count] = slp->screen->device->driver;
+ count++;
+ slp++;
}
j = 0;
- while (xf86ConfigLayout.inactives[j].identifier)
- modulearray[count++] = xf86ConfigLayout.inactives[j++].driver;
+ while (xf86ConfigLayout.inactives[j].identifier)
+ modulearray[count++] = xf86ConfigLayout.inactives[j++].driver;
modulearray[count] = NULL;
/* Remove duplicates */
for (count = 0; modulearray[count] != NULL; count++) {
- int i;
+ int i;
- for (i = 0; i < count; i++)
- if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
- modulearray[count] = "";
- break;
- }
+ for (i = 0; i < count; i++)
+ if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
+ modulearray[count] = "";
+ break;
+ }
}
return modulearray;
}
@@ -452,7 +469,7 @@ xf86InputDriverlistFromConfig(void)
xf86Msg(X_ERROR, "Cannot access global config data structure\n");
return NULL;
}
-
+
/*
* Walk the list of driver lines in active "InputDevice" sections to
* determine now many implicitly loaded modules there are.
@@ -460,36 +477,36 @@ xf86InputDriverlistFromConfig(void)
if (xf86ConfigLayout.inputs) {
idp = xf86ConfigLayout.inputs;
while (*idp) {
- count++;
- idp++;
+ count++;
+ idp++;
}
}
if (count == 0)
- return NULL;
+ return NULL;
/*
* allocate the memory and walk the list again to fill in the pointers
*/
- modulearray = xnfalloc((count + 1) * sizeof(char*));
+ modulearray = xnfalloc((count + 1) * sizeof(char *));
count = 0;
idp = xf86ConfigLayout.inputs;
while (idp && *idp) {
modulearray[count] = (*idp)->driver;
- count++;
- idp++;
+ count++;
+ idp++;
}
modulearray[count] = NULL;
/* Remove duplicates */
for (count = 0; modulearray[count] != NULL; count++) {
- int i;
+ int i;
- for (i = 0; i < count; i++)
- if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
- modulearray[count] = "";
- break;
- }
+ for (i = 0; i < count; i++)
+ if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
+ modulearray[count] = "";
+ break;
+ }
}
return modulearray;
}
@@ -503,7 +520,7 @@ fixup_video_driver_list(char **drivers)
int i;
/* walk to the end of the list */
- for (end = drivers; *end && **end; end++) ;
+ for (end = drivers; *end && **end; end++);
end--;
/*
@@ -513,7 +530,9 @@ fixup_video_driver_list(char **drivers)
for (i = 0; fallback[i]; i++) {
for (drv = drivers; drv != end; drv++) {
if (strstr(*drv, fallback[i])) {
- x = *drv; *drv = *end; *end = x;
+ x = *drv;
+ *drv = *end;
+ *end = x;
end--;
break;
}
@@ -522,13 +541,13 @@ fixup_video_driver_list(char **drivers)
}
static char **
-GenerateDriverlist(const char * dirname)
+GenerateDriverlist(const char *dirname)
{
char **ret;
const char *subdirs[] = { dirname, NULL };
- static const char *patlist[] = {"(.*)_drv\\.so", NULL};
+ static const char *patlist[] = { "(.*)_drv\\.so", NULL };
ret = LoaderListDirs(subdirs, patlist);
-
+
/* fix up the probe order for video drivers */
if (strstr(dirname, "drivers") && ret != NULL)
fixup_video_driver_list(ret);
@@ -552,7 +571,8 @@ xf86DriverlistFromCompile(void)
* Print a READABLE ErrorMessage!!! All information that is
* available is printed.
*/
-static void _X_ATTRIBUTE_PRINTF(1,2)
+static void
+_X_ATTRIBUTE_PRINTF(1, 2)
xf86ConfigError(const char *msg, ...)
{
va_list ap;
@@ -568,31 +588,31 @@ xf86ConfigError(const char *msg, ...)
static void
configFiles(XF86ConfFilesPtr fileconf)
{
- MessageType pathFrom;
- Bool must_copy;
- int size, countDirs;
- char *temp_path, *log_buf, *start, *end;
+ MessageType pathFrom;
+ Bool must_copy;
+ int size, countDirs;
+ char *temp_path, *log_buf, *start, *end;
/* FontPath */
must_copy = TRUE;
temp_path = defaultFontPath ? defaultFontPath : "";
if (xf86fpFlag)
- pathFrom = X_CMDLINE;
+ pathFrom = X_CMDLINE;
else if (fileconf && fileconf->file_fontpath) {
- pathFrom = X_CONFIG;
- if (xf86Info.useDefaultFontPath) {
- if (asprintf(&defaultFontPath, "%s%s%s", fileconf->file_fontpath,
- *temp_path ? "," : "", temp_path) == -1)
- defaultFontPath = NULL;
- else
- must_copy = FALSE;
- }
- else
- defaultFontPath = fileconf->file_fontpath;
+ pathFrom = X_CONFIG;
+ if (xf86Info.useDefaultFontPath) {
+ if (asprintf(&defaultFontPath, "%s%s%s", fileconf->file_fontpath,
+ *temp_path ? "," : "", temp_path) == -1)
+ defaultFontPath = NULL;
+ else
+ must_copy = FALSE;
+ }
+ else
+ defaultFontPath = fileconf->file_fontpath;
}
else
- pathFrom = X_DEFAULT;
+ pathFrom = X_DEFAULT;
temp_path = defaultFontPath ? defaultFontPath : "";
/* xf86ValidateFontPath modifies its argument, but returns a copy of it. */
@@ -604,61 +624,61 @@ configFiles(XF86ConfFilesPtr fileconf)
countDirs = 1;
temp_path = defaultFontPath;
while ((temp_path = index(temp_path, ',')) != NULL) {
- countDirs++;
- temp_path++;
+ countDirs++;
+ temp_path++;
}
log_buf = xnfalloc(strlen(defaultFontPath) + (2 * countDirs) + 1);
temp_path = log_buf;
start = defaultFontPath;
- while((end = index(start, ',')) != NULL) {
- size = (end - start) + 1;
- *(temp_path++) = '\t';
- strncpy(temp_path, start, size);
- temp_path += size;
- *(temp_path++) = '\n';
- start += size;
+ while ((end = index(start, ',')) != NULL) {
+ size = (end - start) + 1;
+ *(temp_path++) = '\t';
+ strncpy(temp_path, start, size);
+ temp_path += size;
+ *(temp_path++) = '\n';
+ start += size;
}
/* copy last entry */
*(temp_path++) = '\t';
strcpy(temp_path, start);
xf86Msg(pathFrom, "FontPath set to:\n%s\n", log_buf);
free(log_buf);
-
- /* ModulePath */
- if (fileconf) {
- if (xf86ModPathFrom != X_CMDLINE && fileconf->file_modulepath) {
- xf86ModulePath = fileconf->file_modulepath;
- xf86ModPathFrom = X_CONFIG;
+ /* ModulePath */
+
+ if (fileconf) {
+ if (xf86ModPathFrom != X_CMDLINE && fileconf->file_modulepath) {
+ xf86ModulePath = fileconf->file_modulepath;
+ xf86ModPathFrom = X_CONFIG;
+ }
}
- }
- xf86Msg(xf86ModPathFrom, "ModulePath set to \"%s\"\n", xf86ModulePath);
+ xf86Msg(xf86ModPathFrom, "ModulePath set to \"%s\"\n", xf86ModulePath);
- if (!xf86xkbdirFlag && fileconf && fileconf->file_xkbdir) {
- XkbBaseDirectory = fileconf->file_xkbdir;
- xf86Msg(X_CONFIG, "XKB base directory set to \"%s\"\n",
- XkbBaseDirectory);
- }
+ if (!xf86xkbdirFlag && fileconf && fileconf->file_xkbdir) {
+ XkbBaseDirectory = fileconf->file_xkbdir;
+ xf86Msg(X_CONFIG, "XKB base directory set to \"%s\"\n",
+ XkbBaseDirectory);
+ }
#if 0
- /* LogFile */
- /*
- * XXX The problem with this is that the log file is already open.
- * One option might be to copy the exiting contents to the new location.
- * and re-open it. The down side is that the default location would
- * already have been overwritten. Another option would be to start with
- * unique temporary location, then copy it once the correct name is known.
- * A problem with this is what happens if the server exits before that
- * happens.
- */
- if (xf86LogFileFrom == X_DEFAULT && fileconf->file_logfile) {
- xf86LogFile = fileconf->file_logfile;
- xf86LogFileFrom = X_CONFIG;
- }
+ /* LogFile */
+ /*
+ * XXX The problem with this is that the log file is already open.
+ * One option might be to copy the exiting contents to the new location.
+ * and re-open it. The down side is that the default location would
+ * already have been overwritten. Another option would be to start with
+ * unique temporary location, then copy it once the correct name is known.
+ * A problem with this is what happens if the server exits before that
+ * happens.
+ */
+ if (xf86LogFileFrom == X_DEFAULT && fileconf->file_logfile) {
+ xf86LogFile = fileconf->file_logfile;
+ xf86LogFileFrom = X_CONFIG;
+ }
#endif
- return;
+ return;
}
typedef enum {
@@ -695,58 +715,58 @@ typedef enum {
* if the parser found the option in the config file.
*/
static OptionInfoRec FlagOptions[] = {
- { FLAG_NOTRAPSIGNALS, "NoTrapSignals", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_DONTVTSWITCH, "DontVTSwitch", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_DONTZAP, "DontZap", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_DONTZOOM, "DontZoom", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_DISABLEVIDMODE, "DisableVidModeExtension", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_ALLOWNONLOCAL, "AllowNonLocalXvidtune", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_ALLOWMOUSEOPENFAIL, "AllowMouseOpenFail", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_SAVER_BLANKTIME, "BlankTime" , OPTV_INTEGER,
- {0}, FALSE },
- { FLAG_DPMS_STANDBYTIME, "StandbyTime", OPTV_INTEGER,
- {0}, FALSE },
- { FLAG_DPMS_SUSPENDTIME, "SuspendTime", OPTV_INTEGER,
- {0}, FALSE },
- { FLAG_DPMS_OFFTIME, "OffTime", OPTV_INTEGER,
- {0}, FALSE },
- { FLAG_PIXMAP, "Pixmap", OPTV_INTEGER,
- {0}, FALSE },
- { FLAG_NOPM, "NoPM", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_XINERAMA, "Xinerama", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_LOG, "Log", OPTV_STRING,
- {0}, FALSE },
- { FLAG_RENDER_COLORMAP_MODE, "RenderColormapMode", OPTV_STRING,
- {0}, FALSE },
- { FLAG_RANDR, "RandR", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_AIGLX, "AIGLX", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_IGNORE_ABI, "IgnoreABI", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_USE_DEFAULT_FONT_PATH, "UseDefaultFontPath", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_AUTO_ADD_DEVICES, "AutoAddDevices", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_AUTO_ENABLE_DEVICES, "AutoEnableDevices", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_GLX_VISUALS, "GlxVisuals", OPTV_STRING,
- {0}, FALSE },
- { FLAG_DRI2, "DRI2", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_USE_SIGIO, "UseSIGIO", OPTV_BOOLEAN,
- {0}, FALSE },
- { -1, NULL, OPTV_NONE,
- {0}, FALSE },
+ {FLAG_NOTRAPSIGNALS, "NoTrapSignals", OPTV_BOOLEAN,
+ {0}, FALSE},
+ {FLAG_DONTVTSWITCH, "DontVTSwitch", OPTV_BOOLEAN,
+ {0}, FALSE},
+ {FLAG_DONTZAP, "DontZap", OPTV_BOOLEAN,
+ {0}, FALSE},
+ {FLAG_DONTZOOM, "DontZoom", OPTV_BOOLEAN,
+ {0}, FALSE},
+ {FLAG_DISABLEVIDMODE, "DisableVidModeExtension", OPTV_BOOLEAN,
+ {0}, FALSE},
+ {FLAG_ALLOWNONLOCAL, "AllowNonLocalXvidtune", OPTV_BOOLEAN,
+ {0}, FALSE},
+ {FLAG_ALLOWMOUSEOPENFAIL, "AllowMouseOpenFail", OPTV_BOOLEAN,
+ {0}, FALSE},
+ {FLAG_SAVER_BLANKTIME, "BlankTime", OPTV_INTEGER,
+ {0}, FALSE},
+ {FLAG_DPMS_STANDBYTIME, "StandbyTime", OPTV_INTEGER,
+ {0}, FALSE},
+ {FLAG_DPMS_SUSPENDTIME, "SuspendTime", OPTV_INTEGER,
+ {0}, FALSE},
+ {FLAG_DPMS_OFFTIME, "OffTime", OPTV_INTEGER,
+ {0}, FALSE},
+ {FLAG_PIXMAP, "Pixmap", OPTV_INTEGER,
+ {0}, FALSE},
+ {FLAG_NOPM, "NoPM", OPTV_BOOLEAN,
+ {0}, FALSE},
+ {FLAG_XINERAMA, "Xinerama", OPTV_BOOLEAN,
+ {0}, FALSE},
+ {FLAG_LOG, "Log", OPTV_STRING,
+ {0}, FALSE},
+ {FLAG_RENDER_COLORMAP_MODE, "RenderColormapMode", OPTV_STRING,
+ {0}, FALSE},
+ {FLAG_RANDR, "RandR", OPTV_BOOLEAN,
+ {0}, FALSE},
+ {FLAG_AIGLX, "AIGLX", OPTV_BOOLEAN,
+ {0}, FALSE},
+ {FLAG_IGNORE_ABI, "IgnoreABI", OPTV_BOOLEAN,
+ {0}, FALSE},
+ {FLAG_USE_DEFAULT_FONT_PATH, "UseDefaultFontPath", OPTV_BOOLEAN,
+ {0}, FALSE},
+ {FLAG_AUTO_ADD_DEVICES, "AutoAddDevices", OPTV_BOOLEAN,
+ {0}, FALSE},
+ {FLAG_AUTO_ENABLE_DEVICES, "AutoEnableDevices", OPTV_BOOLEAN,
+ {0}, FALSE},
+ {FLAG_GLX_VISUALS, "GlxVisuals", OPTV_STRING,
+ {0}, FALSE},
+ {FLAG_DRI2, "DRI2", OPTV_BOOLEAN,
+ {0}, FALSE},
+ {FLAG_USE_SIGIO, "UseSIGIO", OPTV_BOOLEAN,
+ {0}, FALSE},
+ {-1, NULL, OPTV_NONE,
+ {0}, FALSE},
};
static Bool
@@ -759,6 +779,7 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
MessageType from;
const char *s;
XkbRMLVOSet set;
+
/* Default options. */
set.rules = "base";
set.model = "pc105";
@@ -772,13 +793,13 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
*/
optp = NULL;
if (flagsconf && flagsconf->flg_option_lst)
- optp = xf86optionListDup(flagsconf->flg_option_lst);
+ optp = xf86optionListDup(flagsconf->flg_option_lst);
if (layoutopts) {
- tmp = xf86optionListDup(layoutopts);
- if (optp)
- optp = xf86optionListMerge(optp, tmp);
- else
- optp = tmp;
+ tmp = xf86optionListDup(layoutopts);
+ if (optp)
+ optp = xf86optionListMerge(optp, tmp);
+ else
+ optp = tmp;
}
xf86ProcessOptions(-1, optp, FlagOptions);
@@ -790,23 +811,28 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
xf86GetOptValBool(FlagOptions, FLAG_IGNORE_ABI, &xf86Info.ignoreABI);
if (xf86Info.ignoreABI) {
- xf86Msg(X_CONFIG, "Ignoring ABI Version\n");
+ xf86Msg(X_CONFIG, "Ignoring ABI Version\n");
}
if (xf86SIGIOSupported()) {
- xf86Info.useSIGIO = xf86ReturnOptValBool(FlagOptions, FLAG_USE_SIGIO, USE_SIGIO_BY_DEFAULT);
- if (xf86IsOptionSet(FlagOptions, FLAG_USE_SIGIO)) {
- from = X_CONFIG;
- } else {
- from = X_DEFAULT;
- }
- if (!xf86Info.useSIGIO) {
- xf86Msg(from, "Disabling SIGIO handlers for input devices\n");
- } else if (from == X_CONFIG) {
- xf86Msg(from, "Enabling SIGIO handlers for input devices\n");
- }
- } else {
- xf86Info.useSIGIO = FALSE;
+ xf86Info.useSIGIO =
+ xf86ReturnOptValBool(FlagOptions, FLAG_USE_SIGIO,
+ USE_SIGIO_BY_DEFAULT);
+ if (xf86IsOptionSet(FlagOptions, FLAG_USE_SIGIO)) {
+ from = X_CONFIG;
+ }
+ else {
+ from = X_DEFAULT;
+ }
+ if (!xf86Info.useSIGIO) {
+ xf86Msg(from, "Disabling SIGIO handlers for input devices\n");
+ }
+ else if (from == X_CONFIG) {
+ xf86Msg(from, "Enabling SIGIO handlers for input devices\n");
+ }
+ }
+ else {
+ xf86Info.useSIGIO = FALSE;
}
if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ADD_DEVICES)) {
@@ -838,86 +864,92 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
*/
#ifdef XF86VIDMODE
if (xf86GetOptValBool(FlagOptions, FLAG_DISABLEVIDMODE, &value))
- xf86Info.vidModeEnabled = !value;
+ xf86Info.vidModeEnabled = !value;
if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWNONLOCAL, &value))
- xf86Info.vidModeAllowNonLocal = value;
+ xf86Info.vidModeAllowNonLocal = value;
#endif
if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWMOUSEOPENFAIL, &value))
- xf86Info.allowMouseOpenFail = value;
+ xf86Info.allowMouseOpenFail = value;
xf86Info.pmFlag = TRUE;
- if (xf86GetOptValBool(FlagOptions, FLAG_NOPM, &value))
- xf86Info.pmFlag = !value;
+ if (xf86GetOptValBool(FlagOptions, FLAG_NOPM, &value))
+ xf86Info.pmFlag = !value;
{
- if ((s = xf86GetOptValString(FlagOptions, FLAG_LOG))) {
- if (!xf86NameCmp(s,"flush")) {
- xf86Msg(X_CONFIG, "Flushing logfile enabled\n");
- xf86Info.log = LogFlush;
- LogSetParameter(XLOG_FLUSH, TRUE);
- } else if (!xf86NameCmp(s,"sync")) {
- xf86Msg(X_CONFIG, "Syncing logfile enabled\n");
- xf86Info.log = LogSync;
- LogSetParameter(XLOG_FLUSH, TRUE);
- LogSetParameter(XLOG_SYNC, TRUE);
- } else {
- xf86Msg(X_WARNING,"Unknown Log option\n");
- }
- }
- }
-
+ if ((s = xf86GetOptValString(FlagOptions, FLAG_LOG))) {
+ if (!xf86NameCmp(s, "flush")) {
+ xf86Msg(X_CONFIG, "Flushing logfile enabled\n");
+ xf86Info.log = LogFlush;
+ LogSetParameter(XLOG_FLUSH, TRUE);
+ }
+ else if (!xf86NameCmp(s, "sync")) {
+ xf86Msg(X_CONFIG, "Syncing logfile enabled\n");
+ xf86Info.log = LogSync;
+ LogSetParameter(XLOG_FLUSH, TRUE);
+ LogSetParameter(XLOG_SYNC, TRUE);
+ }
+ else {
+ xf86Msg(X_WARNING, "Unknown Log option\n");
+ }
+ }
+ }
+
{
- if ((s = xf86GetOptValString(FlagOptions, FLAG_RENDER_COLORMAP_MODE))){
- int policy = PictureParseCmapPolicy (s);
- if (policy == PictureCmapPolicyInvalid)
- xf86Msg(X_WARNING, "Unknown colormap policy \"%s\"\n", s);
- else
- {
- xf86Msg(X_CONFIG, "Render colormap policy set to %s\n", s);
- PictureCmapPolicy = policy;
- }
- }
+ if ((s = xf86GetOptValString(FlagOptions, FLAG_RENDER_COLORMAP_MODE))) {
+ int policy = PictureParseCmapPolicy(s);
+
+ if (policy == PictureCmapPolicyInvalid)
+ xf86Msg(X_WARNING, "Unknown colormap policy \"%s\"\n", s);
+ else {
+ xf86Msg(X_CONFIG, "Render colormap policy set to %s\n", s);
+ PictureCmapPolicy = policy;
+ }
+ }
}
#ifdef RANDR
xf86Info.disableRandR = FALSE;
xf86Info.randRFrom = X_DEFAULT;
if (xf86GetOptValBool(FlagOptions, FLAG_RANDR, &value)) {
- xf86Info.disableRandR = !value;
- xf86Info.randRFrom = X_CONFIG;
+ xf86Info.disableRandR = !value;
+ xf86Info.randRFrom = X_CONFIG;
}
#endif
xf86Info.aiglx = TRUE;
xf86Info.aiglxFrom = X_DEFAULT;
if (xf86GetOptValBool(FlagOptions, FLAG_AIGLX, &value)) {
- xf86Info.aiglx = value;
- xf86Info.aiglxFrom = X_CONFIG;
+ xf86Info.aiglx = value;
+ xf86Info.aiglxFrom = X_CONFIG;
}
#ifdef GLXEXT
xf86Info.glxVisuals = XF86_GlxVisualsTypical;
xf86Info.glxVisualsFrom = X_DEFAULT;
if ((s = xf86GetOptValString(FlagOptions, FLAG_GLX_VISUALS))) {
- if (!xf86NameCmp(s, "minimal")) {
- xf86Info.glxVisuals = XF86_GlxVisualsMinimal;
- } else if (!xf86NameCmp(s, "typical")) {
- xf86Info.glxVisuals = XF86_GlxVisualsTypical;
- } else if (!xf86NameCmp(s, "all")) {
- xf86Info.glxVisuals = XF86_GlxVisualsAll;
- } else {
- xf86Msg(X_WARNING,"Unknown GlxVisuals option\n");
- }
+ if (!xf86NameCmp(s, "minimal")) {
+ xf86Info.glxVisuals = XF86_GlxVisualsMinimal;
+ }
+ else if (!xf86NameCmp(s, "typical")) {
+ xf86Info.glxVisuals = XF86_GlxVisualsTypical;
+ }
+ else if (!xf86NameCmp(s, "all")) {
+ xf86Info.glxVisuals = XF86_GlxVisualsAll;
+ }
+ else {
+ xf86Msg(X_WARNING, "Unknown GlxVisuals option\n");
+ }
}
if (xf86GetOptValBool(FlagOptions, FLAG_AIGLX, &value)) {
- xf86Info.aiglx = value;
- xf86Info.aiglxFrom = X_CONFIG;
+ xf86Info.aiglx = value;
+ xf86Info.aiglxFrom = X_CONFIG;
}
#endif
/* if we're not hotplugging, force some input devices to exist */
- xf86Info.forceInputDevices = !(xf86Info.autoAddDevices && xf86Info.autoEnableDevices);
+ xf86Info.forceInputDevices = !(xf86Info.autoAddDevices &&
+ xf86Info.autoEnableDevices);
/* when forcing input devices, we use kbd. otherwise evdev, so use the
* evdev rules set. */
@@ -930,8 +962,8 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
xf86Info.useDefaultFontPath = TRUE;
xf86Info.useDefaultFontPathFrom = X_DEFAULT;
if (xf86GetOptValBool(FlagOptions, FLAG_USE_DEFAULT_FONT_PATH, &value)) {
- xf86Info.useDefaultFontPath = value;
- xf86Info.useDefaultFontPathFrom = X_CONFIG;
+ xf86Info.useDefaultFontPath = value;
+ xf86Info.useDefaultFontPathFrom = X_CONFIG;
}
/* Make sure that timers don't overflow CARD32's after multiplying */
@@ -940,86 +972,93 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
i = -1;
xf86GetOptValInteger(FlagOptions, FLAG_SAVER_BLANKTIME, &i);
if ((i >= 0) && (i < MAX_TIME_IN_MIN))
- ScreenSaverTime = defaultScreenSaverTime = i * MILLI_PER_MIN;
+ ScreenSaverTime = defaultScreenSaverTime = i * MILLI_PER_MIN;
else if (i != -1)
- xf86ConfigError("BlankTime value %d outside legal range of 0 - %d minutes",
- i, MAX_TIME_IN_MIN);
+ xf86ConfigError
+ ("BlankTime value %d outside legal range of 0 - %d minutes", i,
+ MAX_TIME_IN_MIN);
#ifdef DPMSExtension
i = -1;
xf86GetOptValInteger(FlagOptions, FLAG_DPMS_STANDBYTIME, &i);
if ((i >= 0) && (i < MAX_TIME_IN_MIN))
- DPMSStandbyTime = i * MILLI_PER_MIN;
+ DPMSStandbyTime = i * MILLI_PER_MIN;
else if (i != -1)
- xf86ConfigError("StandbyTime value %d outside legal range of 0 - %d minutes",
- i, MAX_TIME_IN_MIN);
+ xf86ConfigError
+ ("StandbyTime value %d outside legal range of 0 - %d minutes", i,
+ MAX_TIME_IN_MIN);
i = -1;
xf86GetOptValInteger(FlagOptions, FLAG_DPMS_SUSPENDTIME, &i);
if ((i >= 0) && (i < MAX_TIME_IN_MIN))
- DPMSSuspendTime = i * MILLI_PER_MIN;
+ DPMSSuspendTime = i * MILLI_PER_MIN;
else if (i != -1)
- xf86ConfigError("SuspendTime value %d outside legal range of 0 - %d minutes",
- i, MAX_TIME_IN_MIN);
+ xf86ConfigError
+ ("SuspendTime value %d outside legal range of 0 - %d minutes", i,
+ MAX_TIME_IN_MIN);
i = -1;
xf86GetOptValInteger(FlagOptions, FLAG_DPMS_OFFTIME, &i);
if ((i >= 0) && (i < MAX_TIME_IN_MIN))
- DPMSOffTime = i * MILLI_PER_MIN;
+ DPMSOffTime = i * MILLI_PER_MIN;
else if (i != -1)
- xf86ConfigError("OffTime value %d outside legal range of 0 - %d minutes",
- i, MAX_TIME_IN_MIN);
+ xf86ConfigError
+ ("OffTime value %d outside legal range of 0 - %d minutes", i,
+ MAX_TIME_IN_MIN);
#endif
i = -1;
xf86GetOptValInteger(FlagOptions, FLAG_PIXMAP, &i);
switch (i) {
case 24:
- pix24 = Pix24Use24;
- break;
+ pix24 = Pix24Use24;
+ break;
case 32:
- pix24 = Pix24Use32;
- break;
+ pix24 = Pix24Use32;
+ break;
case -1:
- break;
+ break;
default:
- xf86ConfigError("Pixmap option's value (%d) must be 24 or 32\n", i);
- return FALSE;
+ xf86ConfigError("Pixmap option's value (%d) must be 24 or 32\n", i);
+ return FALSE;
}
if (xf86Pix24 != Pix24DontCare) {
- xf86Info.pixmap24 = xf86Pix24;
- xf86Info.pix24From = X_CMDLINE;
- } else if (pix24 != Pix24DontCare) {
- xf86Info.pixmap24 = pix24;
- xf86Info.pix24From = X_CONFIG;
- } else {
- xf86Info.pixmap24 = Pix24DontCare;
- xf86Info.pix24From = X_DEFAULT;
+ xf86Info.pixmap24 = xf86Pix24;
+ xf86Info.pix24From = X_CMDLINE;
+ }
+ else if (pix24 != Pix24DontCare) {
+ xf86Info.pixmap24 = pix24;
+ xf86Info.pix24From = X_CONFIG;
+ }
+ else {
+ xf86Info.pixmap24 = Pix24DontCare;
+ xf86Info.pix24From = X_DEFAULT;
}
#ifdef PANORAMIX
from = X_DEFAULT;
if (!noPanoramiXExtension)
- from = X_CMDLINE;
+ from = X_CMDLINE;
else if (xf86GetOptValBool(FlagOptions, FLAG_XINERAMA, &value)) {
- noPanoramiXExtension = !value;
- from = X_CONFIG;
+ noPanoramiXExtension = !value;
+ from = X_CONFIG;
}
if (!noPanoramiXExtension)
- xf86Msg(from, "Xinerama: enabled\n");
+ xf86Msg(from, "Xinerama: enabled\n");
#endif
#ifdef DRI2
xf86Info.dri2 = FALSE;
xf86Info.dri2From = X_DEFAULT;
if (xf86GetOptValBool(FlagOptions, FLAG_DRI2, &value)) {
- xf86Info.dri2 = value;
- xf86Info.dri2From = X_CONFIG;
+ xf86Info.dri2 = value;
+ xf86Info.dri2From = X_CONFIG;
}
#endif
return TRUE;
}
-Bool xf86DRI2Enabled(void)
+Bool
+xf86DRI2Enabled(void)
{
return xf86Info.dri2;
}
@@ -1029,17 +1068,17 @@ Bool xf86DRI2Enabled(void)
* free) it if present. All other devices are moved forward.
*/
static void
-freeDevice(InputInfoPtr *list, InputInfoPtr pInfo)
+freeDevice(InputInfoPtr * list, InputInfoPtr pInfo)
{
InputInfoPtr *devs;
for (devs = list; devs && *devs; devs++) {
- if (*devs == pInfo) {
- free(*devs);
- for (; devs && *devs; devs++)
- devs[0] = devs[1];
- break;
- }
+ if (*devs == pInfo) {
+ free(*devs);
+ for (; devs && *devs; devs++)
+ devs[0] = devs[1];
+ break;
+ }
}
}
@@ -1047,14 +1086,14 @@ freeDevice(InputInfoPtr *list, InputInfoPtr pInfo)
* Append pInfo to the null-terminated list, allocating space as necessary.
* pInfo is used as the last element.
*/
-static InputInfoPtr*
-addDevice(InputInfoPtr *list, InputInfoPtr pInfo)
+static InputInfoPtr *
+addDevice(InputInfoPtr * list, InputInfoPtr pInfo)
{
InputInfoPtr *devs;
int count = 1;
for (devs = list; devs && *devs; devs++)
- count++;
+ count++;
list = xnfrealloc(list, (count + 1) * sizeof(InputInfoPtr));
list[count] = NULL;
@@ -1084,14 +1123,16 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
InputInfoPtr corePointer = NULL, coreKeyboard = NULL;
Bool foundPointer = FALSE, foundKeyboard = FALSE;
const char *pointerMsg = NULL, *keyboardMsg = NULL;
- InputInfoPtr *devs, /* iterator */
- indp;
+ InputInfoPtr *devs, /* iterator */
+ indp;
InputInfoPtr Pointer, Keyboard;
XF86ConfInputPtr confInput;
XF86ConfInputRec defPtr, defKbd;
MessageType from = X_DEFAULT;
+
const char *mousedrivers[] = { "mouse", "synaptics", "evdev", "vmmouse",
- "void", NULL };
+ "void", NULL
+ };
/*
* First check if a core pointer or core keyboard have been specified
@@ -1100,249 +1141,255 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
*/
for (devs = servlayoutp->inputs; devs && *devs; devs++) {
indp = *devs;
- if (indp->options &&
- xf86CheckBoolOption(indp->options, "CorePointer", FALSE)) {
- if (!corePointer) {
- corePointer = indp;
- }
- }
- if (indp->options &&
- xf86CheckBoolOption(indp->options, "CoreKeyboard", FALSE)) {
- if (!coreKeyboard) {
- coreKeyboard = indp;
- }
- }
+ if (indp->options &&
+ xf86CheckBoolOption(indp->options, "CorePointer", FALSE)) {
+ if (!corePointer) {
+ corePointer = indp;
+ }
+ }
+ if (indp->options &&
+ xf86CheckBoolOption(indp->options, "CoreKeyboard", FALSE)) {
+ if (!coreKeyboard) {
+ coreKeyboard = indp;
+ }
+ }
}
confInput = NULL;
/* 1. Check for the -pointer command line option. */
if (xf86PointerName) {
- confInput = xf86findInput(xf86PointerName,
- xf86configptr->conf_input_lst);
- if (!confInput) {
- xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n",
- xf86PointerName);
- return FALSE;
- }
- from = X_CMDLINE;
- /*
- * If one was already specified in the ServerLayout, it needs to be
- * removed.
- */
- if (corePointer) {
- freeDevice(servlayoutp->inputs, corePointer);
- corePointer = NULL;
- }
- foundPointer = TRUE;
+ confInput = xf86findInput(xf86PointerName,
+ xf86configptr->conf_input_lst);
+ if (!confInput) {
+ xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n",
+ xf86PointerName);
+ return FALSE;
+ }
+ from = X_CMDLINE;
+ /*
+ * If one was already specified in the ServerLayout, it needs to be
+ * removed.
+ */
+ if (corePointer) {
+ freeDevice(servlayoutp->inputs, corePointer);
+ corePointer = NULL;
+ }
+ foundPointer = TRUE;
}
/* 2. ServerLayout-specified core pointer. */
if (corePointer) {
- foundPointer = TRUE;
- from = X_CONFIG;
+ foundPointer = TRUE;
+ from = X_CONFIG;
}
/* 3. First core pointer device. */
if (!foundPointer && (xf86Info.forceInputDevices || implicitLayout)) {
- XF86ConfInputPtr p;
-
- for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
- if (p->inp_option_lst &&
- xf86CheckBoolOption(p->inp_option_lst, "CorePointer", FALSE)) {
- confInput = p;
- foundPointer = TRUE;
- from = X_DEFAULT;
- pointerMsg = "first core pointer device";
- break;
- }
- }
+ XF86ConfInputPtr p;
+
+ for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
+ if (p->inp_option_lst &&
+ xf86CheckBoolOption(p->inp_option_lst, "CorePointer", FALSE)) {
+ confInput = p;
+ foundPointer = TRUE;
+ from = X_DEFAULT;
+ pointerMsg = "first core pointer device";
+ break;
+ }
+ }
}
/* 4. First pointer with an allowed mouse driver. */
if (!foundPointer && xf86Info.forceInputDevices) {
- const char **driver = mousedrivers;
- confInput = xf86findInput(CONF_IMPLICIT_POINTER,
- xf86configptr->conf_input_lst);
- while (*driver && !confInput) {
- confInput = xf86findInputByDriver(*driver,
- xf86configptr->conf_input_lst);
- driver++;
- }
- if (confInput) {
- foundPointer = TRUE;
- from = X_DEFAULT;
- pointerMsg = "first mouse device";
- }
+ const char **driver = mousedrivers;
+
+ confInput = xf86findInput(CONF_IMPLICIT_POINTER,
+ xf86configptr->conf_input_lst);
+ while (*driver && !confInput) {
+ confInput = xf86findInputByDriver(*driver,
+ xf86configptr->conf_input_lst);
+ driver++;
+ }
+ if (confInput) {
+ foundPointer = TRUE;
+ from = X_DEFAULT;
+ pointerMsg = "first mouse device";
+ }
}
/* 5. Built-in default. */
if (!foundPointer && xf86Info.forceInputDevices) {
- memset(&defPtr, 0, sizeof(defPtr));
- defPtr.inp_identifier = strdup("<default pointer>");
- defPtr.inp_driver = strdup("mouse");
- confInput = &defPtr;
- foundPointer = TRUE;
- from = X_DEFAULT;
- pointerMsg = "default mouse configuration";
+ memset(&defPtr, 0, sizeof(defPtr));
+ defPtr.inp_identifier = strdup("<default pointer>");
+ defPtr.inp_driver = strdup("mouse");
+ confInput = &defPtr;
+ foundPointer = TRUE;
+ from = X_DEFAULT;
+ pointerMsg = "default mouse configuration";
}
/* Add the core pointer device to the layout, and set it to Core. */
if (foundPointer && confInput) {
- Pointer = xf86AllocateInput();
- if (Pointer)
- foundPointer = configInput(Pointer, confInput, from);
- if (foundPointer) {
- Pointer->options = xf86AddNewOption(Pointer->options,
- "CorePointer", "on");
- Pointer->options = xf86AddNewOption(Pointer->options,
- "driver", confInput->inp_driver);
- Pointer->options = xf86AddNewOption(Pointer->options,
- "identifier", confInput->inp_identifier);
- servlayoutp->inputs = addDevice(servlayoutp->inputs, Pointer);
- }
+ Pointer = xf86AllocateInput();
+ if (Pointer)
+ foundPointer = configInput(Pointer, confInput, from);
+ if (foundPointer) {
+ Pointer->options = xf86AddNewOption(Pointer->options,
+ "CorePointer", "on");
+ Pointer->options = xf86AddNewOption(Pointer->options,
+ "driver",
+ confInput->inp_driver);
+ Pointer->options =
+ xf86AddNewOption(Pointer->options, "identifier",
+ confInput->inp_identifier);
+ servlayoutp->inputs = addDevice(servlayoutp->inputs, Pointer);
+ }
}
if (!foundPointer && xf86Info.forceInputDevices) {
- /* This shouldn't happen. */
- xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n");
- xf86DeleteInput(Pointer, 0);
- return FALSE;
+ /* This shouldn't happen. */
+ xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n");
+ xf86DeleteInput(Pointer, 0);
+ return FALSE;
}
confInput = NULL;
/* 1. Check for the -keyboard command line option. */
if (xf86KeyboardName) {
- confInput = xf86findInput(xf86KeyboardName,
- xf86configptr->conf_input_lst);
- if (!confInput) {
- xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n",
- xf86KeyboardName);
- return FALSE;
- }
- from = X_CMDLINE;
- /*
- * If one was already specified in the ServerLayout, it needs to be
- * removed.
- */
- if (coreKeyboard) {
- freeDevice(servlayoutp->inputs, coreKeyboard);
- coreKeyboard = NULL;
- }
- foundKeyboard = TRUE;
+ confInput = xf86findInput(xf86KeyboardName,
+ xf86configptr->conf_input_lst);
+ if (!confInput) {
+ xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n",
+ xf86KeyboardName);
+ return FALSE;
+ }
+ from = X_CMDLINE;
+ /*
+ * If one was already specified in the ServerLayout, it needs to be
+ * removed.
+ */
+ if (coreKeyboard) {
+ freeDevice(servlayoutp->inputs, coreKeyboard);
+ coreKeyboard = NULL;
+ }
+ foundKeyboard = TRUE;
}
/* 2. ServerLayout-specified core keyboard. */
if (coreKeyboard) {
- foundKeyboard = TRUE;
- from = X_CONFIG;
+ foundKeyboard = TRUE;
+ from = X_CONFIG;
}
/* 3. First core keyboard device. */
if (!foundKeyboard && (xf86Info.forceInputDevices || implicitLayout)) {
- XF86ConfInputPtr p;
-
- for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
- if (p->inp_option_lst &&
- xf86CheckBoolOption(p->inp_option_lst, "CoreKeyboard", FALSE)) {
- confInput = p;
- foundKeyboard = TRUE;
- from = X_DEFAULT;
- keyboardMsg = "first core keyboard device";
- break;
- }
- }
+ XF86ConfInputPtr p;
+
+ for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
+ if (p->inp_option_lst &&
+ xf86CheckBoolOption(p->inp_option_lst, "CoreKeyboard", FALSE)) {
+ confInput = p;
+ foundKeyboard = TRUE;
+ from = X_DEFAULT;
+ keyboardMsg = "first core keyboard device";
+ break;
+ }
+ }
}
/* 4. First keyboard with 'keyboard' or 'kbd' as the driver. */
if (!foundKeyboard && xf86Info.forceInputDevices) {
- confInput = xf86findInput(CONF_IMPLICIT_KEYBOARD,
- xf86configptr->conf_input_lst);
- if (!confInput) {
- confInput = xf86findInputByDriver("kbd",
- xf86configptr->conf_input_lst);
- }
- if (confInput) {
- foundKeyboard = TRUE;
- from = X_DEFAULT;
- keyboardMsg = "first keyboard device";
- }
+ confInput = xf86findInput(CONF_IMPLICIT_KEYBOARD,
+ xf86configptr->conf_input_lst);
+ if (!confInput) {
+ confInput = xf86findInputByDriver("kbd",
+ xf86configptr->conf_input_lst);
+ }
+ if (confInput) {
+ foundKeyboard = TRUE;
+ from = X_DEFAULT;
+ keyboardMsg = "first keyboard device";
+ }
}
/* 5. Built-in default. */
if (!foundKeyboard && xf86Info.forceInputDevices) {
- memset(&defKbd, 0, sizeof(defKbd));
- defKbd.inp_identifier = strdup("<default keyboard>");
- defKbd.inp_driver = strdup("kbd");
- confInput = &defKbd;
- foundKeyboard = TRUE;
- keyboardMsg = "default keyboard configuration";
- from = X_DEFAULT;
+ memset(&defKbd, 0, sizeof(defKbd));
+ defKbd.inp_identifier = strdup("<default keyboard>");
+ defKbd.inp_driver = strdup("kbd");
+ confInput = &defKbd;
+ foundKeyboard = TRUE;
+ keyboardMsg = "default keyboard configuration";
+ from = X_DEFAULT;
}
/* Add the core keyboard device to the layout, and set it to Core. */
if (foundKeyboard && confInput) {
- Keyboard = xf86AllocateInput();
- if (Keyboard)
- foundKeyboard = configInput(Keyboard, confInput, from);
- if (foundKeyboard) {
- Keyboard->options = xf86AddNewOption(Keyboard->options,
- "CoreKeyboard", "on");
- Keyboard->options = xf86AddNewOption(Keyboard->options,
- "driver", confInput->inp_driver);
- Keyboard->options = xf86AddNewOption(Keyboard->options,
- "identifier", confInput->inp_identifier);
- servlayoutp->inputs = addDevice(servlayoutp->inputs, Keyboard);
- }
+ Keyboard = xf86AllocateInput();
+ if (Keyboard)
+ foundKeyboard = configInput(Keyboard, confInput, from);
+ if (foundKeyboard) {
+ Keyboard->options = xf86AddNewOption(Keyboard->options,
+ "CoreKeyboard", "on");
+ Keyboard->options = xf86AddNewOption(Keyboard->options,
+ "driver",
+ confInput->inp_driver);
+ Keyboard->options =
+ xf86AddNewOption(Keyboard->options, "identifier",
+ confInput->inp_identifier);
+ servlayoutp->inputs = addDevice(servlayoutp->inputs, Keyboard);
+ }
}
if (!foundKeyboard && xf86Info.forceInputDevices) {
- /* This shouldn't happen. */
- xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n");
- xf86DeleteInput(Keyboard, 0);
- return FALSE;
+ /* This shouldn't happen. */
+ xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n");
+ xf86DeleteInput(Keyboard, 0);
+ return FALSE;
}
if (pointerMsg) {
- if (implicitLayout)
- xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n",
- pointerMsg);
- else
- xf86Msg(X_DEFAULT, "The core pointer device wasn't specified "
- "explicitly in the layout.\n"
- "\tUsing the %s.\n", pointerMsg);
+ if (implicitLayout)
+ xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n",
+ pointerMsg);
+ else
+ xf86Msg(X_DEFAULT, "The core pointer device wasn't specified "
+ "explicitly in the layout.\n"
+ "\tUsing the %s.\n", pointerMsg);
}
if (keyboardMsg) {
- if (implicitLayout)
- xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n",
- keyboardMsg);
- else
- xf86Msg(X_DEFAULT, "The core keyboard device wasn't specified "
- "explicitly in the layout.\n"
- "\tUsing the %s.\n", keyboardMsg);
+ if (implicitLayout)
+ xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n",
+ keyboardMsg);
+ else
+ xf86Msg(X_DEFAULT, "The core keyboard device wasn't specified "
+ "explicitly in the layout.\n"
+ "\tUsing the %s.\n", keyboardMsg);
}
if (!xf86Info.forceInputDevices && !(foundPointer && foundKeyboard)) {
#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS)
- const char *config_backend;
+ const char *config_backend;
+
#if defined(CONFIG_HAL)
- config_backend = "HAL";
+ config_backend = "HAL";
#elif defined(CONFIG_UDEV)
- config_backend = "udev";
+ config_backend = "udev";
#else
- config_backend = "wscons";
+ config_backend = "wscons";
#endif
- xf86Msg(X_INFO, "The server relies on %s to provide the list of "
- "input devices.\n\tIf no devices become available, "
- "reconfigure %s or disable AutoAddDevices.\n",
- config_backend, config_backend);
+ xf86Msg(X_INFO, "The server relies on %s to provide the list of "
+ "input devices.\n\tIf no devices become available, "
+ "reconfigure %s or disable AutoAddDevices.\n",
+ config_backend, config_backend);
#else
- xf86Msg(X_WARNING, "Hotplugging requested but the server was "
- "compiled without a config backend. "
- "No input devices were configured, the server "
- "will start without any input devices.\n");
+ xf86Msg(X_WARNING, "Hotplugging requested but the server was "
+ "compiled without a config backend. "
+ "No input devices were configured, the server "
+ "will start without any input devices.\n");
#endif
}
@@ -1355,12 +1402,12 @@ typedef enum {
} LayoutValues;
static OptionInfoRec LayoutOptions[] = {
- { LAYOUT_ISOLATEDEVICE, "IsolateDevice", OPTV_STRING,
- {0}, FALSE },
- { LAYOUT_SINGLECARD, "SingleCard", OPTV_BOOLEAN,
- {0}, FALSE },
- { -1, NULL, OPTV_NONE,
- {0}, FALSE },
+ {LAYOUT_ISOLATEDEVICE, "IsolateDevice", OPTV_STRING,
+ {0}, FALSE},
+ {LAYOUT_SINGLECARD, "SingleCard", OPTV_BOOLEAN,
+ {0}, FALSE},
+ {-1, NULL, OPTV_NONE,
+ {0}, FALSE},
};
static Bool
@@ -1375,42 +1422,41 @@ configInputDevices(XF86ConfLayoutPtr layout, serverLayoutPtr servlayoutp)
*/
irp = layout->lay_input_lst;
while (irp) {
- count++;
- irp = (XF86ConfInputrefPtr)irp->list.next;
+ count++;
+ irp = (XF86ConfInputrefPtr) irp->list.next;
}
DebugF("Found %d input devices in the layout section %s\n",
- count, layout->lay_identifier);
+ count, layout->lay_identifier);
indp = xnfcalloc((count + 1), sizeof(InputInfoPtr));
indp[count] = NULL;
irp = layout->lay_input_lst;
count = 0;
while (irp) {
- indp[count] = xf86AllocateInput();
- if (!configInput(indp[count], irp->iref_inputdev, X_CONFIG)) {
- do {
- free(indp[count]);
- } while(count--);
- free(indp);
- return FALSE;
- }
- indp[count]->options = xf86OptionListMerge(indp[count]->options,
- irp->iref_option_lst);
- count++;
- irp = (XF86ConfInputrefPtr)irp->list.next;
+ indp[count] = xf86AllocateInput();
+ if (!configInput(indp[count], irp->iref_inputdev, X_CONFIG)) {
+ do {
+ free(indp[count]);
+ } while (count--);
+ free(indp);
+ return FALSE;
+ }
+ indp[count]->options = xf86OptionListMerge(indp[count]->options,
+ irp->iref_option_lst);
+ count++;
+ irp = (XF86ConfInputrefPtr) irp->list.next;
}
servlayoutp->inputs = indp;
return TRUE;
}
-
/*
* figure out which layout is active, which screens are used in that layout,
* which drivers and monitors are used in these screens
*/
static Bool
configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
- char *default_layout)
+ char *default_layout)
{
XF86ConfAdjacencyPtr adjp;
XF86ConfInactivePtr idp;
@@ -1423,7 +1469,7 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
int i = 0, j;
if (!servlayoutp)
- return FALSE;
+ return FALSE;
/*
* which layout section is the active one?
@@ -1433,18 +1479,18 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
*/
from = X_DEFAULT;
if (xf86LayoutName != NULL)
- from = X_CMDLINE;
+ from = X_CMDLINE;
else if (default_layout) {
- xf86LayoutName = default_layout;
- from = X_CONFIG;
+ xf86LayoutName = default_layout;
+ from = X_CONFIG;
}
if (xf86LayoutName != NULL) {
- if ((l = xf86findLayout(xf86LayoutName, conf_layout)) == NULL) {
- xf86Msg(X_ERROR, "No ServerLayout section called \"%s\"\n",
- xf86LayoutName);
- return FALSE;
- }
- conf_layout = l;
+ if ((l = xf86findLayout(xf86LayoutName, conf_layout)) == NULL) {
+ xf86Msg(X_ERROR, "No ServerLayout section called \"%s\"\n",
+ xf86LayoutName);
+ return FALSE;
+ }
+ conf_layout = l;
}
xf86Msg(from, "ServerLayout \"%s\"\n", conf_layout->lay_identifier);
adjp = conf_layout->lay_adjacency_lst;
@@ -1457,12 +1503,12 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
*/
while (adjp) {
count++;
- adjp = (XF86ConfAdjacencyPtr)adjp->list.next;
+ adjp = (XF86ConfAdjacencyPtr) adjp->list.next;
}
DebugF("Found %d screens in the layout section %s",
count, conf_layout->lay_identifier);
- if (!count) /* alloc enough storage even if no screen is specified */
+ if (!count) /* alloc enough storage even if no screen is specified */
count = 1;
slp = xnfcalloc(1, (count + 1) * sizeof(screenLayoutRec));
@@ -1476,107 +1522,105 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
count = 0;
while (adjp) {
slp[count].screen = xnfcalloc(1, sizeof(confScreenRec));
- if (adjp->adj_scrnum < 0)
- scrnum = count;
- else
- scrnum = adjp->adj_scrnum;
- if (!configScreen(slp[count].screen, adjp->adj_screen, scrnum,
- X_CONFIG)) {
- do {
- free(slp[count].screen);
- } while(count--);
- free(slp);
- return FALSE;
- }
- slp[count].x = adjp->adj_x;
- slp[count].y = adjp->adj_y;
- slp[count].refname = adjp->adj_refscreen;
- switch (adjp->adj_where) {
- case CONF_ADJ_OBSOLETE:
- slp[count].where = PosObsolete;
- slp[count].topname = adjp->adj_top_str;
- slp[count].bottomname = adjp->adj_bottom_str;
- slp[count].leftname = adjp->adj_left_str;
- slp[count].rightname = adjp->adj_right_str;
- break;
- case CONF_ADJ_ABSOLUTE:
- slp[count].where = PosAbsolute;
- break;
- case CONF_ADJ_RIGHTOF:
- slp[count].where = PosRightOf;
- break;
- case CONF_ADJ_LEFTOF:
- slp[count].where = PosLeftOf;
- break;
- case CONF_ADJ_ABOVE:
- slp[count].where = PosAbove;
- break;
- case CONF_ADJ_BELOW:
- slp[count].where = PosBelow;
- break;
- case CONF_ADJ_RELATIVE:
- slp[count].where = PosRelative;
- break;
- }
+ if (adjp->adj_scrnum < 0)
+ scrnum = count;
+ else
+ scrnum = adjp->adj_scrnum;
+ if (!configScreen(slp[count].screen, adjp->adj_screen, scrnum,
+ X_CONFIG)) {
+ do {
+ free(slp[count].screen);
+ } while (count--);
+ free(slp);
+ return FALSE;
+ }
+ slp[count].x = adjp->adj_x;
+ slp[count].y = adjp->adj_y;
+ slp[count].refname = adjp->adj_refscreen;
+ switch (adjp->adj_where) {
+ case CONF_ADJ_OBSOLETE:
+ slp[count].where = PosObsolete;
+ slp[count].topname = adjp->adj_top_str;
+ slp[count].bottomname = adjp->adj_bottom_str;
+ slp[count].leftname = adjp->adj_left_str;
+ slp[count].rightname = adjp->adj_right_str;
+ break;
+ case CONF_ADJ_ABSOLUTE:
+ slp[count].where = PosAbsolute;
+ break;
+ case CONF_ADJ_RIGHTOF:
+ slp[count].where = PosRightOf;
+ break;
+ case CONF_ADJ_LEFTOF:
+ slp[count].where = PosLeftOf;
+ break;
+ case CONF_ADJ_ABOVE:
+ slp[count].where = PosAbove;
+ break;
+ case CONF_ADJ_BELOW:
+ slp[count].where = PosBelow;
+ break;
+ case CONF_ADJ_RELATIVE:
+ slp[count].where = PosRelative;
+ break;
+ }
count++;
- adjp = (XF86ConfAdjacencyPtr)adjp->list.next;
+ adjp = (XF86ConfAdjacencyPtr) adjp->list.next;
}
/* No screen was specified in the layout. take the first one from the
* config file, or - if it is NULL - configScreen autogenerates one for
* us */
- if (!count)
- {
+ if (!count) {
slp[0].screen = xnfcalloc(1, sizeof(confScreenRec));
- if (!configScreen(slp[0].screen, xf86configptr->conf_screen_lst,
+ if (!configScreen(slp[0].screen, xf86configptr->conf_screen_lst,
0, X_CONFIG)) {
- free(slp[0].screen);
- free(slp);
- return FALSE;
- }
+ free(slp[0].screen);
+ free(slp);
+ return FALSE;
+ }
}
/* XXX Need to tie down the upper left screen. */
/* Fill in the refscreen and top/bottom/left/right values */
for (i = 0; i < count; i++) {
- for (j = 0; j < count; j++) {
- if (slp[i].refname &&
- strcmp(slp[i].refname, slp[j].screen->id) == 0) {
- slp[i].refscreen = slp[j].screen;
- }
- if (slp[i].topname &&
- strcmp(slp[i].topname, slp[j].screen->id) == 0) {
- slp[i].top = slp[j].screen;
- }
- if (slp[i].bottomname &&
- strcmp(slp[i].bottomname, slp[j].screen->id) == 0) {
- slp[i].bottom = slp[j].screen;
- }
- if (slp[i].leftname &&
- strcmp(slp[i].leftname, slp[j].screen->id) == 0) {
- slp[i].left = slp[j].screen;
- }
- if (slp[i].rightname &&
- strcmp(slp[i].rightname, slp[j].screen->id) == 0) {
- slp[i].right = slp[j].screen;
- }
- }
- if (slp[i].where != PosObsolete
- && slp[i].where != PosAbsolute
- && !slp[i].refscreen) {
- xf86Msg(X_ERROR,"Screen %s doesn't exist: deleting placement\n",
- slp[i].refname);
- slp[i].where = PosAbsolute;
- slp[i].x = 0;
- slp[i].y = 0;
- }
+ for (j = 0; j < count; j++) {
+ if (slp[i].refname &&
+ strcmp(slp[i].refname, slp[j].screen->id) == 0) {
+ slp[i].refscreen = slp[j].screen;
+ }
+ if (slp[i].topname &&
+ strcmp(slp[i].topname, slp[j].screen->id) == 0) {
+ slp[i].top = slp[j].screen;
+ }
+ if (slp[i].bottomname &&
+ strcmp(slp[i].bottomname, slp[j].screen->id) == 0) {
+ slp[i].bottom = slp[j].screen;
+ }
+ if (slp[i].leftname &&
+ strcmp(slp[i].leftname, slp[j].screen->id) == 0) {
+ slp[i].left = slp[j].screen;
+ }
+ if (slp[i].rightname &&
+ strcmp(slp[i].rightname, slp[j].screen->id) == 0) {
+ slp[i].right = slp[j].screen;
+ }
+ }
+ if (slp[i].where != PosObsolete
+ && slp[i].where != PosAbsolute && !slp[i].refscreen) {
+ xf86Msg(X_ERROR, "Screen %s doesn't exist: deleting placement\n",
+ slp[i].refname);
+ slp[i].where = PosAbsolute;
+ slp[i].x = 0;
+ slp[i].y = 0;
+ }
}
if (!count)
- saved_count = 1;
+ saved_count = 1;
else
- saved_count = count;
+ saved_count = count;
/*
* Count the number of inactive devices.
*/
@@ -1584,7 +1628,7 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
idp = conf_layout->lay_inactive_lst;
while (idp) {
count++;
- idp = (XF86ConfInactivePtr)idp->list.next;
+ idp = (XF86ConfInactivePtr) idp->list.next;
}
DebugF("Found %d inactive devices in the layout section %s\n",
count, conf_layout->lay_identifier);
@@ -1593,14 +1637,14 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
idp = conf_layout->lay_inactive_lst;
count = 0;
while (idp) {
- if (!configDevice(&gdp[count], idp->inactive_device, FALSE))
- goto bail;
+ if (!configDevice(&gdp[count], idp->inactive_device, FALSE))
+ goto bail;
count++;
- idp = (XF86ConfInactivePtr)idp->list.next;
+ idp = (XF86ConfInactivePtr) idp->list.next;
}
if (!configInputDevices(conf_layout, servlayoutp))
- goto bail;
+ goto bail;
servlayoutp->id = conf_layout->lay_identifier;
servlayoutp->screens = slp;
@@ -1610,10 +1654,10 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
return TRUE;
-bail:
+ bail:
do {
- free(slp[saved_count].screen);
- } while(saved_count--);
+ free(slp[saved_count].screen);
+ } while (saved_count--);
free(slp);
free(gdp);
return FALSE;
@@ -1634,7 +1678,7 @@ configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen,
XF86ConfLayoutRec layout;
if (!servlayoutp)
- return FALSE;
+ return FALSE;
/*
* which screen section is the active one?
@@ -1645,13 +1689,13 @@ configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen,
from = X_CONFIG;
if (xf86ScreenName != NULL) {
- if ((s = xf86findScreen(xf86ScreenName, conf_screen)) == NULL) {
- xf86Msg(X_ERROR, "No Screen section called \"%s\"\n",
- xf86ScreenName);
- return FALSE;
- }
- conf_screen = s;
- from = X_CMDLINE;
+ if ((s = xf86findScreen(xf86ScreenName, conf_screen)) == NULL) {
+ xf86Msg(X_ERROR, "No Screen section called \"%s\"\n",
+ xf86ScreenName);
+ return FALSE;
+ }
+ conf_screen = s;
+ from = X_CMDLINE;
}
/* We have exactly one screen */
@@ -1660,8 +1704,8 @@ configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen,
slp[0].screen = xnfcalloc(1, sizeof(confScreenRec));
slp[1].screen = NULL;
if (!configScreen(slp[0].screen, conf_screen, 0, from)) {
- free(slp);
- return FALSE;
+ free(slp);
+ return FALSE;
}
servlayoutp->id = "(implicit)";
servlayoutp->screens = slp;
@@ -1671,14 +1715,15 @@ configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen,
memset(&layout, 0, sizeof(layout));
layout.lay_identifier = servlayoutp->id;
if (xf86layoutAddInputDevices(xf86configptr, &layout) > 0) {
- if (!configInputDevices(&layout, servlayoutp))
- return FALSE;
- from = X_DEFAULT;
- } else {
- /* Set up an empty input device list, then look for some core devices. */
- indp = xnfalloc(sizeof(InputInfoPtr));
- *indp = NULL;
- servlayoutp->inputs = indp;
+ if (!configInputDevices(&layout, servlayoutp))
+ return FALSE;
+ from = X_DEFAULT;
+ }
+ else {
+ /* Set up an empty input device list, then look for some core devices. */
+ indp = xnfalloc(sizeof(InputInfoPtr));
+ *indp = NULL;
+ servlayoutp->inputs = indp;
}
return TRUE;
@@ -1691,31 +1736,31 @@ configXvAdaptor(confXvAdaptorPtr adaptor, XF86ConfVideoAdaptorPtr conf_adaptor)
XF86ConfVideoPortPtr conf_port;
xf86Msg(X_CONFIG, "| |-->VideoAdaptor \"%s\"\n",
- conf_adaptor->va_identifier);
+ conf_adaptor->va_identifier);
adaptor->identifier = conf_adaptor->va_identifier;
adaptor->options = conf_adaptor->va_option_lst;
if (conf_adaptor->va_busid || conf_adaptor->va_driver) {
- xf86Msg(X_CONFIG, "| | Unsupported device type, skipping entry\n");
- return FALSE;
+ xf86Msg(X_CONFIG, "| | Unsupported device type, skipping entry\n");
+ return FALSE;
}
/*
* figure out how many videoport subsections there are and fill them in
*/
conf_port = conf_adaptor->va_port_lst;
- while(conf_port) {
+ while (conf_port) {
count++;
- conf_port = (XF86ConfVideoPortPtr)conf_port->list.next;
+ conf_port = (XF86ConfVideoPortPtr) conf_port->list.next;
}
adaptor->ports = xnfalloc((count) * sizeof(confXvPortRec));
adaptor->numports = count;
count = 0;
conf_port = conf_adaptor->va_port_lst;
- while(conf_port) {
- adaptor->ports[count].identifier = conf_port->vp_identifier;
- adaptor->ports[count].options = conf_port->vp_option_lst;
+ while (conf_port) {
+ adaptor->ports[count].identifier = conf_port->vp_identifier;
+ adaptor->ports[count].options = conf_port->vp_option_lst;
count++;
- conf_port = (XF86ConfVideoPortPtr)conf_port->list.next;
+ conf_port = (XF86ConfVideoPortPtr) conf_port->list.next;
}
return TRUE;
@@ -1723,7 +1768,7 @@ configXvAdaptor(confXvAdaptorPtr adaptor, XF86ConfVideoAdaptorPtr conf_adaptor)
static Bool
configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
- MessageType from)
+ MessageType from)
{
int count = 0;
XF86ConfDisplayPtr dispptr;
@@ -1739,96 +1784,98 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
}
xf86Msg(from, "|-->Screen \"%s\" (%d)\n", conf_screen->scrn_identifier,
- scrnum);
+ scrnum);
/*
* now we fill in the elements of the screen
*/
- screenp->id = conf_screen->scrn_identifier;
- screenp->screennum = scrnum;
+ screenp->id = conf_screen->scrn_identifier;
+ screenp->screennum = scrnum;
screenp->defaultdepth = conf_screen->scrn_defaultdepth;
screenp->defaultbpp = conf_screen->scrn_defaultbpp;
screenp->defaultfbbpp = conf_screen->scrn_defaultfbbpp;
- screenp->monitor = xnfcalloc(1, sizeof(MonRec));
+ screenp->monitor = xnfcalloc(1, sizeof(MonRec));
/* If no monitor is specified, create a default one. */
if (!conf_screen->scrn_monitor) {
- XF86ConfMonitorRec defMon;
+ XF86ConfMonitorRec defMon;
- memset(&defMon, 0, sizeof(defMon));
- defMon.mon_identifier = "<default monitor>";
- if (!configMonitor(screenp->monitor, &defMon))
- return FALSE;
- defaultMonitor = TRUE;
- } else {
- if (!configMonitor(screenp->monitor,conf_screen->scrn_monitor))
- return FALSE;
+ memset(&defMon, 0, sizeof(defMon));
+ defMon.mon_identifier = "<default monitor>";
+ if (!configMonitor(screenp->monitor, &defMon))
+ return FALSE;
+ defaultMonitor = TRUE;
+ }
+ else {
+ if (!configMonitor(screenp->monitor, conf_screen->scrn_monitor))
+ return FALSE;
}
/* Configure the device. If there isn't one configured, attach to the
* first inactive one that we can configure. If there's none that work,
* set it to NULL so that the section can be autoconfigured later */
- screenp->device = xnfcalloc(1, sizeof(GDevRec));
+ screenp->device = xnfcalloc(1, sizeof(GDevRec));
if ((!conf_screen->scrn_device) && (xf86configptr->conf_device_lst)) {
conf_screen->scrn_device = xf86configptr->conf_device_lst;
- xf86Msg(X_DEFAULT, "No device specified for screen \"%s\".\n"
- "\tUsing the first device section listed.\n", screenp->id);
+ xf86Msg(X_DEFAULT, "No device specified for screen \"%s\".\n"
+ "\tUsing the first device section listed.\n", screenp->id);
}
- if (configDevice(screenp->device,conf_screen->scrn_device, TRUE)) {
+ if (configDevice(screenp->device, conf_screen->scrn_device, TRUE)) {
screenp->device->myScreenSection = screenp;
- } else {
+ }
+ else {
screenp->device = NULL;
}
screenp->options = conf_screen->scrn_option_lst;
-
+
/*
* figure out how many display subsections there are and fill them in
*/
dispptr = conf_screen->scrn_display_lst;
- while(dispptr) {
+ while (dispptr) {
count++;
- dispptr = (XF86ConfDisplayPtr)dispptr->list.next;
+ dispptr = (XF86ConfDisplayPtr) dispptr->list.next;
}
- screenp->displays = xnfalloc((count) * sizeof(DispRec));
+ screenp->displays = xnfalloc((count) * sizeof(DispRec));
screenp->numdisplays = count;
-
+
/* Fill in the default Virtual size, if any */
if (conf_screen->scrn_virtualX && conf_screen->scrn_virtualY) {
- for (count = 0, dispptr = conf_screen->scrn_display_lst;
- dispptr;
- dispptr = (XF86ConfDisplayPtr)dispptr->list.next, count++) {
- screenp->displays[count].virtualX = conf_screen->scrn_virtualX;
- screenp->displays[count].virtualY = conf_screen->scrn_virtualY;
- }
+ for (count = 0, dispptr = conf_screen->scrn_display_lst;
+ dispptr;
+ dispptr = (XF86ConfDisplayPtr) dispptr->list.next, count++) {
+ screenp->displays[count].virtualX = conf_screen->scrn_virtualX;
+ screenp->displays[count].virtualY = conf_screen->scrn_virtualY;
+ }
}
/* Now do the per-Display Virtual sizes */
count = 0;
dispptr = conf_screen->scrn_display_lst;
- while(dispptr) {
- configDisplay(&(screenp->displays[count]),dispptr);
+ while (dispptr) {
+ configDisplay(&(screenp->displays[count]), dispptr);
count++;
- dispptr = (XF86ConfDisplayPtr)dispptr->list.next;
+ dispptr = (XF86ConfDisplayPtr) dispptr->list.next;
}
/*
* figure out how many videoadaptor references there are and fill them in
*/
conf_adaptor = conf_screen->scrn_adaptor_lst;
- while(conf_adaptor) {
+ while (conf_adaptor) {
count++;
- conf_adaptor = (XF86ConfAdaptorLinkPtr)conf_adaptor->list.next;
+ conf_adaptor = (XF86ConfAdaptorLinkPtr) conf_adaptor->list.next;
}
screenp->xvadaptors = xnfalloc((count) * sizeof(confXvAdaptorRec));
screenp->numxvadaptors = 0;
conf_adaptor = conf_screen->scrn_adaptor_lst;
- while(conf_adaptor) {
+ while (conf_adaptor) {
if (configXvAdaptor(&(screenp->xvadaptors[screenp->numxvadaptors]),
- conf_adaptor->al_adaptor))
- screenp->numxvadaptors++;
- conf_adaptor = (XF86ConfAdaptorLinkPtr)conf_adaptor->list.next;
+ conf_adaptor->al_adaptor))
+ screenp->numxvadaptors++;
+ conf_adaptor = (XF86ConfAdaptorLinkPtr) conf_adaptor->list.next;
}
if (defaultMonitor) {
- xf86Msg(X_DEFAULT, "No monitor specified for screen \"%s\".\n"
- "\tUsing a default monitor configuration.\n", screenp->id);
+ xf86Msg(X_DEFAULT, "No monitor specified for screen \"%s\".\n"
+ "\tUsing a default monitor configuration.\n", screenp->id);
}
return TRUE;
}
@@ -1839,28 +1886,27 @@ typedef enum {
} MonitorValues;
static OptionInfoRec MonitorOptions[] = {
- { MON_REDUCEDBLANKING, "ReducedBlanking", OPTV_BOOLEAN,
- {0}, FALSE },
- { MON_MAX_PIX_CLOCK, "MaxPixClock", OPTV_FREQ,
- {0}, FALSE },
- { -1, NULL, OPTV_NONE,
- {0}, FALSE },
+ {MON_REDUCEDBLANKING, "ReducedBlanking", OPTV_BOOLEAN,
+ {0}, FALSE},
+ {MON_MAX_PIX_CLOCK, "MaxPixClock", OPTV_FREQ,
+ {0}, FALSE},
+ {-1, NULL, OPTV_NONE,
+ {0}, FALSE},
};
static Bool
configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor)
{
int count;
- DisplayModePtr mode,last = NULL;
+ DisplayModePtr mode, last = NULL;
XF86ConfModeLinePtr cmodep;
XF86ConfModesPtr modes;
XF86ConfModesLinkPtr modeslnk = conf_monitor->mon_modes_sect_lst;
- Gamma zeros = {0.0, 0.0, 0.0};
+ Gamma zeros = { 0.0, 0.0, 0.0 };
float badgamma = 0.0;
double maxPixClock;
-
- xf86Msg(X_CONFIG, "| |-->Monitor \"%s\"\n",
- conf_monitor->mon_identifier);
+
+ xf86Msg(X_CONFIG, "| |-->Monitor \"%s\"\n", conf_monitor->mon_identifier);
monitorp->id = conf_monitor->mon_identifier;
monitorp->vendor = conf_monitor->mon_vendor;
monitorp->model = conf_monitor->mon_modelname;
@@ -1875,17 +1921,16 @@ configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor)
/*
* fill in the monitor structure
- */
- for( count = 0 ;
- count < conf_monitor->mon_n_hsync && count < MAX_HSYNC;
- count++) {
+ */
+ for (count = 0;
+ count < conf_monitor->mon_n_hsync && count < MAX_HSYNC; count++) {
monitorp->hsync[count].hi = conf_monitor->mon_hsync[count].hi;
monitorp->hsync[count].lo = conf_monitor->mon_hsync[count].lo;
}
monitorp->nHsync = count;
- for( count = 0 ;
- count < conf_monitor->mon_n_vrefresh && count < MAX_VREFRESH;
- count++) {
+ for (count = 0;
+ count < conf_monitor->mon_n_vrefresh && count < MAX_VREFRESH;
+ count++) {
monitorp->vrefresh[count].hi = conf_monitor->mon_vrefresh[count].hi;
monitorp->vrefresh[count].lo = conf_monitor->mon_vrefresh[count].lo;
}
@@ -1894,27 +1939,23 @@ configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor)
/*
* first we collect the mode lines from the UseModes directive
*/
- while(modeslnk)
- {
- modes = xf86findModes (modeslnk->ml_modes_str,
- xf86configptr->conf_modes_lst);
- modeslnk->ml_modes = modes;
-
-
- /* now add the modes found in the modes
- section to the list of modes for this
- monitor unless it has been added before
- because we are reusing the same section
- for another screen */
- if (xf86itemNotSublist(
- (GenericListPtr)conf_monitor->mon_modeline_lst,
- (GenericListPtr)modes->mon_modeline_lst)) {
- conf_monitor->mon_modeline_lst = (XF86ConfModeLinePtr)
- xf86addListItem(
- (GenericListPtr)conf_monitor->mon_modeline_lst,
- (GenericListPtr)modes->mon_modeline_lst);
- }
- modeslnk = modeslnk->list.next;
+ while (modeslnk) {
+ modes = xf86findModes(modeslnk->ml_modes_str,
+ xf86configptr->conf_modes_lst);
+ modeslnk->ml_modes = modes;
+
+ /* now add the modes found in the modes
+ section to the list of modes for this
+ monitor unless it has been added before
+ because we are reusing the same section
+ for another screen */
+ if (xf86itemNotSublist((GenericListPtr) conf_monitor->mon_modeline_lst,
+ (GenericListPtr) modes->mon_modeline_lst)) {
+ conf_monitor->mon_modeline_lst = (XF86ConfModeLinePtr)
+ xf86addListItem((GenericListPtr) conf_monitor->mon_modeline_lst,
+ (GenericListPtr) modes->mon_modeline_lst);
+ }
+ modeslnk = modeslnk->list.next;
}
/*
@@ -1923,23 +1964,23 @@ configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor)
* is double linked
*/
cmodep = conf_monitor->mon_modeline_lst;
- while( cmodep ) {
+ while (cmodep) {
mode = xnfcalloc(1, sizeof(DisplayModeRec));
- mode->type = 0;
- mode->Clock = cmodep->ml_clock;
- mode->HDisplay = cmodep->ml_hdisplay;
+ mode->type = 0;
+ mode->Clock = cmodep->ml_clock;
+ mode->HDisplay = cmodep->ml_hdisplay;
mode->HSyncStart = cmodep->ml_hsyncstart;
- mode->HSyncEnd = cmodep->ml_hsyncend;
- mode->HTotal = cmodep->ml_htotal;
- mode->VDisplay = cmodep->ml_vdisplay;
+ mode->HSyncEnd = cmodep->ml_hsyncend;
+ mode->HTotal = cmodep->ml_htotal;
+ mode->VDisplay = cmodep->ml_vdisplay;
mode->VSyncStart = cmodep->ml_vsyncstart;
- mode->VSyncEnd = cmodep->ml_vsyncend;
- mode->VTotal = cmodep->ml_vtotal;
- mode->Flags = cmodep->ml_flags;
- mode->HSkew = cmodep->ml_hskew;
- mode->VScan = cmodep->ml_vscan;
- mode->name = xnfstrdup(cmodep->ml_identifier);
- if( last ) {
+ mode->VSyncEnd = cmodep->ml_vsyncend;
+ mode->VTotal = cmodep->ml_vtotal;
+ mode->Flags = cmodep->ml_flags;
+ mode->HSkew = cmodep->ml_hskew;
+ mode->VScan = cmodep->ml_vscan;
+ mode->name = xnfstrdup(cmodep->ml_identifier);
+ if (last) {
mode->prev = last;
last->next = mode;
}
@@ -1951,52 +1992,53 @@ configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor)
mode->prev = NULL;
}
last = mode;
- cmodep = (XF86ConfModeLinePtr)cmodep->list.next;
+ cmodep = (XF86ConfModeLinePtr) cmodep->list.next;
}
- if(last){
- last->next = NULL;
+ if (last) {
+ last->next = NULL;
}
monitorp->Last = last;
/* add the (VESA) default modes */
- if (! addDefaultModes(monitorp) )
- return FALSE;
+ if (!addDefaultModes(monitorp))
+ return FALSE;
if (conf_monitor->mon_gamma_red > GAMMA_ZERO)
- monitorp->gamma.red = conf_monitor->mon_gamma_red;
+ monitorp->gamma.red = conf_monitor->mon_gamma_red;
if (conf_monitor->mon_gamma_green > GAMMA_ZERO)
- monitorp->gamma.green = conf_monitor->mon_gamma_green;
+ monitorp->gamma.green = conf_monitor->mon_gamma_green;
if (conf_monitor->mon_gamma_blue > GAMMA_ZERO)
- monitorp->gamma.blue = conf_monitor->mon_gamma_blue;
-
+ monitorp->gamma.blue = conf_monitor->mon_gamma_blue;
+
/* Check that the gamma values are within range */
if (monitorp->gamma.red > GAMMA_ZERO &&
- (monitorp->gamma.red < GAMMA_MIN ||
- monitorp->gamma.red > GAMMA_MAX)) {
- badgamma = monitorp->gamma.red;
- } else if (monitorp->gamma.green > GAMMA_ZERO &&
- (monitorp->gamma.green < GAMMA_MIN ||
- monitorp->gamma.green > GAMMA_MAX)) {
- badgamma = monitorp->gamma.green;
- } else if (monitorp->gamma.blue > GAMMA_ZERO &&
- (monitorp->gamma.blue < GAMMA_MIN ||
- monitorp->gamma.blue > GAMMA_MAX)) {
- badgamma = monitorp->gamma.blue;
+ (monitorp->gamma.red < GAMMA_MIN || monitorp->gamma.red > GAMMA_MAX)) {
+ badgamma = monitorp->gamma.red;
+ }
+ else if (monitorp->gamma.green > GAMMA_ZERO &&
+ (monitorp->gamma.green < GAMMA_MIN ||
+ monitorp->gamma.green > GAMMA_MAX)) {
+ badgamma = monitorp->gamma.green;
+ }
+ else if (monitorp->gamma.blue > GAMMA_ZERO &&
+ (monitorp->gamma.blue < GAMMA_MIN ||
+ monitorp->gamma.blue > GAMMA_MAX)) {
+ badgamma = monitorp->gamma.blue;
}
if (badgamma > GAMMA_ZERO) {
- xf86ConfigError("Gamma value %.f is out of range (%.2f - %.1f)\n",
- badgamma, GAMMA_MIN, GAMMA_MAX);
- return FALSE;
+ xf86ConfigError("Gamma value %.f is out of range (%.2f - %.1f)\n",
+ badgamma, GAMMA_MIN, GAMMA_MAX);
+ return FALSE;
}
xf86ProcessOptions(-1, monitorp->options, MonitorOptions);
xf86GetOptValBool(MonitorOptions, MON_REDUCEDBLANKING,
&monitorp->reducedblanking);
if (xf86GetOptValFreq(MonitorOptions, MON_MAX_PIX_CLOCK, OPTUNITS_KHZ,
- &maxPixClock) == TRUE) {
- monitorp->maxPixClock = (int) maxPixClock;
+ &maxPixClock) == TRUE) {
+ monitorp->maxPixClock = (int) maxPixClock;
}
-
+
return TRUE;
}
@@ -2006,71 +2048,71 @@ lookupVisual(const char *visname)
int i;
if (!visname || !*visname)
- return -1;
+ return -1;
for (i = 0; i <= DirectColor; i++) {
- if (!xf86nameCompare(visname, xf86VisualNames[i]))
- break;
+ if (!xf86nameCompare(visname, xf86VisualNames[i]))
+ break;
}
if (i <= DirectColor)
- return i;
+ return i;
return -1;
}
-
static Bool
configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display)
{
int count = 0;
XF86ModePtr modep;
-
- displayp->frameX0 = conf_display->disp_frameX0;
- displayp->frameY0 = conf_display->disp_frameY0;
- displayp->virtualX = conf_display->disp_virtualX;
- displayp->virtualY = conf_display->disp_virtualY;
- displayp->depth = conf_display->disp_depth;
- displayp->fbbpp = conf_display->disp_bpp;
- displayp->weight.red = conf_display->disp_weight.red;
- displayp->weight.green = conf_display->disp_weight.green;
- displayp->weight.blue = conf_display->disp_weight.blue;
- displayp->blackColour.red = conf_display->disp_black.red;
+
+ displayp->frameX0 = conf_display->disp_frameX0;
+ displayp->frameY0 = conf_display->disp_frameY0;
+ displayp->virtualX = conf_display->disp_virtualX;
+ displayp->virtualY = conf_display->disp_virtualY;
+ displayp->depth = conf_display->disp_depth;
+ displayp->fbbpp = conf_display->disp_bpp;
+ displayp->weight.red = conf_display->disp_weight.red;
+ displayp->weight.green = conf_display->disp_weight.green;
+ displayp->weight.blue = conf_display->disp_weight.blue;
+ displayp->blackColour.red = conf_display->disp_black.red;
displayp->blackColour.green = conf_display->disp_black.green;
- displayp->blackColour.blue = conf_display->disp_black.blue;
- displayp->whiteColour.red = conf_display->disp_white.red;
+ displayp->blackColour.blue = conf_display->disp_black.blue;
+ displayp->whiteColour.red = conf_display->disp_white.red;
displayp->whiteColour.green = conf_display->disp_white.green;
- displayp->whiteColour.blue = conf_display->disp_white.blue;
- displayp->options = conf_display->disp_option_lst;
+ displayp->whiteColour.blue = conf_display->disp_white.blue;
+ displayp->options = conf_display->disp_option_lst;
if (conf_display->disp_visual) {
- displayp->defaultVisual = lookupVisual(conf_display->disp_visual);
- if (displayp->defaultVisual == -1) {
- xf86ConfigError("Invalid visual name: \"%s\"",
- conf_display->disp_visual);
- return FALSE;
- }
- } else {
- displayp->defaultVisual = -1;
- }
-
+ displayp->defaultVisual = lookupVisual(conf_display->disp_visual);
+ if (displayp->defaultVisual == -1) {
+ xf86ConfigError("Invalid visual name: \"%s\"",
+ conf_display->disp_visual);
+ return FALSE;
+ }
+ }
+ else {
+ displayp->defaultVisual = -1;
+ }
+
/*
* now hook in the modes
*/
modep = conf_display->disp_mode_lst;
- while(modep) {
+ while (modep) {
count++;
- modep = (XF86ModePtr)modep->list.next;
+ modep = (XF86ModePtr) modep->list.next;
}
- displayp->modes = xnfalloc((count+1) * sizeof(char*));
+ displayp->modes = xnfalloc((count + 1) * sizeof(char *));
modep = conf_display->disp_mode_lst;
count = 0;
- while(modep) {
+ while (modep) {
displayp->modes[count] = modep->mode_name;
count++;
- modep = (XF86ModePtr)modep->list.next;
+ modep = (XF86ModePtr) modep->list.next;
}
displayp->modes[count] = NULL;
-
+
return TRUE;
}
@@ -2084,11 +2126,11 @@ configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active)
}
if (active)
- xf86Msg(X_CONFIG, "| |-->Device \"%s\"\n",
- conf_device->dev_identifier);
+ xf86Msg(X_CONFIG, "| |-->Device \"%s\"\n",
+ conf_device->dev_identifier);
else
- xf86Msg(X_CONFIG, "|-->Inactive Device \"%s\"\n",
- conf_device->dev_identifier);
+ xf86Msg(X_CONFIG, "|-->Inactive Device \"%s\"\n",
+ conf_device->dev_identifier);
devicep->identifier = conf_device->dev_identifier;
devicep->vendor = conf_device->dev_vendor;
@@ -2111,16 +2153,16 @@ configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active)
devicep->screen = conf_device->dev_screen;
for (i = 0; i < MAXDACSPEEDS; i++) {
- if (i < CONF_MAXDACSPEEDS)
+ if (i < CONF_MAXDACSPEEDS)
devicep->dacSpeeds[i] = conf_device->dev_dacSpeeds[i];
- else
- devicep->dacSpeeds[i] = 0;
+ else
+ devicep->dacSpeeds[i] = 0;
}
devicep->numclocks = conf_device->dev_clocks;
if (devicep->numclocks > MAXCLOCKS)
- devicep->numclocks = MAXCLOCKS;
+ devicep->numclocks = MAXCLOCKS;
for (i = 0; i < devicep->numclocks; i++) {
- devicep->clock[i] = conf_device->dev_clock[i];
+ devicep->clock[i] = conf_device->dev_clock[i];
}
devicep->claimed = FALSE;
@@ -2131,20 +2173,21 @@ configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active)
static void
configDRI(XF86ConfDRIPtr drip)
{
- struct group *grp;
+ struct group *grp;
- xf86ConfigDRI.group = -1;
- xf86ConfigDRI.mode = 0;
+ xf86ConfigDRI.group = -1;
+ xf86ConfigDRI.mode = 0;
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;
+ 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;
}
}
#endif
@@ -2155,49 +2198,51 @@ configExtensions(XF86ConfExtensionsPtr conf_ext)
XF86OptionPtr o;
if (conf_ext && conf_ext->ext_option_lst) {
- for (o = conf_ext->ext_option_lst; o; o = xf86NextOption(o)) {
- char *name = xf86OptionName(o);
- char *val = xf86OptionValue(o);
- char *n;
- Bool enable = TRUE;
-
- /* Handle "No<ExtensionName>" */
- n = xf86NormalizeName(name);
- if (strncmp(n, "no", 2) == 0) {
- name += 2;
- enable = FALSE;
- }
-
- if (!val ||
- xf86NameCmp(val, "enable") == 0 ||
- xf86NameCmp(val, "enabled") == 0 ||
- xf86NameCmp(val, "on") == 0 ||
- xf86NameCmp(val, "1") == 0 ||
- xf86NameCmp(val, "yes") == 0 ||
- xf86NameCmp(val, "true") == 0) {
- /* NOTHING NEEDED -- enabling is handled below */
- } else if (xf86NameCmp(val, "disable") == 0 ||
- xf86NameCmp(val, "disabled") == 0 ||
- xf86NameCmp(val, "off") == 0 ||
- xf86NameCmp(val, "0") == 0 ||
- xf86NameCmp(val, "no") == 0 ||
- xf86NameCmp(val, "false") == 0) {
- enable = !enable;
- } else {
- xf86Msg(X_WARNING, "Ignoring unrecognized value \"%s\"\n", val);
- free(n);
- continue;
- }
-
- if (EnableDisableExtension(name, enable)) {
- xf86Msg(X_CONFIG, "Extension \"%s\" is %s\n",
- name, enable ? "enabled" : "disabled");
- } else {
- xf86Msg(X_WARNING, "Ignoring unrecognized extension \"%s\"\n",
+ for (o = conf_ext->ext_option_lst; o; o = xf86NextOption(o)) {
+ char *name = xf86OptionName(o);
+ char *val = xf86OptionValue(o);
+ char *n;
+ Bool enable = TRUE;
+
+ /* Handle "No<ExtensionName>" */
+ n = xf86NormalizeName(name);
+ if (strncmp(n, "no", 2) == 0) {
+ name += 2;
+ enable = FALSE;
+ }
+
+ if (!val ||
+ xf86NameCmp(val, "enable") == 0 ||
+ xf86NameCmp(val, "enabled") == 0 ||
+ xf86NameCmp(val, "on") == 0 ||
+ xf86NameCmp(val, "1") == 0 ||
+ xf86NameCmp(val, "yes") == 0 || xf86NameCmp(val, "true") == 0) {
+ /* NOTHING NEEDED -- enabling is handled below */
+ }
+ else if (xf86NameCmp(val, "disable") == 0 ||
+ xf86NameCmp(val, "disabled") == 0 ||
+ xf86NameCmp(val, "off") == 0 ||
+ xf86NameCmp(val, "0") == 0 ||
+ xf86NameCmp(val, "no") == 0 ||
+ xf86NameCmp(val, "false") == 0) {
+ enable = !enable;
+ }
+ else {
+ xf86Msg(X_WARNING, "Ignoring unrecognized value \"%s\"\n", val);
+ free(n);
+ continue;
+ }
+
+ if (EnableDisableExtension(name, enable)) {
+ xf86Msg(X_CONFIG, "Extension \"%s\" is %s\n",
+ name, enable ? "enabled" : "disabled");
+ }
+ else {
+ xf86Msg(X_WARNING, "Ignoring unrecognized extension \"%s\"\n",
name);
- }
- free(n);
- }
+ }
+ free(n);
+ }
}
}
@@ -2219,12 +2264,11 @@ modeIsPresent(DisplayModePtr mode, MonPtr monitorp)
DisplayModePtr knownmodes = monitorp->Modes;
/* all I can think of is a linear search... */
- while(knownmodes != NULL)
- {
- if(!strcmp(mode->name, knownmodes->name) &&
- !(knownmodes->type & M_T_DEFAULT))
- return TRUE;
- knownmodes = knownmodes->next;
+ while (knownmodes != NULL) {
+ if (!strcmp(mode->name, knownmodes->name) &&
+ !(knownmodes->type & M_T_DEFAULT))
+ return TRUE;
+ knownmodes = knownmodes->next;
}
return FALSE;
}
@@ -2236,16 +2280,15 @@ addDefaultModes(MonPtr monitorp)
DisplayModePtr last = monitorp->Last;
int i = 0;
- for (i = 0; i < xf86NumDefaultModes; i++)
- {
- mode = xf86DuplicateMode(&xf86DefaultModes[i]);
- if (!modeIsPresent(mode, monitorp))
- {
- monitorp->Modes = xf86ModesAdd(monitorp->Modes, mode);
- last = mode;
- } else {
- free(mode);
- }
+ for (i = 0; i < xf86NumDefaultModes; i++) {
+ mode = xf86DuplicateMode(&xf86DefaultModes[i]);
+ if (!modeIsPresent(mode, monitorp)) {
+ monitorp->Modes = xf86ModesAdd(monitorp->Modes, mode);
+ last = mode;
+ }
+ else {
+ free(mode);
+ }
}
monitorp->Last = last;
@@ -2253,27 +2296,25 @@ addDefaultModes(MonPtr monitorp)
}
static void
-checkInput(serverLayoutPtr layout, Bool implicit_layout) {
+checkInput(serverLayoutPtr layout, Bool implicit_layout)
+{
checkCoreInputDevices(layout, implicit_layout);
/* Unless we're forcing input devices, disable mouse/kbd devices in the
* config. Otherwise the same physical device is added multiple times,
* leading to duplicate events.
*/
- if (!xf86Info.forceInputDevices && layout->inputs)
- {
+ if (!xf86Info.forceInputDevices && layout->inputs) {
InputInfoPtr *dev = layout->inputs;
BOOL warned = FALSE;
- while(*dev)
- {
+ while (*dev) {
if (strcmp((*dev)->driver, "kbd") == 0 ||
strcmp((*dev)->driver, "mouse") == 0 ||
- strcmp((*dev)->driver, "vmmouse") == 0)
- {
+ strcmp((*dev)->driver, "vmmouse") == 0) {
InputInfoPtr *current;
- if (!warned)
- {
+
+ if (!warned) {
xf86Msg(X_WARNING, "Hotplugging is on, devices using "
"drivers 'kbd', 'mouse' or 'vmmouse' will be disabled.\n");
warned = TRUE;
@@ -2287,8 +2328,9 @@ checkInput(serverLayoutPtr layout, Bool implicit_layout) {
do {
*current = *(current + 1);
current++;
- } while(*current);
- } else
+ } while (*current);
+ }
+ else
dev++;
}
}
@@ -2305,63 +2347,66 @@ xf86HandleConfigFile(Bool autoconfig)
Bool implicit_layout = FALSE;
if (!autoconfig) {
- char *filename, *dirname, *sysdirname;
- const char *filesearch, *dirsearch;
- MessageType filefrom = X_DEFAULT;
- MessageType dirfrom = X_DEFAULT;
-
- if (!xf86PrivsElevated()) {
- filesearch = ALL_CONFIGPATH;
- dirsearch = ALL_CONFIGDIRPATH;
- } else {
- filesearch = RESTRICTED_CONFIGPATH;
- dirsearch = RESTRICTED_CONFIGDIRPATH;
- }
-
- if (xf86ConfigFile)
- filefrom = X_CMDLINE;
- if (xf86ConfigDir)
- dirfrom = X_CMDLINE;
-
- xf86initConfigFiles();
- sysdirname = xf86openConfigDirFiles(SYS_CONFIGDIRPATH, NULL,
- PROJECTROOT);
- dirname = xf86openConfigDirFiles(dirsearch, xf86ConfigDir, PROJECTROOT);
- filename = xf86openConfigFile(filesearch, xf86ConfigFile, PROJECTROOT);
- if (filename) {
- xf86MsgVerb(filefrom, 0, "Using config file: \"%s\"\n", filename);
- xf86ConfigFile = xnfstrdup(filename);
- } else {
- if (xf86ConfigFile)
- xf86Msg(X_ERROR, "Unable to locate/open config file: \"%s\"\n",
- xf86ConfigFile);
- }
- if (dirname) {
- xf86MsgVerb(dirfrom, 0, "Using config directory: \"%s\"\n",
- dirname);
- xf86ConfigDir = xnfstrdup(dirname);
- } else {
- if (xf86ConfigDir)
- xf86Msg(X_ERROR,
- "Unable to locate/open config directory: \"%s\"\n",
- xf86ConfigDir);
- }
- if (sysdirname)
- xf86MsgVerb(X_DEFAULT, 0, "Using system config directory \"%s\"\n",
- sysdirname);
- if (!filename && !dirname && !sysdirname)
- return CONFIG_NOFILE;
-
- free(filename);
- free(dirname);
- free(sysdirname);
- }
-
- if ((xf86configptr = xf86readConfigFile ()) == NULL) {
- xf86Msg(X_ERROR, "Problem parsing the config file\n");
- return CONFIG_PARSE_ERROR;
- }
- xf86closeConfigFile ();
+ char *filename, *dirname, *sysdirname;
+ const char *filesearch, *dirsearch;
+ MessageType filefrom = X_DEFAULT;
+ MessageType dirfrom = X_DEFAULT;
+
+ if (!xf86PrivsElevated()) {
+ filesearch = ALL_CONFIGPATH;
+ dirsearch = ALL_CONFIGDIRPATH;
+ }
+ else {
+ filesearch = RESTRICTED_CONFIGPATH;
+ dirsearch = RESTRICTED_CONFIGDIRPATH;
+ }
+
+ if (xf86ConfigFile)
+ filefrom = X_CMDLINE;
+ if (xf86ConfigDir)
+ dirfrom = X_CMDLINE;
+
+ xf86initConfigFiles();
+ sysdirname = xf86openConfigDirFiles(SYS_CONFIGDIRPATH, NULL,
+ PROJECTROOT);
+ dirname = xf86openConfigDirFiles(dirsearch, xf86ConfigDir, PROJECTROOT);
+ filename = xf86openConfigFile(filesearch, xf86ConfigFile, PROJECTROOT);
+ if (filename) {
+ xf86MsgVerb(filefrom, 0, "Using config file: \"%s\"\n", filename);
+ xf86ConfigFile = xnfstrdup(filename);
+ }
+ else {
+ if (xf86ConfigFile)
+ xf86Msg(X_ERROR, "Unable to locate/open config file: \"%s\"\n",
+ xf86ConfigFile);
+ }
+ if (dirname) {
+ xf86MsgVerb(dirfrom, 0, "Using config directory: \"%s\"\n",
+ dirname);
+ xf86ConfigDir = xnfstrdup(dirname);
+ }
+ else {
+ if (xf86ConfigDir)
+ xf86Msg(X_ERROR,
+ "Unable to locate/open config directory: \"%s\"\n",
+ xf86ConfigDir);
+ }
+ if (sysdirname)
+ xf86MsgVerb(X_DEFAULT, 0, "Using system config directory \"%s\"\n",
+ sysdirname);
+ if (!filename && !dirname && !sysdirname)
+ return CONFIG_NOFILE;
+
+ free(filename);
+ free(dirname);
+ free(sysdirname);
+ }
+
+ if ((xf86configptr = xf86readConfigFile()) == NULL) {
+ xf86Msg(X_ERROR, "Problem parsing the config file\n");
+ return CONFIG_PARSE_ERROR;
+ }
+ xf86closeConfigFile();
/* Initialise a few things. */
@@ -2377,59 +2422,65 @@ xf86HandleConfigFile(Bool autoconfig)
/* First check if a layout section is present, and if it is valid. */
if (xf86configptr->conf_layout_lst == NULL || xf86ScreenName != NULL) {
- if (xf86ScreenName == NULL) {
- xf86Msg(X_DEFAULT,
- "No Layout section. Using the first Screen section.\n");
- }
- if (!configImpliedLayout(&xf86ConfigLayout,
- xf86configptr->conf_screen_lst,
- xf86configptr)) {
+ if (xf86ScreenName == NULL) {
+ xf86Msg(X_DEFAULT,
+ "No Layout section. Using the first Screen section.\n");
+ }
+ if (!configImpliedLayout(&xf86ConfigLayout,
+ xf86configptr->conf_screen_lst,
+ xf86configptr)) {
xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
- return CONFIG_PARSE_ERROR;
- }
- implicit_layout = TRUE;
- } else {
- if (xf86configptr->conf_flags != NULL) {
- char *dfltlayout = NULL;
- pointer optlist = xf86configptr->conf_flags->flg_option_lst;
-
- if (optlist && xf86FindOption(optlist, "defaultserverlayout"))
- dfltlayout = xf86SetStrOption(optlist, "defaultserverlayout", NULL);
- if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst,
- dfltlayout)) {
- xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
- return CONFIG_PARSE_ERROR;
- }
- } else {
- if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst,
- NULL)) {
- xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
- return CONFIG_PARSE_ERROR;
- }
- }
+ return CONFIG_PARSE_ERROR;
+ }
+ implicit_layout = TRUE;
+ }
+ else {
+ if (xf86configptr->conf_flags != NULL) {
+ char *dfltlayout = NULL;
+ pointer optlist = xf86configptr->conf_flags->flg_option_lst;
+
+ if (optlist && xf86FindOption(optlist, "defaultserverlayout"))
+ dfltlayout =
+ xf86SetStrOption(optlist, "defaultserverlayout", NULL);
+ if (!configLayout
+ (&xf86ConfigLayout, xf86configptr->conf_layout_lst,
+ dfltlayout)) {
+ xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
+ return CONFIG_PARSE_ERROR;
+ }
+ }
+ else {
+ if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst,
+ NULL)) {
+ xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
+ return CONFIG_PARSE_ERROR;
+ }
+ }
}
xf86ProcessOptions(-1, xf86ConfigLayout.options, LayoutOptions);
#ifdef XSERVER_LIBPCIACCESS
if ((scanptr = xf86GetOptValString(LayoutOptions, LAYOUT_ISOLATEDEVICE))) {
- ; /* IsolateDevice specified; overrides SingleCard */
- } else {
- xf86GetOptValBool(LayoutOptions, LAYOUT_SINGLECARD, &singlecard);
- if (singlecard)
- scanptr = xf86ConfigLayout.screens->screen->device->busID;
+ ; /* IsolateDevice specified; overrides SingleCard */
+ }
+ else {
+ xf86GetOptValBool(LayoutOptions, LAYOUT_SINGLECARD, &singlecard);
+ if (singlecard)
+ scanptr = xf86ConfigLayout.screens->screen->device->busID;
}
if (scanptr) {
- if (strncmp(scanptr, "PCI:", 4) != 0) {
- xf86Msg(X_WARNING, "Bus types other than PCI not yet isolable.\n"
- "\tIgnoring IsolateDevice option.\n");
- } else
- xf86PciIsolateDevice(scanptr);
+ if (strncmp(scanptr, "PCI:", 4) != 0) {
+ xf86Msg(X_WARNING, "Bus types other than PCI not yet isolable.\n"
+ "\tIgnoring IsolateDevice option.\n");
+ }
+ else
+ xf86PciIsolateDevice(scanptr);
}
#endif
/* Now process everything else */
- if (!configServerFlags(xf86configptr->conf_flags,xf86ConfigLayout.options)){
- ErrorF ("Problem when converting the config data structures\n");
- return CONFIG_PARSE_ERROR;
+ if (!configServerFlags(xf86configptr->conf_flags, xf86ConfigLayout.options)) {
+ ErrorF("Problem when converting the config data structures\n");
+ return CONFIG_PARSE_ERROR;
}
configFiles(xf86configptr->conf_files);
@@ -2446,13 +2497,13 @@ xf86HandleConfigFile(Bool autoconfig)
*/
#ifdef XF86VIDMODE
if (xf86VidModeDisabled)
- xf86Info.vidModeEnabled = FALSE;
+ xf86Info.vidModeEnabled = FALSE;
if (xf86VidModeAllowNonLocal)
- xf86Info.vidModeAllowNonLocal = TRUE;
+ xf86Info.vidModeAllowNonLocal = TRUE;
#endif
if (xf86AllowMouseOpenFail)
- xf86Info.allowMouseOpenFail = TRUE;
+ xf86Info.allowMouseOpenFail = TRUE;
return CONFIG_OK;
}
diff --git a/xorg-server/hw/xfree86/common/xf86Configure.c b/xorg-server/hw/xfree86/common/xf86Configure.c
index 994d46fc2..6f69117d3 100644
--- a/xorg-server/hw/xfree86/common/xf86Configure.c
+++ b/xorg-server/hw/xfree86/common/xf86Configure.c
@@ -43,7 +43,7 @@
typedef struct _DevToConfig {
GDevRec GDev;
- struct pci_device * pVideo;
+ struct pci_device *pVideo;
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
sbusDevicePtr sVideo;
#endif
@@ -77,28 +77,29 @@ static const char *DFLT_MOUSE_PROTO = "auto";
* the caller fill in the rest and/or change it as it sees fit.
*/
GDevPtr
-xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int chipset)
+xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData,
+ int chipset)
{
int ret, i, j;
if (!xf86DoConfigure || !xf86DoConfigurePass1)
- return NULL;
+ return NULL;
/* Check for duplicates */
- for (i = 0; i < nDevToConfig; i++) {
+ for (i = 0; i < nDevToConfig; i++) {
switch (bus) {
#ifdef XSERVER_LIBPCIACCESS
- case BUS_PCI:
- ret = xf86PciConfigure(busData, DevToConfig[i].pVideo);
- break;
+ case BUS_PCI:
+ ret = xf86PciConfigure(busData, DevToConfig[i].pVideo);
+ break;
#endif
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
- case BUS_SBUS:
- ret = xf86SbusConfigure(busData, DevToConfig[i].sVideo);
- break;
+ case BUS_SBUS:
+ ret = xf86SbusConfigure(busData, DevToConfig[i].sVideo);
+ break;
#endif
- default:
- return NULL;
+ default:
+ return NULL;
}
if (ret == 0)
goto out;
@@ -107,112 +108,113 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int
/* Allocate new structure occurrence */
i = nDevToConfig++;
DevToConfig =
- xnfrealloc(DevToConfig, nDevToConfig * sizeof(DevToConfigRec));
+ xnfrealloc(DevToConfig, nDevToConfig * sizeof(DevToConfigRec));
memset(DevToConfig + i, 0, sizeof(DevToConfigRec));
DevToConfig[i].GDev.chipID =
- DevToConfig[i].GDev.chipRev = DevToConfig[i].GDev.irq = -1;
+ DevToConfig[i].GDev.chipRev = DevToConfig[i].GDev.irq = -1;
DevToConfig[i].iDriver = CurrentDriver;
/* Fill in what we know, converting the driver name to lower case */
DevToConfig[i].GDev.driver = xnfalloc(strlen(driver) + 1);
- for (j = 0; (DevToConfig[i].GDev.driver[j] = tolower(driver[j])); j++);
+ for (j = 0; (DevToConfig[i].GDev.driver[j] = tolower(driver[j])); j++);
switch (bus) {
#ifdef XSERVER_LIBPCIACCESS
- case BUS_PCI:
- xf86PciConfigureNewDev(busData, DevToConfig[i].pVideo,
- &DevToConfig[i].GDev, &chipset);
- break;
+ case BUS_PCI:
+ xf86PciConfigureNewDev(busData, DevToConfig[i].pVideo,
+ &DevToConfig[i].GDev, &chipset);
+ break;
#endif
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
- case BUS_SBUS:
- xf86SbusConfigureNewDev(busData, DevToConfig[i].sVideo,
- &DevToConfig[i].GDev);
- break;
+ case BUS_SBUS:
+ xf86SbusConfigureNewDev(busData, DevToConfig[i].sVideo,
+ &DevToConfig[i].GDev);
+ break;
#endif
- default:
- break;
+ default:
+ break;
}
/* Get driver's available options */
if (xf86DriverList[CurrentDriver]->AvailableOptions)
- DevToConfig[i].GDev.options = (OptionInfoPtr)
- (*xf86DriverList[CurrentDriver]->AvailableOptions)(chipset,
- bus);
+ DevToConfig[i].GDev.options = (OptionInfoPtr)
+ (*xf86DriverList[CurrentDriver]->AvailableOptions) (chipset, bus);
return &DevToConfig[i].GDev;
-out:
+ out:
return NULL;
}
static XF86ConfInputPtr
-configureInputSection (void)
+configureInputSection(void)
{
XF86ConfInputPtr mouse = NULL;
- parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
- ptr->inp_identifier = "Keyboard0";
+ parsePrologue(XF86ConfInputPtr, XF86ConfInputRec)
+
+ ptr->inp_identifier = "Keyboard0";
ptr->inp_driver = "kbd";
ptr->list.next = NULL;
/* Crude mechanism to auto-detect mouse (os dependent) */
- {
- int fd;
+ {
+ int fd;
- fd = open(DFLT_MOUSE_DEV, 0);
- if (fd != -1) {
- foundMouse = TRUE;
- close(fd);
- }
+ fd = open(DFLT_MOUSE_DEV, 0);
+ if (fd != -1) {
+ foundMouse = TRUE;
+ close(fd);
+ }
}
mouse = calloc(1, sizeof(XF86ConfInputRec));
mouse->inp_identifier = "Mouse0";
mouse->inp_driver = "mouse";
- mouse->inp_option_lst =
- xf86addNewOption(mouse->inp_option_lst, strdup("Protocol"),
- strdup(DFLT_MOUSE_PROTO));
- mouse->inp_option_lst =
- xf86addNewOption(mouse->inp_option_lst, strdup("Device"),
- strdup(DFLT_MOUSE_DEV));
- mouse->inp_option_lst =
- xf86addNewOption(mouse->inp_option_lst, strdup("ZAxisMapping"),
- strdup("4 5 6 7"));
- ptr = (XF86ConfInputPtr)xf86addListItem((glp)ptr, (glp)mouse);
+ mouse->inp_option_lst =
+ xf86addNewOption(mouse->inp_option_lst, strdup("Protocol"),
+ strdup(DFLT_MOUSE_PROTO));
+ mouse->inp_option_lst =
+ xf86addNewOption(mouse->inp_option_lst, strdup("Device"),
+ strdup(DFLT_MOUSE_DEV));
+ mouse->inp_option_lst =
+ xf86addNewOption(mouse->inp_option_lst, strdup("ZAxisMapping"),
+ strdup("4 5 6 7"));
+ ptr = (XF86ConfInputPtr) xf86addListItem((glp) ptr, (glp) mouse);
return ptr;
}
static XF86ConfScreenPtr
-configureScreenSection (int screennum)
+configureScreenSection(int screennum)
{
int i;
- int depths[] = { 1, 4, 8, 15, 16, 24/*, 32*/ };
- parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec)
+ int depths[] = { 1, 4, 8, 15, 16, 24 /*, 32 */ };
+ parsePrologue(XF86ConfScreenPtr, XF86ConfScreenRec)
- XNFasprintf(&ptr->scrn_identifier, "Screen%d", screennum);
+ XNFasprintf(&ptr->scrn_identifier, "Screen%d", screennum);
XNFasprintf(&ptr->scrn_monitor_str, "Monitor%d", screennum);
XNFasprintf(&ptr->scrn_device_str, "Card%d", screennum);
- for (i=0; i<sizeof(depths)/sizeof(depths[0]); i++)
- {
- XF86ConfDisplayPtr display;
-
- display = calloc(1, sizeof(XF86ConfDisplayRec));
- display->disp_depth = depths[i];
- display->disp_black.red = display->disp_white.red = -1;
- display->disp_black.green = display->disp_white.green = -1;
- display->disp_black.blue = display->disp_white.blue = -1;
- ptr->scrn_display_lst = (XF86ConfDisplayPtr)xf86addListItem(
- (glp)ptr->scrn_display_lst, (glp)display);
+ for (i = 0; i < sizeof(depths) / sizeof(depths[0]); i++) {
+ XF86ConfDisplayPtr display;
+
+ display = calloc(1, sizeof(XF86ConfDisplayRec));
+ display->disp_depth = depths[i];
+ display->disp_black.red = display->disp_white.red = -1;
+ display->disp_black.green = display->disp_white.green = -1;
+ display->disp_black.blue = display->disp_white.blue = -1;
+ ptr->scrn_display_lst = (XF86ConfDisplayPtr) xf86addListItem((glp) ptr->
+ scrn_display_lst,
+ (glp)
+ display);
}
return ptr;
}
-static const char*
+static const char *
optionTypeToString(OptionValueType type)
{
switch (type) {
@@ -223,7 +225,7 @@ optionTypeToString(OptionValueType type)
case OPTV_STRING:
return "<str>";
case OPTV_ANYSTR:
- return "[<str>]";
+ return "[<str>]";
case OPTV_REAL:
return "<f>";
case OPTV_BOOLEAN:
@@ -238,20 +240,21 @@ optionTypeToString(OptionValueType type)
}
static XF86ConfDevicePtr
-configureDeviceSection (int screennum)
+configureDeviceSection(int screennum)
{
OptionInfoPtr p;
int i = 0;
- parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)
- /* Move device info to parser structure */
- if (asprintf(&ptr->dev_identifier, "Card%d", screennum) == -1)
+ parsePrologue(XF86ConfDevicePtr, XF86ConfDeviceRec)
+
+ /* Move device info to parser structure */
+ if (asprintf(&ptr->dev_identifier, "Card%d", screennum) == -1)
ptr->dev_identifier = NULL;
ptr->dev_chipset = DevToConfig[screennum].GDev.chipset;
ptr->dev_busid = DevToConfig[screennum].GDev.busID;
ptr->dev_driver = DevToConfig[screennum].GDev.driver;
ptr->dev_ramdac = DevToConfig[screennum].GDev.ramdac;
- for (i = 0; (i < MAXDACSPEEDS) && (i < CONF_MAXDACSPEEDS); i++)
+ for (i = 0; (i < MAXDACSPEEDS) && (i < CONF_MAXDACSPEEDS); i++)
ptr->dev_dacSpeeds[i] = DevToConfig[screennum].GDev.dacSpeeds[i];
ptr->dev_videoram = DevToConfig[screennum].GDev.videoRam;
ptr->dev_textclockfreq = DevToConfig[screennum].GDev.textClockFreq;
@@ -259,7 +262,8 @@ configureDeviceSection (int screennum)
ptr->dev_mem_base = DevToConfig[screennum].GDev.MemBase;
ptr->dev_io_base = DevToConfig[screennum].GDev.IOBase;
ptr->dev_clockchip = DevToConfig[screennum].GDev.clockchip;
- for (i = 0; (i < MAXCLOCKS) && (i < DevToConfig[screennum].GDev.numclocks); i++)
+ for (i = 0; (i < MAXCLOCKS) && (i < DevToConfig[screennum].GDev.numclocks);
+ i++)
ptr->dev_clock[i] = DevToConfig[screennum].GDev.clock[i];
ptr->dev_clocks = i;
ptr->dev_chipid = DevToConfig[screennum].GDev.chipID;
@@ -268,161 +272,165 @@ configureDeviceSection (int screennum)
/* Make sure older drivers don't segv */
if (DevToConfig[screennum].GDev.options) {
- /* Fill in the available driver options for people to use */
- const char *descrip =
- " ### Available Driver options are:-\n"
- " ### Values: <i>: integer, <f>: float, "
- "<bool>: \"True\"/\"False\",\n"
- " ### <string>: \"String\", <freq>: \"<f> Hz/kHz/MHz\",\n"
- " ### <percent>: \"<f>%\"\n"
- " ### [arg]: arg optional\n";
- ptr->dev_comment = strdup(descrip);
- if (ptr->dev_comment) {
- for (p = DevToConfig[screennum].GDev.options;
- p->name != NULL; p++) {
- char *p_e;
- const char *prefix = " #Option ";
- const char *middle = " \t# ";
- const char *suffix = "\n";
- const char *opttype = optionTypeToString(p->type);
- char *optname;
- int len = strlen(ptr->dev_comment) + strlen(prefix) +
- strlen(middle) + strlen(suffix) + 1;
-
- if (asprintf(&optname, "\"%s\"", p->name) == -1)
- break;
-
- len += max(20, strlen(optname));
- len += strlen(opttype);
-
- ptr->dev_comment = realloc(ptr->dev_comment, len);
- if (!ptr->dev_comment)
- break;
- p_e = ptr->dev_comment + strlen(ptr->dev_comment);
- sprintf(p_e, "%s%-20s%s%s%s", prefix, optname, middle,
- opttype, suffix);
- free(optname);
- }
- }
+ /* Fill in the available driver options for people to use */
+ const char *descrip =
+ " ### Available Driver options are:-\n"
+ " ### Values: <i>: integer, <f>: float, "
+ "<bool>: \"True\"/\"False\",\n"
+ " ### <string>: \"String\", <freq>: \"<f> Hz/kHz/MHz\",\n"
+ " ### <percent>: \"<f>%\"\n"
+ " ### [arg]: arg optional\n";
+ ptr->dev_comment = strdup(descrip);
+ if (ptr->dev_comment) {
+ for (p = DevToConfig[screennum].GDev.options; p->name != NULL; p++) {
+ char *p_e;
+ const char *prefix = " #Option ";
+ const char *middle = " \t# ";
+ const char *suffix = "\n";
+ const char *opttype = optionTypeToString(p->type);
+ char *optname;
+ int len = strlen(ptr->dev_comment) + strlen(prefix) +
+ strlen(middle) + strlen(suffix) + 1;
+
+ if (asprintf(&optname, "\"%s\"", p->name) == -1)
+ break;
+
+ len += max(20, strlen(optname));
+ len += strlen(opttype);
+
+ ptr->dev_comment = realloc(ptr->dev_comment, len);
+ if (!ptr->dev_comment)
+ break;
+ p_e = ptr->dev_comment + strlen(ptr->dev_comment);
+ sprintf(p_e, "%s%-20s%s%s%s", prefix, optname, middle,
+ opttype, suffix);
+ free(optname);
+ }
+ }
}
return ptr;
}
static XF86ConfLayoutPtr
-configureLayoutSection (void)
+configureLayoutSection(void)
{
int scrnum = 0;
- parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec)
- ptr->lay_identifier = "X.org Configured";
+ parsePrologue(XF86ConfLayoutPtr, XF86ConfLayoutRec)
- {
- XF86ConfInputrefPtr iptr;
+ ptr->lay_identifier = "X.org Configured";
- iptr = malloc (sizeof (XF86ConfInputrefRec));
- iptr->list.next = NULL;
- iptr->iref_option_lst = NULL;
- iptr->iref_inputdev_str = "Mouse0";
- iptr->iref_option_lst =
- xf86addNewOption (iptr->iref_option_lst, strdup("CorePointer"), NULL);
- ptr->lay_input_lst = (XF86ConfInputrefPtr)
- xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
+ {
+ XF86ConfInputrefPtr iptr;
+
+ iptr = malloc(sizeof(XF86ConfInputrefRec));
+ iptr->list.next = NULL;
+ iptr->iref_option_lst = NULL;
+ iptr->iref_inputdev_str = "Mouse0";
+ iptr->iref_option_lst =
+ xf86addNewOption(iptr->iref_option_lst, strdup("CorePointer"),
+ NULL);
+ ptr->lay_input_lst = (XF86ConfInputrefPtr)
+ xf86addListItem((glp) ptr->lay_input_lst, (glp) iptr);
}
{
- XF86ConfInputrefPtr iptr;
-
- iptr = malloc (sizeof (XF86ConfInputrefRec));
- iptr->list.next = NULL;
- iptr->iref_option_lst = NULL;
- iptr->iref_inputdev_str = "Keyboard0";
- iptr->iref_option_lst =
- xf86addNewOption (iptr->iref_option_lst, strdup("CoreKeyboard"), NULL);
- ptr->lay_input_lst = (XF86ConfInputrefPtr)
- xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
- }
-
- for (scrnum = 0; scrnum < nDevToConfig; scrnum++) {
- XF86ConfAdjacencyPtr aptr;
-
- aptr = malloc (sizeof (XF86ConfAdjacencyRec));
- aptr->list.next = NULL;
- aptr->adj_x = 0;
- aptr->adj_y = 0;
- aptr->adj_scrnum = scrnum;
- XNFasprintf(&aptr->adj_screen_str, "Screen%d", scrnum);
- if (scrnum == 0) {
- aptr->adj_where = CONF_ADJ_ABSOLUTE;
- aptr->adj_refscreen = NULL;
- }
- else {
- aptr->adj_where = CONF_ADJ_RIGHTOF;
- XNFasprintf(&aptr->adj_refscreen, "Screen%d", scrnum - 1);
- }
- ptr->lay_adjacency_lst =
- (XF86ConfAdjacencyPtr)xf86addListItem((glp)ptr->lay_adjacency_lst,
- (glp)aptr);
+ XF86ConfInputrefPtr iptr;
+
+ iptr = malloc(sizeof(XF86ConfInputrefRec));
+ iptr->list.next = NULL;
+ iptr->iref_option_lst = NULL;
+ iptr->iref_inputdev_str = "Keyboard0";
+ iptr->iref_option_lst =
+ xf86addNewOption(iptr->iref_option_lst, strdup("CoreKeyboard"),
+ NULL);
+ ptr->lay_input_lst = (XF86ConfInputrefPtr)
+ xf86addListItem((glp) ptr->lay_input_lst, (glp) iptr);
+ }
+
+ for (scrnum = 0; scrnum < nDevToConfig; scrnum++) {
+ XF86ConfAdjacencyPtr aptr;
+
+ aptr = malloc(sizeof(XF86ConfAdjacencyRec));
+ aptr->list.next = NULL;
+ aptr->adj_x = 0;
+ aptr->adj_y = 0;
+ aptr->adj_scrnum = scrnum;
+ XNFasprintf(&aptr->adj_screen_str, "Screen%d", scrnum);
+ if (scrnum == 0) {
+ aptr->adj_where = CONF_ADJ_ABSOLUTE;
+ aptr->adj_refscreen = NULL;
+ }
+ else {
+ aptr->adj_where = CONF_ADJ_RIGHTOF;
+ XNFasprintf(&aptr->adj_refscreen, "Screen%d", scrnum - 1);
+ }
+ ptr->lay_adjacency_lst =
+ (XF86ConfAdjacencyPtr) xf86addListItem((glp) ptr->lay_adjacency_lst,
+ (glp) aptr);
}
return ptr;
}
static XF86ConfFlagsPtr
-configureFlagsSection (void)
+configureFlagsSection(void)
{
- parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec)
+ parsePrologue(XF86ConfFlagsPtr, XF86ConfFlagsRec)
- return ptr;
+ return ptr;
}
static XF86ConfModulePtr
-configureModuleSection (void)
+configureModuleSection(void)
{
char **elist, **el;
+
/* Find the list of extension & font modules. */
const char *esubdirs[] = {
- "extensions",
- "fonts",
- NULL
+ "extensions",
+ "fonts",
+ NULL
};
- parsePrologue (XF86ConfModulePtr, XF86ConfModuleRec)
+ parsePrologue(XF86ConfModulePtr, XF86ConfModuleRec)
- elist = LoaderListDirs(esubdirs, NULL);
+ elist = LoaderListDirs(esubdirs, NULL);
if (elist) {
- for (el = elist; *el; el++) {
- XF86LoadPtr module;
-
- module = calloc(1, sizeof(XF86LoadRec));
- module->load_name = *el;
- ptr->mod_load_lst = (XF86LoadPtr)xf86addListItem(
- (glp)ptr->mod_load_lst, (glp)module);
- }
- free(elist);
+ for (el = elist; *el; el++) {
+ XF86LoadPtr module;
+
+ module = calloc(1, sizeof(XF86LoadRec));
+ module->load_name = *el;
+ ptr->mod_load_lst = (XF86LoadPtr) xf86addListItem((glp) ptr->
+ mod_load_lst,
+ (glp) module);
+ }
+ free(elist);
}
return ptr;
}
static XF86ConfFilesPtr
-configureFilesSection (void)
+configureFilesSection(void)
{
- parsePrologue (XF86ConfFilesPtr, XF86ConfFilesRec)
+ parsePrologue(XF86ConfFilesPtr, XF86ConfFilesRec)
+
+ if (xf86ModulePath)
+ ptr->file_modulepath = strdup(xf86ModulePath);
+ if (defaultFontPath)
+ ptr->file_fontpath = strdup(defaultFontPath);
- if (xf86ModulePath)
- ptr->file_modulepath = strdup(xf86ModulePath);
- if (defaultFontPath)
- ptr->file_fontpath = strdup(defaultFontPath);
-
return ptr;
}
static XF86ConfMonitorPtr
-configureMonitorSection (int screennum)
+configureMonitorSection(int screennum)
{
- parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
+ parsePrologue(XF86ConfMonitorPtr, XF86ConfMonitorRec)
- XNFasprintf(&ptr->mon_identifier, "Monitor%d", screennum);
+ XNFasprintf(&ptr->mon_identifier, "Monitor%d", screennum);
ptr->mon_vendor = strdup("Monitor Vendor");
ptr->mon_modelname = strdup("Monitor Model");
@@ -430,29 +438,24 @@ configureMonitorSection (int screennum)
}
/* Initialize Configure Monitor from Detailed Timing Block */
-static void handle_detailed_input(struct detailed_monitor_section *det_mon,
- void *data)
+static void
+handle_detailed_input(struct detailed_monitor_section *det_mon, void *data)
{
XF86ConfMonitorPtr ptr = (XF86ConfMonitorPtr) data;
switch (det_mon->type) {
case DS_NAME:
ptr->mon_modelname = realloc(ptr->mon_modelname,
- strlen((char*)(det_mon->section.name)) +
+ strlen((char *) (det_mon->section.name)) +
1);
- strcpy(ptr->mon_modelname,
- (char*)(det_mon->section.name));
+ strcpy(ptr->mon_modelname, (char *) (det_mon->section.name));
break;
case DS_RANGES:
- ptr->mon_hsync[ptr->mon_n_hsync].lo =
- det_mon->section.ranges.min_h;
- ptr->mon_hsync[ptr->mon_n_hsync].hi =
- det_mon->section.ranges.max_h;
+ ptr->mon_hsync[ptr->mon_n_hsync].lo = det_mon->section.ranges.min_h;
+ ptr->mon_hsync[ptr->mon_n_hsync].hi = det_mon->section.ranges.max_h;
ptr->mon_n_vrefresh = 1;
- ptr->mon_vrefresh[ptr->mon_n_hsync].lo =
- det_mon->section.ranges.min_v;
- ptr->mon_vrefresh[ptr->mon_n_hsync].hi =
- det_mon->section.ranges.max_v;
+ ptr->mon_vrefresh[ptr->mon_n_hsync].lo = det_mon->section.ranges.min_v;
+ ptr->mon_vrefresh[ptr->mon_n_hsync].hi = det_mon->section.ranges.max_v;
ptr->mon_n_hsync++;
default:
break;
@@ -460,53 +463,56 @@ static void handle_detailed_input(struct detailed_monitor_section *det_mon,
}
static XF86ConfMonitorPtr
-configureDDCMonitorSection (int screennum)
+configureDDCMonitorSection(int screennum)
{
int len, mon_width, mon_height;
+
#define displaySizeMaxLen 80
char displaySize_string[displaySizeMaxLen];
int displaySizeLen;
- parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
+ parsePrologue(XF86ConfMonitorPtr, XF86ConfMonitorRec)
- XNFasprintf(&ptr->mon_identifier, "Monitor%d", screennum);
+ XNFasprintf(&ptr->mon_identifier, "Monitor%d", screennum);
ptr->mon_vendor = strdup(ConfiguredMonitor->vendor.name);
XNFasprintf(&ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id);
/* features in centimetres, we want millimetres */
- mon_width = 10 * ConfiguredMonitor->features.hsize ;
- mon_height = 10 * ConfiguredMonitor->features.vsize ;
+ mon_width = 10 * ConfiguredMonitor->features.hsize;
+ mon_height = 10 * ConfiguredMonitor->features.vsize;
#ifdef CONFIGURE_DISPLAYSIZE
- ptr->mon_width = mon_width;
+ ptr->mon_width = mon_width;
ptr->mon_height = mon_height;
#else
if (mon_width && mon_height) {
- /* when values available add DisplaySize option AS A COMMENT */
-
- displaySizeLen = snprintf(displaySize_string, displaySizeMaxLen,
- "\t#DisplaySize\t%5d %5d\t# mm\n",
- mon_width, mon_height);
-
- if (displaySizeLen>0 && displaySizeLen<displaySizeMaxLen) {
- if (ptr->mon_comment) {
- len = strlen(ptr->mon_comment);
- } else {
- len = 0;
- }
- if ((ptr->mon_comment =
- realloc(ptr->mon_comment, len + strlen(displaySize_string) + 1))) {
- strcpy(ptr->mon_comment + len, displaySize_string);
- }
- }
+ /* when values available add DisplaySize option AS A COMMENT */
+
+ displaySizeLen = snprintf(displaySize_string, displaySizeMaxLen,
+ "\t#DisplaySize\t%5d %5d\t# mm\n",
+ mon_width, mon_height);
+
+ if (displaySizeLen > 0 && displaySizeLen < displaySizeMaxLen) {
+ if (ptr->mon_comment) {
+ len = strlen(ptr->mon_comment);
+ }
+ else {
+ len = 0;
+ }
+ if ((ptr->mon_comment =
+ realloc(ptr->mon_comment,
+ len + strlen(displaySize_string) + 1))) {
+ strcpy(ptr->mon_comment + len, displaySize_string);
+ }
+ }
}
-#endif /* def CONFIGURE_DISPLAYSIZE */
+#endif /* def CONFIGURE_DISPLAYSIZE */
- xf86ForEachDetailedBlock(ConfiguredMonitor, handle_detailed_input,
- ptr);
+ xf86ForEachDetailedBlock(ConfiguredMonitor, handle_detailed_input, ptr);
if (ConfiguredMonitor->features.dpms) {
- ptr->mon_option_lst = xf86addNewOption(ptr->mon_option_lst, strdup("DPMS"), NULL);
+ ptr->mon_option_lst =
+ xf86addNewOption(ptr->mon_option_lst, strdup("DPMS"), NULL);
}
return ptr;
@@ -515,7 +521,7 @@ configureDDCMonitorSection (int screennum)
void
DoConfigure(void)
{
- int i,j, screennum = -1;
+ int i, j, screennum = -1;
const char *home = NULL;
char filename[PATH_MAX];
const char *addslash = "";
@@ -526,13 +532,13 @@ DoConfigure(void)
vlist = xf86DriverlistFromCompile();
if (!vlist) {
- ErrorF("Missing output drivers. Configuration failed.\n");
- goto bail;
+ ErrorF("Missing output drivers. Configuration failed.\n");
+ goto bail;
}
ErrorF("List of video drivers:\n");
for (vl = vlist; *vl; vl++)
- ErrorF("\t%s\n", *vl);
+ ErrorF("\t%s\n", *vl);
/* Load all the drivers that were found. */
xf86LoadModules(vlist, NULL);
@@ -540,65 +546,71 @@ DoConfigure(void)
free(vlist);
for (i = 0; i < xf86NumDrivers; i++) {
- xorgHWFlags flags;
- if (!xf86DriverList[i]->driverFunc
- || !xf86DriverList[i]->driverFunc(NULL,
- GET_REQUIRED_HW_INTERFACES,
- &flags)
- || NEED_IO_ENABLED(flags)) {
- xorgHWAccess = TRUE;
- break;
- }
+ xorgHWFlags flags;
+
+ if (!xf86DriverList[i]->driverFunc
+ || !xf86DriverList[i]->driverFunc(NULL,
+ GET_REQUIRED_HW_INTERFACES,
+ &flags)
+ || NEED_IO_ENABLED(flags)) {
+ xorgHWAccess = TRUE;
+ break;
+ }
}
/* Enable full I/O access */
if (xorgHWAccess) {
- if(!xf86EnableIO())
- /* oops, we have failed */
- xorgHWAccess = FALSE;
+ if (!xf86EnableIO())
+ /* oops, we have failed */
+ xorgHWAccess = FALSE;
}
/* Create XF86Config file structure */
xf86config = calloc(1, sizeof(XF86ConfigRec));
/* Call all of the probe functions, reporting the results. */
- for (CurrentDriver = 0; CurrentDriver < xf86NumDrivers; CurrentDriver++) {
- xorgHWFlags flags;
- Bool found_screen;
- DriverRec * const drv = xf86DriverList[CurrentDriver];
-
- if (!xorgHWAccess) {
- if (!drv->driverFunc
- || !drv->driverFunc( NULL, GET_REQUIRED_HW_INTERFACES, &flags )
- || NEED_IO_ENABLED(flags))
- continue;
- }
-
- found_screen = xf86CallDriverProbe( drv, TRUE );
- if ( found_screen && drv->Identify ) {
- (*drv->Identify)(0);
- }
+ for (CurrentDriver = 0; CurrentDriver < xf86NumDrivers; CurrentDriver++) {
+ xorgHWFlags flags;
+ Bool found_screen;
+ DriverRec *const drv = xf86DriverList[CurrentDriver];
+
+ if (!xorgHWAccess) {
+ if (!drv->driverFunc
+ || !drv->driverFunc(NULL, GET_REQUIRED_HW_INTERFACES, &flags)
+ || NEED_IO_ENABLED(flags))
+ continue;
+ }
+
+ found_screen = xf86CallDriverProbe(drv, TRUE);
+ if (found_screen && drv->Identify) {
+ (*drv->Identify) (0);
+ }
}
if (nDevToConfig <= 0) {
- ErrorF("No devices to configure. Configuration failed.\n");
- goto bail;
+ ErrorF("No devices to configure. Configuration failed.\n");
+ goto bail;
}
/* Add device, monitor and screen sections for detected devices */
- for (screennum = 0; screennum < nDevToConfig; screennum++) {
- XF86ConfDevicePtr DevicePtr;
- XF86ConfMonitorPtr MonitorPtr;
- XF86ConfScreenPtr ScreenPtr;
-
- DevicePtr = configureDeviceSection(screennum);
- xf86config->conf_device_lst = (XF86ConfDevicePtr)xf86addListItem(
- (glp)xf86config->conf_device_lst, (glp)DevicePtr);
- MonitorPtr = configureMonitorSection(screennum);
- xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem(
- (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr);
- ScreenPtr = configureScreenSection(screennum);
- xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem(
- (glp)xf86config->conf_screen_lst, (glp)ScreenPtr);
+ for (screennum = 0; screennum < nDevToConfig; screennum++) {
+ XF86ConfDevicePtr DevicePtr;
+ XF86ConfMonitorPtr MonitorPtr;
+ XF86ConfScreenPtr ScreenPtr;
+
+ DevicePtr = configureDeviceSection(screennum);
+ xf86config->conf_device_lst = (XF86ConfDevicePtr) xf86addListItem((glp)
+ xf86config->
+ conf_device_lst,
+ (glp)
+ DevicePtr);
+ MonitorPtr = configureMonitorSection(screennum);
+ xf86config->conf_monitor_lst = (XF86ConfMonitorPtr) xf86addListItem((glp) xf86config->conf_monitor_lst, (glp) MonitorPtr);
+ ScreenPtr = configureScreenSection(screennum);
+ xf86config->conf_screen_lst = (XF86ConfScreenPtr) xf86addListItem((glp)
+ xf86config->
+ conf_screen_lst,
+ (glp)
+ ScreenPtr);
}
xf86config->conf_files = configureFilesSection();
@@ -613,91 +625,95 @@ DoConfigure(void)
home = getenv("HOME");
if ((home == NULL) || (home[0] == '\0')) {
- home = "/";
- } else {
- /* Determine if trailing slash is present or needed */
- int l = strlen(home);
+ home = "/";
+ }
+ else {
+ /* Determine if trailing slash is present or needed */
+ int l = strlen(home);
- if (home[l-1] != '/') {
- addslash = "/";
- }
+ if (home[l - 1] != '/') {
+ addslash = "/";
+ }
}
snprintf(filename, sizeof(filename), "%s%s" XF86CONFIGFILE ".new",
- home, addslash);
+ home, addslash);
if (xf86writeConfigFile(filename, xf86config) == 0) {
- xf86Msg(X_ERROR, "Unable to write config file: \"%s\": %s\n",
- filename, strerror(errno));
- goto bail;
+ xf86Msg(X_ERROR, "Unable to write config file: \"%s\": %s\n",
+ filename, strerror(errno));
+ goto bail;
}
xf86DoConfigurePass1 = FALSE;
/* Try to get DDC information filled in */
xf86ConfigFile = filename;
if (xf86HandleConfigFile(FALSE) != CONFIG_OK) {
- goto bail;
+ goto bail;
}
xf86DoConfigurePass1 = FALSE;
-
- dev2screen = xnfcalloc(1,xf86NumDrivers*sizeof(int));
+
+ dev2screen = xnfcalloc(1, xf86NumDrivers * sizeof(int));
{
- Bool *driverProbed = xnfcalloc(1,xf86NumDrivers*sizeof(Bool));
- for (screennum = 0; screennum < nDevToConfig; screennum++) {
- int k,l,n,oldNumScreens;
-
- i = DevToConfig[screennum].iDriver;
-
- if (driverProbed[i]) continue;
- driverProbed[i] = TRUE;
-
- oldNumScreens = xf86NumScreens;
-
- xf86CallDriverProbe( xf86DriverList[i], FALSE );
-
- /* reorder */
- k = screennum > 0 ? screennum : 1;
- for (l = oldNumScreens; l < xf86NumScreens; l++) {
- /* is screen primary? */
- Bool primary = FALSE;
- for (n = 0; n<xf86Screens[l]->numEntities; n++) {
- if (xf86IsEntityPrimary(xf86Screens[l]->entityList[n])) {
- dev2screen[0] = l;
- primary = TRUE;
- break;
- }
- }
- if (primary) continue;
- /* not primary: assign it to next device of same driver */
- /*
- * NOTE: we assume that devices in DevToConfig
- * and xf86Screens[] have the same order except
- * for the primary device which always comes first.
- */
- for (; k < nDevToConfig; k++) {
- if (DevToConfig[k].iDriver == i) {
- dev2screen[k++] = l;
- break;
- }
- }
- }
- }
- free(driverProbed);
- }
-
+ Bool *driverProbed = xnfcalloc(1, xf86NumDrivers * sizeof(Bool));
+
+ for (screennum = 0; screennum < nDevToConfig; screennum++) {
+ int k, l, n, oldNumScreens;
+
+ i = DevToConfig[screennum].iDriver;
+
+ if (driverProbed[i])
+ continue;
+ driverProbed[i] = TRUE;
+
+ oldNumScreens = xf86NumScreens;
+
+ xf86CallDriverProbe(xf86DriverList[i], FALSE);
+
+ /* reorder */
+ k = screennum > 0 ? screennum : 1;
+ for (l = oldNumScreens; l < xf86NumScreens; l++) {
+ /* is screen primary? */
+ Bool primary = FALSE;
+
+ for (n = 0; n < xf86Screens[l]->numEntities; n++) {
+ if (xf86IsEntityPrimary(xf86Screens[l]->entityList[n])) {
+ dev2screen[0] = l;
+ primary = TRUE;
+ break;
+ }
+ }
+ if (primary)
+ continue;
+ /* not primary: assign it to next device of same driver */
+ /*
+ * NOTE: we assume that devices in DevToConfig
+ * and xf86Screens[] have the same order except
+ * for the primary device which always comes first.
+ */
+ for (; k < nDevToConfig; k++) {
+ if (DevToConfig[k].iDriver == i) {
+ dev2screen[k++] = l;
+ break;
+ }
+ }
+ }
+ }
+ free(driverProbed);
+ }
if (nDevToConfig != xf86NumScreens) {
- ErrorF("Number of created screens does not match number of detected"
- " devices.\n Configuration failed.\n");
- goto bail;
+ ErrorF("Number of created screens does not match number of detected"
+ " devices.\n Configuration failed.\n");
+ goto bail;
}
xf86PostProbe();
for (j = 0; j < xf86NumScreens; j++) {
- xf86Screens[j]->scrnIndex = j;
+ xf86Screens[j]->scrnIndex = j;
}
xf86freeMonitorList(xf86config->conf_monitor_lst);
@@ -705,53 +721,57 @@ DoConfigure(void)
xf86freeScreenList(xf86config->conf_screen_lst);
xf86config->conf_screen_lst = NULL;
for (j = 0; j < xf86NumScreens; j++) {
- XF86ConfMonitorPtr MonitorPtr;
- XF86ConfScreenPtr ScreenPtr;
+ XF86ConfMonitorPtr MonitorPtr;
+ XF86ConfScreenPtr ScreenPtr;
- ConfiguredMonitor = NULL;
+ ConfiguredMonitor = NULL;
- if ((*xf86Screens[dev2screen[j]]->PreInit)(xf86Screens[dev2screen[j]],
- PROBE_DETECT) &&
- ConfiguredMonitor) {
- MonitorPtr = configureDDCMonitorSection(j);
- } else {
- MonitorPtr = configureMonitorSection(j);
- }
- ScreenPtr = configureScreenSection(j);
- xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem(
- (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr);
- xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem(
- (glp)xf86config->conf_screen_lst, (glp)ScreenPtr);
+ if ((*xf86Screens[dev2screen[j]]->PreInit) (xf86Screens[dev2screen[j]],
+ PROBE_DETECT) &&
+ ConfiguredMonitor) {
+ MonitorPtr = configureDDCMonitorSection(j);
+ }
+ else {
+ MonitorPtr = configureMonitorSection(j);
+ }
+ ScreenPtr = configureScreenSection(j);
+
+ xf86config->conf_monitor_lst = (XF86ConfMonitorPtr) xf86addListItem((glp) xf86config->conf_monitor_lst, (glp) MonitorPtr);
+ xf86config->conf_screen_lst = (XF86ConfScreenPtr) xf86addListItem((glp)
+ xf86config->
+ conf_screen_lst,
+ (glp)
+ ScreenPtr);
}
if (xf86writeConfigFile(filename, xf86config) == 0) {
- xf86Msg(X_ERROR, "Unable to write config file: \"%s\": %s\n",
- filename, strerror(errno));
- goto bail;
+ xf86Msg(X_ERROR, "Unable to write config file: \"%s\": %s\n",
+ filename, strerror(errno));
+ goto bail;
}
ErrorF("\n");
if (!foundMouse) {
- ErrorF("\n"__XSERVERNAME__" is not able to detect your mouse.\n"
- "Edit the file and correct the Device.\n");
- } else {
- ErrorF("\n"__XSERVERNAME__" detected your mouse at device %s.\n"
- "Please check your config if the mouse is still not\n"
- "operational, as by default "__XSERVERNAME__
- " tries to autodetect\n"
- "the protocol.\n",DFLT_MOUSE_DEV);
+ ErrorF("\n" __XSERVERNAME__ " is not able to detect your mouse.\n"
+ "Edit the file and correct the Device.\n");
+ }
+ else {
+ ErrorF("\n" __XSERVERNAME__ " detected your mouse at device %s.\n"
+ "Please check your config if the mouse is still not\n"
+ "operational, as by default " __XSERVERNAME__
+ " tries to autodetect\n" "the protocol.\n", DFLT_MOUSE_DEV);
}
if (xf86NumScreens > 1) {
- ErrorF("\n"__XSERVERNAME__
- " has configured a multihead system, please check your config.\n");
+ ErrorF("\n" __XSERVERNAME__
+ " has configured a multihead system, please check your config.\n");
}
- ErrorF("\nYour %s file is %s\n\n", XF86CONFIGFILE ,filename);
+ ErrorF("\nYour %s file is %s\n\n", XF86CONFIGFILE, filename);
ErrorF("To test the server, run 'X -config %s'\n\n", filename);
-bail:
+ bail:
OsCleanup(TRUE);
AbortDDX(EXIT_ERR_CONFIGURE);
fflush(stderr);
@@ -765,47 +785,48 @@ bail:
* Author: Marcus Schaefer, ms@suse.de
*/
-void DoShowOptions (void) {
- int i = 0;
- char **vlist = 0;
- char *pSymbol = 0;
- XF86ModuleData *initData = 0;
- if (! (vlist = xf86DriverlistFromCompile())) {
- ErrorF("Missing output drivers\n");
- goto bail;
- }
- xf86LoadModules (vlist,0);
- free(vlist);
- for (i = 0; i < xf86NumDrivers; i++) {
- if (xf86DriverList[i]->AvailableOptions) {
- const OptionInfoRec *pOption =
- (*xf86DriverList[i]->AvailableOptions)(0,0);
- if (! pOption) {
- ErrorF ("(EE) Couldn't read option table for %s driver\n",
- xf86DriverList[i]->driverName
- );
- continue;
- }
- XNFasprintf(&pSymbol, "%sModuleData",
- xf86DriverList[i]->driverName);
- initData = LoaderSymbol (pSymbol);
- if (initData) {
- XF86ModuleVersionInfo *vers = initData->vers;
- const OptionInfoRec *p;
- ErrorF ("Driver[%d]:%s[%s] {\n",
- i,xf86DriverList[i]->driverName,vers->vendor
- );
- for (p = pOption; p->name != NULL; p++) {
- ErrorF ("\t%s:%s\n", p->name,
- optionTypeToString(p->type));
- }
- ErrorF ("}\n");
- }
- }
- }
- bail:
- OsCleanup (TRUE);
- AbortDDX (EXIT_ERR_DRIVERS);
- fflush (stderr);
- exit (0);
+void
+DoShowOptions(void)
+{
+ int i = 0;
+ char **vlist = 0;
+ char *pSymbol = 0;
+ XF86ModuleData *initData = 0;
+
+ if (!(vlist = xf86DriverlistFromCompile())) {
+ ErrorF("Missing output drivers\n");
+ goto bail;
+ }
+ xf86LoadModules(vlist, 0);
+ free(vlist);
+ for (i = 0; i < xf86NumDrivers; i++) {
+ if (xf86DriverList[i]->AvailableOptions) {
+ const OptionInfoRec *pOption =
+ (*xf86DriverList[i]->AvailableOptions) (0, 0);
+ if (!pOption) {
+ ErrorF("(EE) Couldn't read option table for %s driver\n",
+ xf86DriverList[i]->driverName);
+ continue;
+ }
+ XNFasprintf(&pSymbol, "%sModuleData",
+ xf86DriverList[i]->driverName);
+ initData = LoaderSymbol(pSymbol);
+ if (initData) {
+ XF86ModuleVersionInfo *vers = initData->vers;
+ const OptionInfoRec *p;
+
+ ErrorF("Driver[%d]:%s[%s] {\n",
+ i, xf86DriverList[i]->driverName, vers->vendor);
+ for (p = pOption; p->name != NULL; p++) {
+ ErrorF("\t%s:%s\n", p->name, optionTypeToString(p->type));
+ }
+ ErrorF("}\n");
+ }
+ }
+ }
+ bail:
+ OsCleanup(TRUE);
+ AbortDDX(EXIT_ERR_DRIVERS);
+ fflush(stderr);
+ exit(0);
}
diff --git a/xorg-server/hw/xfree86/common/xf86Cursor.c b/xorg-server/hw/xfree86/common/xf86Cursor.c
index 6f5d726f0..3716434f0 100644
--- a/xorg-server/hw/xfree86/common/xf86Cursor.c
+++ b/xorg-server/hw/xfree86/common/xf86Cursor.c
@@ -51,15 +51,15 @@
#endif
typedef struct _xf86EdgeRec {
- short screen;
- short start;
- short end;
- DDXPointRec offset;
- struct _xf86EdgeRec *next;
+ short screen;
+ short start;
+ short end;
+ DDXPointRec offset;
+ struct _xf86EdgeRec *next;
} xf86EdgeRec, *xf86EdgePtr;
typedef struct {
- xf86EdgePtr left, right, up, down;
+ xf86EdgePtr left, right, up, down;
} xf86ScreenLayoutRec, *xf86ScreenLayoutPtr;
static Bool xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y);
@@ -69,12 +69,12 @@ static void xf86WarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y);
static void xf86PointerMoved(int scrnIndex, int x, int y);
static miPointerScreenFuncRec xf86PointerScreenFuncs = {
- xf86CursorOffScreen,
- xf86CrossScreen,
- xf86WarpCursor,
- /* let miPointerInitialize take care of these */
- NULL,
- NULL
+ xf86CursorOffScreen,
+ xf86CrossScreen,
+ xf86WarpCursor,
+ /* let miPointerInitialize take care of these */
+ NULL,
+ NULL
};
static xf86ScreenLayoutRec xf86ScreenLayout[MAXSCREENS];
@@ -92,41 +92,39 @@ void
xf86InitViewport(ScrnInfoPtr pScr)
{
- pScr->PointerMoved = xf86PointerMoved;
-
- /*
- * Compute the initial Viewport if necessary
- */
- if (pScr->display) {
- if (pScr->display->frameX0 < 0) {
- pScr->frameX0 = (pScr->virtualX - pScr->modes->HDisplay) / 2;
- pScr->frameY0 = (pScr->virtualY - pScr->modes->VDisplay) / 2;
- } else {
- pScr->frameX0 = pScr->display->frameX0;
- pScr->frameY0 = pScr->display->frameY0;
+ pScr->PointerMoved = xf86PointerMoved;
+
+ /*
+ * Compute the initial Viewport if necessary
+ */
+ if (pScr->display) {
+ if (pScr->display->frameX0 < 0) {
+ pScr->frameX0 = (pScr->virtualX - pScr->modes->HDisplay) / 2;
+ pScr->frameY0 = (pScr->virtualY - pScr->modes->VDisplay) / 2;
+ }
+ else {
+ pScr->frameX0 = pScr->display->frameX0;
+ pScr->frameY0 = pScr->display->frameY0;
+ }
}
- }
-
- pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1;
- pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1;
-
- /*
- * Now adjust the initial Viewport, so it lies within the virtual area
- */
- if (pScr->frameX1 >= pScr->virtualX)
- {
- pScr->frameX0 = pScr->virtualX - pScr->modes->HDisplay;
- pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1;
+
+ pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1;
+ pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1;
+
+ /*
+ * Now adjust the initial Viewport, so it lies within the virtual area
+ */
+ if (pScr->frameX1 >= pScr->virtualX) {
+ pScr->frameX0 = pScr->virtualX - pScr->modes->HDisplay;
+ pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1;
}
- if (pScr->frameY1 >= pScr->virtualY)
- {
- pScr->frameY0 = pScr->virtualY - pScr->modes->VDisplay;
- pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1;
+ if (pScr->frameY1 >= pScr->virtualY) {
+ pScr->frameY0 = pScr->virtualY - pScr->modes->VDisplay;
+ pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1;
}
}
-
/*
* xf86SetViewport --
* Scroll the visual part of the screen so the pointer is visible.
@@ -135,48 +133,47 @@ xf86InitViewport(ScrnInfoPtr pScr)
void
xf86SetViewport(ScreenPtr pScreen, int x, int y)
{
- ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+ ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
- (*pScr->PointerMoved)(pScreen->myNum, x, y);
+ (*pScr->PointerMoved) (pScreen->myNum, x, y);
}
-
-static void
+static void
xf86PointerMoved(int scrnIndex, int x, int y)
{
- Bool frameChanged = FALSE;
- ScrnInfoPtr pScr = xf86Screens[scrnIndex];
-
- /*
- * check wether (x,y) belongs to the visual part of the screen
- * if not, change the base of the displayed frame accoring
- */
- if ( pScr->frameX0 > x) {
- pScr->frameX0 = x;
- pScr->frameX1 = x + pScr->currentMode->HDisplay - 1;
- frameChanged = TRUE ;
- }
-
- if ( pScr->frameX1 < x) {
- pScr->frameX1 = x + 1;
- pScr->frameX0 = x - pScr->currentMode->HDisplay + 1;
- frameChanged = TRUE ;
- }
-
- if ( pScr->frameY0 > y) {
- pScr->frameY0 = y;
- pScr->frameY1 = y + pScr->currentMode->VDisplay - 1;
- frameChanged = TRUE;
- }
-
- if ( pScr->frameY1 < y) {
- pScr->frameY1 = y;
- pScr->frameY0 = y - pScr->currentMode->VDisplay + 1;
- frameChanged = TRUE;
- }
-
- if (frameChanged && pScr->AdjustFrame != NULL)
- pScr->AdjustFrame(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0);
+ Bool frameChanged = FALSE;
+ ScrnInfoPtr pScr = xf86Screens[scrnIndex];
+
+ /*
+ * check wether (x,y) belongs to the visual part of the screen
+ * if not, change the base of the displayed frame accoring
+ */
+ if (pScr->frameX0 > x) {
+ pScr->frameX0 = x;
+ pScr->frameX1 = x + pScr->currentMode->HDisplay - 1;
+ frameChanged = TRUE;
+ }
+
+ if (pScr->frameX1 < x) {
+ pScr->frameX1 = x + 1;
+ pScr->frameX0 = x - pScr->currentMode->HDisplay + 1;
+ frameChanged = TRUE;
+ }
+
+ if (pScr->frameY0 > y) {
+ pScr->frameY0 = y;
+ pScr->frameY1 = y + pScr->currentMode->VDisplay - 1;
+ frameChanged = TRUE;
+ }
+
+ if (pScr->frameY1 < y) {
+ pScr->frameY1 = y;
+ pScr->frameY0 = y - pScr->currentMode->VDisplay + 1;
+ frameChanged = TRUE;
+ }
+
+ if (frameChanged && pScr->AdjustFrame != NULL)
+ pScr->AdjustFrame(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0);
}
/*
@@ -187,7 +184,7 @@ xf86PointerMoved(int scrnIndex, int x, int y)
void
xf86LockZoom(ScreenPtr pScreen, Bool lock)
{
- XF86SCRNINFO(pScreen)->zoomLocked = lock;
+ XF86SCRNINFO(pScreen)->zoomLocked = lock;
}
/*
@@ -199,121 +196,118 @@ xf86LockZoom(ScreenPtr pScreen, Bool lock)
Bool
xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
{
- ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
- ScreenPtr pCursorScreen;
- Bool Switched;
- int px, py, was_blocked;
- DeviceIntPtr dev, it;
+ ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+ ScreenPtr pCursorScreen;
+ Bool Switched;
+ int px, py, was_blocked;
+ DeviceIntPtr dev, it;
- if (!pScr->vtSema || !mode || !pScr->SwitchMode)
- return FALSE;
+ if (!pScr->vtSema || !mode || !pScr->SwitchMode)
+ return FALSE;
#ifdef XFreeXDGA
- if (DGAActive(pScr->scrnIndex))
- return FALSE;
+ if (DGAActive(pScr->scrnIndex))
+ return FALSE;
#endif
- if (mode == pScr->currentMode)
- return TRUE;
-
- if (mode->HDisplay > pScr->virtualX || mode->VDisplay > pScr->virtualY)
- return FALSE;
-
- /* Let's take an educated guess for which pointer to take here. And about as
- educated as it gets is to take the first pointer we find.
- */
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (IsPointerDevice(dev) && dev->spriteInfo->spriteOwner)
- break;
- }
-
- pCursorScreen = miPointerGetScreen(dev);
- if (pScreen == pCursorScreen)
- miPointerGetPosition(dev, &px, &py);
+ if (mode == pScr->currentMode)
+ return TRUE;
- was_blocked = xf86BlockSIGIO();
- Switched = (*pScr->SwitchMode)(pScr->scrnIndex, mode, 0);
- if (Switched) {
- pScr->currentMode = mode;
+ if (mode->HDisplay > pScr->virtualX || mode->VDisplay > pScr->virtualY)
+ return FALSE;
- /*
- * Adjust frame for new display size.
- * Frame is centered around cursor position if cursor is on same screen.
+ /* Let's take an educated guess for which pointer to take here. And about as
+ educated as it gets is to take the first pointer we find.
*/
- if (pScreen == pCursorScreen)
- pScr->frameX0 = px - (mode->HDisplay / 2) + 1;
- else
- pScr->frameX0 = (pScr->frameX0 + pScr->frameX1 + 1 - mode->HDisplay) / 2;
-
- if (pScr->frameX0 < 0)
- pScr->frameX0 = 0;
-
- pScr->frameX1 = pScr->frameX0 + mode->HDisplay - 1;
- if (pScr->frameX1 >= pScr->virtualX) {
- pScr->frameX0 = pScr->virtualX - mode->HDisplay;
- pScr->frameX1 = pScr->virtualX - 1;
+ for (dev = inputInfo.devices; dev; dev = dev->next) {
+ if (IsPointerDevice(dev) && dev->spriteInfo->spriteOwner)
+ break;
}
+ pCursorScreen = miPointerGetScreen(dev);
if (pScreen == pCursorScreen)
- pScr->frameY0 = py - (mode->VDisplay / 2) + 1;
- else
- pScr->frameY0 = (pScr->frameY0 + pScr->frameY1 + 1 - mode->VDisplay) / 2;
+ miPointerGetPosition(dev, &px, &py);
+
+ was_blocked = xf86BlockSIGIO();
+ Switched = (*pScr->SwitchMode) (pScr->scrnIndex, mode, 0);
+ if (Switched) {
+ pScr->currentMode = mode;
+
+ /*
+ * Adjust frame for new display size.
+ * Frame is centered around cursor position if cursor is on same screen.
+ */
+ if (pScreen == pCursorScreen)
+ pScr->frameX0 = px - (mode->HDisplay / 2) + 1;
+ else
+ pScr->frameX0 =
+ (pScr->frameX0 + pScr->frameX1 + 1 - mode->HDisplay) / 2;
+
+ if (pScr->frameX0 < 0)
+ pScr->frameX0 = 0;
+
+ pScr->frameX1 = pScr->frameX0 + mode->HDisplay - 1;
+ if (pScr->frameX1 >= pScr->virtualX) {
+ pScr->frameX0 = pScr->virtualX - mode->HDisplay;
+ pScr->frameX1 = pScr->virtualX - 1;
+ }
+
+ if (pScreen == pCursorScreen)
+ pScr->frameY0 = py - (mode->VDisplay / 2) + 1;
+ else
+ pScr->frameY0 =
+ (pScr->frameY0 + pScr->frameY1 + 1 - mode->VDisplay) / 2;
+
+ if (pScr->frameY0 < 0)
+ pScr->frameY0 = 0;
+
+ pScr->frameY1 = pScr->frameY0 + mode->VDisplay - 1;
+ if (pScr->frameY1 >= pScr->virtualY) {
+ pScr->frameY0 = pScr->virtualY - mode->VDisplay;
+ pScr->frameY1 = pScr->virtualY - 1;
+ }
+ }
+ xf86UnblockSIGIO(was_blocked);
- if (pScr->frameY0 < 0)
- pScr->frameY0 = 0;
+ if (pScr->AdjustFrame)
+ (*pScr->AdjustFrame) (pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0);
- pScr->frameY1 = pScr->frameY0 + mode->VDisplay - 1;
- if (pScr->frameY1 >= pScr->virtualY) {
- pScr->frameY0 = pScr->virtualY - mode->VDisplay;
- pScr->frameY1 = pScr->virtualY - 1;
+ /* The original code centered the frame around the cursor if possible.
+ * Since this is hard to achieve with multiple cursors, we do the following:
+ * - center around the first pointer
+ * - move all other pointers to the nearest edge on the screen (or leave
+ * them unmodified if they are within the boundaries).
+ */
+ if (pScreen == pCursorScreen) {
+ xf86WarpCursor(dev, pScreen, px, py);
+ }
+
+ for (it = inputInfo.devices; it; it = it->next) {
+ if (it == dev)
+ continue;
+
+ if (IsPointerDevice(it) && it->spriteInfo->spriteOwner) {
+ pCursorScreen = miPointerGetScreen(it);
+ if (pScreen == pCursorScreen) {
+ miPointerGetPosition(it, &px, &py);
+ if (px < pScr->frameX0)
+ px = pScr->frameX0;
+ else if (px > pScr->frameX1)
+ px = pScr->frameX1;
+
+ if (py < pScr->frameY0)
+ py = pScr->frameY0;
+ else if (py > pScr->frameY1)
+ py = pScr->frameY1;
+
+ xf86WarpCursor(it, pScreen, px, py);
+ }
+ }
}
- }
- xf86UnblockSIGIO(was_blocked);
-
- if (pScr->AdjustFrame)
- (*pScr->AdjustFrame)(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0);
-
- /* The original code centered the frame around the cursor if possible.
- * Since this is hard to achieve with multiple cursors, we do the following:
- * - center around the first pointer
- * - move all other pointers to the nearest edge on the screen (or leave
- * them unmodified if they are within the boundaries).
- */
- if (pScreen == pCursorScreen)
- {
- xf86WarpCursor(dev, pScreen, px, py);
- }
-
- for (it = inputInfo.devices; it; it = it->next)
- {
- if (it == dev)
- continue;
-
- if (IsPointerDevice(it) && it->spriteInfo->spriteOwner)
- {
- pCursorScreen = miPointerGetScreen(it);
- if (pScreen == pCursorScreen)
- {
- miPointerGetPosition(it, &px, &py);
- if (px < pScr->frameX0)
- px = pScr->frameX0;
- else if (px > pScr->frameX1)
- px = pScr->frameX1;
-
- if(py < pScr->frameY0)
- py = pScr->frameY0;
- else if(py > pScr->frameY1)
- py = pScr->frameY1;
-
- xf86WarpCursor(it, pScreen, px, py);
- }
- }
- }
-
- return Switched;
+
+ return Switched;
}
-
+
/*
* xf86ZoomViewport --
* Reinitialize the visual part of the screen for another mode.
@@ -322,31 +316,30 @@ xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
void
xf86ZoomViewport(ScreenPtr pScreen, int zoom)
{
- ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
- DisplayModePtr mode;
+ ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+ DisplayModePtr mode;
- if (pScr->zoomLocked || !(mode = pScr->currentMode))
- return;
+ if (pScr->zoomLocked || !(mode = pScr->currentMode))
+ return;
- do {
- if (zoom > 0)
- mode = mode->next;
- else
- mode = mode->prev;
- } while (mode != pScr->currentMode && !(mode->type & M_T_USERDEF));
+ do {
+ if (zoom > 0)
+ mode = mode->next;
+ else
+ mode = mode->prev;
+ } while (mode != pScr->currentMode && !(mode->type & M_T_USERDEF));
- (void)xf86SwitchMode(pScreen, mode);
+ (void) xf86SwitchMode(pScreen, mode);
}
-
static xf86EdgePtr
FindEdge(xf86EdgePtr edge, int val)
{
- while(edge && (edge->end <= val))
- edge = edge->next;
+ while (edge && (edge->end <= val))
+ edge = edge->next;
- if(edge && (edge->start <= val))
- return edge;
+ if (edge && (edge->start <= val))
+ return edge;
return NULL;
}
@@ -362,89 +355,98 @@ xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
xf86EdgePtr edge;
int tmp;
- if(screenInfo.numScreens == 1)
- return FALSE;
+ if (screenInfo.numScreens == 1)
+ return FALSE;
- if(*x < 0) {
+ if (*x < 0) {
tmp = *y;
- if(tmp < 0) tmp = 0;
- if(tmp >= (*pScreen)->height) tmp = (*pScreen)->height - 1;
-
- if((edge = xf86ScreenLayout[(*pScreen)->myNum].left))
- edge = FindEdge(edge, tmp);
-
- if(!edge) *x = 0;
- else {
- *x += edge->offset.x;
- *y += edge->offset.y;
- *pScreen = xf86Screens[edge->screen]->pScreen;
- }
+ if (tmp < 0)
+ tmp = 0;
+ if (tmp >= (*pScreen)->height)
+ tmp = (*pScreen)->height - 1;
+
+ if ((edge = xf86ScreenLayout[(*pScreen)->myNum].left))
+ edge = FindEdge(edge, tmp);
+
+ if (!edge)
+ *x = 0;
+ else {
+ *x += edge->offset.x;
+ *y += edge->offset.y;
+ *pScreen = xf86Screens[edge->screen]->pScreen;
+ }
}
- if(*x >= (*pScreen)->width) {
+ if (*x >= (*pScreen)->width) {
tmp = *y;
- if(tmp < 0) tmp = 0;
- if(tmp >= (*pScreen)->height) tmp = (*pScreen)->height - 1;
-
- if((edge = xf86ScreenLayout[(*pScreen)->myNum].right))
- edge = FindEdge(edge, tmp);
-
- if(!edge) *x = (*pScreen)->width - 1;
- else {
- *x += edge->offset.x;
- *y += edge->offset.y;
- *pScreen = xf86Screens[edge->screen]->pScreen;
- }
+ if (tmp < 0)
+ tmp = 0;
+ if (tmp >= (*pScreen)->height)
+ tmp = (*pScreen)->height - 1;
+
+ if ((edge = xf86ScreenLayout[(*pScreen)->myNum].right))
+ edge = FindEdge(edge, tmp);
+
+ if (!edge)
+ *x = (*pScreen)->width - 1;
+ else {
+ *x += edge->offset.x;
+ *y += edge->offset.y;
+ *pScreen = xf86Screens[edge->screen]->pScreen;
+ }
}
- if(*y < 0) {
+ if (*y < 0) {
tmp = *x;
- if(tmp < 0) tmp = 0;
- if(tmp >= (*pScreen)->width) tmp = (*pScreen)->width - 1;
-
- if((edge = xf86ScreenLayout[(*pScreen)->myNum].up))
- edge = FindEdge(edge, tmp);
-
- if(!edge) *y = 0;
- else {
- *x += edge->offset.x;
- *y += edge->offset.y;
- *pScreen = xf86Screens[edge->screen]->pScreen;
- }
+ if (tmp < 0)
+ tmp = 0;
+ if (tmp >= (*pScreen)->width)
+ tmp = (*pScreen)->width - 1;
+
+ if ((edge = xf86ScreenLayout[(*pScreen)->myNum].up))
+ edge = FindEdge(edge, tmp);
+
+ if (!edge)
+ *y = 0;
+ else {
+ *x += edge->offset.x;
+ *y += edge->offset.y;
+ *pScreen = xf86Screens[edge->screen]->pScreen;
+ }
}
- if(*y >= (*pScreen)->height) {
+ if (*y >= (*pScreen)->height) {
tmp = *x;
- if(tmp < 0) tmp = 0;
- if(tmp >= (*pScreen)->width) tmp = (*pScreen)->width - 1;
-
- if((edge = xf86ScreenLayout[(*pScreen)->myNum].down))
- edge = FindEdge(edge, tmp);
-
- if(!edge) *y = (*pScreen)->height - 1;
- else {
- *x += edge->offset.x;
- *y += edge->offset.y;
- (*pScreen) = xf86Screens[edge->screen]->pScreen;
- }
+ if (tmp < 0)
+ tmp = 0;
+ if (tmp >= (*pScreen)->width)
+ tmp = (*pScreen)->width - 1;
+
+ if ((edge = xf86ScreenLayout[(*pScreen)->myNum].down))
+ edge = FindEdge(edge, tmp);
+
+ if (!edge)
+ *y = (*pScreen)->height - 1;
+ else {
+ *x += edge->offset.x;
+ *y += edge->offset.y;
+ (*pScreen) = xf86Screens[edge->screen]->pScreen;
+ }
}
-
#if 0
/* This presents problems for overlapping screens when
- HardEdges is used. Have to think about the logic more */
- if((*x < 0) || (*x >= (*pScreen)->width) ||
- (*y < 0) || (*y >= (*pScreen)->height)) {
- /* We may have crossed more than one screen */
- xf86CursorOffScreen(pScreen, x, y);
+ HardEdges is used. Have to think about the logic more */
+ if ((*x < 0) || (*x >= (*pScreen)->width) ||
+ (*y < 0) || (*y >= (*pScreen)->height)) {
+ /* We may have crossed more than one screen */
+ xf86CursorOffScreen(pScreen, x, y);
}
#endif
return TRUE;
}
-
-
/*
* xf86CrossScreen --
* Switch to another screen
@@ -454,11 +456,10 @@ xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
*/
static void
-xf86CrossScreen (ScreenPtr pScreen, Bool entering)
+xf86CrossScreen(ScreenPtr pScreen, Bool entering)
{
}
-
/*
* xf86WarpCursor --
* Warp possible to another screen
@@ -466,88 +467,88 @@ xf86CrossScreen (ScreenPtr pScreen, Bool entering)
/* ARGSUSED */
static void
-xf86WarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
+xf86WarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
{
- int sigstate;
- sigstate = xf86BlockSIGIO ();
+ int sigstate;
+
+ sigstate = xf86BlockSIGIO();
miPointerWarpCursor(pDev, pScreen, x, y);
xf86Info.currentScreen = pScreen;
- xf86UnblockSIGIO (sigstate);
+ xf86UnblockSIGIO(sigstate);
}
-
void *
xf86GetPointerScreenFuncs(void)
{
- return (void *)&xf86PointerScreenFuncs;
+ return (void *) &xf86PointerScreenFuncs;
}
-
static xf86EdgePtr
-AddEdge(
- xf86EdgePtr edge,
- short min,
- short max,
- short dx,
- short dy,
- short screen
-){
- xf86EdgePtr pEdge = edge, pPrev = NULL, pNew;
-
- while(1) {
- while(pEdge && (min >= pEdge->end)) {
- pPrev = pEdge;
- pEdge = pEdge->next;
- }
-
- if(!pEdge) {
- if(!(pNew = malloc(sizeof(xf86EdgeRec))))
- break;
-
- pNew->screen = screen;
- pNew->start = min;
- pNew->end = max;
- pNew->offset.x = dx;
- pNew->offset.y = dy;
- pNew->next = NULL;
-
- if(pPrev)
- pPrev->next = pNew;
- else
- edge = pNew;
-
- break;
- } else if (min < pEdge->start) {
- if(!(pNew = malloc(sizeof(xf86EdgeRec))))
- break;
-
- pNew->screen = screen;
- pNew->start = min;
- pNew->offset.x = dx;
- pNew->offset.y = dy;
- pNew->next = pEdge;
-
- if(pPrev) pPrev->next = pNew;
- else edge = pNew;
-
- if(max <= pEdge->start) {
- pNew->end = max;
- break;
- } else {
- pNew->end = pEdge->start;
- min = pEdge->end;
- }
- } else
- min = pEdge->end;
-
- pPrev = pEdge;
- pEdge = pEdge->next;
-
- if(max <= min) break;
- }
-
- return edge;
+AddEdge(xf86EdgePtr edge,
+ short min, short max, short dx, short dy, short screen)
+{
+ xf86EdgePtr pEdge = edge, pPrev = NULL, pNew;
+
+ while (1) {
+ while (pEdge && (min >= pEdge->end)) {
+ pPrev = pEdge;
+ pEdge = pEdge->next;
+ }
+
+ if (!pEdge) {
+ if (!(pNew = malloc(sizeof(xf86EdgeRec))))
+ break;
+
+ pNew->screen = screen;
+ pNew->start = min;
+ pNew->end = max;
+ pNew->offset.x = dx;
+ pNew->offset.y = dy;
+ pNew->next = NULL;
+
+ if (pPrev)
+ pPrev->next = pNew;
+ else
+ edge = pNew;
+
+ break;
+ }
+ else if (min < pEdge->start) {
+ if (!(pNew = malloc(sizeof(xf86EdgeRec))))
+ break;
+
+ pNew->screen = screen;
+ pNew->start = min;
+ pNew->offset.x = dx;
+ pNew->offset.y = dy;
+ pNew->next = pEdge;
+
+ if (pPrev)
+ pPrev->next = pNew;
+ else
+ edge = pNew;
+
+ if (max <= pEdge->start) {
+ pNew->end = max;
+ break;
+ }
+ else {
+ pNew->end = pEdge->start;
+ min = pEdge->end;
+ }
+ }
+ else
+ min = pEdge->end;
+
+ pPrev = pEdge;
+ pEdge = pEdge->next;
+
+ if (max <= min)
+ break;
+ }
+
+ return edge;
}
static void
@@ -556,19 +557,20 @@ FillOutEdge(xf86EdgePtr pEdge, int limit)
xf86EdgePtr pNext;
int diff;
- if(pEdge->start > 0) pEdge->start = 0;
+ if (pEdge->start > 0)
+ pEdge->start = 0;
- while((pNext = pEdge->next)) {
- diff = pNext->start - pEdge->end;
- if(diff > 0) {
- pEdge->end += diff >> 1;
- pNext->start -= diff - (diff >> 1);
- }
- pEdge = pNext;
+ while ((pNext = pEdge->next)) {
+ diff = pNext->start - pEdge->end;
+ if (diff > 0) {
+ pEdge->end += diff >> 1;
+ pNext->start -= diff - (diff >> 1);
+ }
+ pEdge = pNext;
}
- if(pEdge->end < limit)
- pEdge->end = limit;
+ if (pEdge->end < limit)
+ pEdge->end = limit;
}
/*
@@ -591,252 +593,269 @@ xf86InitOrigins(void)
HardEdges = FALSE;
memset(xf86ScreenLayout, 0, MAXSCREENS * sizeof(xf86ScreenLayoutRec));
-
+
screensLeft = prevScreensLeft = (1 << xf86NumScreens) - 1;
- while(1) {
- for(mask = screensLeft, i = 0; mask; mask >>= 1, i++) {
- if(!(mask & 1L)) continue;
-
- screen = &xf86ConfigLayout.screens[i];
-
- if (screen->refscreen != NULL &&
- screen->refscreen->screennum >= xf86NumScreens) {
- screensLeft &= ~(1 << i);
- xf86Msg(X_WARNING, "Not including screen \"%s\" in origins calculation.\n",
- screen->screen->id);
- continue;
- }
-
- pScreen = xf86Screens[i]->pScreen;
- switch(screen->where) {
- case PosObsolete:
- OldStyleConfig = TRUE;
- pLayout = &xf86ScreenLayout[i];
- /* force edge lists */
- if(screen->left) {
- ref = screen->left->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- pLayout->left = AddEdge(pLayout->left,
- 0, pScreen->height,
- xf86Screens[ref]->pScreen->width, 0, ref);
- }
- if(screen->right) {
- ref = screen->right->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- pLayout->right = AddEdge(pLayout->right,
- 0, pScreen->height, -pScreen->width, 0, ref);
- }
- if(screen->top) {
- ref = screen->top->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- pLayout->up = AddEdge(pLayout->up,
- 0, pScreen->width,
- 0, xf86Screens[ref]->pScreen->height, ref);
- }
- if(screen->bottom) {
- ref = screen->bottom->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- pLayout->down = AddEdge(pLayout->down,
- 0, pScreen->width, 0, -pScreen->height, ref);
- }
- /* we could also try to place it based on those
- relative locations if we wanted to */
- screen->x = screen->y = 0;
- /* FALLTHROUGH */
- case PosAbsolute:
- pScreen->x = screen->x;
- pScreen->y = screen->y;
- screensLeft &= ~(1 << i);
- break;
- case PosRelative:
- ref = screen->refscreen->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- if(screensLeft & (1 << ref)) break;
- refScreen = xf86Screens[ref]->pScreen;
- pScreen->x = refScreen->x + screen->x;
- pScreen->y = refScreen->y + screen->y;
- screensLeft &= ~(1 << i);
- break;
- case PosRightOf:
- ref = screen->refscreen->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- if(screensLeft & (1 << ref)) break;
- refScreen = xf86Screens[ref]->pScreen;
- pScreen->x = refScreen->x + refScreen->width;
- pScreen->y = refScreen->y;
- screensLeft &= ~(1 << i);
- break;
- case PosLeftOf:
- ref = screen->refscreen->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- if(screensLeft & (1 << ref)) break;
- refScreen = xf86Screens[ref]->pScreen;
- pScreen->x = refScreen->x - pScreen->width;
- pScreen->y = refScreen->y;
- screensLeft &= ~(1 << i);
- break;
- case PosBelow:
- ref = screen->refscreen->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- if(screensLeft & (1 << ref)) break;
- refScreen = xf86Screens[ref]->pScreen;
- pScreen->x = refScreen->x;
- pScreen->y = refScreen->y + refScreen->height;
- screensLeft &= ~(1 << i);
- break;
- case PosAbove:
- ref = screen->refscreen->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- if(screensLeft & (1 << ref)) break;
- refScreen = xf86Screens[ref]->pScreen;
- pScreen->x = refScreen->x;
- pScreen->y = refScreen->y - pScreen->height;
- screensLeft &= ~(1 << i);
- break;
- default:
- ErrorF("Illegal placement keyword in Layout!\n");
- break;
- }
-
- }
-
- if(!screensLeft) break;
-
- if(screensLeft == prevScreensLeft) {
- /* All the remaining screens are referencing each other.
- Assign a value to one of them and go through again */
- i = 0;
- while(!((1 << i) & screensLeft)){ i++; }
-
- ref = xf86ConfigLayout.screens[i].refscreen->screennum;
- xf86Screens[ref]->pScreen->x = xf86Screens[ref]->pScreen->y = 0;
- screensLeft &= ~(1 << ref);
- }
-
- prevScreensLeft = screensLeft;
+ while (1) {
+ for (mask = screensLeft, i = 0; mask; mask >>= 1, i++) {
+ if (!(mask & 1L))
+ continue;
+
+ screen = &xf86ConfigLayout.screens[i];
+
+ if (screen->refscreen != NULL &&
+ screen->refscreen->screennum >= xf86NumScreens) {
+ screensLeft &= ~(1 << i);
+ xf86Msg(X_WARNING,
+ "Not including screen \"%s\" in origins calculation.\n",
+ screen->screen->id);
+ continue;
+ }
+
+ pScreen = xf86Screens[i]->pScreen;
+ switch (screen->where) {
+ case PosObsolete:
+ OldStyleConfig = TRUE;
+ pLayout = &xf86ScreenLayout[i];
+ /* force edge lists */
+ if (screen->left) {
+ ref = screen->left->screennum;
+ if (!xf86Screens[ref] || !xf86Screens[ref]->pScreen) {
+ ErrorF("Referenced uninitialized screen in Layout!\n");
+ break;
+ }
+ pLayout->left = AddEdge(pLayout->left,
+ 0, pScreen->height,
+ xf86Screens[ref]->pScreen->width, 0,
+ ref);
+ }
+ if (screen->right) {
+ ref = screen->right->screennum;
+ if (!xf86Screens[ref] || !xf86Screens[ref]->pScreen) {
+ ErrorF("Referenced uninitialized screen in Layout!\n");
+ break;
+ }
+ pLayout->right = AddEdge(pLayout->right,
+ 0, pScreen->height,
+ -pScreen->width, 0, ref);
+ }
+ if (screen->top) {
+ ref = screen->top->screennum;
+ if (!xf86Screens[ref] || !xf86Screens[ref]->pScreen) {
+ ErrorF("Referenced uninitialized screen in Layout!\n");
+ break;
+ }
+ pLayout->up = AddEdge(pLayout->up,
+ 0, pScreen->width,
+ 0, xf86Screens[ref]->pScreen->height,
+ ref);
+ }
+ if (screen->bottom) {
+ ref = screen->bottom->screennum;
+ if (!xf86Screens[ref] || !xf86Screens[ref]->pScreen) {
+ ErrorF("Referenced uninitialized screen in Layout!\n");
+ break;
+ }
+ pLayout->down = AddEdge(pLayout->down,
+ 0, pScreen->width, 0,
+ -pScreen->height, ref);
+ }
+ /* we could also try to place it based on those
+ relative locations if we wanted to */
+ screen->x = screen->y = 0;
+ /* FALLTHROUGH */
+ case PosAbsolute:
+ pScreen->x = screen->x;
+ pScreen->y = screen->y;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosRelative:
+ ref = screen->refscreen->screennum;
+ if (!xf86Screens[ref] || !xf86Screens[ref]->pScreen) {
+ ErrorF("Referenced uninitialized screen in Layout!\n");
+ break;
+ }
+ if (screensLeft & (1 << ref))
+ break;
+ refScreen = xf86Screens[ref]->pScreen;
+ pScreen->x = refScreen->x + screen->x;
+ pScreen->y = refScreen->y + screen->y;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosRightOf:
+ ref = screen->refscreen->screennum;
+ if (!xf86Screens[ref] || !xf86Screens[ref]->pScreen) {
+ ErrorF("Referenced uninitialized screen in Layout!\n");
+ break;
+ }
+ if (screensLeft & (1 << ref))
+ break;
+ refScreen = xf86Screens[ref]->pScreen;
+ pScreen->x = refScreen->x + refScreen->width;
+ pScreen->y = refScreen->y;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosLeftOf:
+ ref = screen->refscreen->screennum;
+ if (!xf86Screens[ref] || !xf86Screens[ref]->pScreen) {
+ ErrorF("Referenced uninitialized screen in Layout!\n");
+ break;
+ }
+ if (screensLeft & (1 << ref))
+ break;
+ refScreen = xf86Screens[ref]->pScreen;
+ pScreen->x = refScreen->x - pScreen->width;
+ pScreen->y = refScreen->y;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosBelow:
+ ref = screen->refscreen->screennum;
+ if (!xf86Screens[ref] || !xf86Screens[ref]->pScreen) {
+ ErrorF("Referenced uninitialized screen in Layout!\n");
+ break;
+ }
+ if (screensLeft & (1 << ref))
+ break;
+ refScreen = xf86Screens[ref]->pScreen;
+ pScreen->x = refScreen->x;
+ pScreen->y = refScreen->y + refScreen->height;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosAbove:
+ ref = screen->refscreen->screennum;
+ if (!xf86Screens[ref] || !xf86Screens[ref]->pScreen) {
+ ErrorF("Referenced uninitialized screen in Layout!\n");
+ break;
+ }
+ if (screensLeft & (1 << ref))
+ break;
+ refScreen = xf86Screens[ref]->pScreen;
+ pScreen->x = refScreen->x;
+ pScreen->y = refScreen->y - pScreen->height;
+ screensLeft &= ~(1 << i);
+ break;
+ default:
+ ErrorF("Illegal placement keyword in Layout!\n");
+ break;
+ }
+
+ }
+
+ if (!screensLeft)
+ break;
+
+ if (screensLeft == prevScreensLeft) {
+ /* All the remaining screens are referencing each other.
+ Assign a value to one of them and go through again */
+ i = 0;
+ while (!((1 << i) & screensLeft)) {
+ i++;
+ }
+
+ ref = xf86ConfigLayout.screens[i].refscreen->screennum;
+ xf86Screens[ref]->pScreen->x = xf86Screens[ref]->pScreen->y = 0;
+ screensLeft &= ~(1 << ref);
+ }
+
+ prevScreensLeft = screensLeft;
}
/* justify the topmost and leftmost to (0,0) */
minX = xf86Screens[0]->pScreen->x;
minY = xf86Screens[0]->pScreen->y;
- for(i = 1; i < xf86NumScreens; i++) {
- if(xf86Screens[i]->pScreen->x < minX)
- minX = xf86Screens[i]->pScreen->x;
- if(xf86Screens[i]->pScreen->y < minY)
- minY = xf86Screens[i]->pScreen->y;
+ for (i = 1; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->pScreen->x < minX)
+ minX = xf86Screens[i]->pScreen->x;
+ if (xf86Screens[i]->pScreen->y < minY)
+ minY = xf86Screens[i]->pScreen->y;
}
if (minX || minY) {
- for(i = 0; i < xf86NumScreens; i++) {
- xf86Screens[i]->pScreen->x -= minX;
- xf86Screens[i]->pScreen->y -= minY;
- }
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86Screens[i]->pScreen->x -= minX;
+ xf86Screens[i]->pScreen->y -= minY;
+ }
}
-
/* Create the edge lists */
- if(!OldStyleConfig) {
- for(i = 0; i < xf86NumScreens; i++) {
- pLayout = &xf86ScreenLayout[i];
-
- pScreen = xf86Screens[i]->pScreen;
-
- left = pScreen->x;
- right = left + pScreen->width;
- top = pScreen->y;
- bottom = top + pScreen->height;
-
- for(j = 0; j < xf86NumScreens; j++) {
- if(i == j) continue;
-
- refScreen = xf86Screens[j]->pScreen;
-
- x1 = refScreen->x;
- x2 = x1 + refScreen->width;
- y1 = refScreen->y;
- y2 = y1 + refScreen->height;
-
- if((bottom > y1) && (top < y2)) {
- min = y1 - top;
- if(min < 0) min = 0;
- max = pScreen->height - (bottom - y2);
- if(max > pScreen->height) max = pScreen->height;
-
- if(((left - 1) >= x1) && ((left - 1) < x2))
- pLayout->left = AddEdge(pLayout->left, min, max,
- pScreen->x - refScreen->x,
- pScreen->y - refScreen->y, j);
-
- if((right >= x1) && (right < x2))
- pLayout->right = AddEdge(pLayout->right, min, max,
- pScreen->x - refScreen->x,
- pScreen->y - refScreen->y, j);
- }
-
-
- if((left < x2) && (right > x1)) {
- min = x1 - left;
- if(min < 0) min = 0;
- max = pScreen->width - (right - x2);
- if(max > pScreen->width) max = pScreen->width;
-
- if(((top - 1) >= y1) && ((top - 1) < y2))
- pLayout->up = AddEdge(pLayout->up, min, max,
- pScreen->x - refScreen->x,
- pScreen->y - refScreen->y, j);
-
- if((bottom >= y1) && (bottom < y2))
- pLayout->down = AddEdge(pLayout->down, min, max,
- pScreen->x - refScreen->x,
- pScreen->y - refScreen->y, j);
- }
- }
- }
+ if (!OldStyleConfig) {
+ for (i = 0; i < xf86NumScreens; i++) {
+ pLayout = &xf86ScreenLayout[i];
+
+ pScreen = xf86Screens[i]->pScreen;
+
+ left = pScreen->x;
+ right = left + pScreen->width;
+ top = pScreen->y;
+ bottom = top + pScreen->height;
+
+ for (j = 0; j < xf86NumScreens; j++) {
+ if (i == j)
+ continue;
+
+ refScreen = xf86Screens[j]->pScreen;
+
+ x1 = refScreen->x;
+ x2 = x1 + refScreen->width;
+ y1 = refScreen->y;
+ y2 = y1 + refScreen->height;
+
+ if ((bottom > y1) && (top < y2)) {
+ min = y1 - top;
+ if (min < 0)
+ min = 0;
+ max = pScreen->height - (bottom - y2);
+ if (max > pScreen->height)
+ max = pScreen->height;
+
+ if (((left - 1) >= x1) && ((left - 1) < x2))
+ pLayout->left = AddEdge(pLayout->left, min, max,
+ pScreen->x - refScreen->x,
+ pScreen->y - refScreen->y, j);
+
+ if ((right >= x1) && (right < x2))
+ pLayout->right = AddEdge(pLayout->right, min, max,
+ pScreen->x - refScreen->x,
+ pScreen->y - refScreen->y, j);
+ }
+
+ if ((left < x2) && (right > x1)) {
+ min = x1 - left;
+ if (min < 0)
+ min = 0;
+ max = pScreen->width - (right - x2);
+ if (max > pScreen->width)
+ max = pScreen->width;
+
+ if (((top - 1) >= y1) && ((top - 1) < y2))
+ pLayout->up = AddEdge(pLayout->up, min, max,
+ pScreen->x - refScreen->x,
+ pScreen->y - refScreen->y, j);
+
+ if ((bottom >= y1) && (bottom < y2))
+ pLayout->down = AddEdge(pLayout->down, min, max,
+ pScreen->x - refScreen->x,
+ pScreen->y - refScreen->y, j);
+ }
+ }
+ }
}
- if(!HardEdges && !OldStyleConfig) {
- for(i = 0; i < xf86NumScreens; i++) {
- pLayout = &xf86ScreenLayout[i];
- pScreen = xf86Screens[i]->pScreen;
- if(pLayout->left)
- FillOutEdge(pLayout->left, pScreen->height);
- if(pLayout->right)
- FillOutEdge(pLayout->right, pScreen->height);
- if(pLayout->up)
- FillOutEdge(pLayout->up, pScreen->width);
- if(pLayout->down)
- FillOutEdge(pLayout->down, pScreen->width);
- }
+ if (!HardEdges && !OldStyleConfig) {
+ for (i = 0; i < xf86NumScreens; i++) {
+ pLayout = &xf86ScreenLayout[i];
+ pScreen = xf86Screens[i]->pScreen;
+ if (pLayout->left)
+ FillOutEdge(pLayout->left, pScreen->height);
+ if (pLayout->right)
+ FillOutEdge(pLayout->right, pScreen->height);
+ if (pLayout->up)
+ FillOutEdge(pLayout->up, pScreen->width);
+ if (pLayout->down)
+ FillOutEdge(pLayout->down, pScreen->width);
+ }
}
update_desktop_dimensions();
@@ -848,15 +867,14 @@ xf86ReconfigureLayout(void)
int i;
for (i = 0; i < MAXSCREENS; i++) {
- xf86ScreenLayoutPtr sl = &xf86ScreenLayout[i];
- /* we don't have to zero these, xf86InitOrigins() takes care of that */
- free(sl->left);
- free(sl->right);
- free(sl->up);
- free(sl->down);
+ xf86ScreenLayoutPtr sl = &xf86ScreenLayout[i];
+
+ /* we don't have to zero these, xf86InitOrigins() takes care of that */
+ free(sl->left);
+ free(sl->right);
+ free(sl->up);
+ free(sl->down);
}
xf86InitOrigins();
}
-
-
diff --git a/xorg-server/hw/xfree86/common/xf86DGA.c b/xorg-server/hw/xfree86/common/xf86DGA.c
index 0c958cdf3..316978cfa 100644
--- a/xorg-server/hw/xfree86/common/xf86DGA.c
+++ b/xorg-server/hw/xfree86/common/xf86DGA.c
@@ -52,6 +52,7 @@
#include "mi.h"
static DevPrivateKeyRec DGAScreenKeyRec;
+
#define DGAScreenKeyRegistered dixPrivateKeyRegistered(&DGAScreenKeyRec)
static Bool mieq_installed;
@@ -63,86 +64,76 @@ static void DGAHandleEvent(int screen_num, InternalEvent *event,
DeviceIntPtr device);
static void
-DGACopyModeInfo(
- DGAModePtr mode,
- XDGAModePtr xmode
-);
+ DGACopyModeInfo(DGAModePtr mode, XDGAModePtr xmode);
int *XDGAEventBase = NULL;
#define DGA_GET_SCREEN_PRIV(pScreen) ((DGAScreenPtr) \
dixLookupPrivate(&(pScreen)->devPrivates, &DGAScreenKeyRec))
-
-typedef struct _FakedVisualList{
- Bool free;
- VisualPtr pVisual;
- struct _FakedVisualList *next;
+typedef struct _FakedVisualList {
+ Bool free;
+ VisualPtr pVisual;
+ struct _FakedVisualList *next;
} FakedVisualList;
-
typedef struct {
- ScrnInfoPtr pScrn;
- int numModes;
- DGAModePtr modes;
- CloseScreenProcPtr CloseScreen;
- DestroyColormapProcPtr DestroyColormap;
- InstallColormapProcPtr InstallColormap;
- UninstallColormapProcPtr UninstallColormap;
- DGADevicePtr current;
- DGAFunctionPtr funcs;
- int input;
- ClientPtr client;
- int pixmapMode;
- FakedVisualList *fakedVisuals;
- ColormapPtr dgaColormap;
- ColormapPtr savedColormap;
- Bool grabMouse;
- Bool grabKeyboard;
+ ScrnInfoPtr pScrn;
+ int numModes;
+ DGAModePtr modes;
+ CloseScreenProcPtr CloseScreen;
+ DestroyColormapProcPtr DestroyColormap;
+ InstallColormapProcPtr InstallColormap;
+ UninstallColormapProcPtr UninstallColormap;
+ DGADevicePtr current;
+ DGAFunctionPtr funcs;
+ int input;
+ ClientPtr client;
+ int pixmapMode;
+ FakedVisualList *fakedVisuals;
+ ColormapPtr dgaColormap;
+ ColormapPtr savedColormap;
+ Bool grabMouse;
+ Bool grabKeyboard;
} DGAScreenRec, *DGAScreenPtr;
Bool
-DGAInit(
- ScreenPtr pScreen,
- DGAFunctionPtr funcs,
- DGAModePtr modes,
- int num
-){
+DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs, DGAModePtr modes, int num)
+{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
DGAScreenPtr pScreenPriv;
int i;
- if(!funcs || !funcs->SetMode || !funcs->OpenFramebuffer)
- return FALSE;
+ if (!funcs || !funcs->SetMode || !funcs->OpenFramebuffer)
+ return FALSE;
- if(!modes || num <= 0)
- return FALSE;
+ if (!modes || num <= 0)
+ return FALSE;
if (!dixRegisterPrivateKey(&DGAScreenKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
+ return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
- if (!pScreenPriv)
- {
- if(!(pScreenPriv = (DGAScreenPtr)malloc(sizeof(DGAScreenRec))))
- return FALSE;
- dixSetPrivate(&pScreen->devPrivates, &DGAScreenKeyRec, pScreenPriv);
- pScreenPriv->CloseScreen = pScreen->CloseScreen;
- pScreen->CloseScreen = DGACloseScreen;
- pScreenPriv->DestroyColormap = pScreen->DestroyColormap;
- pScreen->DestroyColormap = DGADestroyColormap;
- pScreenPriv->InstallColormap = pScreen->InstallColormap;
- pScreen->InstallColormap = DGAInstallColormap;
- pScreenPriv->UninstallColormap = pScreen->UninstallColormap;
- pScreen->UninstallColormap = DGAUninstallColormap;
+ if (!pScreenPriv) {
+ if (!(pScreenPriv = (DGAScreenPtr) malloc(sizeof(DGAScreenRec))))
+ return FALSE;
+ dixSetPrivate(&pScreen->devPrivates, &DGAScreenKeyRec, pScreenPriv);
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = DGACloseScreen;
+ pScreenPriv->DestroyColormap = pScreen->DestroyColormap;
+ pScreen->DestroyColormap = DGADestroyColormap;
+ pScreenPriv->InstallColormap = pScreen->InstallColormap;
+ pScreen->InstallColormap = DGAInstallColormap;
+ pScreenPriv->UninstallColormap = pScreen->UninstallColormap;
+ pScreen->UninstallColormap = DGAUninstallColormap;
}
pScreenPriv->pScrn = pScrn;
pScreenPriv->numModes = num;
pScreenPriv->modes = modes;
- pScreenPriv->current = NULL;
-
+ pScreenPriv->current = NULL;
+
pScreenPriv->funcs = funcs;
pScreenPriv->input = 0;
pScreenPriv->client = NULL;
@@ -151,14 +142,14 @@ DGAInit(
pScreenPriv->savedColormap = NULL;
pScreenPriv->grabMouse = FALSE;
pScreenPriv->grabKeyboard = FALSE;
-
- for(i = 0; i < num; i++)
- modes[i].num = i + 1;
+
+ for (i = 0; i < num; i++)
+ modes[i].num = i + 1;
#ifdef PANORAMIX
- if(!noPanoramiXExtension)
- for(i = 0; i < num; i++)
- modes[i].flags &= ~DGA_PIXMAP_AVAILABLE;
+ if (!noPanoramiXExtension)
+ for (i = 0; i < num; i++)
+ modes[i].flags &= ~DGA_PIXMAP_AVAILABLE;
#endif
return TRUE;
@@ -169,51 +160,48 @@ DGAInit(
*/
Bool
-DGAReInitModes(
- ScreenPtr pScreen,
- DGAModePtr modes,
- int num
-){
+DGAReInitModes(ScreenPtr pScreen, DGAModePtr modes, int num)
+{
DGAScreenPtr pScreenPriv;
int i;
/* No DGA? Ignore call (but don't make it look like it failed) */
- if(!DGAScreenKeyRegistered)
- return TRUE;
-
+ if (!DGAScreenKeyRegistered)
+ return TRUE;
+
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
/* Same as above */
- if(!pScreenPriv)
- return TRUE;
+ if (!pScreenPriv)
+ return TRUE;
/* Can't do this while DGA is active */
- if(pScreenPriv->current)
- return FALSE;
+ if (pScreenPriv->current)
+ return FALSE;
/* Quick sanity check */
- if(!num)
- modes = NULL;
- else if(!modes)
- num = 0;
+ if (!num)
+ modes = NULL;
+ else if (!modes)
+ num = 0;
pScreenPriv->numModes = num;
pScreenPriv->modes = modes;
/* This practically disables DGA. So be it. */
- if(!num)
- return TRUE;
+ if (!num)
+ return TRUE;
- for(i = 0; i < num; i++)
- modes[i].num = i + 1;
+ for (i = 0; i < num; i++)
+ modes[i].num = i + 1;
#ifdef PANORAMIX
- if(!noPanoramiXExtension)
- for(i = 0; i < num; i++)
- modes[i].flags &= ~DGA_PIXMAP_AVAILABLE;
+ if (!noPanoramiXExtension)
+ for (i = 0; i < num; i++)
+ modes[i].flags &= ~DGA_PIXMAP_AVAILABLE;
#endif
- return TRUE;
+ return TRUE;
}
static void
@@ -222,346 +210,346 @@ FreeMarkedVisuals(ScreenPtr pScreen)
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
FakedVisualList *prev, *curr, *tmp;
- if(!pScreenPriv->fakedVisuals)
- return;
+ if (!pScreenPriv->fakedVisuals)
+ return;
prev = NULL;
curr = pScreenPriv->fakedVisuals;
- while(curr) {
- if(curr->free) {
- tmp = curr;
- curr = curr->next;
- if(prev)
- prev->next = curr;
- else
- pScreenPriv->fakedVisuals = curr;
- free(tmp->pVisual);
- free(tmp);
- } else {
- prev = curr;
- curr = curr->next;
- }
+ while (curr) {
+ if (curr->free) {
+ tmp = curr;
+ curr = curr->next;
+ if (prev)
+ prev->next = curr;
+ else
+ pScreenPriv->fakedVisuals = curr;
+ free(tmp->pVisual);
+ free(tmp);
+ }
+ else {
+ prev = curr;
+ curr = curr->next;
+ }
}
}
-static Bool
+static Bool
DGACloseScreen(int i, ScreenPtr pScreen)
{
- DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
- if (mieq_installed) {
- mieqSetHandler(ET_DGAEvent, NULL);
- mieq_installed = FALSE;
- }
+ if (mieq_installed) {
+ mieqSetHandler(ET_DGAEvent, NULL);
+ mieq_installed = FALSE;
+ }
- FreeMarkedVisuals(pScreen);
+ FreeMarkedVisuals(pScreen);
- pScreen->CloseScreen = pScreenPriv->CloseScreen;
- pScreen->DestroyColormap = pScreenPriv->DestroyColormap;
- pScreen->InstallColormap = pScreenPriv->InstallColormap;
- pScreen->UninstallColormap = pScreenPriv->UninstallColormap;
+ pScreen->CloseScreen = pScreenPriv->CloseScreen;
+ pScreen->DestroyColormap = pScreenPriv->DestroyColormap;
+ pScreen->InstallColormap = pScreenPriv->InstallColormap;
+ pScreen->UninstallColormap = pScreenPriv->UninstallColormap;
- /* DGAShutdown() should have ensured that no DGA
- screen were active by here */
+ /* DGAShutdown() should have ensured that no DGA
+ screen were active by here */
- free(pScreenPriv);
+ free(pScreenPriv);
- return((*pScreen->CloseScreen)(i, pScreen));
+ return ((*pScreen->CloseScreen) (i, pScreen));
}
-
-static void
+static void
DGADestroyColormap(ColormapPtr pmap)
{
- ScreenPtr pScreen = pmap->pScreen;
- DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
- VisualPtr pVisual = pmap->pVisual;
-
- if(pScreenPriv->fakedVisuals) {
- FakedVisualList *curr = pScreenPriv->fakedVisuals;
-
- while(curr) {
- if(curr->pVisual == pVisual) {
- /* We can't get rid of them yet since FreeColormap
- still needs the pVisual during the cleanup */
- curr->free = TRUE;
- break;
- }
- curr = curr->next;
- }
- }
-
- if(pScreenPriv->DestroyColormap) {
+ ScreenPtr pScreen = pmap->pScreen;
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+ VisualPtr pVisual = pmap->pVisual;
+
+ if (pScreenPriv->fakedVisuals) {
+ FakedVisualList *curr = pScreenPriv->fakedVisuals;
+
+ while (curr) {
+ if (curr->pVisual == pVisual) {
+ /* We can't get rid of them yet since FreeColormap
+ still needs the pVisual during the cleanup */
+ curr->free = TRUE;
+ break;
+ }
+ curr = curr->next;
+ }
+ }
+
+ if (pScreenPriv->DestroyColormap) {
pScreen->DestroyColormap = pScreenPriv->DestroyColormap;
- (*pScreen->DestroyColormap)(pmap);
+ (*pScreen->DestroyColormap) (pmap);
pScreen->DestroyColormap = DGADestroyColormap;
- }
+ }
}
-
-static void
+static void
DGAInstallColormap(ColormapPtr pmap)
{
ScreenPtr pScreen = pmap->pScreen;
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
- if(pScreenPriv->current && pScreenPriv->dgaColormap) {
- if (pmap != pScreenPriv->dgaColormap) {
- pScreenPriv->savedColormap = pmap;
- pmap = pScreenPriv->dgaColormap;
- }
+ if (pScreenPriv->current && pScreenPriv->dgaColormap) {
+ if (pmap != pScreenPriv->dgaColormap) {
+ pScreenPriv->savedColormap = pmap;
+ pmap = pScreenPriv->dgaColormap;
+ }
}
pScreen->InstallColormap = pScreenPriv->InstallColormap;
- (*pScreen->InstallColormap)(pmap);
+ (*pScreen->InstallColormap) (pmap);
pScreen->InstallColormap = DGAInstallColormap;
}
-static void
+static void
DGAUninstallColormap(ColormapPtr pmap)
{
ScreenPtr pScreen = pmap->pScreen;
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
- if(pScreenPriv->current && pScreenPriv->dgaColormap) {
- if (pmap == pScreenPriv->dgaColormap) {
- pScreenPriv->dgaColormap = NULL;
- }
+ if (pScreenPriv->current && pScreenPriv->dgaColormap) {
+ if (pmap == pScreenPriv->dgaColormap) {
+ pScreenPriv->dgaColormap = NULL;
+ }
}
pScreen->UninstallColormap = pScreenPriv->UninstallColormap;
- (*pScreen->UninstallColormap)(pmap);
+ (*pScreen->UninstallColormap) (pmap);
pScreen->UninstallColormap = DGAUninstallColormap;
}
int
-xf86SetDGAMode(
- int index,
- int num,
- DGADevicePtr devRet
-){
- ScreenPtr pScreen = screenInfo.screens[index];
- DGAScreenPtr pScreenPriv;
- ScrnInfoPtr pScrn;
- DGADevicePtr device;
- PixmapPtr pPix = NULL;
- DGAModePtr pMode = NULL;
-
- /* First check if DGAInit was successful on this screen */
- if (!DGAScreenKeyRegistered)
- return BadValue;
- pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
- if (!pScreenPriv)
- return BadValue;
- pScrn = pScreenPriv->pScrn;
-
- if(!num) {
- if(pScreenPriv->current) {
- PixmapPtr oldPix = pScreenPriv->current->pPix;
- if(oldPix) {
- if(oldPix->drawable.id)
- FreeResource(oldPix->drawable.id, RT_NONE);
- else
- (*pScreen->DestroyPixmap)(oldPix);
- }
- free(pScreenPriv->current);
- pScreenPriv->current = NULL;
- pScrn->vtSema = TRUE;
- (*pScreenPriv->funcs->SetMode)(pScrn, NULL);
- if(pScreenPriv->savedColormap) {
- (*pScreen->InstallColormap)(pScreenPriv->savedColormap);
- pScreenPriv->savedColormap = NULL;
- }
- pScreenPriv->dgaColormap = NULL;
- (*pScrn->EnableDisableFBAccess)(index, TRUE);
-
- FreeMarkedVisuals(pScreen);
- }
-
+xf86SetDGAMode(int index, int num, DGADevicePtr devRet)
+{
+ ScreenPtr pScreen = screenInfo.screens[index];
+ DGAScreenPtr pScreenPriv;
+ ScrnInfoPtr pScrn;
+ DGADevicePtr device;
+ PixmapPtr pPix = NULL;
+ DGAModePtr pMode = NULL;
+
+ /* First check if DGAInit was successful on this screen */
+ if (!DGAScreenKeyRegistered)
+ return BadValue;
+ pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+ if (!pScreenPriv)
+ return BadValue;
+ pScrn = pScreenPriv->pScrn;
+
+ if (!num) {
+ if (pScreenPriv->current) {
+ PixmapPtr oldPix = pScreenPriv->current->pPix;
+
+ if (oldPix) {
+ if (oldPix->drawable.id)
+ FreeResource(oldPix->drawable.id, RT_NONE);
+ else
+ (*pScreen->DestroyPixmap) (oldPix);
+ }
+ free(pScreenPriv->current);
+ pScreenPriv->current = NULL;
+ pScrn->vtSema = TRUE;
+ (*pScreenPriv->funcs->SetMode) (pScrn, NULL);
+ if (pScreenPriv->savedColormap) {
+ (*pScreen->InstallColormap) (pScreenPriv->savedColormap);
+ pScreenPriv->savedColormap = NULL;
+ }
+ pScreenPriv->dgaColormap = NULL;
+ (*pScrn->EnableDisableFBAccess) (index, TRUE);
+
+ FreeMarkedVisuals(pScreen);
+ }
+
pScreenPriv->grabMouse = FALSE;
pScreenPriv->grabKeyboard = FALSE;
- return Success;
- }
-
- if(!pScrn->vtSema && !pScreenPriv->current) /* Really switched away */
- return BadAlloc;
-
- if((num > 0) && (num <= pScreenPriv->numModes))
- pMode = &(pScreenPriv->modes[num - 1]);
- else
- return BadValue;
-
- if(!(device = (DGADevicePtr)malloc(sizeof(DGADeviceRec))))
- return BadAlloc;
-
- if(!pScreenPriv->current) {
- Bool oldVTSema = pScrn->vtSema;
-
- pScrn->vtSema = FALSE; /* kludge until we rewrite VT switching */
- (*pScrn->EnableDisableFBAccess)(index, FALSE);
- pScrn->vtSema = oldVTSema;
- }
-
- if(!(*pScreenPriv->funcs->SetMode)(pScrn, pMode)) {
- free(device);
- return BadAlloc;
- }
-
- pScrn->currentMode = pMode->mode;
-
- if(!pScreenPriv->current && !pScreenPriv->input) {
- /* if it's multihead we need to warp the cursor off of
- our screen so it doesn't get trapped */
- }
-
- pScrn->vtSema = FALSE;
-
- if(pScreenPriv->current) {
- PixmapPtr oldPix = pScreenPriv->current->pPix;
- if(oldPix) {
- if(oldPix->drawable.id)
- FreeResource(oldPix->drawable.id, RT_NONE);
- else
- (*pScreen->DestroyPixmap)(oldPix);
- }
- free(pScreenPriv->current);
- pScreenPriv->current = NULL;
- }
-
- if(pMode->flags & DGA_PIXMAP_AVAILABLE) {
- if((pPix = (*pScreen->CreatePixmap)(pScreen, 0, 0, pMode->depth, 0))) {
- (*pScreen->ModifyPixmapHeader)(pPix,
- pMode->pixmapWidth, pMode->pixmapHeight,
- pMode->depth, pMode->bitsPerPixel,
- pMode->bytesPerScanline,
- (pointer)(pMode->address));
- }
- }
+ return Success;
+ }
- devRet->mode = device->mode = pMode;
- devRet->pPix = device->pPix = pPix;
- pScreenPriv->current = device;
- pScreenPriv->pixmapMode = FALSE;
- pScreenPriv->grabMouse = TRUE;
- pScreenPriv->grabKeyboard = TRUE;
+ if (!pScrn->vtSema && !pScreenPriv->current) /* Really switched away */
+ return BadAlloc;
- if (!mieq_installed) {
- mieqSetHandler(ET_DGAEvent, DGAHandleEvent);
- mieq_installed = TRUE;
- }
+ if ((num > 0) && (num <= pScreenPriv->numModes))
+ pMode = &(pScreenPriv->modes[num - 1]);
+ else
+ return BadValue;
- return Success;
-}
+ if (!(device = (DGADevicePtr) malloc(sizeof(DGADeviceRec))))
+ return BadAlloc;
+
+ if (!pScreenPriv->current) {
+ Bool oldVTSema = pScrn->vtSema;
+
+ pScrn->vtSema = FALSE; /* kludge until we rewrite VT switching */
+ (*pScrn->EnableDisableFBAccess) (index, FALSE);
+ pScrn->vtSema = oldVTSema;
+ }
+
+ if (!(*pScreenPriv->funcs->SetMode) (pScrn, pMode)) {
+ free(device);
+ return BadAlloc;
+ }
+
+ pScrn->currentMode = pMode->mode;
+ if (!pScreenPriv->current && !pScreenPriv->input) {
+ /* if it's multihead we need to warp the cursor off of
+ our screen so it doesn't get trapped */
+ }
+
+ pScrn->vtSema = FALSE;
+
+ if (pScreenPriv->current) {
+ PixmapPtr oldPix = pScreenPriv->current->pPix;
+
+ if (oldPix) {
+ if (oldPix->drawable.id)
+ FreeResource(oldPix->drawable.id, RT_NONE);
+ else
+ (*pScreen->DestroyPixmap) (oldPix);
+ }
+ free(pScreenPriv->current);
+ pScreenPriv->current = NULL;
+ }
+ if (pMode->flags & DGA_PIXMAP_AVAILABLE) {
+ if ((pPix = (*pScreen->CreatePixmap) (pScreen, 0, 0, pMode->depth, 0))) {
+ (*pScreen->ModifyPixmapHeader) (pPix,
+ pMode->pixmapWidth,
+ pMode->pixmapHeight, pMode->depth,
+ pMode->bitsPerPixel,
+ pMode->bytesPerScanline,
+ (pointer) (pMode->address));
+ }
+ }
+
+ devRet->mode = device->mode = pMode;
+ devRet->pPix = device->pPix = pPix;
+ pScreenPriv->current = device;
+ pScreenPriv->pixmapMode = FALSE;
+ pScreenPriv->grabMouse = TRUE;
+ pScreenPriv->grabKeyboard = TRUE;
+
+ if (!mieq_installed) {
+ mieqSetHandler(ET_DGAEvent, DGAHandleEvent);
+ mieq_installed = 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;
-
- if (!mieq_installed) {
- mieqSetHandler(ET_DGAEvent, DGAHandleEvent);
- mieq_installed = TRUE;
- }
- }
+ ScreenPtr pScreen = screenInfo.screens[index];
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+
+ if (pScreenPriv) {
+ pScreenPriv->grabMouse = mouse;
+ pScreenPriv->grabKeyboard = keyboard;
+
+ if (!mieq_installed) {
+ mieqSetHandler(ET_DGAEvent, DGAHandleEvent);
+ mieq_installed = TRUE;
+ }
+ }
}
Bool
DGAChangePixmapMode(int index, int *x, int *y, int mode)
{
- DGAScreenPtr pScreenPriv;
- DGADevicePtr pDev;
- DGAModePtr pMode;
- PixmapPtr pPix;
-
- if(!DGAScreenKeyRegistered)
- return FALSE;
-
- pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
-
- if(!pScreenPriv || !pScreenPriv->current || !pScreenPriv->current->pPix)
- return FALSE;
-
- pDev = pScreenPriv->current;
- pPix = pDev->pPix;
- pMode = pDev->mode;
-
- if(mode) {
- int shift = 2;
-
- if(*x > (pMode->pixmapWidth - pMode->viewportWidth))
- *x = pMode->pixmapWidth - pMode->viewportWidth;
- if(*y > (pMode->pixmapHeight - pMode->viewportHeight))
- *y = pMode->pixmapHeight - pMode->viewportHeight;
-
- switch(xf86Screens[index]->bitsPerPixel) {
- case 16: shift = 1; break;
- case 32: shift = 0; break;
- default: break;
- }
-
- if(BITMAP_SCANLINE_PAD == 64)
- shift++;
-
- *x = (*x >> shift) << shift;
-
- pPix->drawable.x = *x;
- pPix->drawable.y = *y;
- pPix->drawable.width = pMode->viewportWidth;
- pPix->drawable.height = pMode->viewportHeight;
- } else {
- pPix->drawable.x = 0;
- pPix->drawable.y = 0;
- pPix->drawable.width = pMode->pixmapWidth;
- pPix->drawable.height = pMode->pixmapHeight;
- }
- pPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
- pScreenPriv->pixmapMode = mode;
-
- return TRUE;
+ DGAScreenPtr pScreenPriv;
+ DGADevicePtr pDev;
+ DGAModePtr pMode;
+ PixmapPtr pPix;
+
+ if (!DGAScreenKeyRegistered)
+ return FALSE;
+
+ pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+ if (!pScreenPriv || !pScreenPriv->current || !pScreenPriv->current->pPix)
+ return FALSE;
+
+ pDev = pScreenPriv->current;
+ pPix = pDev->pPix;
+ pMode = pDev->mode;
+
+ if (mode) {
+ int shift = 2;
+
+ if (*x > (pMode->pixmapWidth - pMode->viewportWidth))
+ *x = pMode->pixmapWidth - pMode->viewportWidth;
+ if (*y > (pMode->pixmapHeight - pMode->viewportHeight))
+ *y = pMode->pixmapHeight - pMode->viewportHeight;
+
+ switch (xf86Screens[index]->bitsPerPixel) {
+ case 16:
+ shift = 1;
+ break;
+ case 32:
+ shift = 0;
+ break;
+ default:
+ break;
+ }
+
+ if (BITMAP_SCANLINE_PAD == 64)
+ shift++;
+
+ *x = (*x >> shift) << shift;
+
+ pPix->drawable.x = *x;
+ pPix->drawable.y = *y;
+ pPix->drawable.width = pMode->viewportWidth;
+ pPix->drawable.height = pMode->viewportHeight;
+ }
+ else {
+ pPix->drawable.x = 0;
+ pPix->drawable.y = 0;
+ pPix->drawable.width = pMode->pixmapWidth;
+ pPix->drawable.height = pMode->pixmapHeight;
+ }
+ pPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pScreenPriv->pixmapMode = mode;
+
+ return TRUE;
}
Bool
-DGAAvailable(int index)
+DGAAvailable(int index)
{
- if(!DGAScreenKeyRegistered)
- return FALSE;
-
- if(DGA_GET_SCREEN_PRIV(screenInfo.screens[index]))
- return TRUE;
+ if (!DGAScreenKeyRegistered)
+ return FALSE;
- return FALSE;
+ if (DGA_GET_SCREEN_PRIV(screenInfo.screens[index]))
+ return TRUE;
+
+ return FALSE;
}
Bool
-DGAActive(int index)
+DGAActive(int index)
{
- DGAScreenPtr pScreenPriv;
+ DGAScreenPtr pScreenPriv;
- if(!DGAScreenKeyRegistered)
- return FALSE;
+ if (!DGAScreenKeyRegistered)
+ return FALSE;
- pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+ pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
- if(pScreenPriv && pScreenPriv->current)
- return TRUE;
+ if (pScreenPriv && pScreenPriv->current)
+ return TRUE;
- return FALSE;
+ return FALSE;
}
-
-
/* Called by the event code in case the server is abruptly terminated */
void
@@ -570,35 +558,31 @@ DGAShutdown(void)
ScrnInfoPtr pScrn;
int i;
- if(!DGAScreenKeyRegistered)
- return;
+ if (!DGAScreenKeyRegistered)
+ return;
- for(i = 0; i < screenInfo.numScreens; i++) {
- pScrn = xf86Screens[i];
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ pScrn = xf86Screens[i];
- (void)(*pScrn->SetDGAMode)(pScrn->scrnIndex, 0, NULL);
+ (void) (*pScrn->SetDGAMode) (pScrn->scrnIndex, 0, NULL);
}
}
/* Called by the extension to initialize a mode */
int
-DGASetMode(
- int index,
- int num,
- XDGAModePtr mode,
- PixmapPtr *pPix
-){
+DGASetMode(int index, int num, XDGAModePtr mode, PixmapPtr *pPix)
+{
ScrnInfoPtr pScrn = xf86Screens[index];
DGADeviceRec device;
int ret;
- /* We rely on the extension to check that DGA is available */
+ /* We rely on the extension to check that DGA is available */
- ret = (*pScrn->SetDGAMode)(index, num, &device);
- if((ret == Success) && num) {
- DGACopyModeInfo(device.mode, mode);
- *pPix = device.pPix;
+ ret = (*pScrn->SetDGAMode) (index, num, &device);
+ if ((ret == Success) && num) {
+ DGACopyModeInfo(device.mode, mode);
+ *pPix = device.pPix;
}
return ret;
@@ -607,124 +591,119 @@ DGASetMode(
/* Called from the extension to let the DDX know which events are requested */
void
-DGASelectInput(
- int index,
- ClientPtr client,
- long mask
-){
- DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
-
- /* We rely on the extension to check that DGA is available */
- pScreenPriv->client = client;
- pScreenPriv->input = mask;
+DGASelectInput(int index, ClientPtr client, long mask)
+{
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+ /* We rely on the extension to check that DGA is available */
+ pScreenPriv->client = client;
+ pScreenPriv->input = mask;
}
int
-DGAGetViewportStatus(int index)
+DGAGetViewportStatus(int index)
{
- DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
- /* We rely on the extension to check that DGA is active */
+ /* We rely on the extension to check that DGA is active */
- if (!pScreenPriv->funcs->GetViewport)
- return 0;
+ if (!pScreenPriv->funcs->GetViewport)
+ return 0;
- return (*pScreenPriv->funcs->GetViewport)(pScreenPriv->pScrn);
+ return (*pScreenPriv->funcs->GetViewport) (pScreenPriv->pScrn);
}
int
-DGASetViewport(
- int index,
- int x, int y,
- int mode
-){
- DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
-
- if (pScreenPriv->funcs->SetViewport)
- (*pScreenPriv->funcs->SetViewport)(pScreenPriv->pScrn, x, y, mode);
- return Success;
-}
+DGASetViewport(int index, int x, int y, int mode)
+{
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+ if (pScreenPriv->funcs->SetViewport)
+ (*pScreenPriv->funcs->SetViewport) (pScreenPriv->pScrn, x, y, mode);
+ return Success;
+}
static int
BitsClear(CARD32 data)
{
- int bits = 0;
- CARD32 mask;
-
- for(mask = 1; mask; mask <<= 1) {
- if(!(data & mask)) bits++;
- else break;
- }
+ int bits = 0;
+ CARD32 mask;
+
+ for (mask = 1; mask; mask <<= 1) {
+ if (!(data & mask))
+ bits++;
+ else
+ break;
+ }
- return bits;
+ return bits;
}
int
DGACreateColormap(int index, ClientPtr client, int id, int mode, int alloc)
{
- ScreenPtr pScreen = screenInfo.screens[index];
- DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
- FakedVisualList *fvlp;
- VisualPtr pVisual;
- DGAModePtr pMode;
- ColormapPtr pmap;
-
- if(!mode || (mode > pScreenPriv->numModes))
- return BadValue;
-
- if((alloc != AllocNone) && (alloc != AllocAll))
- return BadValue;
-
- pMode = &(pScreenPriv->modes[mode - 1]);
-
- if(!(pVisual = malloc(sizeof(VisualRec))))
- return BadAlloc;
-
- pVisual->vid = FakeClientID(0);
- pVisual->class = pMode->visualClass;
- pVisual->nplanes = pMode->depth;
- pVisual->ColormapEntries = 1 << pMode->depth;
- pVisual->bitsPerRGBValue = (pMode->depth + 2) / 3;
-
- switch (pVisual->class) {
- case PseudoColor:
- case GrayScale:
- case StaticGray:
- pVisual->bitsPerRGBValue = 8; /* not quite */
- pVisual->redMask = 0;
- pVisual->greenMask = 0;
- pVisual->blueMask = 0;
- pVisual->offsetRed = 0;
- pVisual->offsetGreen = 0;
- pVisual->offsetBlue = 0;
- break;
- case DirectColor:
- case TrueColor:
- pVisual->ColormapEntries = 1 << pVisual->bitsPerRGBValue;
- /* fall through */
- case StaticColor:
- pVisual->redMask = pMode->red_mask;
- pVisual->greenMask = pMode->green_mask;
- pVisual->blueMask = pMode->blue_mask;
- pVisual->offsetRed = BitsClear(pVisual->redMask);
- pVisual->offsetGreen = BitsClear(pVisual->greenMask);
- pVisual->offsetBlue = BitsClear(pVisual->blueMask);
- }
-
- if(!(fvlp = malloc(sizeof(FakedVisualList)))) {
- free(pVisual);
- return BadAlloc;
- }
-
- fvlp->free = FALSE;
- fvlp->pVisual = pVisual;
- fvlp->next = pScreenPriv->fakedVisuals;
- pScreenPriv->fakedVisuals = fvlp;
-
- LEGAL_NEW_RESOURCE(id, client);
-
- return CreateColormap(id, pScreen, pVisual, &pmap, alloc, client->index);
+ ScreenPtr pScreen = screenInfo.screens[index];
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+ FakedVisualList *fvlp;
+ VisualPtr pVisual;
+ DGAModePtr pMode;
+ ColormapPtr pmap;
+
+ if (!mode || (mode > pScreenPriv->numModes))
+ return BadValue;
+
+ if ((alloc != AllocNone) && (alloc != AllocAll))
+ return BadValue;
+
+ pMode = &(pScreenPriv->modes[mode - 1]);
+
+ if (!(pVisual = malloc(sizeof(VisualRec))))
+ return BadAlloc;
+
+ pVisual->vid = FakeClientID(0);
+ pVisual->class = pMode->visualClass;
+ pVisual->nplanes = pMode->depth;
+ pVisual->ColormapEntries = 1 << pMode->depth;
+ pVisual->bitsPerRGBValue = (pMode->depth + 2) / 3;
+
+ switch (pVisual->class) {
+ case PseudoColor:
+ case GrayScale:
+ case StaticGray:
+ pVisual->bitsPerRGBValue = 8; /* not quite */
+ pVisual->redMask = 0;
+ pVisual->greenMask = 0;
+ pVisual->blueMask = 0;
+ pVisual->offsetRed = 0;
+ pVisual->offsetGreen = 0;
+ pVisual->offsetBlue = 0;
+ break;
+ case DirectColor:
+ case TrueColor:
+ pVisual->ColormapEntries = 1 << pVisual->bitsPerRGBValue;
+ /* fall through */
+ case StaticColor:
+ pVisual->redMask = pMode->red_mask;
+ pVisual->greenMask = pMode->green_mask;
+ pVisual->blueMask = pMode->blue_mask;
+ pVisual->offsetRed = BitsClear(pVisual->redMask);
+ pVisual->offsetGreen = BitsClear(pVisual->greenMask);
+ pVisual->offsetBlue = BitsClear(pVisual->blueMask);
+ }
+
+ if (!(fvlp = malloc(sizeof(FakedVisualList)))) {
+ free(pVisual);
+ return BadAlloc;
+ }
+
+ fvlp->free = FALSE;
+ fvlp->pVisual = pVisual;
+ fvlp->next = pScreenPriv->fakedVisuals;
+ pScreenPriv->fakedVisuals = fvlp;
+
+ LEGAL_NEW_RESOURCE(id, client);
+
+ return CreateColormap(id, pScreen, pVisual, &pmap, alloc, client->index);
}
/* Called by the extension to install a colormap on DGA active screens */
@@ -735,198 +714,184 @@ DGAInstallCmap(ColormapPtr cmap)
ScreenPtr pScreen = cmap->pScreen;
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
- /* We rely on the extension to check that DGA is active */
+ /* We rely on the extension to check that DGA is active */
- if(!pScreenPriv->dgaColormap)
- pScreenPriv->savedColormap = GetInstalledmiColormap(pScreen);
+ if (!pScreenPriv->dgaColormap)
+ pScreenPriv->savedColormap = GetInstalledmiColormap(pScreen);
- pScreenPriv->dgaColormap = cmap;
+ pScreenPriv->dgaColormap = cmap;
- (*pScreen->InstallColormap)(cmap);
+ (*pScreen->InstallColormap) (cmap);
}
int
DGASync(int index)
{
- DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
-
- /* We rely on the extension to check that DGA is active */
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
- if (pScreenPriv->funcs->Sync)
- (*pScreenPriv->funcs->Sync)(pScreenPriv->pScrn);
+ /* We rely on the extension to check that DGA is active */
- return Success;
+ if (pScreenPriv->funcs->Sync)
+ (*pScreenPriv->funcs->Sync) (pScreenPriv->pScrn);
+
+ return Success;
}
int
-DGAFillRect(
- int index,
- int x, int y, int w, int h,
- unsigned long color
-){
- DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
-
- /* We rely on the extension to check that DGA is active */
-
- if(pScreenPriv->funcs->FillRect &&
- (pScreenPriv->current->mode->flags & DGA_FILL_RECT)) {
-
- (*pScreenPriv->funcs->FillRect)(pScreenPriv->pScrn, x, y, w, h, color);
- return Success;
- }
- return BadMatch;
+DGAFillRect(int index, int x, int y, int w, int h, unsigned long color)
+{
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+ /* We rely on the extension to check that DGA is active */
+
+ if (pScreenPriv->funcs->FillRect &&
+ (pScreenPriv->current->mode->flags & DGA_FILL_RECT)) {
+
+ (*pScreenPriv->funcs->FillRect) (pScreenPriv->pScrn, x, y, w, h, color);
+ return Success;
+ }
+ return BadMatch;
}
int
-DGABlitRect(
- int index,
- int srcx, int srcy,
- int w, int h,
- int dstx, int dsty
-){
- DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
-
- /* We rely on the extension to check that DGA is active */
-
- if(pScreenPriv->funcs->BlitRect &&
- (pScreenPriv->current->mode->flags & DGA_BLIT_RECT)) {
-
- (*pScreenPriv->funcs->BlitRect)(pScreenPriv->pScrn,
- srcx, srcy, w, h, dstx, dsty);
- return Success;
- }
- return BadMatch;
+DGABlitRect(int index, int srcx, int srcy, int w, int h, int dstx, int dsty)
+{
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+ /* We rely on the extension to check that DGA is active */
+
+ if (pScreenPriv->funcs->BlitRect &&
+ (pScreenPriv->current->mode->flags & DGA_BLIT_RECT)) {
+
+ (*pScreenPriv->funcs->BlitRect) (pScreenPriv->pScrn,
+ srcx, srcy, w, h, dstx, dsty);
+ return Success;
+ }
+ return BadMatch;
}
int
-DGABlitTransRect(
- int index,
- int srcx, int srcy,
- int w, int h,
- int dstx, int dsty,
- unsigned long color
-){
- DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
-
- /* We rely on the extension to check that DGA is active */
-
- if(pScreenPriv->funcs->BlitTransRect &&
- (pScreenPriv->current->mode->flags & DGA_BLIT_RECT_TRANS)) {
-
- (*pScreenPriv->funcs->BlitTransRect)(pScreenPriv->pScrn,
- srcx, srcy, w, h, dstx, dsty, color);
- return Success;
- }
- return BadMatch;
-}
+DGABlitTransRect(int index,
+ int srcx, int srcy,
+ int w, int h, int dstx, int dsty, unsigned long color)
+{
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+ /* We rely on the extension to check that DGA is active */
+
+ if (pScreenPriv->funcs->BlitTransRect &&
+ (pScreenPriv->current->mode->flags & DGA_BLIT_RECT_TRANS)) {
+
+ (*pScreenPriv->funcs->BlitTransRect) (pScreenPriv->pScrn,
+ srcx, srcy, w, h, dstx, dsty,
+ color);
+ return Success;
+ }
+ return BadMatch;
+}
int
DGAGetModes(int index)
{
- DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
- /* We rely on the extension to check that DGA is available */
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
- return pScreenPriv->numModes;
-}
+ /* We rely on the extension to check that DGA is available */
+ return pScreenPriv->numModes;
+}
int
-DGAGetModeInfo(
- int index,
- XDGAModePtr mode,
- int num
-){
- DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
- /* We rely on the extension to check that DGA is available */
+DGAGetModeInfo(int index, XDGAModePtr mode, int num)
+{
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
- if((num <= 0) || (num > pScreenPriv->numModes))
- return BadValue;
+ /* We rely on the extension to check that DGA is available */
- DGACopyModeInfo(&(pScreenPriv->modes[num - 1]), mode);
+ if ((num <= 0) || (num > pScreenPriv->numModes))
+ return BadValue;
- return Success;
-}
+ DGACopyModeInfo(&(pScreenPriv->modes[num - 1]), mode);
+ return Success;
+}
static void
-DGACopyModeInfo(
- DGAModePtr mode,
- XDGAModePtr xmode
-){
- DisplayModePtr dmode = mode->mode;
-
- xmode->num = mode->num;
- xmode->name = dmode->name;
- xmode->VSync_num = (int)(dmode->VRefresh * 1000.0);
- xmode->VSync_den = 1000;
- xmode->flags = mode->flags;
- xmode->imageWidth = mode->imageWidth;
- xmode->imageHeight = mode->imageHeight;
- xmode->pixmapWidth = mode->pixmapWidth;
- xmode->pixmapHeight = mode->pixmapHeight;
- xmode->bytesPerScanline = mode->bytesPerScanline;
- xmode->byteOrder = mode->byteOrder;
- xmode->depth = mode->depth;
- xmode->bitsPerPixel = mode->bitsPerPixel;
- xmode->red_mask = mode->red_mask;
- xmode->green_mask = mode->green_mask;
- xmode->blue_mask = mode->blue_mask;
- xmode->visualClass = mode->visualClass;
- xmode->viewportWidth = mode->viewportWidth;
- xmode->viewportHeight = mode->viewportHeight;
- xmode->xViewportStep = mode->xViewportStep;
- xmode->yViewportStep = mode->yViewportStep;
- xmode->maxViewportX = mode->maxViewportX;
- xmode->maxViewportY = mode->maxViewportY;
- xmode->viewportFlags = mode->viewportFlags;
- xmode->reserved1 = mode->reserved1;
- xmode->reserved2 = mode->reserved2;
- xmode->offset = mode->offset;
-
- if(dmode->Flags & V_INTERLACE) xmode->flags |= DGA_INTERLACED;
- if(dmode->Flags & V_DBLSCAN) xmode->flags |= DGA_DOUBLESCAN;
+DGACopyModeInfo(DGAModePtr mode, XDGAModePtr xmode)
+{
+ DisplayModePtr dmode = mode->mode;
+
+ xmode->num = mode->num;
+ xmode->name = dmode->name;
+ xmode->VSync_num = (int) (dmode->VRefresh * 1000.0);
+ xmode->VSync_den = 1000;
+ xmode->flags = mode->flags;
+ xmode->imageWidth = mode->imageWidth;
+ xmode->imageHeight = mode->imageHeight;
+ xmode->pixmapWidth = mode->pixmapWidth;
+ xmode->pixmapHeight = mode->pixmapHeight;
+ xmode->bytesPerScanline = mode->bytesPerScanline;
+ xmode->byteOrder = mode->byteOrder;
+ xmode->depth = mode->depth;
+ xmode->bitsPerPixel = mode->bitsPerPixel;
+ xmode->red_mask = mode->red_mask;
+ xmode->green_mask = mode->green_mask;
+ xmode->blue_mask = mode->blue_mask;
+ xmode->visualClass = mode->visualClass;
+ xmode->viewportWidth = mode->viewportWidth;
+ xmode->viewportHeight = mode->viewportHeight;
+ xmode->xViewportStep = mode->xViewportStep;
+ xmode->yViewportStep = mode->yViewportStep;
+ xmode->maxViewportX = mode->maxViewportX;
+ xmode->maxViewportY = mode->maxViewportY;
+ xmode->viewportFlags = mode->viewportFlags;
+ xmode->reserved1 = mode->reserved1;
+ xmode->reserved2 = mode->reserved2;
+ xmode->offset = mode->offset;
+
+ if (dmode->Flags & V_INTERLACE)
+ xmode->flags |= DGA_INTERLACED;
+ if (dmode->Flags & V_DBLSCAN)
+ xmode->flags |= DGA_DOUBLESCAN;
}
-
Bool
DGAVTSwitch(void)
{
ScreenPtr pScreen;
int i;
- for(i = 0; i < screenInfo.numScreens; i++) {
- pScreen = screenInfo.screens[i];
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ pScreen = screenInfo.screens[i];
- /* Alternatively, this could send events to DGA clients */
+ /* Alternatively, this could send events to DGA clients */
- if(DGAScreenKeyRegistered) {
- DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+ if (DGAScreenKeyRegistered) {
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
- if(pScreenPriv && pScreenPriv->current)
- return FALSE;
- }
+ if (pScreenPriv && pScreenPriv->current)
+ return FALSE;
+ }
}
- return TRUE;
+ return TRUE;
}
Bool
DGAStealKeyEvent(DeviceIntPtr dev, int index, int key_code, int is_down)
{
- DGAScreenPtr pScreenPriv;
- DGAEvent event;
+ DGAScreenPtr pScreenPriv;
+ DGAEvent event;
- if(!DGAScreenKeyRegistered) /* no DGA */
+ if (!DGAScreenKeyRegistered) /* no DGA */
return FALSE;
- if (key_code < 8 || key_code > 255)
- return FALSE;
+ if (key_code < 8 || key_code > 255)
+ return FALSE;
- pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+ pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
- if(!pScreenPriv || !pScreenPriv->grabKeyboard) /* no direct mode */
- return FALSE;
+ if (!pScreenPriv || !pScreenPriv->grabKeyboard) /* no direct mode */
+ return FALSE;
memset(&event, 0, sizeof(event));
event.header = ET_Internal;
@@ -937,23 +902,23 @@ DGAStealKeyEvent(DeviceIntPtr dev, int index, int key_code, int is_down)
event.detail = key_code;
event.dx = 0;
event.dy = 0;
- mieqEnqueue (dev, (InternalEvent*)&event);
+ mieqEnqueue(dev, (InternalEvent *) &event);
- return TRUE;
-}
+ return TRUE;
+}
Bool
DGAStealMotionEvent(DeviceIntPtr dev, int index, int dx, int dy)
{
- DGAScreenPtr pScreenPriv;
- DGAEvent event;
+ DGAScreenPtr pScreenPriv;
+ DGAEvent event;
- if(!DGAScreenKeyRegistered) /* no DGA */
+ if (!DGAScreenKeyRegistered) /* no DGA */
return FALSE;
-
- pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
- if(!pScreenPriv || !pScreenPriv->grabMouse) /* no direct mode */
+ pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+ if (!pScreenPriv || !pScreenPriv->grabMouse) /* no direct mode */
return FALSE;
memset(&event, 0, sizeof(event));
@@ -965,7 +930,7 @@ DGAStealMotionEvent(DeviceIntPtr dev, int index, int dx, int dy)
event.detail = 0;
event.dx = dx;
event.dy = dy;
- mieqEnqueue (dev, (InternalEvent*)&event);
+ mieqEnqueue(dev, (InternalEvent *) &event);
return TRUE;
}
@@ -975,9 +940,9 @@ DGAStealButtonEvent(DeviceIntPtr dev, int index, int button, int is_down)
DGAScreenPtr pScreenPriv;
DGAEvent event;
- if(!DGAScreenKeyRegistered) /* no DGA */
+ if (!DGAScreenKeyRegistered) /* no DGA */
return FALSE;
-
+
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
if (!pScreenPriv || !pScreenPriv->grabMouse)
@@ -992,32 +957,31 @@ DGAStealButtonEvent(DeviceIntPtr dev, int index, int button, int is_down)
event.detail = button;
event.dx = 0;
event.dy = 0;
- mieqEnqueue (dev, (InternalEvent*)&event);
+ mieqEnqueue(dev, (InternalEvent *) &event);
return TRUE;
}
/* We have the power to steal or modify events that are about to get queued */
-#define NoSuchEvent 0x80000000 /* so doesn't match NoEventMask */
-static Mask filters[] =
-{
- NoSuchEvent, /* 0 */
- NoSuchEvent, /* 1 */
- KeyPressMask, /* KeyPress */
- KeyReleaseMask, /* KeyRelease */
- ButtonPressMask, /* ButtonPress */
- ButtonReleaseMask, /* ButtonRelease */
- PointerMotionMask, /* MotionNotify (initial state) */
+#define NoSuchEvent 0x80000000 /* so doesn't match NoEventMask */
+static Mask filters[] = {
+ NoSuchEvent, /* 0 */
+ NoSuchEvent, /* 1 */
+ KeyPressMask, /* KeyPress */
+ KeyReleaseMask, /* KeyRelease */
+ ButtonPressMask, /* ButtonPress */
+ ButtonReleaseMask, /* ButtonRelease */
+ PointerMotionMask, /* MotionNotify (initial state) */
};
static void
-DGAProcessKeyboardEvent (ScreenPtr pScreen, DGAEvent *event, DeviceIntPtr keybd)
+DGAProcessKeyboardEvent(ScreenPtr pScreen, DGAEvent * event, DeviceIntPtr keybd)
{
- KeyClassPtr keyc = keybd->key;
- DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
- DeviceIntPtr pointer = GetMaster(keybd, POINTER_OR_FLOAT);
- DeviceEvent ev;
+ KeyClassPtr keyc = keybd->key;
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+ DeviceIntPtr pointer = GetMaster(keybd, POINTER_OR_FLOAT);
+ DeviceEvent ev;
memset(&ev, 0, sizeof(ev));
ev.header = ET_Internal;
@@ -1034,9 +998,9 @@ DGAProcessKeyboardEvent (ScreenPtr pScreen, DGAEvent *event, DeviceIntPtr keybd)
/*
* Deliver the DGA event
*/
- if (pScreenPriv->client)
- {
+ if (pScreenPriv->client) {
dgaEvent de;
+
de.u.u.type = *XDGAEventBase + GetCoreType(ev.type);
de.u.u.detail = event->detail;
de.u.event.time = event->time;
@@ -1045,39 +1009,37 @@ DGAProcessKeyboardEvent (ScreenPtr pScreen, DGAEvent *event, DeviceIntPtr keybd)
de.u.event.screen = pScreen->myNum;
de.u.event.state = ev.corestate;
- /* If the DGA client has selected input, then deliver based on the usual filter */
- TryClientEvents (pScreenPriv->client, keybd, (xEvent *)&de, 1,
- filters[ev.type], pScreenPriv->input, 0);
+ /* If the DGA client has selected input, then deliver based on the usual filter */
+ TryClientEvents(pScreenPriv->client, keybd, (xEvent *) &de, 1,
+ filters[ev.type], pScreenPriv->input, 0);
}
- else
- {
- /* If the keyboard is actively grabbed, deliver a grabbed core event */
- if (keybd->deviceGrab.grab && !keybd->deviceGrab.fromPassiveGrab)
- {
+ else {
+ /* If the keyboard is actively grabbed, deliver a grabbed core event */
+ if (keybd->deviceGrab.grab && !keybd->deviceGrab.fromPassiveGrab) {
ev.detail.key = event->detail;
- ev.time = event->time;
- ev.root_x = event->dx;
- ev.root_y = event->dy;
- ev.corestate = event->state;
- ev.deviceid = keybd->id;
- DeliverGrabbedEvent ((InternalEvent*)&ev, keybd, FALSE);
- }
+ ev.time = event->time;
+ ev.root_x = event->dx;
+ ev.root_y = event->dy;
+ ev.corestate = event->state;
+ ev.deviceid = keybd->id;
+ DeliverGrabbedEvent((InternalEvent *) &ev, keybd, FALSE);
+ }
}
}
static void
-DGAProcessPointerEvent (ScreenPtr pScreen, DGAEvent *event, DeviceIntPtr mouse)
+DGAProcessPointerEvent(ScreenPtr pScreen, DGAEvent * event, DeviceIntPtr mouse)
{
- ButtonClassPtr butc = mouse->button;
- DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
- DeviceEvent ev;
- DeviceIntPtr master = GetMaster(mouse, MASTER_KEYBOARD);
+ ButtonClassPtr butc = mouse->button;
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+ DeviceEvent ev;
+ DeviceIntPtr master = GetMaster(mouse, MASTER_KEYBOARD);
memset(&ev, 0, sizeof(ev));
ev.header = ET_Internal;
ev.length = sizeof(ev);
ev.type = event->subtype;
- ev.corestate = butc ? butc->state : 0;
+ ev.corestate = butc ? butc->state : 0;
if (master && master->key)
ev.corestate |= XkbStateFieldFromRec(&master->key->xkbInfo->state);
@@ -1086,10 +1048,9 @@ DGAProcessPointerEvent (ScreenPtr pScreen, DGAEvent *event, DeviceIntPtr mouse)
/*
* Deliver the DGA event
*/
- if (pScreenPriv->client)
- {
- dgaEvent de;
- int coreEquiv;
+ if (pScreenPriv->client) {
+ dgaEvent de;
+ int coreEquiv;
coreEquiv = GetCoreType(ev.type);
@@ -1101,54 +1062,49 @@ DGAProcessPointerEvent (ScreenPtr pScreen, DGAEvent *event, DeviceIntPtr mouse)
de.u.event.screen = pScreen->myNum;
de.u.event.state = ev.corestate;
- /* If the DGA client has selected input, then deliver based on the usual filter */
- TryClientEvents (pScreenPriv->client, mouse, (xEvent *)&de, 1,
- filters[coreEquiv], pScreenPriv->input, 0);
+ /* If the DGA client has selected input, then deliver based on the usual filter */
+ TryClientEvents(pScreenPriv->client, mouse, (xEvent *) &de, 1,
+ filters[coreEquiv], pScreenPriv->input, 0);
}
- else
- {
- /* If the pointer is actively grabbed, deliver a grabbed core event */
- if (mouse->deviceGrab.grab && !mouse->deviceGrab.fromPassiveGrab)
- {
- ev.detail.button = event->detail;
- ev.time = event->time;
- ev.root_x = event->dx;
- ev.root_y = event->dy;
- ev.corestate = event->state;
+ else {
+ /* If the pointer is actively grabbed, deliver a grabbed core event */
+ if (mouse->deviceGrab.grab && !mouse->deviceGrab.fromPassiveGrab) {
+ ev.detail.button = event->detail;
+ ev.time = event->time;
+ ev.root_x = event->dx;
+ ev.root_y = event->dy;
+ ev.corestate = event->state;
/* DGA is core only, so valuators.data doesn't actually matter.
* Mask must be set for EventToCore to create motion events. */
SetBit(ev.valuators.mask, 0);
SetBit(ev.valuators.mask, 1);
- DeliverGrabbedEvent ((InternalEvent*)&ev, mouse, FALSE);
- }
+ DeliverGrabbedEvent((InternalEvent *) &ev, mouse, FALSE);
+ }
}
}
Bool
-DGAOpenFramebuffer(
- int index,
- char **name,
- unsigned char **mem,
- int *size,
- int *offset,
- int *flags
-){
- DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
-
- /* We rely on the extension to check that DGA is available */
-
- return (*pScreenPriv->funcs->OpenFramebuffer)(pScreenPriv->pScrn,
- name, mem, size, offset, flags);
+DGAOpenFramebuffer(int index,
+ char **name,
+ unsigned char **mem, int *size, int *offset, int *flags)
+{
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+ /* We rely on the extension to check that DGA is available */
+
+ return (*pScreenPriv->funcs->OpenFramebuffer) (pScreenPriv->pScrn,
+ name, mem, size, offset,
+ flags);
}
void
DGACloseFramebuffer(int index)
{
- DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
- /* We rely on the extension to check that DGA is available */
- if(pScreenPriv->funcs->CloseFramebuffer)
- (*pScreenPriv->funcs->CloseFramebuffer)(pScreenPriv->pScrn);
+ /* We rely on the extension to check that DGA is available */
+ if (pScreenPriv->funcs->CloseFramebuffer)
+ (*pScreenPriv->funcs->CloseFramebuffer) (pScreenPriv->pScrn);
}
/* For DGA 1.0 backwards compatibility only */
@@ -1156,62 +1112,62 @@ DGACloseFramebuffer(int index)
int
DGAGetOldDGAMode(int index)
{
- DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
- ScrnInfoPtr pScrn = pScreenPriv->pScrn;
- DGAModePtr mode;
- int i, w, h, p;
-
- /* We rely on the extension to check that DGA is available */
-
- w = pScrn->currentMode->HDisplay;
- h = pScrn->currentMode->VDisplay;
- p = pad_to_int32(pScrn->displayWidth * bits_to_bytes(pScrn->bitsPerPixel));
-
- for(i = 0; i < pScreenPriv->numModes; i++) {
- mode = &(pScreenPriv->modes[i]);
-
- if((mode->viewportWidth == w) && (mode->viewportHeight == h) &&
- (mode->bytesPerScanline == p) &&
- (mode->bitsPerPixel == pScrn->bitsPerPixel) &&
- (mode->depth == pScrn->depth)) {
-
- return mode->num;
- }
- }
-
- return 0;
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+ ScrnInfoPtr pScrn = pScreenPriv->pScrn;
+ DGAModePtr mode;
+ int i, w, h, p;
+
+ /* We rely on the extension to check that DGA is available */
+
+ w = pScrn->currentMode->HDisplay;
+ h = pScrn->currentMode->VDisplay;
+ p = pad_to_int32(pScrn->displayWidth * bits_to_bytes(pScrn->bitsPerPixel));
+
+ for (i = 0; i < pScreenPriv->numModes; i++) {
+ mode = &(pScreenPriv->modes[i]);
+
+ if ((mode->viewportWidth == w) && (mode->viewportHeight == h) &&
+ (mode->bytesPerScanline == p) &&
+ (mode->bitsPerPixel == pScrn->bitsPerPixel) &&
+ (mode->depth == pScrn->depth)) {
+
+ return mode->num;
+ }
+ }
+
+ return 0;
}
static void
DGAHandleEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device)
{
- DGAEvent *event= &ev->dga_event;
- ScreenPtr pScreen = screenInfo.screens[screen_num];
- DGAScreenPtr pScreenPriv;
+ DGAEvent *event = &ev->dga_event;
+ ScreenPtr pScreen = screenInfo.screens[screen_num];
+ DGAScreenPtr pScreenPriv;
/* no DGA */
if (!DGAScreenKeyRegistered || XDGAEventBase == 0)
- return;
+ return;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
/* DGA not initialized on this screen */
if (!pScreenPriv)
- return;
+ return;
if (!IsMaster(device))
- return;
+ return;
switch (event->subtype) {
case KeyPress:
case KeyRelease:
- DGAProcessKeyboardEvent (pScreen, event, device);
- break;
+ DGAProcessKeyboardEvent(pScreen, event, device);
+ break;
case MotionNotify:
case ButtonPress:
case ButtonRelease:
- DGAProcessPointerEvent (pScreen, event, device);
+ DGAProcessPointerEvent(pScreen, event, device);
break;
default:
- break;
+ break;
}
}
diff --git a/xorg-server/hw/xfree86/common/xf86Events.c b/xorg-server/hw/xfree86/common/xf86Events.c
index 41ffabde3..058057e92 100644
--- a/xorg-server/hw/xfree86/common/xf86Events.c
+++ b/xorg-server/hw/xfree86/common/xf86Events.c
@@ -93,15 +93,15 @@
* This has been generalised to work with Linux and *BSD+syscons (DHD)
*/
-Bool VTSwitchEnabled = TRUE; /* Allows run-time disabling for
- *BSD and for avoiding VT
- switches when using the DRI
- automatic full screen mode.*/
+Bool VTSwitchEnabled = TRUE; /* Allows run-time disabling for
+ *BSD and for avoiding VT
+ switches when using the DRI
+ automatic full screen mode.*/
extern fd_set EnabledDevices;
#ifdef XF86PM
-extern void (*xf86OSPMClose)(void);
+extern void (*xf86OSPMClose) (void);
#endif
static void xf86VTSwitch(void);
@@ -111,16 +111,15 @@ static void xf86VTSwitch(void);
* Wakeup handler.
*/
typedef struct x_IHRec {
- int fd;
- InputHandlerProc ihproc;
- pointer data;
- Bool enabled;
- struct x_IHRec * next;
+ int fd;
+ InputHandlerProc ihproc;
+ pointer data;
+ Bool enabled;
+ struct x_IHRec *next;
} IHRec, *IHPtr;
static IHPtr InputHandlers = NULL;
-
Bool
LegalModifier(unsigned int key, DeviceIntPtr pDev)
{
@@ -135,10 +134,10 @@ LegalModifier(unsigned int key, DeviceIntPtr pDev)
int
TimeSinceLastInputEvent(void)
{
- if (xf86Info.lastEventTime == 0) {
- xf86Info.lastEventTime = GetTimeInMillis();
- }
- return GetTimeInMillis() - xf86Info.lastEventTime;
+ if (xf86Info.lastEventTime == 0) {
+ xf86Info.lastEventTime = GetTimeInMillis();
+ }
+ return GetTimeInMillis() - xf86Info.lastEventTime;
}
/*
@@ -148,7 +147,7 @@ TimeSinceLastInputEvent(void)
void
SetTimeSinceLastInputEvent(void)
{
- xf86Info.lastEventTime = GetTimeInMillis();
+ xf86Info.lastEventTime = GetTimeInMillis();
}
/*
@@ -158,15 +157,16 @@ SetTimeSinceLastInputEvent(void)
* and keyboard.
*/
void
-ProcessInputEvents (void)
+ProcessInputEvents(void)
{
- int x, y;
+ int x, y;
+
+ mieqProcessInputEvents();
- mieqProcessInputEvents();
+ /* FIXME: This is a problem if we have multiple pointers */
+ miPointerGetPosition(inputInfo.pointer, &x, &y);
- /* FIXME: This is a problem if we have multiple pointers */
- miPointerGetPosition(inputInfo.pointer, &x, &y);
- xf86SetViewport(xf86Info.currentScreen, x, y);
+ xf86SetViewport(xf86Info.currentScreen, x, y);
}
/*
@@ -179,57 +179,57 @@ xf86ProcessActionEvent(ActionEvent action, void *arg)
DebugF("ProcessActionEvent(%d,%x)\n", (int) action, arg);
switch (action) {
case ACTION_TERMINATE:
- if (!xf86Info.dontZap) {
+ if (!xf86Info.dontZap) {
#ifdef XFreeXDGA
- DGAShutdown();
+ DGAShutdown();
#endif
- GiveUp(0);
- }
- break;
+ GiveUp(0);
+ }
+ break;
case ACTION_NEXT_MODE:
- if (!xf86Info.dontZoom)
- xf86ZoomViewport(xf86Info.currentScreen, 1);
- break;
+ if (!xf86Info.dontZoom)
+ xf86ZoomViewport(xf86Info.currentScreen, 1);
+ break;
case ACTION_PREV_MODE:
- if (!xf86Info.dontZoom)
- xf86ZoomViewport(xf86Info.currentScreen, -1);
- break;
+ if (!xf86Info.dontZoom)
+ xf86ZoomViewport(xf86Info.currentScreen, -1);
+ break;
case ACTION_SWITCHSCREEN:
- if (VTSwitchEnabled && !xf86Info.dontVTSwitch && arg) {
- int vtno = *((int *) arg);
-
- if (vtno != xf86Info.vtno) {
- if (!xf86VTActivate(vtno)) {
- ErrorF("Failed to switch from vt%02d to vt%02d: %s\n",
- xf86Info.vtno, vtno, strerror(errno));
- }
- }
- }
- break;
+ if (VTSwitchEnabled && !xf86Info.dontVTSwitch && arg) {
+ int vtno = *((int *) arg);
+
+ if (vtno != xf86Info.vtno) {
+ if (!xf86VTActivate(vtno)) {
+ ErrorF("Failed to switch from vt%02d to vt%02d: %s\n",
+ xf86Info.vtno, vtno, strerror(errno));
+ }
+ }
+ }
+ break;
case ACTION_SWITCHSCREEN_NEXT:
- if (VTSwitchEnabled && !xf86Info.dontVTSwitch) {
- if (!xf86VTActivate(xf86Info.vtno + 1)) {
- /* If first try failed, assume this is the last VT and
- * try wrapping around to the first vt.
- */
- if (!xf86VTActivate(1)) {
- ErrorF("Failed to switch from vt%02d to next vt: %s\n",
- xf86Info.vtno, strerror(errno));
- }
- }
- }
- break;
+ if (VTSwitchEnabled && !xf86Info.dontVTSwitch) {
+ if (!xf86VTActivate(xf86Info.vtno + 1)) {
+ /* If first try failed, assume this is the last VT and
+ * try wrapping around to the first vt.
+ */
+ if (!xf86VTActivate(1)) {
+ ErrorF("Failed to switch from vt%02d to next vt: %s\n",
+ xf86Info.vtno, strerror(errno));
+ }
+ }
+ }
+ break;
case ACTION_SWITCHSCREEN_PREV:
- if (VTSwitchEnabled && !xf86Info.dontVTSwitch && xf86Info.vtno > 0) {
- if (!xf86VTActivate(xf86Info.vtno - 1)) {
- /* Don't know what the maximum VT is, so can't wrap around */
- ErrorF("Failed to switch from vt%02d to previous vt: %s\n",
- xf86Info.vtno, strerror(errno));
- }
- }
- break;
+ if (VTSwitchEnabled && !xf86Info.dontVTSwitch && xf86Info.vtno > 0) {
+ if (!xf86VTActivate(xf86Info.vtno - 1)) {
+ /* Don't know what the maximum VT is, so can't wrap around */
+ ErrorF("Failed to switch from vt%02d to previous vt: %s\n",
+ xf86Info.vtno, strerror(errno));
+ }
+ }
+ break;
default:
- break;
+ break;
}
}
@@ -242,49 +242,49 @@ xf86ProcessActionEvent(ActionEvent action, void *arg)
void
xf86Wakeup(pointer blockData, int err, pointer pReadmask)
{
- fd_set* LastSelectMask = (fd_set*)pReadmask;
+ fd_set *LastSelectMask = (fd_set *) pReadmask;
fd_set devicesWithInput;
InputInfoPtr pInfo;
if (err >= 0) {
- XFD_ANDSET(&devicesWithInput, LastSelectMask, &EnabledDevices);
- if (XFD_ANYSET(&devicesWithInput)) {
- pInfo = xf86InputDevs;
- while (pInfo) {
- if (pInfo->read_input && pInfo->fd >= 0 &&
- (FD_ISSET(pInfo->fd, &devicesWithInput) != 0)) {
- int sigstate = xf86BlockSIGIO();
-
- /*
- * Remove the descriptior from the set because more than one
- * device may share the same file descriptor.
- */
- FD_CLR(pInfo->fd, &devicesWithInput);
-
- pInfo->read_input(pInfo);
- xf86UnblockSIGIO(sigstate);
- }
- pInfo = pInfo->next;
- }
- }
+ XFD_ANDSET(&devicesWithInput, LastSelectMask, &EnabledDevices);
+ if (XFD_ANYSET(&devicesWithInput)) {
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ if (pInfo->read_input && pInfo->fd >= 0 &&
+ (FD_ISSET(pInfo->fd, &devicesWithInput) != 0)) {
+ int sigstate = xf86BlockSIGIO();
+
+ /*
+ * Remove the descriptior from the set because more than one
+ * device may share the same file descriptor.
+ */
+ FD_CLR(pInfo->fd, &devicesWithInput);
+
+ pInfo->read_input(pInfo);
+ xf86UnblockSIGIO(sigstate);
+ }
+ pInfo = pInfo->next;
+ }
+ }
}
- if (err >= 0) { /* we don't want the handlers called if select() */
- IHPtr ih; /* returned with an error condition, do we? */
-
- for (ih = InputHandlers; ih; ih = ih->next) {
- if (ih->enabled && ih->fd >= 0 && ih->ihproc &&
- (FD_ISSET(ih->fd, ((fd_set *)pReadmask)) != 0)) {
- ih->ihproc(ih->fd, ih->data);
- }
- }
+ if (err >= 0) { /* we don't want the handlers called if select() */
+ IHPtr ih; /* returned with an error condition, do we? */
+
+ for (ih = InputHandlers; ih; ih = ih->next) {
+ if (ih->enabled && ih->fd >= 0 && ih->ihproc &&
+ (FD_ISSET(ih->fd, ((fd_set *) pReadmask)) != 0)) {
+ ih->ihproc(ih->fd, ih->data);
+ }
+ }
}
- if (xf86VTSwitchPending()) xf86VTSwitch();
+ if (xf86VTSwitchPending())
+ xf86VTSwitch();
}
-
/*
* xf86SigioReadInput --
* signal handler for the SIGIO signal.
@@ -307,8 +307,8 @@ xf86SigioReadInput(int fd, void *closure)
void
xf86AddEnabledDevice(InputInfoPtr pInfo)
{
- if (!xf86InstallSIGIOHandler (pInfo->fd, xf86SigioReadInput, pInfo)) {
- AddEnabledDevice(pInfo->fd);
+ if (!xf86InstallSIGIOHandler(pInfo->fd, xf86SigioReadInput, pInfo)) {
+ AddEnabledDevice(pInfo->fd);
}
}
@@ -319,8 +319,8 @@ xf86AddEnabledDevice(InputInfoPtr pInfo)
void
xf86RemoveEnabledDevice(InputInfoPtr pInfo)
{
- if (!xf86RemoveSIGIOHandler (pInfo->fd)) {
- RemoveEnabledDevice(pInfo->fd);
+ if (!xf86RemoveSIGIOHandler(pInfo->fd)) {
+ RemoveEnabledDevice(pInfo->fd);
}
}
@@ -330,13 +330,13 @@ void
xf86InterceptSignals(int *signo)
{
if ((xf86SignalIntercept = signo))
- *signo = -1;
+ *signo = -1;
}
-static void (*xf86SigIllHandler)(void) = NULL;
+static void (*xf86SigIllHandler) (void) = NULL;
void
-xf86InterceptSigIll(void (*sigillhandler)(void))
+xf86InterceptSigIll(void (*sigillhandler) (void))
{
xf86SigIllHandler = sigillhandler;
}
@@ -348,18 +348,18 @@ xf86InterceptSigIll(void (*sigillhandler)(void))
int
xf86SigWrapper(int signo)
{
- if ((signo == SIGILL) && xf86SigIllHandler) {
- (*xf86SigIllHandler)();
- return 0; /* continue */
- }
-
- if (xf86SignalIntercept && (*xf86SignalIntercept < 0)) {
- *xf86SignalIntercept = signo;
- return 0; /* continue */
- }
-
- xf86Info.caughtSignal = TRUE;
- return 1; /* abort */
+ if ((signo == SIGILL) && xf86SigIllHandler) {
+ (*xf86SigIllHandler) ();
+ return 0; /* continue */
+ }
+
+ if (xf86SignalIntercept && (*xf86SignalIntercept < 0)) {
+ *xf86SignalIntercept = signo;
+ return 0; /* continue */
+ }
+
+ xf86Info.caughtSignal = TRUE;
+ return 1; /* abort */
}
/*
@@ -395,10 +395,9 @@ xf86ReleaseKeys(DeviceIntPtr pDev)
*/
for (i = keyc->xkbInfo->desc->min_key_code;
- i < keyc->xkbInfo->desc->max_key_code;
- i++) {
+ i < keyc->xkbInfo->desc->max_key_code; i++) {
if (key_is_down(pDev, i, KEY_POSTED)) {
- sigstate = xf86BlockSIGIO ();
+ sigstate = xf86BlockSIGIO();
QueueKeyboardEvents(pDev, KeyRelease, i, NULL);
xf86UnblockSIGIO(sigstate);
}
@@ -412,142 +411,144 @@ xf86ReleaseKeys(DeviceIntPtr pDev)
static void
xf86VTSwitch(void)
{
- int i;
- static int prevSIGIO;
- InputInfoPtr pInfo;
- IHPtr ih;
+ int i;
+ static int prevSIGIO;
+ InputInfoPtr pInfo;
+ IHPtr ih;
- DebugF("xf86VTSwitch()\n");
+ DebugF("xf86VTSwitch()\n");
#ifdef XFreeXDGA
- if(!DGAVTSwitch())
- return;
+ if (!DGAVTSwitch())
+ return;
#endif
- /*
- * Since all screens are currently all in the same state it is sufficient
- * check the first. This might change in future.
- */
- if (xf86Screens[0]->vtSema) {
+ /*
+ * Since all screens are currently all in the same state it is sufficient
+ * check the first. This might change in future.
+ */
+ if (xf86Screens[0]->vtSema) {
- DebugF("xf86VTSwitch: Leaving, xf86Exiting is %s\n",
- BOOLTOSTRING((dispatchException & DE_TERMINATE) ? TRUE : FALSE));
+ DebugF("xf86VTSwitch: Leaving, xf86Exiting is %s\n",
+ BOOLTOSTRING((dispatchException & DE_TERMINATE) ? TRUE : FALSE));
#ifdef DPMSExtension
- if (DPMSPowerLevel != DPMSModeOn)
- DPMSSet(serverClient, DPMSModeOn);
+ if (DPMSPowerLevel != DPMSModeOn)
+ DPMSSet(serverClient, DPMSModeOn);
#endif
- for (i = 0; i < xf86NumScreens; i++) {
- if (!(dispatchException & DE_TERMINATE))
- if (xf86Screens[i]->EnableDisableFBAccess)
- (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE);
- }
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (!(dispatchException & DE_TERMINATE))
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE);
+ }
- /*
- * Keep the order: Disable Device > LeaveVT
- * EnterVT > EnableDevice
- */
- for (ih = InputHandlers; ih; ih = ih->next)
- xf86DisableInputHandler(ih);
- for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next) {
- if (pInfo->dev) {
- xf86ReleaseKeys(pInfo->dev);
- ProcessInputEvents();
- DisableDevice(pInfo->dev, TRUE);
- }
- }
+ /*
+ * Keep the order: Disable Device > LeaveVT
+ * EnterVT > EnableDevice
+ */
+ for (ih = InputHandlers; ih; ih = ih->next)
+ xf86DisableInputHandler(ih);
+ for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next) {
+ if (pInfo->dev) {
+ xf86ReleaseKeys(pInfo->dev);
+ ProcessInputEvents();
+ DisableDevice(pInfo->dev, TRUE);
+ }
+ }
+
+ prevSIGIO = xf86BlockSIGIO();
+ for (i = 0; i < xf86NumScreens; i++)
+ xf86Screens[i]->LeaveVT(i, 0);
+
+ xf86AccessLeave(); /* We need this here, otherwise */
+
+ if (!xf86VTSwitchAway()) {
+ /*
+ * switch failed
+ */
+
+ DebugF("xf86VTSwitch: Leave failed\n");
+ xf86AccessEnter();
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (!xf86Screens[i]->EnterVT(i, 0))
+ FatalError("EnterVT failed for screen %d\n", i);
+ }
+ if (!(dispatchException & DE_TERMINATE)) {
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
+ }
+ }
+ dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
+
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ if (pInfo->dev)
+ EnableDevice(pInfo->dev, TRUE);
+ pInfo = pInfo->next;
+ }
+ for (ih = InputHandlers; ih; ih = ih->next)
+ xf86EnableInputHandler(ih);
+
+ xf86UnblockSIGIO(prevSIGIO);
- prevSIGIO = xf86BlockSIGIO();
- for (i = 0; i < xf86NumScreens; i++)
- xf86Screens[i]->LeaveVT(i, 0);
-
- xf86AccessLeave(); /* We need this here, otherwise */
-
- if (!xf86VTSwitchAway()) {
- /*
- * switch failed
- */
-
- DebugF("xf86VTSwitch: Leave failed\n");
- xf86AccessEnter();
- for (i = 0; i < xf86NumScreens; i++) {
- if (!xf86Screens[i]->EnterVT(i, 0))
- FatalError("EnterVT failed for screen %d\n", i);
- }
- if (!(dispatchException & DE_TERMINATE)) {
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->EnableDisableFBAccess)
- (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
- }
- }
- dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
-
- pInfo = xf86InputDevs;
- while (pInfo) {
- if (pInfo->dev)
- EnableDevice(pInfo->dev, TRUE);
- pInfo = pInfo->next;
- }
- for (ih = InputHandlers; ih; ih = ih->next)
- xf86EnableInputHandler(ih);
-
- xf86UnblockSIGIO(prevSIGIO);
-
- } else {
+ }
+ else {
#ifdef XF86PM
- if (xf86OSPMClose)
- xf86OSPMClose();
- xf86OSPMClose = NULL;
+ if (xf86OSPMClose)
+ xf86OSPMClose();
+ xf86OSPMClose = NULL;
#endif
- for (i = 0; i < xf86NumScreens; i++) {
- /*
- * zero all access functions to
- * trap calls when switched away.
- */
- xf86Screens[i]->vtSema = FALSE;
- }
- if (xorgHWAccess)
- xf86DisableIO();
+ for (i = 0; i < xf86NumScreens; i++) {
+ /*
+ * zero all access functions to
+ * trap calls when switched away.
+ */
+ xf86Screens[i]->vtSema = FALSE;
+ }
+ if (xorgHWAccess)
+ xf86DisableIO();
+ }
}
- } else {
- DebugF("xf86VTSwitch: Entering\n");
- if (!xf86VTSwitchTo()) return;
+ else {
+ DebugF("xf86VTSwitch: Entering\n");
+ if (!xf86VTSwitchTo())
+ return;
#ifdef XF86PM
- xf86OSPMClose = xf86OSPMOpen();
+ xf86OSPMClose = xf86OSPMOpen();
#endif
- if (xorgHWAccess)
- xf86EnableIO();
- xf86AccessEnter();
- for (i = 0; i < xf86NumScreens; i++) {
- xf86Screens[i]->vtSema = TRUE;
- if (!xf86Screens[i]->EnterVT(i, 0))
- FatalError("EnterVT failed for screen %d\n", i);
- }
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->EnableDisableFBAccess)
- (*xf86Screens[i]->EnableDisableFBAccess)(i, TRUE);
- }
+ if (xorgHWAccess)
+ xf86EnableIO();
+ xf86AccessEnter();
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86Screens[i]->vtSema = TRUE;
+ if (!xf86Screens[i]->EnterVT(i, 0))
+ FatalError("EnterVT failed for screen %d\n", i);
+ }
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
+ }
- /* Turn screen saver off when switching back */
- dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
+ /* Turn screen saver off when switching back */
+ dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
- pInfo = xf86InputDevs;
- while (pInfo) {
- if (pInfo->dev)
- EnableDevice(pInfo->dev, TRUE);
- pInfo = pInfo->next;
- }
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ if (pInfo->dev)
+ EnableDevice(pInfo->dev, TRUE);
+ pInfo = pInfo->next;
+ }
- for (ih = InputHandlers; ih; ih = ih->next)
- xf86EnableInputHandler(ih);
+ for (ih = InputHandlers; ih; ih = ih->next)
+ xf86EnableInputHandler(ih);
- xf86UnblockSIGIO(prevSIGIO);
- }
+ xf86UnblockSIGIO(prevSIGIO);
+ }
}
-
/* Input handler registration */
static pointer
@@ -556,11 +557,11 @@ addInputHandler(int fd, InputHandlerProc proc, pointer data)
IHPtr ih;
if (fd < 0 || !proc)
- return NULL;
+ return NULL;
ih = calloc(sizeof(*ih), 1);
if (!ih)
- return NULL;
+ return NULL;
ih->fd = fd;
ih->ihproc = proc;
@@ -618,13 +619,13 @@ removeInputHandler(IHPtr ih)
IHPtr p;
if (ih == InputHandlers)
- InputHandlers = ih->next;
+ InputHandlers = ih->next;
else {
- p = InputHandlers;
- while (p && p->next != ih)
- p = p->next;
- if (ih)
- p->next = ih->next;
+ p = InputHandlers;
+ while (p && p->next != ih)
+ p = p->next;
+ if (ih)
+ p->next = ih->next;
}
free(ih);
}
@@ -636,13 +637,13 @@ xf86RemoveInputHandler(pointer handler)
int fd;
if (!handler)
- return -1;
+ return -1;
ih = handler;
fd = ih->fd;
if (ih->fd >= 0)
- RemoveEnabledDevice(ih->fd);
+ RemoveEnabledDevice(ih->fd);
removeInputHandler(ih);
return fd;
@@ -655,13 +656,13 @@ xf86RemoveGeneralHandler(pointer handler)
int fd;
if (!handler)
- return -1;
+ return -1;
ih = handler;
fd = ih->fd;
if (ih->fd >= 0)
- RemoveGeneralSocket(ih->fd);
+ RemoveGeneralSocket(ih->fd);
removeInputHandler(ih);
return fd;
@@ -673,12 +674,12 @@ xf86DisableInputHandler(pointer handler)
IHPtr ih;
if (!handler)
- return;
+ return;
ih = handler;
ih->enabled = FALSE;
if (ih->fd >= 0)
- RemoveEnabledDevice(ih->fd);
+ RemoveEnabledDevice(ih->fd);
}
void
@@ -687,12 +688,12 @@ xf86DisableGeneralHandler(pointer handler)
IHPtr ih;
if (!handler)
- return;
+ return;
ih = handler;
ih->enabled = FALSE;
if (ih->fd >= 0)
- RemoveGeneralSocket(ih->fd);
+ RemoveGeneralSocket(ih->fd);
}
void
@@ -701,12 +702,12 @@ xf86EnableInputHandler(pointer handler)
IHPtr ih;
if (!handler)
- return;
+ return;
ih = handler;
ih->enabled = TRUE;
if (ih->fd >= 0)
- AddEnabledDevice(ih->fd);
+ AddEnabledDevice(ih->fd);
}
void
@@ -715,12 +716,12 @@ xf86EnableGeneralHandler(pointer handler)
IHPtr ih;
if (!handler)
- return;
+ return;
ih = handler;
ih->enabled = TRUE;
if (ih->fd >= 0)
- AddGeneralSocket(ih->fd);
+ AddGeneralSocket(ih->fd);
}
/*
@@ -734,17 +735,19 @@ xf86EnableVTSwitch(Bool new)
old = VTSwitchEnabled;
if (!new) {
- /* Disable VT switching */
- def = VTSwitchEnabled;
- VTSwitchEnabled = FALSE;
- } else {
- /* Restore VT switching to default */
- VTSwitchEnabled = def;
+ /* Disable VT switching */
+ def = VTSwitchEnabled;
+ VTSwitchEnabled = FALSE;
+ }
+ else {
+ /* Restore VT switching to default */
+ VTSwitchEnabled = def;
}
return old;
}
void
-DDXRingBell(int volume, int pitch, int duration) {
+DDXRingBell(int volume, int pitch, int duration)
+{
xf86OSRingBell(volume, pitch, duration);
}
diff --git a/xorg-server/hw/xfree86/common/xf86Globals.c b/xorg-server/hw/xfree86/common/xf86Globals.c
index d576fb915..0071004eb 100644
--- a/xorg-server/hw/xfree86/common/xf86Globals.c
+++ b/xorg-server/hw/xfree86/common/xf86Globals.c
@@ -50,9 +50,9 @@
DevPrivateKeyRec xf86CreateRootWindowKeyRec;
DevPrivateKeyRec xf86ScreenKeyRec;
-ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */
-const unsigned char byte_reversed[256] =
-{
+ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */
+
+const unsigned char byte_reversed[256] = {
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
@@ -90,49 +90,49 @@ const unsigned char byte_reversed[256] =
/* Globals that input drivers may access */
InputInfoPtr xf86InputDevs = NULL;
-
/* Globals that video drivers may not access */
xf86InfoRec xf86Info = {
- .consoleFd = -1,
- .vtno = -1,
- .lastEventTime = -1,
- .vtRequestsPending = FALSE,
+ .consoleFd = -1,
+ .vtno = -1,
+ .lastEventTime = -1,
+ .vtRequestsPending = FALSE,
#ifdef sun
- .vtPendingNum = -1,
+ .vtPendingNum = -1,
#endif
- .dontVTSwitch = FALSE,
- .autoVTSwitch = TRUE,
- .ShareVTs = FALSE,
- .dontZap = FALSE,
- .dontZoom = FALSE,
- .notrapSignals = FALSE,
- .caughtSignal = FALSE,
- .currentScreen = NULL,
+ .dontVTSwitch = FALSE,
+ .autoVTSwitch = TRUE,
+ .ShareVTs = FALSE,
+ .dontZap = FALSE,
+ .dontZoom = FALSE,
+ .notrapSignals = FALSE,
+ .caughtSignal = FALSE,
+ .currentScreen = NULL,
#ifdef CSRG_BASED
- .consType = -1,
+ .consType = -1,
#endif
- .allowMouseOpenFail = FALSE,
- .vidModeEnabled = TRUE,
- .vidModeAllowNonLocal = FALSE,
- .miscModInDevEnabled = TRUE,
- .miscModInDevAllowNonLocal = FALSE,
- .pixmap24 = Pix24DontCare,
- .pix24From = X_DEFAULT,
- .pmFlag = TRUE,
- .log = LogNone,
- .disableRandR = FALSE,
- .randRFrom = X_DEFAULT,
+ .allowMouseOpenFail = FALSE,
+ .vidModeEnabled = TRUE,
+ .vidModeAllowNonLocal = FALSE,
+ .miscModInDevEnabled = TRUE,
+ .miscModInDevAllowNonLocal = FALSE,
+ .pixmap24 = Pix24DontCare,
+ .pix24From = X_DEFAULT,
+ .pmFlag = TRUE,
+ .log = LogNone,
+ .disableRandR = FALSE,
+ .randRFrom = X_DEFAULT,
#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS)
- .forceInputDevices = FALSE,
- .autoAddDevices = TRUE,
- .autoEnableDevices = TRUE
+ .forceInputDevices = FALSE,
+ .autoAddDevices = TRUE,
+ .autoEnableDevices = TRUE
#else
- .forceInputDevices = TRUE,
- .autoAddDevices = FALSE,
- .autoEnableDevices = FALSE
+ .forceInputDevices = TRUE,
+ .autoAddDevices = FALSE,
+ .autoEnableDevices = FALSE
#endif
};
+
const char *xf86ConfigFile = NULL;
const char *xf86ConfigDir = NULL;
const char *xf86ModulePath = DEFAULT_MODULE_PATH;
@@ -140,8 +140,9 @@ MessageType xf86ModPathFrom = X_DEFAULT;
const char *xf86LogFile = DEFAULT_LOGPREFIX;
MessageType xf86LogFileFrom = X_DEFAULT;
Bool xf86LogFileWasOpened = FALSE;
-serverLayoutRec xf86ConfigLayout = {NULL, };
-confDRIRec xf86ConfigDRI = {0, };
+serverLayoutRec xf86ConfigLayout = { NULL, };
+confDRIRec xf86ConfigDRI = { 0, };
+
XF86ConfigPtr xf86configptr = NULL;
Bool xf86Resetting = FALSE;
Bool xf86Initialising = FALSE;
@@ -154,12 +155,12 @@ int xf86NumInputDrivers = 0;
int xf86NumScreens = 0;
const char *xf86VisualNames[] = {
- "StaticGray",
- "GrayScale",
- "StaticColor",
- "PseudoColor",
- "TrueColor",
- "DirectColor"
+ "StaticGray",
+ "GrayScale",
+ "StaticColor",
+ "PseudoColor",
+ "TrueColor",
+ "DirectColor"
};
/* Parameters set only from the command line */
@@ -170,6 +171,7 @@ Bool xf86bsEnableFlag = FALSE;
Bool xf86bsDisableFlag = FALSE;
Bool xf86silkenMouseDisableFlag = FALSE;
Bool xf86xkbdirFlag = FALSE;
+
#ifdef HAVE_ACPI
Bool xf86acpiDisableFlag = FALSE;
#endif
@@ -182,10 +184,13 @@ int xf86LogVerbose = DEFAULT_LOG_VERBOSE;
int xf86FbBpp = -1;
Pix24Flags xf86Pix24 = Pix24DontCare;
int xf86Depth = -1;
-rgb xf86Weight = {0, 0, 0};
+rgb xf86Weight = { 0, 0, 0 };
+
Bool xf86FlipPixels = FALSE;
-Gamma xf86Gamma = {0.0, 0.0, 0.0};
+Gamma xf86Gamma = { 0.0, 0.0, 0.0 };
+
Bool xf86AllowMouseOpenFail = FALSE;
+
#ifdef XF86VIDMODE
Bool xf86VidModeDisabled = FALSE;
Bool xf86VidModeAllowNonLocal = FALSE;
diff --git a/xorg-server/hw/xfree86/common/xf86Helper.c b/xorg-server/hw/xfree86/common/xf86Helper.c
index 248ccf47e..8c948cf6f 100644
--- a/xorg-server/hw/xfree86/common/xf86Helper.c
+++ b/xorg-server/hw/xfree86/common/xf86Helper.c
@@ -64,7 +64,6 @@
static int xf86ScrnInfoPrivateCount = 0;
-
/* Add a pointer to a new DriverRec to xf86DriverList */
void
@@ -72,22 +71,21 @@ xf86AddDriver(DriverPtr driver, pointer module, int flags)
{
/* Don't add null entries */
if (!driver)
- return;
+ return;
if (xf86DriverList == NULL)
- xf86NumDrivers = 0;
+ xf86NumDrivers = 0;
xf86NumDrivers++;
xf86DriverList = xnfrealloc(xf86DriverList,
- xf86NumDrivers * sizeof(DriverPtr));
+ xf86NumDrivers * sizeof(DriverPtr));
xf86DriverList[xf86NumDrivers - 1] = xnfalloc(sizeof(DriverRec));
if (flags & HaveDriverFuncs)
- *xf86DriverList[xf86NumDrivers - 1] = *driver;
+ *xf86DriverList[xf86NumDrivers - 1] = *driver;
else {
- (void) memset( xf86DriverList[xf86NumDrivers - 1], 0,
- sizeof( DriverRec ) );
- (void) memcpy( xf86DriverList[xf86NumDrivers - 1], driver,
- sizeof(DriverRec1));
+ (void) memset(xf86DriverList[xf86NumDrivers - 1], 0, sizeof(DriverRec));
+ (void) memcpy(xf86DriverList[xf86NumDrivers - 1], driver,
+ sizeof(DriverRec1));
}
xf86DriverList[xf86NumDrivers - 1]->module = module;
@@ -98,11 +96,11 @@ void
xf86DeleteDriver(int drvIndex)
{
if (xf86DriverList[drvIndex]
- && (!xf86DriverHasEntities(xf86DriverList[drvIndex]))) {
- if (xf86DriverList[drvIndex]->module)
- UnloadModule(xf86DriverList[drvIndex]->module);
- free(xf86DriverList[drvIndex]);
- xf86DriverList[drvIndex] = NULL;
+ && (!xf86DriverHasEntities(xf86DriverList[drvIndex]))) {
+ if (xf86DriverList[drvIndex]->module)
+ UnloadModule(xf86DriverList[drvIndex]->module);
+ free(xf86DriverList[drvIndex]);
+ xf86DriverList[drvIndex] = NULL;
}
}
@@ -113,16 +111,17 @@ xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags)
{
/* Don't add null entries */
if (!driver)
- return;
+ return;
if (xf86InputDriverList == NULL)
- xf86NumInputDrivers = 0;
+ xf86NumInputDrivers = 0;
xf86NumInputDrivers++;
xf86InputDriverList = xnfrealloc(xf86InputDriverList,
- xf86NumInputDrivers * sizeof(InputDriverPtr));
+ xf86NumInputDrivers *
+ sizeof(InputDriverPtr));
xf86InputDriverList[xf86NumInputDrivers - 1] =
- xnfalloc(sizeof(InputDriverRec));
+ xnfalloc(sizeof(InputDriverRec));
*xf86InputDriverList[xf86NumInputDrivers - 1] = *driver;
xf86InputDriverList[xf86NumInputDrivers - 1]->module = module;
}
@@ -131,7 +130,7 @@ void
xf86DeleteInputDriver(int drvIndex)
{
if (xf86InputDriverList[drvIndex] && xf86InputDriverList[drvIndex]->module)
- UnloadModule(xf86InputDriverList[drvIndex]->module);
+ UnloadModule(xf86InputDriverList[drvIndex]->module);
free(xf86InputDriverList[drvIndex]);
xf86InputDriverList[drvIndex] = NULL;
}
@@ -142,9 +141,9 @@ xf86LookupInputDriver(const char *name)
int i;
for (i = 0; i < xf86NumInputDrivers; i++) {
- if (xf86InputDriverList[i] && xf86InputDriverList[i]->driverName &&
- xf86NameCmp(name, xf86InputDriverList[i]->driverName) == 0)
- return xf86InputDriverList[i];
+ if (xf86InputDriverList[i] && xf86InputDriverList[i]->driverName &&
+ xf86NameCmp(name, xf86InputDriverList[i]->driverName) == 0)
+ return xf86InputDriverList[i];
}
return NULL;
}
@@ -170,15 +169,15 @@ xf86AllocateScreen(DriverPtr drv, int flags)
int i;
if (xf86Screens == NULL)
- xf86NumScreens = 0;
+ xf86NumScreens = 0;
i = xf86NumScreens++;
xf86Screens = xnfrealloc(xf86Screens, xf86NumScreens * sizeof(ScrnInfoPtr));
xf86Screens[i] = xnfcalloc(sizeof(ScrnInfoRec), 1);
- xf86Screens[i]->scrnIndex = i; /* Changes when a screen is removed */
- xf86Screens[i]->origIndex = i; /* This never changes */
+ xf86Screens[i]->scrnIndex = i; /* Changes when a screen is removed */
+ xf86Screens[i]->origIndex = i; /* This never changes */
xf86Screens[i]->privates = xnfcalloc(sizeof(DevUnion),
- xf86ScrnInfoPrivateCount);
+ xf86ScrnInfoPrivateCount);
/*
* EnableDisableFBAccess now gets initialized in InitOutput()
* xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess;
@@ -193,7 +192,6 @@ xf86AllocateScreen(DriverPtr drv, int flags)
return xf86Screens[i];
}
-
/*
* Remove an entry from xf86Screens. Ideally it should free all allocated
* data. To do this properly may require a driver hook.
@@ -207,31 +205,31 @@ xf86DeleteScreen(int scrnIndex, int flags)
/* First check if the screen is valid */
if (xf86NumScreens == 0 || xf86Screens == NULL)
- return;
+ return;
if (scrnIndex > xf86NumScreens - 1)
- return;
+ return;
if (!(pScrn = xf86Screens[scrnIndex]))
- return;
+ return;
/* If a FreeScreen function is defined, call it here */
if (pScrn->FreeScreen != NULL)
- pScrn->FreeScreen(scrnIndex, 0);
+ pScrn->FreeScreen(scrnIndex, 0);
while (pScrn->modes)
- xf86DeleteMode(&pScrn->modes, pScrn->modes);
+ xf86DeleteMode(&pScrn->modes, pScrn->modes);
while (pScrn->modePool)
- xf86DeleteMode(&pScrn->modePool, pScrn->modePool);
+ xf86DeleteMode(&pScrn->modePool, pScrn->modePool);
xf86OptionListFree(pScrn->options);
if (pScrn->module)
- UnloadModule(pScrn->module);
+ UnloadModule(pScrn->module);
if (pScrn->drv)
- pScrn->drv->refCount--;
+ pScrn->drv->refCount--;
free(pScrn->privates);
@@ -244,9 +242,9 @@ xf86DeleteScreen(int scrnIndex, int flags)
xf86NumScreens--;
for (i = scrnIndex; i < xf86NumScreens; i++) {
- xf86Screens[i] = xf86Screens[i + 1];
- xf86Screens[i]->scrnIndex = i;
- /* Also need to take care of the screen layout settings */
+ xf86Screens[i] = xf86Screens[i + 1];
+ xf86Screens[i]->scrnIndex = i;
+ /* Also need to take care of the screen layout settings */
}
}
@@ -263,12 +261,12 @@ xf86AllocateScrnInfoPrivateIndex(void)
idx = xf86ScrnInfoPrivateCount++;
for (i = 0; i < xf86NumScreens; i++) {
- pScr = xf86Screens[i];
- nprivs = xnfrealloc(pScr->privates,
- xf86ScrnInfoPrivateCount * sizeof(DevUnion));
- /* Zero the new private */
- memset(&nprivs[idx], 0, sizeof(DevUnion));
- pScr->privates = nprivs;
+ pScr = xf86Screens[i];
+ nprivs = xnfrealloc(pScr->privates,
+ xf86ScrnInfoPrivateCount * sizeof(DevUnion));
+ /* Zero the new private */
+ memset(&nprivs[idx], 0, sizeof(DevUnion));
+ pScr->privates = nprivs;
}
return idx;
}
@@ -279,22 +277,22 @@ xf86AddPixFormat(ScrnInfoPtr pScrn, int depth, int bpp, int pad)
int i;
if (pScrn->numFormats >= MAXFORMATS)
- return FALSE;
+ return FALSE;
if (bpp <= 0) {
- if (depth == 1)
- bpp = 1;
- else if (depth <= 8)
- bpp = 8;
- else if (depth <= 16)
- bpp = 16;
- else if (depth <= 32)
- bpp = 32;
- else
- return FALSE;
+ if (depth == 1)
+ bpp = 1;
+ else if (depth <= 8)
+ bpp = 8;
+ else if (depth <= 16)
+ bpp = 16;
+ else if (depth <= 32)
+ bpp = 32;
+ else
+ return FALSE;
}
if (pad <= 0)
- pad = BITMAP_SCANLINE_PAD;
+ pad = BITMAP_SCANLINE_PAD;
i = pScrn->numFormats++;
pScrn->formats[i].depth = depth;
@@ -346,7 +344,7 @@ xf86AddPixFormat(ScrnInfoPtr pScrn, int depth, int bpp, int pad)
Bool
xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int dummy, int fbbpp,
- int depth24flags)
+ int depth24flags)
{
int i;
DispPtr disp;
@@ -360,174 +358,182 @@ xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int dummy, int fbbpp,
scrp->depthFrom = X_DEFAULT;
if (xf86FbBpp > 0) {
- scrp->bitsPerPixel = xf86FbBpp;
- scrp->bitsPerPixelFrom = X_CMDLINE;
+ scrp->bitsPerPixel = xf86FbBpp;
+ scrp->bitsPerPixelFrom = X_CMDLINE;
}
if (xf86Depth > 0) {
- scrp->depth = xf86Depth;
- scrp->depthFrom = X_CMDLINE;
+ scrp->depth = xf86Depth;
+ scrp->depthFrom = X_CMDLINE;
}
if (xf86FbBpp < 0 && xf86Depth < 0) {
- if (scrp->confScreen->defaultfbbpp > 0) {
- scrp->bitsPerPixel = scrp->confScreen->defaultfbbpp;
- scrp->bitsPerPixelFrom = X_CONFIG;
- }
- if (scrp->confScreen->defaultdepth > 0) {
- scrp->depth = scrp->confScreen->defaultdepth;
- scrp->depthFrom = X_CONFIG;
- }
-
- if (scrp->confScreen->defaultfbbpp <= 0 &&
- scrp->confScreen->defaultdepth <= 0) {
- /*
- * Check for DefaultDepth and DefaultFbBpp options in the
- * Device sections.
- */
- int i;
- GDevPtr device;
- Bool found = FALSE;
-
- for (i = 0; i < scrp->numEntities; i++) {
- device = xf86GetDevFromEntity(scrp->entityList[i],
- scrp->entityInstanceList[i]);
- if (device && device->options) {
- if (xf86FindOption(device->options, "DefaultDepth")) {
- scrp->depth = xf86SetIntOption(device->options,
- "DefaultDepth", -1);
- scrp->depthFrom = X_CONFIG;
- found = TRUE;
- }
- if (xf86FindOption(device->options, "DefaultFbBpp")) {
- scrp->bitsPerPixel = xf86SetIntOption(device->options,
- "DefaultFbBpp",
- -1);
- scrp->bitsPerPixelFrom = X_CONFIG;
- found = TRUE;
- }
- }
- if (found)
- break;
- }
- }
+ if (scrp->confScreen->defaultfbbpp > 0) {
+ scrp->bitsPerPixel = scrp->confScreen->defaultfbbpp;
+ scrp->bitsPerPixelFrom = X_CONFIG;
+ }
+ if (scrp->confScreen->defaultdepth > 0) {
+ scrp->depth = scrp->confScreen->defaultdepth;
+ scrp->depthFrom = X_CONFIG;
+ }
+
+ if (scrp->confScreen->defaultfbbpp <= 0 &&
+ scrp->confScreen->defaultdepth <= 0) {
+ /*
+ * Check for DefaultDepth and DefaultFbBpp options in the
+ * Device sections.
+ */
+ int i;
+ GDevPtr device;
+ Bool found = FALSE;
+
+ for (i = 0; i < scrp->numEntities; i++) {
+ device = xf86GetDevFromEntity(scrp->entityList[i],
+ scrp->entityInstanceList[i]);
+ if (device && device->options) {
+ if (xf86FindOption(device->options, "DefaultDepth")) {
+ scrp->depth = xf86SetIntOption(device->options,
+ "DefaultDepth", -1);
+ scrp->depthFrom = X_CONFIG;
+ found = TRUE;
+ }
+ if (xf86FindOption(device->options, "DefaultFbBpp")) {
+ scrp->bitsPerPixel = xf86SetIntOption(device->options,
+ "DefaultFbBpp",
+ -1);
+ scrp->bitsPerPixelFrom = X_CONFIG;
+ found = TRUE;
+ }
+ }
+ if (found)
+ break;
+ }
+ }
}
/* If none of these is set, pick a default */
if (scrp->bitsPerPixel < 0 && scrp->depth < 0) {
if (fbbpp > 0 || depth > 0) {
- if (fbbpp > 0)
- scrp->bitsPerPixel = fbbpp;
- if (depth > 0)
- scrp->depth = depth;
- } else {
- scrp->depth = GLOBAL_DEFAULT_DEPTH;
- }
+ if (fbbpp > 0)
+ scrp->bitsPerPixel = fbbpp;
+ if (depth > 0)
+ scrp->depth = depth;
+ }
+ else {
+ scrp->depth = GLOBAL_DEFAULT_DEPTH;
+ }
}
/* If any are not given, determine a default for the others */
if (scrp->bitsPerPixel < 0) {
- /* The depth must be set */
- if (scrp->depth > -1) {
- if (scrp->depth == 1)
- scrp->bitsPerPixel = 1;
- else if (scrp->depth <= 4)
- scrp->bitsPerPixel = 4;
- else if (scrp->depth <= 8)
- scrp->bitsPerPixel = 8;
- else if (scrp->depth <= 16)
- scrp->bitsPerPixel = 16;
- else if (scrp->depth <= 24) {
- /*
- * Figure out if a choice is possible based on the depth24
- * and pix24 flags.
- */
- /* Check pix24 first */
- if (pix24 != Pix24DontCare) {
- if (pix24 == Pix24Use32) {
- if (DO_PIX32(depth24flags)) {
- if (CHOOSE24FOR32(depth24flags))
- scrp->bitsPerPixel = 24;
- else
- scrp->bitsPerPixel = 32;
- } else {
- nomatch = TRUE;
- }
- } else if (pix24 == Pix24Use24) {
- if (DO_PIX24(depth24flags)) {
- if (CHOOSE32FOR24(depth24flags))
- scrp->bitsPerPixel = 32;
- else
- scrp->bitsPerPixel = 24;
- } else {
- nomatch = TRUE;
- }
- }
- } else {
- if (DO_PIX32(depth24flags)) {
- if (CHOOSE24FOR32(depth24flags))
- scrp->bitsPerPixel = 24;
- else
- scrp->bitsPerPixel = 32;
- } else if (DO_PIX24(depth24flags)) {
- if (CHOOSE32FOR24(depth24flags))
- scrp->bitsPerPixel = 32;
- else
- scrp->bitsPerPixel = 24;
- }
- }
- } else if (scrp->depth <= 32)
- scrp->bitsPerPixel = 32;
- else {
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Specified depth (%d) is greater than 32\n",
- scrp->depth);
- return FALSE;
- }
- } else {
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "xf86SetDepthBpp: internal error: depth and fbbpp"
- " are both not set\n");
- return FALSE;
- }
- if (scrp->bitsPerPixel < 0) {
- if (nomatch)
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Driver can't support depth 24 pixmap format (%d)\n",
- PIX24TOBPP(pix24));
- else if ((depth24flags & (Support24bppFb | Support32bppFb)) ==
- NoDepth24Support)
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Driver can't support depth 24\n");
- else
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Can't find fbbpp for depth 24\n");
- return FALSE;
- }
- scrp->bitsPerPixelFrom = X_PROBED;
+ /* The depth must be set */
+ if (scrp->depth > -1) {
+ if (scrp->depth == 1)
+ scrp->bitsPerPixel = 1;
+ else if (scrp->depth <= 4)
+ scrp->bitsPerPixel = 4;
+ else if (scrp->depth <= 8)
+ scrp->bitsPerPixel = 8;
+ else if (scrp->depth <= 16)
+ scrp->bitsPerPixel = 16;
+ else if (scrp->depth <= 24) {
+ /*
+ * Figure out if a choice is possible based on the depth24
+ * and pix24 flags.
+ */
+ /* Check pix24 first */
+ if (pix24 != Pix24DontCare) {
+ if (pix24 == Pix24Use32) {
+ if (DO_PIX32(depth24flags)) {
+ if (CHOOSE24FOR32(depth24flags))
+ scrp->bitsPerPixel = 24;
+ else
+ scrp->bitsPerPixel = 32;
+ }
+ else {
+ nomatch = TRUE;
+ }
+ }
+ else if (pix24 == Pix24Use24) {
+ if (DO_PIX24(depth24flags)) {
+ if (CHOOSE32FOR24(depth24flags))
+ scrp->bitsPerPixel = 32;
+ else
+ scrp->bitsPerPixel = 24;
+ }
+ else {
+ nomatch = TRUE;
+ }
+ }
+ }
+ else {
+ if (DO_PIX32(depth24flags)) {
+ if (CHOOSE24FOR32(depth24flags))
+ scrp->bitsPerPixel = 24;
+ else
+ scrp->bitsPerPixel = 32;
+ }
+ else if (DO_PIX24(depth24flags)) {
+ if (CHOOSE32FOR24(depth24flags))
+ scrp->bitsPerPixel = 32;
+ else
+ scrp->bitsPerPixel = 24;
+ }
+ }
+ }
+ else if (scrp->depth <= 32)
+ scrp->bitsPerPixel = 32;
+ else {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Specified depth (%d) is greater than 32\n",
+ scrp->depth);
+ return FALSE;
+ }
+ }
+ else {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "xf86SetDepthBpp: internal error: depth and fbbpp"
+ " are both not set\n");
+ return FALSE;
+ }
+ if (scrp->bitsPerPixel < 0) {
+ if (nomatch)
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Driver can't support depth 24 pixmap format (%d)\n",
+ PIX24TOBPP(pix24));
+ else if ((depth24flags & (Support24bppFb | Support32bppFb)) ==
+ NoDepth24Support)
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Driver can't support depth 24\n");
+ else
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Can't find fbbpp for depth 24\n");
+ return FALSE;
+ }
+ scrp->bitsPerPixelFrom = X_PROBED;
}
if (scrp->depth <= 0) {
- /* bitsPerPixel is already set */
- switch (scrp->bitsPerPixel) {
- case 32:
- scrp->depth = 24;
- break;
- default:
- /* 1, 4, 8, 16 and 24 */
- scrp->depth = scrp->bitsPerPixel;
- break;
- }
- scrp->depthFrom = X_PROBED;
+ /* bitsPerPixel is already set */
+ switch (scrp->bitsPerPixel) {
+ case 32:
+ scrp->depth = 24;
+ break;
+ default:
+ /* 1, 4, 8, 16 and 24 */
+ scrp->depth = scrp->bitsPerPixel;
+ break;
+ }
+ scrp->depthFrom = X_PROBED;
}
/* Sanity checks */
if (scrp->depth < 1 || scrp->depth > 32) {
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Specified depth (%d) is not in the range 1-32\n",
- scrp->depth);
- return FALSE;
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Specified depth (%d) is not in the range 1-32\n",
+ scrp->depth);
+ return FALSE;
}
switch (scrp->bitsPerPixel) {
case 1:
@@ -536,26 +542,26 @@ xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int dummy, int fbbpp,
case 16:
case 24:
case 32:
- break;
+ break;
default:
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Specified fbbpp (%d) is not a permitted value\n",
- scrp->bitsPerPixel);
- return FALSE;
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Specified fbbpp (%d) is not a permitted value\n",
+ scrp->bitsPerPixel);
+ return FALSE;
}
if (scrp->depth > scrp->bitsPerPixel) {
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Specified depth (%d) is greater than the fbbpp (%d)\n",
- scrp->depth, scrp->bitsPerPixel);
- return FALSE;
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Specified depth (%d) is greater than the fbbpp (%d)\n",
+ scrp->depth, scrp->bitsPerPixel);
+ return FALSE;
}
/* set scrp->pixmap24 if the driver isn't flexible */
if (scrp->bitsPerPixel == 24 && !DO_PIX32FOR24(depth24flags)) {
- scrp->pixmap24 = Pix24Use24;
+ scrp->pixmap24 = Pix24Use24;
}
if (scrp->bitsPerPixel == 32 && !DO_PIX24FOR32(depth24flags)) {
- scrp->pixmap24 = Pix24Use32;
+ scrp->pixmap24 = Pix24Use32;
}
/*
@@ -563,13 +569,13 @@ xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int dummy, int fbbpp,
* scrp->display with it.
*/
for (i = 0, disp = scrp->confScreen->displays;
- i < scrp->confScreen->numdisplays; i++, disp++) {
- if ((disp->depth == scrp->depth && disp->fbbpp == scrp->bitsPerPixel)
- || (disp->depth == scrp->depth && disp->fbbpp <= 0)
- || (disp->fbbpp == scrp->bitsPerPixel && disp->depth <= 0)) {
- scrp->display = disp;
- break;
- }
+ i < scrp->confScreen->numdisplays; i++, disp++) {
+ if ((disp->depth == scrp->depth && disp->fbbpp == scrp->bitsPerPixel)
+ || (disp->depth == scrp->depth && disp->fbbpp <= 0)
+ || (disp->fbbpp == scrp->bitsPerPixel && disp->depth <= 0)) {
+ scrp->display = disp;
+ break;
+ }
}
/*
@@ -577,40 +583,40 @@ xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int dummy, int fbbpp,
* depth or fbbpp specified.
*/
if (i == scrp->confScreen->numdisplays) {
- for (i = 0, disp = scrp->confScreen->displays;
- i < scrp->confScreen->numdisplays; i++, disp++) {
- if (disp->depth <= 0 && disp->fbbpp <= 0) {
- scrp->display = disp;
- break;
- }
- }
+ for (i = 0, disp = scrp->confScreen->displays;
+ i < scrp->confScreen->numdisplays; i++, disp++) {
+ if (disp->depth <= 0 && disp->fbbpp <= 0) {
+ scrp->display = disp;
+ break;
+ }
+ }
}
/*
* If all else fails, create a default one.
*/
if (i == scrp->confScreen->numdisplays) {
- scrp->confScreen->numdisplays++;
- scrp->confScreen->displays =
- xnfrealloc(scrp->confScreen->displays,
- scrp->confScreen->numdisplays * sizeof(DispRec));
- xf86DrvMsg(scrp->scrnIndex, X_INFO,
- "Creating default Display subsection in Screen section\n"
- "\t\"%s\" for depth/fbbpp %d/%d\n",
- scrp->confScreen->id, scrp->depth, scrp->bitsPerPixel);
- memset(&scrp->confScreen->displays[i], 0, sizeof(DispRec));
- scrp->confScreen->displays[i].blackColour.red = -1;
- scrp->confScreen->displays[i].blackColour.green = -1;
- scrp->confScreen->displays[i].blackColour.blue = -1;
- scrp->confScreen->displays[i].whiteColour.red = -1;
- scrp->confScreen->displays[i].whiteColour.green = -1;
- scrp->confScreen->displays[i].whiteColour.blue = -1;
- scrp->confScreen->displays[i].defaultVisual = -1;
- scrp->confScreen->displays[i].modes = xnfalloc(sizeof(char *));
- scrp->confScreen->displays[i].modes[0] = NULL;
- scrp->confScreen->displays[i].depth = depth;
- scrp->confScreen->displays[i].fbbpp = fbbpp;
- scrp->display = &scrp->confScreen->displays[i];
+ scrp->confScreen->numdisplays++;
+ scrp->confScreen->displays =
+ xnfrealloc(scrp->confScreen->displays,
+ scrp->confScreen->numdisplays * sizeof(DispRec));
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Creating default Display subsection in Screen section\n"
+ "\t\"%s\" for depth/fbbpp %d/%d\n",
+ scrp->confScreen->id, scrp->depth, scrp->bitsPerPixel);
+ memset(&scrp->confScreen->displays[i], 0, sizeof(DispRec));
+ scrp->confScreen->displays[i].blackColour.red = -1;
+ scrp->confScreen->displays[i].blackColour.green = -1;
+ scrp->confScreen->displays[i].blackColour.blue = -1;
+ scrp->confScreen->displays[i].whiteColour.red = -1;
+ scrp->confScreen->displays[i].whiteColour.green = -1;
+ scrp->confScreen->displays[i].whiteColour.blue = -1;
+ scrp->confScreen->displays[i].defaultVisual = -1;
+ scrp->confScreen->displays[i].modes = xnfalloc(sizeof(char *));
+ scrp->confScreen->displays[i].modes[0] = NULL;
+ scrp->confScreen->displays[i].depth = depth;
+ scrp->confScreen->displays[i].fbbpp = fbbpp;
+ scrp->display = &scrp->confScreen->displays[i];
}
/*
@@ -621,12 +627,13 @@ xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int dummy, int fbbpp,
scrp->imageByteOrder = IMAGE_BYTE_ORDER;
scrp->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
if (scrp->depth < 8) {
- /* Planar modes need these settings */
- scrp->bitmapScanlineUnit = 8;
- scrp->bitmapBitOrder = MSBFirst;
- } else {
- scrp->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
- scrp->bitmapBitOrder = BITMAP_BIT_ORDER;
+ /* Planar modes need these settings */
+ scrp->bitmapScanlineUnit = 8;
+ scrp->bitmapBitOrder = MSBFirst;
+ }
+ else {
+ scrp->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+ scrp->bitmapBitOrder = BITMAP_BIT_ORDER;
}
/*
@@ -640,14 +647,14 @@ xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int dummy, int fbbpp,
case 15:
case 16:
case 24:
- /* Common depths. Nothing to do for them */
- break;
+ /* Common depths. Nothing to do for them */
+ break;
default:
- if (!xf86AddPixFormat(scrp, scrp->depth, 0, 0)) {
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Can't add pixmap format for depth %d\n", scrp->depth);
- return FALSE;
- }
+ if (!xf86AddPixFormat(scrp, scrp->depth, 0, 0)) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Can't add pixmap format for depth %d\n", scrp->depth);
+ return FALSE;
+ }
}
/* Initialise the framebuffer format for this screen */
@@ -682,87 +689,91 @@ xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask)
scrp->weight.blue = 0;
if (xf86Weight.red > 0 && xf86Weight.green > 0 && xf86Weight.blue > 0) {
- scrp->weight = xf86Weight;
- weightFrom = X_CMDLINE;
- } else if (scrp->display->weight.red > 0 && scrp->display->weight.green > 0
- && scrp->display->weight.blue > 0) {
- scrp->weight = scrp->display->weight;
- weightFrom = X_CONFIG;
- } else if (weight.red > 0 && weight.green > 0 && weight.blue > 0) {
- scrp->weight = weight;
- } else {
- switch (scrp->depth) {
- case 1:
- case 4:
- case 8:
- scrp->weight.red = scrp->weight.green =
- scrp->weight.blue = scrp->rgbBits;
- break;
- case 15:
- scrp->weight.red = scrp->weight.green = scrp->weight.blue = 5;
- break;
- case 16:
- scrp->weight.red = scrp->weight.blue = 5;
- scrp->weight.green = 6;
- break;
- case 18:
- scrp->weight.red = scrp->weight.green = scrp->weight.blue = 6;
- break;
- case 24:
- scrp->weight.red = scrp->weight.green = scrp->weight.blue = 8;
- break;
- case 30:
- scrp->weight.red = scrp->weight.green = scrp->weight.blue = 10;
- break;
- }
+ scrp->weight = xf86Weight;
+ weightFrom = X_CMDLINE;
+ }
+ else if (scrp->display->weight.red > 0 && scrp->display->weight.green > 0
+ && scrp->display->weight.blue > 0) {
+ scrp->weight = scrp->display->weight;
+ weightFrom = X_CONFIG;
+ }
+ else if (weight.red > 0 && weight.green > 0 && weight.blue > 0) {
+ scrp->weight = weight;
+ }
+ else {
+ switch (scrp->depth) {
+ case 1:
+ case 4:
+ case 8:
+ scrp->weight.red = scrp->weight.green =
+ scrp->weight.blue = scrp->rgbBits;
+ break;
+ case 15:
+ scrp->weight.red = scrp->weight.green = scrp->weight.blue = 5;
+ break;
+ case 16:
+ scrp->weight.red = scrp->weight.blue = 5;
+ scrp->weight.green = 6;
+ break;
+ case 18:
+ scrp->weight.red = scrp->weight.green = scrp->weight.blue = 6;
+ break;
+ case 24:
+ scrp->weight.red = scrp->weight.green = scrp->weight.blue = 8;
+ break;
+ case 30:
+ scrp->weight.red = scrp->weight.green = scrp->weight.blue = 10;
+ break;
+ }
}
if (scrp->weight.red)
- xf86DrvMsg(scrp->scrnIndex, weightFrom, "RGB weight %d%d%d\n",
- (int)scrp->weight.red, (int)scrp->weight.green,
- (int)scrp->weight.blue);
+ xf86DrvMsg(scrp->scrnIndex, weightFrom, "RGB weight %d%d%d\n",
+ (int) scrp->weight.red, (int) scrp->weight.green,
+ (int) scrp->weight.blue);
if (scrp->depth > MAX_PSEUDO_DEPTH &&
- (scrp->depth != scrp->weight.red + scrp->weight.green +
- scrp->weight.blue)) {
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Weight given (%d%d%d) is inconsistent with the "
- "depth (%d)\n",
- (int)scrp->weight.red, (int)scrp->weight.green,
- (int)scrp->weight.blue, scrp->depth);
- return FALSE;
+ (scrp->depth != scrp->weight.red + scrp->weight.green +
+ scrp->weight.blue)) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Weight given (%d%d%d) is inconsistent with the "
+ "depth (%d)\n",
+ (int) scrp->weight.red, (int) scrp->weight.green,
+ (int) scrp->weight.blue, scrp->depth);
+ return FALSE;
}
if (scrp->depth > MAX_PSEUDO_DEPTH && scrp->weight.red) {
- /*
- * XXX Does this even mean anything for TrueColor visuals?
- * If not, we shouldn't even be setting it here. However, this
- * matches the behaviour of 3.x versions of XFree86.
- */
- scrp->rgbBits = scrp->weight.red;
- if (scrp->weight.green > scrp->rgbBits)
- scrp->rgbBits = scrp->weight.green;
- if (scrp->weight.blue > scrp->rgbBits)
- scrp->rgbBits = scrp->weight.blue;
+ /*
+ * XXX Does this even mean anything for TrueColor visuals?
+ * If not, we shouldn't even be setting it here. However, this
+ * matches the behaviour of 3.x versions of XFree86.
+ */
+ scrp->rgbBits = scrp->weight.red;
+ if (scrp->weight.green > scrp->rgbBits)
+ scrp->rgbBits = scrp->weight.green;
+ if (scrp->weight.blue > scrp->rgbBits)
+ scrp->rgbBits = scrp->weight.blue;
}
/* Set the mask and offsets */
if (mask.red == 0 || mask.green == 0 || mask.blue == 0) {
- /* Default to a setting common to PC hardware */
- scrp->offset.red = scrp->weight.green + scrp->weight.blue;
- scrp->offset.green = scrp->weight.blue;
- scrp->offset.blue = 0;
- scrp->mask.red = ((1 << scrp->weight.red) - 1) << scrp->offset.red;
- scrp->mask.green = ((1 << scrp->weight.green) - 1)
- << scrp->offset.green;
- scrp->mask.blue = (1 << scrp->weight.blue) - 1;
- } else {
- /* Initialise to the values passed */
- scrp->mask.red = mask.red;
- scrp->mask.green = mask.green;
- scrp->mask.blue = mask.blue;
- scrp->offset.red = ffs(mask.red);
- scrp->offset.green = ffs(mask.green);
- scrp->offset.blue = ffs(mask.blue);
+ /* Default to a setting common to PC hardware */
+ scrp->offset.red = scrp->weight.green + scrp->weight.blue;
+ scrp->offset.green = scrp->weight.blue;
+ scrp->offset.blue = 0;
+ scrp->mask.red = ((1 << scrp->weight.red) - 1) << scrp->offset.red;
+ scrp->mask.green = ((1 << scrp->weight.green) - 1)
+ << scrp->offset.green;
+ scrp->mask.blue = (1 << scrp->weight.blue) - 1;
+ }
+ else {
+ /* Initialise to the values passed */
+ scrp->mask.red = mask.red;
+ scrp->mask.green = mask.green;
+ scrp->mask.blue = mask.blue;
+ scrp->offset.red = ffs(mask.red);
+ scrp->offset.green = ffs(mask.green);
+ scrp->offset.blue = ffs(mask.blue);
}
return TRUE;
}
@@ -773,22 +784,25 @@ xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual)
MessageType visualFrom = X_DEFAULT;
if (defaultColorVisualClass >= 0) {
- scrp->defaultVisual = defaultColorVisualClass;
- visualFrom = X_CMDLINE;
- } else if (scrp->display->defaultVisual >= 0) {
- scrp->defaultVisual = scrp->display->defaultVisual;
- visualFrom = X_CONFIG;
- } else if (visual >= 0) {
- scrp->defaultVisual = visual;
- } else {
- if (scrp->depth == 1)
- scrp->defaultVisual = StaticGray;
- else if (scrp->depth == 4)
- scrp->defaultVisual = StaticColor;
- else if (scrp->depth <= MAX_PSEUDO_DEPTH)
- scrp->defaultVisual = PseudoColor;
- else
- scrp->defaultVisual = TrueColor;
+ scrp->defaultVisual = defaultColorVisualClass;
+ visualFrom = X_CMDLINE;
+ }
+ else if (scrp->display->defaultVisual >= 0) {
+ scrp->defaultVisual = scrp->display->defaultVisual;
+ visualFrom = X_CONFIG;
+ }
+ else if (visual >= 0) {
+ scrp->defaultVisual = visual;
+ }
+ else {
+ if (scrp->depth == 1)
+ scrp->defaultVisual = StaticGray;
+ else if (scrp->depth == 4)
+ scrp->defaultVisual = StaticColor;
+ else if (scrp->depth <= MAX_PSEUDO_DEPTH)
+ scrp->defaultVisual = PseudoColor;
+ else
+ scrp->defaultVisual = TrueColor;
}
switch (scrp->defaultVisual) {
case StaticGray:
@@ -797,14 +811,14 @@ xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual)
case PseudoColor:
case TrueColor:
case DirectColor:
- xf86DrvMsg(scrp->scrnIndex, visualFrom, "Default visual is %s\n",
- xf86VisualNames[scrp->defaultVisual]);
- return TRUE;
+ xf86DrvMsg(scrp->scrnIndex, visualFrom, "Default visual is %s\n",
+ xf86VisualNames[scrp->defaultVisual]);
+ return TRUE;
default:
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Invalid default visual class (%d)\n", scrp->defaultVisual);
- return FALSE;
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Invalid default visual class (%d)\n", scrp->defaultVisual);
+ return FALSE;
}
}
@@ -818,45 +832,50 @@ Bool
xf86SetGamma(ScrnInfoPtr scrp, Gamma gamma)
{
MessageType from = X_DEFAULT;
+
#if 0
- xf86MonPtr DDC = (xf86MonPtr)(scrp->monitor->DDC);
+ xf86MonPtr DDC = (xf86MonPtr) (scrp->monitor->DDC);
#endif
if (TEST_GAMMA(xf86Gamma)) {
- from = X_CMDLINE;
- scrp->gamma.red = SET_GAMMA(xf86Gamma.red);
- scrp->gamma.green = SET_GAMMA(xf86Gamma.green);
- scrp->gamma.blue = SET_GAMMA(xf86Gamma.blue);
- } else if (TEST_GAMMA(scrp->monitor->gamma)) {
- from = X_CONFIG;
- scrp->gamma.red = SET_GAMMA(scrp->monitor->gamma.red);
- scrp->gamma.green = SET_GAMMA(scrp->monitor->gamma.green);
- scrp->gamma.blue = SET_GAMMA(scrp->monitor->gamma.blue);
+ from = X_CMDLINE;
+ scrp->gamma.red = SET_GAMMA(xf86Gamma.red);
+ scrp->gamma.green = SET_GAMMA(xf86Gamma.green);
+ scrp->gamma.blue = SET_GAMMA(xf86Gamma.blue);
+ }
+ else if (TEST_GAMMA(scrp->monitor->gamma)) {
+ from = X_CONFIG;
+ scrp->gamma.red = SET_GAMMA(scrp->monitor->gamma.red);
+ scrp->gamma.green = SET_GAMMA(scrp->monitor->gamma.green);
+ scrp->gamma.blue = SET_GAMMA(scrp->monitor->gamma.blue);
#if 0
- } else if ( DDC && DDC->features.gamma > GAMMA_ZERO ) {
+ }
+ else if (DDC && DDC->features.gamma > GAMMA_ZERO) {
from = X_PROBED;
- scrp->gamma.red = SET_GAMMA(DDC->features.gamma);
- scrp->gamma.green = SET_GAMMA(DDC->features.gamma);
- scrp->gamma.blue = SET_GAMMA(DDC->features.gamma);
- /* EDID structure version 2 gives optional seperate red, green & blue gamma values
- * in bytes 0x57-0x59 */
+ scrp->gamma.red = SET_GAMMA(DDC->features.gamma);
+ scrp->gamma.green = SET_GAMMA(DDC->features.gamma);
+ scrp->gamma.blue = SET_GAMMA(DDC->features.gamma);
+ /* EDID structure version 2 gives optional seperate red, green & blue gamma values
+ * in bytes 0x57-0x59 */
#endif
- } else if (TEST_GAMMA(gamma)) {
- scrp->gamma.red = SET_GAMMA(gamma.red);
- scrp->gamma.green = SET_GAMMA(gamma.green);
- scrp->gamma.blue = SET_GAMMA(gamma.blue);
- } else {
- scrp->gamma.red = 1.0;
- scrp->gamma.green = 1.0;
- scrp->gamma.blue = 1.0;
+ }
+ else if (TEST_GAMMA(gamma)) {
+ scrp->gamma.red = SET_GAMMA(gamma.red);
+ scrp->gamma.green = SET_GAMMA(gamma.green);
+ scrp->gamma.blue = SET_GAMMA(gamma.blue);
+ }
+ else {
+ scrp->gamma.red = 1.0;
+ scrp->gamma.green = 1.0;
+ scrp->gamma.blue = 1.0;
}
/* Pretend we succeeded if we support better a gamma system.
* This avoids a confusing message.
*/
if (xf86_crtc_supports_gamma(scrp))
- return TRUE;
+ return TRUE;
xf86DrvMsg(scrp->scrnIndex, from,
- "Using gamma correction (%.1f, %.1f, %.1f)\n",
- scrp->gamma.red, scrp->gamma.green, scrp->gamma.blue);
+ "Using gamma correction (%.1f, %.1f, %.1f)\n",
+ scrp->gamma.red, scrp->gamma.green, scrp->gamma.blue);
return TRUE;
}
@@ -864,7 +883,6 @@ xf86SetGamma(ScrnInfoPtr scrp, Gamma gamma)
#undef TEST_GAMMA
#undef SET_GAMMA
-
/*
* Set the DPI from the command line option. XXX should allow it to be
* calculated from the widthmm/heightmm values.
@@ -877,7 +895,7 @@ void
xf86SetDpi(ScrnInfoPtr pScrn, int x, int y)
{
MessageType from = X_DEFAULT;
- xf86MonPtr DDC = (xf86MonPtr)(pScrn->monitor->DDC);
+ xf86MonPtr DDC = (xf86MonPtr) (pScrn->monitor->DDC);
int ddcWidthmm, ddcHeightmm;
int widthErr, heightErr;
@@ -885,100 +903,107 @@ xf86SetDpi(ScrnInfoPtr pScrn, int x, int y)
pScrn->widthmm = pScrn->monitor->widthmm;
pScrn->heightmm = pScrn->monitor->heightmm;
- if (DDC && (DDC->features.hsize > 0 && DDC->features.vsize > 0) ) {
- /* DDC gives display size in mm for individual modes,
- * but cm for monitor
- */
- ddcWidthmm = DDC->features.hsize * 10; /* 10mm in 1cm */
- ddcHeightmm = DDC->features.vsize * 10; /* 10mm in 1cm */
- } else {
- ddcWidthmm = ddcHeightmm = 0;
+ if (DDC && (DDC->features.hsize > 0 && DDC->features.vsize > 0)) {
+ /* DDC gives display size in mm for individual modes,
+ * but cm for monitor
+ */
+ ddcWidthmm = DDC->features.hsize * 10; /* 10mm in 1cm */
+ ddcHeightmm = DDC->features.vsize * 10; /* 10mm in 1cm */
+ }
+ else {
+ ddcWidthmm = ddcHeightmm = 0;
}
if (monitorResolution > 0) {
- pScrn->xDpi = monitorResolution;
- pScrn->yDpi = monitorResolution;
- from = X_CMDLINE;
- } else if (pScrn->widthmm > 0 || pScrn->heightmm > 0) {
- from = X_CONFIG;
- if (pScrn->widthmm > 0) {
- pScrn->xDpi =
- (int)((double)pScrn->virtualX * MMPERINCH / pScrn->widthmm);
- }
- if (pScrn->heightmm > 0) {
- pScrn->yDpi =
- (int)((double)pScrn->virtualY * MMPERINCH / pScrn->heightmm);
- }
- if (pScrn->xDpi > 0 && pScrn->yDpi <= 0)
- pScrn->yDpi = pScrn->xDpi;
- if (pScrn->yDpi > 0 && pScrn->xDpi <= 0)
- pScrn->xDpi = pScrn->yDpi;
- xf86DrvMsg(pScrn->scrnIndex, from, "Display dimensions: (%d, %d) mm\n",
- pScrn->widthmm, pScrn->heightmm);
-
- /* Warn if config and probe disagree about display size */
- if ( ddcWidthmm && ddcHeightmm ) {
- if (pScrn->widthmm > 0) {
- widthErr = abs(ddcWidthmm - pScrn->widthmm);
- } else {
- widthErr = 0;
- }
- if (pScrn->heightmm > 0) {
- heightErr = abs(ddcHeightmm - pScrn->heightmm);
- } else {
- heightErr = 0;
- }
- if (widthErr>10 || heightErr>10) {
- /* Should include config file name for monitor here */
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "Probed monitor is %dx%d mm, using Displaysize %dx%d mm\n",
- ddcWidthmm,ddcHeightmm, pScrn->widthmm,pScrn->heightmm);
- }
- }
- } else if ( ddcWidthmm && ddcHeightmm ) {
- from = X_PROBED;
- xf86DrvMsg(pScrn->scrnIndex, from, "Display dimensions: (%d, %d) mm\n",
- ddcWidthmm, ddcHeightmm );
- pScrn->widthmm = ddcWidthmm;
- pScrn->heightmm = ddcHeightmm;
- if (pScrn->widthmm > 0) {
- pScrn->xDpi =
- (int)((double)pScrn->virtualX * MMPERINCH / pScrn->widthmm);
- }
- if (pScrn->heightmm > 0) {
- pScrn->yDpi =
- (int)((double)pScrn->virtualY * MMPERINCH / pScrn->heightmm);
- }
- if (pScrn->xDpi > 0 && pScrn->yDpi <= 0)
- pScrn->yDpi = pScrn->xDpi;
- if (pScrn->yDpi > 0 && pScrn->xDpi <= 0)
- pScrn->xDpi = pScrn->yDpi;
- } else {
- if (x > 0)
- pScrn->xDpi = x;
- else
- pScrn->xDpi = DEFAULT_DPI;
- if (y > 0)
- pScrn->yDpi = y;
- else
- pScrn->yDpi = DEFAULT_DPI;
+ pScrn->xDpi = monitorResolution;
+ pScrn->yDpi = monitorResolution;
+ from = X_CMDLINE;
+ }
+ else if (pScrn->widthmm > 0 || pScrn->heightmm > 0) {
+ from = X_CONFIG;
+ if (pScrn->widthmm > 0) {
+ pScrn->xDpi =
+ (int) ((double) pScrn->virtualX * MMPERINCH / pScrn->widthmm);
+ }
+ if (pScrn->heightmm > 0) {
+ pScrn->yDpi =
+ (int) ((double) pScrn->virtualY * MMPERINCH / pScrn->heightmm);
+ }
+ if (pScrn->xDpi > 0 && pScrn->yDpi <= 0)
+ pScrn->yDpi = pScrn->xDpi;
+ if (pScrn->yDpi > 0 && pScrn->xDpi <= 0)
+ pScrn->xDpi = pScrn->yDpi;
+ xf86DrvMsg(pScrn->scrnIndex, from, "Display dimensions: (%d, %d) mm\n",
+ pScrn->widthmm, pScrn->heightmm);
+
+ /* Warn if config and probe disagree about display size */
+ if (ddcWidthmm && ddcHeightmm) {
+ if (pScrn->widthmm > 0) {
+ widthErr = abs(ddcWidthmm - pScrn->widthmm);
+ }
+ else {
+ widthErr = 0;
+ }
+ if (pScrn->heightmm > 0) {
+ heightErr = abs(ddcHeightmm - pScrn->heightmm);
+ }
+ else {
+ heightErr = 0;
+ }
+ if (widthErr > 10 || heightErr > 10) {
+ /* Should include config file name for monitor here */
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "Probed monitor is %dx%d mm, using Displaysize %dx%d mm\n",
+ ddcWidthmm, ddcHeightmm, pScrn->widthmm,
+ pScrn->heightmm);
+ }
+ }
+ }
+ else if (ddcWidthmm && ddcHeightmm) {
+ from = X_PROBED;
+ xf86DrvMsg(pScrn->scrnIndex, from, "Display dimensions: (%d, %d) mm\n",
+ ddcWidthmm, ddcHeightmm);
+ pScrn->widthmm = ddcWidthmm;
+ pScrn->heightmm = ddcHeightmm;
+ if (pScrn->widthmm > 0) {
+ pScrn->xDpi =
+ (int) ((double) pScrn->virtualX * MMPERINCH / pScrn->widthmm);
+ }
+ if (pScrn->heightmm > 0) {
+ pScrn->yDpi =
+ (int) ((double) pScrn->virtualY * MMPERINCH / pScrn->heightmm);
+ }
+ if (pScrn->xDpi > 0 && pScrn->yDpi <= 0)
+ pScrn->yDpi = pScrn->xDpi;
+ if (pScrn->yDpi > 0 && pScrn->xDpi <= 0)
+ pScrn->xDpi = pScrn->yDpi;
+ }
+ else {
+ if (x > 0)
+ pScrn->xDpi = x;
+ else
+ pScrn->xDpi = DEFAULT_DPI;
+ if (y > 0)
+ pScrn->yDpi = y;
+ else
+ pScrn->yDpi = DEFAULT_DPI;
}
xf86DrvMsg(pScrn->scrnIndex, from, "DPI set to (%d, %d)\n",
- pScrn->xDpi, pScrn->yDpi);
+ pScrn->xDpi, pScrn->yDpi);
}
#undef MMPERINCH
-
void
xf86SetBlackWhitePixels(ScreenPtr pScreen)
{
if (xf86FlipPixels) {
- pScreen->whitePixel = 0;
- pScreen->blackPixel = 1;
- } else {
- pScreen->whitePixel = 1;
- pScreen->blackPixel = 0;
+ pScreen->whitePixel = 0;
+ pScreen->blackPixel = 1;
+ }
+ else {
+ pScreen->whitePixel = 1;
+ pScreen->blackPixel = 0;
}
}
@@ -1009,21 +1034,19 @@ xf86EnableDisableFBAccess(int scrnIndex, Bool enable)
PixmapPtr pspix;
pspix = (*pScreen->GetScreenPixmap) (pScreen);
- if (enable)
- {
- /*
- * Restore all of the clip lists on the screen
- */
- if (!xf86Resetting)
- SetRootClip (pScreen, TRUE);
+ if (enable) {
+ /*
+ * Restore all of the clip lists on the screen
+ */
+ if (!xf86Resetting)
+ SetRootClip(pScreen, TRUE);
}
- else
- {
- /*
- * Empty all of the clip lists on the screen
- */
- SetRootClip (pScreen, FALSE);
+ else {
+ /*
+ * Empty all of the clip lists on the screen
+ */
+ SetRootClip(pScreen, FALSE);
}
}
@@ -1031,21 +1054,21 @@ xf86EnableDisableFBAccess(int scrnIndex, Bool enable)
(<type>) <screen name>(<screen index>): <message> */
void
xf86VDrvMsgVerb(int scrnIndex, MessageType type, int verb, const char *format,
- va_list args)
+ va_list args)
{
/* Prefix the scrnIndex name to the format string. */
if (scrnIndex >= 0 && scrnIndex < xf86NumScreens &&
- xf86Screens[scrnIndex]->name)
- LogHdrMessageVerb(type, verb, format, args, "%s(%d): ",
- xf86Screens[scrnIndex]->name, scrnIndex);
+ xf86Screens[scrnIndex]->name)
+ LogHdrMessageVerb(type, verb, format, args, "%s(%d): ",
+ xf86Screens[scrnIndex]->name, scrnIndex);
else
- LogVMessageVerb(type, verb, format, args);
+ LogVMessageVerb(type, verb, format, args);
}
/* Print driver messages, with verbose level specified directly */
void
xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb, const char *format,
- ...)
+ ...)
{
va_list ap;
@@ -1069,26 +1092,26 @@ xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...)
(<type>) <driver>: <device name>: <message> */
void
xf86VIDrvMsgVerb(InputInfoPtr dev, MessageType type, int verb,
- const char *format, va_list args)
+ const char *format, va_list args)
{
const char *driverName = NULL;
const char *deviceName = NULL;
/* Prefix driver and device names to formatted message. */
if (dev) {
- deviceName = dev->name;
- if (dev->drv)
- driverName = dev->drv->driverName;
+ deviceName = dev->name;
+ if (dev->drv)
+ driverName = dev->drv->driverName;
}
LogHdrMessageVerb(type, verb, format, args, "%s: %s: ", driverName,
- deviceName);
+ deviceName);
}
/* Print input driver message, with verbose level specified directly */
void
-xf86IDrvMsgVerb(InputInfoPtr dev, MessageType type, int verb, const char *format,
- ...)
+xf86IDrvMsgVerb(InputInfoPtr dev, MessageType type, int verb,
+ const char *format, ...)
{
va_list ap;
@@ -1108,7 +1131,6 @@ xf86IDrvMsg(InputInfoPtr dev, MessageType type, const char *format, ...)
va_end(ap);
}
-
/* Print non-driver messages with verbose level specified directly */
void
xf86MsgVerb(MessageType type, int verb, const char *format, ...)
@@ -1139,7 +1161,7 @@ xf86ErrorFVerb(int verb, const char *format, ...)
va_start(ap, format);
if (xf86Verbose >= verb || xf86LogVerbose >= verb)
- LogVWrite(verb, format, ap);
+ LogVWrite(verb, format, ap);
va_end(ap);
}
@@ -1151,11 +1173,10 @@ xf86ErrorF(const char *format, ...)
va_start(ap, format);
if (xf86Verbose >= 1 || xf86LogVerbose >= 1)
- LogVWrite(1, format, ap);
+ LogVWrite(1, format, ap);
va_end(ap);
}
-
void
xf86LogInit(void)
{
@@ -1166,10 +1187,10 @@ xf86LogInit(void)
/* Get the log file name */
if (xf86LogFileFrom == X_DEFAULT) {
- /* Append the display number and ".log" */
- if (asprintf(&lf, "%s%%s" LOGSUFFIX, xf86LogFile) == -1)
- FatalError("Cannot allocate space for the log file name\n");
- xf86LogFile = lf;
+ /* Append the display number and ".log" */
+ if (asprintf(&lf, "%s%%s" LOGSUFFIX, xf86LogFile) == -1)
+ FatalError("Cannot allocate space for the log file name\n");
+ xf86LogFile = lf;
}
xf86LogFile = LogInit(xf86LogFile, LOGOLDSUFFIX);
@@ -1190,7 +1211,6 @@ xf86CloseLog(enum ExitCode error)
LogClose(error);
}
-
/*
* Drivers can use these for using their own SymTabRecs.
*/
@@ -1200,13 +1220,12 @@ xf86TokenToString(SymTabPtr table, int token)
{
int i;
- for (i = 0; table[i].token >= 0 && table[i].token != token; i++)
- ;
+ for (i = 0; table[i].token >= 0 && table[i].token != token; i++);
if (table[i].token < 0)
- return NULL;
+ return NULL;
else
- return table[i].name;
+ return table[i].name;
}
int
@@ -1215,10 +1234,9 @@ xf86StringToToken(SymTabPtr table, const char *string)
int i;
if (string == NULL)
- return -1;
+ return -1;
- for (i = 0; table[i].token >= 0 && xf86NameCmp(string, table[i].name); i++)
- ;
+ for (i = 0; table[i].token >= 0 && xf86NameCmp(string, table[i].name); i++);
return table[i].token;
}
@@ -1232,17 +1250,16 @@ xf86ShowClocks(ScrnInfoPtr scrp, MessageType from)
int j;
xf86DrvMsg(scrp->scrnIndex, from, "Pixel clocks available:");
- for (j=0; j < scrp->numClocks; j++) {
- if ((j % 4) == 0) {
- xf86ErrorF("\n");
- xf86DrvMsg(scrp->scrnIndex, from, "pixel clocks:");
- }
- xf86ErrorF(" %7.3f", (double)scrp->clock[j] / 1000.0);
+ for (j = 0; j < scrp->numClocks; j++) {
+ if ((j % 4) == 0) {
+ xf86ErrorF("\n");
+ xf86DrvMsg(scrp->scrnIndex, from, "pixel clocks:");
+ }
+ xf86ErrorF(" %7.3f", (double) scrp->clock[j] / 1000.0);
}
xf86ErrorF("\n");
}
-
/*
* This prints out the driver identify message, including the names of
* the supported chipsets.
@@ -1258,40 +1275,40 @@ xf86PrintChipsets(const char *drvname, const char *drvmsg, SymTabPtr chips)
len = 6 + strlen(drvname) + 2 + strlen(drvmsg) + 2;
xf86Msg(X_INFO, "%s: %s:", drvname, drvmsg);
for (i = 0; chips[i].name != NULL; i++) {
- if (i != 0) {
- xf86ErrorF(",");
- len++;
- }
- if (len + 2 + strlen(chips[i].name) < 78) {
- xf86ErrorF(" ");
- len++;
- } else {
- xf86ErrorF("\n\t");
- len = 8;
- }
- xf86ErrorF("%s", chips[i].name);
- len += strlen(chips[i].name);
+ if (i != 0) {
+ xf86ErrorF(",");
+ len++;
+ }
+ if (len + 2 + strlen(chips[i].name) < 78) {
+ xf86ErrorF(" ");
+ len++;
+ }
+ else {
+ xf86ErrorF("\n\t");
+ len = 8;
+ }
+ xf86ErrorF("%s", chips[i].name);
+ len += strlen(chips[i].name);
}
xf86ErrorF("\n");
}
-
int
-xf86MatchDevice(const char *drivername, GDevPtr **sectlist)
+xf86MatchDevice(const char *drivername, GDevPtr ** sectlist)
{
- GDevPtr gdp, *pgdp = NULL;
+ GDevPtr gdp, *pgdp = NULL;
confScreenPtr screensecptr;
- int i,j;
+ int i, j;
if (sectlist)
- *sectlist = NULL;
+ *sectlist = NULL;
/*
* This can happen when running Xorg -showopts and a module like ati
* or vmware tries to load its submodules when xf86ConfigLayout is empty
*/
if (!xf86ConfigLayout.screens)
- return 0;
+ return 0;
/*
* This is a very important function that matches the device sections
@@ -1314,11 +1331,11 @@ xf86MatchDevice(const char *drivername, GDevPtr **sectlist)
* first we need to loop over all the Screens sections to get to all
* 'active' device sections
*/
- for (j=0; xf86ConfigLayout.screens[j].screen != NULL; j++) {
+ for (j = 0; xf86ConfigLayout.screens[j].screen != NULL; j++) {
screensecptr = xf86ConfigLayout.screens[j].screen;
if ((screensecptr->device->driver != NULL)
- && (xf86NameCmp( screensecptr->device->driver,drivername) == 0)
- && (! screensecptr->device->claimed)) {
+ && (xf86NameCmp(screensecptr->device->driver, drivername) == 0)
+ && (!screensecptr->device->claimed)) {
/*
* we have a matching driver that wasn't claimed, yet
*/
@@ -1330,14 +1347,14 @@ xf86MatchDevice(const char *drivername, GDevPtr **sectlist)
/* Then handle the inactive devices */
j = 0;
while (xf86ConfigLayout.inactives[j].identifier) {
- gdp = &xf86ConfigLayout.inactives[j];
- if (gdp->driver && !gdp->claimed &&
- !xf86NameCmp(gdp->driver,drivername)) {
- /* we have a matching driver that wasn't claimed yet */
- pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr));
- pgdp[i++] = gdp;
- }
- j++;
+ gdp = &xf86ConfigLayout.inactives[j];
+ if (gdp->driver && !gdp->claimed &&
+ !xf86NameCmp(gdp->driver, drivername)) {
+ /* we have a matching driver that wasn't claimed yet */
+ pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr));
+ pgdp[i++] = gdp;
+ }
+ j++;
}
/*
@@ -1347,9 +1364,9 @@ xf86MatchDevice(const char *drivername, GDevPtr **sectlist)
pgdp[i] = NULL;
if (sectlist)
- *sectlist = pgdp;
+ *sectlist = pgdp;
else
- free(pgdp);
+ free(pgdp);
return i;
}
@@ -1357,12 +1374,11 @@ const char *
xf86GetVisualName(int visual)
{
if (visual < 0 || visual > DirectColor)
- return NULL;
+ return NULL;
return xf86VisualNames[visual];
}
-
int
xf86GetVerbosity(void)
{
@@ -1375,84 +1391,72 @@ xf86GetPix24(void)
return xf86Info.pixmap24;
}
-
int
xf86GetDepth(void)
{
return xf86Depth;
}
-
rgb
xf86GetWeight(void)
{
return xf86Weight;
}
-
Gamma
xf86GetGamma(void)
{
return xf86Gamma;
}
-
Bool
xf86GetFlipPixels(void)
{
return xf86FlipPixels;
}
-
const char *
xf86GetServerName(void)
{
return xf86ServerName;
}
-
Bool
xf86ServerIsExiting(void)
{
return (dispatchException & DE_TERMINATE) == DE_TERMINATE;
}
-
Bool
xf86ServerIsResetting(void)
{
return xf86Resetting;
}
-
Bool
xf86ServerIsInitialising(void)
{
return xf86Initialising;
}
-
Bool
xf86ServerIsOnlyDetecting(void)
{
return xf86DoConfigure;
}
-
Bool
xf86CaughtSignal(void)
{
return xf86Info.caughtSignal;
}
-
Bool
xf86GetVidModeAllowNonLocal(void)
{
return xf86Info.vidModeAllowNonLocal;
}
-
Bool
xf86GetVidModeEnabled(void)
{
@@ -1465,21 +1469,18 @@ xf86GetModInDevAllowNonLocal(void)
return xf86Info.miscModInDevAllowNonLocal;
}
-
Bool
xf86GetModInDevEnabled(void)
{
return xf86Info.miscModInDevEnabled;
}
-
Bool
xf86GetAllowMouseOpenFail(void)
{
return xf86Info.allowMouseOpenFail;
}
-
void
xf86DisableRandR(void)
{
@@ -1490,7 +1491,7 @@ xf86DisableRandR(void)
CARD32
xf86GetModuleVersion(pointer module)
{
- return (CARD32)LoaderGetModuleVersion(module);
+ return (CARD32) LoaderGetModuleVersion(module);
}
pointer
@@ -1500,9 +1501,9 @@ xf86LoadDrvSubModule(DriverPtr drv, const char *name)
int errmaj = 0, errmin = 0;
ret = LoadSubModule(drv->module, name, NULL, NULL, NULL, NULL,
- &errmaj, &errmin);
+ &errmaj, &errmin);
if (!ret)
- LoaderErrorMsg(NULL, name, errmaj, errmin);
+ LoaderErrorMsg(NULL, name, errmaj, errmin);
return ret;
}
@@ -1513,9 +1514,9 @@ xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name)
int errmaj = 0, errmin = 0;
ret = LoadSubModule(pScrn->module, name, NULL, NULL, NULL, NULL,
- &errmaj, &errmin);
+ &errmaj, &errmin);
if (!ret)
- LoaderErrorMsg(pScrn->name, name, errmaj, errmin);
+ LoaderErrorMsg(pScrn->name, name, errmaj, errmin);
return ret;
}
@@ -1530,22 +1531,22 @@ xf86LoadOneModule(char *name, pointer opt)
pointer mod;
if (!name)
- return NULL;
+ return NULL;
/* Normalise the module name */
Name = xf86NormalizeName(name);
/* Skip empty names */
if (Name == NULL)
- return NULL;
+ return NULL;
if (*Name == '\0') {
- free(Name);
- return NULL;
+ free(Name);
+ return NULL;
}
mod = LoadModule(Name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin);
if (!mod)
- LoaderErrorMsg(NULL, Name, errmaj, errmin);
+ LoaderErrorMsg(NULL, Name, errmaj, errmin);
free(Name);
return mod;
}
@@ -1563,12 +1564,12 @@ xf86LoaderCheckSymbol(const char *name)
}
typedef enum {
- OPTION_BACKING_STORE
+ OPTION_BACKING_STORE
} BSOpts;
static const OptionInfoRec BSOptions[] = {
- { OPTION_BACKING_STORE, "BackingStore", OPTV_BOOLEAN, {0}, FALSE },
- { -1, NULL, OPTV_NONE, {0}, FALSE }
+ {OPTION_BACKING_STORE, "BackingStore", OPTV_BOOLEAN, {0}, FALSE},
+ {-1, NULL, OPTV_NONE, {0}, FALSE}
};
void
@@ -1580,39 +1581,40 @@ xf86SetBackingStore(ScreenPtr pScreen)
OptionInfoPtr options;
options = xnfalloc(sizeof(BSOptions));
- (void)memcpy(options, BSOptions, sizeof(BSOptions));
+ (void) memcpy(options, BSOptions, sizeof(BSOptions));
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
/* check for commandline option here */
if (xf86bsEnableFlag) {
- from = X_CMDLINE;
- useBS = TRUE;
- } else if (xf86bsDisableFlag) {
- from = X_CMDLINE;
- useBS = FALSE;
- } else {
- if (xf86GetOptValBool(options, OPTION_BACKING_STORE, &useBS))
- from = X_CONFIG;
+ from = X_CMDLINE;
+ useBS = TRUE;
+ }
+ else if (xf86bsDisableFlag) {
+ from = X_CMDLINE;
+ useBS = FALSE;
+ }
+ else {
+ if (xf86GetOptValBool(options, OPTION_BACKING_STORE, &useBS))
+ from = X_CONFIG;
}
free(options);
pScreen->backingStoreSupport = useBS ? Always : NotUseful;
if (serverGeneration == 1)
- xf86DrvMsg(pScreen->myNum, from, "Backing store %s\n",
- useBS ? "enabled" : "disabled");
+ xf86DrvMsg(pScreen->myNum, from, "Backing store %s\n",
+ useBS ? "enabled" : "disabled");
}
-
typedef enum {
- OPTION_SILKEN_MOUSE
+ OPTION_SILKEN_MOUSE
} SMOpts;
static const OptionInfoRec SMOptions[] = {
- { OPTION_SILKEN_MOUSE, "SilkenMouse", OPTV_BOOLEAN, {0}, FALSE },
- { -1, NULL, OPTV_NONE, {0}, FALSE }
+ {OPTION_SILKEN_MOUSE, "SilkenMouse", OPTV_BOOLEAN, {0}, FALSE},
+ {-1, NULL, OPTV_NONE, {0}, FALSE}
};
void
-xf86SetSilkenMouse (ScreenPtr pScreen)
+xf86SetSilkenMouse(ScreenPtr pScreen)
{
Bool useSM = TRUE;
MessageType from = X_DEFAULT;
@@ -1620,18 +1622,19 @@ xf86SetSilkenMouse (ScreenPtr pScreen)
OptionInfoPtr options;
options = xnfalloc(sizeof(SMOptions));
- (void)memcpy(options, SMOptions, sizeof(SMOptions));
+ (void) memcpy(options, SMOptions, sizeof(SMOptions));
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
/* check for commandline option here */
/* disable if screen shares resources */
- /* TODO VGA arb disable silken mouse */
+ /* TODO VGA arb disable silken mouse */
if (xf86silkenMouseDisableFlag) {
from = X_CMDLINE;
- useSM = FALSE;
- } else {
- if (xf86GetOptValBool(options, OPTION_SILKEN_MOUSE, &useSM))
- from = X_CONFIG;
+ useSM = FALSE;
+ }
+ else {
+ if (xf86GetOptValBool(options, OPTION_SILKEN_MOUSE, &useSM))
+ from = X_CONFIG;
}
free(options);
/*
@@ -1641,33 +1644,37 @@ xf86SetSilkenMouse (ScreenPtr pScreen)
*/
pScrn->silkenMouse = useSM && xf86Info.useSIGIO && xf86SIGIOSupported();
if (serverGeneration == 1)
- xf86DrvMsg(pScreen->myNum, from, "Silken mouse %s\n",
- pScrn->silkenMouse ? "enabled" : "disabled");
+ xf86DrvMsg(pScreen->myNum, from, "Silken mouse %s\n",
+ pScrn->silkenMouse ? "enabled" : "disabled");
}
/* Wrote this function for the PM2 Xv driver, preliminary. */
pointer
xf86FindXvOptions(int scrnIndex, int adaptor_index, char *port_name,
- char **adaptor_name, pointer *adaptor_options)
+ char **adaptor_name, pointer *adaptor_options)
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
confXvAdaptorPtr adaptor;
int i;
if (adaptor_index >= pScrn->confScreen->numxvadaptors) {
- if (adaptor_name) *adaptor_name = NULL;
- if (adaptor_options) *adaptor_options = NULL;
- return NULL;
+ if (adaptor_name)
+ *adaptor_name = NULL;
+ if (adaptor_options)
+ *adaptor_options = NULL;
+ return NULL;
}
adaptor = &pScrn->confScreen->xvadaptors[adaptor_index];
- if (adaptor_name) *adaptor_name = adaptor->identifier;
- if (adaptor_options) *adaptor_options = adaptor->options;
+ if (adaptor_name)
+ *adaptor_name = adaptor->identifier;
+ if (adaptor_options)
+ *adaptor_options = adaptor->options;
for (i = 0; i < adaptor->numports; i++)
- if (!xf86NameCmp(adaptor->ports[i].identifier, port_name))
- return adaptor->ports[i].options;
+ if (!xf86NameCmp(adaptor->ports[i].identifier, port_name))
+ return adaptor->ports[i].options;
return NULL;
}
@@ -1678,39 +1685,41 @@ xf86FindXvOptions(int scrnIndex, int adaptor_index, char *port_name,
static void
xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init,
- EntityProc enter, EntityProc leave, pointer private)
+ EntityProc enter, EntityProc leave, pointer private)
{
ScrnInfoPtr pScrn;
if ((pScrn = xf86FindScreenForEntity(pEnt->index)))
- xf86RemoveEntityFromScreen(pScrn,pEnt->index);
- xf86SetEntityFuncs(pEnt->index,init,enter,leave,private);
+ xf86RemoveEntityFromScreen(pScrn, pEnt->index);
+ xf86SetEntityFuncs(pEnt->index, init, enter, leave, private);
}
ScrnInfoPtr
xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
- EntityProc init, EntityProc enter, EntityProc leave,
- pointer private)
+ EntityProc init, EntityProc enter, EntityProc leave,
+ pointer private)
{
EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
- if (!pEnt) return pScrn;
+
+ if (!pEnt)
+ return pScrn;
if (!(pEnt->location.type == BUS_NONE)) {
- free(pEnt);
- return pScrn;
+ free(pEnt);
+ return pScrn;
}
if (!pEnt->active) {
- xf86ConfigFbEntityInactive(pEnt, init, enter, leave, private);
- free(pEnt);
- return pScrn;
+ xf86ConfigFbEntityInactive(pEnt, init, enter, leave, private);
+ free(pEnt);
+ return pScrn;
}
if (!pScrn)
- pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag);
- xf86AddEntityToScreen(pScrn,entityIndex);
+ pScrn = xf86AllocateScreen(pEnt->driver, scrnFlag);
+ xf86AddEntityToScreen(pScrn, entityIndex);
- xf86SetEntityFuncs(entityIndex,init,enter,leave,private);
+ xf86SetEntityFuncs(entityIndex, init, enter, leave, private);
free(pEnt);
return pScrn;
@@ -1722,48 +1731,49 @@ xf86IsScreenPrimary(int scrnIndex)
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
int i;
- for (i=0 ; i < pScrn->numEntities; i++) {
- if (xf86IsEntityPrimary(i))
- return TRUE;
+ for (i = 0; i < pScrn->numEntities; i++) {
+ if (xf86IsEntityPrimary(i))
+ return TRUE;
}
return FALSE;
}
int
xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
- int format, unsigned long len, pointer value )
+ int format, unsigned long len, pointer value)
{
RootWinPropPtr pNewProp = NULL, pRegProp;
Bool existing = FALSE;
DebugF("xf86RegisterRootWindowProperty(%d, %ld, %ld, %d, %ld, %p)\n",
- ScrnIndex, property, type, format, len, value);
+ ScrnIndex, property, type, format, len, value);
- if (ScrnIndex<0 || ScrnIndex>=xf86NumScreens) {
- return BadMatch;
+ if (ScrnIndex < 0 || ScrnIndex >= xf86NumScreens) {
+ return BadMatch;
}
if (xf86RegisteredPropertiesTable &&
- xf86RegisteredPropertiesTable[ScrnIndex]) {
- for (pNewProp = xf86RegisteredPropertiesTable[ScrnIndex];
- pNewProp; pNewProp = pNewProp->next) {
- if (strcmp(pNewProp->name, NameForAtom(property)) == 0)
- break;
- }
+ xf86RegisteredPropertiesTable[ScrnIndex]) {
+ for (pNewProp = xf86RegisteredPropertiesTable[ScrnIndex];
+ pNewProp; pNewProp = pNewProp->next) {
+ if (strcmp(pNewProp->name, NameForAtom(property)) == 0)
+ break;
+ }
}
if (!pNewProp) {
- if ((pNewProp = (RootWinPropPtr)malloc(sizeof(RootWinProp))) == NULL) {
- return BadAlloc;
- }
- /*
- * We will put this property at the end of the list so that
- * the changes are made in the order they were requested.
- */
- pNewProp->next = NULL;
- } else {
- free(pNewProp->name);
- existing = TRUE;
+ if ((pNewProp = (RootWinPropPtr) malloc(sizeof(RootWinProp))) == NULL) {
+ return BadAlloc;
+ }
+ /*
+ * We will put this property at the end of the list so that
+ * the changes are made in the order they were requested.
+ */
+ pNewProp->next = NULL;
+ }
+ else {
+ free(pNewProp->name);
+ existing = TRUE;
}
pNewProp->name = xnfstrdup(NameForAtom(property));
@@ -1775,28 +1785,29 @@ xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
DebugF("new property filled\n");
if (xf86RegisteredPropertiesTable == NULL) {
- DebugF("creating xf86RegisteredPropertiesTable[] size %d\n",
- xf86NumScreens);
- xf86RegisteredPropertiesTable =
- xnfcalloc(sizeof(RootWinProp), xf86NumScreens);
+ DebugF("creating xf86RegisteredPropertiesTable[] size %d\n",
+ xf86NumScreens);
+ xf86RegisteredPropertiesTable =
+ xnfcalloc(sizeof(RootWinProp), xf86NumScreens);
}
DebugF("xf86RegisteredPropertiesTable %p\n",
- (void *)xf86RegisteredPropertiesTable);
+ (void *) xf86RegisteredPropertiesTable);
DebugF("xf86RegisteredPropertiesTable[%d] %p\n",
- ScrnIndex, (void *)xf86RegisteredPropertiesTable[ScrnIndex]);
+ ScrnIndex, (void *) xf86RegisteredPropertiesTable[ScrnIndex]);
if (!existing) {
- if ( xf86RegisteredPropertiesTable[ScrnIndex] == NULL) {
- xf86RegisteredPropertiesTable[ScrnIndex] = pNewProp;
- } else {
- pRegProp = xf86RegisteredPropertiesTable[ScrnIndex];
- while (pRegProp->next != NULL) {
- DebugF("- next %p\n", (void *)pRegProp);
- pRegProp = pRegProp->next;
+ if (xf86RegisteredPropertiesTable[ScrnIndex] == NULL) {
+ xf86RegisteredPropertiesTable[ScrnIndex] = pNewProp;
+ }
+ else {
+ pRegProp = xf86RegisteredPropertiesTable[ScrnIndex];
+ while (pRegProp->next != NULL) {
+ DebugF("- next %p\n", (void *) pRegProp);
+ pRegProp = pRegProp->next;
+ }
+ pRegProp->next = pNewProp;
}
- pRegProp->next = pNewProp;
- }
}
DebugF("xf86RegisterRootWindowProperty succeeded\n");
return Success;
@@ -1805,16 +1816,16 @@ xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
Bool
xf86IsUnblank(int mode)
{
- switch(mode) {
+ switch (mode) {
case SCREEN_SAVER_OFF:
case SCREEN_SAVER_FORCER:
- return TRUE;
+ return TRUE;
case SCREEN_SAVER_ON:
case SCREEN_SAVER_CYCLE:
- return FALSE;
+ return FALSE;
default:
- xf86MsgVerb(X_WARNING, 0, "Unexpected save screen mode: %d\n", mode);
- return TRUE;
+ xf86MsgVerb(X_WARNING, 0, "Unexpected save screen mode: %d\n", mode);
+ return TRUE;
}
}
diff --git a/xorg-server/hw/xfree86/common/xf86Init.c b/xorg-server/hw/xfree86/common/xf86Init.c
index 5263b5f73..0974893d3 100644
--- a/xorg-server/hw/xfree86/common/xf86Init.c
+++ b/xorg-server/hw/xfree86/common/xf86Init.c
@@ -91,21 +91,22 @@
#include <hotplug.h>
#ifdef XF86PM
-void (*xf86OSPMClose)(void) = NULL;
+void (*xf86OSPMClose) (void) = NULL;
#endif
static Bool xorgHWOpenConsole = FALSE;
/* Common pixmap formats */
static PixmapFormatRec formats[MAXFORMATS] = {
- { 1, 1, BITMAP_SCANLINE_PAD },
- { 4, 8, BITMAP_SCANLINE_PAD },
- { 8, 8, BITMAP_SCANLINE_PAD },
- { 15, 16, BITMAP_SCANLINE_PAD },
- { 16, 16, BITMAP_SCANLINE_PAD },
- { 24, 32, BITMAP_SCANLINE_PAD },
- { 32, 32, BITMAP_SCANLINE_PAD },
+ {1, 1, BITMAP_SCANLINE_PAD},
+ {4, 8, BITMAP_SCANLINE_PAD},
+ {8, 8, BITMAP_SCANLINE_PAD},
+ {15, 16, BITMAP_SCANLINE_PAD},
+ {16, 16, BITMAP_SCANLINE_PAD},
+ {24, 32, BITMAP_SCANLINE_PAD},
+ {32, 32, BITMAP_SCANLINE_PAD},
};
+
static int numFormats = 7;
static Bool formatsDone = FALSE;
@@ -123,241 +124,242 @@ static void
xf86PrintBanner(void)
{
#if PRE_RELEASE
- xf86ErrorFVerb(0, "\n"
- "This is a pre-release version of the X server from " XVENDORNAME ".\n"
- "It is not supported in any way.\n"
- "Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.\n"
- "Select the \"xorg\" product for bugs you find in this release.\n"
- "Before reporting bugs in pre-release versions please check the\n"
- "latest version in the X.Org Foundation git repository.\n"
- "See http://wiki.x.org/wiki/GitPage for git access instructions.\n");
+ xf86ErrorFVerb(0, "\n"
+ "This is a pre-release version of the X server from "
+ XVENDORNAME ".\n" "It is not supported in any way.\n"
+ "Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.\n"
+ "Select the \"xorg\" product for bugs you find in this release.\n"
+ "Before reporting bugs in pre-release versions please check the\n"
+ "latest version in the X.Org Foundation git repository.\n"
+ "See http://wiki.x.org/wiki/GitPage for git access instructions.\n");
#endif
- xf86ErrorFVerb(0, "\nX.Org X Server %d.%d.%d",
- XORG_VERSION_MAJOR,
- XORG_VERSION_MINOR,
- XORG_VERSION_PATCH);
+ xf86ErrorFVerb(0, "\nX.Org X Server %d.%d.%d",
+ XORG_VERSION_MAJOR, XORG_VERSION_MINOR, XORG_VERSION_PATCH);
#if XORG_VERSION_SNAP > 0
- xf86ErrorFVerb(0, ".%d", XORG_VERSION_SNAP);
+ xf86ErrorFVerb(0, ".%d", XORG_VERSION_SNAP);
#endif
#if XORG_VERSION_SNAP >= 900
- /* When the minor number is 99, that signifies that the we are making
- * a release candidate for a major version. (X.0.0)
- * When the patch number is 99, that signifies that the we are making
- * a release candidate for a minor version. (X.Y.0)
- * When the patch number is < 99, then we are making a release
- * candidate for the next point release. (X.Y.Z)
- */
+ /* When the minor number is 99, that signifies that the we are making
+ * a release candidate for a major version. (X.0.0)
+ * When the patch number is 99, that signifies that the we are making
+ * a release candidate for a minor version. (X.Y.0)
+ * When the patch number is < 99, then we are making a release
+ * candidate for the next point release. (X.Y.Z)
+ */
#if XORG_VERSION_MINOR >= 99
- xf86ErrorFVerb(0, " (%d.0.0 RC %d)", XORG_VERSION_MAJOR+1,
- XORG_VERSION_SNAP - 900);
+ xf86ErrorFVerb(0, " (%d.0.0 RC %d)", XORG_VERSION_MAJOR + 1,
+ XORG_VERSION_SNAP - 900);
#elif XORG_VERSION_PATCH == 99
- xf86ErrorFVerb(0, " (%d.%d.0 RC %d)", XORG_VERSION_MAJOR,
- XORG_VERSION_MINOR + 1, XORG_VERSION_SNAP - 900);
+ xf86ErrorFVerb(0, " (%d.%d.0 RC %d)", XORG_VERSION_MAJOR,
+ XORG_VERSION_MINOR + 1, XORG_VERSION_SNAP - 900);
#else
- xf86ErrorFVerb(0, " (%d.%d.%d RC %d)", XORG_VERSION_MAJOR,
- XORG_VERSION_MINOR, XORG_VERSION_PATCH + 1,
- XORG_VERSION_SNAP - 900);
+ xf86ErrorFVerb(0, " (%d.%d.%d RC %d)", XORG_VERSION_MAJOR,
+ XORG_VERSION_MINOR, XORG_VERSION_PATCH + 1,
+ XORG_VERSION_SNAP - 900);
#endif
#endif
#ifdef XORG_CUSTOM_VERSION
- xf86ErrorFVerb(0, " (%s)", XORG_CUSTOM_VERSION);
+ xf86ErrorFVerb(0, " (%s)", XORG_CUSTOM_VERSION);
#endif
#ifndef XORG_DATE
-# define XORG_DATE "Unknown"
+#define XORG_DATE "Unknown"
#endif
- xf86ErrorFVerb(0, "\nRelease Date: %s\n", XORG_DATE);
- xf86ErrorFVerb(0, "X Protocol Version %d, Revision %d\n",
- X_PROTOCOL, X_PROTOCOL_REVISION);
- xf86ErrorFVerb(0, "Build Operating System: %s %s\n", OSNAME, OSVENDOR);
+ xf86ErrorFVerb(0, "\nRelease Date: %s\n", XORG_DATE);
+ xf86ErrorFVerb(0, "X Protocol Version %d, Revision %d\n",
+ X_PROTOCOL, X_PROTOCOL_REVISION);
+ xf86ErrorFVerb(0, "Build Operating System: %s %s\n", OSNAME, OSVENDOR);
#ifdef HAS_UTSNAME
- {
- struct utsname name;
+ {
+ struct utsname name;
- /* Linux & BSD state that 0 is success, SysV (including Solaris, HP-UX,
- and Irix) and Single Unix Spec 3 just say that non-negative is success.
- All agree that failure is represented by a negative number.
- */
- if (uname(&name) >= 0) {
- xf86ErrorFVerb(0, "Current Operating System: %s %s %s %s %s\n",
- name.sysname, name.nodename, name.release, name.version, name.machine);
+ /* Linux & BSD state that 0 is success, SysV (including Solaris, HP-UX,
+ and Irix) and Single Unix Spec 3 just say that non-negative is success.
+ All agree that failure is represented by a negative number.
+ */
+ if (uname(&name) >= 0) {
+ xf86ErrorFVerb(0, "Current Operating System: %s %s %s %s %s\n",
+ name.sysname, name.nodename, name.release,
+ name.version, name.machine);
#ifdef linux
- do {
- char buf[80];
- int fd = open("/proc/cmdline", O_RDONLY);
- if (fd != -1) {
- xf86ErrorFVerb(0, "Kernel command line: ");
- memset(buf, 0, 80);
- while (read(fd, buf, 80) > 0) {
- xf86ErrorFVerb(0, "%.80s", buf);
- memset(buf, 0, 80);
- }
- close(fd);
- }
- } while (0);
+ do {
+ char buf[80];
+ int fd = open("/proc/cmdline", O_RDONLY);
+
+ if (fd != -1) {
+ xf86ErrorFVerb(0, "Kernel command line: ");
+ memset(buf, 0, 80);
+ while (read(fd, buf, 80) > 0) {
+ xf86ErrorFVerb(0, "%.80s", buf);
+ memset(buf, 0, 80);
+ }
+ close(fd);
+ }
+ } while (0);
#endif
+ }
}
- }
#endif
#if defined(BUILD_DATE) && (BUILD_DATE > 19000000)
- {
- struct tm t;
- char buf[100];
-
- memset(&t, 0, sizeof(t));
- memset(buf, 0, sizeof(buf));
- t.tm_mday = BUILD_DATE % 100;
- t.tm_mon = (BUILD_DATE / 100) % 100 - 1;
- t.tm_year = BUILD_DATE / 10000 - 1900;
+ {
+ struct tm t;
+ char buf[100];
+
+ memset(&t, 0, sizeof(t));
+ memset(buf, 0, sizeof(buf));
+ t.tm_mday = BUILD_DATE % 100;
+ t.tm_mon = (BUILD_DATE / 100) % 100 - 1;
+ t.tm_year = BUILD_DATE / 10000 - 1900;
#if defined(BUILD_TIME)
- t.tm_sec = BUILD_TIME % 100;
- t.tm_min = (BUILD_TIME / 100) % 100;
- t.tm_hour = (BUILD_TIME / 10000) % 100;
- if (strftime(buf, sizeof(buf), "%d %B %Y %I:%M:%S%p", &t))
- xf86ErrorFVerb(0, "Build Date: %s\n", buf);
+ t.tm_sec = BUILD_TIME % 100;
+ t.tm_min = (BUILD_TIME / 100) % 100;
+ t.tm_hour = (BUILD_TIME / 10000) % 100;
+ if (strftime(buf, sizeof(buf), "%d %B %Y %I:%M:%S%p", &t))
+ xf86ErrorFVerb(0, "Build Date: %s\n", buf);
#else
- if (strftime(buf, sizeof(buf), "%d %B %Y", &t))
- xf86ErrorFVerb(0, "Build Date: %s\n", buf);
+ if (strftime(buf, sizeof(buf), "%d %B %Y", &t))
+ xf86ErrorFVerb(0, "Build Date: %s\n", buf);
#endif
- }
+ }
#endif
#if defined(BUILDERSTRING)
- xf86ErrorFVerb(0, "%s \n", BUILDERSTRING);
+ xf86ErrorFVerb(0, "%s \n", BUILDERSTRING);
#endif
- xf86ErrorFVerb(0, "Current version of pixman: %s\n",
- pixman_version_string());
- xf86ErrorFVerb(0, "\tBefore reporting problems, check "
- ""__VENDORDWEBSUPPORT__"\n"
- "\tto make sure that you have the latest version.\n");
+ xf86ErrorFVerb(0, "Current version of pixman: %s\n",
+ pixman_version_string());
+ xf86ErrorFVerb(0, "\tBefore reporting problems, check "
+ "" __VENDORDWEBSUPPORT__ "\n"
+ "\tto make sure that you have the latest version.\n");
}
static void
xf86PrintMarkers(void)
{
- LogPrintMarkers();
+ LogPrintMarkers();
}
-Bool xf86PrivsElevated(void)
+Bool
+xf86PrivsElevated(void)
{
- static Bool privsTested = FALSE;
- static Bool privsElevated = TRUE;
+ static Bool privsTested = FALSE;
+ static Bool privsElevated = TRUE;
- if (!privsTested) {
+ if (!privsTested) {
#if defined(WIN32)
- privsElevated = FALSE;
+ privsElevated = FALSE;
#else
- if ((getuid() != geteuid()) || (getgid() != getegid())) {
- privsElevated = TRUE;
- } else {
+ if ((getuid() != geteuid()) || (getgid() != getegid())) {
+ privsElevated = TRUE;
+ }
+ else {
#if defined(HAVE_ISSETUGID)
- privsElevated = issetugid();
+ privsElevated = issetugid();
#elif defined(HAVE_GETRESUID)
- uid_t ruid, euid, suid;
- gid_t rgid, egid, sgid;
-
- if ((getresuid(&ruid, &euid, &suid) == 0) &&
- (getresgid(&rgid, &egid, &sgid) == 0)) {
- privsElevated = (euid != suid) || (egid != sgid);
- }
- else {
- printf("Failed getresuid or getresgid");
- /* Something went wrong, make defensive assumption */
- privsElevated = TRUE;
- }
+ uid_t ruid, euid, suid;
+ gid_t rgid, egid, sgid;
+
+ if ((getresuid(&ruid, &euid, &suid) == 0) &&
+ (getresgid(&rgid, &egid, &sgid) == 0)) {
+ privsElevated = (euid != suid) || (egid != sgid);
+ }
+ else {
+ printf("Failed getresuid or getresgid");
+ /* Something went wrong, make defensive assumption */
+ privsElevated = TRUE;
+ }
#else
- if (getuid()==0) {
- /* running as root: uid==euid==0 */
- privsElevated = FALSE;
- }
- else {
- /*
- * If there are saved ID's the process might still be privileged
- * even though the above test succeeded. If issetugid() and
- * getresgid() aren't available, test this by trying to set
- * euid to 0.
- */
- unsigned int oldeuid;
- oldeuid = geteuid();
-
- if (seteuid(0) != 0) {
- privsElevated = FALSE;
- } else {
- if (seteuid(oldeuid) != 0) {
- FatalError("Failed to drop privileges. Exiting\n");
- }
- privsElevated = TRUE;
+ if (getuid() == 0) {
+ /* running as root: uid==euid==0 */
+ privsElevated = FALSE;
+ }
+ else {
+ /*
+ * If there are saved ID's the process might still be privileged
+ * even though the above test succeeded. If issetugid() and
+ * getresgid() aren't available, test this by trying to set
+ * euid to 0.
+ */
+ unsigned int oldeuid;
+
+ oldeuid = geteuid();
+
+ if (seteuid(0) != 0) {
+ privsElevated = FALSE;
+ }
+ else {
+ if (seteuid(oldeuid) != 0) {
+ FatalError("Failed to drop privileges. Exiting\n");
+ }
+ privsElevated = TRUE;
+ }
+ }
+#endif
}
- }
#endif
+ privsTested = TRUE;
}
-#endif
- privsTested = TRUE;
- }
- return privsElevated;
+ return privsElevated;
}
static Bool
xf86CreateRootWindow(WindowPtr pWin)
{
- int ret = TRUE;
- int err = Success;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- RootWinPropPtr pProp;
- CreateWindowProcPtr CreateWindow = (CreateWindowProcPtr)
- dixLookupPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey);
-
- DebugF("xf86CreateRootWindow(%p)\n", pWin);
-
- if ( pScreen->CreateWindow != xf86CreateRootWindow ) {
- /* Can't find hook we are hung on */
- xf86DrvMsg(pScreen->myNum, X_WARNING /* X_ERROR */,
- "xf86CreateRootWindow %p called when not in pScreen->CreateWindow %p n",
- (void *)xf86CreateRootWindow,
- (void *)pScreen->CreateWindow );
- }
-
- /* Unhook this function ... */
- pScreen->CreateWindow = CreateWindow;
- dixSetPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey, NULL);
-
- /* ... and call the previous CreateWindow fuction, if any */
- if (NULL!=pScreen->CreateWindow) {
- ret = (*pScreen->CreateWindow)(pWin);
- }
-
- /* Now do our stuff */
- if (xf86RegisteredPropertiesTable != NULL) {
- if (pWin->parent == NULL && xf86RegisteredPropertiesTable != NULL) {
- for (pProp = xf86RegisteredPropertiesTable[pScreen->myNum];
- pProp != NULL && err==Success;
- pProp = pProp->next )
- {
- Atom prop;
-
- prop = MakeAtom(pProp->name, strlen(pProp->name), TRUE);
- err = dixChangeWindowProperty(serverClient, pWin,
- prop, pProp->type,
- pProp->format, PropModeReplace,
- pProp->size, pProp->data,
- FALSE);
- }
-
- /* Look at err */
- ret &= (err==Success);
-
- } else {
- xf86Msg(X_ERROR, "xf86CreateRootWindow unexpectedly called with "
- "non-root window %p (parent %p)\n",
- (void *)pWin, (void *)pWin->parent);
- ret = FALSE;
+ int ret = TRUE;
+ int err = Success;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ RootWinPropPtr pProp;
+ CreateWindowProcPtr CreateWindow = (CreateWindowProcPtr)
+ dixLookupPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey);
+
+ DebugF("xf86CreateRootWindow(%p)\n", pWin);
+
+ if (pScreen->CreateWindow != xf86CreateRootWindow) {
+ /* Can't find hook we are hung on */
+ xf86DrvMsg(pScreen->myNum, X_WARNING /* X_ERROR */ ,
+ "xf86CreateRootWindow %p called when not in pScreen->CreateWindow %p n",
+ (void *) xf86CreateRootWindow,
+ (void *) pScreen->CreateWindow);
}
- }
- DebugF("xf86CreateRootWindow() returns %d\n", ret);
- return ret;
-}
+ /* Unhook this function ... */
+ pScreen->CreateWindow = CreateWindow;
+ dixSetPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey, NULL);
+
+ /* ... and call the previous CreateWindow fuction, if any */
+ if (NULL != pScreen->CreateWindow) {
+ ret = (*pScreen->CreateWindow) (pWin);
+ }
+
+ /* Now do our stuff */
+ if (xf86RegisteredPropertiesTable != NULL) {
+ if (pWin->parent == NULL && xf86RegisteredPropertiesTable != NULL) {
+ for (pProp = xf86RegisteredPropertiesTable[pScreen->myNum];
+ pProp != NULL && err == Success; pProp = pProp->next) {
+ Atom prop;
+
+ prop = MakeAtom(pProp->name, strlen(pProp->name), TRUE);
+ err = dixChangeWindowProperty(serverClient, pWin,
+ prop, pProp->type,
+ pProp->format, PropModeReplace,
+ pProp->size, pProp->data, FALSE);
+ }
+
+ /* Look at err */
+ ret &= (err == Success);
+
+ }
+ else {
+ xf86Msg(X_ERROR, "xf86CreateRootWindow unexpectedly called with "
+ "non-root window %p (parent %p)\n",
+ (void *) pWin, (void *) pWin->parent);
+ ret = FALSE;
+ }
+ }
+ DebugF("xf86CreateRootWindow() returns %d\n", ret);
+ return ret;
+}
static void
InstallSignalHandlers(void)
@@ -365,20 +367,21 @@ InstallSignalHandlers(void)
/*
* Install signal handler for unexpected signals
*/
- xf86Info.caughtSignal=FALSE;
+ xf86Info.caughtSignal = FALSE;
if (!xf86Info.notrapSignals) {
- OsRegisterSigWrapper(xf86SigWrapper);
- } else {
- signal(SIGSEGV, SIG_DFL);
- signal(SIGILL, SIG_DFL);
+ OsRegisterSigWrapper(xf86SigWrapper);
+ }
+ else {
+ signal(SIGSEGV, SIG_DFL);
+ signal(SIGILL, SIG_DFL);
#ifdef SIGEMT
- signal(SIGEMT, SIG_DFL);
+ signal(SIGEMT, SIG_DFL);
#endif
- signal(SIGFPE, SIG_DFL);
- signal(SIGBUS, SIG_DFL);
- signal(SIGSYS, SIG_DFL);
- signal(SIGXCPU, SIG_DFL);
- signal(SIGXFSZ, SIG_DFL);
+ signal(SIGFPE, SIG_DFL);
+ signal(SIGBUS, SIG_DFL);
+ signal(SIGSYS, SIG_DFL);
+ signal(SIGXCPU, SIG_DFL);
+ signal(SIGXFSZ, SIG_DFL);
}
}
@@ -389,485 +392,500 @@ InstallSignalHandlers(void)
* collecting the pixmap formats.
*/
void
-InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
+InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
{
- int i, j, k, scr_index, was_blocked = 0;
- char **modulelist;
- pointer *optionlist;
- Pix24Flags screenpix24, pix24;
- MessageType pix24From = X_DEFAULT;
- Bool pix24Fail = FALSE;
- Bool autoconfig = FALSE;
- GDevPtr configured_device;
-
- xf86Initialising = TRUE;
-
- if (serverGeneration == 1) {
- if ((xf86ServerName = strrchr(argv[0], '/')) != 0)
- xf86ServerName++;
- else
- xf86ServerName = argv[0];
-
- xf86PrintBanner();
- xf86PrintMarkers();
- if (xf86LogFile) {
- time_t t;
- const char *ct;
- t = time(NULL);
- ct = ctime(&t);
- xf86MsgVerb(xf86LogFileFrom, 0, "Log file: \"%s\", Time: %s",
- xf86LogFile, ct);
- }
-
- /* Read and parse the config file */
- if (!xf86DoConfigure && !xf86DoShowOptions) {
- switch (xf86HandleConfigFile(FALSE)) {
- case CONFIG_OK:
- break;
- case CONFIG_PARSE_ERROR:
- xf86Msg(X_ERROR, "Error parsing the config file\n");
- return;
- case CONFIG_NOFILE:
- autoconfig = TRUE;
- break;
- }
- }
+ int i, j, k, scr_index, was_blocked = 0;
+ char **modulelist;
+ pointer *optionlist;
+ Pix24Flags screenpix24, pix24;
+ MessageType pix24From = X_DEFAULT;
+ Bool pix24Fail = FALSE;
+ Bool autoconfig = FALSE;
+ GDevPtr configured_device;
+
+ xf86Initialising = TRUE;
+
+ if (serverGeneration == 1) {
+ if ((xf86ServerName = strrchr(argv[0], '/')) != 0)
+ xf86ServerName++;
+ else
+ xf86ServerName = argv[0];
+
+ xf86PrintBanner();
+ xf86PrintMarkers();
+ if (xf86LogFile) {
+ time_t t;
+ const char *ct;
+
+ t = time(NULL);
+ ct = ctime(&t);
+ xf86MsgVerb(xf86LogFileFrom, 0, "Log file: \"%s\", Time: %s",
+ xf86LogFile, ct);
+ }
- InstallSignalHandlers();
+ /* Read and parse the config file */
+ if (!xf86DoConfigure && !xf86DoShowOptions) {
+ switch (xf86HandleConfigFile(FALSE)) {
+ case CONFIG_OK:
+ break;
+ case CONFIG_PARSE_ERROR:
+ xf86Msg(X_ERROR, "Error parsing the config file\n");
+ return;
+ case CONFIG_NOFILE:
+ autoconfig = TRUE;
+ break;
+ }
+ }
- /* Initialise the loader */
- LoaderInit();
+ InstallSignalHandlers();
- /* Tell the loader the default module search path */
- LoaderSetPath(xf86ModulePath);
+ /* Initialise the loader */
+ LoaderInit();
- if (xf86Info.ignoreABI) {
- LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL);
- }
+ /* Tell the loader the default module search path */
+ LoaderSetPath(xf86ModulePath);
- if (xf86DoShowOptions)
- DoShowOptions();
+ if (xf86Info.ignoreABI) {
+ LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL);
+ }
- /* Do a general bus probe. This will be a PCI probe for x86 platforms */
- xf86BusProbe();
+ if (xf86DoShowOptions)
+ DoShowOptions();
- if (xf86DoConfigure)
- DoConfigure();
+ /* Do a general bus probe. This will be a PCI probe for x86 platforms */
+ xf86BusProbe();
- if (autoconfig) {
- if (!xf86AutoConfig()) {
- xf86Msg(X_ERROR, "Auto configuration failed\n");
- return;
- }
- }
+ if (xf86DoConfigure)
+ DoConfigure();
+
+ if (autoconfig) {
+ if (!xf86AutoConfig()) {
+ xf86Msg(X_ERROR, "Auto configuration failed\n");
+ return;
+ }
+ }
#ifdef XF86PM
- xf86OSPMClose = xf86OSPMOpen();
+ xf86OSPMClose = xf86OSPMOpen();
#endif
- /* Load all modules specified explicitly in the config file */
- if ((modulelist = xf86ModulelistFromConfig(&optionlist))) {
- xf86LoadModules(modulelist, optionlist);
- free(modulelist);
- free(optionlist);
- }
+ /* Load all modules specified explicitly in the config file */
+ if ((modulelist = xf86ModulelistFromConfig(&optionlist))) {
+ xf86LoadModules(modulelist, optionlist);
+ free(modulelist);
+ free(optionlist);
+ }
- /* Load all driver modules specified in the config file */
- /* If there aren't any specified in the config file, autoconfig them */
- /* FIXME: Does not handle multiple active screen sections, but I'm not
- * sure if we really want to handle that case*/
- configured_device = xf86ConfigLayout.screens->screen->device;
- if ((!configured_device) || (!configured_device->driver)) {
- if (!autoConfigDevice(configured_device)) {
- xf86Msg(X_ERROR, "Automatic driver configuration failed\n");
- return ;
+ /* Load all driver modules specified in the config file */
+ /* If there aren't any specified in the config file, autoconfig them */
+ /* FIXME: Does not handle multiple active screen sections, but I'm not
+ * sure if we really want to handle that case*/
+ configured_device = xf86ConfigLayout.screens->screen->device;
+ if ((!configured_device) || (!configured_device->driver)) {
+ if (!autoConfigDevice(configured_device)) {
+ xf86Msg(X_ERROR, "Automatic driver configuration failed\n");
+ return;
+ }
+ }
+ if ((modulelist = xf86DriverlistFromConfig())) {
+ xf86LoadModules(modulelist, NULL);
+ free(modulelist);
}
- }
- if ((modulelist = xf86DriverlistFromConfig())) {
- xf86LoadModules(modulelist, NULL);
- free(modulelist);
- }
- /* Load all input driver modules specified in the config file. */
- if ((modulelist = xf86InputDriverlistFromConfig())) {
- xf86LoadModules(modulelist, NULL);
- free(modulelist);
- }
+ /* Load all input driver modules specified in the config file. */
+ if ((modulelist = xf86InputDriverlistFromConfig())) {
+ xf86LoadModules(modulelist, NULL);
+ free(modulelist);
+ }
- /*
- * It is expected that xf86AddDriver()/xf86AddInputDriver will be
- * called for each driver as it is loaded. Those functions save the
- * module pointers for drivers.
- * XXX Nothing keeps track of them for other modules.
- */
- /* XXX What do we do if not all of these could be loaded? */
+ /*
+ * It is expected that xf86AddDriver()/xf86AddInputDriver will be
+ * called for each driver as it is loaded. Those functions save the
+ * module pointers for drivers.
+ * XXX Nothing keeps track of them for other modules.
+ */
+ /* XXX What do we do if not all of these could be loaded? */
- /*
- * At this point, xf86DriverList[] is all filled in with entries for
- * each of the drivers to try and xf86NumDrivers has the number of
- * drivers. If there are none, return now.
- */
+ /*
+ * At this point, xf86DriverList[] is all filled in with entries for
+ * each of the drivers to try and xf86NumDrivers has the number of
+ * drivers. If there are none, return now.
+ */
- if (xf86NumDrivers == 0) {
- xf86Msg(X_ERROR, "No drivers available.\n");
- return;
- }
+ if (xf86NumDrivers == 0) {
+ xf86Msg(X_ERROR, "No drivers available.\n");
+ return;
+ }
- /*
- * Call each of the Identify functions and call the driverFunc to check
- * if HW access is required. The Identify functions print out some
- * identifying information, and anything else that might be
- * needed at this early stage.
- */
+ /*
+ * Call each of the Identify functions and call the driverFunc to check
+ * if HW access is required. The Identify functions print out some
+ * identifying information, and anything else that might be
+ * needed at this early stage.
+ */
- for (i = 0; i < xf86NumDrivers; i++) {
- if (xf86DriverList[i]->Identify != NULL)
- xf86DriverList[i]->Identify(0);
-
- if (!xorgHWAccess || !xorgHWOpenConsole) {
- xorgHWFlags flags;
- if(!xf86DriverList[i]->driverFunc
- || !xf86DriverList[i]->driverFunc(NULL,
- GET_REQUIRED_HW_INTERFACES,
- &flags))
- flags = HW_IO;
-
- if(NEED_IO_ENABLED(flags))
- xorgHWAccess = TRUE;
- if(!(flags & HW_SKIP_CONSOLE))
- xorgHWOpenConsole = TRUE;
- }
- }
+ for (i = 0; i < xf86NumDrivers; i++) {
+ if (xf86DriverList[i]->Identify != NULL)
+ xf86DriverList[i]->Identify(0);
- if (xorgHWOpenConsole)
- xf86OpenConsole();
- else
- xf86Info.dontVTSwitch = TRUE;
+ if (!xorgHWAccess || !xorgHWOpenConsole) {
+ xorgHWFlags flags;
- if (xf86BusConfig() == FALSE)
- return;
+ if (!xf86DriverList[i]->driverFunc
+ || !xf86DriverList[i]->driverFunc(NULL,
+ GET_REQUIRED_HW_INTERFACES,
+ &flags))
+ flags = HW_IO;
- xf86PostProbe();
+ if (NEED_IO_ENABLED(flags))
+ xorgHWAccess = TRUE;
+ if (!(flags & HW_SKIP_CONSOLE))
+ xorgHWOpenConsole = TRUE;
+ }
+ }
- /*
- * Sort the drivers to match the requested ording. Using a slow
- * bubble sort.
- */
- for (j = 0; j < xf86NumScreens - 1; j++) {
- for (i = 0; i < xf86NumScreens - j - 1; i++) {
- if (xf86Screens[i + 1]->confScreen->screennum <
- xf86Screens[i]->confScreen->screennum) {
- ScrnInfoPtr tmpScrn = xf86Screens[i + 1];
- xf86Screens[i + 1] = xf86Screens[i];
- xf86Screens[i] = tmpScrn;
- }
- }
- }
- /* Fix up the indexes */
- for (i = 0; i < xf86NumScreens; i++) {
- xf86Screens[i]->scrnIndex = i;
- }
+ if (xorgHWOpenConsole)
+ xf86OpenConsole();
+ else
+ xf86Info.dontVTSwitch = TRUE;
- /*
- * Call the driver's PreInit()'s to complete initialisation for the first
- * generation.
- */
+ if (xf86BusConfig() == FALSE)
+ return;
- for (i = 0; i < xf86NumScreens; i++) {
- xf86VGAarbiterScrnInit(xf86Screens[i]);
- xf86VGAarbiterLock(xf86Screens[i]);
- if (xf86Screens[i]->PreInit &&
- xf86Screens[i]->PreInit(xf86Screens[i], 0))
- xf86Screens[i]->configured = TRUE;
- xf86VGAarbiterUnlock(xf86Screens[i]);
- }
- for (i = 0; i < xf86NumScreens; i++)
- if (!xf86Screens[i]->configured)
- xf86DeleteScreen(i--, 0);
+ xf86PostProbe();
- /*
- * If no screens left, return now.
- */
+ /*
+ * Sort the drivers to match the requested ording. Using a slow
+ * bubble sort.
+ */
+ for (j = 0; j < xf86NumScreens - 1; j++) {
+ for (i = 0; i < xf86NumScreens - j - 1; i++) {
+ if (xf86Screens[i + 1]->confScreen->screennum <
+ xf86Screens[i]->confScreen->screennum) {
+ ScrnInfoPtr tmpScrn = xf86Screens[i + 1];
+
+ xf86Screens[i + 1] = xf86Screens[i];
+ xf86Screens[i] = tmpScrn;
+ }
+ }
+ }
+ /* Fix up the indexes */
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86Screens[i]->scrnIndex = i;
+ }
- if (xf86NumScreens == 0) {
- xf86Msg(X_ERROR,
- "Screen(s) found, but none have a usable configuration.\n");
- return;
- }
+ /*
+ * Call the driver's PreInit()'s to complete initialisation for the first
+ * generation.
+ */
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->name == NULL) {
- XNFasprintf(&xf86Screens[i]->name, "screen%d", i);
- xf86MsgVerb(X_WARNING, 0,
- "Screen driver %d has no name set, using `%s'.\n",
- i, xf86Screens[i]->name);
- }
- }
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86VGAarbiterScrnInit(xf86Screens[i]);
+ xf86VGAarbiterLock(xf86Screens[i]);
+ if (xf86Screens[i]->PreInit &&
+ xf86Screens[i]->PreInit(xf86Screens[i], 0))
+ xf86Screens[i]->configured = TRUE;
+ xf86VGAarbiterUnlock(xf86Screens[i]);
+ }
+ for (i = 0; i < xf86NumScreens; i++)
+ if (!xf86Screens[i]->configured)
+ xf86DeleteScreen(i--, 0);
- /* Remove (unload) drivers that are not required */
- for (i = 0; i < xf86NumDrivers; i++)
- if (xf86DriverList[i] && xf86DriverList[i]->refCount <= 0)
- xf86DeleteDriver(i);
+ /*
+ * If no screens left, return now.
+ */
- /*
- * At this stage we know how many screens there are.
- */
+ if (xf86NumScreens == 0) {
+ xf86Msg(X_ERROR,
+ "Screen(s) found, but none have a usable configuration.\n");
+ return;
+ }
- for (i = 0; i < xf86NumScreens; i++)
- xf86InitViewport(xf86Screens[i]);
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->name == NULL) {
+ XNFasprintf(&xf86Screens[i]->name, "screen%d", i);
+ xf86MsgVerb(X_WARNING, 0,
+ "Screen driver %d has no name set, using `%s'.\n",
+ i, xf86Screens[i]->name);
+ }
+ }
- /*
- * Collect all pixmap formats and check for conflicts at the display
- * level. Should we die here? Or just delete the offending screens?
- */
- screenpix24 = Pix24DontCare;
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->imageByteOrder !=
- xf86Screens[0]->imageByteOrder)
- FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
- if (xf86Screens[i]->bitmapScanlinePad !=
- xf86Screens[0]->bitmapScanlinePad)
- FatalError("Inconsistent display bitmapScanlinePad. Exiting\n");
- if (xf86Screens[i]->bitmapScanlineUnit !=
- xf86Screens[0]->bitmapScanlineUnit)
- FatalError("Inconsistent display bitmapScanlineUnit. Exiting\n");
- if (xf86Screens[i]->bitmapBitOrder !=
- xf86Screens[0]->bitmapBitOrder)
- FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
-
- /* Determine the depth 24 pixmap format the screens would like */
- if (xf86Screens[i]->pixmap24 != Pix24DontCare) {
- if (screenpix24 == Pix24DontCare)
- screenpix24 = xf86Screens[i]->pixmap24;
- else if (screenpix24 != xf86Screens[i]->pixmap24)
- FatalError("Inconsistent depth 24 pixmap format. Exiting\n");
- }
- }
- /* check if screenpix24 is consistent with the config/cmdline */
- if (xf86Info.pixmap24 != Pix24DontCare) {
- pix24 = xf86Info.pixmap24;
- pix24From = xf86Info.pix24From;
- if (screenpix24 != Pix24DontCare && screenpix24 != xf86Info.pixmap24)
- pix24Fail = TRUE;
- } else if (screenpix24 != Pix24DontCare) {
- pix24 = screenpix24;
- pix24From = X_PROBED;
- } else
- pix24 = Pix24Use32;
-
- if (pix24Fail)
- FatalError("Screen(s) can't use the required depth 24 pixmap format"
- " (%d). Exiting\n", PIX24TOBPP(pix24));
-
- /* Initialise the depth 24 format */
- for (j = 0; j < numFormats && formats[j].depth != 24; j++)
- ;
- formats[j].bitsPerPixel = PIX24TOBPP(pix24);
-
- /* Collect additional formats */
- for (i = 0; i < xf86NumScreens; i++) {
- for (j = 0; j < xf86Screens[i]->numFormats; j++) {
- for (k = 0; ; k++) {
- if (k >= numFormats) {
- if (k >= MAXFORMATS)
- FatalError("Too many pixmap formats! Exiting\n");
- formats[k] = xf86Screens[i]->formats[j];
- numFormats++;
- break;
- }
- if (formats[k].depth == xf86Screens[i]->formats[j].depth) {
- if ((formats[k].bitsPerPixel ==
- xf86Screens[i]->formats[j].bitsPerPixel) &&
- (formats[k].scanlinePad ==
- xf86Screens[i]->formats[j].scanlinePad))
- break;
- FatalError("Inconsistent pixmap format for depth %d."
- " Exiting\n", formats[k].depth);
- }
- }
- }
- }
- formatsDone = TRUE;
+ /* Remove (unload) drivers that are not required */
+ for (i = 0; i < xf86NumDrivers; i++)
+ if (xf86DriverList[i] && xf86DriverList[i]->refCount <= 0)
+ xf86DeleteDriver(i);
- if (xf86Info.vtno >= 0 ) {
-#define VT_ATOM_NAME "XFree86_VT"
- Atom VTAtom=-1;
- CARD32 *VT = NULL;
- int ret;
-
- /* This memory needs to stay available until the screen has been
- initialized, and we can create the property for real.
- */
- if ( (VT = malloc(sizeof(CARD32)))==NULL ) {
- FatalError("Unable to make VT property - out of memory. Exiting...\n");
- }
- *VT = xf86Info.vtno;
-
- VTAtom = MakeAtom(VT_ATOM_NAME, sizeof(VT_ATOM_NAME) - 1, TRUE);
-
- for (i = 0, ret = Success; i < xf86NumScreens && ret == Success; i++) {
- ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex,
- VTAtom, XA_INTEGER, 32,
- 1, VT );
- if (ret != Success)
- xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING,
- "Failed to register VT property\n");
- }
- }
+ /*
+ * At this stage we know how many screens there are.
+ */
+
+ for (i = 0; i < xf86NumScreens; i++)
+ xf86InitViewport(xf86Screens[i]);
+
+ /*
+ * Collect all pixmap formats and check for conflicts at the display
+ * level. Should we die here? Or just delete the offending screens?
+ */
+ screenpix24 = Pix24DontCare;
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->imageByteOrder !=
+ xf86Screens[0]->imageByteOrder)
+ FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
+ if (xf86Screens[i]->bitmapScanlinePad !=
+ xf86Screens[0]->bitmapScanlinePad)
+ FatalError
+ ("Inconsistent display bitmapScanlinePad. Exiting\n");
+ if (xf86Screens[i]->bitmapScanlineUnit !=
+ xf86Screens[0]->bitmapScanlineUnit)
+ FatalError
+ ("Inconsistent display bitmapScanlineUnit. Exiting\n");
+ if (xf86Screens[i]->bitmapBitOrder !=
+ xf86Screens[0]->bitmapBitOrder)
+ FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
+
+ /* Determine the depth 24 pixmap format the screens would like */
+ if (xf86Screens[i]->pixmap24 != Pix24DontCare) {
+ if (screenpix24 == Pix24DontCare)
+ screenpix24 = xf86Screens[i]->pixmap24;
+ else if (screenpix24 != xf86Screens[i]->pixmap24)
+ FatalError
+ ("Inconsistent depth 24 pixmap format. Exiting\n");
+ }
+ }
+ /* check if screenpix24 is consistent with the config/cmdline */
+ if (xf86Info.pixmap24 != Pix24DontCare) {
+ pix24 = xf86Info.pixmap24;
+ pix24From = xf86Info.pix24From;
+ if (screenpix24 != Pix24DontCare &&
+ screenpix24 != xf86Info.pixmap24)
+ pix24Fail = TRUE;
+ }
+ else if (screenpix24 != Pix24DontCare) {
+ pix24 = screenpix24;
+ pix24From = X_PROBED;
+ }
+ else
+ pix24 = Pix24Use32;
- if (SeatId) {
- Atom SeatAtom;
+ if (pix24Fail)
+ FatalError("Screen(s) can't use the required depth 24 pixmap format"
+ " (%d). Exiting\n", PIX24TOBPP(pix24));
- SeatAtom = MakeAtom(SEAT_ATOM_NAME, sizeof(SEAT_ATOM_NAME) - 1, TRUE);
+ /* Initialise the depth 24 format */
+ for (j = 0; j < numFormats && formats[j].depth != 24; j++);
+ formats[j].bitsPerPixel = PIX24TOBPP(pix24);
+ /* Collect additional formats */
for (i = 0; i < xf86NumScreens; i++) {
+ for (j = 0; j < xf86Screens[i]->numFormats; j++) {
+ for (k = 0;; k++) {
+ if (k >= numFormats) {
+ if (k >= MAXFORMATS)
+ FatalError("Too many pixmap formats! Exiting\n");
+ formats[k] = xf86Screens[i]->formats[j];
+ numFormats++;
+ break;
+ }
+ if (formats[k].depth == xf86Screens[i]->formats[j].depth) {
+ if ((formats[k].bitsPerPixel ==
+ xf86Screens[i]->formats[j].bitsPerPixel) &&
+ (formats[k].scanlinePad ==
+ xf86Screens[i]->formats[j].scanlinePad))
+ break;
+ FatalError("Inconsistent pixmap format for depth %d."
+ " Exiting\n", formats[k].depth);
+ }
+ }
+ }
+ }
+ formatsDone = TRUE;
+
+ if (xf86Info.vtno >= 0) {
+#define VT_ATOM_NAME "XFree86_VT"
+ Atom VTAtom = -1;
+ CARD32 *VT = NULL;
int ret;
- ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex,
- SeatAtom, XA_STRING, 8,
- strlen(SeatId)+1, SeatId );
- if (ret != Success) {
- xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING,
- "Failed to register seat property\n");
+ /* This memory needs to stay available until the screen has been
+ initialized, and we can create the property for real.
+ */
+ if ((VT = malloc(sizeof(CARD32))) == NULL) {
+ FatalError
+ ("Unable to make VT property - out of memory. Exiting...\n");
+ }
+ *VT = xf86Info.vtno;
+
+ VTAtom = MakeAtom(VT_ATOM_NAME, sizeof(VT_ATOM_NAME) - 1, TRUE);
+
+ for (i = 0, ret = Success; i < xf86NumScreens && ret == Success;
+ i++) {
+ ret =
+ xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex,
+ VTAtom, XA_INTEGER, 32, 1,
+ VT);
+ if (ret != Success)
+ xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING,
+ "Failed to register VT property\n");
+ }
+ }
+
+ if (SeatId) {
+ Atom SeatAtom;
+
+ SeatAtom =
+ MakeAtom(SEAT_ATOM_NAME, sizeof(SEAT_ATOM_NAME) - 1, TRUE);
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ int ret;
+
+ ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex,
+ SeatAtom, XA_STRING, 8,
+ strlen(SeatId) + 1,
+ SeatId);
+ if (ret != Success) {
+ xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING,
+ "Failed to register seat property\n");
+ }
+ }
+ }
+
+ /* If a screen uses depth 24, show what the pixmap format is */
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->depth == 24) {
+ xf86Msg(pix24From, "Depth 24 pixmap format is %d bpp\n",
+ PIX24TOBPP(pix24));
+ break;
}
}
}
+ else {
+ /*
+ * serverGeneration != 1; some OSs have to do things here, too.
+ */
+ if (xorgHWOpenConsole)
+ xf86OpenConsole();
- /* If a screen uses depth 24, show what the pixmap format is */
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->depth == 24) {
- xf86Msg(pix24From, "Depth 24 pixmap format is %d bpp\n",
- PIX24TOBPP(pix24));
- break;
- }
+#ifdef XF86PM
+ /*
+ should we reopen it here? We need to deal with an already opened
+ device. We could leave this to the OS layer. For now we simply
+ close it here
+ */
+ if (xf86OSPMClose)
+ xf86OSPMClose();
+ if ((xf86OSPMClose = xf86OSPMOpen()) != NULL)
+ xf86MsgVerb(X_INFO, 3, "APM registered successfully\n");
+#endif
+
+ /* Make sure full I/O access is enabled */
+ if (xorgHWAccess)
+ xf86EnableIO();
}
- } else {
+
/*
- * serverGeneration != 1; some OSs have to do things here, too.
+ * Use the previously collected parts to setup pScreenInfo
*/
- if (xorgHWOpenConsole)
- xf86OpenConsole();
-#ifdef XF86PM
- /*
- should we reopen it here? We need to deal with an already opened
- device. We could leave this to the OS layer. For now we simply
- close it here
- */
- if (xf86OSPMClose)
- xf86OSPMClose();
- if ((xf86OSPMClose = xf86OSPMOpen()) != NULL)
- xf86MsgVerb(X_INFO, 3, "APM registered successfully\n");
-#endif
+ pScreenInfo->imageByteOrder = xf86Screens[0]->imageByteOrder;
+ pScreenInfo->bitmapScanlinePad = xf86Screens[0]->bitmapScanlinePad;
+ pScreenInfo->bitmapScanlineUnit = xf86Screens[0]->bitmapScanlineUnit;
+ pScreenInfo->bitmapBitOrder = xf86Screens[0]->bitmapBitOrder;
+ pScreenInfo->numPixmapFormats = numFormats;
+ for (i = 0; i < numFormats; i++)
+ pScreenInfo->formats[i] = formats[i];
- /* Make sure full I/O access is enabled */
- if (xorgHWAccess)
- xf86EnableIO();
- }
-
- /*
- * Use the previously collected parts to setup pScreenInfo
- */
-
- pScreenInfo->imageByteOrder = xf86Screens[0]->imageByteOrder;
- pScreenInfo->bitmapScanlinePad = xf86Screens[0]->bitmapScanlinePad;
- pScreenInfo->bitmapScanlineUnit = xf86Screens[0]->bitmapScanlineUnit;
- pScreenInfo->bitmapBitOrder = xf86Screens[0]->bitmapBitOrder;
- pScreenInfo->numPixmapFormats = numFormats;
- for (i = 0; i < numFormats; i++)
- pScreenInfo->formats[i] = formats[i];
-
- /* Make sure the server's VT is active */
-
- if (serverGeneration != 1) {
- xf86Resetting = TRUE;
- /* All screens are in the same state, so just check the first */
- if (!xf86Screens[0]->vtSema) {
+ /* Make sure the server's VT is active */
+
+ if (serverGeneration != 1) {
+ xf86Resetting = TRUE;
+ /* All screens are in the same state, so just check the first */
+ if (!xf86Screens[0]->vtSema) {
#ifdef HAS_USL_VTS
- ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ);
+ ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ);
#endif
- xf86AccessEnter();
- was_blocked = xf86BlockSIGIO();
+ xf86AccessEnter();
+ was_blocked = xf86BlockSIGIO();
+ }
}
- }
-
- for (i = 0; i < xf86NumScreens; i++)
- if (!xf86ColormapAllocatePrivates(xf86Screens[i]))
- FatalError("Cannot register DDX private keys");
-
- if (!dixRegisterPrivateKey(&xf86ScreenKeyRec, PRIVATE_SCREEN, 0) ||
- !dixRegisterPrivateKey(&xf86CreateRootWindowKeyRec, PRIVATE_SCREEN, 0))
- FatalError("Cannot register DDX private keys");
-
- for (i = 0; i < xf86NumScreens; i++) {
- xf86VGAarbiterLock(xf86Screens[i]);
- /*
- * Almost everything uses these defaults, and many of those that
- * don't, will wrap them.
- */
- xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess;
+
+ for (i = 0; i < xf86NumScreens; i++)
+ if (!xf86ColormapAllocatePrivates(xf86Screens[i]))
+ FatalError("Cannot register DDX private keys");
+
+ if (!dixRegisterPrivateKey(&xf86ScreenKeyRec, PRIVATE_SCREEN, 0) ||
+ !dixRegisterPrivateKey(&xf86CreateRootWindowKeyRec, PRIVATE_SCREEN, 0))
+ FatalError("Cannot register DDX private keys");
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86VGAarbiterLock(xf86Screens[i]);
+ /*
+ * Almost everything uses these defaults, and many of those that
+ * don't, will wrap them.
+ */
+ xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess;
#ifdef XFreeXDGA
- xf86Screens[i]->SetDGAMode = xf86SetDGAMode;
+ xf86Screens[i]->SetDGAMode = xf86SetDGAMode;
#endif
- xf86Screens[i]->DPMSSet = NULL;
- xf86Screens[i]->LoadPalette = NULL;
- xf86Screens[i]->SetOverscan = NULL;
- xf86Screens[i]->DriverFunc = NULL;
- xf86Screens[i]->pScreen = NULL;
- scr_index = AddScreen(xf86Screens[i]->ScreenInit, argc, argv);
- xf86VGAarbiterUnlock(xf86Screens[i]);
- if (scr_index == i) {
- /*
- * Hook in our ScrnInfoRec, and initialise some other pScreen
- * fields.
- */
- dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
- xf86ScreenKey, xf86Screens[i]);
- xf86Screens[i]->pScreen = screenInfo.screens[scr_index];
- /* The driver should set this, but make sure it is set anyway */
- xf86Screens[i]->vtSema = TRUE;
- } else {
- /* This shouldn't normally happen */
- FatalError("AddScreen/ScreenInit failed for driver %d\n", i);
- }
-
- DebugF("InitOutput - xf86Screens[%d]->pScreen = %p\n",
- i, xf86Screens[i]->pScreen );
- DebugF("xf86Screens[%d]->pScreen->CreateWindow = %p\n",
- i, xf86Screens[i]->pScreen->CreateWindow );
-
- dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
- xf86CreateRootWindowKey,
- xf86Screens[i]->pScreen->CreateWindow);
- xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow;
-
- if (PictureGetSubpixelOrder (xf86Screens[i]->pScreen) == SubPixelUnknown)
- {
- xf86MonPtr DDC = (xf86MonPtr)(xf86Screens[i]->monitor->DDC);
- PictureSetSubpixelOrder (xf86Screens[i]->pScreen,
- DDC ?
- (DDC->features.input_type ?
- SubPixelHorizontalRGB : SubPixelNone) :
- SubPixelUnknown);
- }
+ xf86Screens[i]->DPMSSet = NULL;
+ xf86Screens[i]->LoadPalette = NULL;
+ xf86Screens[i]->SetOverscan = NULL;
+ xf86Screens[i]->DriverFunc = NULL;
+ xf86Screens[i]->pScreen = NULL;
+ scr_index = AddScreen(xf86Screens[i]->ScreenInit, argc, argv);
+ xf86VGAarbiterUnlock(xf86Screens[i]);
+ if (scr_index == i) {
+ /*
+ * Hook in our ScrnInfoRec, and initialise some other pScreen
+ * fields.
+ */
+ dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
+ xf86ScreenKey, xf86Screens[i]);
+ xf86Screens[i]->pScreen = screenInfo.screens[scr_index];
+ /* The driver should set this, but make sure it is set anyway */
+ xf86Screens[i]->vtSema = TRUE;
+ }
+ else {
+ /* This shouldn't normally happen */
+ FatalError("AddScreen/ScreenInit failed for driver %d\n", i);
+ }
+
+ DebugF("InitOutput - xf86Screens[%d]->pScreen = %p\n",
+ i, xf86Screens[i]->pScreen);
+ DebugF("xf86Screens[%d]->pScreen->CreateWindow = %p\n",
+ i, xf86Screens[i]->pScreen->CreateWindow);
+
+ dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
+ xf86CreateRootWindowKey,
+ xf86Screens[i]->pScreen->CreateWindow);
+ xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow;
+
+ if (PictureGetSubpixelOrder(xf86Screens[i]->pScreen) == SubPixelUnknown) {
+ xf86MonPtr DDC = (xf86MonPtr) (xf86Screens[i]->monitor->DDC);
+
+ PictureSetSubpixelOrder(xf86Screens[i]->pScreen,
+ DDC ?
+ (DDC->features.input_type ?
+ SubPixelHorizontalRGB : SubPixelNone) :
+ SubPixelUnknown);
+ }
#ifdef RANDR
- if (!xf86Info.disableRandR)
- xf86RandRInit (screenInfo.screens[scr_index]);
- xf86Msg(xf86Info.randRFrom, "RandR %s\n",
- xf86Info.disableRandR ? "disabled" : "enabled");
+ if (!xf86Info.disableRandR)
+ xf86RandRInit(screenInfo.screens[scr_index]);
+ xf86Msg(xf86Info.randRFrom, "RandR %s\n",
+ xf86Info.disableRandR ? "disabled" : "enabled");
#endif
- }
+ }
- xf86VGAarbiterWrapFunctions();
- xf86UnblockSIGIO(was_blocked);
+ xf86VGAarbiterWrapFunctions();
+ xf86UnblockSIGIO(was_blocked);
- xf86InitOrigins();
+ xf86InitOrigins();
- xf86Resetting = FALSE;
- xf86Initialising = FALSE;
+ xf86Resetting = FALSE;
+ xf86Initialising = FALSE;
- RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA, xf86Wakeup,
- NULL);
+ RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr) NoopDDA, xf86Wakeup,
+ NULL);
}
/**
@@ -877,7 +895,7 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
void
InitInput(int argc, char **argv)
{
- InputInfoPtr* pInfo;
+ InputInfoPtr *pInfo;
DeviceIntPtr dev;
xf86Info.vtRequestsPending = FALSE;
@@ -886,8 +904,10 @@ InitInput(int argc, char **argv)
/* Initialize all configured input devices */
for (pInfo = xf86ConfigLayout.inputs; pInfo && *pInfo; pInfo++) {
- (*pInfo)->options = xf86AddNewOption((*pInfo)->options, "driver", (*pInfo)->driver);
- (*pInfo)->options = xf86AddNewOption((*pInfo)->options, "identifier", (*pInfo)->name);
+ (*pInfo)->options =
+ xf86AddNewOption((*pInfo)->options, "driver", (*pInfo)->driver);
+ (*pInfo)->options =
+ xf86AddNewOption((*pInfo)->options, "identifier", (*pInfo)->name);
/* If one fails, the others will too */
if (NewInputDeviceRequest((*pInfo)->options, NULL, &dev) == BadAlloc)
break;
@@ -897,7 +917,7 @@ InitInput(int argc, char **argv)
}
void
-CloseInput (void)
+CloseInput(void)
{
config_fini();
mieqFini();
@@ -912,16 +932,16 @@ CloseInput (void)
void
OsVendorInit(void)
{
- static Bool beenHere = FALSE;
+ static Bool beenHere = FALSE;
- signal(SIGCHLD, SIG_DFL); /* Need to wait for child processes */
+ signal(SIGCHLD, SIG_DFL); /* Need to wait for child processes */
- if (!beenHere) {
- umask(022);
- xf86LogInit();
- }
+ if (!beenHere) {
+ umask(022);
+ xf86LogInit();
+ }
- /* Set stderr to non-blocking. */
+ /* Set stderr to non-blocking. */
#ifndef O_NONBLOCK
#if defined(FNDELAY)
#define O_NONBLOCK FNDELAY
@@ -930,21 +950,20 @@ OsVendorInit(void)
#endif
#ifdef O_NONBLOCK
- if (!beenHere) {
- if (xf86PrivsElevated())
- {
- int status;
+ if (!beenHere) {
+ if (xf86PrivsElevated()) {
+ int status;
- status = fcntl(fileno(stderr), F_GETFL, 0);
- if (status != -1) {
- fcntl(fileno(stderr), F_SETFL, status | O_NONBLOCK);
- }
+ status = fcntl(fileno(stderr), F_GETFL, 0);
+ if (status != -1) {
+ fcntl(fileno(stderr), F_SETFL, status | O_NONBLOCK);
+ }
+ }
}
- }
#endif
#endif
- beenHere = TRUE;
+ beenHere = TRUE;
}
/*
@@ -963,16 +982,16 @@ ddxGiveUp(enum ExitCode error)
#ifdef XF86PM
if (xf86OSPMClose)
- xf86OSPMClose();
+ xf86OSPMClose();
xf86OSPMClose = NULL;
#endif
for (i = 0; i < xf86NumScreens; i++) {
- /*
- * zero all access functions to
- * trap calls when switched away.
- */
- xf86Screens[i]->vtSema = FALSE;
+ /*
+ * zero all access functions to
+ * trap calls when switched away.
+ */
+ xf86Screens[i]->vtSema = FALSE;
}
#ifdef XFreeXDGA
@@ -980,17 +999,15 @@ ddxGiveUp(enum ExitCode error)
#endif
if (xorgHWOpenConsole)
- xf86CloseConsole();
+ xf86CloseConsole();
xf86CloseLog(error);
/* If an unexpected signal was caught, dump a core for debugging */
if (xf86Info.caughtSignal)
- OsAbort();
+ OsAbort();
}
-
-
/*
* AbortDDX --
* DDX - specific abort routine. Called by AbortServer(). The attempt is
@@ -1001,38 +1018,38 @@ ddxGiveUp(enum ExitCode error)
void
AbortDDX(enum ExitCode error)
{
- int i;
+ int i;
- xf86BlockSIGIO();
+ xf86BlockSIGIO();
- /*
- * try to restore the original video state
- */
-#ifdef DPMSExtension /* Turn screens back on */
- if (DPMSPowerLevel != DPMSModeOn)
- DPMSSet(serverClient, DPMSModeOn);
+ /*
+ * try to restore the original video state
+ */
+#ifdef DPMSExtension /* Turn screens back on */
+ if (DPMSPowerLevel != DPMSModeOn)
+ DPMSSet(serverClient, DPMSModeOn);
#endif
- if (xf86Screens) {
- for (i = 0; i < xf86NumScreens; i++)
- if (xf86Screens[i]->vtSema) {
- /*
- * if we are aborting before ScreenInit() has finished
- * we might not have been wrapped yet. Therefore enable
- * screen explicitely.
- */
- xf86VGAarbiterLock(xf86Screens[i]);
- (xf86Screens[i]->LeaveVT)(i, 0);
- xf86VGAarbiterUnlock(xf86Screens[i]);
- }
- }
-
- xf86AccessLeave();
-
- /*
- * This is needed for an abnormal server exit, since the normal exit stuff
- * MUST also be performed (i.e. the vt must be left in a defined state)
- */
- ddxGiveUp(error);
+ if (xf86Screens) {
+ for (i = 0; i < xf86NumScreens; i++)
+ if (xf86Screens[i]->vtSema) {
+ /*
+ * if we are aborting before ScreenInit() has finished
+ * we might not have been wrapped yet. Therefore enable
+ * screen explicitely.
+ */
+ xf86VGAarbiterLock(xf86Screens[i]);
+ (xf86Screens[i]->LeaveVT) (i, 0);
+ xf86VGAarbiterUnlock(xf86Screens[i]);
+ }
+ }
+
+ xf86AccessLeave();
+
+ /*
+ * This is needed for an abnormal server exit, since the normal exit stuff
+ * MUST also be performed (i.e. the vt must be left in a defined state)
+ */
+ ddxGiveUp(error);
}
void
@@ -1040,14 +1057,14 @@ OsVendorFatalError(void)
{
#ifdef VENDORSUPPORT
ErrorF("\nPlease refer to your Operating System Vendor support pages\n"
- "at %s for support on this crash.\n",VENDORSUPPORT);
+ "at %s for support on this crash.\n", VENDORSUPPORT);
#else
- ErrorF("\nPlease consult the "XVENDORNAME" support \n"
- "\t at "__VENDORDWEBSUPPORT__"\n for help. \n");
+ ErrorF("\nPlease consult the " XVENDORNAME " support \n"
+ "\t at " __VENDORDWEBSUPPORT__ "\n for help. \n");
#endif
if (xf86LogFile && xf86LogFileWasOpened)
- ErrorF("Please also check the log file at \"%s\" for additional "
- "information.\n", xf86LogFile);
+ ErrorF("Please also check the log file at \"%s\" for additional "
+ "information.\n", xf86LogFile);
ErrorF("\n");
}
@@ -1074,13 +1091,13 @@ xf86SetLogVerbosity(int verb)
static void
xf86PrintDefaultModulePath(void)
{
- ErrorF("%s\n", DEFAULT_MODULE_PATH);
+ ErrorF("%s\n", DEFAULT_MODULE_PATH);
}
static void
xf86PrintDefaultLibraryPath(void)
{
- ErrorF("%s\n", DEFAULT_LIBRARY_PATH);
+ ErrorF("%s\n", DEFAULT_LIBRARY_PATH);
}
/*
@@ -1102,325 +1119,289 @@ ddxProcessArgument(int argc, char **argv, int i)
FatalError("Required argument to %s not specified\n", argv[i]); \
}
- /* First the options that are not allowed with elevated privileges */
- if (!strcmp(argv[i], "-modulepath") || !strcmp(argv[i], "-logfile")) {
- if (xf86PrivsElevated()) {
- FatalError("The '%s' option cannot be used with "
- "elevated privileges.\n", argv[i]);
- }
- else if (!strcmp(argv[i], "-modulepath"))
- {
- char *mp;
- CHECK_FOR_REQUIRED_ARGUMENT();
- mp = strdup(argv[i + 1]);
- if (!mp)
- FatalError("Can't allocate memory for ModulePath\n");
- xf86ModulePath = mp;
- xf86ModPathFrom = X_CMDLINE;
- return 2;
+ /* First the options that are not allowed with elevated privileges */
+ if (!strcmp(argv[i], "-modulepath") || !strcmp(argv[i], "-logfile")) {
+ if (xf86PrivsElevated()) {
+ FatalError("The '%s' option cannot be used with "
+ "elevated privileges.\n", argv[i]);
+ }
+ else if (!strcmp(argv[i], "-modulepath")) {
+ char *mp;
+
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ mp = strdup(argv[i + 1]);
+ if (!mp)
+ FatalError("Can't allocate memory for ModulePath\n");
+ xf86ModulePath = mp;
+ xf86ModPathFrom = X_CMDLINE;
+ return 2;
+ }
+ else if (!strcmp(argv[i], "-logfile")) {
+ char *lf;
+
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ lf = strdup(argv[i + 1]);
+ if (!lf)
+ FatalError("Can't allocate memory for LogFile\n");
+ xf86LogFile = lf;
+ xf86LogFileFrom = X_CMDLINE;
+ return 2;
+ }
}
- else if (!strcmp(argv[i], "-logfile"))
- {
- char *lf;
- CHECK_FOR_REQUIRED_ARGUMENT();
- lf = strdup(argv[i + 1]);
- if (!lf)
- FatalError("Can't allocate memory for LogFile\n");
- xf86LogFile = lf;
- xf86LogFileFrom = X_CMDLINE;
- return 2;
+ if (!strcmp(argv[i], "-config") || !strcmp(argv[i], "-xf86config")) {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (xf86PrivsElevated() && !xf86PathIsSafe(argv[i + 1])) {
+ FatalError("\nInvalid argument for %s\n"
+ "\tWith elevated privileges, the file specified with %s must be\n"
+ "\ta relative path and must not contain any \"..\" elements.\n"
+ "\tUsing default " __XCONFIGFILE__ " search path.\n\n",
+ argv[i], argv[i]);
+ }
+ xf86ConfigFile = argv[i + 1];
+ return 2;
}
- }
- if (!strcmp(argv[i], "-config") || !strcmp(argv[i], "-xf86config"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (xf86PrivsElevated() && !xf86PathIsSafe(argv[i + 1])) {
- FatalError("\nInvalid argument for %s\n"
- "\tWith elevated privileges, the file specified with %s must be\n"
- "\ta relative path and must not contain any \"..\" elements.\n"
- "\tUsing default "__XCONFIGFILE__" search path.\n\n",
- argv[i], argv[i]);
+ if (!strcmp(argv[i], "-configdir")) {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (xf86PrivsElevated() && !xf86PathIsSafe(argv[i + 1])) {
+ FatalError("\nInvalid argument for %s\n"
+ "\tWith elevated privileges, the file specified with %s must be\n"
+ "\ta relative path and must not contain any \"..\" elements.\n"
+ "\tUsing default " __XCONFIGDIR__ " search path.\n\n",
+ argv[i], argv[i]);
+ }
+ xf86ConfigDir = argv[i + 1];
+ return 2;
}
- xf86ConfigFile = argv[i + 1];
- return 2;
- }
- if (!strcmp(argv[i], "-configdir"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (xf86PrivsElevated() && !xf86PathIsSafe(argv[i + 1])) {
- FatalError("\nInvalid argument for %s\n"
- "\tWith elevated privileges, the file specified with %s must be\n"
- "\ta relative path and must not contain any \"..\" elements.\n"
- "\tUsing default "__XCONFIGDIR__" search path.\n\n",
- argv[i], argv[i]);
+ if (!strcmp(argv[i], "-flipPixels")) {
+ xf86FlipPixels = TRUE;
+ return 1;
}
- xf86ConfigDir = argv[i + 1];
- return 2;
- }
- if (!strcmp(argv[i],"-flipPixels"))
- {
- xf86FlipPixels = TRUE;
- return 1;
- }
#ifdef XF86VIDMODE
- if (!strcmp(argv[i],"-disableVidMode"))
- {
- xf86VidModeDisabled = TRUE;
- return 1;
- }
- if (!strcmp(argv[i],"-allowNonLocalXvidtune"))
- {
- xf86VidModeAllowNonLocal = TRUE;
- return 1;
- }
+ if (!strcmp(argv[i], "-disableVidMode")) {
+ xf86VidModeDisabled = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-allowNonLocalXvidtune")) {
+ xf86VidModeAllowNonLocal = TRUE;
+ return 1;
+ }
#endif
- if (!strcmp(argv[i],"-allowMouseOpenFail"))
- {
- xf86AllowMouseOpenFail = TRUE;
- return 1;
- }
- if (!strcmp(argv[i],"-ignoreABI"))
- {
- LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL);
- return 1;
- }
- if (!strcmp(argv[i],"-verbose"))
- {
- if (++i < argc && argv[i])
- {
- char *end;
- long val;
- val = strtol(argv[i], &end, 0);
- if (*end == '\0')
- {
- xf86SetVerbosity(val);
- return 2;
- }
+ if (!strcmp(argv[i], "-allowMouseOpenFail")) {
+ xf86AllowMouseOpenFail = TRUE;
+ return 1;
}
- xf86SetVerbosity(++xf86Verbose);
- return 1;
- }
- if (!strcmp(argv[i],"-logverbose"))
- {
- if (++i < argc && argv[i])
- {
- char *end;
- long val;
- val = strtol(argv[i], &end, 0);
- if (*end == '\0')
- {
- xf86SetLogVerbosity(val);
- return 2;
- }
+ if (!strcmp(argv[i], "-ignoreABI")) {
+ LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL);
+ return 1;
}
- xf86SetLogVerbosity(++xf86LogVerbose);
- return 1;
- }
- if (!strcmp(argv[i],"-quiet"))
- {
- xf86SetVerbosity(-1);
- return 1;
- }
- if (!strcmp(argv[i],"-showconfig") || !strcmp(argv[i],"-version"))
- {
- xf86PrintBanner();
- exit(0);
- }
- if (!strcmp(argv[i],"-showDefaultModulePath"))
- {
- xf86PrintDefaultModulePath();
- exit(0);
- }
- if (!strcmp(argv[i],"-showDefaultLibPath"))
- {
- xf86PrintDefaultLibraryPath();
- exit(0);
- }
- /* Notice the -fp flag, but allow it to pass to the dix layer */
- if (!strcmp(argv[i], "-fp"))
- {
- xf86fpFlag = TRUE;
- return 0;
- }
- /* Notice the -bs flag, but allow it to pass to the dix layer */
- if (!strcmp(argv[i], "-bs"))
- {
- xf86bsDisableFlag = TRUE;
- return 0;
- }
- /* Notice the +bs flag, but allow it to pass to the dix layer */
- if (!strcmp(argv[i], "+bs"))
- {
- xf86bsEnableFlag = TRUE;
- return 0;
- }
- /* Notice the -s flag, but allow it to pass to the dix layer */
- if (!strcmp(argv[i], "-s"))
- {
- xf86sFlag = TRUE;
- return 0;
- }
- if (!strcmp(argv[i], "-pixmap24"))
- {
- xf86Pix24 = Pix24Use24;
- return 1;
- }
- if (!strcmp(argv[i], "-pixmap32"))
- {
- xf86Pix24 = Pix24Use32;
- return 1;
- }
- if (!strcmp(argv[i], "-fbbpp"))
- {
- int bpp;
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (sscanf(argv[++i], "%d", &bpp) == 1)
- {
- xf86FbBpp = bpp;
- return 2;
+ if (!strcmp(argv[i], "-verbose")) {
+ if (++i < argc && argv[i]) {
+ char *end;
+ long val;
+
+ val = strtol(argv[i], &end, 0);
+ if (*end == '\0') {
+ xf86SetVerbosity(val);
+ return 2;
+ }
+ }
+ xf86SetVerbosity(++xf86Verbose);
+ return 1;
}
- else
- {
- ErrorF("Invalid fbbpp\n");
- return 0;
+ if (!strcmp(argv[i], "-logverbose")) {
+ if (++i < argc && argv[i]) {
+ char *end;
+ long val;
+
+ val = strtol(argv[i], &end, 0);
+ if (*end == '\0') {
+ xf86SetLogVerbosity(val);
+ return 2;
+ }
+ }
+ xf86SetLogVerbosity(++xf86LogVerbose);
+ return 1;
}
- }
- if (!strcmp(argv[i], "-depth"))
- {
- int depth;
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (sscanf(argv[++i], "%d", &depth) == 1)
- {
- xf86Depth = depth;
- return 2;
+ if (!strcmp(argv[i], "-quiet")) {
+ xf86SetVerbosity(-1);
+ return 1;
}
- else
- {
- ErrorF("Invalid depth\n");
- return 0;
+ if (!strcmp(argv[i], "-showconfig") || !strcmp(argv[i], "-version")) {
+ xf86PrintBanner();
+ exit(0);
}
- }
- if (!strcmp(argv[i], "-weight"))
- {
- int red, green, blue;
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (sscanf(argv[++i], "%1d%1d%1d", &red, &green, &blue) == 3)
- {
- xf86Weight.red = red;
- xf86Weight.green = green;
- xf86Weight.blue = blue;
- return 2;
+ if (!strcmp(argv[i], "-showDefaultModulePath")) {
+ xf86PrintDefaultModulePath();
+ exit(0);
}
- else
- {
- ErrorF("Invalid weighting\n");
- return 0;
+ if (!strcmp(argv[i], "-showDefaultLibPath")) {
+ xf86PrintDefaultLibraryPath();
+ exit(0);
+ }
+ /* Notice the -fp flag, but allow it to pass to the dix layer */
+ if (!strcmp(argv[i], "-fp")) {
+ xf86fpFlag = TRUE;
+ return 0;
+ }
+ /* Notice the -bs flag, but allow it to pass to the dix layer */
+ if (!strcmp(argv[i], "-bs")) {
+ xf86bsDisableFlag = TRUE;
+ return 0;
+ }
+ /* Notice the +bs flag, but allow it to pass to the dix layer */
+ if (!strcmp(argv[i], "+bs")) {
+ xf86bsEnableFlag = TRUE;
+ return 0;
}
- }
- if (!strcmp(argv[i], "-gamma") || !strcmp(argv[i], "-rgamma") ||
- !strcmp(argv[i], "-ggamma") || !strcmp(argv[i], "-bgamma"))
- {
- double gamma;
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (sscanf(argv[++i], "%lf", &gamma) == 1) {
- if (gamma < GAMMA_MIN || gamma > GAMMA_MAX) {
- ErrorF("gamma out of range, only %.2f <= gamma_value <= %.1f"
- " is valid\n", GAMMA_MIN, GAMMA_MAX);
- return 0;
- }
- if (!strcmp(argv[i-1], "-gamma"))
- xf86Gamma.red = xf86Gamma.green = xf86Gamma.blue = gamma;
- else if (!strcmp(argv[i-1], "-rgamma")) xf86Gamma.red = gamma;
- else if (!strcmp(argv[i-1], "-ggamma")) xf86Gamma.green = gamma;
- else if (!strcmp(argv[i-1], "-bgamma")) xf86Gamma.blue = gamma;
- return 2;
+ /* Notice the -s flag, but allow it to pass to the dix layer */
+ if (!strcmp(argv[i], "-s")) {
+ xf86sFlag = TRUE;
+ return 0;
+ }
+ if (!strcmp(argv[i], "-pixmap24")) {
+ xf86Pix24 = Pix24Use24;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-pixmap32")) {
+ xf86Pix24 = Pix24Use32;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-fbbpp")) {
+ int bpp;
+
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (sscanf(argv[++i], "%d", &bpp) == 1) {
+ xf86FbBpp = bpp;
+ return 2;
+ }
+ else {
+ ErrorF("Invalid fbbpp\n");
+ return 0;
+ }
+ }
+ if (!strcmp(argv[i], "-depth")) {
+ int depth;
+
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (sscanf(argv[++i], "%d", &depth) == 1) {
+ xf86Depth = depth;
+ return 2;
+ }
+ else {
+ ErrorF("Invalid depth\n");
+ return 0;
+ }
+ }
+ if (!strcmp(argv[i], "-weight")) {
+ int red, green, blue;
+
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (sscanf(argv[++i], "%1d%1d%1d", &red, &green, &blue) == 3) {
+ xf86Weight.red = red;
+ xf86Weight.green = green;
+ xf86Weight.blue = blue;
+ return 2;
+ }
+ else {
+ ErrorF("Invalid weighting\n");
+ return 0;
+ }
+ }
+ if (!strcmp(argv[i], "-gamma") || !strcmp(argv[i], "-rgamma") ||
+ !strcmp(argv[i], "-ggamma") || !strcmp(argv[i], "-bgamma")) {
+ double gamma;
+
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (sscanf(argv[++i], "%lf", &gamma) == 1) {
+ if (gamma < GAMMA_MIN || gamma > GAMMA_MAX) {
+ ErrorF("gamma out of range, only %.2f <= gamma_value <= %.1f"
+ " is valid\n", GAMMA_MIN, GAMMA_MAX);
+ return 0;
+ }
+ if (!strcmp(argv[i - 1], "-gamma"))
+ xf86Gamma.red = xf86Gamma.green = xf86Gamma.blue = gamma;
+ else if (!strcmp(argv[i - 1], "-rgamma"))
+ xf86Gamma.red = gamma;
+ else if (!strcmp(argv[i - 1], "-ggamma"))
+ xf86Gamma.green = gamma;
+ else if (!strcmp(argv[i - 1], "-bgamma"))
+ xf86Gamma.blue = gamma;
+ return 2;
+ }
+ }
+ if (!strcmp(argv[i], "-layout")) {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ xf86LayoutName = argv[++i];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-screen")) {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ xf86ScreenName = argv[++i];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-pointer")) {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ xf86PointerName = argv[++i];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-keyboard")) {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ xf86KeyboardName = argv[++i];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-nosilk")) {
+ xf86silkenMouseDisableFlag = TRUE;
+ return 1;
}
- }
- if (!strcmp(argv[i], "-layout"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- xf86LayoutName = argv[++i];
- return 2;
- }
- if (!strcmp(argv[i], "-screen"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- xf86ScreenName = argv[++i];
- return 2;
- }
- if (!strcmp(argv[i], "-pointer"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- xf86PointerName = argv[++i];
- return 2;
- }
- if (!strcmp(argv[i], "-keyboard"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- xf86KeyboardName = argv[++i];
- return 2;
- }
- if (!strcmp(argv[i], "-nosilk"))
- {
- xf86silkenMouseDisableFlag = TRUE;
- return 1;
- }
#ifdef HAVE_ACPI
- if (!strcmp(argv[i], "-noacpi"))
- {
- xf86acpiDisableFlag = TRUE;
- return 1;
- }
+ if (!strcmp(argv[i], "-noacpi")) {
+ xf86acpiDisableFlag = TRUE;
+ return 1;
+ }
#endif
- if (!strcmp(argv[i], "-configure"))
- {
- if (getuid() != 0 && geteuid() == 0) {
- ErrorF("The '-configure' option can only be used by root.\n");
- exit(1);
+ if (!strcmp(argv[i], "-configure")) {
+ if (getuid() != 0 && geteuid() == 0) {
+ ErrorF("The '-configure' option can only be used by root.\n");
+ exit(1);
+ }
+ xf86DoConfigure = TRUE;
+ xf86AllowMouseOpenFail = TRUE;
+ return 1;
}
- xf86DoConfigure = TRUE;
- xf86AllowMouseOpenFail = TRUE;
- return 1;
- }
- if (!strcmp(argv[i], "-showopts"))
- {
- if (getuid() != 0 && geteuid() == 0) {
- ErrorF("The '-showopts' option can only be used by root.\n");
- exit(1);
+ if (!strcmp(argv[i], "-showopts")) {
+ if (getuid() != 0 && geteuid() == 0) {
+ ErrorF("The '-showopts' option can only be used by root.\n");
+ exit(1);
+ }
+ xf86DoShowOptions = TRUE;
+ return 1;
}
- xf86DoShowOptions = TRUE;
- return 1;
- }
#ifdef XSERVER_LIBPCIACCESS
- if (!strcmp(argv[i], "-isolateDevice"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (strncmp(argv[++i], "PCI:", 4)) {
- FatalError("Bus types other than PCI not yet isolable\n");
+ if (!strcmp(argv[i], "-isolateDevice")) {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (strncmp(argv[++i], "PCI:", 4)) {
+ FatalError("Bus types other than PCI not yet isolable\n");
+ }
+ xf86PciIsolateDevice(argv[i]);
+ return 2;
}
- xf86PciIsolateDevice(argv[i]);
- return 2;
- }
#endif
- /* Notice cmdline xkbdir, but pass to dix as well */
- if (!strcmp(argv[i], "-xkbdir"))
- {
- xf86xkbdirFlag = TRUE;
- return 0;
- }
- if (!strcmp(argv[i], "-novtswitch"))
- {
- xf86Info.autoVTSwitch = FALSE;
- return 1;
- }
- if (!strcmp(argv[i], "-sharevts"))
- {
- xf86Info.ShareVTs = TRUE;
- return 1;
- }
-
- /* OS-specific processing */
- return xf86ProcessArgument(argc, argv, i);
+ /* Notice cmdline xkbdir, but pass to dix as well */
+ if (!strcmp(argv[i], "-xkbdir")) {
+ xf86xkbdirFlag = TRUE;
+ return 0;
+ }
+ if (!strcmp(argv[i], "-novtswitch")) {
+ xf86Info.autoVTSwitch = FALSE;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-sharevts")) {
+ xf86Info.ShareVTs = TRUE;
+ return 1;
+ }
+
+ /* OS-specific processing */
+ return xf86ProcessArgument(argc, argv, i);
}
/*
@@ -1432,58 +1413,70 @@ ddxProcessArgument(int argc, char **argv, int i)
void
ddxUseMsg(void)
{
- ErrorF("\n");
- ErrorF("\n");
- ErrorF("Device Dependent Usage\n");
- if (!xf86PrivsElevated())
- {
- ErrorF("-modulepath paths specify the module search path\n");
- ErrorF("-logfile file specify a log file name\n");
- ErrorF("-configure probe for devices and write an "__XCONFIGFILE__"\n");
- ErrorF("-showopts print available options for all installed drivers\n");
- }
- ErrorF("-config file specify a configuration file, relative to the\n");
- ErrorF(" "__XCONFIGFILE__" search path, only root can use absolute\n");
- ErrorF("-configdir dir specify a configuration directory, relative to the\n");
- ErrorF(" "__XCONFIGDIR__" search path, only root can use absolute\n");
- ErrorF("-verbose [n] verbose startup messages\n");
- ErrorF("-logverbose [n] verbose log messages\n");
- ErrorF("-quiet minimal startup messages\n");
- ErrorF("-pixmap24 use 24bpp pixmaps for depth 24\n");
- ErrorF("-pixmap32 use 32bpp pixmaps for depth 24\n");
- ErrorF("-fbbpp n set bpp for the framebuffer. Default: 8\n");
- ErrorF("-depth n set colour depth. Default: 8\n");
- ErrorF("-gamma f set gamma value (0.1 < f < 10.0) Default: 1.0\n");
- ErrorF("-rgamma f set gamma value for red phase\n");
- ErrorF("-ggamma f set gamma value for green phase\n");
- ErrorF("-bgamma f set gamma value for blue phase\n");
- ErrorF("-weight nnn set RGB weighting at 16 bpp. Default: 565\n");
- ErrorF("-layout name specify the ServerLayout section name\n");
- ErrorF("-screen name specify the Screen section name\n");
- ErrorF("-keyboard name specify the core keyboard InputDevice name\n");
- ErrorF("-pointer name specify the core pointer InputDevice name\n");
- ErrorF("-nosilk disable Silken Mouse\n");
- ErrorF("-flipPixels swap default black/white Pixel values\n");
+ ErrorF("\n");
+ ErrorF("\n");
+ ErrorF("Device Dependent Usage\n");
+ if (!xf86PrivsElevated()) {
+ ErrorF("-modulepath paths specify the module search path\n");
+ ErrorF("-logfile file specify a log file name\n");
+ ErrorF("-configure probe for devices and write an "
+ __XCONFIGFILE__ "\n");
+ ErrorF
+ ("-showopts print available options for all installed drivers\n");
+ }
+ ErrorF
+ ("-config file specify a configuration file, relative to the\n");
+ ErrorF(" " __XCONFIGFILE__
+ " search path, only root can use absolute\n");
+ ErrorF
+ ("-configdir dir specify a configuration directory, relative to the\n");
+ ErrorF(" " __XCONFIGDIR__
+ " search path, only root can use absolute\n");
+ ErrorF("-verbose [n] verbose startup messages\n");
+ ErrorF("-logverbose [n] verbose log messages\n");
+ ErrorF("-quiet minimal startup messages\n");
+ ErrorF("-pixmap24 use 24bpp pixmaps for depth 24\n");
+ ErrorF("-pixmap32 use 32bpp pixmaps for depth 24\n");
+ ErrorF("-fbbpp n set bpp for the framebuffer. Default: 8\n");
+ ErrorF("-depth n set colour depth. Default: 8\n");
+ ErrorF
+ ("-gamma f set gamma value (0.1 < f < 10.0) Default: 1.0\n");
+ ErrorF("-rgamma f set gamma value for red phase\n");
+ ErrorF("-ggamma f set gamma value for green phase\n");
+ ErrorF("-bgamma f set gamma value for blue phase\n");
+ ErrorF
+ ("-weight nnn set RGB weighting at 16 bpp. Default: 565\n");
+ ErrorF("-layout name specify the ServerLayout section name\n");
+ ErrorF("-screen name specify the Screen section name\n");
+ ErrorF
+ ("-keyboard name specify the core keyboard InputDevice name\n");
+ ErrorF
+ ("-pointer name specify the core pointer InputDevice name\n");
+ ErrorF("-nosilk disable Silken Mouse\n");
+ ErrorF("-flipPixels swap default black/white Pixel values\n");
#ifdef XF86VIDMODE
- ErrorF("-disableVidMode disable mode adjustments with xvidtune\n");
- ErrorF("-allowNonLocalXvidtune allow xvidtune to be run as a non-local client\n");
+ ErrorF("-disableVidMode disable mode adjustments with xvidtune\n");
+ ErrorF
+ ("-allowNonLocalXvidtune allow xvidtune to be run as a non-local client\n");
#endif
- ErrorF("-allowMouseOpenFail start server even if the mouse can't be initialized\n");
- ErrorF("-ignoreABI make module ABI mismatches non-fatal\n");
+ ErrorF
+ ("-allowMouseOpenFail start server even if the mouse can't be initialized\n");
+ ErrorF("-ignoreABI make module ABI mismatches non-fatal\n");
#ifdef XSERVER_LIBPCIACCESS
- ErrorF("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n");
+ ErrorF
+ ("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n");
#endif
- ErrorF("-version show the server version\n");
- ErrorF("-showDefaultModulePath show the server default module path\n");
- ErrorF("-showDefaultLibPath show the server default library path\n");
- ErrorF("-novtswitch don't automatically switch VT at reset & exit\n");
- ErrorF("-sharevts share VTs with another X server\n");
- /* OS-specific usage */
- xf86UseMsg();
- ErrorF("\n");
+ ErrorF("-version show the server version\n");
+ ErrorF("-showDefaultModulePath show the server default module path\n");
+ ErrorF("-showDefaultLibPath show the server default library path\n");
+ ErrorF
+ ("-novtswitch don't automatically switch VT at reset & exit\n");
+ ErrorF("-sharevts share VTs with another X server\n");
+ /* OS-specific usage */
+ xf86UseMsg();
+ ErrorF("\n");
}
-
/*
* xf86LoadModules iterates over a list that is being passed in.
*/
@@ -1497,34 +1490,34 @@ xf86LoadModules(char **list, pointer *optlist)
Bool failed = FALSE;
if (!list)
- return TRUE;
+ return TRUE;
for (i = 0; list[i] != NULL; i++) {
- /* Normalise the module name */
- name = xf86NormalizeName(list[i]);
+ /* Normalise the module name */
+ name = xf86NormalizeName(list[i]);
- /* Skip empty names */
- if (name == NULL || *name == '\0') {
- free(name);
- continue;
- }
+ /* Skip empty names */
+ if (name == NULL || *name == '\0') {
+ free(name);
+ continue;
+ }
- /* Replace obsolete keyboard driver with kbd */
- if (!xf86NameCmp(name, "keyboard")) {
- strcpy(name, "kbd");
- }
+ /* Replace obsolete keyboard driver with kbd */
+ if (!xf86NameCmp(name, "keyboard")) {
+ strcpy(name, "kbd");
+ }
- if (optlist)
- opt = optlist[i];
- else
- opt = NULL;
+ if (optlist)
+ opt = optlist[i];
+ else
+ opt = NULL;
if (!LoadModule(name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin)) {
- LoaderErrorMsg(NULL, name, errmaj, errmin);
- failed = TRUE;
- }
- free(name);
+ LoaderErrorMsg(NULL, name, errmaj, errmin);
+ failed = TRUE;
+ }
+ free(name);
}
return !failed;
}
@@ -1535,7 +1528,7 @@ PixmapFormatPtr
xf86GetPixFormat(ScrnInfoPtr pScrn, int depth)
{
int i;
- static PixmapFormatRec format; /* XXX not reentrant */
+ static PixmapFormatRec format; /* XXX not reentrant */
/*
* When the formats[] list initialisation isn't complete, check the
@@ -1543,35 +1536,35 @@ xf86GetPixFormat(ScrnInfoPtr pScrn, int depth)
*/
if (!formatsDone) {
- if (depth == 24) {
- Pix24Flags pix24 = Pix24DontCare;
-
- format.depth = 24;
- format.scanlinePad = BITMAP_SCANLINE_PAD;
- if (xf86Info.pixmap24 != Pix24DontCare)
- pix24 = xf86Info.pixmap24;
- else if (pScrn->pixmap24 != Pix24DontCare)
- pix24 = pScrn->pixmap24;
- if (pix24 == Pix24Use24)
- format.bitsPerPixel = 24;
- else
- format.bitsPerPixel = 32;
- return &format;
- }
+ if (depth == 24) {
+ Pix24Flags pix24 = Pix24DontCare;
+
+ format.depth = 24;
+ format.scanlinePad = BITMAP_SCANLINE_PAD;
+ if (xf86Info.pixmap24 != Pix24DontCare)
+ pix24 = xf86Info.pixmap24;
+ else if (pScrn->pixmap24 != Pix24DontCare)
+ pix24 = pScrn->pixmap24;
+ if (pix24 == Pix24Use24)
+ format.bitsPerPixel = 24;
+ else
+ format.bitsPerPixel = 32;
+ return &format;
+ }
}
for (i = 0; i < numFormats; i++)
- if (formats[i].depth == depth)
- break;
+ if (formats[i].depth == depth)
+ break;
if (i != numFormats)
- return &formats[i];
+ return &formats[i];
else if (!formatsDone) {
- /* Check for screen-specified formats */
- for (i = 0; i < pScrn->numFormats; i++)
- if (pScrn->formats[i].depth == depth)
- break;
- if (i != pScrn->numFormats)
- return &pScrn->formats[i];
+ /* Check for screen-specified formats */
+ for (i = 0; i < pScrn->numFormats; i++)
+ if (pScrn->formats[i].depth == depth)
+ break;
+ if (i != pScrn->numFormats)
+ return &pScrn->formats[i];
}
return NULL;
}
@@ -1581,10 +1574,9 @@ xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth)
{
PixmapFormatPtr format;
-
format = xf86GetPixFormat(pScrn, depth);
if (format)
- return format->bitsPerPixel;
+ return format->bitsPerPixel;
else
- return 0;
+ return 0;
}
diff --git a/xorg-server/hw/xfree86/common/xf86Mode.c b/xorg-server/hw/xfree86/common/xf86Mode.c
index d202d4079..ab4d595c7 100644
--- a/xorg-server/hw/xfree86/common/xf86Mode.c
+++ b/xorg-server/hw/xfree86/common/xf86Mode.c
@@ -99,16 +99,16 @@ printModeRejectMessage(int index, DisplayModePtr p, int status)
const char *type;
if (p->type & M_T_BUILTIN)
- type = "built-in ";
+ type = "built-in ";
else if (p->type & M_T_DEFAULT)
- type = "default ";
+ type = "default ";
else if (p->type & M_T_DRIVER)
- type = "driver ";
+ type = "driver ";
else
- type = "";
+ type = "";
xf86DrvMsg(index, X_INFO, "Not using %smode \"%s\" (%s)\n", type, p->name,
- xf86ModeStatusToString(status));
+ xf86ModeStatusToString(status));
}
/*
@@ -118,33 +118,32 @@ printModeRejectMessage(int index, DisplayModePtr p, int status)
*/
int
xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2,
- int DivFactor, int MulFactor, int *divider)
+ int DivFactor, int MulFactor, int *divider)
{
int nearestClock = 0, nearestDiv = 1;
int minimumGap = abs(freq - scrp->clock[0]);
int i, j, k, gap;
if (allowDiv2)
- k = 2;
+ k = 2;
else
- k = 1;
+ k = 1;
/* Must set this here in case the best match is scrp->clock[0] */
if (divider != NULL)
- *divider = 0;
-
- for (i = 0; i < scrp->numClocks; i++) {
- for (j = 1; j <= k; j++) {
- gap = abs((freq * j) - ((scrp->clock[i] * DivFactor) / MulFactor));
- if ((gap < minimumGap) ||
- ((gap == minimumGap) && (j < nearestDiv))) {
- minimumGap = gap;
- nearestClock = i;
- nearestDiv = j;
- if (divider != NULL)
- *divider = (j - 1) * V_CLKDIV2;
- }
- }
+ *divider = 0;
+
+ for (i = 0; i < scrp->numClocks; i++) {
+ for (j = 1; j <= k; j++) {
+ gap = abs((freq * j) - ((scrp->clock[i] * DivFactor) / MulFactor));
+ if ((gap < minimumGap) || ((gap == minimumGap) && (j < nearestDiv))) {
+ minimumGap = gap;
+ nearestClock = i;
+ nearestDiv = j;
+ if (divider != NULL)
+ *divider = (j - 1) * V_CLKDIV2;
+ }
+ }
}
return nearestClock;
}
@@ -160,67 +159,67 @@ xf86ModeStatusToString(ModeStatus status)
{
switch (status) {
case MODE_OK:
- return "Mode OK";
+ return "Mode OK";
case MODE_HSYNC:
- return "hsync out of range";
+ return "hsync out of range";
case MODE_VSYNC:
- return "vrefresh out of range";
+ return "vrefresh out of range";
case MODE_H_ILLEGAL:
- return "illegal horizontal timings";
+ return "illegal horizontal timings";
case MODE_V_ILLEGAL:
- return "illegal vertical timings";
+ return "illegal vertical timings";
case MODE_BAD_WIDTH:
- return "width requires unsupported line pitch";
+ return "width requires unsupported line pitch";
case MODE_NOMODE:
- return "no mode of this name";
+ return "no mode of this name";
case MODE_NO_INTERLACE:
- return "interlace mode not supported";
+ return "interlace mode not supported";
case MODE_NO_DBLESCAN:
- return "doublescan mode not supported";
+ return "doublescan mode not supported";
case MODE_NO_VSCAN:
- return "multiscan mode not supported";
+ return "multiscan mode not supported";
case MODE_MEM:
- return "insufficient memory for mode";
+ return "insufficient memory for mode";
case MODE_VIRTUAL_X:
- return "width too large for virtual size";
+ return "width too large for virtual size";
case MODE_VIRTUAL_Y:
- return "height too large for virtual size";
+ return "height too large for virtual size";
case MODE_MEM_VIRT:
- return "insufficient memory given virtual size";
+ return "insufficient memory given virtual size";
case MODE_NOCLOCK:
- return "no clock available for mode";
+ return "no clock available for mode";
case MODE_CLOCK_HIGH:
- return "mode clock too high";
+ return "mode clock too high";
case MODE_CLOCK_LOW:
- return "mode clock too low";
+ return "mode clock too low";
case MODE_CLOCK_RANGE:
- return "bad mode clock/interlace/doublescan";
+ return "bad mode clock/interlace/doublescan";
case MODE_BAD_HVALUE:
- return "horizontal timing out of range";
+ return "horizontal timing out of range";
case MODE_BAD_VVALUE:
- return "vertical timing out of range";
+ return "vertical timing out of range";
case MODE_BAD_VSCAN:
- return "VScan value out of range";
+ return "VScan value out of range";
case MODE_HSYNC_NARROW:
- return "horizontal sync too narrow";
+ return "horizontal sync too narrow";
case MODE_HSYNC_WIDE:
- return "horizontal sync too wide";
+ return "horizontal sync too wide";
case MODE_HBLANK_NARROW:
- return "horizontal blanking too narrow";
+ return "horizontal blanking too narrow";
case MODE_HBLANK_WIDE:
- return "horizontal blanking too wide";
+ return "horizontal blanking too wide";
case MODE_VSYNC_NARROW:
- return "vertical sync too narrow";
+ return "vertical sync too narrow";
case MODE_VSYNC_WIDE:
- return "vertical sync too wide";
+ return "vertical sync too wide";
case MODE_VBLANK_NARROW:
- return "vertical blanking too narrow";
+ return "vertical blanking too narrow";
case MODE_VBLANK_WIDE:
- return "vertical blanking too wide";
+ return "vertical blanking too wide";
case MODE_PANEL:
- return "exceeds panel dimensions";
+ return "exceeds panel dimensions";
case MODE_INTERLACE_WIDTH:
- return "width too large for interlaced mode";
+ return "width too large for interlaced mode";
case MODE_ONE_WIDTH:
return "all modes must have the same width";
case MODE_ONE_HEIGHT:
@@ -230,13 +229,13 @@ xf86ModeStatusToString(ModeStatus status)
case MODE_NO_REDUCED:
return "monitor doesn't support reduced blanking";
case MODE_BANDWIDTH:
- return "mode requires too much memory bandwidth";
+ return "mode requires too much memory bandwidth";
case MODE_BAD:
- return "unknown reason";
+ return "unknown reason";
case MODE_ERROR:
- return "internal error";
+ return "internal error";
default:
- return "unknown";
+ return "unknown";
}
}
@@ -254,43 +253,46 @@ xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges)
int scaledClock;
for (cp = clockRanges; cp != NULL; cp = cp->next) {
- DivFactor = max(1, cp->ClockDivFactor);
- MulFactor = max(1, cp->ClockMulFactor);
- if (scrp->progClock) {
- if (cp->minClock) {
- if (cp->maxClock) {
- xf86DrvMsg(scrp->scrnIndex, X_INFO,
- "Clock range: %6.2f to %6.2f MHz\n",
- (double)cp->minClock / 1000.0,
- (double)cp->maxClock / 1000.0);
- } else {
- xf86DrvMsg(scrp->scrnIndex, X_INFO,
- "Minimum clock: %6.2f MHz\n",
- (double)cp->minClock / 1000.0);
- }
- } else {
- if (cp->maxClock) {
- xf86DrvMsg(scrp->scrnIndex, X_INFO,
- "Maximum clock: %6.2f MHz\n",
- (double)cp->maxClock / 1000.0);
- }
- }
- } else if (DivFactor > 1 || MulFactor > 1) {
- j = 0;
- for (i = 0; i < scrp->numClocks; i++) {
- scaledClock = (scrp->clock[i] * DivFactor) / MulFactor;
- if (scaledClock >= cp->minClock && scaledClock <= cp->maxClock) {
- if ((j % 8) == 0) {
- if (j > 0)
- xf86ErrorF("\n");
- xf86DrvMsg(scrp->scrnIndex, X_INFO, "scaled clocks:");
- }
- xf86ErrorF(" %6.2f", (double)scaledClock / 1000.0);
- j++;
- }
- }
- xf86ErrorF("\n");
- }
+ DivFactor = max(1, cp->ClockDivFactor);
+ MulFactor = max(1, cp->ClockMulFactor);
+ if (scrp->progClock) {
+ if (cp->minClock) {
+ if (cp->maxClock) {
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Clock range: %6.2f to %6.2f MHz\n",
+ (double) cp->minClock / 1000.0,
+ (double) cp->maxClock / 1000.0);
+ }
+ else {
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Minimum clock: %6.2f MHz\n",
+ (double) cp->minClock / 1000.0);
+ }
+ }
+ else {
+ if (cp->maxClock) {
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Maximum clock: %6.2f MHz\n",
+ (double) cp->maxClock / 1000.0);
+ }
+ }
+ }
+ else if (DivFactor > 1 || MulFactor > 1) {
+ j = 0;
+ for (i = 0; i < scrp->numClocks; i++) {
+ scaledClock = (scrp->clock[i] * DivFactor) / MulFactor;
+ if (scaledClock >= cp->minClock && scaledClock <= cp->maxClock) {
+ if ((j % 8) == 0) {
+ if (j > 0)
+ xf86ErrorF("\n");
+ xf86DrvMsg(scrp->scrnIndex, X_INFO, "scaled clocks:");
+ }
+ xf86ErrorF(" %6.2f", (double) scaledClock / 1000.0);
+ j++;
+ }
+ }
+ xf86ErrorF("\n");
+ }
}
}
@@ -298,10 +300,10 @@ static Bool
modeInClockRange(ClockRangePtr cp, DisplayModePtr p)
{
return ((p->Clock >= cp->minClock) &&
- (p->Clock <= cp->maxClock) &&
- (cp->interlaceAllowed || !(p->Flags & V_INTERLACE)) &&
- (cp->doubleScanAllowed ||
- ((p->VScan <= 1) && !(p->Flags & V_DBLSCAN))));
+ (p->Clock <= cp->maxClock) &&
+ (cp->interlaceAllowed || !(p->Flags & V_INTERLACE)) &&
+ (cp->doubleScanAllowed ||
+ ((p->VScan <= 1) && !(p->Flags & V_DBLSCAN))));
}
/*
@@ -312,111 +314,112 @@ xf86FindClockRangeForMode(ClockRangePtr clockRanges, DisplayModePtr p)
{
ClockRangePtr cp;
- for (cp = clockRanges; ; cp = cp->next)
- if (!cp || modeInClockRange(cp, p))
- return cp;
+ for (cp = clockRanges;; cp = cp->next)
+ if (!cp || modeInClockRange(cp, p))
+ return cp;
}
-
/*
* xf86HandleBuiltinMode() - handles built-in modes
*/
static ModeStatus
xf86HandleBuiltinMode(ScrnInfoPtr scrp,
- DisplayModePtr p,
- DisplayModePtr modep,
- ClockRangePtr clockRanges,
- Bool allowDiv2)
+ DisplayModePtr p,
+ DisplayModePtr modep,
+ ClockRangePtr clockRanges, Bool allowDiv2)
{
ClockRangePtr cp;
int extraFlags = 0;
int MulFactor = 1;
int DivFactor = 1;
int clockIndex;
-
+
/* Reject previously rejected modes */
if (p->status != MODE_OK)
- return p->status;
+ return p->status;
/* Reject previously considered modes */
if (p->prev)
return MODE_NOMODE;
if ((p->type & M_T_CLOCK_C) == M_T_CLOCK_C) {
- /* Check clock is in range */
- cp = xf86FindClockRangeForMode(clockRanges, p);
- if (cp == NULL){
- modep->type = p->type;
- p->status = MODE_CLOCK_RANGE;
- return MODE_CLOCK_RANGE;
- }
- DivFactor = cp->ClockDivFactor;
- MulFactor = cp->ClockMulFactor;
- if (!scrp->progClock) {
- clockIndex = xf86GetNearestClock(scrp, p->Clock, allowDiv2,
- cp->ClockDivFactor,
- cp->ClockMulFactor, &extraFlags);
- modep->Clock = (scrp->clock[clockIndex] * DivFactor)
- / MulFactor;
- modep->ClockIndex = clockIndex;
- modep->SynthClock = scrp->clock[clockIndex];
- if (extraFlags & V_CLKDIV2) {
- modep->Clock /= 2;
- modep->SynthClock /= 2;
- }
- } else {
- modep->Clock = p->Clock;
- modep->ClockIndex = -1;
- modep->SynthClock = (modep->Clock * MulFactor)
- / DivFactor;
- }
- modep->PrivFlags = cp->PrivFlags;
- } else {
- if(!scrp->progClock) {
+ /* Check clock is in range */
+ cp = xf86FindClockRangeForMode(clockRanges, p);
+ if (cp == NULL) {
+ modep->type = p->type;
+ p->status = MODE_CLOCK_RANGE;
+ return MODE_CLOCK_RANGE;
+ }
+ DivFactor = cp->ClockDivFactor;
+ MulFactor = cp->ClockMulFactor;
+ if (!scrp->progClock) {
+ clockIndex = xf86GetNearestClock(scrp, p->Clock, allowDiv2,
+ cp->ClockDivFactor,
+ cp->ClockMulFactor, &extraFlags);
+ modep->Clock = (scrp->clock[clockIndex] * DivFactor)
+ / MulFactor;
+ modep->ClockIndex = clockIndex;
+ modep->SynthClock = scrp->clock[clockIndex];
+ if (extraFlags & V_CLKDIV2) {
+ modep->Clock /= 2;
+ modep->SynthClock /= 2;
+ }
+ }
+ else {
modep->Clock = p->Clock;
- modep->ClockIndex = p->ClockIndex;
- modep->SynthClock = p->SynthClock;
- } else {
- modep->Clock = p->Clock;
- modep->ClockIndex = -1;
- modep->SynthClock = p->SynthClock;
- }
- modep->PrivFlags = p->PrivFlags;
+ modep->ClockIndex = -1;
+ modep->SynthClock = (modep->Clock * MulFactor)
+ / DivFactor;
+ }
+ modep->PrivFlags = cp->PrivFlags;
}
- modep->type = p->type;
- modep->HDisplay = p->HDisplay;
- modep->HSyncStart = p->HSyncStart;
- modep->HSyncEnd = p->HSyncEnd;
- modep->HTotal = p->HTotal;
- modep->HSkew = p->HSkew;
- modep->VDisplay = p->VDisplay;
- modep->VSyncStart = p->VSyncStart;
- modep->VSyncEnd = p->VSyncEnd;
- modep->VTotal = p->VTotal;
- modep->VScan = p->VScan;
- modep->Flags = p->Flags | extraFlags;
- modep->CrtcHDisplay = p->CrtcHDisplay;
+ else {
+ if (!scrp->progClock) {
+ modep->Clock = p->Clock;
+ modep->ClockIndex = p->ClockIndex;
+ modep->SynthClock = p->SynthClock;
+ }
+ else {
+ modep->Clock = p->Clock;
+ modep->ClockIndex = -1;
+ modep->SynthClock = p->SynthClock;
+ }
+ modep->PrivFlags = p->PrivFlags;
+ }
+ modep->type = p->type;
+ modep->HDisplay = p->HDisplay;
+ modep->HSyncStart = p->HSyncStart;
+ modep->HSyncEnd = p->HSyncEnd;
+ modep->HTotal = p->HTotal;
+ modep->HSkew = p->HSkew;
+ modep->VDisplay = p->VDisplay;
+ modep->VSyncStart = p->VSyncStart;
+ modep->VSyncEnd = p->VSyncEnd;
+ modep->VTotal = p->VTotal;
+ modep->VScan = p->VScan;
+ modep->Flags = p->Flags | extraFlags;
+ modep->CrtcHDisplay = p->CrtcHDisplay;
modep->CrtcHBlankStart = p->CrtcHBlankStart;
- modep->CrtcHSyncStart = p->CrtcHSyncStart;
- modep->CrtcHSyncEnd = p->CrtcHSyncEnd;
- modep->CrtcHBlankEnd = p->CrtcHBlankEnd;
- modep->CrtcHTotal = p->CrtcHTotal;
- modep->CrtcHSkew = p->CrtcHSkew;
- modep->CrtcVDisplay = p->CrtcVDisplay;
+ modep->CrtcHSyncStart = p->CrtcHSyncStart;
+ modep->CrtcHSyncEnd = p->CrtcHSyncEnd;
+ modep->CrtcHBlankEnd = p->CrtcHBlankEnd;
+ modep->CrtcHTotal = p->CrtcHTotal;
+ modep->CrtcHSkew = p->CrtcHSkew;
+ modep->CrtcVDisplay = p->CrtcVDisplay;
modep->CrtcVBlankStart = p->CrtcVBlankStart;
- modep->CrtcVSyncStart = p->CrtcVSyncStart;
- modep->CrtcVSyncEnd = p->CrtcVSyncEnd;
- modep->CrtcVBlankEnd = p->CrtcVBlankEnd;
- modep->CrtcVTotal = p->CrtcVTotal;
- modep->CrtcHAdjusted = p->CrtcHAdjusted;
- modep->CrtcVAdjusted = p->CrtcVAdjusted;
- modep->HSync = p->HSync;
- modep->VRefresh = p->VRefresh;
- modep->Private = p->Private;
- modep->PrivSize = p->PrivSize;
+ modep->CrtcVSyncStart = p->CrtcVSyncStart;
+ modep->CrtcVSyncEnd = p->CrtcVSyncEnd;
+ modep->CrtcVBlankEnd = p->CrtcVBlankEnd;
+ modep->CrtcVTotal = p->CrtcVTotal;
+ modep->CrtcHAdjusted = p->CrtcHAdjusted;
+ modep->CrtcVAdjusted = p->CrtcVAdjusted;
+ modep->HSync = p->HSync;
+ modep->VRefresh = p->VRefresh;
+ modep->Private = p->Private;
+ modep->PrivSize = p->PrivSize;
p->prev = modep;
-
+
return MODE_OK;
}
@@ -450,7 +453,7 @@ xf86HandleBuiltinMode(ScrnInfoPtr scrp,
ModeStatus
xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
- ClockRangePtr clockRanges, LookupModeFlags strategy)
+ ClockRangePtr clockRanges, LookupModeFlags strategy)
{
DisplayModePtr p, bestMode = NULL;
ClockRangePtr cp;
@@ -465,14 +468,15 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
ModeStatus status = MODE_NOMODE;
Bool allowDiv2 = (strategy & LOOKUP_CLKDIV2) != 0;
int n;
+
const int types[] = {
- M_T_BUILTIN | M_T_PREFERRED,
- M_T_BUILTIN,
- M_T_USERDEF | M_T_PREFERRED,
- M_T_USERDEF,
- M_T_DRIVER | M_T_PREFERRED,
- M_T_DRIVER,
- 0
+ M_T_BUILTIN | M_T_PREFERRED,
+ M_T_BUILTIN,
+ M_T_USERDEF | M_T_PREFERRED,
+ M_T_USERDEF,
+ M_T_DRIVER | M_T_PREFERRED,
+ M_T_DRIVER,
+ 0
};
const int ntypes = sizeof(types) / sizeof(int);
@@ -480,206 +484,209 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
/* Some sanity checking */
if (scrp == NULL || scrp->modePool == NULL ||
- (!scrp->progClock && scrp->numClocks == 0)) {
- ErrorF("xf86LookupMode: called with invalid scrnInfoRec\n");
- return MODE_ERROR;
+ (!scrp->progClock && scrp->numClocks == 0)) {
+ ErrorF("xf86LookupMode: called with invalid scrnInfoRec\n");
+ return MODE_ERROR;
}
if (modep == NULL || modep->name == NULL) {
- ErrorF("xf86LookupMode: called with invalid modep\n");
- return MODE_ERROR;
+ ErrorF("xf86LookupMode: called with invalid modep\n");
+ return MODE_ERROR;
}
for (cp = clockRanges; cp != NULL; cp = cp->next) {
- /* DivFactor and MulFactor must be > 0 */
- cp->ClockDivFactor = max(1, cp->ClockDivFactor);
- cp->ClockMulFactor = max(1, cp->ClockMulFactor);
+ /* DivFactor and MulFactor must be > 0 */
+ cp->ClockDivFactor = max(1, cp->ClockDivFactor);
+ cp->ClockMulFactor = max(1, cp->ClockMulFactor);
}
/* Scan the mode pool for matching names */
for (n = 0; n < ntypes; n++) {
- int type = types[n];
- for (p = scrp->modePool; p != NULL; p = p->next) {
-
- /* scan through the modes in the sort order above */
- if ((p->type & type) != type)
- continue;
-
- if (strcmp(p->name, modep->name) == 0) {
-
- /* Skip over previously rejected modes */
- if (p->status != MODE_OK) {
- if (!found)
- status = p->status;
- continue;
- }
-
- /* Skip over previously considered modes */
- if (p->prev)
- continue;
-
- if (p->type & M_T_BUILTIN) {
- return xf86HandleBuiltinMode(scrp, p,modep, clockRanges,
- allowDiv2);
- }
-
- /* Check clock is in range */
- cp = xf86FindClockRangeForMode(clockRanges, p);
- if (cp == NULL) {
- /*
- * XXX Could do more here to provide a more detailed
- * reason for not finding a mode.
- */
- p->status = MODE_CLOCK_RANGE;
- if (!found)
- status = MODE_CLOCK_RANGE;
- continue;
- }
-
- /*
- * If programmable clock and strategy is not
- * LOOKUP_BEST_REFRESH, the required mode has been found,
- * otherwise record the refresh and continue looking.
- */
- if (scrp->progClock) {
- found = TRUE;
- if (strategy != LOOKUP_BEST_REFRESH) {
- bestMode = p;
- DivFactor = cp->ClockDivFactor;
- MulFactor = cp->ClockMulFactor;
- ModePrivFlags = cp->PrivFlags;
- break;
- }
- refresh = xf86ModeVRefresh(p);
- if (p->Flags & V_INTERLACE)
- refresh /= INTERLACE_REFRESH_WEIGHT;
- if (refresh > bestRefresh) {
- bestMode = p;
- DivFactor = cp->ClockDivFactor;
- MulFactor = cp->ClockMulFactor;
- ModePrivFlags = cp->PrivFlags;
- bestRefresh = refresh;
- }
- continue;
- }
-
- /*
- * Clock is in range, so if it is not a programmable clock, find
- * a matching clock.
- */
-
- i = xf86GetNearestClock(scrp, p->Clock, allowDiv2,
- cp->ClockDivFactor, cp->ClockMulFactor, &k);
- /*
- * If the clock is too far from the requested clock, this
- * mode is no good.
- */
- if (k & V_CLKDIV2)
- gap = abs((p->Clock * 2) -
- ((scrp->clock[i] * cp->ClockDivFactor) /
- cp->ClockMulFactor));
- else
- gap = abs(p->Clock -
- ((scrp->clock[i] * cp->ClockDivFactor) /
- cp->ClockMulFactor));
- if (gap > minimumGap) {
- p->status = MODE_NOCLOCK;
- if (!found)
- status = MODE_NOCLOCK;
- continue;
- }
- found = TRUE;
-
- if (strategy == LOOKUP_BEST_REFRESH) {
- refresh = xf86ModeVRefresh(p);
- if (p->Flags & V_INTERLACE)
- refresh /= INTERLACE_REFRESH_WEIGHT;
- if (refresh > bestRefresh) {
- bestMode = p;
- DivFactor = cp->ClockDivFactor;
- MulFactor = cp->ClockMulFactor;
- ModePrivFlags = cp->PrivFlags;
- extraFlags = k;
- clockIndex = i;
- bestRefresh = refresh;
- }
- continue;
- }
- if (strategy == LOOKUP_CLOSEST_CLOCK) {
- if (gap < minimumGap) {
- bestMode = p;
- DivFactor = cp->ClockDivFactor;
- MulFactor = cp->ClockMulFactor;
- ModePrivFlags = cp->PrivFlags;
- extraFlags = k;
- clockIndex = i;
- minimumGap = gap;
- }
- continue;
- }
- /*
- * If strategy is neither LOOKUP_BEST_REFRESH or
- * LOOKUP_CLOSEST_CLOCK the required mode has been found.
- */
- bestMode = p;
- DivFactor = cp->ClockDivFactor;
- MulFactor = cp->ClockMulFactor;
- ModePrivFlags = cp->PrivFlags;
- extraFlags = k;
- clockIndex = i;
- break;
- }
- }
- if (found) break;
+ int type = types[n];
+
+ for (p = scrp->modePool; p != NULL; p = p->next) {
+
+ /* scan through the modes in the sort order above */
+ if ((p->type & type) != type)
+ continue;
+
+ if (strcmp(p->name, modep->name) == 0) {
+
+ /* Skip over previously rejected modes */
+ if (p->status != MODE_OK) {
+ if (!found)
+ status = p->status;
+ continue;
+ }
+
+ /* Skip over previously considered modes */
+ if (p->prev)
+ continue;
+
+ if (p->type & M_T_BUILTIN) {
+ return xf86HandleBuiltinMode(scrp, p, modep, clockRanges,
+ allowDiv2);
+ }
+
+ /* Check clock is in range */
+ cp = xf86FindClockRangeForMode(clockRanges, p);
+ if (cp == NULL) {
+ /*
+ * XXX Could do more here to provide a more detailed
+ * reason for not finding a mode.
+ */
+ p->status = MODE_CLOCK_RANGE;
+ if (!found)
+ status = MODE_CLOCK_RANGE;
+ continue;
+ }
+
+ /*
+ * If programmable clock and strategy is not
+ * LOOKUP_BEST_REFRESH, the required mode has been found,
+ * otherwise record the refresh and continue looking.
+ */
+ if (scrp->progClock) {
+ found = TRUE;
+ if (strategy != LOOKUP_BEST_REFRESH) {
+ bestMode = p;
+ DivFactor = cp->ClockDivFactor;
+ MulFactor = cp->ClockMulFactor;
+ ModePrivFlags = cp->PrivFlags;
+ break;
+ }
+ refresh = xf86ModeVRefresh(p);
+ if (p->Flags & V_INTERLACE)
+ refresh /= INTERLACE_REFRESH_WEIGHT;
+ if (refresh > bestRefresh) {
+ bestMode = p;
+ DivFactor = cp->ClockDivFactor;
+ MulFactor = cp->ClockMulFactor;
+ ModePrivFlags = cp->PrivFlags;
+ bestRefresh = refresh;
+ }
+ continue;
+ }
+
+ /*
+ * Clock is in range, so if it is not a programmable clock, find
+ * a matching clock.
+ */
+
+ i = xf86GetNearestClock(scrp, p->Clock, allowDiv2,
+ cp->ClockDivFactor, cp->ClockMulFactor,
+ &k);
+ /*
+ * If the clock is too far from the requested clock, this
+ * mode is no good.
+ */
+ if (k & V_CLKDIV2)
+ gap = abs((p->Clock * 2) -
+ ((scrp->clock[i] * cp->ClockDivFactor) /
+ cp->ClockMulFactor));
+ else
+ gap = abs(p->Clock -
+ ((scrp->clock[i] * cp->ClockDivFactor) /
+ cp->ClockMulFactor));
+ if (gap > minimumGap) {
+ p->status = MODE_NOCLOCK;
+ if (!found)
+ status = MODE_NOCLOCK;
+ continue;
+ }
+ found = TRUE;
+
+ if (strategy == LOOKUP_BEST_REFRESH) {
+ refresh = xf86ModeVRefresh(p);
+ if (p->Flags & V_INTERLACE)
+ refresh /= INTERLACE_REFRESH_WEIGHT;
+ if (refresh > bestRefresh) {
+ bestMode = p;
+ DivFactor = cp->ClockDivFactor;
+ MulFactor = cp->ClockMulFactor;
+ ModePrivFlags = cp->PrivFlags;
+ extraFlags = k;
+ clockIndex = i;
+ bestRefresh = refresh;
+ }
+ continue;
+ }
+ if (strategy == LOOKUP_CLOSEST_CLOCK) {
+ if (gap < minimumGap) {
+ bestMode = p;
+ DivFactor = cp->ClockDivFactor;
+ MulFactor = cp->ClockMulFactor;
+ ModePrivFlags = cp->PrivFlags;
+ extraFlags = k;
+ clockIndex = i;
+ minimumGap = gap;
+ }
+ continue;
+ }
+ /*
+ * If strategy is neither LOOKUP_BEST_REFRESH or
+ * LOOKUP_CLOSEST_CLOCK the required mode has been found.
+ */
+ bestMode = p;
+ DivFactor = cp->ClockDivFactor;
+ MulFactor = cp->ClockMulFactor;
+ ModePrivFlags = cp->PrivFlags;
+ extraFlags = k;
+ clockIndex = i;
+ break;
+ }
+ }
+ if (found)
+ break;
}
if (!found || bestMode == NULL)
- return status;
+ return status;
/* Fill in the mode parameters */
if (scrp->progClock) {
- modep->Clock = bestMode->Clock;
- modep->ClockIndex = -1;
- modep->SynthClock = (modep->Clock * MulFactor) / DivFactor;
- } else {
- modep->Clock = (scrp->clock[clockIndex] * DivFactor) /
- MulFactor;
- modep->ClockIndex = clockIndex;
- modep->SynthClock = scrp->clock[clockIndex];
- if (extraFlags & V_CLKDIV2) {
- modep->Clock /= 2;
- modep->SynthClock /= 2;
- }
+ modep->Clock = bestMode->Clock;
+ modep->ClockIndex = -1;
+ modep->SynthClock = (modep->Clock * MulFactor) / DivFactor;
+ }
+ else {
+ modep->Clock = (scrp->clock[clockIndex] * DivFactor) / MulFactor;
+ modep->ClockIndex = clockIndex;
+ modep->SynthClock = scrp->clock[clockIndex];
+ if (extraFlags & V_CLKDIV2) {
+ modep->Clock /= 2;
+ modep->SynthClock /= 2;
+ }
}
- modep->type = bestMode->type;
- modep->PrivFlags = ModePrivFlags;
- modep->HDisplay = bestMode->HDisplay;
- modep->HSyncStart = bestMode->HSyncStart;
- modep->HSyncEnd = bestMode->HSyncEnd;
- modep->HTotal = bestMode->HTotal;
- modep->HSkew = bestMode->HSkew;
- modep->VDisplay = bestMode->VDisplay;
- modep->VSyncStart = bestMode->VSyncStart;
- modep->VSyncEnd = bestMode->VSyncEnd;
- modep->VTotal = bestMode->VTotal;
- modep->VScan = bestMode->VScan;
- modep->Flags = bestMode->Flags | extraFlags;
- modep->CrtcHDisplay = bestMode->CrtcHDisplay;
- modep->CrtcHBlankStart = bestMode->CrtcHBlankStart;
- modep->CrtcHSyncStart = bestMode->CrtcHSyncStart;
- modep->CrtcHSyncEnd = bestMode->CrtcHSyncEnd;
- modep->CrtcHBlankEnd = bestMode->CrtcHBlankEnd;
- modep->CrtcHTotal = bestMode->CrtcHTotal;
- modep->CrtcHSkew = bestMode->CrtcHSkew;
- modep->CrtcVDisplay = bestMode->CrtcVDisplay;
- modep->CrtcVBlankStart = bestMode->CrtcVBlankStart;
- modep->CrtcVSyncStart = bestMode->CrtcVSyncStart;
- modep->CrtcVSyncEnd = bestMode->CrtcVSyncEnd;
- modep->CrtcVBlankEnd = bestMode->CrtcVBlankEnd;
- modep->CrtcVTotal = bestMode->CrtcVTotal;
- modep->CrtcHAdjusted = bestMode->CrtcHAdjusted;
- modep->CrtcVAdjusted = bestMode->CrtcVAdjusted;
- modep->HSync = bestMode->HSync;
- modep->VRefresh = bestMode->VRefresh;
- modep->Private = bestMode->Private;
- modep->PrivSize = bestMode->PrivSize;
+ modep->type = bestMode->type;
+ modep->PrivFlags = ModePrivFlags;
+ modep->HDisplay = bestMode->HDisplay;
+ modep->HSyncStart = bestMode->HSyncStart;
+ modep->HSyncEnd = bestMode->HSyncEnd;
+ modep->HTotal = bestMode->HTotal;
+ modep->HSkew = bestMode->HSkew;
+ modep->VDisplay = bestMode->VDisplay;
+ modep->VSyncStart = bestMode->VSyncStart;
+ modep->VSyncEnd = bestMode->VSyncEnd;
+ modep->VTotal = bestMode->VTotal;
+ modep->VScan = bestMode->VScan;
+ modep->Flags = bestMode->Flags | extraFlags;
+ modep->CrtcHDisplay = bestMode->CrtcHDisplay;
+ modep->CrtcHBlankStart = bestMode->CrtcHBlankStart;
+ modep->CrtcHSyncStart = bestMode->CrtcHSyncStart;
+ modep->CrtcHSyncEnd = bestMode->CrtcHSyncEnd;
+ modep->CrtcHBlankEnd = bestMode->CrtcHBlankEnd;
+ modep->CrtcHTotal = bestMode->CrtcHTotal;
+ modep->CrtcHSkew = bestMode->CrtcHSkew;
+ modep->CrtcVDisplay = bestMode->CrtcVDisplay;
+ modep->CrtcVBlankStart = bestMode->CrtcVBlankStart;
+ modep->CrtcVSyncStart = bestMode->CrtcVSyncStart;
+ modep->CrtcVSyncEnd = bestMode->CrtcVSyncEnd;
+ modep->CrtcVBlankEnd = bestMode->CrtcVBlankEnd;
+ modep->CrtcVTotal = bestMode->CrtcVTotal;
+ modep->CrtcHAdjusted = bestMode->CrtcHAdjusted;
+ modep->CrtcVAdjusted = bestMode->CrtcVAdjusted;
+ modep->HSync = bestMode->HSync;
+ modep->VRefresh = bestMode->VRefresh;
+ modep->Private = bestMode->Private;
+ modep->PrivSize = bestMode->PrivSize;
bestMode->prev = modep;
@@ -699,51 +706,53 @@ xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor)
/* Sanity checks */
if (mode == NULL || monitor == NULL) {
- ErrorF("xf86CheckModeForMonitor: called with invalid parameters\n");
- return MODE_ERROR;
+ ErrorF("xf86CheckModeForMonitor: called with invalid parameters\n");
+ return MODE_ERROR;
}
DebugF("xf86CheckModeForMonitor(%p %s, %p %s)\n",
- mode, mode->name, monitor, monitor->id);
+ mode, mode->name, monitor, monitor->id);
/* Some basic mode validity checks */
if (0 >= mode->HDisplay || mode->HDisplay > mode->HSyncStart ||
- mode->HSyncStart >= mode->HSyncEnd || mode->HSyncEnd >= mode->HTotal)
- return MODE_H_ILLEGAL;
+ mode->HSyncStart >= mode->HSyncEnd || mode->HSyncEnd >= mode->HTotal)
+ return MODE_H_ILLEGAL;
if (0 >= mode->VDisplay || mode->VDisplay > mode->VSyncStart ||
- mode->VSyncStart >= mode->VSyncEnd || mode->VSyncEnd >= mode->VTotal)
- return MODE_V_ILLEGAL;
+ mode->VSyncStart >= mode->VSyncEnd || mode->VSyncEnd >= mode->VTotal)
+ return MODE_V_ILLEGAL;
if (monitor->nHsync > 0) {
- /* Check hsync against the allowed ranges */
- float hsync = xf86ModeHSync(mode);
- for (i = 0; i < monitor->nHsync; i++)
- if ((hsync > monitor->hsync[i].lo * (1.0 - SYNC_TOLERANCE)) &&
- (hsync < monitor->hsync[i].hi * (1.0 + SYNC_TOLERANCE)))
- break;
-
- /* Now see whether we ran out of sync ranges without finding a match */
- if (i == monitor->nHsync)
- return MODE_HSYNC;
+ /* Check hsync against the allowed ranges */
+ float hsync = xf86ModeHSync(mode);
+
+ for (i = 0; i < monitor->nHsync; i++)
+ if ((hsync > monitor->hsync[i].lo * (1.0 - SYNC_TOLERANCE)) &&
+ (hsync < monitor->hsync[i].hi * (1.0 + SYNC_TOLERANCE)))
+ break;
+
+ /* Now see whether we ran out of sync ranges without finding a match */
+ if (i == monitor->nHsync)
+ return MODE_HSYNC;
}
if (monitor->nVrefresh > 0) {
- /* Check vrefresh against the allowed ranges */
- float vrefrsh = xf86ModeVRefresh(mode);
- for (i = 0; i < monitor->nVrefresh; i++)
- if ((vrefrsh > monitor->vrefresh[i].lo * (1.0 - SYNC_TOLERANCE)) &&
- (vrefrsh < monitor->vrefresh[i].hi * (1.0 + SYNC_TOLERANCE)))
- break;
-
- /* Now see whether we ran out of refresh ranges without finding a match */
- if (i == monitor->nVrefresh)
- return MODE_VSYNC;
+ /* Check vrefresh against the allowed ranges */
+ float vrefrsh = xf86ModeVRefresh(mode);
+
+ for (i = 0; i < monitor->nVrefresh; i++)
+ if ((vrefrsh > monitor->vrefresh[i].lo * (1.0 - SYNC_TOLERANCE)) &&
+ (vrefrsh < monitor->vrefresh[i].hi * (1.0 + SYNC_TOLERANCE)))
+ break;
+
+ /* Now see whether we ran out of refresh ranges without finding a match */
+ if (i == monitor->nVrefresh)
+ return MODE_VSYNC;
}
/* Force interlaced modes to have an odd VTotal */
if (mode->Flags & V_INTERLACE)
- mode->CrtcVTotal = mode->VTotal |= 1;
+ mode->CrtcVTotal = mode->VTotal |= 1;
/*
* This code stops cvt -r modes, and only cvt -r modes, from hitting 15y+
@@ -759,7 +768,7 @@ xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor)
}
if ((monitor->maxPixClock) && (mode->Clock > monitor->maxPixClock))
- return MODE_CLOCK_HIGH;
+ return MODE_CLOCK_HIGH;
return MODE_OK;
}
@@ -774,16 +783,15 @@ xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor)
static Bool
xf86CheckModeSize(ScrnInfoPtr scrp, int w, int x, int y)
{
- int bpp = scrp->fbFormat.bitsPerPixel,
- pad = scrp->fbFormat.scanlinePad;
+ int bpp = scrp->fbFormat.bitsPerPixel, pad = scrp->fbFormat.scanlinePad;
int lineWidth, lastWidth;
if (scrp->depth == 4)
- pad *= 4; /* 4 planes */
+ pad *= 4; /* 4 planes */
/* Sanity check */
if ((w < 0) || (x < 0) || (y <= 0))
- return FALSE;
+ return FALSE;
lineWidth = (((w * bpp) + pad - 1) / pad) * pad;
lastWidth = x * bpp;
@@ -791,11 +799,11 @@ xf86CheckModeSize(ScrnInfoPtr scrp, int w, int x, int y)
/*
* At this point, we need to compare
*
- * (lineWidth * (y - 1)) + lastWidth
+ * (lineWidth * (y - 1)) + lastWidth
*
* against
*
- * scrp->videoRam * (1024 * 8)
+ * scrp->videoRam * (1024 * 8)
*
* These are bit quantities. To avoid overflows, do the comparison in
* terms of BITMAP_SCANLINE_PAD units. This assumes BITMAP_SCANLINE_PAD
@@ -807,8 +815,8 @@ xf86CheckModeSize(ScrnInfoPtr scrp, int w, int x, int y)
lastWidth = (lastWidth + (BITMAP_SCANLINE_PAD - 1)) / BITMAP_SCANLINE_PAD;
if ((lineWidth * (y - 1) + lastWidth) >
- (scrp->videoRam * ((1024 * 8) / BITMAP_SCANLINE_PAD)))
- return FALSE;
+ (scrp->videoRam * ((1024 * 8) / BITMAP_SCANLINE_PAD)))
+ return FALSE;
return TRUE;
}
@@ -839,52 +847,53 @@ xf86CheckModeSize(ScrnInfoPtr scrp, int w, int x, int y)
ModeStatus
xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
- ClockRangePtr clockRanges,
- LookupModeFlags strategy,
- int maxPitch, int virtualX, int virtualY)
+ ClockRangePtr clockRanges,
+ LookupModeFlags strategy,
+ int maxPitch, int virtualX, int virtualY)
{
ClockRangePtr cp;
ModeStatus status;
Bool allowDiv2 = (strategy & LOOKUP_CLKDIV2) != 0;
int i, needDiv2;
-
+
/* Sanity checks */
if (!scrp || !mode || !clockRanges) {
- ErrorF("xf86InitialCheckModeForDriver: "
- "called with invalid parameters\n");
- return MODE_ERROR;
+ ErrorF("xf86InitialCheckModeForDriver: "
+ "called with invalid parameters\n");
+ return MODE_ERROR;
}
DebugF("xf86InitialCheckModeForDriver(%p, %p %s, %p, 0x%x, %d, %d, %d)\n",
- scrp, mode, mode->name , clockRanges, strategy, maxPitch, virtualX, virtualY);
+ scrp, mode, mode->name, clockRanges, strategy, maxPitch, virtualX,
+ virtualY);
/* Some basic mode validity checks */
if (0 >= mode->HDisplay || mode->HDisplay > mode->HSyncStart ||
- mode->HSyncStart >= mode->HSyncEnd || mode->HSyncEnd >= mode->HTotal)
- return MODE_H_ILLEGAL;
+ mode->HSyncStart >= mode->HSyncEnd || mode->HSyncEnd >= mode->HTotal)
+ return MODE_H_ILLEGAL;
if (0 >= mode->VDisplay || mode->VDisplay > mode->VSyncStart ||
- mode->VSyncStart >= mode->VSyncEnd || mode->VSyncEnd >= mode->VTotal)
- return MODE_V_ILLEGAL;
+ mode->VSyncStart >= mode->VSyncEnd || mode->VSyncEnd >= mode->VTotal)
+ return MODE_V_ILLEGAL;
if (!xf86CheckModeSize(scrp, mode->HDisplay, mode->HDisplay,
- mode->VDisplay))
+ mode->VDisplay))
return MODE_MEM;
if (maxPitch > 0 && mode->HDisplay > maxPitch)
- return MODE_BAD_WIDTH;
+ return MODE_BAD_WIDTH;
if (virtualX > 0 && mode->HDisplay > virtualX)
- return MODE_VIRTUAL_X;
+ return MODE_VIRTUAL_X;
if (virtualY > 0 && mode->VDisplay > virtualY)
- return MODE_VIRTUAL_Y;
+ return MODE_VIRTUAL_Y;
if (scrp->maxHValue > 0 && mode->HTotal > scrp->maxHValue)
- return MODE_BAD_HVALUE;
+ return MODE_BAD_HVALUE;
if (scrp->maxVValue > 0 && mode->VTotal > scrp->maxVValue)
- return MODE_BAD_VVALUE;
+ return MODE_BAD_VVALUE;
/*
* The use of the DisplayModeRec's Crtc* and SynthClock elements below is
@@ -910,48 +919,49 @@ xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
* confusion and is bad software design. However since it's part of
* the driver API it's hard to change.
*/
-
+
if (scrp->ValidMode) {
-
- xf86SetModeCrtc(mode, INTERLACE_HALVE_V);
-
- cp = xf86FindClockRangeForMode(clockRanges, mode);
- if (!cp)
- return MODE_CLOCK_RANGE;
-
- if (cp->ClockMulFactor < 1)
- cp->ClockMulFactor = 1;
- if (cp->ClockDivFactor < 1)
- cp->ClockDivFactor = 1;
-
- /*
- * XXX The effect of clock dividers and multipliers on the monitor's
- * pixel clock needs to be verified.
- */
- if (scrp->progClock) {
- mode->SynthClock = mode->Clock;
- } else {
- i = xf86GetNearestClock(scrp, mode->Clock, allowDiv2,
- cp->ClockDivFactor, cp->ClockMulFactor,
- &needDiv2);
- mode->SynthClock = (scrp->clock[i] * cp->ClockDivFactor) /
- cp->ClockMulFactor;
- if (needDiv2 & V_CLKDIV2)
- mode->SynthClock /= 2;
- }
-
- status = (*scrp->ValidMode)(scrp->scrnIndex, mode, FALSE,
- MODECHECK_INITIAL);
- if (status != MODE_OK)
- return status;
-
- if (mode->HSync <= 0.0)
- mode->HSync = (float)mode->SynthClock / (float)mode->CrtcHTotal;
- if (mode->VRefresh <= 0.0)
- mode->VRefresh = (mode->SynthClock * 1000.0)
- / (mode->CrtcHTotal * mode->CrtcVTotal);
+
+ xf86SetModeCrtc(mode, INTERLACE_HALVE_V);
+
+ cp = xf86FindClockRangeForMode(clockRanges, mode);
+ if (!cp)
+ return MODE_CLOCK_RANGE;
+
+ if (cp->ClockMulFactor < 1)
+ cp->ClockMulFactor = 1;
+ if (cp->ClockDivFactor < 1)
+ cp->ClockDivFactor = 1;
+
+ /*
+ * XXX The effect of clock dividers and multipliers on the monitor's
+ * pixel clock needs to be verified.
+ */
+ if (scrp->progClock) {
+ mode->SynthClock = mode->Clock;
+ }
+ else {
+ i = xf86GetNearestClock(scrp, mode->Clock, allowDiv2,
+ cp->ClockDivFactor, cp->ClockMulFactor,
+ &needDiv2);
+ mode->SynthClock = (scrp->clock[i] * cp->ClockDivFactor) /
+ cp->ClockMulFactor;
+ if (needDiv2 & V_CLKDIV2)
+ mode->SynthClock /= 2;
+ }
+
+ status = (*scrp->ValidMode) (scrp->scrnIndex, mode, FALSE,
+ MODECHECK_INITIAL);
+ if (status != MODE_OK)
+ return status;
+
+ if (mode->HSync <= 0.0)
+ mode->HSync = (float) mode->SynthClock / (float) mode->CrtcHTotal;
+ if (mode->VRefresh <= 0.0)
+ mode->VRefresh = (mode->SynthClock * 1000.0)
+ / (mode->CrtcHTotal * mode->CrtcVTotal);
}
-
+
mode->HSync = xf86ModeHSync(mode);
mode->VRefresh = xf86ModeVRefresh(mode);
@@ -996,109 +1006,112 @@ xf86CheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode, int flags)
ModeStatus status = MODE_NOMODE;
/* Some sanity checking */
- if (scrp == NULL || (!scrp->progClock && scrp->numClocks == 0)) {
- ErrorF("xf86CheckModeForDriver: called with invalid scrnInfoRec\n");
- return MODE_ERROR;
+ if (scrp == NULL || (!scrp->progClock && scrp->numClocks == 0)) {
+ ErrorF("xf86CheckModeForDriver: called with invalid scrnInfoRec\n");
+ return MODE_ERROR;
}
if (mode == NULL) {
- ErrorF("xf86CheckModeForDriver: called with invalid modep\n");
- return MODE_ERROR;
+ ErrorF("xf86CheckModeForDriver: called with invalid modep\n");
+ return MODE_ERROR;
}
/* Check the mode size */
if (mode->HDisplay > scrp->virtualX)
- return MODE_VIRTUAL_X;
+ return MODE_VIRTUAL_X;
if (mode->VDisplay > scrp->virtualY)
- return MODE_VIRTUAL_Y;
+ return MODE_VIRTUAL_Y;
if (scrp->maxHValue > 0 && mode->HTotal > scrp->maxHValue)
- return MODE_BAD_HVALUE;
+ return MODE_BAD_HVALUE;
if (scrp->maxVValue > 0 && mode->VTotal > scrp->maxVValue)
- return MODE_BAD_VVALUE;
+ return MODE_BAD_VVALUE;
for (cp = scrp->clockRanges; cp != NULL; cp = cp->next) {
- /* DivFactor and MulFactor must be > 0 */
- cp->ClockDivFactor = max(1, cp->ClockDivFactor);
- cp->ClockMulFactor = max(1, cp->ClockMulFactor);
+ /* DivFactor and MulFactor must be > 0 */
+ cp->ClockDivFactor = max(1, cp->ClockDivFactor);
+ cp->ClockMulFactor = max(1, cp->ClockMulFactor);
}
if (scrp->progClock) {
- /* Check clock is in range */
- for (cp = scrp->clockRanges; cp != NULL; cp = cp->next) {
- if (modeInClockRange(cp, mode))
- break;
- }
- if (cp == NULL) {
- return MODE_CLOCK_RANGE;
- }
- /*
- * If programmable clock the required mode has been found
- */
- DivFactor = cp->ClockDivFactor;
- MulFactor = cp->ClockMulFactor;
- ModePrivFlags = cp->PrivFlags;
- } else {
- status = MODE_CLOCK_RANGE;
- /* Check clock is in range */
- for (cp = scrp->clockRanges; cp != NULL; cp = cp->next) {
- if (modeInClockRange(cp, mode)) {
- /*
- * Clock is in range, so if it is not a programmable clock,
- * find a matching clock.
- */
-
- i = xf86GetNearestClock(scrp, mode->Clock, 0,
- cp->ClockDivFactor, cp->ClockMulFactor, &k);
- /*
- * If the clock is too far from the requested clock, this
- * mode is no good.
- */
- if (k & V_CLKDIV2)
- gap = abs((mode->Clock * 2) -
- ((scrp->clock[i] * cp->ClockDivFactor) /
- cp->ClockMulFactor));
- else
- gap = abs(mode->Clock -
- ((scrp->clock[i] * cp->ClockDivFactor) /
- cp->ClockMulFactor));
- if (gap > minimumGap) {
- status = MODE_NOCLOCK;
- continue;
- }
-
- DivFactor = cp->ClockDivFactor;
- MulFactor = cp->ClockMulFactor;
- ModePrivFlags = cp->PrivFlags;
- extraFlags = k;
- clockIndex = i;
- break;
- }
- }
- if (cp == NULL)
- return status;
+ /* Check clock is in range */
+ for (cp = scrp->clockRanges; cp != NULL; cp = cp->next) {
+ if (modeInClockRange(cp, mode))
+ break;
+ }
+ if (cp == NULL) {
+ return MODE_CLOCK_RANGE;
+ }
+ /*
+ * If programmable clock the required mode has been found
+ */
+ DivFactor = cp->ClockDivFactor;
+ MulFactor = cp->ClockMulFactor;
+ ModePrivFlags = cp->PrivFlags;
+ }
+ else {
+ status = MODE_CLOCK_RANGE;
+ /* Check clock is in range */
+ for (cp = scrp->clockRanges; cp != NULL; cp = cp->next) {
+ if (modeInClockRange(cp, mode)) {
+ /*
+ * Clock is in range, so if it is not a programmable clock,
+ * find a matching clock.
+ */
+
+ i = xf86GetNearestClock(scrp, mode->Clock, 0,
+ cp->ClockDivFactor, cp->ClockMulFactor,
+ &k);
+ /*
+ * If the clock is too far from the requested clock, this
+ * mode is no good.
+ */
+ if (k & V_CLKDIV2)
+ gap = abs((mode->Clock * 2) -
+ ((scrp->clock[i] * cp->ClockDivFactor) /
+ cp->ClockMulFactor));
+ else
+ gap = abs(mode->Clock -
+ ((scrp->clock[i] * cp->ClockDivFactor) /
+ cp->ClockMulFactor));
+ if (gap > minimumGap) {
+ status = MODE_NOCLOCK;
+ continue;
+ }
+
+ DivFactor = cp->ClockDivFactor;
+ MulFactor = cp->ClockMulFactor;
+ ModePrivFlags = cp->PrivFlags;
+ extraFlags = k;
+ clockIndex = i;
+ break;
+ }
+ }
+ if (cp == NULL)
+ return status;
}
/* Fill in the mode parameters */
if (scrp->progClock) {
- mode->ClockIndex = -1;
- mode->SynthClock = (mode->Clock * MulFactor) / DivFactor;
- } else {
- mode->Clock = (scrp->clock[clockIndex] * DivFactor) / MulFactor;
- mode->ClockIndex = clockIndex;
- mode->SynthClock = scrp->clock[clockIndex];
- if (extraFlags & V_CLKDIV2) {
- mode->Clock /= 2;
- mode->SynthClock /= 2;
- }
+ mode->ClockIndex = -1;
+ mode->SynthClock = (mode->Clock * MulFactor) / DivFactor;
}
- mode->PrivFlags = ModePrivFlags;
+ else {
+ mode->Clock = (scrp->clock[clockIndex] * DivFactor) / MulFactor;
+ mode->ClockIndex = clockIndex;
+ mode->SynthClock = scrp->clock[clockIndex];
+ if (extraFlags & V_CLKDIV2) {
+ mode->Clock /= 2;
+ mode->SynthClock /= 2;
+ }
+ }
+ mode->PrivFlags = ModePrivFlags;
return MODE_OK;
}
-static int
+static int
inferVirtualSize(ScrnInfoPtr scrp, DisplayModePtr modes, int *vx, int *vy)
{
float aspect = 0.0;
@@ -1107,24 +1120,25 @@ inferVirtualSize(ScrnInfoPtr scrp, DisplayModePtr modes, int *vx, int *vy)
int x = 0, y = 0;
DisplayModePtr mode;
- if (!mon) return 0;
+ if (!mon)
+ return 0;
DDC = mon->DDC;
if (DDC && DDC->ver.revision >= 4) {
- /* For 1.4, we might actually get native pixel format. How novel. */
- if (PREFERRED_TIMING_MODE(DDC->features.msc)) {
- for (mode = modes; mode; mode = mode->next) {
- if (mode->type & (M_T_DRIVER | M_T_PREFERRED)) {
- x = mode->HDisplay;
- y = mode->VDisplay;
- goto found;
- }
- }
- }
- /*
- * Even if we don't, we might get aspect ratio from extra CVT info
- * or from the monitor size fields. TODO.
- */
+ /* For 1.4, we might actually get native pixel format. How novel. */
+ if (PREFERRED_TIMING_MODE(DDC->features.msc)) {
+ for (mode = modes; mode; mode = mode->next) {
+ if (mode->type & (M_T_DRIVER | M_T_PREFERRED)) {
+ x = mode->HDisplay;
+ y = mode->VDisplay;
+ goto found;
+ }
+ }
+ }
+ /*
+ * Even if we don't, we might get aspect ratio from extra CVT info
+ * or from the monitor size fields. TODO.
+ */
}
/*
@@ -1132,41 +1146,42 @@ inferVirtualSize(ScrnInfoPtr scrp, DisplayModePtr modes, int *vx, int *vy)
* before EDID 1.4, but right now we'll get that wrong. TODO.
*/
if (!aspect) {
- if (!mon->widthmm || !mon->heightmm)
- aspect = 4.0/3.0;
- else
- aspect = (float)mon->widthmm / (float)mon->heightmm;
+ if (!mon->widthmm || !mon->heightmm)
+ aspect = 4.0 / 3.0;
+ else
+ aspect = (float) mon->widthmm / (float) mon->heightmm;
}
/* find the largest M_T_DRIVER mode with that aspect ratio */
for (mode = modes; mode; mode = mode->next) {
- float mode_aspect, metaspect;
- if (!(mode->type & (M_T_DRIVER|M_T_USERDEF)))
- continue;
- mode_aspect = (float)mode->HDisplay / (float)mode->VDisplay;
- metaspect = aspect / mode_aspect;
- /* 5% slop or so, since we only get size in centimeters */
- if (fabs(1.0 - metaspect) < 0.05) {
- if ((mode->HDisplay > x) && (mode->VDisplay > y)) {
- x = mode->HDisplay;
- y = mode->VDisplay;
- }
- }
+ float mode_aspect, metaspect;
+
+ if (!(mode->type & (M_T_DRIVER | M_T_USERDEF)))
+ continue;
+ mode_aspect = (float) mode->HDisplay / (float) mode->VDisplay;
+ metaspect = aspect / mode_aspect;
+ /* 5% slop or so, since we only get size in centimeters */
+ if (fabs(1.0 - metaspect) < 0.05) {
+ if ((mode->HDisplay > x) && (mode->VDisplay > y)) {
+ x = mode->HDisplay;
+ y = mode->VDisplay;
+ }
+ }
}
if (!x || !y) {
- xf86DrvMsg(scrp->scrnIndex, X_WARNING,
- "Unable to estimate virtual size\n");
- return 0;
+ xf86DrvMsg(scrp->scrnIndex, X_WARNING,
+ "Unable to estimate virtual size\n");
+ return 0;
}
-found:
+ found:
*vx = x;
*vy = y;
xf86DrvMsg(scrp->scrnIndex, X_INFO,
- "Estimated virtual size for aspect ratio %.4f is %dx%d\n",
- aspect, *vx, *vy);
+ "Estimated virtual size for aspect ratio %.4f is %dx%d\n",
+ aspect, *vx, *vy);
return 1;
}
@@ -1177,8 +1192,7 @@ LCM(unsigned int x, unsigned int y)
{
unsigned int m = x, n = y, o;
- while ((o = m % n))
- {
+ while ((o = m % n)) {
m = n;
n = o;
}
@@ -1193,14 +1207,12 @@ LCM(unsigned int x, unsigned int y)
* cannot exist.
*/
static int
-scanLineWidth(
- unsigned int xsize, /* pixels */
- unsigned int ysize, /* pixels */
- unsigned int width, /* pixels */
- unsigned long BankSize, /* char's */
- PixmapFormatRec *pBankFormat,
- unsigned int nWidthUnit /* bits */
-)
+scanLineWidth(unsigned int xsize, /* pixels */
+ unsigned int ysize, /* pixels */
+ unsigned int width, /* pixels */
+ unsigned long BankSize, /* char's */
+ PixmapFormatRec * pBankFormat, unsigned int nWidthUnit /* bits */
+ )
{
unsigned long nBitsPerBank, nBitsPerScanline, nBitsPerScanlinePadUnit;
unsigned long minBitsPerScanline, maxBitsPerScanline;
@@ -1223,7 +1235,7 @@ scanLineWidth(
width = nBitsPerScanline / pBankFormat->bitsPerPixel;
if (!xsize || !(nBitsPerBank % pBankFormat->bitsPerPixel))
- return (int)width;
+ return (int) width;
/*
* Scanlines will be server-pad aligned at this point. They will also be
@@ -1244,40 +1256,36 @@ scanLineWidth(
return -1;
if (ysize == 1)
- return (int)width;
+ return (int) width;
maxBitsPerScanline =
- (((unsigned long)(-1) >> 1) - minBitsPerScanline) / (ysize - 1);
- while (nBitsPerScanline <= maxBitsPerScanline)
- {
+ (((unsigned long) (-1) >> 1) - minBitsPerScanline) / (ysize - 1);
+ while (nBitsPerScanline <= maxBitsPerScanline) {
unsigned long BankBase, BankUnit;
BankUnit = ((nBitsPerBank + nBitsPerScanline - 1) / nBitsPerBank) *
nBitsPerBank;
if (!(BankUnit % nBitsPerScanline))
- return (int)width;
+ return (int) width;
- for (BankBase = BankUnit; ; BankBase += nBitsPerBank)
- {
+ for (BankBase = BankUnit;; BankBase += nBitsPerBank) {
unsigned long x, y;
y = BankBase / nBitsPerScanline;
if (y >= ysize)
- return (int)width;
+ return (int) width;
x = BankBase % nBitsPerScanline;
if (!(x % pBankFormat->bitsPerPixel))
continue;
- if (x < minBitsPerScanline)
- {
+ if (x < minBitsPerScanline) {
/*
* Skip ahead certain widths by dividing the excess scanline
* amongst the y's.
*/
y *= nBitsPerScanlinePadUnit;
- nBitsPerScanline +=
- ((x + y - 1) / y) * nBitsPerScanlinePadUnit;
+ nBitsPerScanline += ((x + y - 1) / y) * nBitsPerScanlinePadUnit;
width = nBitsPerScanline / pBankFormat->bitsPerPixel;
break;
}
@@ -1286,10 +1294,10 @@ scanLineWidth(
continue;
if (!(nBitsPerScanline % x))
- return (int)width;
+ return (int) width;
BankBase = ((nBitsPerScanline - minBitsPerScanline) /
- (nBitsPerScanline - x)) * BankUnit;
+ (nBitsPerScanline - x)) * BankUnit;
}
}
@@ -1346,17 +1354,17 @@ scanLineWidth(
int
xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
- char **modeNames, ClockRangePtr clockRanges,
- int *linePitches, int minPitch, int maxPitch, int pitchInc,
- int minHeight, int maxHeight, int virtualX, int virtualY,
- int apertureSize, LookupModeFlags strategy)
+ char **modeNames, ClockRangePtr clockRanges,
+ int *linePitches, int minPitch, int maxPitch, int pitchInc,
+ int minHeight, int maxHeight, int virtualX, int virtualY,
+ int apertureSize, LookupModeFlags strategy)
{
DisplayModePtr p, q, r, new, last, *endp;
int i, numModes = 0;
ModeStatus status;
int linePitch = -1, virtX = 0, virtY = 0;
int newLinePitch, newVirtX, newVirtY;
- int modeSize; /* in pixels */
+ int modeSize; /* in pixels */
Bool validateAllDefaultModes = FALSE;
Bool userModes = FALSE;
int saveType;
@@ -1368,30 +1376,29 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
range vrefresh[MAX_VREFRESH];
Bool inferred_virtual = FALSE;
- DebugF("xf86ValidateModes(%p, %p, %p, %p,\n\t\t %p, %d, %d, %d, %d, %d, %d, %d, %d, 0x%x)\n",
- scrp, availModes, modeNames, clockRanges,
- linePitches, minPitch, maxPitch, pitchInc,
- minHeight, maxHeight, virtualX, virtualY,
- apertureSize, strategy
- );
+ DebugF
+ ("xf86ValidateModes(%p, %p, %p, %p,\n\t\t %p, %d, %d, %d, %d, %d, %d, %d, %d, 0x%x)\n",
+ scrp, availModes, modeNames, clockRanges, linePitches, minPitch,
+ maxPitch, pitchInc, minHeight, maxHeight, virtualX, virtualY,
+ apertureSize, strategy);
/* Some sanity checking */
if (scrp == NULL || scrp->name == NULL || !scrp->monitor ||
- (!scrp->progClock && scrp->numClocks == 0)) {
- ErrorF("xf86ValidateModes: called with invalid scrnInfoRec\n");
- return -1;
+ (!scrp->progClock && scrp->numClocks == 0)) {
+ ErrorF("xf86ValidateModes: called with invalid scrnInfoRec\n");
+ return -1;
}
if (linePitches != NULL && linePitches[0] <= 0) {
- ErrorF("xf86ValidateModes: called with invalid linePitches\n");
- return -1;
+ ErrorF("xf86ValidateModes: called with invalid linePitches\n");
+ return -1;
}
if (pitchInc <= 0) {
- ErrorF("xf86ValidateModes: called with invalid pitchInc\n");
- return -1;
+ ErrorF("xf86ValidateModes: called with invalid pitchInc\n");
+ return -1;
}
if ((virtualX > 0) != (virtualY > 0)) {
- ErrorF("xf86ValidateModes: called with invalid virtual resolution\n");
- return -1;
+ ErrorF("xf86ValidateModes: called with invalid virtual resolution\n");
+ return -1;
}
/*
@@ -1399,83 +1406,87 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
* in the monitor section.
*/
if (strategy & LOOKUP_OPTIONAL_TOLERANCES) {
- strategy &= ~LOOKUP_OPTIONAL_TOLERANCES;
- } else {
- const char *type = "";
+ strategy &= ~LOOKUP_OPTIONAL_TOLERANCES;
+ }
+ else {
+ const char *type = "";
Bool specified = FALSE;
- if (scrp->monitor->nHsync <= 0) {
- if (numTimings > 0) {
- scrp->monitor->nHsync = numTimings;
- for (i = 0; i < numTimings; i++) {
- scrp->monitor->hsync[i].lo = hsync[i].lo;
- scrp->monitor->hsync[i].hi = hsync[i].hi;
- }
- } else {
- scrp->monitor->hsync[0].lo = 31.5;
- scrp->monitor->hsync[0].hi = 48.0;
- scrp->monitor->nHsync = 1;
- }
- type = "default ";
- } else {
+ if (scrp->monitor->nHsync <= 0) {
+ if (numTimings > 0) {
+ scrp->monitor->nHsync = numTimings;
+ for (i = 0; i < numTimings; i++) {
+ scrp->monitor->hsync[i].lo = hsync[i].lo;
+ scrp->monitor->hsync[i].hi = hsync[i].hi;
+ }
+ }
+ else {
+ scrp->monitor->hsync[0].lo = 31.5;
+ scrp->monitor->hsync[0].hi = 48.0;
+ scrp->monitor->nHsync = 1;
+ }
+ type = "default ";
+ }
+ else {
specified = TRUE;
}
- for (i = 0; i < scrp->monitor->nHsync; i++) {
- if (scrp->monitor->hsync[i].lo == scrp->monitor->hsync[i].hi)
- xf86DrvMsg(scrp->scrnIndex, X_INFO,
- "%s: Using %shsync value of %.2f kHz\n",
- scrp->monitor->id, type,
- scrp->monitor->hsync[i].lo);
- else
- xf86DrvMsg(scrp->scrnIndex, X_INFO,
- "%s: Using %shsync range of %.2f-%.2f kHz\n",
- scrp->monitor->id, type,
- scrp->monitor->hsync[i].lo,
- scrp->monitor->hsync[i].hi);
- }
-
- type = "";
- if (scrp->monitor->nVrefresh <= 0) {
- if (numTimings > 0) {
- scrp->monitor->nVrefresh = numTimings;
- for (i = 0; i < numTimings; i++) {
- scrp->monitor->vrefresh[i].lo = vrefresh[i].lo;
- scrp->monitor->vrefresh[i].hi = vrefresh[i].hi;
- }
- } else {
- scrp->monitor->vrefresh[0].lo = 50;
- scrp->monitor->vrefresh[0].hi = 70;
- scrp->monitor->nVrefresh = 1;
- }
- type = "default ";
- } 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 %shsync value of %.2f kHz\n",
+ scrp->monitor->id, type, scrp->monitor->hsync[i].lo);
+ else
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "%s: Using %shsync range of %.2f-%.2f kHz\n",
+ scrp->monitor->id, type,
+ scrp->monitor->hsync[i].lo,
+ scrp->monitor->hsync[i].hi);
+ }
+
+ type = "";
+ if (scrp->monitor->nVrefresh <= 0) {
+ if (numTimings > 0) {
+ scrp->monitor->nVrefresh = numTimings;
+ for (i = 0; i < numTimings; i++) {
+ scrp->monitor->vrefresh[i].lo = vrefresh[i].lo;
+ scrp->monitor->vrefresh[i].hi = vrefresh[i].hi;
+ }
+ }
+ else {
+ scrp->monitor->vrefresh[0].lo = 50;
+ scrp->monitor->vrefresh[0].hi = 70;
+ scrp->monitor->nVrefresh = 1;
+ }
+ type = "default ";
+ }
+ else {
specified = TRUE;
}
- for (i = 0; i < scrp->monitor->nVrefresh; i++) {
- if (scrp->monitor->vrefresh[i].lo == scrp->monitor->vrefresh[i].hi)
- xf86DrvMsg(scrp->scrnIndex, X_INFO,
- "%s: Using %svrefresh value of %.2f Hz\n",
- scrp->monitor->id, type,
- scrp->monitor->vrefresh[i].lo);
- else
- xf86DrvMsg(scrp->scrnIndex, X_INFO,
- "%s: Using %svrefresh range of %.2f-%.2f Hz\n",
- scrp->monitor->id, type,
- scrp->monitor->vrefresh[i].lo,
- scrp->monitor->vrefresh[i].hi);
- }
+ for (i = 0; i < scrp->monitor->nVrefresh; i++) {
+ if (scrp->monitor->vrefresh[i].lo == scrp->monitor->vrefresh[i].hi)
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "%s: Using %svrefresh value of %.2f Hz\n",
+ scrp->monitor->id, type,
+ scrp->monitor->vrefresh[i].lo);
+ else
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "%s: Using %svrefresh range of %.2f-%.2f Hz\n",
+ scrp->monitor->id, type,
+ scrp->monitor->vrefresh[i].lo,
+ scrp->monitor->vrefresh[i].hi);
+ }
type = "";
- if (!scrp->monitor->maxPixClock && !specified) {
+ if (!scrp->monitor->maxPixClock && !specified) {
type = "default ";
scrp->monitor->maxPixClock = 65000.0;
}
- if (scrp->monitor->maxPixClock) {
- xf86DrvMsg(scrp->scrnIndex, X_INFO,
- "%s: Using %smaximum pixel clock of %.2f MHz\n",
- scrp->monitor->id, type,
- (float)scrp->monitor->maxPixClock / 1000.0);
- }
+ if (scrp->monitor->maxPixClock) {
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "%s: Using %smaximum pixel clock of %.2f MHz\n",
+ scrp->monitor->id, type,
+ (float) scrp->monitor->maxPixClock / 1000.0);
+ }
}
/*
@@ -1483,24 +1494,24 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
*/
storeClockRanges = scrp->clockRanges;
while (storeClockRanges != NULL) {
- storeClockRanges = storeClockRanges->next;
+ storeClockRanges = storeClockRanges->next;
}
for (cp = clockRanges; cp != NULL; cp = cp->next,
- storeClockRanges = storeClockRanges->next) {
- storeClockRanges = xnfalloc(sizeof(ClockRange));
- if (scrp->clockRanges == NULL)
- scrp->clockRanges = storeClockRanges;
- memcpy(storeClockRanges, cp, sizeof(ClockRange));
+ storeClockRanges = storeClockRanges->next) {
+ storeClockRanges = xnfalloc(sizeof(ClockRange));
+ if (scrp->clockRanges == NULL)
+ scrp->clockRanges = storeClockRanges;
+ memcpy(storeClockRanges, cp, sizeof(ClockRange));
}
/* Determine which pixmap format to pass to scanLineWidth() */
if (scrp->depth > 4)
- BankFormat = &scrp->fbFormat;
+ BankFormat = &scrp->fbFormat;
else
- BankFormat = xf86GetPixFormat(scrp, 1); /* >not< scrp->depth! */
+ BankFormat = xf86GetPixFormat(scrp, 1); /* >not< scrp->depth! */
if (scrp->xInc <= 0)
- scrp->xInc = 8; /* Suitable for VGA and others */
+ scrp->xInc = 8; /* Suitable for VGA and others */
#define _VIRTUALX(x) ((((x) + scrp->xInc - 1) / scrp->xInc) * scrp->xInc)
@@ -1510,13 +1521,13 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
* maxPitch values passed are ignored.
*/
if (linePitches) {
- minPitch = maxPitch = linePitches[0];
- for (i = 1; linePitches[i] > 0; i++) {
- if (linePitches[i] > maxPitch)
- maxPitch = linePitches[i];
- if (linePitches[i] < minPitch)
- minPitch = linePitches[i];
- }
+ minPitch = maxPitch = linePitches[0];
+ for (i = 1; linePitches[i] > 0; i++) {
+ if (linePitches[i] > maxPitch)
+ maxPitch = linePitches[i];
+ if (linePitches[i] < minPitch)
+ minPitch = linePitches[i];
+ }
}
/* Initial check of virtual size against other constraints */
@@ -1525,60 +1536,62 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
* Initialise virtX and virtY if the values are fixed.
*/
if (virtualY > 0) {
- if (maxHeight > 0 && virtualY > maxHeight) {
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Virtual height (%d) is too large for the hardware "
- "(max %d)\n", virtualY, maxHeight);
- return -1;
- }
-
- if (minHeight > 0 && virtualY < minHeight) {
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Virtual height (%d) is too small for the hardware "
- "(min %d)\n", virtualY, minHeight);
- return -1;
- }
-
- virtualX = _VIRTUALX(virtualX);
- if (linePitches != NULL) {
- for (i = 0; linePitches[i] != 0; i++) {
- if ((linePitches[i] >= virtualX) &&
- (linePitches[i] ==
- scanLineWidth(virtualX, virtualY, linePitches[i],
- apertureSize, BankFormat, pitchInc))) {
- linePitch = linePitches[i];
- break;
- }
- }
- } else {
- linePitch = scanLineWidth(virtualX, virtualY, minPitch,
- apertureSize, BankFormat, pitchInc);
- }
-
- if ((linePitch < minPitch) || (linePitch > maxPitch)) {
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Virtual width (%d) is too large for the hardware "
- "(max %d)\n", virtualX, maxPitch);
- return -1;
- }
-
- if (!xf86CheckModeSize(scrp, linePitch, virtualX, virtualY)) {
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Virtual size (%dx%d) (pitch %d) exceeds video memory\n",
- virtualX, virtualY, linePitch);
- return -1;
- }
-
- virtX = virtualX;
- virtY = virtualY;
- scrp->virtualFrom = X_CONFIG;
- } else if (!modeNames || !*modeNames) {
- /* No virtual size given in the config, try to infer */
- /* XXX this doesn't take m{in,ax}Pitch into account; oh well */
- inferred_virtual = inferVirtualSize(scrp, availModes, &virtX, &virtY);
- if (inferred_virtual)
- linePitch = scanLineWidth(virtX, virtY, minPitch, apertureSize,
- BankFormat, pitchInc);
+ if (maxHeight > 0 && virtualY > maxHeight) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Virtual height (%d) is too large for the hardware "
+ "(max %d)\n", virtualY, maxHeight);
+ return -1;
+ }
+
+ if (minHeight > 0 && virtualY < minHeight) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Virtual height (%d) is too small for the hardware "
+ "(min %d)\n", virtualY, minHeight);
+ return -1;
+ }
+
+ virtualX = _VIRTUALX(virtualX);
+ if (linePitches != NULL) {
+ for (i = 0; linePitches[i] != 0; i++) {
+ if ((linePitches[i] >= virtualX) &&
+ (linePitches[i] ==
+ scanLineWidth(virtualX, virtualY, linePitches[i],
+ apertureSize, BankFormat, pitchInc))) {
+ linePitch = linePitches[i];
+ break;
+ }
+ }
+ }
+ else {
+ linePitch = scanLineWidth(virtualX, virtualY, minPitch,
+ apertureSize, BankFormat, pitchInc);
+ }
+
+ if ((linePitch < minPitch) || (linePitch > maxPitch)) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Virtual width (%d) is too large for the hardware "
+ "(max %d)\n", virtualX, maxPitch);
+ return -1;
+ }
+
+ if (!xf86CheckModeSize(scrp, linePitch, virtualX, virtualY)) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Virtual size (%dx%d) (pitch %d) exceeds video memory\n",
+ virtualX, virtualY, linePitch);
+ return -1;
+ }
+
+ virtX = virtualX;
+ virtY = virtualY;
+ scrp->virtualFrom = X_CONFIG;
+ }
+ else if (!modeNames || !*modeNames) {
+ /* No virtual size given in the config, try to infer */
+ /* XXX this doesn't take m{in,ax}Pitch into account; oh well */
+ inferred_virtual = inferVirtualSize(scrp, availModes, &virtX, &virtY);
+ if (inferred_virtual)
+ linePitch = scanLineWidth(virtX, virtY, minPitch, apertureSize,
+ BankFormat, pitchInc);
}
/* Print clock ranges and scaled clocks */
@@ -1591,253 +1604,256 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
* member of the scrp->modes list for which a match was considered.
*/
if (scrp->modePool == NULL) {
- q = NULL;
- for (p = availModes; p != NULL; p = p->next) {
- status = xf86InitialCheckModeForDriver(scrp, p, clockRanges,
- strategy, maxPitch,
- virtX, virtY);
-
- if (status == MODE_OK) {
- status = xf86CheckModeForMonitor(p, scrp->monitor);
- }
-
- if (status == MODE_OK) {
- new = xnfalloc(sizeof(DisplayModeRec));
- *new = *p;
- new->next = NULL;
- if (!q) {
- scrp->modePool = new;
- } else {
- q->next = new;
- }
- new->prev = NULL;
- q = new;
- q->name = xnfstrdup(p->name);
- q->status = MODE_OK;
- } else {
- printModeRejectMessage(scrp->scrnIndex, p, status);
- }
- }
-
- if (scrp->modePool == NULL) {
- xf86DrvMsg(scrp->scrnIndex, X_WARNING, "Mode pool is empty\n");
- return 0;
- }
- } else {
- for (p = scrp->modePool; p != NULL; p = p->next) {
- p->prev = NULL;
- p->status = MODE_OK;
- }
+ q = NULL;
+ for (p = availModes; p != NULL; p = p->next) {
+ status = xf86InitialCheckModeForDriver(scrp, p, clockRanges,
+ strategy, maxPitch,
+ virtX, virtY);
+
+ if (status == MODE_OK) {
+ status = xf86CheckModeForMonitor(p, scrp->monitor);
+ }
+
+ if (status == MODE_OK) {
+ new = xnfalloc(sizeof(DisplayModeRec));
+ *new = *p;
+ new->next = NULL;
+ if (!q) {
+ scrp->modePool = new;
+ }
+ else {
+ q->next = new;
+ }
+ new->prev = NULL;
+ q = new;
+ q->name = xnfstrdup(p->name);
+ q->status = MODE_OK;
+ }
+ else {
+ printModeRejectMessage(scrp->scrnIndex, p, status);
+ }
+ }
+
+ if (scrp->modePool == NULL) {
+ xf86DrvMsg(scrp->scrnIndex, X_WARNING, "Mode pool is empty\n");
+ return 0;
+ }
+ }
+ else {
+ for (p = scrp->modePool; p != NULL; p = p->next) {
+ p->prev = NULL;
+ p->status = MODE_OK;
+ }
}
/*
* Allocate one entry in scrp->modes for each named mode.
*/
while (scrp->modes)
- xf86DeleteMode(&scrp->modes, scrp->modes);
+ xf86DeleteMode(&scrp->modes, scrp->modes);
endp = &scrp->modes;
last = NULL;
if (modeNames != NULL) {
- for (i = 0; modeNames[i] != NULL; i++) {
- userModes = TRUE;
- new = xnfcalloc(1, sizeof(DisplayModeRec));
- new->prev = last;
- new->type = M_T_USERDEF;
- new->name = xnfstrdup(modeNames[i]);
- if (new->prev)
- new->prev->next = new;
- *endp = last = new;
- endp = &new->next;
- }
+ for (i = 0; modeNames[i] != NULL; i++) {
+ userModes = TRUE;
+ new = xnfcalloc(1, sizeof(DisplayModeRec));
+ new->prev = last;
+ new->type = M_T_USERDEF;
+ new->name = xnfstrdup(modeNames[i]);
+ if (new->prev)
+ new->prev->next = new;
+ *endp = last = new;
+ endp = &new->next;
+ }
}
/* Lookup each mode */
#ifdef RANDR
- if (!xf86Info.disableRandR
+ if (!xf86Info.disableRandR
#ifdef PANORAMIX
- && noPanoramiXExtension
+ && noPanoramiXExtension
#endif
- )
- validateAllDefaultModes = TRUE;
+ )
+ validateAllDefaultModes = TRUE;
#endif
- for (p = scrp->modes; ; p = p->next) {
- Bool repeat;
-
- /*
- * If the supplied mode names don't produce a valid mode, scan through
- * unconsidered modePool members until one survives validation. This
- * is done in decreasing order by mode pixel area.
- */
-
- if (p == NULL) {
- if ((numModes > 0) && !validateAllDefaultModes)
- break;
-
- validateAllDefaultModes = TRUE;
- r = NULL;
- modeSize = 0;
- for (q = scrp->modePool; q != NULL; q = q->next) {
- if ((q->prev == NULL) && (q->status == MODE_OK)) {
- /*
- * Deal with the case where this mode wasn't considered
- * because of a builtin mode of the same name.
- */
- for (p = scrp->modes; p != NULL; p = p->next) {
- if ((p->status != MODE_OK) &&
- !strcmp(p->name, q->name))
- break;
- }
-
- if (p != NULL)
- q->prev = p;
- else {
- /*
- * A quick check to not allow default modes with
- * horizontal timing parameters that CRTs may have
- * problems with.
- */
- if (!scrp->monitor->reducedblanking &&
- (q->type & M_T_DEFAULT) &&
- ((double)q->HTotal / (double)q->HDisplay) < 1.15)
- continue;
-
- if (modeSize < (q->HDisplay * q->VDisplay)) {
- r = q;
- modeSize = q->HDisplay * q->VDisplay;
- }
- }
- }
- }
-
- if (r == NULL)
- break;
-
- p = xnfcalloc(1, sizeof(DisplayModeRec));
- p->prev = last;
- p->name = xnfstrdup(r->name);
- if (!userModes)
- p->type = M_T_USERDEF;
- if (p->prev)
- p->prev->next = p;
- *endp = last = p;
- endp = &p->next;
- }
-
- repeat = FALSE;
- lookupNext:
- if (repeat && ((status = p->status) != MODE_OK))
- printModeRejectMessage(scrp->scrnIndex, p, status);
- saveType = p->type;
- status = xf86LookupMode(scrp, p, clockRanges, strategy);
- if (repeat && status == MODE_NOMODE)
- continue;
- if (status != MODE_OK)
- printModeRejectMessage(scrp->scrnIndex, p, status);
- if (status == MODE_ERROR) {
- ErrorF("xf86ValidateModes: "
- "unexpected result from xf86LookupMode()\n");
- return -1;
- }
- if (status != MODE_OK) {
- if (p->status == MODE_OK)
- p->status = status;
- continue;
- }
- p->type |= saveType;
- repeat = TRUE;
-
- newLinePitch = linePitch;
- newVirtX = virtX;
- newVirtY = virtY;
-
- /*
- * Don't let non-user defined modes increase the virtual size
- */
- if (!(p->type & M_T_USERDEF) && (numModes > 0)) {
- if (p->HDisplay > virtX) {
- p->status = MODE_VIRTUAL_X;
- goto lookupNext;
- }
- if (p->VDisplay > virtY) {
- p->status = MODE_VIRTUAL_Y;
- goto lookupNext;
- }
- }
- /*
- * Adjust virtual width and height if the mode is too large for the
- * current values and if they are not fixed.
- */
- if (virtualX <= 0 && p->HDisplay > newVirtX)
- newVirtX = _VIRTUALX(p->HDisplay);
- if (virtualY <= 0 && p->VDisplay > newVirtY) {
- if (maxHeight > 0 && p->VDisplay > maxHeight) {
- p->status = MODE_VIRTUAL_Y; /* ? */
- goto lookupNext;
- }
- newVirtY = p->VDisplay;
- }
-
- /*
- * If virtual resolution is to be increased, revalidate it.
- */
- if ((virtX != newVirtX) || (virtY != newVirtY)) {
- if (linePitches != NULL) {
- newLinePitch = -1;
- for (i = 0; linePitches[i] != 0; i++) {
- if ((linePitches[i] >= newVirtX) &&
- (linePitches[i] >= linePitch) &&
- (linePitches[i] ==
- scanLineWidth(newVirtX, newVirtY, linePitches[i],
- apertureSize, BankFormat, pitchInc))) {
- newLinePitch = linePitches[i];
- break;
- }
- }
- } else {
- if (linePitch < minPitch)
- linePitch = minPitch;
- newLinePitch = scanLineWidth(newVirtX, newVirtY, linePitch,
- apertureSize, BankFormat,
- pitchInc);
- }
- if ((newLinePitch < minPitch) || (newLinePitch > maxPitch)) {
- p->status = MODE_BAD_WIDTH;
- goto lookupNext;
- }
-
- /*
- * Check that the pixel area required by the new virtual height
- * and line pitch isn't too large.
- */
- if (!xf86CheckModeSize(scrp, newLinePitch, newVirtX, newVirtY)) {
- p->status = MODE_MEM_VIRT;
- goto lookupNext;
- }
- }
-
- if (scrp->ValidMode) {
- /*
- * Give the driver a final say, passing it the proposed virtual
- * geometry.
- */
- scrp->virtualX = newVirtX;
- scrp->virtualY = newVirtY;
- scrp->displayWidth = newLinePitch;
- p->status = (scrp->ValidMode)(scrp->scrnIndex, p, FALSE,
- MODECHECK_FINAL);
-
- if (p->status != MODE_OK) {
- goto lookupNext;
- }
- }
-
- /* Mode has passed all the tests */
- virtX = newVirtX;
- virtY = newVirtY;
- linePitch = newLinePitch;
- p->status = MODE_OK;
- numModes++;
+ for (p = scrp->modes;; p = p->next) {
+ Bool repeat;
+
+ /*
+ * If the supplied mode names don't produce a valid mode, scan through
+ * unconsidered modePool members until one survives validation. This
+ * is done in decreasing order by mode pixel area.
+ */
+
+ if (p == NULL) {
+ if ((numModes > 0) && !validateAllDefaultModes)
+ break;
+
+ validateAllDefaultModes = TRUE;
+ r = NULL;
+ modeSize = 0;
+ for (q = scrp->modePool; q != NULL; q = q->next) {
+ if ((q->prev == NULL) && (q->status == MODE_OK)) {
+ /*
+ * Deal with the case where this mode wasn't considered
+ * because of a builtin mode of the same name.
+ */
+ for (p = scrp->modes; p != NULL; p = p->next) {
+ if ((p->status != MODE_OK) && !strcmp(p->name, q->name))
+ break;
+ }
+
+ if (p != NULL)
+ q->prev = p;
+ else {
+ /*
+ * A quick check to not allow default modes with
+ * horizontal timing parameters that CRTs may have
+ * problems with.
+ */
+ if (!scrp->monitor->reducedblanking &&
+ (q->type & M_T_DEFAULT) &&
+ ((double) q->HTotal / (double) q->HDisplay) < 1.15)
+ continue;
+
+ if (modeSize < (q->HDisplay * q->VDisplay)) {
+ r = q;
+ modeSize = q->HDisplay * q->VDisplay;
+ }
+ }
+ }
+ }
+
+ if (r == NULL)
+ break;
+
+ p = xnfcalloc(1, sizeof(DisplayModeRec));
+ p->prev = last;
+ p->name = xnfstrdup(r->name);
+ if (!userModes)
+ p->type = M_T_USERDEF;
+ if (p->prev)
+ p->prev->next = p;
+ *endp = last = p;
+ endp = &p->next;
+ }
+
+ repeat = FALSE;
+ lookupNext:
+ if (repeat && ((status = p->status) != MODE_OK))
+ printModeRejectMessage(scrp->scrnIndex, p, status);
+ saveType = p->type;
+ status = xf86LookupMode(scrp, p, clockRanges, strategy);
+ if (repeat && status == MODE_NOMODE)
+ continue;
+ if (status != MODE_OK)
+ printModeRejectMessage(scrp->scrnIndex, p, status);
+ if (status == MODE_ERROR) {
+ ErrorF("xf86ValidateModes: "
+ "unexpected result from xf86LookupMode()\n");
+ return -1;
+ }
+ if (status != MODE_OK) {
+ if (p->status == MODE_OK)
+ p->status = status;
+ continue;
+ }
+ p->type |= saveType;
+ repeat = TRUE;
+
+ newLinePitch = linePitch;
+ newVirtX = virtX;
+ newVirtY = virtY;
+
+ /*
+ * Don't let non-user defined modes increase the virtual size
+ */
+ if (!(p->type & M_T_USERDEF) && (numModes > 0)) {
+ if (p->HDisplay > virtX) {
+ p->status = MODE_VIRTUAL_X;
+ goto lookupNext;
+ }
+ if (p->VDisplay > virtY) {
+ p->status = MODE_VIRTUAL_Y;
+ goto lookupNext;
+ }
+ }
+ /*
+ * Adjust virtual width and height if the mode is too large for the
+ * current values and if they are not fixed.
+ */
+ if (virtualX <= 0 && p->HDisplay > newVirtX)
+ newVirtX = _VIRTUALX(p->HDisplay);
+ if (virtualY <= 0 && p->VDisplay > newVirtY) {
+ if (maxHeight > 0 && p->VDisplay > maxHeight) {
+ p->status = MODE_VIRTUAL_Y; /* ? */
+ goto lookupNext;
+ }
+ newVirtY = p->VDisplay;
+ }
+
+ /*
+ * If virtual resolution is to be increased, revalidate it.
+ */
+ if ((virtX != newVirtX) || (virtY != newVirtY)) {
+ if (linePitches != NULL) {
+ newLinePitch = -1;
+ for (i = 0; linePitches[i] != 0; i++) {
+ if ((linePitches[i] >= newVirtX) &&
+ (linePitches[i] >= linePitch) &&
+ (linePitches[i] ==
+ scanLineWidth(newVirtX, newVirtY, linePitches[i],
+ apertureSize, BankFormat, pitchInc))) {
+ newLinePitch = linePitches[i];
+ break;
+ }
+ }
+ }
+ else {
+ if (linePitch < minPitch)
+ linePitch = minPitch;
+ newLinePitch = scanLineWidth(newVirtX, newVirtY, linePitch,
+ apertureSize, BankFormat,
+ pitchInc);
+ }
+ if ((newLinePitch < minPitch) || (newLinePitch > maxPitch)) {
+ p->status = MODE_BAD_WIDTH;
+ goto lookupNext;
+ }
+
+ /*
+ * Check that the pixel area required by the new virtual height
+ * and line pitch isn't too large.
+ */
+ if (!xf86CheckModeSize(scrp, newLinePitch, newVirtX, newVirtY)) {
+ p->status = MODE_MEM_VIRT;
+ goto lookupNext;
+ }
+ }
+
+ if (scrp->ValidMode) {
+ /*
+ * Give the driver a final say, passing it the proposed virtual
+ * geometry.
+ */
+ scrp->virtualX = newVirtX;
+ scrp->virtualY = newVirtY;
+ scrp->displayWidth = newLinePitch;
+ p->status = (scrp->ValidMode) (scrp->scrnIndex, p, FALSE,
+ MODECHECK_FINAL);
+
+ if (p->status != MODE_OK) {
+ goto lookupNext;
+ }
+ }
+
+ /* Mode has passed all the tests */
+ virtX = newVirtX;
+ virtY = newVirtY;
+ linePitch = newLinePitch;
+ p->status = MODE_OK;
+ numModes++;
}
/*
@@ -1846,102 +1862,105 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
* fix up if so.
*/
if (inferred_virtual) {
- int vx = 0, vy = 0;
- for (p = scrp->modes; p; p = p->next) {
- if (p->HDisplay > vx && p->VDisplay > vy) {
- vx = p->HDisplay;
- vy = p->VDisplay;
- }
- }
- if (vx < virtX || vy < virtY) {
- const int types[] = {
- M_T_BUILTIN | M_T_PREFERRED,
- M_T_BUILTIN,
- M_T_DRIVER | M_T_PREFERRED,
- M_T_DRIVER,
- 0
- };
- const int ntypes = sizeof(types) / sizeof(int);
- int n;
-
- /*
- * We did not find the estimated virtual size. So now we want to
- * find the largest mode available, but we want to search in the
- * modes in the order of "types" listed above.
- */
- for (n = 0; n < ntypes; n++) {
- int type = types[n];
-
- vx = 0; vy = 0;
- for (p = scrp->modes; p; p = p->next) {
- /* scan through the modes in the sort order above */
- if ((p->type & type) != type)
- continue;
- if (p->HDisplay > vx && p->VDisplay > vy) {
- vx = p->HDisplay;
- vy = p->VDisplay;
- }
- }
- if (vx && vy)
- /* Found one */
- break;
- }
- xf86DrvMsg(scrp->scrnIndex, X_WARNING,
- "Shrinking virtual size estimate from %dx%d to %dx%d\n",
- virtX, virtY, vx, vy);
- virtX = _VIRTUALX(vx);
- virtY = vy;
- for (p = scrp->modes; p; p = p->next) {
- if (numModes > 0) {
- if (p->HDisplay > virtX)
- p->status = MODE_VIRTUAL_X;
- if (p->VDisplay > virtY)
- p->status = MODE_VIRTUAL_Y;
- if (p->status != MODE_OK) {
- numModes--;
- printModeRejectMessage(scrp->scrnIndex, p, p->status);
- }
- }
- }
- if (linePitches != NULL) {
- for (i = 0; linePitches[i] != 0; i++) {
- if ((linePitches[i] >= virtX) &&
- (linePitches[i] ==
- scanLineWidth(virtX, virtY, linePitches[i],
- apertureSize, BankFormat, pitchInc))) {
- linePitch = linePitches[i];
- break;
- }
- }
- } else {
- linePitch = scanLineWidth(virtX, virtY, minPitch,
- apertureSize, BankFormat, pitchInc);
- }
- }
+ int vx = 0, vy = 0;
+
+ for (p = scrp->modes; p; p = p->next) {
+ if (p->HDisplay > vx && p->VDisplay > vy) {
+ vx = p->HDisplay;
+ vy = p->VDisplay;
+ }
+ }
+ if (vx < virtX || vy < virtY) {
+ const int types[] = {
+ M_T_BUILTIN | M_T_PREFERRED,
+ M_T_BUILTIN,
+ M_T_DRIVER | M_T_PREFERRED,
+ M_T_DRIVER,
+ 0
+ };
+ const int ntypes = sizeof(types) / sizeof(int);
+ int n;
+
+ /*
+ * We did not find the estimated virtual size. So now we want to
+ * find the largest mode available, but we want to search in the
+ * modes in the order of "types" listed above.
+ */
+ for (n = 0; n < ntypes; n++) {
+ int type = types[n];
+
+ vx = 0;
+ vy = 0;
+ for (p = scrp->modes; p; p = p->next) {
+ /* scan through the modes in the sort order above */
+ if ((p->type & type) != type)
+ continue;
+ if (p->HDisplay > vx && p->VDisplay > vy) {
+ vx = p->HDisplay;
+ vy = p->VDisplay;
+ }
+ }
+ if (vx && vy)
+ /* Found one */
+ break;
+ }
+ xf86DrvMsg(scrp->scrnIndex, X_WARNING,
+ "Shrinking virtual size estimate from %dx%d to %dx%d\n",
+ virtX, virtY, vx, vy);
+ virtX = _VIRTUALX(vx);
+ virtY = vy;
+ for (p = scrp->modes; p; p = p->next) {
+ if (numModes > 0) {
+ if (p->HDisplay > virtX)
+ p->status = MODE_VIRTUAL_X;
+ if (p->VDisplay > virtY)
+ p->status = MODE_VIRTUAL_Y;
+ if (p->status != MODE_OK) {
+ numModes--;
+ printModeRejectMessage(scrp->scrnIndex, p, p->status);
+ }
+ }
+ }
+ if (linePitches != NULL) {
+ for (i = 0; linePitches[i] != 0; i++) {
+ if ((linePitches[i] >= virtX) &&
+ (linePitches[i] ==
+ scanLineWidth(virtX, virtY, linePitches[i],
+ apertureSize, BankFormat, pitchInc))) {
+ linePitch = linePitches[i];
+ break;
+ }
+ }
+ }
+ else {
+ linePitch = scanLineWidth(virtX, virtY, minPitch,
+ apertureSize, BankFormat, pitchInc);
+ }
+ }
}
/* Update the ScrnInfoRec parameters */
-
+
scrp->virtualX = virtX;
scrp->virtualY = virtY;
scrp->displayWidth = linePitch;
if (numModes <= 0)
- return 0;
-
+ return 0;
+
/* Make the mode list into a circular list by joining up the ends */
p = scrp->modes;
while (p->next != NULL)
- p = p->next;
+ p = p->next;
/* p is now the last mode on the list */
p->next = scrp->modes;
scrp->modes->prev = p;
if (minHeight > 0 && virtY < minHeight) {
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Virtual height (%d) is too small for the hardware "
- "(min %d)\n", virtY, minHeight);
- return -1;
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Virtual height (%d) is too small for the hardware "
+ "(min %d)\n", virtY, minHeight);
+ return -1;
}
return numModes;
@@ -1959,26 +1978,27 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
* - doubly linked circular lists
*
*/
-
+
void
-xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode)
+xf86DeleteMode(DisplayModePtr * modeList, DisplayModePtr mode)
{
/* Catch the easy/insane cases */
if (modeList == NULL || *modeList == NULL || mode == NULL)
- return;
+ return;
/* If the mode is at the start of the list, move the start of the list */
if (*modeList == mode)
- *modeList = mode->next;
+ *modeList = mode->next;
/* If mode is the only one on the list, set the list to NULL */
if ((mode == mode->prev) && (mode == mode->next)) {
- *modeList = NULL;
- } else {
- if ((mode->prev != NULL) && (mode->prev->next == mode))
- mode->prev->next = mode->next;
- if ((mode->next != NULL) && (mode->next->prev == mode))
- mode->next->prev = mode->prev;
+ *modeList = NULL;
+ }
+ else {
+ if ((mode->prev != NULL) && (mode->prev->next == mode))
+ mode->prev->next = mode->next;
+ if ((mode->next != NULL) && (mode->next->prev == mode))
+ mode->next->prev = mode->prev;
}
free(mode->name);
@@ -1999,32 +2019,31 @@ xf86PruneDriverModes(ScrnInfoPtr scrp)
p = scrp->modes;
if (p == NULL)
- return;
+ return;
do {
- if (!(first = scrp->modes))
- return;
- n = p->next;
- if (p->status != MODE_OK) {
- xf86DeleteMode(&(scrp->modes), p);
- }
- p = n;
+ if (!(first = scrp->modes))
+ return;
+ n = p->next;
+ if (p->status != MODE_OK) {
+ xf86DeleteMode(&(scrp->modes), p);
+ }
+ p = n;
} while (p != NULL && p != first);
/* modePool is no longer needed, turf it */
while (scrp->modePool) {
- /*
- * A modePool mode's prev field is used to hold a pointer to the
- * member of the scrp->modes list for which a match was considered.
- * Clear that pointer first, otherwise xf86DeleteMode might get
- * confused
- */
- scrp->modePool->prev = NULL;
- xf86DeleteMode(&scrp->modePool, scrp->modePool);
+ /*
+ * A modePool mode's prev field is used to hold a pointer to the
+ * member of the scrp->modes list for which a match was considered.
+ * Clear that pointer first, otherwise xf86DeleteMode might get
+ * confused
+ */
+ scrp->modePool->prev = NULL;
+ xf86DeleteMode(&scrp->modePool, scrp->modePool);
}
}
-
/*
* xf86SetCrtcForModes
*
@@ -2045,18 +2064,18 @@ xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags)
p = scrp->modes;
if (p == NULL)
- return;
+ return;
do {
- xf86SetModeCrtc(p, adjustFlags);
- DebugF("%sMode %s: %d (%d) %d %d (%d) %d %d (%d) %d %d (%d) %d\n",
- (p->type & M_T_DEFAULT) ? "Default " : "",
- p->name, p->CrtcHDisplay, p->CrtcHBlankStart,
- p->CrtcHSyncStart, p->CrtcHSyncEnd, p->CrtcHBlankEnd,
- p->CrtcHTotal, p->CrtcVDisplay, p->CrtcVBlankStart,
- p->CrtcVSyncStart, p->CrtcVSyncEnd, p->CrtcVBlankEnd,
- p->CrtcVTotal);
- p = p->next;
+ xf86SetModeCrtc(p, adjustFlags);
+ DebugF("%sMode %s: %d (%d) %d %d (%d) %d %d (%d) %d %d (%d) %d\n",
+ (p->type & M_T_DEFAULT) ? "Default " : "",
+ p->name, p->CrtcHDisplay, p->CrtcHBlankStart,
+ p->CrtcHSyncStart, p->CrtcHSyncEnd, p->CrtcHBlankEnd,
+ p->CrtcHTotal, p->CrtcVDisplay, p->CrtcVBlankStart,
+ p->CrtcVSyncStart, p->CrtcVSyncEnd, p->CrtcVBlankEnd,
+ p->CrtcVTotal);
+ p = p->next;
} while (p != NULL && p != scrp->modes);
}
@@ -2068,63 +2087,65 @@ xf86PrintModes(ScrnInfoPtr scrp)
const char *desc, *desc2, *prefix, *uprefix;
if (scrp == NULL)
- return;
+ return;
xf86DrvMsg(scrp->scrnIndex, scrp->virtualFrom, "Virtual size is %dx%d "
- "(pitch %d)\n", scrp->virtualX, scrp->virtualY,
- scrp->displayWidth);
-
+ "(pitch %d)\n", scrp->virtualX, scrp->virtualY,
+ scrp->displayWidth);
+
p = scrp->modes;
if (p == NULL)
- return;
+ return;
do {
- desc = desc2 = "";
- hsync = xf86ModeHSync(p);
- refresh = xf86ModeVRefresh(p);
- if (p->Flags & V_INTERLACE) {
- desc = " (I)";
- }
- if (p->Flags & V_DBLSCAN) {
- desc = " (D)";
- }
- if (p->VScan > 1) {
- desc2 = " (VScan)";
- }
- if (p->type & M_T_BUILTIN)
- prefix = "Built-in mode";
- else if (p->type & M_T_DEFAULT)
- prefix = "Default mode";
- else if (p->type & M_T_DRIVER)
- prefix = "Driver mode";
- else
- prefix = "Mode";
- if (p->type & M_T_USERDEF)
- uprefix = "*";
- else
- uprefix = " ";
- if (hsync == 0 || refresh == 0) {
- if (p->name)
- xf86DrvMsg(scrp->scrnIndex, X_CONFIG,
- "%s%s \"%s\"\n", uprefix, prefix, p->name);
- else
- xf86DrvMsg(scrp->scrnIndex, X_PROBED,
- "%s%s %dx%d (unnamed)\n",
- uprefix, prefix, p->HDisplay, p->VDisplay);
- } else if (p->Clock == p->SynthClock) {
- xf86DrvMsg(scrp->scrnIndex, X_CONFIG,
- "%s%s \"%s\": %.1f MHz, %.1f kHz, %.1f Hz%s%s\n",
- uprefix, prefix, p->name, p->Clock / 1000.0,
- hsync, refresh, desc, desc2);
- } else {
- xf86DrvMsg(scrp->scrnIndex, X_CONFIG,
- "%s%s \"%s\": %.1f MHz (scaled from %.1f MHz), "
- "%.1f kHz, %.1f Hz%s%s\n",
- uprefix, prefix, p->name, p->Clock / 1000.0,
- p->SynthClock / 1000.0, hsync, refresh, desc, desc2);
- }
- if (hsync != 0 && refresh != 0)
- xf86PrintModeline(scrp->scrnIndex,p);
- p = p->next;
+ desc = desc2 = "";
+ hsync = xf86ModeHSync(p);
+ refresh = xf86ModeVRefresh(p);
+ if (p->Flags & V_INTERLACE) {
+ desc = " (I)";
+ }
+ if (p->Flags & V_DBLSCAN) {
+ desc = " (D)";
+ }
+ if (p->VScan > 1) {
+ desc2 = " (VScan)";
+ }
+ if (p->type & M_T_BUILTIN)
+ prefix = "Built-in mode";
+ else if (p->type & M_T_DEFAULT)
+ prefix = "Default mode";
+ else if (p->type & M_T_DRIVER)
+ prefix = "Driver mode";
+ else
+ prefix = "Mode";
+ if (p->type & M_T_USERDEF)
+ uprefix = "*";
+ else
+ uprefix = " ";
+ if (hsync == 0 || refresh == 0) {
+ if (p->name)
+ xf86DrvMsg(scrp->scrnIndex, X_CONFIG,
+ "%s%s \"%s\"\n", uprefix, prefix, p->name);
+ else
+ xf86DrvMsg(scrp->scrnIndex, X_PROBED,
+ "%s%s %dx%d (unnamed)\n",
+ uprefix, prefix, p->HDisplay, p->VDisplay);
+ }
+ else if (p->Clock == p->SynthClock) {
+ xf86DrvMsg(scrp->scrnIndex, X_CONFIG,
+ "%s%s \"%s\": %.1f MHz, %.1f kHz, %.1f Hz%s%s\n",
+ uprefix, prefix, p->name, p->Clock / 1000.0,
+ hsync, refresh, desc, desc2);
+ }
+ else {
+ xf86DrvMsg(scrp->scrnIndex, X_CONFIG,
+ "%s%s \"%s\": %.1f MHz (scaled from %.1f MHz), "
+ "%.1f kHz, %.1f Hz%s%s\n",
+ uprefix, prefix, p->name, p->Clock / 1000.0,
+ p->SynthClock / 1000.0, hsync, refresh, desc, desc2);
+ }
+ if (hsync != 0 && refresh != 0)
+ xf86PrintModeline(scrp->scrnIndex, p);
+ p = p->next;
} while (p != NULL && p != scrp->modes);
}
diff --git a/xorg-server/hw/xfree86/common/xf86Module.h b/xorg-server/hw/xfree86/common/xf86Module.h
index 1de87dbbe..894b93f59 100644
--- a/xorg-server/hw/xfree86/common/xf86Module.h
+++ b/xorg-server/hw/xfree86/common/xf86Module.h
@@ -47,10 +47,10 @@
#endif
typedef enum {
- LD_RESOLV_IFDONE = 0, /* only check if no more
- delays pending */
- LD_RESOLV_NOW = 1, /* finish one delay step */
- LD_RESOLV_FORCE = 2 /* force checking... */
+ LD_RESOLV_IFDONE = 0, /* only check if no more
+ delays pending */
+ LD_RESOLV_NOW = 1, /* finish one delay step */
+ LD_RESOLV_FORCE = 2 /* force checking... */
} LoaderResolveOptions;
#define DEFAULT_LIST ((char *)-1)
@@ -97,21 +97,21 @@ typedef enum {
/* Error return codes for errmaj. New codes must only be added at the end. */
typedef enum {
LDR_NOERROR = 0,
- LDR_NOMEM, /* memory allocation failed */
- LDR_NOENT, /* Module file does not exist */
- LDR_NOSUBENT, /* pre-requsite file to be sub-loaded does not exist */
- LDR_NOSPACE, /* internal module array full */
- LDR_NOMODOPEN, /* module file could not be opened (check errmin) */
- LDR_UNKTYPE, /* file is not a recognized module type */
- LDR_NOLOAD, /* type specific loader failed */
- LDR_ONCEONLY, /* Module should only be loaded once (not an error) */
- LDR_NOPORTOPEN, /* could not open port (check errmin) */
- LDR_NOHARDWARE, /* could not query/initialize the hardware device */
- LDR_MISMATCH, /* the module didn't match the spec'd requirments */
- LDR_BADUSAGE, /* LoadModule is called with bad arguments */
- LDR_INVALID, /* The module doesn't have a valid ModuleData object */
- LDR_BADOS, /* The module doesn't support the OS */
- LDR_MODSPECIFIC /* A module-specific error in the SetupProc */
+ LDR_NOMEM, /* memory allocation failed */
+ LDR_NOENT, /* Module file does not exist */
+ LDR_NOSUBENT, /* pre-requsite file to be sub-loaded does not exist */
+ LDR_NOSPACE, /* internal module array full */
+ LDR_NOMODOPEN, /* module file could not be opened (check errmin) */
+ LDR_UNKTYPE, /* file is not a recognized module type */
+ LDR_NOLOAD, /* type specific loader failed */
+ LDR_ONCEONLY, /* Module should only be loaded once (not an error) */
+ LDR_NOPORTOPEN, /* could not open port (check errmin) */
+ LDR_NOHARDWARE, /* could not query/initialize the hardware device */
+ LDR_MISMATCH, /* the module didn't match the spec'd requirments */
+ LDR_BADUSAGE, /* LoadModule is called with bad arguments */
+ LDR_INVALID, /* The module doesn't have a valid ModuleData object */
+ LDR_BADOS, /* The module doesn't support the OS */
+ LDR_MODSPECIFIC /* A module-specific error in the SetupProc */
} LoaderErrorCode;
/*
@@ -129,19 +129,19 @@ typedef enum {
/* This structure is expected to be returned by the initfunc */
typedef struct {
- const char * modname; /* name of module, e.g. "foo" */
- const char * vendor; /* vendor specific string */
- CARD32 _modinfo1_; /* constant MODINFOSTRING1/2 to find */
- CARD32 _modinfo2_; /* infoarea with a binary editor or sign tool */
- CARD32 xf86version; /* contains XF86_VERSION_CURRENT */
- CARD8 majorversion; /* module-specific major version */
- CARD8 minorversion; /* module-specific minor version */
- CARD16 patchlevel; /* module-specific patch level */
- const char * abiclass; /* ABI class that the module uses */
- CARD32 abiversion; /* ABI version */
- const char * moduleclass; /* module class description */
- CARD32 checksum[4]; /* contains a digital signature of the */
- /* version info structure */
+ const char *modname; /* name of module, e.g. "foo" */
+ const char *vendor; /* vendor specific string */
+ CARD32 _modinfo1_; /* constant MODINFOSTRING1/2 to find */
+ CARD32 _modinfo2_; /* infoarea with a binary editor or sign tool */
+ CARD32 xf86version; /* contains XF86_VERSION_CURRENT */
+ CARD8 majorversion; /* module-specific major version */
+ CARD8 minorversion; /* module-specific minor version */
+ CARD16 patchlevel; /* module-specific patch level */
+ const char *abiclass; /* ABI class that the module uses */
+ CARD32 abiversion; /* ABI version */
+ const char *moduleclass; /* module class description */
+ CARD32 checksum[4]; /* contains a digital signature of the */
+ /* version info structure */
} XF86ModuleVersionInfo;
/*
@@ -149,12 +149,12 @@ typedef struct {
* specify version and/or ABI requirements.
*/
typedef struct {
- CARD8 majorversion; /* module-specific major version */
- CARD8 minorversion; /* moudle-specific minor version */
- CARD16 patchlevel; /* module-specific patch level */
- const char * abiclass; /* ABI class that the module uses */
- CARD32 abiversion; /* ABI version */
- const char * moduleclass; /* module class */
+ CARD8 majorversion; /* module-specific major version */
+ CARD8 minorversion; /* moudle-specific minor version */
+ CARD16 patchlevel; /* module-specific patch level */
+ const char *abiclass; /* ABI class that the module uses */
+ CARD32 abiversion; /* ABI version */
+ const char *moduleclass; /* module class */
} XF86ModReqInfo;
/* values to indicate unspecified fields in XF86ModReqInfo. */
@@ -171,42 +171,44 @@ typedef struct {
#define INITARGS void
-typedef void (*InitExtension)(INITARGS);
+typedef void (*InitExtension) (INITARGS);
typedef struct {
- InitExtension initFunc;
- const char * name;
- Bool *disablePtr;
- InitExtension setupFunc;
- const char ** initDependencies;
+ InitExtension initFunc;
+ const char *name;
+ Bool *disablePtr;
+ InitExtension setupFunc;
+ const char **initDependencies;
} ExtensionModule;
extern _X_EXPORT ExtensionModule *ExtensionModuleList;
/* Prototypes for Loader functions that are exported to modules */
extern _X_EXPORT pointer LoadSubModule(pointer, const char *, const char **,
- const char **, pointer, const XF86ModReqInfo *,
- int *, int *);
+ const char **, pointer,
+ const XF86ModReqInfo *, int *, int *);
extern _X_EXPORT void UnloadSubModule(pointer);
-extern _X_EXPORT void UnloadModule (pointer);
+extern _X_EXPORT void UnloadModule(pointer);
extern _X_EXPORT pointer LoaderSymbol(const char *);
extern _X_EXPORT char **LoaderListDirs(const char **, const char **);
extern _X_EXPORT void LoaderFreeDirList(char **);
extern _X_EXPORT void LoaderErrorMsg(const char *, const char *, int, int);
extern _X_EXPORT void LoadExtension(ExtensionModule *, Bool);
-extern _X_EXPORT void LoaderGetOS(const char **name, int *major, int *minor, int *teeny);
+extern _X_EXPORT void LoaderGetOS(const char **name, int *major, int *minor,
+ int *teeny);
extern _X_EXPORT Bool LoaderShouldIgnoreABI(void);
extern _X_EXPORT int LoaderGetABIVersion(const char *abiclass);
-typedef pointer (*ModuleSetupProc)(pointer, pointer, int *, int *);
-typedef void (*ModuleTearDownProc)(pointer);
+typedef pointer (*ModuleSetupProc) (pointer, pointer, int *, int *);
+typedef void (*ModuleTearDownProc) (pointer);
+
#define MODULESETUPPROTO(func) pointer func(pointer, pointer, int*, int*)
#define MODULETEARDOWNPROTO(func) void func(pointer)
typedef struct {
- XF86ModuleVersionInfo * vers;
- ModuleSetupProc setup;
- ModuleTearDownProc teardown;
+ XF86ModuleVersionInfo *vers;
+ ModuleSetupProc setup;
+ ModuleTearDownProc teardown;
} XF86ModuleData;
-#endif /* _XF86STR_H */
+#endif /* _XF86STR_H */
diff --git a/xorg-server/hw/xfree86/common/xf86Opt.h b/xorg-server/hw/xfree86/common/xf86Opt.h
index b0fdaa6b6..0d808de14 100644
--- a/xorg-server/hw/xfree86/common/xf86Opt.h
+++ b/xorg-server/hw/xfree86/common/xf86Opt.h
@@ -38,13 +38,13 @@ typedef struct {
} OptFrequency;
typedef union {
- unsigned long num;
- char * str;
- double realnum;
- Bool bool;
- OptFrequency freq;
+ unsigned long num;
+ char *str;
+ double realnum;
+ Bool bool;
+ OptFrequency freq;
} ValueUnion;
-
+
typedef enum {
OPTV_NONE = 0,
OPTV_INTEGER,
@@ -63,57 +63,96 @@ typedef enum {
} OptFreqUnits;
typedef struct {
- int token;
- const char* name;
- OptionValueType type;
- ValueUnion value;
- Bool found;
+ int token;
+ const char *name;
+ OptionValueType type;
+ ValueUnion value;
+ Bool found;
} OptionInfoRec, *OptionInfoPtr;
-extern _X_EXPORT int xf86SetIntOption(XF86OptionPtr optlist, const char *name, int deflt);
-extern _X_EXPORT double xf86SetRealOption(XF86OptionPtr optlist, const char *name, double deflt);
-extern _X_EXPORT char *xf86SetStrOption(XF86OptionPtr optlist, const char *name, const char *deflt);
-extern _X_EXPORT int xf86SetBoolOption(XF86OptionPtr list, const char *name, int deflt );
-extern _X_EXPORT double xf86SetPercentOption(XF86OptionPtr list, const char *name, double deflt );
-extern _X_EXPORT int xf86CheckIntOption(XF86OptionPtr optlist, const char *name, int deflt);
-extern _X_EXPORT double xf86CheckRealOption(XF86OptionPtr optlist, const char *name, double deflt);
-extern _X_EXPORT char *xf86CheckStrOption(XF86OptionPtr optlist, const char *name, char *deflt);
-extern _X_EXPORT int xf86CheckBoolOption(XF86OptionPtr list, const char *name, int deflt );
-extern _X_EXPORT double xf86CheckPercentOption(XF86OptionPtr list, const char *name, double deflt );
-extern _X_EXPORT XF86OptionPtr xf86AddNewOption(XF86OptionPtr head, const char *name, const char *val );
-extern _X_EXPORT XF86OptionPtr xf86NewOption(char *name, char *value );
-extern _X_EXPORT XF86OptionPtr xf86NextOption(XF86OptionPtr list );
-extern _X_EXPORT XF86OptionPtr xf86OptionListCreate(const char **options, int count, int used);
-extern _X_EXPORT XF86OptionPtr xf86OptionListMerge(XF86OptionPtr head, XF86OptionPtr tail);
+extern _X_EXPORT int xf86SetIntOption(XF86OptionPtr optlist, const char *name,
+ int deflt);
+extern _X_EXPORT double xf86SetRealOption(XF86OptionPtr optlist,
+ const char *name, double deflt);
+extern _X_EXPORT char *xf86SetStrOption(XF86OptionPtr optlist, const char *name,
+ const char *deflt);
+extern _X_EXPORT int xf86SetBoolOption(XF86OptionPtr list, const char *name,
+ int deflt);
+extern _X_EXPORT double xf86SetPercentOption(XF86OptionPtr list,
+ const char *name, double deflt);
+extern _X_EXPORT int xf86CheckIntOption(XF86OptionPtr optlist, const char *name,
+ int deflt);
+extern _X_EXPORT double xf86CheckRealOption(XF86OptionPtr optlist,
+ const char *name, double deflt);
+extern _X_EXPORT char *xf86CheckStrOption(XF86OptionPtr optlist,
+ const char *name, char *deflt);
+extern _X_EXPORT int xf86CheckBoolOption(XF86OptionPtr list, const char *name,
+ int deflt);
+extern _X_EXPORT double xf86CheckPercentOption(XF86OptionPtr list,
+ const char *name, double deflt);
+extern _X_EXPORT XF86OptionPtr xf86AddNewOption(XF86OptionPtr head,
+ const char *name,
+ const char *val);
+extern _X_EXPORT XF86OptionPtr xf86NewOption(char *name, char *value);
+extern _X_EXPORT XF86OptionPtr xf86NextOption(XF86OptionPtr list);
+extern _X_EXPORT XF86OptionPtr xf86OptionListCreate(const char **options,
+ int count, int used);
+extern _X_EXPORT XF86OptionPtr xf86OptionListMerge(XF86OptionPtr head,
+ XF86OptionPtr tail);
extern _X_EXPORT XF86OptionPtr xf86OptionListDuplicate(XF86OptionPtr list);
extern _X_EXPORT void xf86OptionListFree(XF86OptionPtr opt);
extern _X_EXPORT char *xf86OptionName(XF86OptionPtr opt);
extern _X_EXPORT char *xf86OptionValue(XF86OptionPtr opt);
extern _X_EXPORT void xf86OptionListReport(XF86OptionPtr parm);
-extern _X_EXPORT XF86OptionPtr xf86FindOption(XF86OptionPtr options, const char *name);
-extern _X_EXPORT const char *xf86FindOptionValue(XF86OptionPtr options, const char *name);
+extern _X_EXPORT XF86OptionPtr xf86FindOption(XF86OptionPtr options,
+ const char *name);
+extern _X_EXPORT const char *xf86FindOptionValue(XF86OptionPtr options,
+ const char *name);
extern _X_EXPORT void xf86MarkOptionUsed(XF86OptionPtr option);
-extern _X_EXPORT void xf86MarkOptionUsedByName(XF86OptionPtr options, const char *name);
+extern _X_EXPORT void xf86MarkOptionUsedByName(XF86OptionPtr options,
+ const char *name);
extern _X_EXPORT Bool xf86CheckIfOptionUsed(XF86OptionPtr option);
-extern _X_EXPORT Bool xf86CheckIfOptionUsedByName(XF86OptionPtr options, const char *name);
-extern _X_EXPORT void xf86ShowUnusedOptions(int scrnIndex, XF86OptionPtr options);
-extern _X_EXPORT void xf86ProcessOptions(int scrnIndex, XF86OptionPtr options, OptionInfoPtr optinfo);
-extern _X_EXPORT OptionInfoPtr xf86TokenToOptinfo(const OptionInfoRec *table, int token);
-extern _X_EXPORT const char *xf86TokenToOptName(const OptionInfoRec *table, int token);
-extern _X_EXPORT Bool xf86IsOptionSet(const OptionInfoRec *table, int token);
-extern _X_EXPORT char *xf86GetOptValString(const OptionInfoRec *table, int token);
-extern _X_EXPORT Bool xf86GetOptValInteger(const OptionInfoRec *table, int token, int *value);
-extern _X_EXPORT Bool xf86GetOptValULong(const OptionInfoRec *table, int token, unsigned long *value);
-extern _X_EXPORT Bool xf86GetOptValReal(const OptionInfoRec *table, int token, double *value);
-extern _X_EXPORT Bool xf86GetOptValFreq(const OptionInfoRec *table, int token,
- OptFreqUnits expectedUnits, double *value);
-extern _X_EXPORT Bool xf86GetOptValBool(const OptionInfoRec *table, int token, Bool *value);
-extern _X_EXPORT Bool xf86ReturnOptValBool(const OptionInfoRec *table, int token, Bool def);
+extern _X_EXPORT Bool xf86CheckIfOptionUsedByName(XF86OptionPtr options,
+ const char *name);
+extern _X_EXPORT void xf86ShowUnusedOptions(int scrnIndex,
+ XF86OptionPtr options);
+extern _X_EXPORT void xf86ProcessOptions(int scrnIndex, XF86OptionPtr options,
+ OptionInfoPtr optinfo);
+extern _X_EXPORT OptionInfoPtr xf86TokenToOptinfo(const OptionInfoRec * table,
+ int token);
+extern _X_EXPORT const char *xf86TokenToOptName(const OptionInfoRec * table,
+ int token);
+extern _X_EXPORT Bool xf86IsOptionSet(const OptionInfoRec * table, int token);
+extern _X_EXPORT char *xf86GetOptValString(const OptionInfoRec * table,
+ int token);
+extern _X_EXPORT Bool xf86GetOptValInteger(const OptionInfoRec * table,
+ int token, int *value);
+extern _X_EXPORT Bool xf86GetOptValULong(const OptionInfoRec * table, int token,
+ unsigned long *value);
+extern _X_EXPORT Bool xf86GetOptValReal(const OptionInfoRec * table, int token,
+ double *value);
+extern _X_EXPORT Bool xf86GetOptValFreq(const OptionInfoRec * table, int token,
+ OptFreqUnits expectedUnits,
+ double *value);
+extern _X_EXPORT Bool xf86GetOptValBool(const OptionInfoRec * table, int token,
+ Bool *value);
+extern _X_EXPORT Bool xf86ReturnOptValBool(const OptionInfoRec * table,
+ int token, Bool def);
extern _X_EXPORT int xf86NameCmp(const char *s1, const char *s2);
extern _X_EXPORT char *xf86NormalizeName(const char *s);
-extern _X_EXPORT XF86OptionPtr xf86ReplaceIntOption(XF86OptionPtr optlist, const char *name, const int val);
-extern _X_EXPORT XF86OptionPtr xf86ReplaceRealOption(XF86OptionPtr optlist, const char *name, const double val);
-extern _X_EXPORT XF86OptionPtr xf86ReplaceBoolOption(XF86OptionPtr optlist, const char *name, const Bool val);
-extern _X_EXPORT XF86OptionPtr xf86ReplacePercentOption(XF86OptionPtr optlist, const char *name, const double val);
-extern _X_EXPORT XF86OptionPtr xf86ReplaceStrOption(XF86OptionPtr optlist, const char *name, const char* val);
+extern _X_EXPORT XF86OptionPtr xf86ReplaceIntOption(XF86OptionPtr optlist,
+ const char *name,
+ const int val);
+extern _X_EXPORT XF86OptionPtr xf86ReplaceRealOption(XF86OptionPtr optlist,
+ const char *name,
+ const double val);
+extern _X_EXPORT XF86OptionPtr xf86ReplaceBoolOption(XF86OptionPtr optlist,
+ const char *name,
+ const Bool val);
+extern _X_EXPORT XF86OptionPtr xf86ReplacePercentOption(XF86OptionPtr optlist,
+ const char *name,
+ const double val);
+extern _X_EXPORT XF86OptionPtr xf86ReplaceStrOption(XF86OptionPtr optlist,
+ const char *name,
+ const char *val);
#endif
diff --git a/xorg-server/hw/xfree86/common/xf86Option.c b/xorg-server/hw/xfree86/common/xf86Option.c
index dc0a01899..7cc744029 100644
--- a/xorg-server/hw/xfree86/common/xf86Option.c
+++ b/xorg-server/hw/xfree86/common/xf86Option.c
@@ -46,8 +46,8 @@
#include "xf86Parser.h"
#include "optionstr.h"
-static Bool ParseOptionValue(int scrnIndex, XF86OptionPtr options, OptionInfoPtr p,
- Bool markUsed);
+static Bool ParseOptionValue(int scrnIndex, XF86OptionPtr options,
+ OptionInfoPtr p, Bool markUsed);
/*
* xf86CollectOptions collects the options from each of the config file
@@ -71,51 +71,51 @@ void
xf86CollectOptions(ScrnInfoPtr pScrn, XF86OptionPtr extraOpts)
{
XF86OptionPtr tmp;
- XF86OptionPtr extras = (XF86OptionPtr)extraOpts;
+ XF86OptionPtr extras = (XF86OptionPtr) extraOpts;
GDevPtr device;
-
+
int i;
pScrn->options = NULL;
- for (i=pScrn->numEntities - 1; i >= 0; i--) {
- device = xf86GetDevFromEntity(pScrn->entityList[i],
- pScrn->entityInstanceList[i]);
- if (device && device->options) {
- tmp = xf86optionListDup(device->options);
- if (pScrn->options)
- xf86optionListMerge(pScrn->options,tmp);
- else
- pScrn->options = tmp;
- }
+ for (i = pScrn->numEntities - 1; i >= 0; i--) {
+ device = xf86GetDevFromEntity(pScrn->entityList[i],
+ pScrn->entityInstanceList[i]);
+ if (device && device->options) {
+ tmp = xf86optionListDup(device->options);
+ if (pScrn->options)
+ xf86optionListMerge(pScrn->options, tmp);
+ else
+ pScrn->options = tmp;
+ }
}
if (pScrn->monitor->options) {
- tmp = xf86optionListDup(pScrn->monitor->options);
- if (pScrn->options)
- pScrn->options = xf86optionListMerge(pScrn->options, tmp);
- else
- pScrn->options = tmp;
+ tmp = xf86optionListDup(pScrn->monitor->options);
+ if (pScrn->options)
+ pScrn->options = xf86optionListMerge(pScrn->options, tmp);
+ else
+ pScrn->options = tmp;
}
if (pScrn->confScreen->options) {
- tmp = xf86optionListDup(pScrn->confScreen->options);
- if (pScrn->options)
- pScrn->options = xf86optionListMerge(pScrn->options, tmp);
- else
- pScrn->options = tmp;
+ tmp = xf86optionListDup(pScrn->confScreen->options);
+ if (pScrn->options)
+ pScrn->options = xf86optionListMerge(pScrn->options, tmp);
+ else
+ pScrn->options = tmp;
}
if (pScrn->display->options) {
- tmp = xf86optionListDup(pScrn->display->options);
- if (pScrn->options)
- pScrn->options = xf86optionListMerge(pScrn->options, tmp);
- else
- pScrn->options = tmp;
+ tmp = xf86optionListDup(pScrn->display->options);
+ if (pScrn->options)
+ pScrn->options = xf86optionListMerge(pScrn->options, tmp);
+ else
+ pScrn->options = tmp;
}
if (extras) {
- tmp = xf86optionListDup(extras);
- if (pScrn->options)
- pScrn->options = xf86optionListMerge(pScrn->options, tmp);
- else
- pScrn->options = tmp;
+ tmp = xf86optionListDup(extras);
+ if (pScrn->options)
+ pScrn->options = xf86optionListMerge(pScrn->options, tmp);
+ else
+ pScrn->options = tmp;
}
}
@@ -130,11 +130,12 @@ void
xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts)
{
if (defaultOpts) {
- XF86OptionPtr tmp =xf86optionListCreate(defaultOpts, -1, 0);
- if (pInfo->options)
- pInfo->options = xf86optionListMerge(tmp, pInfo->options);
- else
- pInfo->options = tmp;
+ XF86OptionPtr tmp = xf86optionListCreate(defaultOpts, -1, 0);
+
+ if (pInfo->options)
+ pInfo->options = xf86optionListMerge(tmp, pInfo->options);
+ else
+ pInfo->options = tmp;
}
}
@@ -147,47 +148,46 @@ xf86OptionListDuplicate(XF86OptionPtr options)
{
XF86OptionPtr o = NULL;
- while (options)
- {
- o = xf86AddNewOption(o, xf86OptionName(options), xf86OptionValue(options));
+ while (options) {
+ o = xf86AddNewOption(o, xf86OptionName(options),
+ xf86OptionValue(options));
options = xf86nextOption(options);
}
return o;
}
-
/* Created for new XInput stuff -- essentially extensions to the parser */
static int
-LookupIntOption(XF86OptionPtr optlist, const char *name, int deflt, Bool markUsed)
+LookupIntOption(XF86OptionPtr optlist, const char *name, int deflt,
+ Bool markUsed)
{
OptionInfoRec o;
o.name = name;
o.type = OPTV_INTEGER;
if (ParseOptionValue(-1, optlist, &o, markUsed))
- deflt = o.value.num;
+ deflt = o.value.num;
return deflt;
}
-
static double
LookupRealOption(XF86OptionPtr optlist, const char *name, double deflt,
- Bool markUsed)
+ Bool markUsed)
{
OptionInfoRec o;
o.name = name;
o.type = OPTV_REAL;
if (ParseOptionValue(-1, optlist, &o, markUsed))
- deflt = o.value.realnum;
+ deflt = o.value.realnum;
return deflt;
}
-
static char *
-LookupStrOption(XF86OptionPtr optlist, const char *name, const char *deflt, Bool markUsed)
+LookupStrOption(XF86OptionPtr optlist, const char *name, const char *deflt,
+ Bool markUsed)
{
OptionInfoRec o;
@@ -196,33 +196,34 @@ LookupStrOption(XF86OptionPtr optlist, const char *name, const char *deflt, Bool
if (ParseOptionValue(-1, optlist, &o, markUsed))
deflt = o.value.str;
if (deflt)
- return strdup(deflt);
+ return strdup(deflt);
else
- return NULL;
+ return NULL;
}
-
static int
-LookupBoolOption(XF86OptionPtr optlist, const char *name, int deflt, Bool markUsed)
+LookupBoolOption(XF86OptionPtr optlist, const char *name, int deflt,
+ Bool markUsed)
{
OptionInfoRec o;
o.name = name;
o.type = OPTV_BOOLEAN;
if (ParseOptionValue(-1, optlist, &o, markUsed))
- deflt = o.value.bool;
+ deflt = o.value.bool;
return deflt;
}
static double
-LookupPercentOption(XF86OptionPtr optlist, const char *name, double deflt, Bool markUsed)
+LookupPercentOption(XF86OptionPtr optlist, const char *name, double deflt,
+ Bool markUsed)
{
OptionInfoRec o;
o.name = name;
o.type = OPTV_PERCENT;
if (ParseOptionValue(-1, optlist, &o, markUsed))
- deflt = o.value.realnum;
+ deflt = o.value.realnum;
return deflt;
}
@@ -234,21 +235,18 @@ xf86SetIntOption(XF86OptionPtr optlist, const char *name, int deflt)
return LookupIntOption(optlist, name, deflt, TRUE);
}
-
double
xf86SetRealOption(XF86OptionPtr optlist, const char *name, double deflt)
{
return LookupRealOption(optlist, name, deflt, TRUE);
}
-
char *
xf86SetStrOption(XF86OptionPtr optlist, const char *name, const char *deflt)
{
return LookupStrOption(optlist, name, deflt, TRUE);
}
-
int
xf86SetBoolOption(XF86OptionPtr optlist, const char *name, int deflt)
{
@@ -271,33 +269,30 @@ xf86CheckIntOption(XF86OptionPtr optlist, const char *name, int deflt)
return LookupIntOption(optlist, name, deflt, FALSE);
}
-
double
xf86CheckRealOption(XF86OptionPtr optlist, const char *name, double deflt)
{
return LookupRealOption(optlist, name, deflt, FALSE);
}
-
char *
xf86CheckStrOption(XF86OptionPtr optlist, const char *name, char *deflt)
{
return LookupStrOption(optlist, name, deflt, FALSE);
}
-
int
xf86CheckBoolOption(XF86OptionPtr optlist, const char *name, int deflt)
{
return LookupBoolOption(optlist, name, deflt, FALSE);
}
-
double
xf86CheckPercentOption(XF86OptionPtr optlist, const char *name, double deflt)
{
return LookupPercentOption(optlist, name, deflt, FALSE);
}
+
/*
* xf86AddNewOption() has the required property of replacing the option value
* if the option is already present.
@@ -306,36 +301,40 @@ XF86OptionPtr
xf86ReplaceIntOption(XF86OptionPtr optlist, const char *name, const int val)
{
char tmp[16];
- snprintf(tmp,sizeof(tmp),"%i",val);
- return xf86AddNewOption(optlist,name,tmp);
+
+ snprintf(tmp, sizeof(tmp), "%i", val);
+ return xf86AddNewOption(optlist, name, tmp);
}
XF86OptionPtr
xf86ReplaceRealOption(XF86OptionPtr optlist, const char *name, const double val)
{
char tmp[32];
- snprintf(tmp,sizeof(tmp),"%f",val);
- return xf86AddNewOption(optlist,name,tmp);
+
+ snprintf(tmp, sizeof(tmp), "%f", val);
+ return xf86AddNewOption(optlist, name, tmp);
}
XF86OptionPtr
xf86ReplaceBoolOption(XF86OptionPtr optlist, const char *name, const Bool val)
{
- return xf86AddNewOption(optlist,name,val?"True":"False");
+ return xf86AddNewOption(optlist, name, val ? "True" : "False");
}
XF86OptionPtr
-xf86ReplacePercentOption(XF86OptionPtr optlist, const char *name, const double val)
+xf86ReplacePercentOption(XF86OptionPtr optlist, const char *name,
+ const double val)
{
char tmp[16];
+
snprintf(tmp, sizeof(tmp), "%lf%%", val);
- return xf86AddNewOption(optlist,name,tmp);
+ return xf86AddNewOption(optlist, name, tmp);
}
XF86OptionPtr
-xf86ReplaceStrOption(XF86OptionPtr optlist, const char *name, const char* val)
+xf86ReplaceStrOption(XF86OptionPtr optlist, const char *name, const char *val)
{
- return xf86AddNewOption(optlist,name,val);
+ return xf86AddNewOption(optlist, name, val);
}
XF86OptionPtr
@@ -348,14 +347,12 @@ xf86AddNewOption(XF86OptionPtr head, const char *name, const char *val)
return xf86addNewOption(head, tmp_name, tmp);
}
-
XF86OptionPtr
xf86NewOption(char *name, char *value)
{
return xf86newOption(name, value);
}
-
XF86OptionPtr
xf86NextOption(XF86OptionPtr list)
{
@@ -365,31 +362,31 @@ xf86NextOption(XF86OptionPtr list)
XF86OptionPtr
xf86OptionListCreate(const char **options, int count, int used)
{
- return xf86optionListCreate(options, count, used);
+ return xf86optionListCreate(options, count, used);
}
XF86OptionPtr
xf86OptionListMerge(XF86OptionPtr head, XF86OptionPtr tail)
{
- return xf86optionListMerge(head, tail);
+ return xf86optionListMerge(head, tail);
}
void
xf86OptionListFree(XF86OptionPtr opt)
{
- xf86optionListFree(opt);
+ xf86optionListFree(opt);
}
char *
xf86OptionName(XF86OptionPtr opt)
{
- return xf86optionName(opt);
+ return xf86optionName(opt);
}
char *
xf86OptionValue(XF86OptionPtr opt)
{
- return xf86optionValue(opt);
+ return xf86optionValue(opt);
}
void
@@ -397,13 +394,13 @@ xf86OptionListReport(XF86OptionPtr parm)
{
XF86OptionPtr opts = parm;
- while(opts) {
- if (xf86optionValue(opts))
- xf86ErrorFVerb(5, "\tOption \"%s\" \"%s\"\n",
- xf86optionName(opts), xf86optionValue(opts));
- else
- xf86ErrorFVerb( 5, "\tOption \"%s\"\n", xf86optionName(opts));
- opts = xf86nextOption(opts);
+ while (opts) {
+ if (xf86optionValue(opts))
+ xf86ErrorFVerb(5, "\tOption \"%s\" \"%s\"\n",
+ xf86optionName(opts), xf86optionValue(opts));
+ else
+ xf86ErrorFVerb(5, "\tOption \"%s\"\n", xf86optionName(opts));
+ opts = xf86nextOption(opts);
}
}
@@ -415,22 +412,19 @@ xf86FindOption(XF86OptionPtr options, const char *name)
return xf86findOption(options, name);
}
-
const char *
xf86FindOptionValue(XF86OptionPtr options, const char *name)
{
return xf86findOptionValue(options, name);
}
-
void
xf86MarkOptionUsed(XF86OptionPtr option)
{
if (option != NULL)
- option->opt_used = TRUE;
+ option->opt_used = TRUE;
}
-
void
xf86MarkOptionUsedByName(XF86OptionPtr options, const char *name)
{
@@ -438,16 +432,16 @@ xf86MarkOptionUsedByName(XF86OptionPtr options, const char *name)
opt = xf86findOption(options, name);
if (opt != NULL)
- opt->opt_used = TRUE;
+ opt->opt_used = TRUE;
}
Bool
xf86CheckIfOptionUsed(XF86OptionPtr option)
{
if (option != NULL)
- return option->opt_used;
+ return option->opt_used;
else
- return FALSE;
+ return FALSE;
}
Bool
@@ -457,24 +451,23 @@ xf86CheckIfOptionUsedByName(XF86OptionPtr options, const char *name)
opt = xf86findOption(options, name);
if (opt != NULL)
- return opt->opt_used;
+ return opt->opt_used;
else
- return FALSE;
+ return FALSE;
}
void
xf86ShowUnusedOptions(int scrnIndex, XF86OptionPtr opt)
{
while (opt) {
- if (opt->opt_name && !opt->opt_used) {
- xf86DrvMsg(scrnIndex, X_WARNING, "Option \"%s\" is not used\n",
- opt->opt_name);
- }
- opt = opt->list.next;
+ if (opt->opt_name && !opt->opt_used) {
+ xf86DrvMsg(scrnIndex, X_WARNING, "Option \"%s\" is not used\n",
+ opt->opt_name);
+ }
+ opt = opt->list.next;
}
}
-
static Bool
GetBoolValue(OptionInfoPtr p, const char *s)
{
@@ -483,257 +476,269 @@ GetBoolValue(OptionInfoPtr p, const char *s)
static Bool
ParseOptionValue(int scrnIndex, XF86OptionPtr options, OptionInfoPtr p,
- Bool markUsed)
+ Bool markUsed)
{
char *s, *end;
Bool wasUsed = FALSE;
if ((s = xf86findOptionValue(options, p->name)) != NULL) {
- if (markUsed) {
- wasUsed = xf86CheckIfOptionUsedByName(options, p->name);
- xf86MarkOptionUsedByName(options, p->name);
- }
- switch (p->type) {
- case OPTV_INTEGER:
- if (*s == '\0') {
- if (markUsed) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires an integer value\n",
- p->name);
- }
- p->found = FALSE;
- } else {
- p->value.num = strtoul(s, &end, 0);
- if (*end == '\0') {
- p->found = TRUE;
- } else {
- if (markUsed) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires an integer value\n",
- p->name);
- }
- p->found = FALSE;
- }
- }
- break;
- case OPTV_STRING:
- if (*s == '\0') {
- if (markUsed) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires an string value\n",
- p->name);
- }
- p->found = FALSE;
- } else {
- p->value.str = s;
- p->found = TRUE;
- }
- break;
- case OPTV_ANYSTR:
- p->value.str = s;
- p->found = TRUE;
- break;
- case OPTV_REAL:
- if (*s == '\0') {
- if (markUsed) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires a floating point "
- "value\n", p->name);
- }
- p->found = FALSE;
- } else {
- p->value.realnum = strtod(s, &end);
- if (*end == '\0') {
- p->found = TRUE;
- } else {
- if (markUsed) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires a floating point "
- "value\n", p->name);
- }
- p->found = FALSE;
- }
- }
- break;
- case OPTV_BOOLEAN:
- if (GetBoolValue(p, s)) {
- p->found = TRUE;
- } else {
- if (markUsed) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires a boolean value\n",
- p->name);
- }
- p->found = FALSE;
- }
- break;
- case OPTV_PERCENT:
- {
- char tmp = 0;
- /* awkward match, but %% doesn't increase the match counter,
- * hence 100 looks the same as 100% to the caller of sccanf
- */
- if (sscanf(s, "%lf%c", &p->value.realnum, &tmp) != 2 || tmp != '%') {
- if (markUsed) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires a percent value\n", p->name);
- }
- p->found = FALSE;
- } else {
- p->found = TRUE;
- }
- }
- break;
- case OPTV_FREQ:
- if (*s == '\0') {
- if (markUsed) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires a frequency value\n",
- p->name);
- }
- p->found = FALSE;
- } else {
- double freq = strtod(s, &end);
- int units = 0;
-
- if (end != s) {
- p->found = TRUE;
- if (!xf86NameCmp(end, "Hz"))
- units = 1;
- else if (!xf86NameCmp(end, "kHz") ||
- !xf86NameCmp(end, "k"))
- units = 1000;
- else if (!xf86NameCmp(end, "MHz") ||
- !xf86NameCmp(end, "M"))
- units = 1000000;
- else {
- if (markUsed) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires a frequency value\n",
- p->name);
- }
- p->found = FALSE;
- }
- if (p->found)
- freq *= (double)units;
- } else {
- if (markUsed) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires a frequency value\n",
- p->name);
- }
- p->found = FALSE;
- }
- if (p->found) {
- p->value.freq.freq = freq;
- p->value.freq.units = units;
- }
- }
- break;
- case OPTV_NONE:
- /* Should never get here */
- p->found = FALSE;
- break;
- }
- if (p->found && markUsed) {
- int verb = 2;
- if (wasUsed)
- verb = 4;
- xf86DrvMsgVerb(scrnIndex, X_CONFIG, verb, "Option \"%s\"", p->name);
- if (!(p->type == OPTV_BOOLEAN && *s == 0)) {
- xf86ErrorFVerb(verb, " \"%s\"", s);
- }
- xf86ErrorFVerb(verb, "\n");
- }
- } else if (p->type == OPTV_BOOLEAN) {
- /* Look for matches with options with or without a "No" prefix. */
- char *n, *newn;
- OptionInfoRec opt;
-
- n = xf86NormalizeName(p->name);
- if (!n) {
- p->found = FALSE;
- return FALSE;
- }
- if (strncmp(n, "no", 2) == 0) {
- newn = n + 2;
- } else {
- free(n);
- if (asprintf(&n, "No%s", p->name) == -1) {
- p->found = FALSE;
- return FALSE;
- }
- newn = n;
- }
- if ((s = xf86findOptionValue(options, newn)) != NULL) {
- if (markUsed)
- xf86MarkOptionUsedByName(options, newn);
- if (GetBoolValue(&opt, s)) {
- p->value.bool = !opt.value.bool;
- p->found = TRUE;
- } else {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires a boolean value\n", newn);
- p->found = FALSE;
- }
- } else {
- p->found = FALSE;
- }
- if (p->found && markUsed) {
- xf86DrvMsgVerb(scrnIndex, X_CONFIG, 2, "Option \"%s\"", newn);
- if (*s != 0) {
- xf86ErrorFVerb(2, " \"%s\"", s);
- }
- xf86ErrorFVerb(2, "\n");
- }
- free(n);
- } else {
- p->found = FALSE;
+ if (markUsed) {
+ wasUsed = xf86CheckIfOptionUsedByName(options, p->name);
+ xf86MarkOptionUsedByName(options, p->name);
+ }
+ switch (p->type) {
+ case OPTV_INTEGER:
+ if (*s == '\0') {
+ if (markUsed) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires an integer value\n",
+ p->name);
+ }
+ p->found = FALSE;
+ }
+ else {
+ p->value.num = strtoul(s, &end, 0);
+ if (*end == '\0') {
+ p->found = TRUE;
+ }
+ else {
+ if (markUsed) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires an integer value\n",
+ p->name);
+ }
+ p->found = FALSE;
+ }
+ }
+ break;
+ case OPTV_STRING:
+ if (*s == '\0') {
+ if (markUsed) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires an string value\n",
+ p->name);
+ }
+ p->found = FALSE;
+ }
+ else {
+ p->value.str = s;
+ p->found = TRUE;
+ }
+ break;
+ case OPTV_ANYSTR:
+ p->value.str = s;
+ p->found = TRUE;
+ break;
+ case OPTV_REAL:
+ if (*s == '\0') {
+ if (markUsed) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a floating point "
+ "value\n", p->name);
+ }
+ p->found = FALSE;
+ }
+ else {
+ p->value.realnum = strtod(s, &end);
+ if (*end == '\0') {
+ p->found = TRUE;
+ }
+ else {
+ if (markUsed) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a floating point "
+ "value\n", p->name);
+ }
+ p->found = FALSE;
+ }
+ }
+ break;
+ case OPTV_BOOLEAN:
+ if (GetBoolValue(p, s)) {
+ p->found = TRUE;
+ }
+ else {
+ if (markUsed) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a boolean value\n",
+ p->name);
+ }
+ p->found = FALSE;
+ }
+ break;
+ case OPTV_PERCENT:
+ {
+ char tmp = 0;
+
+ /* awkward match, but %% doesn't increase the match counter,
+ * hence 100 looks the same as 100% to the caller of sccanf
+ */
+ if (sscanf(s, "%lf%c", &p->value.realnum, &tmp) != 2 || tmp != '%') {
+ if (markUsed) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a percent value\n",
+ p->name);
+ }
+ p->found = FALSE;
+ }
+ else {
+ p->found = TRUE;
+ }
+ }
+ break;
+ case OPTV_FREQ:
+ if (*s == '\0') {
+ if (markUsed) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a frequency value\n",
+ p->name);
+ }
+ p->found = FALSE;
+ }
+ else {
+ double freq = strtod(s, &end);
+ int units = 0;
+
+ if (end != s) {
+ p->found = TRUE;
+ if (!xf86NameCmp(end, "Hz"))
+ units = 1;
+ else if (!xf86NameCmp(end, "kHz") || !xf86NameCmp(end, "k"))
+ units = 1000;
+ else if (!xf86NameCmp(end, "MHz") || !xf86NameCmp(end, "M"))
+ units = 1000000;
+ else {
+ if (markUsed) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a frequency value\n",
+ p->name);
+ }
+ p->found = FALSE;
+ }
+ if (p->found)
+ freq *= (double) units;
+ }
+ else {
+ if (markUsed) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a frequency value\n",
+ p->name);
+ }
+ p->found = FALSE;
+ }
+ if (p->found) {
+ p->value.freq.freq = freq;
+ p->value.freq.units = units;
+ }
+ }
+ break;
+ case OPTV_NONE:
+ /* Should never get here */
+ p->found = FALSE;
+ break;
+ }
+ if (p->found && markUsed) {
+ int verb = 2;
+
+ if (wasUsed)
+ verb = 4;
+ xf86DrvMsgVerb(scrnIndex, X_CONFIG, verb, "Option \"%s\"", p->name);
+ if (!(p->type == OPTV_BOOLEAN && *s == 0)) {
+ xf86ErrorFVerb(verb, " \"%s\"", s);
+ }
+ xf86ErrorFVerb(verb, "\n");
+ }
+ }
+ else if (p->type == OPTV_BOOLEAN) {
+ /* Look for matches with options with or without a "No" prefix. */
+ char *n, *newn;
+ OptionInfoRec opt;
+
+ n = xf86NormalizeName(p->name);
+ if (!n) {
+ p->found = FALSE;
+ return FALSE;
+ }
+ if (strncmp(n, "no", 2) == 0) {
+ newn = n + 2;
+ }
+ else {
+ free(n);
+ if (asprintf(&n, "No%s", p->name) == -1) {
+ p->found = FALSE;
+ return FALSE;
+ }
+ newn = n;
+ }
+ if ((s = xf86findOptionValue(options, newn)) != NULL) {
+ if (markUsed)
+ xf86MarkOptionUsedByName(options, newn);
+ if (GetBoolValue(&opt, s)) {
+ p->value.bool = !opt.value.bool;
+ p->found = TRUE;
+ }
+ else {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a boolean value\n", newn);
+ p->found = FALSE;
+ }
+ }
+ else {
+ p->found = FALSE;
+ }
+ if (p->found && markUsed) {
+ xf86DrvMsgVerb(scrnIndex, X_CONFIG, 2, "Option \"%s\"", newn);
+ if (*s != 0) {
+ xf86ErrorFVerb(2, " \"%s\"", s);
+ }
+ xf86ErrorFVerb(2, "\n");
+ }
+ free(n);
+ }
+ else {
+ p->found = FALSE;
}
return p->found;
}
-
void
xf86ProcessOptions(int scrnIndex, XF86OptionPtr options, OptionInfoPtr optinfo)
{
OptionInfoPtr p;
for (p = optinfo; p->name != NULL; p++) {
- ParseOptionValue(scrnIndex, options, p, TRUE);
+ ParseOptionValue(scrnIndex, options, p, TRUE);
}
}
-
OptionInfoPtr
-xf86TokenToOptinfo(const OptionInfoRec *table, int token)
+xf86TokenToOptinfo(const OptionInfoRec * table, int token)
{
const OptionInfoRec *p, *match = NULL, *set = NULL;
if (!table) {
- ErrorF("xf86TokenToOptinfo: table is NULL\n");
- return NULL;
+ ErrorF("xf86TokenToOptinfo: table is NULL\n");
+ return NULL;
}
for (p = table; p->token >= 0; p++) {
- if (p->token == token) {
- match = p;
- if (p->found)
- set = p;
- }
+ if (p->token == token) {
+ match = p;
+ if (p->found)
+ set = p;
+ }
}
if (set)
- return (OptionInfoPtr)set;
+ return (OptionInfoPtr) set;
else if (match)
- return (OptionInfoPtr)match;
+ return (OptionInfoPtr) match;
else
- return NULL;
+ return NULL;
}
-
const char *
-xf86TokenToOptName(const OptionInfoRec *table, int token)
+xf86TokenToOptName(const OptionInfoRec * table, int token)
{
const OptionInfoRec *p;
@@ -741,9 +746,8 @@ xf86TokenToOptName(const OptionInfoRec *table, int token)
return p->name;
}
-
Bool
-xf86IsOptionSet(const OptionInfoRec *table, int token)
+xf86IsOptionSet(const OptionInfoRec * table, int token)
{
OptionInfoPtr p;
@@ -751,137 +755,136 @@ xf86IsOptionSet(const OptionInfoRec *table, int token)
return p && p->found;
}
-
char *
-xf86GetOptValString(const OptionInfoRec *table, int token)
+xf86GetOptValString(const OptionInfoRec * table, int token)
{
OptionInfoPtr p;
p = xf86TokenToOptinfo(table, token);
if (p && p->found)
- return p->value.str;
+ return p->value.str;
else
- return NULL;
+ return NULL;
}
-
Bool
-xf86GetOptValInteger(const OptionInfoRec *table, int token, int *value)
+xf86GetOptValInteger(const OptionInfoRec * table, int token, int *value)
{
OptionInfoPtr p;
p = xf86TokenToOptinfo(table, token);
if (p && p->found) {
- *value = p->value.num;
- return TRUE;
- } else
- return FALSE;
+ *value = p->value.num;
+ return TRUE;
+ }
+ else
+ return FALSE;
}
-
Bool
-xf86GetOptValULong(const OptionInfoRec *table, int token, unsigned long *value)
+xf86GetOptValULong(const OptionInfoRec * table, int token, unsigned long *value)
{
OptionInfoPtr p;
p = xf86TokenToOptinfo(table, token);
if (p && p->found) {
- *value = p->value.num;
- return TRUE;
- } else
- return FALSE;
+ *value = p->value.num;
+ return TRUE;
+ }
+ else
+ return FALSE;
}
-
Bool
-xf86GetOptValReal(const OptionInfoRec *table, int token, double *value)
+xf86GetOptValReal(const OptionInfoRec * table, int token, double *value)
{
OptionInfoPtr p;
p = xf86TokenToOptinfo(table, token);
if (p && p->found) {
- *value = p->value.realnum;
- return TRUE;
- } else
- return FALSE;
+ *value = p->value.realnum;
+ return TRUE;
+ }
+ else
+ return FALSE;
}
-
Bool
-xf86GetOptValFreq(const OptionInfoRec *table, int token,
- OptFreqUnits expectedUnits, double *value)
+xf86GetOptValFreq(const OptionInfoRec * table, int token,
+ OptFreqUnits expectedUnits, double *value)
{
OptionInfoPtr p;
p = xf86TokenToOptinfo(table, token);
if (p && p->found) {
- if (p->value.freq.units > 0) {
- /* Units give, so the scaling is known. */
- switch (expectedUnits) {
- case OPTUNITS_HZ:
- *value = p->value.freq.freq;
- break;
- case OPTUNITS_KHZ:
- *value = p->value.freq.freq / 1000.0;
- break;
- case OPTUNITS_MHZ:
- *value = p->value.freq.freq / 1000000.0;
- break;
- }
- } else {
- /* No units given, so try to guess the scaling. */
- switch (expectedUnits) {
- case OPTUNITS_HZ:
- *value = p->value.freq.freq;
- break;
- case OPTUNITS_KHZ:
- if (p->value.freq.freq > 1000.0)
- *value = p->value.freq.freq / 1000.0;
- else
- *value = p->value.freq.freq;
- break;
- case OPTUNITS_MHZ:
- if (p->value.freq.freq > 1000000.0)
- *value = p->value.freq.freq / 1000000.0;
- else if (p->value.freq.freq > 1000.0)
- *value = p->value.freq.freq / 1000.0;
- else
- *value = p->value.freq.freq;
- }
- }
- return TRUE;
- } else
- return FALSE;
+ if (p->value.freq.units > 0) {
+ /* Units give, so the scaling is known. */
+ switch (expectedUnits) {
+ case OPTUNITS_HZ:
+ *value = p->value.freq.freq;
+ break;
+ case OPTUNITS_KHZ:
+ *value = p->value.freq.freq / 1000.0;
+ break;
+ case OPTUNITS_MHZ:
+ *value = p->value.freq.freq / 1000000.0;
+ break;
+ }
+ }
+ else {
+ /* No units given, so try to guess the scaling. */
+ switch (expectedUnits) {
+ case OPTUNITS_HZ:
+ *value = p->value.freq.freq;
+ break;
+ case OPTUNITS_KHZ:
+ if (p->value.freq.freq > 1000.0)
+ *value = p->value.freq.freq / 1000.0;
+ else
+ *value = p->value.freq.freq;
+ break;
+ case OPTUNITS_MHZ:
+ if (p->value.freq.freq > 1000000.0)
+ *value = p->value.freq.freq / 1000000.0;
+ else if (p->value.freq.freq > 1000.0)
+ *value = p->value.freq.freq / 1000.0;
+ else
+ *value = p->value.freq.freq;
+ }
+ }
+ return TRUE;
+ }
+ else
+ return FALSE;
}
-
Bool
-xf86GetOptValBool(const OptionInfoRec *table, int token, Bool *value)
+xf86GetOptValBool(const OptionInfoRec * table, int token, Bool *value)
{
OptionInfoPtr p;
p = xf86TokenToOptinfo(table, token);
if (p && p->found) {
- *value = p->value.bool;
- return TRUE;
- } else
- return FALSE;
+ *value = p->value.bool;
+ return TRUE;
+ }
+ else
+ return FALSE;
}
-
Bool
-xf86ReturnOptValBool(const OptionInfoRec *table, int token, Bool def)
+xf86ReturnOptValBool(const OptionInfoRec * table, int token, Bool def)
{
OptionInfoPtr p;
p = xf86TokenToOptinfo(table, token);
if (p && p->found) {
- return p->value.bool;
- } else
- return def;
+ return p->value.bool;
+ }
+ else
+ return def;
}
-
int
xf86NameCmp(const char *s1, const char *s2)
{
@@ -895,21 +898,21 @@ xf86NormalizeName(const char *s)
const char *p;
if (s == NULL)
- return NULL;
+ return NULL;
ret = malloc(strlen(s) + 1);
for (p = s, q = ret; *p != 0; p++) {
- switch (*p) {
- case '_':
- case ' ':
- case '\t':
- continue;
- default:
- if (isupper(*p))
- *q++ = tolower(*p);
- else
- *q++ = *p;
- }
+ switch (*p) {
+ case '_':
+ case ' ':
+ case '\t':
+ continue;
+ default:
+ if (isupper(*p))
+ *q++ = tolower(*p);
+ else
+ *q++ = *p;
+ }
}
*q = '\0';
return ret;
diff --git a/xorg-server/hw/xfree86/common/xf86Optionstr.h b/xorg-server/hw/xfree86/common/xf86Optionstr.h
index fc9385617..c38499cb5 100644
--- a/xorg-server/hw/xfree86/common/xf86Optionstr.h
+++ b/xorg-server/hw/xfree86/common/xf86Optionstr.h
@@ -29,15 +29,13 @@
/*
* All options are stored using this data type.
*/
-typedef struct _XF86OptionRec
-{
- GenericListRec list;
- char *opt_name;
- char *opt_val;
- int opt_used;
- char *opt_comment;
-}
-XF86OptionRec;
+typedef struct _XF86OptionRec {
+ GenericListRec list;
+ char *opt_name;
+ char *opt_val;
+ int opt_used;
+ char *opt_comment;
+} XF86OptionRec;
typedef struct _InputOption *XF86OptionPtr;
diff --git a/xorg-server/hw/xfree86/common/xf86PM.c b/xorg-server/hw/xfree86/common/xf86PM.c
index 47e0297d6..f69fffa0e 100644
--- a/xorg-server/hw/xfree86/common/xf86PM.c
+++ b/xorg-server/hw/xfree86/common/xf86PM.c
@@ -35,60 +35,90 @@
#include "xf86Xinput.h"
#include "xf86_OSproc.h"
-int (*xf86PMGetEventFromOs)(int fd,pmEvent *events,int num) = NULL;
-pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event) = NULL;
+int (*xf86PMGetEventFromOs) (int fd, pmEvent * events, int num) = NULL;
+pmWait (*xf86PMConfirmEventToOs) (int fd, pmEvent event) = NULL;
static Bool suspended = FALSE;
static int
eventName(pmEvent event, const char **str)
{
- switch(event) {
- case XF86_APM_SYS_STANDBY: *str="System Standby Request"; return 0;
- case XF86_APM_SYS_SUSPEND: *str="System Suspend Request"; return 0;
- case XF86_APM_CRITICAL_SUSPEND: *str="Critical Suspend"; return 0;
- case XF86_APM_USER_STANDBY: *str="User System Standby Request"; return 0;
- case XF86_APM_USER_SUSPEND: *str="User System Suspend Request"; return 0;
- case XF86_APM_STANDBY_RESUME: *str="System Standby Resume"; return 0;
- case XF86_APM_NORMAL_RESUME: *str="Normal Resume System"; return 0;
- case XF86_APM_CRITICAL_RESUME: *str="Critical Resume System"; return 0;
- case XF86_APM_LOW_BATTERY: *str="Battery Low"; return 3;
- case XF86_APM_POWER_STATUS_CHANGE: *str="Power Status Change";return 3;
- case XF86_APM_UPDATE_TIME: *str="Update Time";return 3;
- case XF86_APM_CAPABILITY_CHANGED: *str="Capability Changed"; return 3;
- case XF86_APM_STANDBY_FAILED: *str="Standby Request Failed"; return 0;
- case XF86_APM_SUSPEND_FAILED: *str="Suspend Request Failed"; return 0;
- default: *str="Unknown Event"; return 0;
+ switch (event) {
+ case XF86_APM_SYS_STANDBY:
+ *str = "System Standby Request";
+ return 0;
+ case XF86_APM_SYS_SUSPEND:
+ *str = "System Suspend Request";
+ return 0;
+ case XF86_APM_CRITICAL_SUSPEND:
+ *str = "Critical Suspend";
+ return 0;
+ case XF86_APM_USER_STANDBY:
+ *str = "User System Standby Request";
+ return 0;
+ case XF86_APM_USER_SUSPEND:
+ *str = "User System Suspend Request";
+ return 0;
+ case XF86_APM_STANDBY_RESUME:
+ *str = "System Standby Resume";
+ return 0;
+ case XF86_APM_NORMAL_RESUME:
+ *str = "Normal Resume System";
+ return 0;
+ case XF86_APM_CRITICAL_RESUME:
+ *str = "Critical Resume System";
+ return 0;
+ case XF86_APM_LOW_BATTERY:
+ *str = "Battery Low";
+ return 3;
+ case XF86_APM_POWER_STATUS_CHANGE:
+ *str = "Power Status Change";
+ return 3;
+ case XF86_APM_UPDATE_TIME:
+ *str = "Update Time";
+ return 3;
+ case XF86_APM_CAPABILITY_CHANGED:
+ *str = "Capability Changed";
+ return 3;
+ case XF86_APM_STANDBY_FAILED:
+ *str = "Standby Request Failed";
+ return 0;
+ case XF86_APM_SUSPEND_FAILED:
+ *str = "Suspend Request Failed";
+ return 0;
+ default:
+ *str = "Unknown Event";
+ return 0;
}
}
static int sigio_blocked_for_suspend;
static void
-suspend (pmEvent event, Bool undo)
+suspend(pmEvent event, Bool undo)
{
int i;
InputInfoPtr pInfo;
for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->EnableDisableFBAccess)
- (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE);
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE);
}
pInfo = xf86InputDevs;
while (pInfo) {
- DisableDevice(pInfo->dev, TRUE);
- pInfo = pInfo->next;
+ DisableDevice(pInfo->dev, TRUE);
+ pInfo = pInfo->next;
}
sigio_blocked_for_suspend = xf86BlockSIGIO();
for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->PMEvent)
- xf86Screens[i]->PMEvent(i,event,undo);
- else {
- xf86Screens[i]->LeaveVT(i, 0);
- xf86Screens[i]->vtSema = FALSE;
- }
+ if (xf86Screens[i]->PMEvent)
+ xf86Screens[i]->PMEvent(i, event, undo);
+ else {
+ xf86Screens[i]->LeaveVT(i, 0);
+ xf86Screens[i]->vtSema = FALSE;
+ }
}
- xf86AccessLeave();
+ xf86AccessLeave();
}
@@ -100,23 +130,23 @@ resume(pmEvent event, Bool undo)
xf86AccessEnter();
for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->PMEvent)
- xf86Screens[i]->PMEvent(i,event,undo);
- else {
- xf86Screens[i]->vtSema = TRUE;
- xf86Screens[i]->EnterVT(i, 0);
- }
+ if (xf86Screens[i]->PMEvent)
+ xf86Screens[i]->PMEvent(i, event, undo);
+ else {
+ xf86Screens[i]->vtSema = TRUE;
+ xf86Screens[i]->EnterVT(i, 0);
+ }
}
xf86UnblockSIGIO(sigio_blocked_for_suspend);
for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->EnableDisableFBAccess)
- (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
}
dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
pInfo = xf86InputDevs;
while (pInfo) {
- EnableDevice(pInfo->dev, TRUE);
- pInfo = pInfo->next;
+ EnableDevice(pInfo->dev, TRUE);
+ pInfo = pInfo->next;
}
}
@@ -124,43 +154,44 @@ static void
DoApmEvent(pmEvent event, Bool undo)
{
int i, was_blocked;
-
- switch(event) {
+
+ switch (event) {
#if 0
case XF86_APM_SYS_STANDBY:
case XF86_APM_USER_STANDBY:
#endif
case XF86_APM_SYS_SUSPEND:
- case XF86_APM_CRITICAL_SUSPEND: /*do we want to delay a critical suspend?*/
+ case XF86_APM_CRITICAL_SUSPEND: /*do we want to delay a critical suspend? */
case XF86_APM_USER_SUSPEND:
- /* should we do this ? */
- if (!undo && !suspended) {
- suspend(event,undo);
- suspended = TRUE;
- } else if (undo && suspended) {
- resume(event,undo);
- suspended = FALSE;
- }
- break;
+ /* should we do this ? */
+ if (!undo && !suspended) {
+ suspend(event, undo);
+ suspended = TRUE;
+ }
+ else if (undo && suspended) {
+ resume(event, undo);
+ suspended = FALSE;
+ }
+ break;
#if 0
case XF86_APM_STANDBY_RESUME:
#endif
case XF86_APM_NORMAL_RESUME:
case XF86_APM_CRITICAL_RESUME:
- if (suspended) {
- resume(event,undo);
- suspended = FALSE;
- }
- break;
+ if (suspended) {
+ resume(event, undo);
+ suspended = FALSE;
+ }
+ break;
default:
- was_blocked = xf86BlockSIGIO();
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->PMEvent) {
- xf86Screens[i]->PMEvent(i,event,undo);
- }
- }
- xf86UnblockSIGIO(was_blocked);
- break;
+ was_blocked = xf86BlockSIGIO();
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->PMEvent) {
+ xf86Screens[i]->PMEvent(i, event, undo);
+ }
+ }
+ xf86UnblockSIGIO(was_blocked);
+ break;
}
}
@@ -170,39 +201,39 @@ void
xf86HandlePMEvents(int fd, pointer data)
{
pmEvent events[MAX_NO_EVENTS];
- int i,n;
+ int i, n;
Bool wait = FALSE;
if (!xf86PMGetEventFromOs)
- return;
-
- if ((n = xf86PMGetEventFromOs(fd,events,MAX_NO_EVENTS))) {
- do {
- for (i = 0; i < n; i++) {
- const char *str = NULL;
- int verb = eventName(events[i],&str);
-
- xf86MsgVerb(X_INFO,verb,"PM Event received: %s\n",str);
- DoApmEvent(events[i],FALSE);
- switch (xf86PMConfirmEventToOs(fd,events[i])) {
- case PM_WAIT:
- wait = TRUE;
- break;
- case PM_CONTINUE:
- wait = FALSE;
- break;
- case PM_FAILED:
- DoApmEvent(events[i],TRUE);
- wait = FALSE;
- break;
- default:
- break;
- }
- }
- if (wait)
- n = xf86PMGetEventFromOs(fd,events,MAX_NO_EVENTS);
- else
- break;
- } while (1);
+ return;
+
+ if ((n = xf86PMGetEventFromOs(fd, events, MAX_NO_EVENTS))) {
+ do {
+ for (i = 0; i < n; i++) {
+ const char *str = NULL;
+ int verb = eventName(events[i], &str);
+
+ xf86MsgVerb(X_INFO, verb, "PM Event received: %s\n", str);
+ DoApmEvent(events[i], FALSE);
+ switch (xf86PMConfirmEventToOs(fd, events[i])) {
+ case PM_WAIT:
+ wait = TRUE;
+ break;
+ case PM_CONTINUE:
+ wait = FALSE;
+ break;
+ case PM_FAILED:
+ DoApmEvent(events[i], TRUE);
+ wait = FALSE;
+ break;
+ default:
+ break;
+ }
+ }
+ if (wait)
+ n = xf86PMGetEventFromOs(fd, events, MAX_NO_EVENTS);
+ else
+ break;
+ } while (1);
}
}
diff --git a/xorg-server/hw/xfree86/common/xf86Priv.h b/xorg-server/hw/xfree86/common/xf86Priv.h
index 255407b48..8d9cb5539 100644
--- a/xorg-server/hw/xfree86/common/xf86Priv.h
+++ b/xorg-server/hw/xfree86/common/xf86Priv.h
@@ -45,53 +45,55 @@
*/
extern _X_EXPORT const char *xf86ConfigFile;
extern _X_EXPORT const char *xf86ConfigDir;
-extern _X_EXPORT Bool xf86AllowMouseOpenFail;
+extern _X_EXPORT Bool xf86AllowMouseOpenFail;
+
#ifdef XF86VIDMODE
-extern _X_EXPORT Bool xf86VidModeDisabled;
-extern _X_EXPORT Bool xf86VidModeAllowNonLocal;
-#endif
-extern _X_EXPORT Bool xf86fpFlag;
-extern _X_EXPORT Bool xf86sFlag;
-extern _X_EXPORT Bool xf86bsEnableFlag;
-extern _X_EXPORT Bool xf86bsDisableFlag;
-extern _X_EXPORT Bool xf86silkenMouseDisableFlag;
-extern _X_EXPORT Bool xf86xkbdirFlag;
+extern _X_EXPORT Bool xf86VidModeDisabled;
+extern _X_EXPORT Bool xf86VidModeAllowNonLocal;
+#endif
+extern _X_EXPORT Bool xf86fpFlag;
+extern _X_EXPORT Bool xf86sFlag;
+extern _X_EXPORT Bool xf86bsEnableFlag;
+extern _X_EXPORT Bool xf86bsDisableFlag;
+extern _X_EXPORT Bool xf86silkenMouseDisableFlag;
+extern _X_EXPORT Bool xf86xkbdirFlag;
+
#ifdef HAVE_ACPI
-extern _X_EXPORT Bool xf86acpiDisableFlag;
+extern _X_EXPORT Bool xf86acpiDisableFlag;
#endif
-extern _X_EXPORT char *xf86LayoutName;
-extern _X_EXPORT char *xf86ScreenName;
-extern _X_EXPORT char *xf86PointerName;
-extern _X_EXPORT char *xf86KeyboardName;
-extern _X_EXPORT int xf86FbBpp;
-extern _X_EXPORT int xf86Depth;
-extern _X_EXPORT Pix24Flags xf86Pix24;
-extern _X_EXPORT rgb xf86Weight;
-extern _X_EXPORT Bool xf86FlipPixels;
-extern _X_EXPORT Gamma xf86Gamma;
-extern _X_EXPORT const char *xf86ServerName;
+extern _X_EXPORT char *xf86LayoutName;
+extern _X_EXPORT char *xf86ScreenName;
+extern _X_EXPORT char *xf86PointerName;
+extern _X_EXPORT char *xf86KeyboardName;
+extern _X_EXPORT int xf86FbBpp;
+extern _X_EXPORT int xf86Depth;
+extern _X_EXPORT Pix24Flags xf86Pix24;
+extern _X_EXPORT rgb xf86Weight;
+extern _X_EXPORT Bool xf86FlipPixels;
+extern _X_EXPORT Gamma xf86Gamma;
+extern _X_EXPORT const char *xf86ServerName;
/* Other parameters */
-extern _X_EXPORT xf86InfoRec xf86Info;
-extern _X_EXPORT const char *xf86ModulePath;
-extern _X_EXPORT MessageType xf86ModPathFrom;
-extern _X_EXPORT const char *xf86LogFile;
-extern _X_EXPORT MessageType xf86LogFileFrom;
-extern _X_EXPORT Bool xf86LogFileWasOpened;
-extern _X_EXPORT serverLayoutRec xf86ConfigLayout;
-
-extern _X_EXPORT DriverPtr *xf86DriverList;
-extern _X_EXPORT int xf86NumDrivers;
-extern _X_EXPORT Bool xf86Resetting;
-extern _X_EXPORT Bool xf86Initialising;
-extern _X_EXPORT int xf86NumScreens;
-extern _X_EXPORT const char *xf86VisualNames[];
-extern _X_EXPORT int xf86Verbose; /* verbosity level */
-extern _X_EXPORT int xf86LogVerbose; /* log file verbosity level */
-extern _X_EXPORT Bool xorgHWAccess;
-
-extern _X_EXPORT RootWinPropPtr *xf86RegisteredPropertiesTable;
+extern _X_EXPORT xf86InfoRec xf86Info;
+extern _X_EXPORT const char *xf86ModulePath;
+extern _X_EXPORT MessageType xf86ModPathFrom;
+extern _X_EXPORT const char *xf86LogFile;
+extern _X_EXPORT MessageType xf86LogFileFrom;
+extern _X_EXPORT Bool xf86LogFileWasOpened;
+extern _X_EXPORT serverLayoutRec xf86ConfigLayout;
+
+extern _X_EXPORT DriverPtr *xf86DriverList;
+extern _X_EXPORT int xf86NumDrivers;
+extern _X_EXPORT Bool xf86Resetting;
+extern _X_EXPORT Bool xf86Initialising;
+extern _X_EXPORT int xf86NumScreens;
+extern _X_EXPORT const char *xf86VisualNames[];
+extern _X_EXPORT int xf86Verbose; /* verbosity level */
+extern _X_EXPORT int xf86LogVerbose; /* log file verbosity level */
+extern _X_EXPORT Bool xorgHWAccess;
+
+extern _X_EXPORT RootWinPropPtr *xf86RegisteredPropertiesTable;
#ifndef DEFAULT_VERBOSE
#define DEFAULT_VERBOSE 0
@@ -125,29 +127,43 @@ extern _X_EXPORT const DisplayModeRec xf86DefaultModes[];
extern _X_EXPORT const int xf86NumDefaultModes;
/* xf86Configure.c */
-extern _X_EXPORT void DoConfigure(void) _X_NORETURN;
-extern _X_EXPORT void DoShowOptions(void) _X_NORETURN;
+extern _X_EXPORT void
+DoConfigure(void)
+ _X_NORETURN;
+extern _X_EXPORT void
+DoShowOptions(void)
+ _X_NORETURN;
/* xf86Events.c */
-extern _X_EXPORT void xf86Wakeup(pointer blockData, int err, pointer pReadmask);
-extern _X_HIDDEN int xf86SigWrapper(int signo);
-extern _X_EXPORT void xf86HandlePMEvents(int fd, pointer data);
-extern _X_EXPORT int (*xf86PMGetEventFromOs)(int fd,pmEvent *events,int num);
-extern _X_EXPORT pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event);
+extern _X_EXPORT void
+xf86Wakeup(pointer blockData, int err, pointer pReadmask);
+extern _X_HIDDEN int
+xf86SigWrapper(int signo);
+extern _X_EXPORT void
+xf86HandlePMEvents(int fd, pointer data);
+extern _X_EXPORT int (*xf86PMGetEventFromOs) (int fd, pmEvent * events,
+ int num);
+extern _X_EXPORT pmWait (*xf86PMConfirmEventToOs) (int fd, pmEvent event);
/* xf86Helper.c */
-extern _X_EXPORT void xf86LogInit(void);
-extern _X_EXPORT void xf86CloseLog(enum ExitCode error);
+extern _X_EXPORT void
+xf86LogInit(void);
+extern _X_EXPORT void
+xf86CloseLog(enum ExitCode error);
/* xf86Init.c */
-extern _X_EXPORT Bool xf86LoadModules(char **list, pointer *optlist);
-extern _X_EXPORT int xf86SetVerbosity(int verb);
-extern _X_EXPORT int xf86SetLogVerbosity(int verb);
-extern _X_EXPORT Bool xf86CallDriverProbe( struct _DriverRec * drv, Bool detect_only );
-extern _X_EXPORT Bool xf86PrivsElevated(void);
-
-#endif /* _NO_XF86_PROTOTYPES */
-
-
-#endif /* _XF86PRIV_H */
+extern _X_EXPORT Bool
+xf86LoadModules(char **list, pointer *optlist);
+extern _X_EXPORT int
+xf86SetVerbosity(int verb);
+extern _X_EXPORT int
+xf86SetLogVerbosity(int verb);
+extern _X_EXPORT Bool
+xf86CallDriverProbe(struct _DriverRec *drv, Bool detect_only);
+extern _X_EXPORT Bool
+xf86PrivsElevated(void);
+
+#endif /* _NO_XF86_PROTOTYPES */
+
+#endif /* _XF86PRIV_H */
diff --git a/xorg-server/hw/xfree86/common/xf86RandR.c b/xorg-server/hw/xfree86/common/xf86RandR.c
index d0e47841e..abd894dff 100644
--- a/xorg-server/hw/xfree86/common/xf86RandR.c
+++ b/xorg-server/hw/xfree86/common/xf86RandR.c
@@ -37,13 +37,13 @@
#include "inputstr.h"
typedef struct _xf86RandRInfo {
- CreateScreenResourcesProcPtr CreateScreenResources;
- CloseScreenProcPtr CloseScreen;
- int virtualX;
- int virtualY;
- int mmWidth;
- int mmHeight;
- Rotation rotation;
+ CreateScreenResourcesProcPtr CreateScreenResources;
+ CloseScreenProcPtr CloseScreen;
+ int virtualX;
+ int virtualY;
+ int mmWidth;
+ int mmHeight;
+ Rotation rotation;
} XF86RandRInfoRec, *XF86RandRInfoPtr;
static DevPrivateKeyRec xf86RandRKeyRec;
@@ -52,171 +52,162 @@ static DevPrivateKey xf86RandRKey;
#define XF86RANDRINFO(p) ((XF86RandRInfoPtr)dixLookupPrivate(&(p)->devPrivates, xf86RandRKey))
static int
-xf86RandRModeRefresh (DisplayModePtr mode)
+xf86RandRModeRefresh(DisplayModePtr mode)
{
if (mode->VRefresh)
- return (int) (mode->VRefresh + 0.5);
+ return (int) (mode->VRefresh + 0.5);
else if (mode->Clock == 0)
- return 0;
+ return 0;
else
- return (int) (mode->Clock * 1000.0 / mode->HTotal / mode->VTotal + 0.5);
+ return (int) (mode->Clock * 1000.0 / mode->HTotal / mode->VTotal + 0.5);
}
static Bool
-xf86RandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
+xf86RandRGetInfo(ScreenPtr pScreen, Rotation * rotations)
{
- RRScreenSizePtr pSize;
- ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- DisplayModePtr mode;
- int refresh0 = 60;
- xorgRRModeMM RRModeMM;
+ RRScreenSizePtr pSize;
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ DisplayModePtr mode;
+ int refresh0 = 60;
+ xorgRRModeMM RRModeMM;
*rotations = RR_Rotate_0;
- for (mode = scrp->modes; mode != NULL ; mode = mode->next)
- {
- int refresh = xf86RandRModeRefresh (mode);
-
- if (mode == scrp->modes)
- refresh0 = refresh;
-
- RRModeMM.mode = mode;
- RRModeMM.virtX = randrp->virtualX;
- RRModeMM.virtY = randrp->virtualY;
- RRModeMM.mmWidth = randrp->mmWidth;
- RRModeMM.mmHeight = randrp->mmHeight;
-
- if(scrp->DriverFunc) {
- (*scrp->DriverFunc)(scrp, RR_GET_MODE_MM, &RRModeMM);
- }
-
- pSize = RRRegisterSize (pScreen,
- mode->HDisplay, mode->VDisplay,
- RRModeMM.mmWidth, RRModeMM.mmHeight);
- if (!pSize)
- return FALSE;
- RRRegisterRate (pScreen, pSize, refresh);
- if (mode == scrp->currentMode &&
- mode->HDisplay == scrp->virtualX && mode->VDisplay == scrp->virtualY)
- RRSetCurrentConfig (pScreen, randrp->rotation, refresh, pSize);
- if (mode->next == scrp->modes)
- break;
+ for (mode = scrp->modes; mode != NULL; mode = mode->next) {
+ int refresh = xf86RandRModeRefresh(mode);
+
+ if (mode == scrp->modes)
+ refresh0 = refresh;
+
+ RRModeMM.mode = mode;
+ RRModeMM.virtX = randrp->virtualX;
+ RRModeMM.virtY = randrp->virtualY;
+ RRModeMM.mmWidth = randrp->mmWidth;
+ RRModeMM.mmHeight = randrp->mmHeight;
+
+ if (scrp->DriverFunc) {
+ (*scrp->DriverFunc) (scrp, RR_GET_MODE_MM, &RRModeMM);
+ }
+
+ pSize = RRRegisterSize(pScreen,
+ mode->HDisplay, mode->VDisplay,
+ RRModeMM.mmWidth, RRModeMM.mmHeight);
+ if (!pSize)
+ return FALSE;
+ RRRegisterRate(pScreen, pSize, refresh);
+ if (mode == scrp->currentMode &&
+ mode->HDisplay == scrp->virtualX &&
+ mode->VDisplay == scrp->virtualY)
+ RRSetCurrentConfig(pScreen, randrp->rotation, refresh, pSize);
+ if (mode->next == scrp->modes)
+ break;
}
if (scrp->currentMode->HDisplay != randrp->virtualX ||
- scrp->currentMode->VDisplay != randrp->virtualY)
- {
- mode = scrp->modes;
-
- RRModeMM.mode = NULL;
- RRModeMM.virtX = randrp->virtualX;
- RRModeMM.virtY = randrp->virtualY;
- RRModeMM.mmWidth = randrp->mmWidth;
- RRModeMM.mmHeight = randrp->mmHeight;
-
- if(scrp->DriverFunc) {
- (*scrp->DriverFunc)(scrp, RR_GET_MODE_MM, &RRModeMM);
- }
-
- pSize = RRRegisterSize (pScreen,
- randrp->virtualX, randrp->virtualY,
- RRModeMM.mmWidth, RRModeMM.mmHeight);
- if (!pSize)
- return FALSE;
- RRRegisterRate (pScreen, pSize, refresh0);
- if (scrp->virtualX == randrp->virtualX &&
- scrp->virtualY == randrp->virtualY)
- {
- RRSetCurrentConfig (pScreen, randrp->rotation, refresh0, pSize);
- }
+ scrp->currentMode->VDisplay != randrp->virtualY) {
+ mode = scrp->modes;
+
+ RRModeMM.mode = NULL;
+ RRModeMM.virtX = randrp->virtualX;
+ RRModeMM.virtY = randrp->virtualY;
+ RRModeMM.mmWidth = randrp->mmWidth;
+ RRModeMM.mmHeight = randrp->mmHeight;
+
+ if (scrp->DriverFunc) {
+ (*scrp->DriverFunc) (scrp, RR_GET_MODE_MM, &RRModeMM);
+ }
+
+ pSize = RRRegisterSize(pScreen,
+ randrp->virtualX, randrp->virtualY,
+ RRModeMM.mmWidth, RRModeMM.mmHeight);
+ if (!pSize)
+ return FALSE;
+ RRRegisterRate(pScreen, pSize, refresh0);
+ if (scrp->virtualX == randrp->virtualX &&
+ scrp->virtualY == randrp->virtualY) {
+ RRSetCurrentConfig(pScreen, randrp->rotation, refresh0, pSize);
+ }
}
/* If there is driver support for randr, let it set our supported rotations */
- if(scrp->DriverFunc) {
- xorgRRRotation RRRotation;
+ if (scrp->DriverFunc) {
+ xorgRRRotation RRRotation;
- RRRotation.RRRotations = *rotations;
- if (!(*scrp->DriverFunc)(scrp, RR_GET_INFO, &RRRotation))
- return TRUE;
- *rotations = RRRotation.RRRotations;
+ RRRotation.RRRotations = *rotations;
+ if (!(*scrp->DriverFunc) (scrp, RR_GET_INFO, &RRRotation))
+ return TRUE;
+ *rotations = RRRotation.RRRotations;
}
return TRUE;
}
static Bool
-xf86RandRSetMode (ScreenPtr pScreen,
- DisplayModePtr mode,
- Bool useVirtual,
- int mmWidth,
- int mmHeight)
+xf86RandRSetMode(ScreenPtr pScreen,
+ DisplayModePtr mode,
+ Bool useVirtual, int mmWidth, int mmHeight)
{
- ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- int oldWidth = pScreen->width;
- int oldHeight = pScreen->height;
- int oldmmWidth = pScreen->mmWidth;
- int oldmmHeight = pScreen->mmHeight;
- int oldVirtualX = scrp->virtualX;
- int oldVirtualY = scrp->virtualY;
- WindowPtr pRoot = pScreen->root;
- Bool ret = TRUE;
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ int oldWidth = pScreen->width;
+ int oldHeight = pScreen->height;
+ int oldmmWidth = pScreen->mmWidth;
+ int oldmmHeight = pScreen->mmHeight;
+ int oldVirtualX = scrp->virtualX;
+ int oldVirtualY = scrp->virtualY;
+ WindowPtr pRoot = pScreen->root;
+ Bool ret = TRUE;
if (pRoot && scrp->vtSema)
- (*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE);
- if (useVirtual)
- {
- scrp->virtualX = randrp->virtualX;
- scrp->virtualY = randrp->virtualY;
+ (*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE);
+ if (useVirtual) {
+ scrp->virtualX = randrp->virtualX;
+ scrp->virtualY = randrp->virtualY;
}
- else
- {
- scrp->virtualX = mode->HDisplay;
- scrp->virtualY = mode->VDisplay;
+ else {
+ scrp->virtualX = mode->HDisplay;
+ scrp->virtualY = mode->VDisplay;
}
/*
* The DIX forgets the physical dimensions we passed into RRRegisterSize, so
* reconstruct them if possible.
*/
- if(scrp->DriverFunc) {
- xorgRRModeMM RRModeMM;
+ if (scrp->DriverFunc) {
+ xorgRRModeMM RRModeMM;
- RRModeMM.mode = mode;
- RRModeMM.virtX = scrp->virtualX;
- RRModeMM.virtY = scrp->virtualY;
- RRModeMM.mmWidth = mmWidth;
- RRModeMM.mmHeight = mmHeight;
+ RRModeMM.mode = mode;
+ RRModeMM.virtX = scrp->virtualX;
+ RRModeMM.virtY = scrp->virtualY;
+ RRModeMM.mmWidth = mmWidth;
+ RRModeMM.mmHeight = mmHeight;
- (*scrp->DriverFunc)(scrp, RR_GET_MODE_MM, &RRModeMM);
+ (*scrp->DriverFunc) (scrp, RR_GET_MODE_MM, &RRModeMM);
- mmWidth = RRModeMM.mmWidth;
- mmHeight = RRModeMM.mmHeight;
+ mmWidth = RRModeMM.mmWidth;
+ mmHeight = RRModeMM.mmHeight;
}
- if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270))
- {
- /* If the screen is rotated 90 or 270 degrees, swap the sizes. */
- pScreen->width = scrp->virtualY;
- pScreen->height = scrp->virtualX;
- pScreen->mmWidth = mmHeight;
- pScreen->mmHeight = mmWidth;
+ if (randrp->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
+ /* If the screen is rotated 90 or 270 degrees, swap the sizes. */
+ pScreen->width = scrp->virtualY;
+ pScreen->height = scrp->virtualX;
+ pScreen->mmWidth = mmHeight;
+ pScreen->mmHeight = mmWidth;
}
- else
- {
- pScreen->width = scrp->virtualX;
- pScreen->height = scrp->virtualY;
- pScreen->mmWidth = mmWidth;
- pScreen->mmHeight = mmHeight;
+ else {
+ pScreen->width = scrp->virtualX;
+ pScreen->height = scrp->virtualY;
+ pScreen->mmWidth = mmWidth;
+ pScreen->mmHeight = mmHeight;
}
- if (!xf86SwitchMode (pScreen, mode))
- {
- pScreen->width = oldWidth;
- pScreen->height = oldHeight;
- pScreen->mmWidth = oldmmWidth;
- pScreen->mmHeight = oldmmHeight;
- scrp->virtualX = oldVirtualX;
- scrp->virtualY = oldVirtualY;
- ret = FALSE;
+ if (!xf86SwitchMode(pScreen, mode)) {
+ pScreen->width = oldWidth;
+ pScreen->height = oldHeight;
+ pScreen->mmWidth = oldmmWidth;
+ pScreen->mmHeight = oldmmHeight;
+ scrp->virtualX = oldVirtualX;
+ scrp->virtualY = oldVirtualY;
+ ret = FALSE;
}
/*
* Make sure the layout is correct
@@ -226,120 +217,117 @@ xf86RandRSetMode (ScreenPtr pScreen,
/*
* Make sure the whole screen is visible
*/
- xf86SetViewport (pScreen, pScreen->width, pScreen->height);
- xf86SetViewport (pScreen, 0, 0);
+ xf86SetViewport(pScreen, pScreen->width, pScreen->height);
+ xf86SetViewport(pScreen, 0, 0);
if (pRoot && scrp->vtSema)
- (*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE);
+ (*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE);
return ret;
}
static Bool
-xf86RandRSetConfig (ScreenPtr pScreen,
- Rotation rotation,
- int rate,
- RRScreenSizePtr pSize)
+xf86RandRSetConfig(ScreenPtr pScreen,
+ Rotation rotation, int rate, RRScreenSizePtr pSize)
{
- ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- DisplayModePtr mode;
- int pos[MAXDEVICES][2];
- Bool useVirtual = FALSE;
- Rotation oldRotation = randrp->rotation;
- DeviceIntPtr dev;
- Bool view_adjusted = FALSE;
-
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (!IsMaster(dev) && !IsFloating(dev))
- continue;
-
- miPointerGetPosition(dev, &pos[dev->id][0], &pos[dev->id][1]);
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ DisplayModePtr mode;
+ int pos[MAXDEVICES][2];
+ Bool useVirtual = FALSE;
+ Rotation oldRotation = randrp->rotation;
+ DeviceIntPtr dev;
+ Bool view_adjusted = FALSE;
+
+ for (dev = inputInfo.devices; dev; dev = dev->next) {
+ if (!IsMaster(dev) && !IsFloating(dev))
+ continue;
+
+ miPointerGetPosition(dev, &pos[dev->id][0], &pos[dev->id][1]);
}
- for (mode = scrp->modes; ; mode = mode->next)
- {
- if (mode->HDisplay == pSize->width &&
- mode->VDisplay == pSize->height &&
- (rate == 0 || xf86RandRModeRefresh (mode) == rate))
- break;
- if (mode->next == scrp->modes)
- {
- if (pSize->width == randrp->virtualX &&
- pSize->height == randrp->virtualY)
- {
- mode = scrp->modes;
- useVirtual = TRUE;
- break;
- }
- return FALSE;
- }
+ for (mode = scrp->modes;; mode = mode->next) {
+ if (mode->HDisplay == pSize->width &&
+ mode->VDisplay == pSize->height &&
+ (rate == 0 || xf86RandRModeRefresh(mode) == rate))
+ break;
+ if (mode->next == scrp->modes) {
+ if (pSize->width == randrp->virtualX &&
+ pSize->height == randrp->virtualY) {
+ mode = scrp->modes;
+ useVirtual = TRUE;
+ break;
+ }
+ return FALSE;
+ }
}
if (randrp->rotation != rotation) {
/* Have the driver do its thing. */
- if (scrp->DriverFunc) {
- xorgRRRotation RRRotation;
- RRRotation.RRConfig.rotation = rotation;
- RRRotation.RRConfig.rate = rate;
- RRRotation.RRConfig.width = pSize->width;
- RRRotation.RRConfig.height = pSize->height;
-
- /*
- * Currently we need to rely on HW support for rotation.
- */
- if (!(*scrp->DriverFunc)(scrp, RR_SET_CONFIG, &RRRotation))
- return FALSE;
- } else
- return FALSE;
-
- randrp->rotation = rotation;
+ if (scrp->DriverFunc) {
+ xorgRRRotation RRRotation;
+
+ RRRotation.RRConfig.rotation = rotation;
+ RRRotation.RRConfig.rate = rate;
+ RRRotation.RRConfig.width = pSize->width;
+ RRRotation.RRConfig.height = pSize->height;
+
+ /*
+ * Currently we need to rely on HW support for rotation.
+ */
+ if (!(*scrp->DriverFunc) (scrp, RR_SET_CONFIG, &RRRotation))
+ return FALSE;
+ }
+ else
+ return FALSE;
+
+ randrp->rotation = rotation;
}
- if (!xf86RandRSetMode (pScreen, mode, useVirtual, pSize->mmWidth, pSize->mmHeight)) {
- if(randrp->rotation != oldRotation) {
- /* Have the driver undo its thing. */
- if (scrp->DriverFunc) {
- xorgRRRotation RRRotation;
- RRRotation.RRConfig.rotation = oldRotation;
- RRRotation.RRConfig.rate = xf86RandRModeRefresh (scrp->currentMode);
- RRRotation.RRConfig.width = scrp->virtualX;
- RRRotation.RRConfig.height = scrp->virtualY;
- (*scrp->DriverFunc)(scrp, RR_SET_CONFIG, &RRRotation);
- }
-
- randrp->rotation = oldRotation;
- }
- return FALSE;
+ if (!xf86RandRSetMode
+ (pScreen, mode, useVirtual, pSize->mmWidth, pSize->mmHeight)) {
+ if (randrp->rotation != oldRotation) {
+ /* Have the driver undo its thing. */
+ if (scrp->DriverFunc) {
+ xorgRRRotation RRRotation;
+
+ RRRotation.RRConfig.rotation = oldRotation;
+ RRRotation.RRConfig.rate =
+ xf86RandRModeRefresh(scrp->currentMode);
+ RRRotation.RRConfig.width = scrp->virtualX;
+ RRRotation.RRConfig.height = scrp->virtualY;
+ (*scrp->DriverFunc) (scrp, RR_SET_CONFIG, &RRRotation);
+ }
+
+ randrp->rotation = oldRotation;
+ }
+ return FALSE;
}
-
update_desktop_dimensions();
/*
* Move the cursor back where it belongs; SwitchMode repositions it
* FIXME: duplicated code, see modes/xf86RandR12.c
*/
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (!IsMaster(dev) && !IsFloating(dev))
- continue;
-
- if (pScreen == miPointerGetScreen(dev)) {
- int px = pos[dev->id][0];
- int py = pos[dev->id][1];
-
- px = (px >= pScreen->width ? (pScreen->width - 1) : px);
- py = (py >= pScreen->height ? (pScreen->height - 1) : py);
-
- /* Setting the viewpoint makes only sense on one device */
- if (!view_adjusted && IsMaster(dev)) {
- xf86SetViewport(pScreen, px, py);
- view_adjusted = TRUE;
- }
-
- (*pScreen->SetCursorPosition) (dev, pScreen, px, py, FALSE);
- }
+ for (dev = inputInfo.devices; dev; dev = dev->next) {
+ if (!IsMaster(dev) && !IsFloating(dev))
+ continue;
+
+ if (pScreen == miPointerGetScreen(dev)) {
+ int px = pos[dev->id][0];
+ int py = pos[dev->id][1];
+
+ px = (px >= pScreen->width ? (pScreen->width - 1) : px);
+ py = (py >= pScreen->height ? (pScreen->height - 1) : py);
+
+ /* Setting the viewpoint makes only sense on one device */
+ if (!view_adjusted && IsMaster(dev)) {
+ xf86SetViewport(pScreen, px, py);
+ view_adjusted = TRUE;
+ }
+
+ (*pScreen->SetCursorPosition) (dev, pScreen, px, py, FALSE);
+ }
}
return TRUE;
@@ -351,22 +339,23 @@ xf86RandRSetConfig (ScreenPtr pScreen,
* at the current mode size rather than the maximum size
*/
static Bool
-xf86RandRCreateScreenResources (ScreenPtr pScreen)
+xf86RandRCreateScreenResources(ScreenPtr pScreen)
{
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+
#if 0
- ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
- DisplayModePtr mode;
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ DisplayModePtr mode;
#endif
pScreen->CreateScreenResources = randrp->CreateScreenResources;
if (!(*pScreen->CreateScreenResources) (pScreen))
- return FALSE;
+ return FALSE;
#if 0
mode = scrp->currentMode;
if (mode)
- xf86RandRSetMode (pScreen, mode, TRUE);
+ xf86RandRSetMode(pScreen, mode, TRUE);
#endif
return TRUE;
@@ -376,10 +365,10 @@ xf86RandRCreateScreenResources (ScreenPtr pScreen)
* Reset size back to original
*/
static Bool
-xf86RandRCloseScreen (int index, ScreenPtr pScreen)
+xf86RandRCloseScreen(int index, ScreenPtr pScreen)
{
- ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
scrp->virtualX = pScreen->width = randrp->virtualX;
scrp->virtualY = pScreen->height = randrp->virtualY;
@@ -394,7 +383,7 @@ Rotation
xf86GetRotation(ScreenPtr pScreen)
{
if (xf86RandRKey == NULL)
- return RR_Rotate_0;
+ return RR_Rotate_0;
return XF86RANDRINFO(pScreen)->rotation;
}
@@ -402,67 +391,65 @@ xf86GetRotation(ScreenPtr pScreen)
/* Function to change RandR's idea of the virtual screen size */
Bool
xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
- int newvirtX, int newvirtY, int newmmWidth, int newmmHeight,
- Bool resetMode)
+ int newvirtX, int newvirtY, int newmmWidth,
+ int newmmHeight, Bool resetMode)
{
XF86RandRInfoPtr randrp;
if (xf86RandRKey == NULL)
- return FALSE;
+ return FALSE;
randrp = XF86RANDRINFO(pScreen);
if (randrp == NULL)
- return FALSE;
+ return FALSE;
if (newvirtX > 0)
- randrp->virtualX = newvirtX;
+ randrp->virtualX = newvirtX;
if (newvirtY > 0)
- randrp->virtualY = newvirtY;
+ randrp->virtualY = newvirtY;
if (newmmWidth > 0)
- randrp->mmWidth = newmmWidth;
+ randrp->mmWidth = newmmWidth;
if (newmmHeight > 0)
- randrp->mmHeight = newmmHeight;
+ randrp->mmHeight = newmmHeight;
/* This is only for during server start */
if (resetMode) {
- return (xf86RandRSetMode(pScreen,
- XF86SCRNINFO(pScreen)->currentMode,
- TRUE,
- pScreen->mmWidth, pScreen->mmHeight));
+ return (xf86RandRSetMode(pScreen,
+ XF86SCRNINFO(pScreen)->currentMode,
+ TRUE, pScreen->mmWidth, pScreen->mmHeight));
}
return TRUE;
}
Bool
-xf86RandRInit (ScreenPtr pScreen)
+xf86RandRInit(ScreenPtr pScreen)
{
- rrScrPrivPtr rp;
- XF86RandRInfoPtr randrp;
- ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ rrScrPrivPtr rp;
+ XF86RandRInfoPtr randrp;
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
#ifdef PANORAMIX
/* XXX disable RandR when using Xinerama */
if (!noPanoramiXExtension)
- return TRUE;
+ return TRUE;
#endif
xf86RandRKey = &xf86RandRKeyRec;
if (!dixRegisterPrivateKey(&xf86RandRKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
+ return FALSE;
- randrp = malloc(sizeof (XF86RandRInfoRec));
+ randrp = malloc(sizeof(XF86RandRInfoRec));
if (!randrp)
- return FALSE;
+ return FALSE;
- if (!RRScreenInit (pScreen))
- {
- free(randrp);
- return FALSE;
+ if (!RRScreenInit(pScreen)) {
+ free(randrp);
+ return FALSE;
}
rp = rrGetScrPriv(pScreen);
rp->rrGetInfo = xf86RandRGetInfo;
@@ -484,5 +471,3 @@ xf86RandRInit (ScreenPtr pScreen)
dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, randrp);
return TRUE;
}
-
-
diff --git a/xorg-server/hw/xfree86/common/xf86VGAarbiter.c b/xorg-server/hw/xfree86/common/xf86VGAarbiter.c
index 819ad6e7c..7c9e6ba02 100644
--- a/xorg-server/hw/xfree86/common/xf86VGAarbiter.c
+++ b/xorg-server/hw/xfree86/common/xf86VGAarbiter.c
@@ -36,7 +36,6 @@
#include "xf86Priv.h"
#include "pciaccess.h"
-
static GCFuncs VGAarbiterGCFuncs = {
VGAarbiterValidateGC, VGAarbiterChangeGC, VGAarbiterCopyGC,
VGAarbiterDestroyGC, VGAarbiterChangeClip, VGAarbiterDestroyClip,
@@ -60,8 +59,10 @@ static miPointerSpriteFuncRec VGAarbiterSpriteFuncs = {
};
static DevPrivateKeyRec VGAarbiterScreenKeyRec;
+
#define VGAarbiterScreenKey (&VGAarbiterScreenKeyRec)
static DevPrivateKeyRec VGAarbiterGCKeyRec;
+
#define VGAarbiterGCKey (&VGAarbiterGCKeyRec)
static int vga_no_arb = 0;
@@ -69,8 +70,9 @@ void
xf86VGAarbiterInit(void)
{
if (pci_device_vgaarb_init() != 0) {
- vga_no_arb = 1;
- xf86Msg(X_WARNING, "VGA arbiter: cannot open kernel arbiter, no multi-card support\n");
+ vga_no_arb = 1;
+ xf86Msg(X_WARNING,
+ "VGA arbiter: cannot open kernel arbiter, no multi-card support\n");
}
}
@@ -78,7 +80,7 @@ void
xf86VGAarbiterFini(void)
{
if (vga_no_arb)
- return;
+ return;
pci_device_vgaarb_fini();
}
@@ -86,7 +88,7 @@ void
xf86VGAarbiterLock(ScrnInfoPtr pScrn)
{
if (vga_no_arb)
- return;
+ return;
pci_device_vgaarb_set_target(pScrn->vgaDev);
pci_device_vgaarb_lock();
}
@@ -95,18 +97,19 @@ void
xf86VGAarbiterUnlock(ScrnInfoPtr pScrn)
{
if (vga_no_arb)
- return;
+ return;
pci_device_vgaarb_unlock();
}
-Bool xf86VGAarbiterAllowDRI(ScreenPtr pScreen)
+Bool
+xf86VGAarbiterAllowDRI(ScreenPtr pScreen)
{
int vga_count;
int rsrc_decodes;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
if (vga_no_arb)
- return TRUE;
+ return TRUE;
pci_device_vgaarb_get_info(pScrn->vgaDev, &vga_count, &rsrc_decodes);
if (vga_count > 1) {
@@ -124,11 +127,11 @@ xf86VGAarbiterScrnInit(ScrnInfoPtr pScrn)
EntityPtr pEnt;
if (vga_no_arb)
- return;
+ return;
pEnt = xf86Entities[pScrn->entityList[0]];
if (pEnt->bus.type != BUS_PCI)
- return;
+ return;
dev = pEnt->bus.id.pci;
pScrn->vgaDev = dev;
@@ -138,7 +141,7 @@ void
xf86VGAarbiterDeviceDecodes(ScrnInfoPtr pScrn, int rsrc)
{
if (vga_no_arb)
- return;
+ return;
pci_device_vgaarb_set_target(pScrn->vgaDev);
pci_device_vgaarb_decodes(rsrc);
}
@@ -149,7 +152,7 @@ xf86VGAarbiterWrapFunctions(void)
ScrnInfoPtr pScrn;
VGAarbiterScreenPtr pScreenPriv;
miPointerScreenPtr PointPriv;
- PictureScreenPtr ps;
+ PictureScreenPtr ps;
ScreenPtr pScreen;
int vga_count, i;
@@ -164,7 +167,7 @@ xf86VGAarbiterWrapFunctions(void)
if (vga_count < 2 || !xf86Screens)
return FALSE;
- xf86Msg(X_INFO,"Found %d VGA devices: arbiter wrapping enabled\n",
+ xf86Msg(X_INFO, "Found %d VGA devices: arbiter wrapping enabled\n",
vga_count);
for (i = 0; i < xf86NumScreens; i++) {
@@ -173,11 +176,12 @@ xf86VGAarbiterWrapFunctions(void)
pScrn = xf86Screens[pScreen->myNum];
PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
- if (!dixRegisterPrivateKey(&VGAarbiterGCKeyRec, PRIVATE_GC, sizeof(VGAarbiterGCRec)))
+ if (!dixRegisterPrivateKey
+ (&VGAarbiterGCKeyRec, PRIVATE_GC, sizeof(VGAarbiterGCRec)))
return FALSE;
- if (!dixRegisterPrivateKey(&VGAarbiterScreenKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
+ if (!dixRegisterPrivateKey(&VGAarbiterScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
if (!(pScreenPriv = malloc(sizeof(VGAarbiterScreenRec))))
return FALSE;
@@ -201,9 +205,9 @@ xf86VGAarbiterWrapFunctions(void)
WRAP_SCREEN(UnrealizeCursor, VGAarbiterUnrealizeCursor);
WRAP_SCREEN(RecolorCursor, VGAarbiterRecolorCursor);
WRAP_SCREEN(SetCursorPosition, VGAarbiterSetCursorPosition);
- WRAP_PICT(Composite,VGAarbiterComposite);
- WRAP_PICT(Glyphs,VGAarbiterGlyphs);
- WRAP_PICT(CompositeRects,VGAarbiterCompositeRects);
+ WRAP_PICT(Composite, VGAarbiterComposite);
+ WRAP_PICT(Glyphs, VGAarbiterGlyphs);
+ WRAP_PICT(CompositeRects, VGAarbiterCompositeRects);
WRAP_SCREEN_INFO(AdjustFrame, VGAarbiterAdjustFrame);
WRAP_SCREEN_INFO(SwitchMode, VGAarbiterSwitchMode);
WRAP_SCREEN_INFO(EnterVT, VGAarbiterEnterVT);
@@ -217,15 +221,17 @@ xf86VGAarbiterWrapFunctions(void)
/* Screen funcs */
static Bool
-VGAarbiterCloseScreen (int i, ScreenPtr pScreen)
+VGAarbiterCloseScreen(int i, ScreenPtr pScreen)
{
Bool val;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, VGAarbiterScreenKey);
- miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, miPointerScreenKey);
- PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
+ VGAarbiterScreenPtr pScreenPriv =
+ (VGAarbiterScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ VGAarbiterScreenKey);
+ miPointerScreenPtr PointPriv =
+ (miPointerScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ miPointerScreenKey);
+ PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
UNWRAP_SCREEN(CreateGC);
UNWRAP_SCREEN(CloseScreen);
@@ -263,6 +269,7 @@ VGAarbiterBlockHandler(int i,
pointer blockData, pointer pTimeout, pointer pReadmask)
{
ScreenPtr pScreen = screenInfo.screens[i];
+
SCREEN_PROLOG(BlockHandler);
VGAGet(pScreen);
pScreen->BlockHandler(i, blockData, pTimeout, pReadmask);
@@ -271,9 +278,11 @@ VGAarbiterBlockHandler(int i,
}
static void
-VGAarbiterWakeupHandler(int i, pointer blockData, unsigned long result, pointer pReadmask)
+VGAarbiterWakeupHandler(int i, pointer blockData, unsigned long result,
+ pointer pReadmask)
{
ScreenPtr pScreen = screenInfo.screens[i];
+
SCREEN_PROLOG(WakeupHandler);
VGAGet(pScreen);
pScreen->WakeupHandler(i, blockData, result, pReadmask);
@@ -282,100 +291,87 @@ VGAarbiterWakeupHandler(int i, pointer blockData, unsigned long result, pointer
}
static void
-VGAarbiterGetImage (
- DrawablePtr pDrawable,
- int sx, int sy, int w, int h,
- unsigned int format,
- unsigned long planemask,
- char *pdstLine
- )
+VGAarbiterGetImage(DrawablePtr pDrawable,
+ int sx, int sy, int w, int h,
+ unsigned int format, unsigned long planemask, char *pdstLine)
{
ScreenPtr pScreen = pDrawable->pScreen;
+
SCREEN_PROLOG(GetImage);
// if (xf86Screens[pScreen->myNum]->vtSema) {
VGAGet(pScreen);
// }
- (*pScreen->GetImage) (pDrawable, sx, sy, w, h,
- format, planemask, pdstLine);
+ (*pScreen->GetImage) (pDrawable, sx, sy, w, h, format, planemask, pdstLine);
VGAPut();
- SCREEN_EPILOG (GetImage, VGAarbiterGetImage);
+ SCREEN_EPILOG(GetImage, VGAarbiterGetImage);
}
static void
-VGAarbiterGetSpans (
- DrawablePtr pDrawable,
- int wMax,
- DDXPointPtr ppt,
- int *pwidth,
- int nspans,
- char *pdstStart
- )
-{
- ScreenPtr pScreen = pDrawable->pScreen;
-
- SCREEN_PROLOG (GetSpans);
+VGAarbiterGetSpans(DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr ppt, int *pwidth, int nspans, char *pdstStart)
+{
+ ScreenPtr pScreen = pDrawable->pScreen;
+
+ SCREEN_PROLOG(GetSpans);
VGAGet(pScreen);
(*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
VGAPut();
- SCREEN_EPILOG (GetSpans, VGAarbiterGetSpans);
+ SCREEN_EPILOG(GetSpans, VGAarbiterGetSpans);
}
static void
-VGAarbiterSourceValidate (
- DrawablePtr pDrawable,
- int x, int y, int width, int height,
- unsigned int subWindowMode )
+VGAarbiterSourceValidate(DrawablePtr pDrawable,
+ int x, int y, int width, int height,
+ unsigned int subWindowMode)
{
- ScreenPtr pScreen = pDrawable->pScreen;
- SCREEN_PROLOG (SourceValidate);
+ ScreenPtr pScreen = pDrawable->pScreen;
+
+ SCREEN_PROLOG(SourceValidate);
VGAGet(pScreen);
if (pScreen->SourceValidate)
- (*pScreen->SourceValidate) (pDrawable, x, y, width, height, subWindowMode);
+ (*pScreen->SourceValidate) (pDrawable, x, y, width, height,
+ subWindowMode);
VGAPut();
- SCREEN_EPILOG (SourceValidate, VGAarbiterSourceValidate);
+ SCREEN_EPILOG(SourceValidate, VGAarbiterSourceValidate);
}
static void
-VGAarbiterCopyWindow(
- WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgnSrc )
+VGAarbiterCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
- SCREEN_PROLOG (CopyWindow);
+ SCREEN_PROLOG(CopyWindow);
VGAGet(pScreen);
(*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
VGAPut();
- SCREEN_EPILOG (CopyWindow, VGAarbiterCopyWindow);
+ SCREEN_EPILOG(CopyWindow, VGAarbiterCopyWindow);
}
static void
-VGAarbiterClearToBackground (
- WindowPtr pWin,
- int x, int y,
- int w, int h,
- Bool generateExposures )
+VGAarbiterClearToBackground(WindowPtr pWin,
+ int x, int y, int w, int h, Bool generateExposures)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
- SCREEN_PROLOG ( ClearToBackground);
+ SCREEN_PROLOG(ClearToBackground);
VGAGet(pScreen);
(*pScreen->ClearToBackground) (pWin, x, y, w, h, generateExposures);
VGAPut();
- SCREEN_EPILOG (ClearToBackground, VGAarbiterClearToBackground);
+ SCREEN_EPILOG(ClearToBackground, VGAarbiterClearToBackground);
}
static PixmapPtr
-VGAarbiterCreatePixmap(ScreenPtr pScreen, int w, int h, int depth, unsigned usage_hint)
+VGAarbiterCreatePixmap(ScreenPtr pScreen, int w, int h, int depth,
+ unsigned usage_hint)
{
PixmapPtr pPix;
- SCREEN_PROLOG ( CreatePixmap);
+ SCREEN_PROLOG(CreatePixmap);
VGAGet(pScreen);
pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth, usage_hint);
VGAPut();
- SCREEN_EPILOG (CreatePixmap, VGAarbiterCreatePixmap);
+ SCREEN_EPILOG(CreatePixmap, VGAarbiterCreatePixmap);
return pPix;
}
@@ -385,110 +381,89 @@ VGAarbiterSaveScreen(ScreenPtr pScreen, Bool unblank)
{
Bool val;
- SCREEN_PROLOG (SaveScreen);
+ SCREEN_PROLOG(SaveScreen);
VGAGet(pScreen);
val = (*pScreen->SaveScreen) (pScreen, unblank);
VGAPut();
- SCREEN_EPILOG (SaveScreen, VGAarbiterSaveScreen);
+ SCREEN_EPILOG(SaveScreen, VGAarbiterSaveScreen);
return val;
}
static void
-VGAarbiterStoreColors (
- ColormapPtr pmap,
- int ndef,
- xColorItem *pdefs)
+VGAarbiterStoreColors(ColormapPtr pmap, int ndef, xColorItem * pdefs)
{
ScreenPtr pScreen = pmap->pScreen;
- SCREEN_PROLOG (StoreColors);
+ SCREEN_PROLOG(StoreColors);
VGAGet(pScreen);
- (*pScreen->StoreColors) (pmap,ndef,pdefs);
+ (*pScreen->StoreColors) (pmap, ndef, pdefs);
VGAPut();
- SCREEN_EPILOG ( StoreColors, VGAarbiterStoreColors);
+ SCREEN_EPILOG(StoreColors, VGAarbiterStoreColors);
}
static void
-VGAarbiterRecolorCursor (
- DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCurs,
- Bool displayed
- )
-{
- SCREEN_PROLOG (RecolorCursor);
+VGAarbiterRecolorCursor(DeviceIntPtr pDev,
+ ScreenPtr pScreen, CursorPtr pCurs, Bool displayed)
+{
+ SCREEN_PROLOG(RecolorCursor);
VGAGet(pScreen);
(*pScreen->RecolorCursor) (pDev, pScreen, pCurs, displayed);
VGAPut();
- SCREEN_EPILOG ( RecolorCursor, VGAarbiterRecolorCursor);
+ SCREEN_EPILOG(RecolorCursor, VGAarbiterRecolorCursor);
}
static Bool
-VGAarbiterRealizeCursor (
- DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCursor
- )
+VGAarbiterRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
{
Bool val;
- SCREEN_PROLOG (RealizeCursor);
+ SCREEN_PROLOG(RealizeCursor);
VGAGet(pScreen);
- val = (*pScreen->RealizeCursor) (pDev, pScreen,pCursor);
+ val = (*pScreen->RealizeCursor) (pDev, pScreen, pCursor);
VGAPut();
- SCREEN_EPILOG ( RealizeCursor, VGAarbiterRealizeCursor);
+ SCREEN_EPILOG(RealizeCursor, VGAarbiterRealizeCursor);
return val;
}
static Bool
-VGAarbiterUnrealizeCursor (
- DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCursor
- )
+VGAarbiterUnrealizeCursor(DeviceIntPtr pDev,
+ ScreenPtr pScreen, CursorPtr pCursor)
{
Bool val;
- SCREEN_PROLOG (UnrealizeCursor);
+ SCREEN_PROLOG(UnrealizeCursor);
VGAGet(pScreen);
val = (*pScreen->UnrealizeCursor) (pDev, pScreen, pCursor);
VGAPut();
- SCREEN_EPILOG ( UnrealizeCursor, VGAarbiterUnrealizeCursor);
+ SCREEN_EPILOG(UnrealizeCursor, VGAarbiterUnrealizeCursor);
return val;
}
static Bool
-VGAarbiterDisplayCursor (
- DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCursor
- )
+VGAarbiterDisplayCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
{
Bool val;
- SCREEN_PROLOG (DisplayCursor);
+ SCREEN_PROLOG(DisplayCursor);
VGAGet(pScreen);
val = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
VGAPut();
- SCREEN_EPILOG ( DisplayCursor, VGAarbiterDisplayCursor);
+ SCREEN_EPILOG(DisplayCursor, VGAarbiterDisplayCursor);
return val;
}
static Bool
-VGAarbiterSetCursorPosition (
- DeviceIntPtr pDev,
- ScreenPtr pScreen,
- int x, int y,
- Bool generateEvent)
+VGAarbiterSetCursorPosition(DeviceIntPtr pDev,
+ ScreenPtr pScreen, int x, int y, Bool generateEvent)
{
Bool val;
- SCREEN_PROLOG (SetCursorPosition);
+ SCREEN_PROLOG(SetCursorPosition);
VGAGet(pScreen);
val = (*pScreen->SetCursorPosition) (pDev, pScreen, x, y, generateEvent);
VGAPut();
- SCREEN_EPILOG ( SetCursorPosition, VGAarbiterSetCursorPosition);
+ SCREEN_EPILOG(SetCursorPosition, VGAarbiterSetCursorPosition);
return val;
}
@@ -496,11 +471,12 @@ static void
VGAarbiterAdjustFrame(int index, int x, int y, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
- VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, VGAarbiterScreenKey);
+ VGAarbiterScreenPtr pScreenPriv =
+ (VGAarbiterScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ VGAarbiterScreenKey);
VGAGet(pScreen);
- (*pScreenPriv->AdjustFrame)(index, x, y, flags);
+ (*pScreenPriv->AdjustFrame) (index, x, y, flags);
VGAPut();
}
@@ -509,11 +485,12 @@ VGAarbiterSwitchMode(int index, DisplayModePtr mode, int flags)
{
Bool val;
ScreenPtr pScreen = screenInfo.screens[index];
- VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, VGAarbiterScreenKey);
+ VGAarbiterScreenPtr pScreenPriv =
+ (VGAarbiterScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ VGAarbiterScreenKey);
VGAGet(pScreen);
- val = (*pScreenPriv->SwitchMode)(index, mode, flags);
+ val = (*pScreenPriv->SwitchMode) (index, mode, flags);
VGAPut();
return val;
}
@@ -524,12 +501,13 @@ VGAarbiterEnterVT(int index, int flags)
Bool val;
ScrnInfoPtr pScrn = xf86Screens[index];
ScreenPtr pScreen = screenInfo.screens[index];
- VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, VGAarbiterScreenKey);
+ VGAarbiterScreenPtr pScreenPriv =
+ (VGAarbiterScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ VGAarbiterScreenKey);
VGAGet(pScreen);
pScrn->EnterVT = pScreenPriv->EnterVT;
- val = (*pScrn->EnterVT)(index, flags);
+ val = (*pScrn->EnterVT) (index, flags);
pScreenPriv->EnterVT = pScrn->EnterVT;
pScrn->EnterVT = VGAarbiterEnterVT;
VGAPut();
@@ -541,12 +519,13 @@ VGAarbiterLeaveVT(int index, int flags)
{
ScrnInfoPtr pScrn = xf86Screens[index];
ScreenPtr pScreen = screenInfo.screens[index];
- VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, VGAarbiterScreenKey);
+ VGAarbiterScreenPtr pScreenPriv =
+ (VGAarbiterScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ VGAarbiterScreenKey);
VGAGet(pScreen);
pScrn->LeaveVT = pScreenPriv->LeaveVT;
- (*pScreenPriv->LeaveVT)(index, flags);
+ (*pScreenPriv->LeaveVT) (index, flags);
pScreenPriv->LeaveVT = pScrn->LeaveVT;
pScrn->LeaveVT = VGAarbiterLeaveVT;
VGAPut();
@@ -556,450 +535,389 @@ static void
VGAarbiterFreeScreen(int index, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
- VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, VGAarbiterScreenKey);
+ VGAarbiterScreenPtr pScreenPriv =
+ (VGAarbiterScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ VGAarbiterScreenKey);
VGAGet(pScreen);
- (*pScreenPriv->FreeScreen)(index, flags);
+ (*pScreenPriv->FreeScreen) (index, flags);
VGAPut();
}
static Bool
VGAarbiterCreateGC(GCPtr pGC)
{
- ScreenPtr pScreen = pGC->pScreen;
- VGAarbiterGCPtr pGCPriv = (VGAarbiterGCPtr)dixLookupPrivate(&pGC->devPrivates, VGAarbiterGCKey);
- Bool ret;
+ ScreenPtr pScreen = pGC->pScreen;
+ VGAarbiterGCPtr pGCPriv =
+ (VGAarbiterGCPtr) dixLookupPrivate(&pGC->devPrivates, VGAarbiterGCKey);
+ Bool ret;
SCREEN_PROLOG(CreateGC);
- ret = (*pScreen->CreateGC)(pGC);
+ ret = (*pScreen->CreateGC) (pGC);
GC_WRAP(pGC);
- SCREEN_EPILOG(CreateGC,VGAarbiterCreateGC);
+ SCREEN_EPILOG(CreateGC, VGAarbiterCreateGC);
return ret;
}
/* GC funcs */
static void
-VGAarbiterValidateGC(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw )
+VGAarbiterValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDraw)
{
GC_UNWRAP(pGC);
- (*pGC->funcs->ValidateGC)(pGC, changes, pDraw);
+ (*pGC->funcs->ValidateGC) (pGC, changes, pDraw);
GC_WRAP(pGC);
}
-
static void
VGAarbiterDestroyGC(GCPtr pGC)
{
- GC_UNWRAP (pGC);
- (*pGC->funcs->DestroyGC)(pGC);
- GC_WRAP (pGC);
+ GC_UNWRAP(pGC);
+ (*pGC->funcs->DestroyGC) (pGC);
+ GC_WRAP(pGC);
}
static void
-VGAarbiterChangeGC (
- GCPtr pGC,
- unsigned long mask)
+VGAarbiterChangeGC(GCPtr pGC, unsigned long mask)
{
- GC_UNWRAP (pGC);
+ GC_UNWRAP(pGC);
(*pGC->funcs->ChangeGC) (pGC, mask);
- GC_WRAP (pGC);
+ GC_WRAP(pGC);
}
static void
-VGAarbiterCopyGC (
- GCPtr pGCSrc,
- unsigned long mask,
- GCPtr pGCDst)
+VGAarbiterCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
{
- GC_UNWRAP (pGCDst);
+ GC_UNWRAP(pGCDst);
(*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
- GC_WRAP (pGCDst);
+ GC_WRAP(pGCDst);
}
static void
-VGAarbiterChangeClip (
- GCPtr pGC,
- int type,
- pointer pvalue,
- int nrects )
+VGAarbiterChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects)
{
- GC_UNWRAP (pGC);
+ GC_UNWRAP(pGC);
(*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
- GC_WRAP (pGC);
+ GC_WRAP(pGC);
}
static void
VGAarbiterCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
{
- GC_UNWRAP (pgcDst);
- (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
- GC_WRAP (pgcDst);
+ GC_UNWRAP(pgcDst);
+ (*pgcDst->funcs->CopyClip) (pgcDst, pgcSrc);
+ GC_WRAP(pgcDst);
}
static void
VGAarbiterDestroyClip(GCPtr pGC)
{
- GC_UNWRAP (pGC);
- (* pGC->funcs->DestroyClip)(pGC);
- GC_WRAP (pGC);
+ GC_UNWRAP(pGC);
+ (*pGC->funcs->DestroyClip) (pGC);
+ GC_WRAP(pGC);
}
/* GC Ops */
static void
-VGAarbiterFillSpans(
- DrawablePtr pDraw,
- GC *pGC,
- int nInit,
- DDXPointPtr pptInit,
- int *pwidthInit,
- int fSorted )
+VGAarbiterFillSpans(DrawablePtr pDraw,
+ GC * pGC,
+ int nInit,
+ DDXPointPtr pptInit, int *pwidthInit, int fSorted)
{
ScreenPtr pScreen = pGC->pScreen;
+
GC_UNWRAP(pGC);
VGAGet(pScreen);
- (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
+ (*pGC->ops->FillSpans) (pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
VGAPut();
GC_WRAP(pGC);
}
static void
-VGAarbiterSetSpans(
- DrawablePtr pDraw,
- GCPtr pGC,
- char *pcharsrc,
- register DDXPointPtr ppt,
- int *pwidth,
- int nspans,
- int fSorted )
+VGAarbiterSetSpans(DrawablePtr pDraw,
+ GCPtr pGC,
+ char *pcharsrc,
+ register DDXPointPtr ppt,
+ int *pwidth, int nspans, int fSorted)
{
ScreenPtr pScreen = pGC->pScreen;
+
GC_UNWRAP(pGC);
VGAGet(pScreen);
- (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted);
+ (*pGC->ops->SetSpans) (pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted);
VGAPut();
GC_WRAP(pGC);
}
static void
-VGAarbiterPutImage(
- DrawablePtr pDraw,
- GCPtr pGC,
- int depth,
- int x, int y, int w, int h,
- int leftPad,
- int format,
- char *pImage )
+VGAarbiterPutImage(DrawablePtr pDraw,
+ GCPtr pGC,
+ int depth,
+ int x, int y, int w, int h,
+ int leftPad, int format, char *pImage)
{
ScreenPtr pScreen = pGC->pScreen;
+
GC_UNWRAP(pGC);
VGAGet(pScreen);
- (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h,
- leftPad, format, pImage);
+ (*pGC->ops->PutImage) (pDraw, pGC, depth, x, y, w, h,
+ leftPad, format, pImage);
VGAPut();
GC_WRAP(pGC);
}
static RegionPtr
-VGAarbiterCopyArea(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GC *pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty )
+VGAarbiterCopyArea(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GC * pGC,
+ int srcx, int srcy,
+ int width, int height, int dstx, int dsty)
{
RegionPtr ret;
ScreenPtr pScreen = pGC->pScreen;
+
GC_UNWRAP(pGC);
VGAGet(pScreen);
- ret = (*pGC->ops->CopyArea)(pSrc, pDst,
- pGC, srcx, srcy, width, height, dstx, dsty);
+ ret = (*pGC->ops->CopyArea) (pSrc, pDst,
+ pGC, srcx, srcy, width, height, dstx, dsty);
VGAPut();
GC_WRAP(pGC);
return ret;
}
static RegionPtr
-VGAarbiterCopyPlane(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GCPtr pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty,
- unsigned long bitPlane )
+VGAarbiterCopyPlane(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx, int srcy,
+ int width, int height,
+ int dstx, int dsty, unsigned long bitPlane)
{
RegionPtr ret;
ScreenPtr pScreen = pGC->pScreen;
+
GC_UNWRAP(pGC);
VGAGet(pScreen);
- ret = (*pGC->ops->CopyPlane)(pSrc, pDst, pGC, srcx, srcy,
- width, height, dstx, dsty, bitPlane);
+ ret = (*pGC->ops->CopyPlane) (pSrc, pDst, pGC, srcx, srcy,
+ width, height, dstx, dsty, bitPlane);
VGAPut();
GC_WRAP(pGC);
return ret;
}
static void
-VGAarbiterPolyPoint(
- DrawablePtr pDraw,
- GCPtr pGC,
- int mode,
- int npt,
- xPoint *pptInit )
+VGAarbiterPolyPoint(DrawablePtr pDraw,
+ GCPtr pGC, int mode, int npt, xPoint * pptInit)
{
ScreenPtr pScreen = pGC->pScreen;
+
GC_UNWRAP(pGC);
VGAGet(pScreen);
- (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit);
+ (*pGC->ops->PolyPoint) (pDraw, pGC, mode, npt, pptInit);
VGAPut();
GC_WRAP(pGC);
}
-
static void
-VGAarbiterPolylines(
- DrawablePtr pDraw,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr pptInit )
+VGAarbiterPolylines(DrawablePtr pDraw,
+ GCPtr pGC, int mode, int npt, DDXPointPtr pptInit)
{
ScreenPtr pScreen = pGC->pScreen;
+
GC_UNWRAP(pGC);
VGAGet(pScreen);
- (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit);
+ (*pGC->ops->Polylines) (pDraw, pGC, mode, npt, pptInit);
VGAPut();
GC_WRAP(pGC);
}
static void
-VGAarbiterPolySegment(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nseg,
- xSegment *pSeg )
+VGAarbiterPolySegment(DrawablePtr pDraw, GCPtr pGC, int nseg, xSegment * pSeg)
{
ScreenPtr pScreen = pGC->pScreen;
+
GC_UNWRAP(pGC);
VGAGet(pScreen);
- (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg);
+ (*pGC->ops->PolySegment) (pDraw, pGC, nseg, pSeg);
VGAPut();
GC_WRAP(pGC);
}
static void
-VGAarbiterPolyRectangle(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nRectsInit,
- xRectangle *pRectsInit )
+VGAarbiterPolyRectangle(DrawablePtr pDraw,
+ GCPtr pGC, int nRectsInit, xRectangle *pRectsInit)
{
ScreenPtr pScreen = pGC->pScreen;
+
GC_UNWRAP(pGC);
VGAGet(pScreen);
- (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit);
+ (*pGC->ops->PolyRectangle) (pDraw, pGC, nRectsInit, pRectsInit);
VGAPut();
GC_WRAP(pGC);
}
static void
-VGAarbiterPolyArc(
- DrawablePtr pDraw,
- GCPtr pGC,
- int narcs,
- xArc *parcs )
+VGAarbiterPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
{
ScreenPtr pScreen = pGC->pScreen;
+
GC_UNWRAP(pGC);
VGAGet(pScreen);
- (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs);
+ (*pGC->ops->PolyArc) (pDraw, pGC, narcs, parcs);
VGAPut();
GC_WRAP(pGC);
}
static void
-VGAarbiterFillPolygon(
- DrawablePtr pDraw,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn )
+VGAarbiterFillPolygon(DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape, int mode, int count, DDXPointPtr ptsIn)
{
ScreenPtr pScreen = pGC->pScreen;
+
GC_UNWRAP(pGC);
VGAGet(pScreen);
- (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn);
+ (*pGC->ops->FillPolygon) (pDraw, pGC, shape, mode, count, ptsIn);
VGAPut();
GC_WRAP(pGC);
}
static void
-VGAarbiterPolyFillRect(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nrectFill,
- xRectangle *prectInit)
+VGAarbiterPolyFillRect(DrawablePtr pDraw,
+ GCPtr pGC, int nrectFill, xRectangle *prectInit)
{
ScreenPtr pScreen = pGC->pScreen;
+
GC_UNWRAP(pGC);
VGAGet(pScreen);
- (*pGC->ops->PolyFillRect)(pDraw, pGC, nrectFill, prectInit);
+ (*pGC->ops->PolyFillRect) (pDraw, pGC, nrectFill, prectInit);
VGAPut();
GC_WRAP(pGC);
}
static void
-VGAarbiterPolyFillArc(
- DrawablePtr pDraw,
- GCPtr pGC,
- int narcs,
- xArc *parcs )
+VGAarbiterPolyFillArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
{
ScreenPtr pScreen = pGC->pScreen;
+
GC_UNWRAP(pGC);
VGAGet(pScreen);
- (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs);
+ (*pGC->ops->PolyFillArc) (pDraw, pGC, narcs, parcs);
VGAPut();
GC_WRAP(pGC);
}
static int
-VGAarbiterPolyText8(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- char *chars )
+VGAarbiterPolyText8(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars)
{
int ret;
ScreenPtr pScreen = pGC->pScreen;
+
GC_UNWRAP(pGC);
VGAGet(pScreen);
- ret = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars);
+ ret = (*pGC->ops->PolyText8) (pDraw, pGC, x, y, count, chars);
VGAPut();
GC_WRAP(pGC);
return ret;
}
static int
-VGAarbiterPolyText16(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- unsigned short *chars )
+VGAarbiterPolyText16(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, unsigned short *chars)
{
int ret;
ScreenPtr pScreen = pGC->pScreen;
+
GC_UNWRAP(pGC);
VGAGet(pScreen);
- ret = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars);
+ ret = (*pGC->ops->PolyText16) (pDraw, pGC, x, y, count, chars);
VGAPut();
GC_WRAP(pGC);
return ret;
}
static void
-VGAarbiterImageText8(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- char *chars )
+VGAarbiterImageText8(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars)
{
ScreenPtr pScreen = pGC->pScreen;
+
GC_UNWRAP(pGC);
VGAGet(pScreen);
- (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars);
+ (*pGC->ops->ImageText8) (pDraw, pGC, x, y, count, chars);
VGAPut();
GC_WRAP(pGC);
}
static void
-VGAarbiterImageText16(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- unsigned short *chars )
+VGAarbiterImageText16(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, unsigned short *chars)
{
ScreenPtr pScreen = pGC->pScreen;
+
GC_UNWRAP(pGC);
VGAGet(pScreen);
- (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars);
+ (*pGC->ops->ImageText16) (pDraw, pGC, x, y, count, chars);
VGAPut();
GC_WRAP(pGC);
}
-
static void
-VGAarbiterImageGlyphBlt(
- DrawablePtr pDraw,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase )
+VGAarbiterImageGlyphBlt(DrawablePtr pDraw,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase)
{
ScreenPtr pScreen = pGC->pScreen;
+
GC_UNWRAP(pGC);
VGAGet(pScreen);
- (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, xInit, yInit,
- nglyph, ppci, pglyphBase);
+ (*pGC->ops->ImageGlyphBlt) (pDraw, pGC, xInit, yInit,
+ nglyph, ppci, pglyphBase);
VGAPut();
GC_WRAP(pGC);
}
static void
-VGAarbiterPolyGlyphBlt(
- DrawablePtr pDraw,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase )
+VGAarbiterPolyGlyphBlt(DrawablePtr pDraw,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase)
{
ScreenPtr pScreen = pGC->pScreen;
+
GC_UNWRAP(pGC);
VGAGet(pScreen);
- (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, xInit, yInit,
- nglyph, ppci, pglyphBase);
+ (*pGC->ops->PolyGlyphBlt) (pDraw, pGC, xInit, yInit,
+ nglyph, ppci, pglyphBase);
VGAPut();
GC_WRAP(pGC);
}
static void
-VGAarbiterPushPixels(
- GCPtr pGC,
- PixmapPtr pBitMap,
- DrawablePtr pDraw,
- int dx, int dy, int xOrg, int yOrg )
+VGAarbiterPushPixels(GCPtr pGC,
+ PixmapPtr pBitMap,
+ DrawablePtr pDraw, int dx, int dy, int xOrg, int yOrg)
{
ScreenPtr pScreen = pGC->pScreen;
+
GC_UNWRAP(pGC);
VGAGet(pScreen);
- (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
+ (*pGC->ops->PushPixels) (pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
VGAPut();
GC_WRAP(pGC);
}
-
/* miSpriteFuncs */
static Bool
-VGAarbiterSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCur)
+VGAarbiterSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
+ CursorPtr pCur)
{
Bool val;
+
SPRITE_PROLOG;
VGAGet(pScreen);
val = PointPriv->spriteFuncs->RealizeCursor(pDev, pScreen, pCur);
@@ -1009,9 +927,11 @@ VGAarbiterSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pC
}
static Bool
-VGAarbiterSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCur)
+VGAarbiterSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
+ CursorPtr pCur)
{
Bool val;
+
SPRITE_PROLOG;
VGAGet(pScreen);
val = PointPriv->spriteFuncs->UnrealizeCursor(pDev, pScreen, pCur);
@@ -1021,7 +941,8 @@ VGAarbiterSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr
}
static void
-VGAarbiterSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCur, int x, int y)
+VGAarbiterSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCur,
+ int x, int y)
{
SPRITE_PROLOG;
VGAGet(pScreen);
@@ -1044,6 +965,7 @@ static Bool
VGAarbiterDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
{
Bool val;
+
SPRITE_PROLOG;
VGAGet(pScreen);
val = PointPriv->spriteFuncs->DeviceCursorInitialize(pDev, pScreen);
@@ -1064,49 +986,49 @@ VGAarbiterDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
static void
VGAarbiterComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask,
- PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask,
- INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width,
- CARD16 height)
+ PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask,
+ INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width,
+ CARD16 height)
{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- PictureScreenPtr ps = GetPictureScreen(pScreen);
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
PICTURE_PROLOGUE(Composite);
VGAGet(pScreen);
(*ps->Composite) (op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst,
- yDst, width, height);
+ yDst, width, height);
VGAPut();
PICTURE_EPILOGUE(Composite, VGAarbiterComposite);
}
static void
VGAarbiterGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
- PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist,
- GlyphListPtr list, GlyphPtr *glyphs)
+ PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist,
+ GlyphListPtr list, GlyphPtr * glyphs)
{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- PictureScreenPtr ps = GetPictureScreen(pScreen);
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
PICTURE_PROLOGUE(Glyphs);
VGAGet(pScreen);
- (*ps->Glyphs)(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
+ (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
VGAPut();
- PICTURE_EPILOGUE (Glyphs, VGAarbiterGlyphs);
+ PICTURE_EPILOGUE(Glyphs, VGAarbiterGlyphs);
}
static void
-VGAarbiterCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor *color, int nRect,
- xRectangle *rects)
+VGAarbiterCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor * color,
+ int nRect, xRectangle *rects)
{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- PictureScreenPtr ps = GetPictureScreen(pScreen);
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
PICTURE_PROLOGUE(CompositeRects);
VGAGet(pScreen);
- (*ps->CompositeRects)(op, pDst, color, nRect, rects);
+ (*ps->CompositeRects) (op, pDst, color, nRect, rects);
VGAPut();
- PICTURE_EPILOGUE (CompositeRects, VGAarbiterCompositeRects);
+ PICTURE_EPILOGUE(CompositeRects, VGAarbiterCompositeRects);
}
diff --git a/xorg-server/hw/xfree86/common/xf86VGAarbiterPriv.h b/xorg-server/hw/xfree86/common/xf86VGAarbiterPriv.h
index 13fde5e79..2513ce65d 100644
--- a/xorg-server/hw/xfree86/common/xf86VGAarbiterPriv.h
+++ b/xorg-server/hw/xfree86/common/xf86VGAarbiterPriv.h
@@ -1,253 +1,268 @@
-/*
- * Copyright (c) 2009 Tiago Vignatti
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use,
- * copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-#include <X11/X.h>
-#include "colormapst.h"
-#include "scrnintstr.h"
-#include "screenint.h"
-#include "gcstruct.h"
-#include "pixmapstr.h"
-#include "pixmap.h"
-#include "windowstr.h"
-#include "window.h"
-#include "xf86str.h"
-#include "mipointer.h"
-#include "mipointrst.h"
-# include "picturestr.h"
-
-
-#define WRAP_SCREEN(x,y) {pScreenPriv->x = pScreen->x; pScreen->x = y;}
-
-#define UNWRAP_SCREEN(x) pScreen->x = pScreenPriv->x
-
-#define SCREEN_PROLOG(x) pScreen->x = ((VGAarbiterScreenPtr) \
- dixLookupPrivate(&(pScreen)->devPrivates, VGAarbiterScreenKey))->x
-
-#define SCREEN_EPILOG(x,y) pScreen->x = y;
-
-#define WRAP_PICT(x,y) if (ps) {pScreenPriv->x = ps->x;\
- ps->x = y;}
-
-#define UNWRAP_PICT(x) if (ps) {ps->x = pScreenPriv->x;}
-
-#define PICTURE_PROLOGUE(field) ps->field = \
- ((VGAarbiterScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, \
- VGAarbiterScreenKey))->field
-
-#define PICTURE_EPILOGUE(field, wrap) ps->field = wrap
-
-#define WRAP_SCREEN_INFO(x,y) do {pScreenPriv->x = pScrn->x; pScrn->x = y;} while(0)
-
-#define UNWRAP_SCREEN_INFO(x) pScrn->x = pScreenPriv->x
-
-#define SPRITE_PROLOG miPointerScreenPtr PointPriv = \
- (miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates, \
- miPointerScreenKey); VGAarbiterScreenPtr pScreenPriv = \
- ((VGAarbiterScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, \
- VGAarbiterScreenKey)); PointPriv->spriteFuncs = pScreenPriv->miSprite;
-
-#define SPRITE_EPILOG pScreenPriv->miSprite = PointPriv->spriteFuncs;\
- PointPriv->spriteFuncs = &VGAarbiterSpriteFuncs;
-
-#define WRAP_SPRITE do { pScreenPriv->miSprite = PointPriv->spriteFuncs;\
- PointPriv->spriteFuncs = &VGAarbiterSpriteFuncs; \
- } while (0)
-
-#define UNWRAP_SPRITE PointPriv->spriteFuncs = pScreenPriv->miSprite
-
-#define GC_WRAP(x) pGCPriv->wrapOps = (x)->ops;\
- pGCPriv->wrapFuncs = (x)->funcs; (x)->ops = &VGAarbiterGCOps;\
- (x)->funcs = &VGAarbiterGCFuncs;
-
-#define GC_UNWRAP(x) VGAarbiterGCPtr pGCPriv = \
- (VGAarbiterGCPtr)dixLookupPrivate(&(x)->devPrivates, VGAarbiterGCKey);\
- (x)->ops = pGCPriv->wrapOps; (x)->funcs = pGCPriv->wrapFuncs;
-
-static inline void
-VGAGet(ScreenPtr pScreen) {
- pci_device_vgaarb_set_target(xf86Screens[pScreen->myNum]->vgaDev);
- pci_device_vgaarb_lock();
-}
-
-static inline void
-VGAPut(void) {
- pci_device_vgaarb_unlock();
-}
-
-typedef struct _VGAarbiterScreen {
- CreateGCProcPtr CreateGC;
- CloseScreenProcPtr CloseScreen;
- ScreenBlockHandlerProcPtr BlockHandler;
- ScreenWakeupHandlerProcPtr WakeupHandler;
- GetImageProcPtr GetImage;
- GetSpansProcPtr GetSpans;
- SourceValidateProcPtr SourceValidate;
- CopyWindowProcPtr CopyWindow;
- ClearToBackgroundProcPtr ClearToBackground;
- CreatePixmapProcPtr CreatePixmap;
- SaveScreenProcPtr SaveScreen;
- /* Colormap */
- StoreColorsProcPtr StoreColors;
- /* Cursor */
- DisplayCursorProcPtr DisplayCursor;
- RealizeCursorProcPtr RealizeCursor;
- UnrealizeCursorProcPtr UnrealizeCursor;
- RecolorCursorProcPtr RecolorCursor;
- SetCursorPositionProcPtr SetCursorPosition;
- void (*AdjustFrame)(int,int,int,int);
- Bool (*SwitchMode)(int, DisplayModePtr,int);
- Bool (*EnterVT)(int, int);
- void (*LeaveVT)(int, int);
- void (*FreeScreen)(int, int);
- miPointerSpriteFuncPtr miSprite;
- CompositeProcPtr Composite;
- GlyphsProcPtr Glyphs;
- CompositeRectsProcPtr CompositeRects;
-} VGAarbiterScreenRec, *VGAarbiterScreenPtr;
-
-typedef struct _VGAarbiterGC {
- GCOps *wrapOps;
- GCFuncs *wrapFuncs;
-} VGAarbiterGCRec, *VGAarbiterGCPtr;
-
-/* Screen funcs */
-static void VGAarbiterBlockHandler(int i, pointer blockData, pointer pTimeout, pointer pReadmask);
-static void VGAarbiterWakeupHandler(int i, pointer blockData, unsigned long result, pointer pReadmask);
-static Bool VGAarbiterCloseScreen (int i, ScreenPtr pScreen);
-static void VGAarbiterGetImage (DrawablePtr pDrawable, int sx, int sy, int w,
- int h, unsigned int format, unsigned long planemask, char *pdstLine);
-static void VGAarbiterGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr
- ppt, int *pwidth, int nspans, char *pdstStart);
-static void VGAarbiterSourceValidate (DrawablePtr pDrawable, int x, int y,
- int width, int height, unsigned int subWindowMode);
-static void VGAarbiterCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
- RegionPtr prgnSrc);
-static void VGAarbiterClearToBackground (WindowPtr pWin, int x, int y, int w,
- int h, Bool generateExposures);
-static PixmapPtr VGAarbiterCreatePixmap(ScreenPtr pScreen, int w, int h,
- int depth, unsigned int usage_hint);
-static Bool VGAarbiterCreateGC(GCPtr pGC);
-static Bool VGAarbiterSaveScreen(ScreenPtr pScreen, Bool unblank);
-static void VGAarbiterStoreColors (ColormapPtr pmap, int ndef, xColorItem
- *pdefs);
-static void VGAarbiterRecolorCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
- CursorPtr pCurs, Bool displayed);
-static Bool VGAarbiterRealizeCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
- CursorPtr pCursor);
-static Bool VGAarbiterUnrealizeCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
- CursorPtr pCursor);
-static Bool VGAarbiterDisplayCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
- CursorPtr pCursor);
-static Bool VGAarbiterSetCursorPosition (DeviceIntPtr pDev, ScreenPtr
- pScreen, int x, int y, Bool generateEvent);
-static void VGAarbiterAdjustFrame(int index, int x, int y, int flags);
-static Bool VGAarbiterSwitchMode(int index, DisplayModePtr mode, int flags);
-static Bool VGAarbiterEnterVT(int index, int flags);
-static void VGAarbiterLeaveVT(int index, int flags);
-static void VGAarbiterFreeScreen(int index, int flags);
-
-/* GC funcs */
-static void VGAarbiterValidateGC(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw);
-static void VGAarbiterChangeGC(GCPtr pGC, unsigned long mask);
-static void VGAarbiterCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
-static void VGAarbiterDestroyGC(GCPtr pGC);
-static void VGAarbiterChangeClip(GCPtr pGC, int type, pointer pvalue,
- int nrects);
-static void VGAarbiterDestroyClip(GCPtr pGC);
-static void VGAarbiterCopyClip(GCPtr pgcDst, GCPtr pgcSrc);
-
-/* GC ops */
-static void VGAarbiterFillSpans( DrawablePtr pDraw, GC *pGC, int nInit,
- DDXPointPtr pptInit, int *pwidthInit, int fSorted);
-static void VGAarbiterSetSpans(DrawablePtr pDraw, GCPtr pGC, char *pcharsrc,
- register DDXPointPtr ppt, int *pwidth, int nspans, int fSorted);
-static void VGAarbiterPutImage(DrawablePtr pDraw, GCPtr pGC, int depth,
- int x, int y, int w, int h, int leftPad, int format, char *pImage);
-static RegionPtr VGAarbiterCopyArea(DrawablePtr pSrc, DrawablePtr pDst,
- GC *pGC, int srcx, int srcy, int width, int height, int dstx, int dsty);
-static RegionPtr VGAarbiterCopyPlane(DrawablePtr pSrc, DrawablePtr pDst,
- GCPtr pGC, int srcx, int srcy, int width, int height, int dstx, int dsty,
- unsigned long bitPlane);
-static void VGAarbiterPolyPoint(DrawablePtr pDraw, GCPtr pGC, int mode,
- int npt, xPoint *pptInit);
-static void VGAarbiterPolylines(DrawablePtr pDraw, GCPtr pGC, int mode,
- int npt, DDXPointPtr pptInit);
-static void VGAarbiterPolySegment(DrawablePtr pDraw, GCPtr pGC, int nseg,
- xSegment *pSeg);
-static void VGAarbiterPolyRectangle(DrawablePtr pDraw, GCPtr pGC,
- int nRectsInit, xRectangle *pRectsInit);
-static void VGAarbiterPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs,
- xArc *parcs);
-static void VGAarbiterFillPolygon(DrawablePtr pDraw, GCPtr pGC, int shape,
- int mode, int count, DDXPointPtr ptsIn);
-static void VGAarbiterPolyFillRect( DrawablePtr pDraw, GCPtr pGC,
- int nrectFill, xRectangle *prectInit);
-static void VGAarbiterPolyFillArc(DrawablePtr pDraw, GCPtr pGC, int narcs,
- xArc *parcs);
-static int VGAarbiterPolyText8(DrawablePtr pDraw, GCPtr pGC, int x, int y,
- int count, char *chars);
-static int VGAarbiterPolyText16(DrawablePtr pDraw, GCPtr pGC, int x, int y,
- int count, unsigned short *chars);
-static void VGAarbiterImageText8(DrawablePtr pDraw, GCPtr pGC, int x, int y,
- int count, char *chars);
-static void VGAarbiterImageText16(DrawablePtr pDraw, GCPtr pGC, int x, int y,
- int count, unsigned short *chars);
-static void VGAarbiterImageGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int xInit,
- int yInit, unsigned int nglyph, CharInfoPtr *ppci, pointer pglyphBase);
-static void VGAarbiterPolyGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int xInit,
- int yInit, unsigned int nglyph, CharInfoPtr *ppci, pointer pglyphBase);
-static void VGAarbiterPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr
- pDraw, int dx, int dy, int xOrg, int yOrg);
-
-/* miSpriteFuncs */
-static Bool VGAarbiterSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr
- pScreen, CursorPtr pCur);
-static Bool VGAarbiterSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr
- pScreen, CursorPtr pCur);
-static void VGAarbiterSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
- CursorPtr pCur, int x, int y);
-static void VGAarbiterSpriteMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
- int x, int y);
-static Bool VGAarbiterDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen);
-static void VGAarbiterDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen);
-
-
-static void VGAarbiterComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask,
- PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask,
- INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
-static void VGAarbiterGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
- PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist, GlyphListPtr
- list, GlyphPtr *glyphs);
-static void VGAarbiterCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor
- *color, int nRect, xRectangle *rects);
+/*
+ * Copyright (c) 2009 Tiago Vignatti
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include <X11/X.h>
+#include "colormapst.h"
+#include "scrnintstr.h"
+#include "screenint.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "pixmap.h"
+#include "windowstr.h"
+#include "window.h"
+#include "xf86str.h"
+#include "mipointer.h"
+#include "mipointrst.h"
+#include "picturestr.h"
+
+#define WRAP_SCREEN(x,y) {pScreenPriv->x = pScreen->x; pScreen->x = y;}
+
+#define UNWRAP_SCREEN(x) pScreen->x = pScreenPriv->x
+
+#define SCREEN_PROLOG(x) pScreen->x = ((VGAarbiterScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, VGAarbiterScreenKey))->x
+
+#define SCREEN_EPILOG(x,y) pScreen->x = y;
+
+#define WRAP_PICT(x,y) if (ps) {pScreenPriv->x = ps->x;\
+ ps->x = y;}
+
+#define UNWRAP_PICT(x) if (ps) {ps->x = pScreenPriv->x;}
+
+#define PICTURE_PROLOGUE(field) ps->field = \
+ ((VGAarbiterScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, \
+ VGAarbiterScreenKey))->field
+
+#define PICTURE_EPILOGUE(field, wrap) ps->field = wrap
+
+#define WRAP_SCREEN_INFO(x,y) do {pScreenPriv->x = pScrn->x; pScrn->x = y;} while(0)
+
+#define UNWRAP_SCREEN_INFO(x) pScrn->x = pScreenPriv->x
+
+#define SPRITE_PROLOG miPointerScreenPtr PointPriv = \
+ (miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates, \
+ miPointerScreenKey); VGAarbiterScreenPtr pScreenPriv = \
+ ((VGAarbiterScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, \
+ VGAarbiterScreenKey)); PointPriv->spriteFuncs = pScreenPriv->miSprite;
+
+#define SPRITE_EPILOG pScreenPriv->miSprite = PointPriv->spriteFuncs;\
+ PointPriv->spriteFuncs = &VGAarbiterSpriteFuncs;
+
+#define WRAP_SPRITE do { pScreenPriv->miSprite = PointPriv->spriteFuncs;\
+ PointPriv->spriteFuncs = &VGAarbiterSpriteFuncs; \
+ } while (0)
+
+#define UNWRAP_SPRITE PointPriv->spriteFuncs = pScreenPriv->miSprite
+
+#define GC_WRAP(x) pGCPriv->wrapOps = (x)->ops;\
+ pGCPriv->wrapFuncs = (x)->funcs; (x)->ops = &VGAarbiterGCOps;\
+ (x)->funcs = &VGAarbiterGCFuncs;
+
+#define GC_UNWRAP(x) VGAarbiterGCPtr pGCPriv = \
+ (VGAarbiterGCPtr)dixLookupPrivate(&(x)->devPrivates, VGAarbiterGCKey);\
+ (x)->ops = pGCPriv->wrapOps; (x)->funcs = pGCPriv->wrapFuncs;
+
+static inline void
+VGAGet(ScreenPtr pScreen)
+{
+ pci_device_vgaarb_set_target(xf86Screens[pScreen->myNum]->vgaDev);
+ pci_device_vgaarb_lock();
+}
+
+static inline void
+VGAPut(void)
+{
+ pci_device_vgaarb_unlock();
+}
+
+typedef struct _VGAarbiterScreen {
+ CreateGCProcPtr CreateGC;
+ CloseScreenProcPtr CloseScreen;
+ ScreenBlockHandlerProcPtr BlockHandler;
+ ScreenWakeupHandlerProcPtr WakeupHandler;
+ GetImageProcPtr GetImage;
+ GetSpansProcPtr GetSpans;
+ SourceValidateProcPtr SourceValidate;
+ CopyWindowProcPtr CopyWindow;
+ ClearToBackgroundProcPtr ClearToBackground;
+ CreatePixmapProcPtr CreatePixmap;
+ SaveScreenProcPtr SaveScreen;
+ /* Colormap */
+ StoreColorsProcPtr StoreColors;
+ /* Cursor */
+ DisplayCursorProcPtr DisplayCursor;
+ RealizeCursorProcPtr RealizeCursor;
+ UnrealizeCursorProcPtr UnrealizeCursor;
+ RecolorCursorProcPtr RecolorCursor;
+ SetCursorPositionProcPtr SetCursorPosition;
+ void (*AdjustFrame) (int, int, int, int);
+ Bool (*SwitchMode) (int, DisplayModePtr, int);
+ Bool (*EnterVT) (int, int);
+ void (*LeaveVT) (int, int);
+ void (*FreeScreen) (int, int);
+ miPointerSpriteFuncPtr miSprite;
+ CompositeProcPtr Composite;
+ GlyphsProcPtr Glyphs;
+ CompositeRectsProcPtr CompositeRects;
+} VGAarbiterScreenRec, *VGAarbiterScreenPtr;
+
+typedef struct _VGAarbiterGC {
+ GCOps *wrapOps;
+ GCFuncs *wrapFuncs;
+} VGAarbiterGCRec, *VGAarbiterGCPtr;
+
+/* Screen funcs */
+static void VGAarbiterBlockHandler(int i, pointer blockData, pointer pTimeout,
+ pointer pReadmask);
+static void VGAarbiterWakeupHandler(int i, pointer blockData,
+ unsigned long result, pointer pReadmask);
+static Bool VGAarbiterCloseScreen(int i, ScreenPtr pScreen);
+static void VGAarbiterGetImage(DrawablePtr pDrawable, int sx, int sy, int w,
+ int h, unsigned int format,
+ unsigned long planemask, char *pdstLine);
+static void VGAarbiterGetSpans(DrawablePtr pDrawable, int wMax, DDXPointPtr ppt,
+ int *pwidth, int nspans, char *pdstStart);
+static void VGAarbiterSourceValidate(DrawablePtr pDrawable, int x, int y,
+ int width, int height,
+ unsigned int subWindowMode);
+static void VGAarbiterCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc);
+static void VGAarbiterClearToBackground(WindowPtr pWin, int x, int y, int w,
+ int h, Bool generateExposures);
+static PixmapPtr VGAarbiterCreatePixmap(ScreenPtr pScreen, int w, int h,
+ int depth, unsigned int usage_hint);
+static Bool VGAarbiterCreateGC(GCPtr pGC);
+static Bool VGAarbiterSaveScreen(ScreenPtr pScreen, Bool unblank);
+static void VGAarbiterStoreColors(ColormapPtr pmap, int ndef, xColorItem
+ * pdefs);
+static void VGAarbiterRecolorCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
+ CursorPtr pCurs, Bool displayed);
+static Bool VGAarbiterRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
+ CursorPtr pCursor);
+static Bool VGAarbiterUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
+ CursorPtr pCursor);
+static Bool VGAarbiterDisplayCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
+ CursorPtr pCursor);
+static Bool VGAarbiterSetCursorPosition(DeviceIntPtr pDev, ScreenPtr
+ pScreen, int x, int y,
+ Bool generateEvent);
+static void VGAarbiterAdjustFrame(int index, int x, int y, int flags);
+static Bool VGAarbiterSwitchMode(int index, DisplayModePtr mode, int flags);
+static Bool VGAarbiterEnterVT(int index, int flags);
+static void VGAarbiterLeaveVT(int index, int flags);
+static void VGAarbiterFreeScreen(int index, int flags);
+
+/* GC funcs */
+static void VGAarbiterValidateGC(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDraw);
+static void VGAarbiterChangeGC(GCPtr pGC, unsigned long mask);
+static void VGAarbiterCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
+static void VGAarbiterDestroyGC(GCPtr pGC);
+static void VGAarbiterChangeClip(GCPtr pGC, int type, pointer pvalue,
+ int nrects);
+static void VGAarbiterDestroyClip(GCPtr pGC);
+static void VGAarbiterCopyClip(GCPtr pgcDst, GCPtr pgcSrc);
+
+/* GC ops */
+static void VGAarbiterFillSpans(DrawablePtr pDraw, GC * pGC, int nInit,
+ DDXPointPtr pptInit, int *pwidthInit,
+ int fSorted);
+static void VGAarbiterSetSpans(DrawablePtr pDraw, GCPtr pGC, char *pcharsrc,
+ register DDXPointPtr ppt, int *pwidth,
+ int nspans, int fSorted);
+static void VGAarbiterPutImage(DrawablePtr pDraw, GCPtr pGC, int depth, int x,
+ int y, int w, int h, int leftPad, int format,
+ char *pImage);
+static RegionPtr VGAarbiterCopyArea(DrawablePtr pSrc, DrawablePtr pDst,
+ GC * pGC, int srcx, int srcy, int width,
+ int height, int dstx, int dsty);
+static RegionPtr VGAarbiterCopyPlane(DrawablePtr pSrc, DrawablePtr pDst,
+ GCPtr pGC, int srcx, int srcy, int width,
+ int height, int dstx, int dsty,
+ unsigned long bitPlane);
+static void VGAarbiterPolyPoint(DrawablePtr pDraw, GCPtr pGC, int mode, int npt,
+ xPoint * pptInit);
+static void VGAarbiterPolylines(DrawablePtr pDraw, GCPtr pGC, int mode, int npt,
+ DDXPointPtr pptInit);
+static void VGAarbiterPolySegment(DrawablePtr pDraw, GCPtr pGC, int nseg,
+ xSegment * pSeg);
+static void VGAarbiterPolyRectangle(DrawablePtr pDraw, GCPtr pGC,
+ int nRectsInit, xRectangle *pRectsInit);
+static void VGAarbiterPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs,
+ xArc * parcs);
+static void VGAarbiterFillPolygon(DrawablePtr pDraw, GCPtr pGC, int shape,
+ int mode, int count, DDXPointPtr ptsIn);
+static void VGAarbiterPolyFillRect(DrawablePtr pDraw, GCPtr pGC, int nrectFill,
+ xRectangle *prectInit);
+static void VGAarbiterPolyFillArc(DrawablePtr pDraw, GCPtr pGC, int narcs,
+ xArc * parcs);
+static int VGAarbiterPolyText8(DrawablePtr pDraw, GCPtr pGC, int x, int y,
+ int count, char *chars);
+static int VGAarbiterPolyText16(DrawablePtr pDraw, GCPtr pGC, int x, int y,
+ int count, unsigned short *chars);
+static void VGAarbiterImageText8(DrawablePtr pDraw, GCPtr pGC, int x, int y,
+ int count, char *chars);
+static void VGAarbiterImageText16(DrawablePtr pDraw, GCPtr pGC, int x, int y,
+ int count, unsigned short *chars);
+static void VGAarbiterImageGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int xInit,
+ int yInit, unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase);
+static void VGAarbiterPolyGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int xInit,
+ int yInit, unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase);
+static void VGAarbiterPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr
+ pDraw, int dx, int dy, int xOrg, int yOrg);
+
+/* miSpriteFuncs */
+static Bool VGAarbiterSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr
+ pScreen, CursorPtr pCur);
+static Bool VGAarbiterSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr
+ pScreen, CursorPtr pCur);
+static void VGAarbiterSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
+ CursorPtr pCur, int x, int y);
+static void VGAarbiterSpriteMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
+ int x, int y);
+static Bool VGAarbiterDeviceCursorInitialize(DeviceIntPtr pDev,
+ ScreenPtr pScreen);
+static void VGAarbiterDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen);
+
+static void VGAarbiterComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask,
+ PicturePtr pDst, INT16 xSrc, INT16 ySrc,
+ INT16 xMask, INT16 yMask, INT16 xDst,
+ INT16 yDst, CARD16 width, CARD16 height);
+static void VGAarbiterGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
+ int nlist, GlyphListPtr list, GlyphPtr * glyphs);
+static void VGAarbiterCompositeRects(CARD8 op, PicturePtr pDst,
+ xRenderColor * color, int nRect,
+ xRectangle *rects);
diff --git a/xorg-server/hw/xfree86/common/xf86VidMode.c b/xorg-server/hw/xfree86/common/xf86VidMode.c
index 2ae5484e3..13ffe061c 100644
--- a/xorg-server/hw/xfree86/common/xf86VidMode.c
+++ b/xorg-server/hw/xfree86/common/xf86VidMode.c
@@ -61,20 +61,20 @@ VidModeExtensionInit(ScreenPtr pScreen)
{
#ifdef XF86VIDMODE
VidModePtr pVidMode;
-
+
if (!xf86GetVidModeEnabled()) {
- DebugF("!xf86GetVidModeEnabled()\n");
- return FALSE;
+ DebugF("!xf86GetVidModeEnabled()\n");
+ return FALSE;
}
VidModeKey = &VidModeKeyRec;
if (!dixRegisterPrivateKey(&VidModeKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
+ return FALSE;
pVidMode = calloc(sizeof(VidModeRec), 1);
if (!pVidMode)
- return FALSE;
+ return FALSE;
dixSetPrivate(&pScreen->devPrivates, VidModeKey, pVidMode);
@@ -90,7 +90,6 @@ VidModeExtensionInit(ScreenPtr pScreen)
#endif
}
-
#ifdef XF86VIDMODE
static Bool
@@ -100,14 +99,14 @@ VidModeClose(int i, ScreenPtr pScreen)
/* This shouldn't happen */
if (!pVidMode)
- return FALSE;
+ return FALSE;
pScreen->CloseScreen = pVidMode->CloseScreen;
if (--VidModeCount == 0) {
- free(dixLookupPrivate(&pScreen->devPrivates, VidModeKey));
- dixSetPrivate(&pScreen->devPrivates, VidModeKey, NULL);
- VidModeKey = NULL;
+ free(dixLookupPrivate(&pScreen->devPrivates, VidModeKey));
+ dixSetPrivate(&pScreen->devPrivates, VidModeKey, NULL);
+ VidModeKey = NULL;
}
return pScreen->CloseScreen(i, pScreen);
}
@@ -119,22 +118,22 @@ VidModeAvailable(int scrnIndex)
VidModePtr pVidMode;
if (VidModeKey == NULL) {
- DebugF("VidModeKey == NULL\n");
- return FALSE;
+ DebugF("VidModeKey == NULL\n");
+ return FALSE;
}
-
+
pScrn = xf86Screens[scrnIndex];
if (pScrn == NULL) {
- DebugF("pScrn == NULL\n");
- return FALSE;
+ DebugF("pScrn == NULL\n");
+ return FALSE;
}
-
+
pVidMode = VMPTR(pScrn->pScreen);
if (pVidMode)
- return TRUE;
+ return TRUE;
else {
- DebugF("pVidMode == NULL\n");
- return FALSE;
+ DebugF("pVidMode == NULL\n");
+ return FALSE;
}
}
@@ -144,15 +143,15 @@ VidModeGetCurrentModeline(int scrnIndex, pointer *mode, int *dotClock)
ScrnInfoPtr pScrn;
if (!VidModeAvailable(scrnIndex))
- return FALSE;
+ return FALSE;
pScrn = xf86Screens[scrnIndex];
if (pScrn->currentMode) {
- *mode = (pointer)(pScrn->currentMode);
- *dotClock = pScrn->currentMode->Clock;
+ *mode = (pointer) (pScrn->currentMode);
+ *dotClock = pScrn->currentMode->Clock;
- return TRUE;
+ return TRUE;
}
return FALSE;
}
@@ -163,13 +162,13 @@ VidModeGetDotClock(int scrnIndex, int Clock)
ScrnInfoPtr pScrn;
if (!VidModeAvailable(scrnIndex))
- return 0;
+ return 0;
pScrn = xf86Screens[scrnIndex];
if ((pScrn->progClock) || (Clock >= MAXCLOCKS))
- return Clock;
- else
- return pScrn->clock[Clock];
+ return Clock;
+ else
+ return pScrn->clock[Clock];
}
int
@@ -178,15 +177,16 @@ VidModeGetNumOfClocks(int scrnIndex, Bool *progClock)
ScrnInfoPtr pScrn;
if (!VidModeAvailable(scrnIndex))
- return 0;
+ return 0;
pScrn = xf86Screens[scrnIndex];
- if (pScrn->progClock){
- *progClock = TRUE;
- return 0;
- } else {
- *progClock = FALSE;
- return pScrn->numClocks;
+ if (pScrn->progClock) {
+ *progClock = TRUE;
+ return 0;
+ }
+ else {
+ *progClock = FALSE;
+ return pScrn->numClocks;
}
}
@@ -197,20 +197,19 @@ VidModeGetClocks(int scrnIndex, int *Clocks)
int i;
if (!VidModeAvailable(scrnIndex))
- return FALSE;
+ return FALSE;
pScrn = xf86Screens[scrnIndex];
if (pScrn->progClock)
- return FALSE;
+ return FALSE;
- for (i = 0; i < pScrn->numClocks; i++)
- *Clocks++ = pScrn->clock[i];
+ for (i = 0; i < pScrn->numClocks; i++)
+ *Clocks++ = pScrn->clock[i];
return TRUE;
}
-
Bool
VidModeGetFirstModeline(int scrnIndex, pointer *mode, int *dotClock)
{
@@ -218,20 +217,20 @@ VidModeGetFirstModeline(int scrnIndex, pointer *mode, int *dotClock)
VidModePtr pVidMode;
if (!VidModeAvailable(scrnIndex))
- return FALSE;
+ return FALSE;
pScrn = xf86Screens[scrnIndex];
if (pScrn->modes == NULL)
- return FALSE;
+ return FALSE;
pVidMode = VMPTR(pScrn->pScreen);
pVidMode->First = pScrn->modes;
- pVidMode->Next = pVidMode->First->next;
+ pVidMode->Next = pVidMode->First->next;
if (pVidMode->First->status == MODE_OK) {
- *mode = (pointer)(pVidMode->First);
- *dotClock = VidModeGetDotClock(scrnIndex, pVidMode->First->Clock);
- return TRUE;
+ *mode = (pointer) (pVidMode->First);
+ *dotClock = VidModeGetDotClock(scrnIndex, pVidMode->First->Clock);
+ return TRUE;
}
return VidModeGetNextModeline(scrnIndex, mode, dotClock);
@@ -245,20 +244,20 @@ VidModeGetNextModeline(int scrnIndex, pointer *mode, int *dotClock)
DisplayModePtr p;
if (!VidModeAvailable(scrnIndex))
- return FALSE;
+ return FALSE;
pScrn = xf86Screens[scrnIndex];
pVidMode = VMPTR(pScrn->pScreen);
for (p = pVidMode->Next; p != NULL && p != pVidMode->First; p = p->next) {
- if (p->status == MODE_OK) {
- pVidMode->Next = p->next;
- *mode = (pointer)p;
- *dotClock = VidModeGetDotClock(scrnIndex, p->Clock);
- return TRUE;
- }
+ if (p->status == MODE_OK) {
+ pVidMode->Next = p->next;
+ *mode = (pointer) p;
+ *dotClock = VidModeGetDotClock(scrnIndex, p->Clock);
+ return TRUE;
+ }
}
-
+
return FALSE;
}
@@ -268,10 +267,10 @@ VidModeDeleteModeline(int scrnIndex, pointer mode)
ScrnInfoPtr pScrn;
if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
- return FALSE;
+ return FALSE;
pScrn = xf86Screens[scrnIndex];
- xf86DeleteMode(&(pScrn->modes), (DisplayModePtr)mode);
+ xf86DeleteMode(&(pScrn->modes), (DisplayModePtr) mode);
return TRUE;
}
@@ -281,7 +280,7 @@ VidModeZoomViewport(int scrnIndex, int zoom)
ScrnInfoPtr pScrn;
if (!VidModeAvailable(scrnIndex))
- return FALSE;
+ return FALSE;
pScrn = xf86Screens[scrnIndex];
xf86ZoomViewport(pScrn->pScreen, zoom);
@@ -294,17 +293,17 @@ VidModeSetViewPort(int scrnIndex, int x, int y)
ScrnInfoPtr pScrn;
if (!VidModeAvailable(scrnIndex))
- return FALSE;
+ return FALSE;
pScrn = xf86Screens[scrnIndex];
- pScrn->frameX0 = min( max(x, 0),
- pScrn->virtualX - pScrn->currentMode->HDisplay );
+ pScrn->frameX0 = min(max(x, 0),
+ pScrn->virtualX - pScrn->currentMode->HDisplay);
pScrn->frameX1 = pScrn->frameX0 + pScrn->currentMode->HDisplay - 1;
- pScrn->frameY0 = min( max(y, 0),
- pScrn->virtualY - pScrn->currentMode->VDisplay );
+ pScrn->frameY0 = min(max(y, 0),
+ pScrn->virtualY - pScrn->currentMode->VDisplay);
pScrn->frameY1 = pScrn->frameY0 + pScrn->currentMode->VDisplay - 1;
if (pScrn->AdjustFrame != NULL)
- (pScrn->AdjustFrame)(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+ (pScrn->AdjustFrame) (scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
return TRUE;
}
@@ -315,7 +314,7 @@ VidModeGetViewPort(int scrnIndex, int *x, int *y)
ScrnInfoPtr pScrn;
if (!VidModeAvailable(scrnIndex))
- return FALSE;
+ return FALSE;
pScrn = xf86Screens[scrnIndex];
*x = pScrn->frameX0;
@@ -331,7 +330,7 @@ VidModeSwitchMode(int scrnIndex, pointer mode)
Bool retval;
if (!VidModeAvailable(scrnIndex))
- return FALSE;
+ return FALSE;
pScrn = xf86Screens[scrnIndex];
/* save in case we fail */
@@ -341,7 +340,7 @@ VidModeSwitchMode(int scrnIndex, pointer mode)
retval = xf86SwitchMode(pScrn->pScreen, mode);
/* we failed: restore it */
if (retval == FALSE)
- pScrn->currentMode = pTmpMode;
+ pScrn->currentMode = pTmpMode;
return retval;
}
@@ -351,12 +350,12 @@ VidModeLockZoom(int scrnIndex, Bool lock)
ScrnInfoPtr pScrn;
if (!VidModeAvailable(scrnIndex))
- return FALSE;
+ return FALSE;
pScrn = xf86Screens[scrnIndex];
if (xf86Info.dontZoom)
- return FALSE;
+ return FALSE;
xf86LockZoom(pScrn->pScreen, lock);
return TRUE;
@@ -368,10 +367,10 @@ VidModeGetMonitor(int scrnIndex, pointer *monitor)
ScrnInfoPtr pScrn;
if (!VidModeAvailable(scrnIndex))
- return FALSE;
+ return FALSE;
pScrn = xf86Screens[scrnIndex];
- *monitor = (pointer)(pScrn->monitor);
+ *monitor = (pointer) (pScrn->monitor);
return TRUE;
}
@@ -382,11 +381,11 @@ VidModeCheckModeForMonitor(int scrnIndex, pointer mode)
ScrnInfoPtr pScrn;
if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
- return MODE_ERROR;
+ return MODE_ERROR;
pScrn = xf86Screens[scrnIndex];
- return xf86CheckModeForMonitor((DisplayModePtr)mode, pScrn->monitor);
+ return xf86CheckModeForMonitor((DisplayModePtr) mode, pScrn->monitor);
}
ModeStatus
@@ -395,11 +394,11 @@ VidModeCheckModeForDriver(int scrnIndex, pointer mode)
ScrnInfoPtr pScrn;
if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
- return MODE_ERROR;
+ return MODE_ERROR;
pScrn = xf86Screens[scrnIndex];
- return xf86CheckModeForDriver(pScrn, (DisplayModePtr)mode, 0);
+ return xf86CheckModeForDriver(pScrn, (DisplayModePtr) mode, 0);
}
void
@@ -407,15 +406,15 @@ VidModeSetCrtcForMode(int scrnIndex, pointer mode)
{
ScrnInfoPtr pScrn;
DisplayModePtr ScreenModes;
-
+
if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
- return;
+ return;
/* Ugly hack so that the xf86Mode.c function can be used without change */
pScrn = xf86Screens[scrnIndex];
ScreenModes = pScrn->modes;
- pScrn->modes = (DisplayModePtr)mode;
-
+ pScrn->modes = (DisplayModePtr) mode;
+
xf86SetCrtcForModes(pScrn, pScrn->adjustFlags);
pScrn->modes = ScreenModes;
return;
@@ -425,19 +424,19 @@ Bool
VidModeAddModeline(int scrnIndex, pointer mode)
{
ScrnInfoPtr pScrn;
-
+
if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
- return FALSE;
+ return FALSE;
pScrn = xf86Screens[scrnIndex];
- ((DisplayModePtr)mode)->name = strdup(""); /* freed by deletemode */
- ((DisplayModePtr)mode)->status = MODE_OK;
- ((DisplayModePtr)mode)->next = pScrn->modes->next;
- ((DisplayModePtr)mode)->prev = pScrn->modes;
- pScrn->modes->next = (DisplayModePtr)mode;
- if( ((DisplayModePtr)mode)->next != NULL )
- ((DisplayModePtr)mode)->next->prev = (DisplayModePtr)mode;
+ ((DisplayModePtr) mode)->name = strdup(""); /* freed by deletemode */
+ ((DisplayModePtr) mode)->status = MODE_OK;
+ ((DisplayModePtr) mode)->next = pScrn->modes->next;
+ ((DisplayModePtr) mode)->prev = pScrn->modes;
+ pScrn->modes->next = (DisplayModePtr) mode;
+ if (((DisplayModePtr) mode)->next != NULL)
+ ((DisplayModePtr) mode)->next->prev = (DisplayModePtr) mode;
return TRUE;
}
@@ -446,15 +445,15 @@ int
VidModeGetNumOfModes(int scrnIndex)
{
pointer mode = NULL;
- int dotClock= 0, nummodes = 0;
-
+ int dotClock = 0, nummodes = 0;
+
if (!VidModeGetFirstModeline(scrnIndex, &mode, &dotClock))
- return nummodes;
+ return nummodes;
do {
- nummodes++;
- if (!VidModeGetNextModeline(scrnIndex, &mode, &dotClock))
- return nummodes;
+ nummodes++;
+ if (!VidModeGetNextModeline(scrnIndex, &mode, &dotClock))
+ return nummodes;
} while (TRUE);
}
@@ -465,16 +464,16 @@ VidModeSetGamma(int scrnIndex, float red, float green, float blue)
Gamma gamma;
if (!VidModeAvailable(scrnIndex))
- return FALSE;
+ return FALSE;
pScrn = xf86Screens[scrnIndex];
gamma.red = red;
gamma.green = green;
gamma.blue = blue;
if (xf86ChangeGamma(pScrn->pScreen, gamma) != Success)
- return FALSE;
+ return FALSE;
else
- return TRUE;
+ return TRUE;
}
Bool
@@ -483,7 +482,7 @@ VidModeGetGamma(int scrnIndex, float *red, float *green, float *blue)
ScrnInfoPtr pScrn;
if (!VidModeAvailable(scrnIndex))
- return FALSE;
+ return FALSE;
pScrn = xf86Screens[scrnIndex];
*red = pScrn->gamma.red;
@@ -499,7 +498,7 @@ VidModeSetGammaRamp(int scrnIndex, int size, CARD16 *r, CARD16 *g, CARD16 *b)
if (!VidModeAvailable(scrnIndex))
return FALSE;
-
+
pScrn = xf86Screens[scrnIndex];
xf86ChangeGammaRamp(pScrn->pScreen, size, r, g, b);
return TRUE;
@@ -531,14 +530,14 @@ pointer
VidModeCreateMode(void)
{
DisplayModePtr mode;
-
+
mode = malloc(sizeof(DisplayModeRec));
if (mode != NULL) {
- mode->name = "";
- mode->VScan = 1; /* divides refresh rate. default = 1 */
- mode->Private = NULL;
- mode->next = mode;
- mode->prev = mode;
+ mode->name = "";
+ mode->VScan = 1; /* divides refresh rate. default = 1 */
+ mode->Private = NULL;
+ mode->next = mode;
+ mode->prev = mode;
}
return mode;
}
@@ -546,127 +545,125 @@ VidModeCreateMode(void)
void
VidModeCopyMode(pointer modefrom, pointer modeto)
{
- memcpy(modeto, modefrom, sizeof(DisplayModeRec));
+ memcpy(modeto, modefrom, sizeof(DisplayModeRec));
}
-
int
VidModeGetModeValue(pointer mode, int valtyp)
{
- int ret = 0;
-
- switch (valtyp) {
+ int ret = 0;
+
+ switch (valtyp) {
case VIDMODE_H_DISPLAY:
- ret = ((DisplayModePtr) mode)->HDisplay;
- break;
+ ret = ((DisplayModePtr) mode)->HDisplay;
+ break;
case VIDMODE_H_SYNCSTART:
- ret = ((DisplayModePtr)mode)->HSyncStart;
- break;
+ ret = ((DisplayModePtr) mode)->HSyncStart;
+ break;
case VIDMODE_H_SYNCEND:
- ret = ((DisplayModePtr)mode)->HSyncEnd;
- break;
+ ret = ((DisplayModePtr) mode)->HSyncEnd;
+ break;
case VIDMODE_H_TOTAL:
- ret = ((DisplayModePtr)mode)->HTotal;
- break;
+ ret = ((DisplayModePtr) mode)->HTotal;
+ break;
case VIDMODE_H_SKEW:
- ret = ((DisplayModePtr)mode)->HSkew;
- break;
+ ret = ((DisplayModePtr) mode)->HSkew;
+ break;
case VIDMODE_V_DISPLAY:
- ret = ((DisplayModePtr)mode)->VDisplay;
- break;
+ ret = ((DisplayModePtr) mode)->VDisplay;
+ break;
case VIDMODE_V_SYNCSTART:
- ret = ((DisplayModePtr)mode)->VSyncStart;
- break;
+ ret = ((DisplayModePtr) mode)->VSyncStart;
+ break;
case VIDMODE_V_SYNCEND:
- ret = ((DisplayModePtr)mode)->VSyncEnd;
- break;
+ ret = ((DisplayModePtr) mode)->VSyncEnd;
+ break;
case VIDMODE_V_TOTAL:
- ret = ((DisplayModePtr)mode)->VTotal;
- break;
+ ret = ((DisplayModePtr) mode)->VTotal;
+ break;
case VIDMODE_FLAGS:
- ret = ((DisplayModePtr)mode)->Flags;
- break;
+ ret = ((DisplayModePtr) mode)->Flags;
+ break;
case VIDMODE_CLOCK:
- ret = ((DisplayModePtr)mode)->Clock;
- break;
- }
- return ret;
+ ret = ((DisplayModePtr) mode)->Clock;
+ break;
+ }
+ return ret;
}
void
VidModeSetModeValue(pointer mode, int valtyp, int val)
{
- switch (valtyp) {
+ switch (valtyp) {
case VIDMODE_H_DISPLAY:
- ((DisplayModePtr)mode)->HDisplay = val;
- break;
+ ((DisplayModePtr) mode)->HDisplay = val;
+ break;
case VIDMODE_H_SYNCSTART:
- ((DisplayModePtr)mode)->HSyncStart = val;
- break;
+ ((DisplayModePtr) mode)->HSyncStart = val;
+ break;
case VIDMODE_H_SYNCEND:
- ((DisplayModePtr)mode)->HSyncEnd = val;
- break;
+ ((DisplayModePtr) mode)->HSyncEnd = val;
+ break;
case VIDMODE_H_TOTAL:
- ((DisplayModePtr)mode)->HTotal = val;
- break;
+ ((DisplayModePtr) mode)->HTotal = val;
+ break;
case VIDMODE_H_SKEW:
- ((DisplayModePtr)mode)->HSkew = val;
- break;
+ ((DisplayModePtr) mode)->HSkew = val;
+ break;
case VIDMODE_V_DISPLAY:
- ((DisplayModePtr)mode)->VDisplay = val;
- break;
+ ((DisplayModePtr) mode)->VDisplay = val;
+ break;
case VIDMODE_V_SYNCSTART:
- ((DisplayModePtr)mode)->VSyncStart = val;
- break;
+ ((DisplayModePtr) mode)->VSyncStart = val;
+ break;
case VIDMODE_V_SYNCEND:
- ((DisplayModePtr)mode)->VSyncEnd = val;
- break;
+ ((DisplayModePtr) mode)->VSyncEnd = val;
+ break;
case VIDMODE_V_TOTAL:
- ((DisplayModePtr)mode)->VTotal = val;
- break;
+ ((DisplayModePtr) mode)->VTotal = val;
+ break;
case VIDMODE_FLAGS:
- ((DisplayModePtr)mode)->Flags = val;
- break;
+ ((DisplayModePtr) mode)->Flags = val;
+ break;
case VIDMODE_CLOCK:
- ((DisplayModePtr)mode)->Clock = val;
- break;
- }
- return;
+ ((DisplayModePtr) mode)->Clock = val;
+ break;
+ }
+ return;
}
vidMonitorValue
VidModeGetMonitorValue(pointer monitor, int valtyp, int indx)
{
- vidMonitorValue ret = { NULL, };
-
- switch (valtyp) {
+ vidMonitorValue ret = { NULL, };
+
+ switch (valtyp) {
case VIDMODE_MON_VENDOR:
- ret.ptr = (((MonPtr)monitor)->vendor);
- break;
+ ret.ptr = (((MonPtr) monitor)->vendor);
+ break;
case VIDMODE_MON_MODEL:
- ret.ptr = (((MonPtr)monitor)->model);
- break;
+ ret.ptr = (((MonPtr) monitor)->model);
+ break;
case VIDMODE_MON_NHSYNC:
- ret.i = ((MonPtr)monitor)->nHsync;
- break;
+ ret.i = ((MonPtr) monitor)->nHsync;
+ break;
case VIDMODE_MON_NVREFRESH:
- ret.i = ((MonPtr)monitor)->nVrefresh;
- break;
+ ret.i = ((MonPtr) monitor)->nVrefresh;
+ break;
case VIDMODE_MON_HSYNC_LO:
- ret.f = (100.0 * ((MonPtr)monitor)->hsync[indx].lo);
- break;
+ ret.f = (100.0 * ((MonPtr) monitor)->hsync[indx].lo);
+ break;
case VIDMODE_MON_HSYNC_HI:
- ret.f = (100.0 * ((MonPtr)monitor)->hsync[indx].hi);
- break;
+ ret.f = (100.0 * ((MonPtr) monitor)->hsync[indx].hi);
+ break;
case VIDMODE_MON_VREFRESH_LO:
- ret.f = (100.0 * ((MonPtr)monitor)->vrefresh[indx].lo);
- break;
+ ret.f = (100.0 * ((MonPtr) monitor)->vrefresh[indx].lo);
+ break;
case VIDMODE_MON_VREFRESH_HI:
- ret.f = (100.0 * ((MonPtr)monitor)->vrefresh[indx].hi);
- break;
- }
- return ret;
+ ret.f = (100.0 * ((MonPtr) monitor)->vrefresh[indx].hi);
+ break;
+ }
+ return ret;
}
-
-#endif /* XF86VIDMODE */
+#endif /* XF86VIDMODE */
diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.c b/xorg-server/hw/xfree86/common/xf86Xinput.c
index f6be99910..77b800000 100644
--- a/xorg-server/hw/xfree86/common/xf86Xinput.c
+++ b/xorg-server/hw/xfree86/common/xf86Xinput.c
@@ -64,13 +64,13 @@
#include "extinit.h"
#include "loaderProcs.h"
-#include "exevents.h" /* AddInputDevice */
+#include "exevents.h" /* AddInputDevice */
#include "exglobals.h"
#include "eventstr.h"
#include "inpututils.h"
#include "optionstr.h"
-#include <string.h> /* InputClassMatches */
+#include <string.h> /* InputClassMatches */
#ifdef HAVE_FNMATCH_H
#include <fnmatch.h>
#endif
@@ -79,11 +79,11 @@
#endif
#include <stdarg.h>
-#include <stdint.h> /* for int64_t */
+#include <stdint.h> /* for int64_t */
#include "mi.h"
-#include <ptrveloc.h> /* dix pointer acceleration */
+#include <ptrveloc.h> /* dix pointer acceleration */
#include <xserver-properties.h>
#ifdef XFreeXDGA
@@ -101,13 +101,13 @@
}
static int
-xf86InputDevicePostInit(DeviceIntPtr dev);
+ xf86InputDevicePostInit(DeviceIntPtr dev);
/**
* Eval config and modify DeviceVelocityRec accordingly
*/
static void
-ProcessVelocityConfiguration(DeviceIntPtr pDev, char* devname, pointer list,
+ProcessVelocityConfiguration(DeviceIntPtr pDev, char *devname, pointer list,
DeviceVelocityPtr s)
{
int tempi;
@@ -115,7 +115,7 @@ ProcessVelocityConfiguration(DeviceIntPtr pDev, char* devname, pointer list,
Atom float_prop = XIGetKnownProperty(XATOM_FLOAT);
Atom prop;
- if(!s)
+ if (!s)
return;
/* common settings (available via device properties) */
@@ -139,14 +139,15 @@ ProcessVelocityConfiguration(DeviceIntPtr pDev, char* devname, pointer list,
/* select profile by number */
tempi = xf86SetIntOption(list, "AccelerationProfile",
- s->statistics.profile_number);
+ s->statistics.profile_number);
prop = XIGetKnownProperty(ACCEL_PROP_PROFILE_NUMBER);
if (XIChangeDeviceProperty(pDev, prop, XA_INTEGER, 32,
PropModeReplace, 1, &tempi, FALSE) == Success) {
xf86Msg(X_CONFIG, "%s: (accel) acceleration profile %i\n", devname,
tempi);
- } else {
+ }
+ else {
xf86Msg(X_CONFIG, "%s: (accel) acceleration profile %i is unknown\n",
devname, tempi);
}
@@ -158,7 +159,8 @@ ProcessVelocityConfiguration(DeviceIntPtr pDev, char* devname, pointer list,
tempf = 1000.0 / tempf;
XIChangeDeviceProperty(pDev, prop, float_prop, 32,
PropModeReplace, 1, &tempf, FALSE);
- } else {
+ }
+ else {
tempf = xf86SetRealOption(list, "VelocityScale", s->corr_mul);
XIChangeDeviceProperty(pDev, prop, float_prop, 32,
PropModeReplace, 1, &tempf, FALSE);
@@ -166,7 +168,7 @@ ProcessVelocityConfiguration(DeviceIntPtr pDev, char* devname, pointer list,
tempi = xf86SetIntOption(list, "VelocityTrackerCount", -1);
if (tempi > 1)
- InitTrackers(s, tempi);
+ InitTrackers(s, tempi);
s->initial_range = xf86SetIntOption(list, "VelocityInitialRange",
s->initial_range);
@@ -175,9 +177,9 @@ ProcessVelocityConfiguration(DeviceIntPtr pDev, char* devname, pointer list,
tempf = xf86SetRealOption(list, "VelocityRelDiff", -1);
if (tempf >= 0) {
- xf86Msg(X_CONFIG, "%s: (accel) max rel. velocity difference: %.1f%%\n",
- devname, tempf*100.0);
- s->max_rel_diff = tempf;
+ xf86Msg(X_CONFIG, "%s: (accel) max rel. velocity difference: %.1f%%\n",
+ devname, tempf * 100.0);
+ s->max_rel_diff = tempf;
}
/* Configure softening. If const deceleration is used, this is expected
@@ -194,25 +196,26 @@ ProcessVelocityConfiguration(DeviceIntPtr pDev, char* devname, pointer list,
}
static void
-ApplyAccelerationSettings(DeviceIntPtr dev){
+ApplyAccelerationSettings(DeviceIntPtr dev)
+{
int scheme, i;
DeviceVelocityPtr pVel;
- InputInfoPtr pInfo = (InputInfoPtr)dev->public.devicePrivate;
- char* schemeStr;
+ InputInfoPtr pInfo = (InputInfoPtr) dev->public.devicePrivate;
+ char *schemeStr;
if (dev->valuator && dev->ptrfeed) {
- schemeStr = xf86SetStrOption(pInfo->options, "AccelerationScheme", "");
+ schemeStr = xf86SetStrOption(pInfo->options, "AccelerationScheme", "");
- scheme = dev->valuator->accelScheme.number;
+ scheme = dev->valuator->accelScheme.number;
- if (!xf86NameCmp(schemeStr, "predictable"))
- scheme = PtrAccelPredictable;
+ if (!xf86NameCmp(schemeStr, "predictable"))
+ scheme = PtrAccelPredictable;
- if (!xf86NameCmp(schemeStr, "lightweight"))
- scheme = PtrAccelLightweight;
+ if (!xf86NameCmp(schemeStr, "lightweight"))
+ scheme = PtrAccelLightweight;
- if (!xf86NameCmp(schemeStr, "none"))
- scheme = PtrAccelNoOp;
+ if (!xf86NameCmp(schemeStr, "none"))
+ scheme = PtrAccelNoOp;
/* reinit scheme if needed */
if (dev->valuator->accelScheme.number != scheme) {
@@ -221,14 +224,16 @@ ApplyAccelerationSettings(DeviceIntPtr dev){
}
if (InitPointerAccelerationScheme(dev, scheme)) {
- xf86Msg(X_CONFIG, "%s: (accel) selected scheme %s/%i\n",
- pInfo->name, schemeStr, scheme);
- } else {
- xf86Msg(X_CONFIG, "%s: (accel) could not init scheme %s\n",
- pInfo->name, schemeStr);
- scheme = dev->valuator->accelScheme.number;
+ xf86Msg(X_CONFIG, "%s: (accel) selected scheme %s/%i\n",
+ pInfo->name, schemeStr, scheme);
}
- } else {
+ else {
+ xf86Msg(X_CONFIG, "%s: (accel) could not init scheme %s\n",
+ pInfo->name, schemeStr);
+ scheme = dev->valuator->accelScheme.number;
+ }
+ }
+ else {
xf86Msg(X_CONFIG, "%s: (accel) keeping acceleration scheme %i\n",
pInfo->name, scheme);
}
@@ -237,11 +242,11 @@ ApplyAccelerationSettings(DeviceIntPtr dev){
/* process special configuration */
switch (scheme) {
- case PtrAccelPredictable:
- pVel = GetDevicePredictableAccelData(dev);
- ProcessVelocityConfiguration (dev, pInfo->name, pInfo->options,
- pVel);
- break;
+ case PtrAccelPredictable:
+ pVel = GetDevicePredictableAccelData(dev);
+ ProcessVelocityConfiguration(dev, pInfo->name, pInfo->options,
+ pVel);
+ break;
}
i = xf86SetIntOption(pInfo->options, "AccelerationNumerator",
@@ -260,8 +265,8 @@ ApplyAccelerationSettings(DeviceIntPtr dev){
dev->ptrfeed->ctrl.threshold = i;
xf86Msg(X_CONFIG, "%s: (accel) acceleration factor: %.3f\n",
- pInfo->name, ((float)dev->ptrfeed->ctrl.num)/
- ((float)dev->ptrfeed->ctrl.den));
+ pInfo->name, ((float) dev->ptrfeed->ctrl.num) /
+ ((float) dev->ptrfeed->ctrl.den));
xf86Msg(X_CONFIG, "%s: (accel) acceleration threshold: %i\n",
pInfo->name, dev->ptrfeed->ctrl.threshold);
}
@@ -270,10 +275,10 @@ ApplyAccelerationSettings(DeviceIntPtr dev){
static void
ApplyTransformationMatrix(DeviceIntPtr dev)
{
- InputInfoPtr pInfo = (InputInfoPtr)dev->public.devicePrivate;
+ InputInfoPtr pInfo = (InputInfoPtr) dev->public.devicePrivate;
char *str;
int rc;
- float matrix[9] = {0};
+ float matrix[9] = { 0 };
if (!dev->valuator)
return;
@@ -282,10 +287,12 @@ ApplyTransformationMatrix(DeviceIntPtr dev)
if (!str)
return;
- rc = sscanf(str, "%f %f %f %f %f %f %f %f %f", &matrix[0], &matrix[1], &matrix[2],
- &matrix[3], &matrix[4], &matrix[5], &matrix[6], &matrix[7], &matrix[8]);
+ rc = sscanf(str, "%f %f %f %f %f %f %f %f %f", &matrix[0], &matrix[1],
+ &matrix[2], &matrix[3], &matrix[4], &matrix[5], &matrix[6],
+ &matrix[7], &matrix[8]);
if (rc != 9) {
- xf86Msg(X_ERROR, "%s: invalid format for transformation matrix. Ignoring configuration.\n",
+ xf86Msg(X_ERROR,
+ "%s: invalid format for transformation matrix. Ignoring configuration.\n",
pInfo->name);
return;
}
@@ -304,8 +311,7 @@ ApplyTransformationMatrix(DeviceIntPtr dev)
***********************************************************************
*/
void
-xf86ProcessCommonOptions(InputInfoPtr pInfo,
- XF86OptionPtr list)
+xf86ProcessCommonOptions(InputInfoPtr pInfo, XF86OptionPtr list)
{
if (xf86SetBoolOption(list, "Floating", 0) ||
!xf86SetBoolOption(list, "AlwaysCore", 1) ||
@@ -313,7 +319,8 @@ xf86ProcessCommonOptions(InputInfoPtr pInfo,
!xf86SetBoolOption(list, "CorePointer", 1) ||
!xf86SetBoolOption(list, "CoreKeyboard", 1)) {
xf86Msg(X_CONFIG, "%s: doesn't report core events\n", pInfo->name);
- } else {
+ }
+ else {
pInfo->flags |= XI86_ALWAYS_CORE;
xf86Msg(X_CONFIG, "%s: always reports core events\n", pInfo->name);
}
@@ -331,15 +338,13 @@ xf86ProcessCommonOptions(InputInfoPtr pInfo,
static DeviceIntPtr
xf86ActivateDevice(InputInfoPtr pInfo)
{
- DeviceIntPtr dev;
- Atom atom;
+ DeviceIntPtr dev;
+ Atom atom;
dev = AddInputDevice(serverClient, pInfo->device_control, TRUE);
- if (dev == NULL)
- {
- xf86Msg(X_ERROR, "Too many input devices. Ignoring %s\n",
- pInfo->name);
+ if (dev == NULL) {
+ xf86Msg(X_ERROR, "Too many input devices. Ignoring %s\n", pInfo->name);
pInfo->dev = NULL;
return NULL;
}
@@ -356,7 +361,8 @@ xf86ActivateDevice(InputInfoPtr pInfo)
dev->config_info = xf86SetStrOption(pInfo->options, "config_info", NULL);
if (serverGeneration == 1)
- xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s, id %d)\n",
+ xf86Msg(X_INFO,
+ "XINPUT: Adding extended input device \"%s\" (type: %s, id %d)\n",
pInfo->name, pInfo->type_name, dev->id);
return dev;
@@ -376,18 +382,17 @@ xf86ActivateDevice(InputInfoPtr pInfo)
*/
int
-SetDeviceMode (ClientPtr client, DeviceIntPtr dev, int mode)
+SetDeviceMode(ClientPtr client, DeviceIntPtr dev, int mode)
{
- InputInfoPtr pInfo = (InputInfoPtr)dev->public.devicePrivate;
+ InputInfoPtr pInfo = (InputInfoPtr) dev->public.devicePrivate;
- if (pInfo->switch_mode) {
- return (*pInfo->switch_mode)(client, dev, mode);
- }
- else
- return BadMatch;
+ if (pInfo->switch_mode) {
+ return (*pInfo->switch_mode) (client, dev, mode);
+ }
+ else
+ return BadMatch;
}
-
/***********************************************************************
*
* Caller: ProcXSetDeviceValuators
@@ -402,19 +407,18 @@ SetDeviceMode (ClientPtr client, DeviceIntPtr dev, int mode)
*/
int
-SetDeviceValuators (ClientPtr client, DeviceIntPtr dev, int *valuators,
- int first_valuator, int num_valuators)
+SetDeviceValuators(ClientPtr client, DeviceIntPtr dev, int *valuators,
+ int first_valuator, int num_valuators)
{
InputInfoPtr pInfo = (InputInfoPtr) dev->public.devicePrivate;
if (pInfo->set_device_valuators)
- return (*pInfo->set_device_valuators)(pInfo, valuators, first_valuator,
- num_valuators);
+ return (*pInfo->set_device_valuators) (pInfo, valuators, first_valuator,
+ num_valuators);
return BadMatch;
}
-
/***********************************************************************
*
* Caller: ProcXChangeDeviceControl
@@ -425,26 +429,26 @@ SetDeviceValuators (ClientPtr client, DeviceIntPtr dev, int *valuators,
*/
int
-ChangeDeviceControl (ClientPtr client, DeviceIntPtr dev, xDeviceCtl *control)
+ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev, xDeviceCtl * control)
{
- InputInfoPtr pInfo = (InputInfoPtr)dev->public.devicePrivate;
-
- if (!pInfo->control_proc) {
- switch (control->control) {
- case DEVICE_CORE:
- case DEVICE_ABS_CALIB:
- case DEVICE_ABS_AREA:
- return BadMatch;
- case DEVICE_RESOLUTION:
- case DEVICE_ENABLE:
- return Success;
- default:
- return BadMatch;
- }
- }
- else {
- return (*pInfo->control_proc)(pInfo, control);
- }
+ InputInfoPtr pInfo = (InputInfoPtr) dev->public.devicePrivate;
+
+ if (!pInfo->control_proc) {
+ switch (control->control) {
+ case DEVICE_CORE:
+ case DEVICE_ABS_CALIB:
+ case DEVICE_ABS_AREA:
+ return BadMatch;
+ case DEVICE_RESOLUTION:
+ case DEVICE_ENABLE:
+ return Success;
+ default:
+ return BadMatch;
+ }
+ }
+ else {
+ return (*pInfo->control_proc) (pInfo, control);
+ }
}
/*
@@ -506,8 +510,9 @@ match_string_implicit(const char *attr, const char *pattern)
{
if (strlen(pattern)) {
return strcmp(attr, pattern);
- } else {
- return strcmp(attr,"(implicit)");
+ }
+ else {
+ return strcmp(attr, "(implicit)");
}
}
@@ -517,7 +522,7 @@ match_string_implicit(const char *attr, const char *pattern)
*/
static Bool
MatchAttrToken(const char *attr, struct xorg_list *patterns,
- int (*compare)(const char *attr, const char *pattern))
+ int (*compare) (const char *attr, const char *pattern))
{
const xf86MatchGroup *group;
@@ -534,11 +539,11 @@ MatchAttrToken(const char *attr, struct xorg_list *patterns,
* match. Each list entry is a separate Match line of the same type.
*/
xorg_list_for_each_entry(group, patterns, entry) {
- char * const *cur;
+ char *const *cur;
Bool match = FALSE;
for (cur = group->values; *cur; cur++)
- if ((*compare)(attr, *cur) == 0) {
+ if ((*compare) (attr, *cur) == 0) {
match = TRUE;
break;
}
@@ -556,10 +561,11 @@ MatchAttrToken(const char *attr, struct xorg_list *patterns,
*/
static Bool
InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev,
- const InputAttributes *attrs)
+ const InputAttributes * attrs)
{
/* MatchProduct substring */
- if (!MatchAttrToken(attrs->product, &iclass->match_product, match_substring))
+ if (!MatchAttrToken
+ (attrs->product, &iclass->match_product, match_substring))
return FALSE;
/* MatchVendor substring */
@@ -567,7 +573,8 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev,
return FALSE;
/* MatchDevicePath pattern */
- if (!MatchAttrToken(attrs->device, &iclass->match_device, match_path_pattern))
+ if (!MatchAttrToken
+ (attrs->device, &iclass->match_device, match_path_pattern))
return FALSE;
/* MatchOS case-insensitive string */
@@ -591,7 +598,7 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev,
* See if any of the device's tags match any of the MatchTag tokens.
*/
if (!xorg_list_is_empty(&iclass->match_tag)) {
- char * const *tag;
+ char *const *tag;
Bool match;
if (!attrs->tags)
@@ -615,22 +622,22 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev,
/* MatchIs* booleans */
if (iclass->is_keyboard.set &&
- iclass->is_keyboard.val != !!(attrs->flags & ATTR_KEYBOARD))
+ iclass->is_keyboard.val != ! !(attrs->flags & ATTR_KEYBOARD))
return FALSE;
if (iclass->is_pointer.set &&
- iclass->is_pointer.val != !!(attrs->flags & ATTR_POINTER))
+ iclass->is_pointer.val != ! !(attrs->flags & ATTR_POINTER))
return FALSE;
if (iclass->is_joystick.set &&
- iclass->is_joystick.val != !!(attrs->flags & ATTR_JOYSTICK))
+ iclass->is_joystick.val != ! !(attrs->flags & ATTR_JOYSTICK))
return FALSE;
if (iclass->is_tablet.set &&
- iclass->is_tablet.val != !!(attrs->flags & ATTR_TABLET))
+ iclass->is_tablet.val != ! !(attrs->flags & ATTR_TABLET))
return FALSE;
if (iclass->is_touchpad.set &&
- iclass->is_touchpad.val != !!(attrs->flags & ATTR_TOUCHPAD))
+ iclass->is_touchpad.val != ! !(attrs->flags & ATTR_TOUCHPAD))
return FALSE;
if (iclass->is_touchscreen.set &&
- iclass->is_touchscreen.val != !!(attrs->flags & ATTR_TOUCHSCREEN))
+ iclass->is_touchscreen.val != ! !(attrs->flags & ATTR_TOUCHSCREEN))
return FALSE;
return TRUE;
@@ -642,7 +649,7 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev,
* well as any previous InputClass sections.
*/
static int
-MergeInputClasses(const InputInfoPtr idev, const InputAttributes *attrs)
+MergeInputClasses(const InputInfoPtr idev, const InputAttributes * attrs)
{
XF86ConfInputClassPtr cl;
XF86OptionPtr classopts;
@@ -661,8 +668,7 @@ MergeInputClasses(const InputInfoPtr idev, const InputAttributes *attrs)
"InputClass configuration");
return BadAlloc;
}
- classopts = xf86ReplaceStrOption(classopts, "driver",
- idev->driver);
+ classopts = xf86ReplaceStrOption(classopts, "driver", idev->driver);
}
/* Apply options to device with InputClass settings preferred. */
@@ -679,7 +685,7 @@ MergeInputClasses(const InputInfoPtr idev, const InputAttributes *attrs)
* value of the last matching class and holler when returning TRUE.
*/
static Bool
-IgnoreInputClass(const InputInfoPtr idev, const InputAttributes *attrs)
+IgnoreInputClass(const InputInfoPtr idev, const InputAttributes * attrs)
{
XF86ConfInputClassPtr cl;
Bool ignore = FALSE;
@@ -724,13 +730,12 @@ xf86AddInput(InputDriverPtr drv, InputInfoPtr pInfo)
pInfo->drv = drv;
pInfo->module = DuplicateModule(drv->module, NULL);
- for (prev = &xf86InputDevs; *prev; prev = &(*prev)->next)
- ;
+ for (prev = &xf86InputDevs; *prev; prev = &(*prev)->next);
*prev = pInfo;
pInfo->next = NULL;
- xf86CollectInputOptions(pInfo, (const char**)drv->default_options);
+ xf86CollectInputOptions(pInfo, (const char **) drv->default_options);
xf86OptionListReport(pInfo->options);
xf86ProcessCommonOptions(pInfo, pInfo->options);
}
@@ -743,10 +748,10 @@ xf86DeleteInput(InputInfoPtr pInp, int flags)
{
/* First check if the inputdev is valid. */
if (pInp == NULL)
- return;
+ return;
if (pInp->module)
- UnloadModule(pInp->module);
+ UnloadModule(pInp->module);
/* This should *really* be handled in drv->UnInit(dev) call instead, but
* if the driver forgets about it make sure we free it or at least crash
@@ -757,14 +762,15 @@ xf86DeleteInput(InputInfoPtr pInp, int flags)
/* Remove the entry from the list. */
if (pInp == xf86InputDevs)
- xf86InputDevs = pInp->next;
+ xf86InputDevs = pInp->next;
else {
- InputInfoPtr p = xf86InputDevs;
- while (p && p->next != pInp)
- p = p->next;
- if (p)
- p->next = pInp->next;
- /* Else the entry wasn't in the xf86InputDevs list (ignore this). */
+ InputInfoPtr p = xf86InputDevs;
+
+ while (p && p->next != pInp)
+ p = p->next;
+ if (p)
+ p->next = pInp->next;
+ /* Else the entry wasn't in the xf86InputDevs list (ignore this). */
}
free(pInp->driver);
@@ -781,7 +787,8 @@ xf86DeleteInput(InputInfoPtr pInp, int flags)
* @return Success or an error code
*/
static int
-xf86InputDevicePostInit(DeviceIntPtr dev) {
+xf86InputDevicePostInit(DeviceIntPtr dev)
+{
ApplyAccelerationSettings(dev);
ApplyTransformationMatrix(dev);
return Success;
@@ -823,7 +830,8 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
goto unwind;
}
- xf86Msg(X_INFO, "Using input driver '%s' for '%s'\n", drv->driverName, pInfo->name);
+ xf86Msg(X_INFO, "Using input driver '%s' for '%s'\n", drv->driverName,
+ pInfo->name);
if (!drv->PreInit) {
xf86Msg(X_ERROR,
@@ -842,35 +850,30 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
goto unwind;
}
- if (!(dev = xf86ActivateDevice(pInfo)))
- {
+ if (!(dev = xf86ActivateDevice(pInfo))) {
rval = BadAlloc;
goto unwind;
}
rval = ActivateDevice(dev, TRUE);
- if (rval != Success)
- {
+ if (rval != Success) {
xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", pInfo->name);
RemoveDevice(dev, TRUE);
goto unwind;
}
rval = xf86InputDevicePostInit(dev);
- if (rval != Success)
- {
- xf86Msg(X_ERROR, "Couldn't post-init device \"%s\"\n", pInfo->name);
- RemoveDevice(dev, TRUE);
- goto unwind;
+ if (rval != Success) {
+ xf86Msg(X_ERROR, "Couldn't post-init device \"%s\"\n", pInfo->name);
+ RemoveDevice(dev, TRUE);
+ goto unwind;
}
/* Enable it if it's properly initialised and we're currently in the VT */
- if (enable && dev->inited && dev->startup && xf86Screens[0]->vtSema)
- {
+ if (enable && dev->inited && dev->startup && xf86Screens[0]->vtSema) {
OsBlockSignals();
EnableDevice(dev, TRUE);
- if (!dev->enabled)
- {
+ if (!dev->enabled) {
OsReleaseSignals();
xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", pInfo->name);
RemoveDevice(dev, TRUE);
@@ -885,9 +888,9 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
*pdev = dev;
return Success;
-unwind:
- if(pInfo) {
- if(drv && drv->UnInit)
+ unwind:
+ if (pInfo) {
+ if (drv && drv->UnInit)
drv->UnInit(drv, pInfo, 0);
else
xf86DeleteInput(pInfo, 0);
@@ -896,8 +899,8 @@ unwind:
}
int
-NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
- DeviceIntPtr *pdev)
+NewInputDeviceRequest(InputOption *options, InputAttributes * attrs,
+ DeviceIntPtr *pdev)
{
InputInfoPtr pInfo = NULL;
InputOption *option = NULL;
@@ -924,8 +927,7 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
}
}
- if (strcasecmp(key, "name") == 0 ||
- strcasecmp(key, "identifier") == 0) {
+ if (strcasecmp(key, "name") == 0 || strcasecmp(key, "identifier") == 0) {
if (pInfo->name) {
rval = BadRequest;
goto unwind;
@@ -978,17 +980,19 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
if (!pInfo->driver) {
xf86Msg(X_INFO, "No input driver specified, ignoring this device.\n");
- xf86Msg(X_INFO, "This device may have been added with another device file.\n");
+ xf86Msg(X_INFO,
+ "This device may have been added with another device file.\n");
rval = BadRequest;
goto unwind;
}
rval = xf86NewInputDevice(pInfo, pdev,
- (!is_auto || (is_auto && xf86Info.autoEnableDevices)));
+ (!is_auto ||
+ (is_auto && xf86Info.autoEnableDevices)));
return rval;
-unwind:
+ unwind:
if (is_auto && !xf86Info.autoAddDevices)
xf86Msg(X_INFO, "AutoAddDevices is off - not adding device.\n");
xf86DeleteInput(pInfo, 0);
@@ -1002,15 +1006,14 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev)
InputDriverPtr drv = NULL;
Bool isMaster = IsMaster(pDev);
- if (pInfo) /* need to get these before RemoveDevice */
+ if (pInfo) /* need to get these before RemoveDevice */
drv = pInfo->drv;
OsBlockSignals();
RemoveDevice(pDev, TRUE);
- if (!isMaster && pInfo != NULL)
- {
- if(drv->UnInit)
+ if (!isMaster && pInfo != NULL) {
+ if (drv->UnInit)
drv->UnInit(drv, pInfo, 0);
else
xf86DeleteInput(pInfo, 0);
@@ -1023,11 +1026,8 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev)
*/
void
-xf86PostMotionEvent(DeviceIntPtr device,
- int is_absolute,
- int first_valuator,
- int num_valuators,
- ...)
+xf86PostMotionEvent(DeviceIntPtr device,
+ int is_absolute, int first_valuator, int num_valuators, ...)
{
va_list var;
int i = 0;
@@ -1039,17 +1039,17 @@ xf86PostMotionEvent(DeviceIntPtr device,
va_start(var, num_valuators);
for (i = 0; i < num_valuators; i++)
valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
+
va_end(var);
xf86PostMotionEventM(device, is_absolute, &mask);
}
void
-xf86PostMotionEventP(DeviceIntPtr device,
- int is_absolute,
- int first_valuator,
- int num_valuators,
- const int *valuators)
+xf86PostMotionEventP(DeviceIntPtr device,
+ int is_absolute,
+ int first_valuator,
+ int num_valuators, const int *valuators)
{
ValuatorMask mask;
@@ -1060,14 +1060,12 @@ xf86PostMotionEventP(DeviceIntPtr device,
}
void
-xf86PostMotionEventM(DeviceIntPtr device,
- int is_absolute,
- const ValuatorMask *mask)
+xf86PostMotionEventM(DeviceIntPtr device,
+ int is_absolute, const ValuatorMask *mask)
{
int flags = 0;
- if (valuator_mask_num_valuators(mask) > 0)
- {
+ if (valuator_mask_num_valuators(mask) > 0) {
if (is_absolute)
flags = POINTER_ABSOLUTE;
else
@@ -1076,21 +1074,18 @@ xf86PostMotionEventM(DeviceIntPtr device,
#if XFreeXDGA
/* The evdev driver may not always send all axes across. */
- if (valuator_mask_isset(mask, 0) ||
- valuator_mask_isset(mask, 1))
+ if (valuator_mask_isset(mask, 0) || valuator_mask_isset(mask, 1))
if (miPointerGetScreen(device)) {
int index = miPointerGetScreen(device)->myNum;
int dx = 0, dy = 0;
- if (valuator_mask_isset(mask, 0))
- {
+ if (valuator_mask_isset(mask, 0)) {
dx = valuator_mask_get(mask, 0);
if (is_absolute)
dx -= device->last.valuators[0];
}
- if (valuator_mask_isset(mask, 1))
- {
+ if (valuator_mask_isset(mask, 1)) {
dy = valuator_mask_get(mask, 1);
if (is_absolute)
dy -= device->last.valuators[1];
@@ -1105,11 +1100,8 @@ xf86PostMotionEventM(DeviceIntPtr device,
}
void
-xf86PostProximityEvent(DeviceIntPtr device,
- int is_in,
- int first_valuator,
- int num_valuators,
- ...)
+xf86PostProximityEvent(DeviceIntPtr device,
+ int is_in, int first_valuator, int num_valuators, ...)
{
va_list var;
int i;
@@ -1121,17 +1113,17 @@ xf86PostProximityEvent(DeviceIntPtr device,
va_start(var, num_valuators);
for (i = 0; i < num_valuators; i++)
valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
+
va_end(var);
xf86PostProximityEventM(device, is_in, &mask);
}
void
-xf86PostProximityEventP(DeviceIntPtr device,
- int is_in,
- int first_valuator,
- int num_valuators,
- const int *valuators)
+xf86PostProximityEventP(DeviceIntPtr device,
+ int is_in,
+ int first_valuator,
+ int num_valuators, const int *valuators)
{
ValuatorMask mask;
@@ -1142,21 +1134,17 @@ xf86PostProximityEventP(DeviceIntPtr device,
}
void
-xf86PostProximityEventM(DeviceIntPtr device,
- int is_in,
- const ValuatorMask *mask)
+xf86PostProximityEventM(DeviceIntPtr device,
+ int is_in, const ValuatorMask *mask)
{
QueueProximityEvents(device, is_in ? ProximityIn : ProximityOut, mask);
}
void
-xf86PostButtonEvent(DeviceIntPtr device,
- int is_absolute,
- int button,
- int is_down,
- int first_valuator,
- int num_valuators,
- ...)
+xf86PostButtonEvent(DeviceIntPtr device,
+ int is_absolute,
+ int button,
+ int is_down, int first_valuator, int num_valuators, ...)
{
va_list var;
ValuatorMask mask;
@@ -1169,19 +1157,19 @@ xf86PostButtonEvent(DeviceIntPtr device,
va_start(var, num_valuators);
for (i = 0; i < num_valuators; i++)
valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
+
va_end(var);
xf86PostButtonEventM(device, is_absolute, button, is_down, &mask);
}
void
-xf86PostButtonEventP(DeviceIntPtr device,
- int is_absolute,
- int button,
- int is_down,
- int first_valuator,
- int num_valuators,
- const int *valuators)
+xf86PostButtonEventP(DeviceIntPtr device,
+ int is_absolute,
+ int button,
+ int is_down,
+ int first_valuator,
+ int num_valuators, const int *valuators)
{
ValuatorMask mask;
@@ -1192,16 +1180,13 @@ xf86PostButtonEventP(DeviceIntPtr device,
}
void
-xf86PostButtonEventM(DeviceIntPtr device,
- int is_absolute,
- int button,
- int is_down,
- const ValuatorMask *mask)
+xf86PostButtonEventM(DeviceIntPtr device,
+ int is_absolute,
+ int button, int is_down, const ValuatorMask *mask)
{
int flags = 0;
- if (valuator_mask_num_valuators(mask) > 0)
- {
+ if (valuator_mask_num_valuators(mask) > 0) {
if (is_absolute)
flags = POINTER_ABSOLUTE;
else
@@ -1223,13 +1208,10 @@ xf86PostButtonEventM(DeviceIntPtr device,
}
void
-xf86PostKeyEvent(DeviceIntPtr device,
- unsigned int key_code,
- int is_down,
- int is_absolute,
- int first_valuator,
- int num_valuators,
- ...)
+xf86PostKeyEvent(DeviceIntPtr device,
+ unsigned int key_code,
+ int is_down,
+ int is_absolute, int first_valuator, int num_valuators, ...)
{
va_list var;
int i = 0;
@@ -1242,19 +1224,18 @@ xf86PostKeyEvent(DeviceIntPtr device,
va_start(var, num_valuators);
for (i = 0; i < num_valuators; i++)
valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
+
va_end(var);
xf86PostKeyEventM(device, key_code, is_down, is_absolute, &mask);
}
void
-xf86PostKeyEventP(DeviceIntPtr device,
- unsigned int key_code,
- int is_down,
- int is_absolute,
- int first_valuator,
- int num_valuators,
- const int *valuators)
+xf86PostKeyEventP(DeviceIntPtr device,
+ unsigned int key_code,
+ int is_down,
+ int is_absolute,
+ int first_valuator, int num_valuators, const int *valuators)
{
ValuatorMask mask;
@@ -1265,17 +1246,16 @@ xf86PostKeyEventP(DeviceIntPtr device,
}
void
-xf86PostKeyEventM(DeviceIntPtr device,
- unsigned int key_code,
- int is_down,
- int is_absolute,
- const ValuatorMask *mask)
+xf86PostKeyEventM(DeviceIntPtr device,
+ unsigned int key_code,
+ int is_down, int is_absolute, const ValuatorMask *mask)
{
#if XFreeXDGA
DeviceIntPtr pointer;
/* Some pointers send key events, paired device is wrong then. */
pointer = GetMaster(device, POINTER_OR_FLOAT);
+
if (miPointerGetScreen(pointer)) {
int index = miPointerGetScreen(pointer)->myNum;
@@ -1285,14 +1265,11 @@ xf86PostKeyEventM(DeviceIntPtr device,
#endif
QueueKeyboardEvents(device,
- is_down ? KeyPress : KeyRelease,
- key_code, mask);
+ is_down ? KeyPress : KeyRelease, key_code, mask);
}
void
-xf86PostKeyboardEvent(DeviceIntPtr device,
- unsigned int key_code,
- int is_down)
+xf86PostKeyboardEvent(DeviceIntPtr device, unsigned int key_code, int is_down)
{
ValuatorMask mask;
@@ -1323,41 +1300,38 @@ xf86FirstLocalDevice(void)
*/
int
-xf86ScaleAxis(int Cx,
- int to_max,
- int to_min,
- int from_max,
- int from_min )
+xf86ScaleAxis(int Cx, int to_max, int to_min, int from_max, int from_min)
{
int X;
int64_t to_width = to_max - to_min;
int64_t from_width = from_max - from_min;
if (from_width) {
- X = (int)(((to_width * (Cx - from_min)) / from_width) + to_min);
+ X = (int) (((to_width * (Cx - from_min)) / from_width) + to_min);
}
else {
- X = 0;
- ErrorF ("Divide by Zero in xf86ScaleAxis\n");
+ X = 0;
+ ErrorF("Divide by Zero in xf86ScaleAxis\n");
}
-
+
if (X > to_max)
- X = to_max;
+ X = to_max;
if (X < to_min)
- X = to_min;
-
+ X = to_min;
+
return X;
}
Bool
-xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int maxval,
- int resolution, int min_res, int max_res, int mode)
+xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval,
+ int maxval, int resolution, int min_res, int max_res,
+ int mode)
{
if (!dev || !dev->valuator)
return FALSE;
- return InitValuatorAxisStruct(dev, axnum, label, minval, maxval, resolution, min_res,
- max_res, mode);
+ return InitValuatorAxisStruct(dev, axnum, label, minval, maxval, resolution,
+ min_res, max_res, mode);
}
/*
@@ -1368,16 +1342,15 @@ void
xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum)
{
if (axnum == 0) {
- dev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2;
+ dev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2;
dev->last.valuators[0] = dev->valuator->axisVal[0];
}
else if (axnum == 1) {
- dev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2;
+ dev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2;
dev->last.valuators[1] = dev->valuator->axisVal[1];
}
}
-
/**
* Deactivate a device. Call this function from the driver if you receive a
* read error or something else that spoils your day.
@@ -1390,11 +1363,10 @@ xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum)
void
xf86DisableDevice(DeviceIntPtr dev, Bool panic)
{
- if(!panic)
- {
+ if (!panic) {
DisableDevice(dev, TRUE);
- } else
- {
+ }
+ else {
SendDevicePresenceEvent(dev->id, DeviceUnrecoverable);
DeleteInputDeviceRequest(dev);
}
diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.h b/xorg-server/hw/xfree86/common/xf86Xinput.h
index ad092dd03..3731a34d5 100644
--- a/xorg-server/hw/xfree86/common/xf86Xinput.h
+++ b/xorg-server/hw/xfree86/common/xf86Xinput.h
@@ -48,7 +48,6 @@
* authorization from the copyright holder(s) and author(s).
*/
-
#ifndef _xf86Xinput_h
#define _xf86Xinput_h
@@ -59,52 +58,48 @@
#include "XIstubs.h"
/* Input device flags */
-#define XI86_ALWAYS_CORE 0x04 /* device always controls the pointer */
+#define XI86_ALWAYS_CORE 0x04 /* device always controls the pointer */
/* the device sends Xinput and core pointer events */
#define XI86_SEND_CORE_EVENTS XI86_ALWAYS_CORE
/* This holds the input driver entry and module information. */
typedef struct _InputDriverRec {
- int driverVersion;
- char * driverName;
- void (*Identify)(int flags);
- int (*PreInit)(struct _InputDriverRec *drv,
- struct _InputInfoRec* pInfo, int flags);
- void (*UnInit)(struct _InputDriverRec *drv,
- struct _InputInfoRec *pInfo,
- int flags);
- pointer module;
- char ** default_options;
+ int driverVersion;
+ char *driverName;
+ void (*Identify) (int flags);
+ int (*PreInit) (struct _InputDriverRec * drv,
+ struct _InputInfoRec * pInfo, int flags);
+ void (*UnInit) (struct _InputDriverRec * drv,
+ struct _InputInfoRec * pInfo, int flags);
+ pointer module;
+ char **default_options;
} InputDriverRec, *InputDriverPtr;
/* This is to input devices what the ScrnInfoRec is to screens. */
typedef struct _InputInfoRec {
struct _InputInfoRec *next;
- char * name;
- char * driver;
-
- int flags;
-
- Bool (*device_control)(DeviceIntPtr device, int what);
- void (*read_input)(struct _InputInfoRec *local);
- int (*control_proc)(struct _InputInfoRec *local,
- xDeviceCtl *control);
- int (*switch_mode)(ClientPtr client, DeviceIntPtr dev,
- int mode);
- int (*set_device_valuators)
- (struct _InputInfoRec *local,
- int *valuators, int first_valuator,
- int num_valuators);
-
- int fd;
- DeviceIntPtr dev;
- pointer private;
- char * type_name;
- InputDriverPtr drv;
- pointer module;
- XF86OptionPtr options;
- InputAttributes *attrs;
+ char *name;
+ char *driver;
+
+ int flags;
+
+ Bool (*device_control) (DeviceIntPtr device, int what);
+ void (*read_input) (struct _InputInfoRec * local);
+ int (*control_proc) (struct _InputInfoRec * local, xDeviceCtl * control);
+ int (*switch_mode) (ClientPtr client, DeviceIntPtr dev, int mode);
+ int (*set_device_valuators)
+ (struct _InputInfoRec * local,
+ int *valuators, int first_valuator, int num_valuators);
+
+ int fd;
+ DeviceIntPtr dev;
+ pointer private;
+ char *type_name;
+ InputDriverPtr drv;
+ pointer module;
+ XF86OptionPtr options;
+ InputAttributes *attrs;
} *InputInfoPtr;
/* xf86Globals.c */
@@ -112,73 +107,95 @@ extern InputInfoPtr xf86InputDevs;
/* xf86Xinput.c */
extern _X_EXPORT void xf86PostMotionEvent(DeviceIntPtr device, int is_absolute,
- int first_valuator, int num_valuators, ...);
+ int first_valuator, int num_valuators,
+ ...);
extern _X_EXPORT void xf86PostMotionEventP(DeviceIntPtr device, int is_absolute,
- int first_valuator, int num_valuators, const int *valuators);
+ int first_valuator,
+ int num_valuators,
+ const int *valuators);
extern _X_EXPORT void xf86PostMotionEventM(DeviceIntPtr device, int is_absolute,
- const ValuatorMask *mask);
+ const ValuatorMask *mask);
extern _X_EXPORT void xf86PostProximityEvent(DeviceIntPtr device, int is_in,
- int first_valuator, int num_valuators, ...);
-extern _X_EXPORT void xf86PostProximityEventP(DeviceIntPtr device, int is_in, int first_valuator,
- int num_valuators, const int *valuators);
+ int first_valuator,
+ int num_valuators, ...);
+extern _X_EXPORT void xf86PostProximityEventP(DeviceIntPtr device, int is_in,
+ int first_valuator,
+ int num_valuators,
+ const int *valuators);
extern _X_EXPORT void xf86PostProximityEventM(DeviceIntPtr device, int is_in,
- const ValuatorMask *mask);
-extern _X_EXPORT void xf86PostButtonEvent(DeviceIntPtr device, int is_absolute, int button,
- int is_down, int first_valuator, int num_valuators,
- ...);
-extern _X_EXPORT void xf86PostButtonEventP(DeviceIntPtr device, int is_absolute, int button,
- int is_down, int first_valuator, int num_valuators,
- const int *valuators);
-extern _X_EXPORT void xf86PostButtonEventM(DeviceIntPtr device, int is_absolute, int button,
- int is_down, const ValuatorMask *mask);
-extern _X_EXPORT void xf86PostKeyEvent(DeviceIntPtr device, unsigned int key_code, int is_down,
- int is_absolute, int first_valuator, int num_valuators,
- ...);
-extern _X_EXPORT void xf86PostKeyEventM(DeviceIntPtr device, unsigned int key_code, int is_down,
- int is_absolute, const ValuatorMask *mask);
-extern _X_EXPORT void xf86PostKeyEventP(DeviceIntPtr device, unsigned int key_code, int is_down,
- int is_absolute, int first_valuator, int num_valuators,
- const int *valuators);
-extern _X_EXPORT void xf86PostKeyboardEvent(DeviceIntPtr device, unsigned int key_code,
- int is_down);
+ const ValuatorMask *mask);
+extern _X_EXPORT void xf86PostButtonEvent(DeviceIntPtr device, int is_absolute,
+ int button, int is_down,
+ int first_valuator, int num_valuators,
+ ...);
+extern _X_EXPORT void xf86PostButtonEventP(DeviceIntPtr device, int is_absolute,
+ int button, int is_down,
+ int first_valuator,
+ int num_valuators,
+ const int *valuators);
+extern _X_EXPORT void xf86PostButtonEventM(DeviceIntPtr device, int is_absolute,
+ int button, int is_down,
+ const ValuatorMask *mask);
+extern _X_EXPORT void xf86PostKeyEvent(DeviceIntPtr device,
+ unsigned int key_code, int is_down,
+ int is_absolute, int first_valuator,
+ int num_valuators, ...);
+extern _X_EXPORT void xf86PostKeyEventM(DeviceIntPtr device,
+ unsigned int key_code, int is_down,
+ int is_absolute,
+ const ValuatorMask *mask);
+extern _X_EXPORT void xf86PostKeyEventP(DeviceIntPtr device,
+ unsigned int key_code, int is_down,
+ int is_absolute, int first_valuator,
+ int num_valuators,
+ const int *valuators);
+extern _X_EXPORT void xf86PostKeyboardEvent(DeviceIntPtr device,
+ unsigned int key_code, int is_down);
extern _X_EXPORT void xf86PostTouchEvent(DeviceIntPtr dev, uint32_t touchid,
uint16_t type, uint32_t flags,
const ValuatorMask *mask);
extern _X_EXPORT InputInfoPtr xf86FirstLocalDevice(void);
-extern _X_EXPORT int xf86ScaleAxis(int Cx, int to_max, int to_min, int from_max, int from_min);
-extern _X_EXPORT void xf86ProcessCommonOptions(InputInfoPtr pInfo, XF86OptionPtr options);
-extern _X_EXPORT Bool xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval,
- int maxval, int resolution, int min_res,
- int max_res, int mode);
+extern _X_EXPORT int xf86ScaleAxis(int Cx, int to_max, int to_min, int from_max,
+ int from_min);
+extern _X_EXPORT void xf86ProcessCommonOptions(InputInfoPtr pInfo,
+ XF86OptionPtr options);
+extern _X_EXPORT Bool xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum,
+ Atom label, int minval,
+ int maxval, int resolution,
+ int min_res, int max_res,
+ int mode);
extern _X_EXPORT void xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum);
extern _X_EXPORT void xf86AddEnabledDevice(InputInfoPtr pInfo);
extern _X_EXPORT void xf86RemoveEnabledDevice(InputInfoPtr pInfo);
extern _X_EXPORT void xf86DisableDevice(DeviceIntPtr dev, Bool panic);
extern _X_EXPORT void xf86EnableDevice(DeviceIntPtr dev);
+
/* not exported */
int xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL is_auto);
InputInfoPtr xf86AllocateInput(void);
/* xf86Helper.c */
-extern _X_EXPORT void xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags);
+extern _X_EXPORT void xf86AddInputDriver(InputDriverPtr driver, pointer module,
+ int flags);
extern _X_EXPORT void xf86DeleteInputDriver(int drvIndex);
extern _X_EXPORT InputDriverPtr xf86LookupInputDriver(const char *name);
extern _X_EXPORT InputInfoPtr xf86LookupInput(const char *name);
extern _X_EXPORT void xf86DeleteInput(InputInfoPtr pInp, int flags);
extern _X_EXPORT void xf86MotionHistoryAllocate(InputInfoPtr pInfo);
-extern _X_EXPORT void xf86IDrvMsgVerb(InputInfoPtr dev,
- MessageType type, int verb,
- const char *format, ...) _X_ATTRIBUTE_PRINTF(4,5);
-extern _X_EXPORT void xf86IDrvMsg(InputInfoPtr dev,
- MessageType type,
- const char *format, ...) _X_ATTRIBUTE_PRINTF(3,4);
-extern _X_EXPORT void xf86VIDrvMsgVerb(InputInfoPtr dev,
- MessageType type,
- int verb,
- const char *format,
- va_list args) _X_ATTRIBUTE_PRINTF(4,0);
+extern _X_EXPORT void
+xf86IDrvMsgVerb(InputInfoPtr dev,
+ MessageType type, int verb, const char *format, ...)
+_X_ATTRIBUTE_PRINTF(4, 5);
+extern _X_EXPORT void
+xf86IDrvMsg(InputInfoPtr dev, MessageType type, const char *format, ...)
+_X_ATTRIBUTE_PRINTF(3, 4);
+extern _X_EXPORT void
+xf86VIDrvMsgVerb(InputInfoPtr dev,
+ MessageType type, int verb, const char *format, va_list args)
+_X_ATTRIBUTE_PRINTF(4, 0);
/* xf86Option.c */
-extern _X_EXPORT void xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts);
+extern _X_EXPORT void
+xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts);
-#endif /* _xf86Xinput_h */
+#endif /* _xf86Xinput_h */
diff --git a/xorg-server/hw/xfree86/common/xf86cmap.c b/xorg-server/hw/xfree86/common/xf86cmap.c
index 191ae6132..cdc8459af 100644
--- a/xorg-server/hw/xfree86/common/xf86cmap.c
+++ b/xorg-server/hw/xfree86/common/xf86cmap.c
@@ -1,1183 +1,1181 @@
-/*
- * Copyright (c) 1998-2001 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#if defined(_XOPEN_SOURCE) || defined(sun) && defined(__SVR4)
-#include <math.h>
-#else
-#define _XOPEN_SOURCE /* to get prototype for pow on some systems */
-#include <math.h>
-#undef _XOPEN_SOURCE
-#endif
-
-#include <X11/X.h>
-#include "misc.h"
-#include <X11/Xproto.h>
-#include "colormapst.h"
-#include "scrnintstr.h"
-
-#include "resource.h"
-
-#include "xf86.h"
-#include "xf86_OSproc.h"
-#include "xf86str.h"
-#include "micmap.h"
-#include "xf86Crtc.h"
-
-#ifdef XFreeXDGA
-#include <X11/extensions/xf86dgaproto.h>
-#include "dgaproc.h"
-#endif
-
-#include "xf86cmap.h"
-
-#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \
- ((CMapScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, CMapScreenKey))->field)
-#define SCREEN_EPILOGUE(pScreen, field, wrapper)\
- ((pScreen)->field = wrapper)
-
-#define LOAD_PALETTE(pmap) \
- ((pmap == GetInstalledmiColormap(pmap->pScreen)) && \
- ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) || \
- xf86Screens[pmap->pScreen->myNum]->vtSema || pScreenPriv->isDGAmode))
-
-
-typedef struct _CMapLink {
- ColormapPtr cmap;
- struct _CMapLink *next;
-} CMapLink, *CMapLinkPtr;
-
-typedef struct {
- ScrnInfoPtr pScrn;
- CloseScreenProcPtr CloseScreen;
- CreateColormapProcPtr CreateColormap;
- DestroyColormapProcPtr DestroyColormap;
- InstallColormapProcPtr InstallColormap;
- StoreColorsProcPtr StoreColors;
- Bool (*EnterVT)(int, int);
- Bool (*SwitchMode)(int, DisplayModePtr, int);
- int (*SetDGAMode)(int, int, DGADevicePtr);
- xf86ChangeGammaProc *ChangeGamma;
- int maxColors;
- int sigRGBbits;
- int gammaElements;
- LOCO *gamma;
- int *PreAllocIndices;
- CMapLinkPtr maps;
- unsigned int flags;
- Bool isDGAmode;
-} CMapScreenRec, *CMapScreenPtr;
-
-typedef struct {
- int numColors;
- LOCO *colors;
- Bool recalculate;
- int overscan;
-} CMapColormapRec, *CMapColormapPtr;
-
-static DevPrivateKeyRec CMapScreenKeyRec;
-#define CMapScreenKeyRegistered dixPrivateKeyRegistered(&CMapScreenKeyRec)
-#define CMapScreenKey (&CMapScreenKeyRec)
-static DevPrivateKeyRec CMapColormapKeyRec;
-#define CMapColormapKey (&CMapColormapKeyRec)
-
-static void CMapInstallColormap(ColormapPtr);
-static void CMapStoreColors(ColormapPtr, int, xColorItem *);
-static Bool CMapCloseScreen (int, ScreenPtr);
-static Bool CMapCreateColormap (ColormapPtr);
-static void CMapDestroyColormap (ColormapPtr);
-
-static Bool CMapEnterVT(int, int);
-static Bool CMapSwitchMode(int, DisplayModePtr, int);
-#ifdef XFreeXDGA
-static int CMapSetDGAMode(int, int, DGADevicePtr);
-#endif
-static int CMapChangeGamma(int, Gamma);
-
-static void ComputeGamma(CMapScreenPtr);
-static Bool CMapAllocateColormapPrivate(ColormapPtr);
-static void CMapRefreshColors(ColormapPtr, int, int*);
-static void CMapSetOverscan(ColormapPtr, int, int *);
-static void CMapReinstallMap(ColormapPtr);
-static void CMapUnwrapScreen(ScreenPtr pScreen);
-
-
-Bool xf86ColormapAllocatePrivates(ScrnInfoPtr pScrn)
-{
- /* If we support a better colormap system, then pretend we succeeded. */
- if (xf86_crtc_supports_gamma(pScrn))
- return TRUE;
- if (!dixRegisterPrivateKey(&CMapScreenKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
-
- if (!dixRegisterPrivateKey(&CMapColormapKeyRec, PRIVATE_COLORMAP, 0))
- return FALSE;
- return TRUE;
-}
-
-Bool xf86HandleColormaps(
- ScreenPtr pScreen,
- int maxColors,
- int sigRGBbits,
- xf86LoadPaletteProc *loadPalette,
- xf86SetOverscanProc *setOverscan,
- unsigned int flags
-){
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- ColormapPtr pDefMap = NULL;
- CMapScreenPtr pScreenPriv;
- LOCO *gamma;
- int *indices;
- int elements;
-
- /* If we support a better colormap system, then pretend we succeeded. */
- if (xf86_crtc_supports_gamma(pScrn))
- return TRUE;
-
- if(!maxColors || !sigRGBbits || !loadPalette)
- return FALSE;
-
- elements = 1 << sigRGBbits;
-
- if(!(gamma = malloc(elements * sizeof(LOCO))))
- return FALSE;
-
- if(!(indices = malloc(maxColors * sizeof(int)))) {
- free(gamma);
- return FALSE;
- }
-
- if(!(pScreenPriv = malloc(sizeof(CMapScreenRec)))) {
- free(gamma);
- free(indices);
- return FALSE;
- }
-
- dixSetPrivate(&pScreen->devPrivates, &CMapScreenKeyRec, pScreenPriv);
-
- pScreenPriv->CloseScreen = pScreen->CloseScreen;
- pScreenPriv->CreateColormap = pScreen->CreateColormap;
- pScreenPriv->DestroyColormap = pScreen->DestroyColormap;
- pScreenPriv->InstallColormap = pScreen->InstallColormap;
- pScreenPriv->StoreColors = pScreen->StoreColors;
- pScreen->CloseScreen = CMapCloseScreen;
- pScreen->CreateColormap = CMapCreateColormap;
- pScreen->DestroyColormap = CMapDestroyColormap;
- pScreen->InstallColormap = CMapInstallColormap;
- pScreen->StoreColors = CMapStoreColors;
-
- pScreenPriv->pScrn = pScrn;
- pScrn->LoadPalette = loadPalette;
- pScrn->SetOverscan = setOverscan;
- pScreenPriv->maxColors = maxColors;
- pScreenPriv->sigRGBbits = sigRGBbits;
- pScreenPriv->gammaElements = elements;
- pScreenPriv->gamma = gamma;
- pScreenPriv->PreAllocIndices = indices;
- pScreenPriv->maps = NULL;
- pScreenPriv->flags = flags;
- pScreenPriv->isDGAmode = FALSE;
-
- pScreenPriv->EnterVT = pScrn->EnterVT;
- pScreenPriv->SwitchMode = pScrn->SwitchMode;
- pScreenPriv->SetDGAMode = pScrn->SetDGAMode;
- pScreenPriv->ChangeGamma = pScrn->ChangeGamma;
-
- if (!(flags & CMAP_LOAD_EVEN_IF_OFFSCREEN)) {
- pScrn->EnterVT = CMapEnterVT;
- if ((flags & CMAP_RELOAD_ON_MODE_SWITCH) && pScrn->SwitchMode)
- pScrn->SwitchMode = CMapSwitchMode;
- }
-#ifdef XFreeXDGA
- pScrn->SetDGAMode = CMapSetDGAMode;
-#endif
- pScrn->ChangeGamma = CMapChangeGamma;
-
- ComputeGamma(pScreenPriv);
-
- /* get the default map */
- dixLookupResourceByType((pointer *)&pDefMap, pScreen->defColormap,
- RT_COLORMAP, serverClient, DixInstallAccess);
-
- if(!CMapAllocateColormapPrivate(pDefMap)) {
- CMapUnwrapScreen(pScreen);
- return FALSE;
- }
-
- /* Force the initial map to be loaded */
- SetInstalledmiColormap(pScreen, NULL);
- CMapInstallColormap(pDefMap);
- return TRUE;
-}
-
-
-/**** Screen functions ****/
-
-
-static Bool
-CMapCloseScreen (int i, ScreenPtr pScreen)
-{
- CMapUnwrapScreen(pScreen);
-
- return (*pScreen->CloseScreen) (i, pScreen);
-}
-
-static Bool
-CMapColormapUseMax(VisualPtr pVisual, CMapScreenPtr pScreenPriv)
-{
- if (pVisual->nplanes > 16)
- return TRUE;
- return ((1 << pVisual->nplanes) > pScreenPriv->maxColors);
-}
-
-static Bool
-CMapAllocateColormapPrivate(ColormapPtr pmap)
-{
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pmap->pScreen->devPrivates, CMapScreenKey);
- CMapColormapPtr pColPriv;
- CMapLinkPtr pLink;
- int numColors;
- LOCO *colors;
-
- if (CMapColormapUseMax(pmap->pVisual, pScreenPriv))
- numColors = pmap->pVisual->ColormapEntries;
- else
- numColors = 1 << pmap->pVisual->nplanes;
-
- if(!(colors = malloc(numColors * sizeof(LOCO))))
- return FALSE;
-
- if(!(pColPriv = malloc(sizeof(CMapColormapRec)))) {
- free(colors);
- return FALSE;
- }
-
- dixSetPrivate(&pmap->devPrivates, CMapColormapKey, pColPriv);
-
- pColPriv->numColors = numColors;
- pColPriv->colors = colors;
- pColPriv->recalculate = TRUE;
- pColPriv->overscan = -1;
-
- /* add map to list */
- pLink = malloc(sizeof(CMapLink));
- if(pLink) {
- pLink->cmap = pmap;
- pLink->next = pScreenPriv->maps;
- pScreenPriv->maps = pLink;
- }
-
- return TRUE;
-}
-
-static Bool
-CMapCreateColormap (ColormapPtr pmap)
-{
- ScreenPtr pScreen = pmap->pScreen;
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, CMapScreenKey);
- Bool ret = FALSE;
-
- pScreen->CreateColormap = pScreenPriv->CreateColormap;
- if((*pScreen->CreateColormap)(pmap)) {
- if(CMapAllocateColormapPrivate(pmap))
- ret = TRUE;
- }
- pScreen->CreateColormap = CMapCreateColormap;
-
- return ret;
-}
-
-static void
-CMapDestroyColormap (ColormapPtr cmap)
-{
- ScreenPtr pScreen = cmap->pScreen;
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, CMapScreenKey);
- CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate(
- &cmap->devPrivates, CMapColormapKey);
- CMapLinkPtr prevLink = NULL, pLink = pScreenPriv->maps;
-
- if(pColPriv) {
- free(pColPriv->colors);
- free(pColPriv);
- }
-
- /* remove map from list */
- while(pLink) {
- if(pLink->cmap == cmap) {
- if(prevLink)
- prevLink->next = pLink->next;
- else
- pScreenPriv->maps = pLink->next;
- free(pLink);
- break;
- }
- prevLink = pLink;
- pLink = pLink->next;
- }
-
- if(pScreenPriv->DestroyColormap) {
- pScreen->DestroyColormap = pScreenPriv->DestroyColormap;
- (*pScreen->DestroyColormap)(cmap);
- pScreen->DestroyColormap = CMapDestroyColormap;
- }
-}
-
-
-
-static void
-CMapStoreColors(
- ColormapPtr pmap,
- int ndef,
- xColorItem *pdefs
-){
- ScreenPtr pScreen = pmap->pScreen;
- VisualPtr pVisual = pmap->pVisual;
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, CMapScreenKey);
- int *indices = pScreenPriv->PreAllocIndices;
- int num = ndef;
-
- /* At the moment this isn't necessary since there's nobody below us */
- pScreen->StoreColors = pScreenPriv->StoreColors;
- (*pScreen->StoreColors)(pmap, ndef, pdefs);
- pScreen->StoreColors = CMapStoreColors;
-
- /* should never get here for these */
- if( (pVisual->class == TrueColor) ||
- (pVisual->class == StaticColor) ||
- (pVisual->class == StaticGray))
- return;
-
- if(pVisual->class == DirectColor) {
- CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate(
- &pmap->devPrivates, CMapColormapKey);
- int i;
-
- if (CMapColormapUseMax(pVisual, pScreenPriv)) {
- int index;
-
- num = 0;
- while(ndef--) {
- if(pdefs[ndef].flags & DoRed) {
- index = (pdefs[ndef].pixel & pVisual->redMask) >>
- pVisual->offsetRed;
- i = num;
- while(i--)
- if(indices[i] == index) break;
- if(i == -1)
- indices[num++] = index;
- }
- if(pdefs[ndef].flags & DoGreen) {
- index = (pdefs[ndef].pixel & pVisual->greenMask) >>
- pVisual->offsetGreen;
- i = num;
- while(i--)
- if(indices[i] == index) break;
- if(i == -1)
- indices[num++] = index;
- }
- if(pdefs[ndef].flags & DoBlue) {
- index = (pdefs[ndef].pixel & pVisual->blueMask) >>
- pVisual->offsetBlue;
- i = num;
- while(i--)
- if(indices[i] == index) break;
- if(i == -1)
- indices[num++] = index;
- }
- }
-
- } else {
- /* not really as overkill as it seems */
- num = pColPriv->numColors;
- for(i = 0; i < pColPriv->numColors; i++)
- indices[i] = i;
- }
- } else {
- while(ndef--)
- indices[ndef] = pdefs[ndef].pixel;
- }
-
- CMapRefreshColors(pmap, num, indices);
-}
-
-
-static void
-CMapInstallColormap(ColormapPtr pmap)
-{
- ScreenPtr pScreen = pmap->pScreen;
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, CMapScreenKey);
-
- if (pmap == GetInstalledmiColormap(pmap->pScreen))
- return;
-
- pScreen->InstallColormap = pScreenPriv->InstallColormap;
- (*pScreen->InstallColormap)(pmap);
- pScreen->InstallColormap = CMapInstallColormap;
-
- /* Important. We let the lower layers, namely DGA,
- overwrite the choice of Colormap to install */
- if (GetInstalledmiColormap(pmap->pScreen))
- pmap = GetInstalledmiColormap(pmap->pScreen);
-
- if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) &&
- (pmap->pVisual->class == TrueColor) &&
- CMapColormapUseMax(pmap->pVisual, pScreenPriv))
- return;
-
- if(LOAD_PALETTE(pmap))
- CMapReinstallMap(pmap);
-}
-
-
-/**** ScrnInfoRec functions ****/
-
-static Bool
-CMapEnterVT(int index, int flags)
-{
- ScrnInfoPtr pScrn = xf86Screens[index];
- ScreenPtr pScreen = screenInfo.screens[index];
- Bool ret;
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, CMapScreenKey);
-
- pScrn->EnterVT = pScreenPriv->EnterVT;
- ret = (*pScreenPriv->EnterVT)(index, flags);
- pScreenPriv->EnterVT = pScrn->EnterVT;
- pScrn->EnterVT = CMapEnterVT;
- if(ret) {
- if(GetInstalledmiColormap(pScreen))
- CMapReinstallMap(GetInstalledmiColormap(pScreen));
- return TRUE;
- }
- return FALSE;
-}
-
-
-static Bool
-CMapSwitchMode(int index, DisplayModePtr mode, int flags)
-{
- ScreenPtr pScreen = screenInfo.screens[index];
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, CMapScreenKey);
-
- if((*pScreenPriv->SwitchMode)(index, mode, flags)) {
- if(GetInstalledmiColormap(pScreen))
- CMapReinstallMap(GetInstalledmiColormap(pScreen));
- return TRUE;
- }
- return FALSE;
-}
-
-#ifdef XFreeXDGA
-static int
-CMapSetDGAMode(int index, int num, DGADevicePtr dev)
-{
- ScreenPtr pScreen = screenInfo.screens[index];
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, CMapScreenKey);
- int ret;
-
- ret = (*pScreenPriv->SetDGAMode)(index, num, dev);
-
- pScreenPriv->isDGAmode = DGAActive(index);
-
- if(!pScreenPriv->isDGAmode && GetInstalledmiColormap(pScreen)
- && xf86Screens[pScreen->myNum]->vtSema)
- CMapReinstallMap(GetInstalledmiColormap(pScreen));
-
- return ret;
-}
-#endif
-
-
-/**** Utilities ****/
-
-static void
-CMapReinstallMap(ColormapPtr pmap)
-{
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pmap->pScreen->devPrivates, CMapScreenKey);
- CMapColormapPtr cmapPriv = (CMapColormapPtr)dixLookupPrivate(
- &pmap->devPrivates, CMapColormapKey);
- ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
- int i = cmapPriv->numColors;
- int *indices = pScreenPriv->PreAllocIndices;
-
- while(i--)
- indices[i] = i;
-
- if(cmapPriv->recalculate)
- CMapRefreshColors(pmap, cmapPriv->numColors, indices);
- else {
- (*pScrn->LoadPalette)(pScrn, cmapPriv->numColors,
- indices, cmapPriv->colors, pmap->pVisual);
- if (pScrn->SetOverscan) {
-#ifdef DEBUGOVERSCAN
- ErrorF("SetOverscan() called from CMapReinstallMap\n");
-#endif
- pScrn->SetOverscan(pScrn, cmapPriv->overscan);
- }
- }
-
- cmapPriv->recalculate = FALSE;
-}
-
-
-static void
-CMapRefreshColors(ColormapPtr pmap, int defs, int* indices)
-{
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pmap->pScreen->devPrivates, CMapScreenKey);
- CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate(
- &pmap->devPrivates, CMapColormapKey);
- VisualPtr pVisual = pmap->pVisual;
- ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
- int numColors, i;
- LOCO *gamma, *colors;
- EntryPtr entry;
- int reds, greens, blues, maxValue, index, shift;
-
- numColors = pColPriv->numColors;
- shift = 16 - pScreenPriv->sigRGBbits;
- maxValue = (1 << pScreenPriv->sigRGBbits) - 1;
- gamma = pScreenPriv->gamma;
- colors = pColPriv->colors;
-
- reds = pVisual->redMask >> pVisual->offsetRed;
- greens = pVisual->greenMask >> pVisual->offsetGreen;
- blues = pVisual->blueMask >> pVisual->offsetBlue;
-
- switch(pVisual->class) {
- case StaticGray:
- for(i = 0; i < numColors; i++) {
- index = (i+1) * maxValue / numColors;
- colors[i].red = gamma[index].red;
- colors[i].green = gamma[index].green;
- colors[i].blue = gamma[index].blue;
- }
- break;
- case TrueColor:
- if (CMapColormapUseMax(pVisual, pScreenPriv)) {
- for(i = 0; i <= reds; i++)
- colors[i].red = gamma[i * maxValue / reds].red;
- for(i = 0; i <= greens; i++)
- colors[i].green = gamma[i * maxValue / greens].green;
- for(i = 0; i <= blues; i++)
- colors[i].blue = gamma[i * maxValue / blues].blue;
- break;
- }
- for(i = 0; i < numColors; i++) {
- colors[i].red = gamma[((i >> pVisual->offsetRed) & reds) *
- maxValue / reds].red;
- colors[i].green = gamma[((i >> pVisual->offsetGreen) & greens) *
- maxValue / greens].green;
- colors[i].blue = gamma[((i >> pVisual->offsetBlue) & blues) *
- maxValue / blues].blue;
- }
- break;
- case StaticColor:
- case PseudoColor:
- case GrayScale:
- for(i = 0; i < defs; i++) {
- index = indices[i];
- entry = (EntryPtr)&pmap->red[index];
-
- if(entry->fShared) {
- colors[index].red =
- gamma[entry->co.shco.red->color >> shift].red;
- colors[index].green =
- gamma[entry->co.shco.green->color >> shift].green;
- colors[index].blue =
- gamma[entry->co.shco.blue->color >> shift].blue;
- } else {
- colors[index].red =
- gamma[entry->co.local.red >> shift].red;
- colors[index].green =
- gamma[entry->co.local.green >> shift].green;
- colors[index].blue =
- gamma[entry->co.local.blue >> shift].blue;
- }
- }
- break;
- case DirectColor:
- if (CMapColormapUseMax(pVisual, pScreenPriv)) {
- for(i = 0; i < defs; i++) {
- index = indices[i];
- if(index <= reds)
- colors[index].red =
- gamma[pmap->red[index].co.local.red >> shift].red;
- if(index <= greens)
- colors[index].green =
- gamma[pmap->green[index].co.local.green >> shift].green;
- if(index <= blues)
- colors[index].blue =
- gamma[pmap->blue[index].co.local.blue >> shift].blue;
-
- }
- break;
- }
- for(i = 0; i < defs; i++) {
- index = indices[i];
-
- colors[index].red = gamma[pmap->red[
- (index >> pVisual->offsetRed) & reds
- ].co.local.red >> shift].red;
- colors[index].green = gamma[pmap->green[
- (index >> pVisual->offsetGreen) & greens
- ].co.local.green >> shift].green;
- colors[index].blue = gamma[pmap->blue[
- (index >> pVisual->offsetBlue) & blues
- ].co.local.blue >> shift].blue;
- }
- break;
- }
-
-
- if(LOAD_PALETTE(pmap))
- (*pScrn->LoadPalette)(pScreenPriv->pScrn, defs, indices,
- colors, pmap->pVisual);
-
- if (pScrn->SetOverscan)
- CMapSetOverscan(pmap, defs, indices);
-
-}
-
-static Bool
-CMapCompareColors(LOCO *color1, LOCO *color2)
-{
- /* return TRUE if the color1 is "closer" to black than color2 */
-#ifdef DEBUGOVERSCAN
- ErrorF("#%02x%02x%02x vs #%02x%02x%02x (%d vs %d)\n",
- color1->red, color1->green, color1->blue,
- color2->red, color2->green, color2->blue,
- color1->red + color1->green + color1->blue,
- color2->red + color2->green + color2->blue);
-#endif
- return (color1->red + color1->green + color1->blue <
- color2->red + color2->green + color2->blue);
-}
-
-static void
-CMapSetOverscan(ColormapPtr pmap, int defs, int *indices)
-{
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pmap->pScreen->devPrivates, CMapScreenKey);
- CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate(
- &pmap->devPrivates, CMapColormapKey);
- ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
- VisualPtr pVisual = pmap->pVisual;
- int i;
- LOCO *colors;
- int index;
- Bool newOverscan = FALSE;
- int overscan, tmpOverscan;
-
- colors = pColPriv->colors;
- overscan = pColPriv->overscan;
-
- /*
- * Search for a new overscan index in the following cases:
- *
- * - The index hasn't yet been initialised.  In this case search
- * for an index that is black or a close match to black.
- *
- * - The colour of the old index is changed. In this case search
- * all indices for a black or close match to black.
- *
- * - The colour of the old index wasn't black. In this case only
- * search the indices that were changed for a better match to black.
- */
-
- switch (pVisual->class) {
- case StaticGray:
- case TrueColor:
- /* Should only come here once. Initialise the overscan index to 0 */
- overscan = 0;
- newOverscan = TRUE;
- break;
- case StaticColor:
- /*
- * Only come here once, but search for the overscan in the same way
- * as for the other cases.
- */
- case DirectColor:
- case PseudoColor:
- case GrayScale:
- if (overscan < 0 || overscan > pScreenPriv->maxColors - 1) {
- /* Uninitialised */
- newOverscan = TRUE;
- } else {
- /* Check if the overscan was changed */
- for (i = 0; i < defs; i++) {
- index = indices[i];
- if (index == overscan) {
- newOverscan = TRUE;
- break;
- }
- }
- }
- if (newOverscan) {
- /* The overscan is either uninitialised or it has been changed */
-
- if (overscan < 0 || overscan > pScreenPriv->maxColors - 1)
- tmpOverscan = pScreenPriv->maxColors - 1;
- else
- tmpOverscan = overscan;
-
- /* search all entries for a close match to black */
- for (i = pScreenPriv->maxColors - 1; i >= 0; i--) {
- if (colors[i].red == 0 && colors[i].green == 0 &&
- colors[i].blue == 0) {
- overscan = i;
-#ifdef DEBUGOVERSCAN
- ErrorF("Black found at index 0x%02x\n", i);
-#endif
- break;
- } else {
-#ifdef DEBUGOVERSCAN
- ErrorF("0x%02x: ", i);
-#endif
- if (CMapCompareColors(&colors[i], &colors[tmpOverscan])) {
- tmpOverscan = i;
-#ifdef DEBUGOVERSCAN
- ErrorF("possible \"Black\" at index 0x%02x\n", i);
-#endif
- }
- }
- }
- if (i < 0)
- overscan = tmpOverscan;
- } else {
- /* Check of the old overscan wasn't black */
- if (colors[overscan].red != 0 || colors[overscan].green != 0 ||
- colors[overscan].blue != 0) {
- int oldOverscan = tmpOverscan = overscan;
- /* See of there is now a better match */
- for (i = 0; i < defs; i++) {
- index = indices[i];
- if (colors[index].red == 0 && colors[index].green == 0 &&
- colors[index].blue == 0) {
- overscan = index;
-#ifdef DEBUGOVERSCAN
- ErrorF("Black found at index 0x%02x\n", index);
-#endif
- break;
- } else {
-#ifdef DEBUGOVERSCAN
- ErrorF("0x%02x: ", index);
-#endif
- if (CMapCompareColors(&colors[index],
- &colors[tmpOverscan])) {
- tmpOverscan = index;
-#ifdef DEBUGOVERSCAN
- ErrorF("possible \"Black\" at index 0x%02x\n",
- index);
-#endif
- }
- }
- }
- if (i == defs)
- overscan = tmpOverscan;
- if (overscan != oldOverscan)
- newOverscan = TRUE;
- }
- }
- break;
- }
- if (newOverscan) {
- pColPriv->overscan = overscan;
- if (LOAD_PALETTE(pmap)) {
-#ifdef DEBUGOVERSCAN
- ErrorF("SetOverscan() called from CmapSetOverscan\n");
-#endif
- pScrn->SetOverscan(pScreenPriv->pScrn, overscan);
- }
- }
-}
-
-static void
-CMapUnwrapScreen(ScreenPtr pScreen)
-{
- CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, CMapScreenKey);
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-
- pScreen->CloseScreen = pScreenPriv->CloseScreen;
- pScreen->CreateColormap = pScreenPriv->CreateColormap;
- pScreen->DestroyColormap = pScreenPriv->DestroyColormap;
- pScreen->InstallColormap = pScreenPriv->InstallColormap;
- pScreen->StoreColors = pScreenPriv->StoreColors;
-
- pScrn->EnterVT = pScreenPriv->EnterVT;
- pScrn->SwitchMode = pScreenPriv->SwitchMode;
- pScrn->SetDGAMode = pScreenPriv->SetDGAMode;
- pScrn->ChangeGamma = pScreenPriv->ChangeGamma;
-
- free(pScreenPriv->gamma);
- free(pScreenPriv->PreAllocIndices);
- free(pScreenPriv);
-}
-
-
-static void
-ComputeGamma(CMapScreenPtr priv)
-{
- int elements = priv->gammaElements - 1;
- double RedGamma, GreenGamma, BlueGamma;
- int i;
-
-#ifndef DONT_CHECK_GAMMA
- /* This check is to catch drivers that are not initialising pScrn->gamma */
- if (priv->pScrn->gamma.red < GAMMA_MIN ||
- priv->pScrn->gamma.red > GAMMA_MAX ||
- priv->pScrn->gamma.green < GAMMA_MIN ||
- priv->pScrn->gamma.green > GAMMA_MAX ||
- priv->pScrn->gamma.blue < GAMMA_MIN ||
- priv->pScrn->gamma.blue > GAMMA_MAX) {
-
- xf86DrvMsgVerb(priv->pScrn->scrnIndex, X_WARNING, 0,
- "The %s driver didn't call xf86SetGamma() to initialise\n"
- "\tthe gamma values.\n", priv->pScrn->driverName);
- xf86DrvMsgVerb(priv->pScrn->scrnIndex, X_WARNING, 0,
- "PLEASE FIX THE `%s' DRIVER!\n", priv->pScrn->driverName);
- priv->pScrn->gamma.red = 1.0;
- priv->pScrn->gamma.green = 1.0;
- priv->pScrn->gamma.blue = 1.0;
- }
-#endif
-
- RedGamma = 1.0 / (double)priv->pScrn->gamma.red;
- GreenGamma = 1.0 / (double)priv->pScrn->gamma.green;
- BlueGamma = 1.0 / (double)priv->pScrn->gamma.blue;
-
- for(i = 0; i <= elements; i++) {
- if(RedGamma == 1.0)
- priv->gamma[i].red = i;
- else
- priv->gamma[i].red = (CARD16)(pow((double)i/(double)elements,
- RedGamma) * (double)elements + 0.5);
-
- if(GreenGamma == 1.0)
- priv->gamma[i].green = i;
- else
- priv->gamma[i].green = (CARD16)(pow((double)i/(double)elements,
- GreenGamma) * (double)elements + 0.5);
-
- if(BlueGamma == 1.0)
- priv->gamma[i].blue = i;
- else
- priv->gamma[i].blue = (CARD16)(pow((double)i/(double)elements,
- BlueGamma) * (double)elements + 0.5);
- }
-}
-
-
-int
-CMapChangeGamma(
- int index,
- Gamma gamma
-){
- int ret = Success;
- ScrnInfoPtr pScrn = xf86Screens[index];
- ScreenPtr pScreen = pScrn->pScreen;
- CMapColormapPtr pColPriv;
- CMapScreenPtr pScreenPriv;
- CMapLinkPtr pLink;
-
- /* Is this sufficient checking ? */
- if(!CMapScreenKeyRegistered)
- return BadImplementation;
-
- pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
- CMapScreenKey);
- if(!pScreenPriv)
- return BadImplementation;
-
- if (gamma.red < GAMMA_MIN || gamma.red > GAMMA_MAX ||
- gamma.green < GAMMA_MIN || gamma.green > GAMMA_MAX ||
- gamma.blue < GAMMA_MIN || gamma.blue > GAMMA_MAX)
- return BadValue;
-
- pScrn->gamma.red = gamma.red;
- pScrn->gamma.green = gamma.green;
- pScrn->gamma.blue = gamma.blue;
-
- ComputeGamma(pScreenPriv);
-
- /* mark all colormaps on this screen */
- pLink = pScreenPriv->maps;
- while(pLink) {
- pColPriv = (CMapColormapPtr)dixLookupPrivate(&pLink->cmap->devPrivates,
- CMapColormapKey);
- pColPriv->recalculate = TRUE;
- pLink = pLink->next;
- }
-
- if(GetInstalledmiColormap(pScreen) &&
- ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) ||
- pScrn->vtSema || pScreenPriv->isDGAmode)) {
- ColormapPtr pMap = GetInstalledmiColormap(pScreen);
-
- if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) &&
- (pMap->pVisual->class == TrueColor) &&
- CMapColormapUseMax(pMap->pVisual, pScreenPriv)) {
-
- /* if the current map doesn't have a palette look
- for another map to change the gamma on. */
-
- pLink = pScreenPriv->maps;
- while(pLink) {
- if(pLink->cmap->pVisual->class == PseudoColor)
- break;
- pLink = pLink->next;
- }
-
- if(pLink) {
- /* need to trick CMapRefreshColors() into thinking
- this is the currently installed map */
- SetInstalledmiColormap(pScreen, pLink->cmap);
- CMapReinstallMap(pLink->cmap);
- SetInstalledmiColormap(pScreen, pMap);
- }
- } else
- CMapReinstallMap(pMap);
- }
-
- pScrn->ChangeGamma = pScreenPriv->ChangeGamma;
- if (pScrn->ChangeGamma)
- ret = pScrn->ChangeGamma(index, gamma);
- pScrn->ChangeGamma = CMapChangeGamma;
-
- return ret;
-}
-
-
-static void
-ComputeGammaRamp (
- CMapScreenPtr priv,
- unsigned short *red,
- unsigned short *green,
- unsigned short *blue
-){
- int elements = priv->gammaElements;
- LOCO *entry = priv->gamma;
- int shift = 16 - priv->sigRGBbits;
-
- while(elements--) {
- entry->red = *(red++) >> shift;
- entry->green = *(green++) >> shift;
- entry->blue = *(blue++) >> shift;
- entry++;
- }
-}
-
-int
-xf86ChangeGammaRamp(
- ScreenPtr pScreen,
- int size,
- unsigned short *red,
- unsigned short *green,
- unsigned short *blue
-){
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- CMapColormapPtr pColPriv;
- CMapScreenPtr pScreenPriv;
- CMapLinkPtr pLink;
-
- if (xf86_crtc_supports_gamma(pScrn)) {
- RRCrtcPtr crtc = xf86CompatRRCrtc(pScrn);
-
- if (crtc) {
- if (crtc->gammaSize != size)
- return BadValue;
-
- RRCrtcGammaSet(crtc, red, green, blue);
-
- return Success;
- }
- }
-
- if(!CMapScreenKeyRegistered)
- return BadImplementation;
-
- pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
- CMapScreenKey);
- if(!pScreenPriv)
- return BadImplementation;
-
- if(pScreenPriv->gammaElements != size)
- return BadValue;
-
- ComputeGammaRamp(pScreenPriv, red, green, blue);
-
- /* mark all colormaps on this screen */
- pLink = pScreenPriv->maps;
- while(pLink) {
- pColPriv = (CMapColormapPtr)dixLookupPrivate(&pLink->cmap->devPrivates,
- CMapColormapKey);
- pColPriv->recalculate = TRUE;
- pLink = pLink->next;
- }
-
- if(GetInstalledmiColormap(pScreen) &&
- ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) ||
- pScrn->vtSema || pScreenPriv->isDGAmode)) {
- ColormapPtr pMap = GetInstalledmiColormap(pScreen);
-
- if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) &&
- (pMap->pVisual->class == TrueColor) &&
- CMapColormapUseMax(pMap->pVisual, pScreenPriv)) {
-
- /* if the current map doesn't have a palette look
- for another map to change the gamma on. */
-
- pLink = pScreenPriv->maps;
- while(pLink) {
- if(pLink->cmap->pVisual->class == PseudoColor)
- break;
- pLink = pLink->next;
- }
-
- if(pLink) {
- /* need to trick CMapRefreshColors() into thinking
- this is the currently installed map */
- SetInstalledmiColormap(pScreen, pLink->cmap);
- CMapReinstallMap(pLink->cmap);
- SetInstalledmiColormap(pScreen, pMap);
- }
- } else
- CMapReinstallMap(pMap);
- }
-
- return Success;
-}
-
-int
-xf86GetGammaRampSize(ScreenPtr pScreen)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- CMapScreenPtr pScreenPriv;
-
- if (xf86_crtc_supports_gamma(pScrn)) {
- RRCrtcPtr crtc = xf86CompatRRCrtc(pScrn);
-
- if (crtc)
- return crtc->gammaSize;
- }
-
- if(!CMapScreenKeyRegistered) return 0;
-
- pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
- CMapScreenKey);
- if(!pScreenPriv) return 0;
-
- return pScreenPriv->gammaElements;
-}
-
-int
-xf86GetGammaRamp(
- ScreenPtr pScreen,
- int size,
- unsigned short *red,
- unsigned short *green,
- unsigned short *blue
-){
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- CMapScreenPtr pScreenPriv;
- LOCO *entry;
- int shift, sigbits;
-
- if (xf86_crtc_supports_gamma(pScrn)) {
- RRCrtcPtr crtc = xf86CompatRRCrtc(pScrn);
-
- if (crtc) {
- if (crtc->gammaSize < size)
- return BadValue;
-
- if (!RRCrtcGammaGet(crtc))
- return BadImplementation;
-
- memcpy(red, crtc->gammaRed, size * sizeof(*red));
- memcpy(green, crtc->gammaGreen, size * sizeof(*green));
- memcpy(blue, crtc->gammaBlue, size * sizeof(*blue));
-
- return Success;
- }
- }
-
- if(!CMapScreenKeyRegistered)
- return BadImplementation;
-
- pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
- CMapScreenKey);
- if(!pScreenPriv)
- return BadImplementation;
-
- if(size > pScreenPriv->gammaElements)
- return BadValue;
-
- entry = pScreenPriv->gamma;
- sigbits = pScreenPriv->sigRGBbits;
-
- while(size--) {
- *red = entry->red << (16 - sigbits);
- *green = entry->green << (16 - sigbits);
- *blue = entry->blue << (16 - sigbits);
- shift = sigbits;
- while(shift < 16) {
- *red |= *red >> shift;
- *green |= *green >> shift;
- *blue |= *blue >> shift;
- shift += sigbits;
- }
- red++; green++; blue++;
- entry++;
- }
-
- return Success;
-}
-
-int
-xf86ChangeGamma(
- ScreenPtr pScreen,
- Gamma gamma
-){
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-
- if(pScrn->ChangeGamma)
- return (*pScrn->ChangeGamma)(pScreen->myNum, gamma);
-
- return BadImplementation;
-}
+/*
+ * Copyright (c) 1998-2001 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#if defined(_XOPEN_SOURCE) || defined(sun) && defined(__SVR4)
+#include <math.h>
+#else
+#define _XOPEN_SOURCE /* to get prototype for pow on some systems */
+#include <math.h>
+#undef _XOPEN_SOURCE
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include <X11/Xproto.h>
+#include "colormapst.h"
+#include "scrnintstr.h"
+
+#include "resource.h"
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86str.h"
+#include "micmap.h"
+#include "xf86Crtc.h"
+
+#ifdef XFreeXDGA
+#include <X11/extensions/xf86dgaproto.h>
+#include "dgaproc.h"
+#endif
+
+#include "xf86cmap.h"
+
+#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \
+ ((CMapScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, CMapScreenKey))->field)
+#define SCREEN_EPILOGUE(pScreen, field, wrapper)\
+ ((pScreen)->field = wrapper)
+
+#define LOAD_PALETTE(pmap) \
+ ((pmap == GetInstalledmiColormap(pmap->pScreen)) && \
+ ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) || \
+ xf86Screens[pmap->pScreen->myNum]->vtSema || pScreenPriv->isDGAmode))
+
+typedef struct _CMapLink {
+ ColormapPtr cmap;
+ struct _CMapLink *next;
+} CMapLink, *CMapLinkPtr;
+
+typedef struct {
+ ScrnInfoPtr pScrn;
+ CloseScreenProcPtr CloseScreen;
+ CreateColormapProcPtr CreateColormap;
+ DestroyColormapProcPtr DestroyColormap;
+ InstallColormapProcPtr InstallColormap;
+ StoreColorsProcPtr StoreColors;
+ Bool (*EnterVT) (int, int);
+ Bool (*SwitchMode) (int, DisplayModePtr, int);
+ int (*SetDGAMode) (int, int, DGADevicePtr);
+ xf86ChangeGammaProc *ChangeGamma;
+ int maxColors;
+ int sigRGBbits;
+ int gammaElements;
+ LOCO *gamma;
+ int *PreAllocIndices;
+ CMapLinkPtr maps;
+ unsigned int flags;
+ Bool isDGAmode;
+} CMapScreenRec, *CMapScreenPtr;
+
+typedef struct {
+ int numColors;
+ LOCO *colors;
+ Bool recalculate;
+ int overscan;
+} CMapColormapRec, *CMapColormapPtr;
+
+static DevPrivateKeyRec CMapScreenKeyRec;
+
+#define CMapScreenKeyRegistered dixPrivateKeyRegistered(&CMapScreenKeyRec)
+#define CMapScreenKey (&CMapScreenKeyRec)
+static DevPrivateKeyRec CMapColormapKeyRec;
+
+#define CMapColormapKey (&CMapColormapKeyRec)
+
+static void CMapInstallColormap(ColormapPtr);
+static void CMapStoreColors(ColormapPtr, int, xColorItem *);
+static Bool CMapCloseScreen(int, ScreenPtr);
+static Bool CMapCreateColormap(ColormapPtr);
+static void CMapDestroyColormap(ColormapPtr);
+
+static Bool CMapEnterVT(int, int);
+static Bool CMapSwitchMode(int, DisplayModePtr, int);
+
+#ifdef XFreeXDGA
+static int CMapSetDGAMode(int, int, DGADevicePtr);
+#endif
+static int CMapChangeGamma(int, Gamma);
+
+static void ComputeGamma(CMapScreenPtr);
+static Bool CMapAllocateColormapPrivate(ColormapPtr);
+static void CMapRefreshColors(ColormapPtr, int, int *);
+static void CMapSetOverscan(ColormapPtr, int, int *);
+static void CMapReinstallMap(ColormapPtr);
+static void CMapUnwrapScreen(ScreenPtr pScreen);
+
+Bool
+xf86ColormapAllocatePrivates(ScrnInfoPtr pScrn)
+{
+ /* If we support a better colormap system, then pretend we succeeded. */
+ if (xf86_crtc_supports_gamma(pScrn))
+ return TRUE;
+ if (!dixRegisterPrivateKey(&CMapScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&CMapColormapKeyRec, PRIVATE_COLORMAP, 0))
+ return FALSE;
+ return TRUE;
+}
+
+Bool
+xf86HandleColormaps(ScreenPtr pScreen,
+ int maxColors,
+ int sigRGBbits,
+ xf86LoadPaletteProc * loadPalette,
+ xf86SetOverscanProc * setOverscan, unsigned int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ ColormapPtr pDefMap = NULL;
+ CMapScreenPtr pScreenPriv;
+ LOCO *gamma;
+ int *indices;
+ int elements;
+
+ /* If we support a better colormap system, then pretend we succeeded. */
+ if (xf86_crtc_supports_gamma(pScrn))
+ return TRUE;
+
+ if (!maxColors || !sigRGBbits || !loadPalette)
+ return FALSE;
+
+ elements = 1 << sigRGBbits;
+
+ if (!(gamma = malloc(elements * sizeof(LOCO))))
+ return FALSE;
+
+ if (!(indices = malloc(maxColors * sizeof(int)))) {
+ free(gamma);
+ return FALSE;
+ }
+
+ if (!(pScreenPriv = malloc(sizeof(CMapScreenRec)))) {
+ free(gamma);
+ free(indices);
+ return FALSE;
+ }
+
+ dixSetPrivate(&pScreen->devPrivates, &CMapScreenKeyRec, pScreenPriv);
+
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreenPriv->CreateColormap = pScreen->CreateColormap;
+ pScreenPriv->DestroyColormap = pScreen->DestroyColormap;
+ pScreenPriv->InstallColormap = pScreen->InstallColormap;
+ pScreenPriv->StoreColors = pScreen->StoreColors;
+ pScreen->CloseScreen = CMapCloseScreen;
+ pScreen->CreateColormap = CMapCreateColormap;
+ pScreen->DestroyColormap = CMapDestroyColormap;
+ pScreen->InstallColormap = CMapInstallColormap;
+ pScreen->StoreColors = CMapStoreColors;
+
+ pScreenPriv->pScrn = pScrn;
+ pScrn->LoadPalette = loadPalette;
+ pScrn->SetOverscan = setOverscan;
+ pScreenPriv->maxColors = maxColors;
+ pScreenPriv->sigRGBbits = sigRGBbits;
+ pScreenPriv->gammaElements = elements;
+ pScreenPriv->gamma = gamma;
+ pScreenPriv->PreAllocIndices = indices;
+ pScreenPriv->maps = NULL;
+ pScreenPriv->flags = flags;
+ pScreenPriv->isDGAmode = FALSE;
+
+ pScreenPriv->EnterVT = pScrn->EnterVT;
+ pScreenPriv->SwitchMode = pScrn->SwitchMode;
+ pScreenPriv->SetDGAMode = pScrn->SetDGAMode;
+ pScreenPriv->ChangeGamma = pScrn->ChangeGamma;
+
+ if (!(flags & CMAP_LOAD_EVEN_IF_OFFSCREEN)) {
+ pScrn->EnterVT = CMapEnterVT;
+ if ((flags & CMAP_RELOAD_ON_MODE_SWITCH) && pScrn->SwitchMode)
+ pScrn->SwitchMode = CMapSwitchMode;
+ }
+#ifdef XFreeXDGA
+ pScrn->SetDGAMode = CMapSetDGAMode;
+#endif
+ pScrn->ChangeGamma = CMapChangeGamma;
+
+ ComputeGamma(pScreenPriv);
+
+ /* get the default map */
+ dixLookupResourceByType((pointer *) &pDefMap, pScreen->defColormap,
+ RT_COLORMAP, serverClient, DixInstallAccess);
+
+ if (!CMapAllocateColormapPrivate(pDefMap)) {
+ CMapUnwrapScreen(pScreen);
+ return FALSE;
+ }
+
+ /* Force the initial map to be loaded */
+ SetInstalledmiColormap(pScreen, NULL);
+ CMapInstallColormap(pDefMap);
+ return TRUE;
+}
+
+/**** Screen functions ****/
+
+static Bool
+CMapCloseScreen(int i, ScreenPtr pScreen)
+{
+ CMapUnwrapScreen(pScreen);
+
+ return (*pScreen->CloseScreen) (i, pScreen);
+}
+
+static Bool
+CMapColormapUseMax(VisualPtr pVisual, CMapScreenPtr pScreenPriv)
+{
+ if (pVisual->nplanes > 16)
+ return TRUE;
+ return ((1 << pVisual->nplanes) > pScreenPriv->maxColors);
+}
+
+static Bool
+CMapAllocateColormapPrivate(ColormapPtr pmap)
+{
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) dixLookupPrivate(&pmap->pScreen->devPrivates,
+ CMapScreenKey);
+ CMapColormapPtr pColPriv;
+ CMapLinkPtr pLink;
+ int numColors;
+ LOCO *colors;
+
+ if (CMapColormapUseMax(pmap->pVisual, pScreenPriv))
+ numColors = pmap->pVisual->ColormapEntries;
+ else
+ numColors = 1 << pmap->pVisual->nplanes;
+
+ if (!(colors = malloc(numColors * sizeof(LOCO))))
+ return FALSE;
+
+ if (!(pColPriv = malloc(sizeof(CMapColormapRec)))) {
+ free(colors);
+ return FALSE;
+ }
+
+ dixSetPrivate(&pmap->devPrivates, CMapColormapKey, pColPriv);
+
+ pColPriv->numColors = numColors;
+ pColPriv->colors = colors;
+ pColPriv->recalculate = TRUE;
+ pColPriv->overscan = -1;
+
+ /* add map to list */
+ pLink = malloc(sizeof(CMapLink));
+ if (pLink) {
+ pLink->cmap = pmap;
+ pLink->next = pScreenPriv->maps;
+ pScreenPriv->maps = pLink;
+ }
+
+ return TRUE;
+}
+
+static Bool
+CMapCreateColormap(ColormapPtr pmap)
+{
+ ScreenPtr pScreen = pmap->pScreen;
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) dixLookupPrivate(&pScreen->devPrivates, CMapScreenKey);
+ Bool ret = FALSE;
+
+ pScreen->CreateColormap = pScreenPriv->CreateColormap;
+ if ((*pScreen->CreateColormap) (pmap)) {
+ if (CMapAllocateColormapPrivate(pmap))
+ ret = TRUE;
+ }
+ pScreen->CreateColormap = CMapCreateColormap;
+
+ return ret;
+}
+
+static void
+CMapDestroyColormap(ColormapPtr cmap)
+{
+ ScreenPtr pScreen = cmap->pScreen;
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) dixLookupPrivate(&pScreen->devPrivates, CMapScreenKey);
+ CMapColormapPtr pColPriv =
+ (CMapColormapPtr) dixLookupPrivate(&cmap->devPrivates, CMapColormapKey);
+ CMapLinkPtr prevLink = NULL, pLink = pScreenPriv->maps;
+
+ if (pColPriv) {
+ free(pColPriv->colors);
+ free(pColPriv);
+ }
+
+ /* remove map from list */
+ while (pLink) {
+ if (pLink->cmap == cmap) {
+ if (prevLink)
+ prevLink->next = pLink->next;
+ else
+ pScreenPriv->maps = pLink->next;
+ free(pLink);
+ break;
+ }
+ prevLink = pLink;
+ pLink = pLink->next;
+ }
+
+ if (pScreenPriv->DestroyColormap) {
+ pScreen->DestroyColormap = pScreenPriv->DestroyColormap;
+ (*pScreen->DestroyColormap) (cmap);
+ pScreen->DestroyColormap = CMapDestroyColormap;
+ }
+}
+
+static void
+CMapStoreColors(ColormapPtr pmap, int ndef, xColorItem * pdefs)
+{
+ ScreenPtr pScreen = pmap->pScreen;
+ VisualPtr pVisual = pmap->pVisual;
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) dixLookupPrivate(&pScreen->devPrivates, CMapScreenKey);
+ int *indices = pScreenPriv->PreAllocIndices;
+ int num = ndef;
+
+ /* At the moment this isn't necessary since there's nobody below us */
+ pScreen->StoreColors = pScreenPriv->StoreColors;
+ (*pScreen->StoreColors) (pmap, ndef, pdefs);
+ pScreen->StoreColors = CMapStoreColors;
+
+ /* should never get here for these */
+ if ((pVisual->class == TrueColor) ||
+ (pVisual->class == StaticColor) || (pVisual->class == StaticGray))
+ return;
+
+ if (pVisual->class == DirectColor) {
+ CMapColormapPtr pColPriv =
+ (CMapColormapPtr) dixLookupPrivate(&pmap->devPrivates,
+ CMapColormapKey);
+ int i;
+
+ if (CMapColormapUseMax(pVisual, pScreenPriv)) {
+ int index;
+
+ num = 0;
+ while (ndef--) {
+ if (pdefs[ndef].flags & DoRed) {
+ index = (pdefs[ndef].pixel & pVisual->redMask) >>
+ pVisual->offsetRed;
+ i = num;
+ while (i--)
+ if (indices[i] == index)
+ break;
+ if (i == -1)
+ indices[num++] = index;
+ }
+ if (pdefs[ndef].flags & DoGreen) {
+ index = (pdefs[ndef].pixel & pVisual->greenMask) >>
+ pVisual->offsetGreen;
+ i = num;
+ while (i--)
+ if (indices[i] == index)
+ break;
+ if (i == -1)
+ indices[num++] = index;
+ }
+ if (pdefs[ndef].flags & DoBlue) {
+ index = (pdefs[ndef].pixel & pVisual->blueMask) >>
+ pVisual->offsetBlue;
+ i = num;
+ while (i--)
+ if (indices[i] == index)
+ break;
+ if (i == -1)
+ indices[num++] = index;
+ }
+ }
+
+ }
+ else {
+ /* not really as overkill as it seems */
+ num = pColPriv->numColors;
+ for (i = 0; i < pColPriv->numColors; i++)
+ indices[i] = i;
+ }
+ }
+ else {
+ while (ndef--)
+ indices[ndef] = pdefs[ndef].pixel;
+ }
+
+ CMapRefreshColors(pmap, num, indices);
+}
+
+static void
+CMapInstallColormap(ColormapPtr pmap)
+{
+ ScreenPtr pScreen = pmap->pScreen;
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) dixLookupPrivate(&pScreen->devPrivates, CMapScreenKey);
+
+ if (pmap == GetInstalledmiColormap(pmap->pScreen))
+ return;
+
+ pScreen->InstallColormap = pScreenPriv->InstallColormap;
+ (*pScreen->InstallColormap) (pmap);
+ pScreen->InstallColormap = CMapInstallColormap;
+
+ /* Important. We let the lower layers, namely DGA,
+ overwrite the choice of Colormap to install */
+ if (GetInstalledmiColormap(pmap->pScreen))
+ pmap = GetInstalledmiColormap(pmap->pScreen);
+
+ if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) &&
+ (pmap->pVisual->class == TrueColor) &&
+ CMapColormapUseMax(pmap->pVisual, pScreenPriv))
+ return;
+
+ if (LOAD_PALETTE(pmap))
+ CMapReinstallMap(pmap);
+}
+
+/**** ScrnInfoRec functions ****/
+
+static Bool
+CMapEnterVT(int index, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ ScreenPtr pScreen = screenInfo.screens[index];
+ Bool ret;
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) dixLookupPrivate(&pScreen->devPrivates, CMapScreenKey);
+
+ pScrn->EnterVT = pScreenPriv->EnterVT;
+ ret = (*pScreenPriv->EnterVT) (index, flags);
+ pScreenPriv->EnterVT = pScrn->EnterVT;
+ pScrn->EnterVT = CMapEnterVT;
+ if (ret) {
+ if (GetInstalledmiColormap(pScreen))
+ CMapReinstallMap(GetInstalledmiColormap(pScreen));
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static Bool
+CMapSwitchMode(int index, DisplayModePtr mode, int flags)
+{
+ ScreenPtr pScreen = screenInfo.screens[index];
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) dixLookupPrivate(&pScreen->devPrivates, CMapScreenKey);
+
+ if ((*pScreenPriv->SwitchMode) (index, mode, flags)) {
+ if (GetInstalledmiColormap(pScreen))
+ CMapReinstallMap(GetInstalledmiColormap(pScreen));
+ return TRUE;
+ }
+ return FALSE;
+}
+
+#ifdef XFreeXDGA
+static int
+CMapSetDGAMode(int index, int num, DGADevicePtr dev)
+{
+ ScreenPtr pScreen = screenInfo.screens[index];
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) dixLookupPrivate(&pScreen->devPrivates, CMapScreenKey);
+ int ret;
+
+ ret = (*pScreenPriv->SetDGAMode) (index, num, dev);
+
+ pScreenPriv->isDGAmode = DGAActive(index);
+
+ if (!pScreenPriv->isDGAmode && GetInstalledmiColormap(pScreen)
+ && xf86Screens[pScreen->myNum]->vtSema)
+ CMapReinstallMap(GetInstalledmiColormap(pScreen));
+
+ return ret;
+}
+#endif
+
+/**** Utilities ****/
+
+static void
+CMapReinstallMap(ColormapPtr pmap)
+{
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) dixLookupPrivate(&pmap->pScreen->devPrivates,
+ CMapScreenKey);
+ CMapColormapPtr cmapPriv =
+ (CMapColormapPtr) dixLookupPrivate(&pmap->devPrivates, CMapColormapKey);
+ ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
+ int i = cmapPriv->numColors;
+ int *indices = pScreenPriv->PreAllocIndices;
+
+ while (i--)
+ indices[i] = i;
+
+ if (cmapPriv->recalculate)
+ CMapRefreshColors(pmap, cmapPriv->numColors, indices);
+ else {
+ (*pScrn->LoadPalette) (pScrn, cmapPriv->numColors,
+ indices, cmapPriv->colors, pmap->pVisual);
+ if (pScrn->SetOverscan) {
+#ifdef DEBUGOVERSCAN
+ ErrorF("SetOverscan() called from CMapReinstallMap\n");
+#endif
+ pScrn->SetOverscan(pScrn, cmapPriv->overscan);
+ }
+ }
+
+ cmapPriv->recalculate = FALSE;
+}
+
+static void
+CMapRefreshColors(ColormapPtr pmap, int defs, int *indices)
+{
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) dixLookupPrivate(&pmap->pScreen->devPrivates,
+ CMapScreenKey);
+ CMapColormapPtr pColPriv =
+ (CMapColormapPtr) dixLookupPrivate(&pmap->devPrivates, CMapColormapKey);
+ VisualPtr pVisual = pmap->pVisual;
+ ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
+ int numColors, i;
+ LOCO *gamma, *colors;
+ EntryPtr entry;
+ int reds, greens, blues, maxValue, index, shift;
+
+ numColors = pColPriv->numColors;
+ shift = 16 - pScreenPriv->sigRGBbits;
+ maxValue = (1 << pScreenPriv->sigRGBbits) - 1;
+ gamma = pScreenPriv->gamma;
+ colors = pColPriv->colors;
+
+ reds = pVisual->redMask >> pVisual->offsetRed;
+ greens = pVisual->greenMask >> pVisual->offsetGreen;
+ blues = pVisual->blueMask >> pVisual->offsetBlue;
+
+ switch (pVisual->class) {
+ case StaticGray:
+ for (i = 0; i < numColors; i++) {
+ index = (i + 1) * maxValue / numColors;
+ colors[i].red = gamma[index].red;
+ colors[i].green = gamma[index].green;
+ colors[i].blue = gamma[index].blue;
+ }
+ break;
+ case TrueColor:
+ if (CMapColormapUseMax(pVisual, pScreenPriv)) {
+ for (i = 0; i <= reds; i++)
+ colors[i].red = gamma[i * maxValue / reds].red;
+ for (i = 0; i <= greens; i++)
+ colors[i].green = gamma[i * maxValue / greens].green;
+ for (i = 0; i <= blues; i++)
+ colors[i].blue = gamma[i * maxValue / blues].blue;
+ break;
+ }
+ for (i = 0; i < numColors; i++) {
+ colors[i].red = gamma[((i >> pVisual->offsetRed) & reds) *
+ maxValue / reds].red;
+ colors[i].green = gamma[((i >> pVisual->offsetGreen) & greens) *
+ maxValue / greens].green;
+ colors[i].blue = gamma[((i >> pVisual->offsetBlue) & blues) *
+ maxValue / blues].blue;
+ }
+ break;
+ case StaticColor:
+ case PseudoColor:
+ case GrayScale:
+ for (i = 0; i < defs; i++) {
+ index = indices[i];
+ entry = (EntryPtr) & pmap->red[index];
+
+ if (entry->fShared) {
+ colors[index].red =
+ gamma[entry->co.shco.red->color >> shift].red;
+ colors[index].green =
+ gamma[entry->co.shco.green->color >> shift].green;
+ colors[index].blue =
+ gamma[entry->co.shco.blue->color >> shift].blue;
+ }
+ else {
+ colors[index].red = gamma[entry->co.local.red >> shift].red;
+ colors[index].green =
+ gamma[entry->co.local.green >> shift].green;
+ colors[index].blue = gamma[entry->co.local.blue >> shift].blue;
+ }
+ }
+ break;
+ case DirectColor:
+ if (CMapColormapUseMax(pVisual, pScreenPriv)) {
+ for (i = 0; i < defs; i++) {
+ index = indices[i];
+ if (index <= reds)
+ colors[index].red =
+ gamma[pmap->red[index].co.local.red >> shift].red;
+ if (index <= greens)
+ colors[index].green =
+ gamma[pmap->green[index].co.local.green >> shift].green;
+ if (index <= blues)
+ colors[index].blue =
+ gamma[pmap->blue[index].co.local.blue >> shift].blue;
+
+ }
+ break;
+ }
+ for (i = 0; i < defs; i++) {
+ index = indices[i];
+
+ colors[index].red = gamma[pmap->red[(index >> pVisual->
+ offsetRed) & reds].co.local.
+ red >> shift].red;
+ colors[index].green =
+ gamma[pmap->green[(index >> pVisual->offsetGreen) & greens].co.
+ local.green >> shift].green;
+ colors[index].blue =
+ gamma[pmap->blue[(index >> pVisual->offsetBlue) & blues].co.
+ local.blue >> shift].blue;
+ }
+ break;
+ }
+
+ if (LOAD_PALETTE(pmap))
+ (*pScrn->LoadPalette) (pScreenPriv->pScrn, defs, indices,
+ colors, pmap->pVisual);
+
+ if (pScrn->SetOverscan)
+ CMapSetOverscan(pmap, defs, indices);
+
+}
+
+static Bool
+CMapCompareColors(LOCO * color1, LOCO * color2)
+{
+ /* return TRUE if the color1 is "closer" to black than color2 */
+#ifdef DEBUGOVERSCAN
+ ErrorF("#%02x%02x%02x vs #%02x%02x%02x (%d vs %d)\n",
+ color1->red, color1->green, color1->blue,
+ color2->red, color2->green, color2->blue,
+ color1->red + color1->green + color1->blue,
+ color2->red + color2->green + color2->blue);
+#endif
+ return (color1->red + color1->green + color1->blue <
+ color2->red + color2->green + color2->blue);
+}
+
+static void
+CMapSetOverscan(ColormapPtr pmap, int defs, int *indices)
+{
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) dixLookupPrivate(&pmap->pScreen->devPrivates,
+ CMapScreenKey);
+ CMapColormapPtr pColPriv =
+ (CMapColormapPtr) dixLookupPrivate(&pmap->devPrivates, CMapColormapKey);
+ ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
+ VisualPtr pVisual = pmap->pVisual;
+ int i;
+ LOCO *colors;
+ int index;
+ Bool newOverscan = FALSE;
+ int overscan, tmpOverscan;
+
+ colors = pColPriv->colors;
+ overscan = pColPriv->overscan;
+
+ /*
+ * Search for a new overscan index in the following cases:
+ *
+ * - The index hasn't yet been initialised.  In this case search
+ * for an index that is black or a close match to black.
+ *
+ * - The colour of the old index is changed. In this case search
+ * all indices for a black or close match to black.
+ *
+ * - The colour of the old index wasn't black. In this case only
+ * search the indices that were changed for a better match to black.
+ */
+
+ switch (pVisual->class) {
+ case StaticGray:
+ case TrueColor:
+ /* Should only come here once. Initialise the overscan index to 0 */
+ overscan = 0;
+ newOverscan = TRUE;
+ break;
+ case StaticColor:
+ /*
+ * Only come here once, but search for the overscan in the same way
+ * as for the other cases.
+ */
+ case DirectColor:
+ case PseudoColor:
+ case GrayScale:
+ if (overscan < 0 || overscan > pScreenPriv->maxColors - 1) {
+ /* Uninitialised */
+ newOverscan = TRUE;
+ }
+ else {
+ /* Check if the overscan was changed */
+ for (i = 0; i < defs; i++) {
+ index = indices[i];
+ if (index == overscan) {
+ newOverscan = TRUE;
+ break;
+ }
+ }
+ }
+ if (newOverscan) {
+ /* The overscan is either uninitialised or it has been changed */
+
+ if (overscan < 0 || overscan > pScreenPriv->maxColors - 1)
+ tmpOverscan = pScreenPriv->maxColors - 1;
+ else
+ tmpOverscan = overscan;
+
+ /* search all entries for a close match to black */
+ for (i = pScreenPriv->maxColors - 1; i >= 0; i--) {
+ if (colors[i].red == 0 && colors[i].green == 0 &&
+ colors[i].blue == 0) {
+ overscan = i;
+#ifdef DEBUGOVERSCAN
+ ErrorF("Black found at index 0x%02x\n", i);
+#endif
+ break;
+ }
+ else {
+#ifdef DEBUGOVERSCAN
+ ErrorF("0x%02x: ", i);
+#endif
+ if (CMapCompareColors(&colors[i], &colors[tmpOverscan])) {
+ tmpOverscan = i;
+#ifdef DEBUGOVERSCAN
+ ErrorF("possible \"Black\" at index 0x%02x\n", i);
+#endif
+ }
+ }
+ }
+ if (i < 0)
+ overscan = tmpOverscan;
+ }
+ else {
+ /* Check of the old overscan wasn't black */
+ if (colors[overscan].red != 0 || colors[overscan].green != 0 ||
+ colors[overscan].blue != 0) {
+ int oldOverscan = tmpOverscan = overscan;
+
+ /* See of there is now a better match */
+ for (i = 0; i < defs; i++) {
+ index = indices[i];
+ if (colors[index].red == 0 && colors[index].green == 0 &&
+ colors[index].blue == 0) {
+ overscan = index;
+#ifdef DEBUGOVERSCAN
+ ErrorF("Black found at index 0x%02x\n", index);
+#endif
+ break;
+ }
+ else {
+#ifdef DEBUGOVERSCAN
+ ErrorF("0x%02x: ", index);
+#endif
+ if (CMapCompareColors(&colors[index],
+ &colors[tmpOverscan])) {
+ tmpOverscan = index;
+#ifdef DEBUGOVERSCAN
+ ErrorF("possible \"Black\" at index 0x%02x\n",
+ index);
+#endif
+ }
+ }
+ }
+ if (i == defs)
+ overscan = tmpOverscan;
+ if (overscan != oldOverscan)
+ newOverscan = TRUE;
+ }
+ }
+ break;
+ }
+ if (newOverscan) {
+ pColPriv->overscan = overscan;
+ if (LOAD_PALETTE(pmap)) {
+#ifdef DEBUGOVERSCAN
+ ErrorF("SetOverscan() called from CmapSetOverscan\n");
+#endif
+ pScrn->SetOverscan(pScreenPriv->pScrn, overscan);
+ }
+ }
+}
+
+static void
+CMapUnwrapScreen(ScreenPtr pScreen)
+{
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) dixLookupPrivate(&pScreen->devPrivates, CMapScreenKey);
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+ pScreen->CloseScreen = pScreenPriv->CloseScreen;
+ pScreen->CreateColormap = pScreenPriv->CreateColormap;
+ pScreen->DestroyColormap = pScreenPriv->DestroyColormap;
+ pScreen->InstallColormap = pScreenPriv->InstallColormap;
+ pScreen->StoreColors = pScreenPriv->StoreColors;
+
+ pScrn->EnterVT = pScreenPriv->EnterVT;
+ pScrn->SwitchMode = pScreenPriv->SwitchMode;
+ pScrn->SetDGAMode = pScreenPriv->SetDGAMode;
+ pScrn->ChangeGamma = pScreenPriv->ChangeGamma;
+
+ free(pScreenPriv->gamma);
+ free(pScreenPriv->PreAllocIndices);
+ free(pScreenPriv);
+}
+
+static void
+ComputeGamma(CMapScreenPtr priv)
+{
+ int elements = priv->gammaElements - 1;
+ double RedGamma, GreenGamma, BlueGamma;
+ int i;
+
+#ifndef DONT_CHECK_GAMMA
+ /* This check is to catch drivers that are not initialising pScrn->gamma */
+ if (priv->pScrn->gamma.red < GAMMA_MIN ||
+ priv->pScrn->gamma.red > GAMMA_MAX ||
+ priv->pScrn->gamma.green < GAMMA_MIN ||
+ priv->pScrn->gamma.green > GAMMA_MAX ||
+ priv->pScrn->gamma.blue < GAMMA_MIN ||
+ priv->pScrn->gamma.blue > GAMMA_MAX) {
+
+ xf86DrvMsgVerb(priv->pScrn->scrnIndex, X_WARNING, 0,
+ "The %s driver didn't call xf86SetGamma() to initialise\n"
+ "\tthe gamma values.\n", priv->pScrn->driverName);
+ xf86DrvMsgVerb(priv->pScrn->scrnIndex, X_WARNING, 0,
+ "PLEASE FIX THE `%s' DRIVER!\n",
+ priv->pScrn->driverName);
+ priv->pScrn->gamma.red = 1.0;
+ priv->pScrn->gamma.green = 1.0;
+ priv->pScrn->gamma.blue = 1.0;
+ }
+#endif
+
+ RedGamma = 1.0 / (double) priv->pScrn->gamma.red;
+ GreenGamma = 1.0 / (double) priv->pScrn->gamma.green;
+ BlueGamma = 1.0 / (double) priv->pScrn->gamma.blue;
+
+ for (i = 0; i <= elements; i++) {
+ if (RedGamma == 1.0)
+ priv->gamma[i].red = i;
+ else
+ priv->gamma[i].red = (CARD16) (pow((double) i / (double) elements,
+ RedGamma) * (double) elements +
+ 0.5);
+
+ if (GreenGamma == 1.0)
+ priv->gamma[i].green = i;
+ else
+ priv->gamma[i].green = (CARD16) (pow((double) i / (double) elements,
+ GreenGamma) *
+ (double) elements + 0.5);
+
+ if (BlueGamma == 1.0)
+ priv->gamma[i].blue = i;
+ else
+ priv->gamma[i].blue = (CARD16) (pow((double) i / (double) elements,
+ BlueGamma) * (double) elements +
+ 0.5);
+ }
+}
+
+int
+CMapChangeGamma(int index, Gamma gamma)
+{
+ int ret = Success;
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ ScreenPtr pScreen = pScrn->pScreen;
+ CMapColormapPtr pColPriv;
+ CMapScreenPtr pScreenPriv;
+ CMapLinkPtr pLink;
+
+ /* Is this sufficient checking ? */
+ if (!CMapScreenKeyRegistered)
+ return BadImplementation;
+
+ pScreenPriv = (CMapScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ CMapScreenKey);
+ if (!pScreenPriv)
+ return BadImplementation;
+
+ if (gamma.red < GAMMA_MIN || gamma.red > GAMMA_MAX ||
+ gamma.green < GAMMA_MIN || gamma.green > GAMMA_MAX ||
+ gamma.blue < GAMMA_MIN || gamma.blue > GAMMA_MAX)
+ return BadValue;
+
+ pScrn->gamma.red = gamma.red;
+ pScrn->gamma.green = gamma.green;
+ pScrn->gamma.blue = gamma.blue;
+
+ ComputeGamma(pScreenPriv);
+
+ /* mark all colormaps on this screen */
+ pLink = pScreenPriv->maps;
+ while (pLink) {
+ pColPriv = (CMapColormapPtr) dixLookupPrivate(&pLink->cmap->devPrivates,
+ CMapColormapKey);
+ pColPriv->recalculate = TRUE;
+ pLink = pLink->next;
+ }
+
+ if (GetInstalledmiColormap(pScreen) &&
+ ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) ||
+ pScrn->vtSema || pScreenPriv->isDGAmode)) {
+ ColormapPtr pMap = GetInstalledmiColormap(pScreen);
+
+ if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) &&
+ (pMap->pVisual->class == TrueColor) &&
+ CMapColormapUseMax(pMap->pVisual, pScreenPriv)) {
+
+ /* if the current map doesn't have a palette look
+ for another map to change the gamma on. */
+
+ pLink = pScreenPriv->maps;
+ while (pLink) {
+ if (pLink->cmap->pVisual->class == PseudoColor)
+ break;
+ pLink = pLink->next;
+ }
+
+ if (pLink) {
+ /* need to trick CMapRefreshColors() into thinking
+ this is the currently installed map */
+ SetInstalledmiColormap(pScreen, pLink->cmap);
+ CMapReinstallMap(pLink->cmap);
+ SetInstalledmiColormap(pScreen, pMap);
+ }
+ }
+ else
+ CMapReinstallMap(pMap);
+ }
+
+ pScrn->ChangeGamma = pScreenPriv->ChangeGamma;
+ if (pScrn->ChangeGamma)
+ ret = pScrn->ChangeGamma(index, gamma);
+ pScrn->ChangeGamma = CMapChangeGamma;
+
+ return ret;
+}
+
+static void
+ComputeGammaRamp(CMapScreenPtr priv,
+ unsigned short *red,
+ unsigned short *green, unsigned short *blue)
+{
+ int elements = priv->gammaElements;
+ LOCO *entry = priv->gamma;
+ int shift = 16 - priv->sigRGBbits;
+
+ while (elements--) {
+ entry->red = *(red++) >> shift;
+ entry->green = *(green++) >> shift;
+ entry->blue = *(blue++) >> shift;
+ entry++;
+ }
+}
+
+int
+xf86ChangeGammaRamp(ScreenPtr pScreen,
+ int size,
+ unsigned short *red,
+ unsigned short *green, unsigned short *blue)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ CMapColormapPtr pColPriv;
+ CMapScreenPtr pScreenPriv;
+ CMapLinkPtr pLink;
+
+ if (xf86_crtc_supports_gamma(pScrn)) {
+ RRCrtcPtr crtc = xf86CompatRRCrtc(pScrn);
+
+ if (crtc) {
+ if (crtc->gammaSize != size)
+ return BadValue;
+
+ RRCrtcGammaSet(crtc, red, green, blue);
+
+ return Success;
+ }
+ }
+
+ if (!CMapScreenKeyRegistered)
+ return BadImplementation;
+
+ pScreenPriv = (CMapScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ CMapScreenKey);
+ if (!pScreenPriv)
+ return BadImplementation;
+
+ if (pScreenPriv->gammaElements != size)
+ return BadValue;
+
+ ComputeGammaRamp(pScreenPriv, red, green, blue);
+
+ /* mark all colormaps on this screen */
+ pLink = pScreenPriv->maps;
+ while (pLink) {
+ pColPriv = (CMapColormapPtr) dixLookupPrivate(&pLink->cmap->devPrivates,
+ CMapColormapKey);
+ pColPriv->recalculate = TRUE;
+ pLink = pLink->next;
+ }
+
+ if (GetInstalledmiColormap(pScreen) &&
+ ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) ||
+ pScrn->vtSema || pScreenPriv->isDGAmode)) {
+ ColormapPtr pMap = GetInstalledmiColormap(pScreen);
+
+ if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) &&
+ (pMap->pVisual->class == TrueColor) &&
+ CMapColormapUseMax(pMap->pVisual, pScreenPriv)) {
+
+ /* if the current map doesn't have a palette look
+ for another map to change the gamma on. */
+
+ pLink = pScreenPriv->maps;
+ while (pLink) {
+ if (pLink->cmap->pVisual->class == PseudoColor)
+ break;
+ pLink = pLink->next;
+ }
+
+ if (pLink) {
+ /* need to trick CMapRefreshColors() into thinking
+ this is the currently installed map */
+ SetInstalledmiColormap(pScreen, pLink->cmap);
+ CMapReinstallMap(pLink->cmap);
+ SetInstalledmiColormap(pScreen, pMap);
+ }
+ }
+ else
+ CMapReinstallMap(pMap);
+ }
+
+ return Success;
+}
+
+int
+xf86GetGammaRampSize(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ CMapScreenPtr pScreenPriv;
+
+ if (xf86_crtc_supports_gamma(pScrn)) {
+ RRCrtcPtr crtc = xf86CompatRRCrtc(pScrn);
+
+ if (crtc)
+ return crtc->gammaSize;
+ }
+
+ if (!CMapScreenKeyRegistered)
+ return 0;
+
+ pScreenPriv = (CMapScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ CMapScreenKey);
+ if (!pScreenPriv)
+ return 0;
+
+ return pScreenPriv->gammaElements;
+}
+
+int
+xf86GetGammaRamp(ScreenPtr pScreen,
+ int size,
+ unsigned short *red,
+ unsigned short *green, unsigned short *blue)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ CMapScreenPtr pScreenPriv;
+ LOCO *entry;
+ int shift, sigbits;
+
+ if (xf86_crtc_supports_gamma(pScrn)) {
+ RRCrtcPtr crtc = xf86CompatRRCrtc(pScrn);
+
+ if (crtc) {
+ if (crtc->gammaSize < size)
+ return BadValue;
+
+ if (!RRCrtcGammaGet(crtc))
+ return BadImplementation;
+
+ memcpy(red, crtc->gammaRed, size * sizeof(*red));
+ memcpy(green, crtc->gammaGreen, size * sizeof(*green));
+ memcpy(blue, crtc->gammaBlue, size * sizeof(*blue));
+
+ return Success;
+ }
+ }
+
+ if (!CMapScreenKeyRegistered)
+ return BadImplementation;
+
+ pScreenPriv = (CMapScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ CMapScreenKey);
+ if (!pScreenPriv)
+ return BadImplementation;
+
+ if (size > pScreenPriv->gammaElements)
+ return BadValue;
+
+ entry = pScreenPriv->gamma;
+ sigbits = pScreenPriv->sigRGBbits;
+
+ while (size--) {
+ *red = entry->red << (16 - sigbits);
+ *green = entry->green << (16 - sigbits);
+ *blue = entry->blue << (16 - sigbits);
+ shift = sigbits;
+ while (shift < 16) {
+ *red |= *red >> shift;
+ *green |= *green >> shift;
+ *blue |= *blue >> shift;
+ shift += sigbits;
+ }
+ red++;
+ green++;
+ blue++;
+ entry++;
+ }
+
+ return Success;
+}
+
+int
+xf86ChangeGamma(ScreenPtr pScreen, Gamma gamma)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+ if (pScrn->ChangeGamma)
+ return (*pScrn->ChangeGamma) (pScreen->myNum, gamma);
+
+ return BadImplementation;
+}
diff --git a/xorg-server/hw/xfree86/common/xf86cmap.h b/xorg-server/hw/xfree86/common/xf86cmap.h
index caa01e8ed..2661cf429 100644
--- a/xorg-server/hw/xfree86/common/xf86cmap.h
+++ b/xorg-server/hw/xfree86/common/xf86cmap.h
@@ -1,79 +1,67 @@
-
-/*
- * Copyright (c) 1998-2001 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-#ifndef _XF86CMAP_H
-#define _XF86CMAP_H
-
-#include "xf86str.h"
-#include "colormapst.h"
-
-#define CMAP_PALETTED_TRUECOLOR 0x0000001
-#define CMAP_RELOAD_ON_MODE_SWITCH 0x0000002
-#define CMAP_LOAD_EVEN_IF_OFFSCREEN 0x0000004
-
-extern _X_EXPORT Bool xf86HandleColormaps(
- ScreenPtr pScreen,
- int maxCol,
- int sigRGBbits,
- xf86LoadPaletteProc *loadPalette,
- xf86SetOverscanProc *setOverscan,
- unsigned int flags
-);
-
-extern _X_EXPORT Bool xf86ColormapAllocatePrivates(
- ScrnInfoPtr pScrn
-);
-
-extern _X_EXPORT int
-xf86ChangeGamma(
- ScreenPtr pScreen,
- Gamma newGamma
-);
-
-extern _X_EXPORT int
-xf86ChangeGammaRamp(
- ScreenPtr pScreen,
- int size,
- unsigned short *red,
- unsigned short *green,
- unsigned short *blue
-);
-
-extern _X_EXPORT int xf86GetGammaRampSize(ScreenPtr pScreen);
-
-extern _X_EXPORT int
-xf86GetGammaRamp(
- ScreenPtr pScreen,
- int size,
- unsigned short *red,
- unsigned short *green,
- unsigned short *blue
-);
-
-#endif /* _XF86CMAP_H */
-
+
+/*
+ * Copyright (c) 1998-2001 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifndef _XF86CMAP_H
+#define _XF86CMAP_H
+
+#include "xf86str.h"
+#include "colormapst.h"
+
+#define CMAP_PALETTED_TRUECOLOR 0x0000001
+#define CMAP_RELOAD_ON_MODE_SWITCH 0x0000002
+#define CMAP_LOAD_EVEN_IF_OFFSCREEN 0x0000004
+
+extern _X_EXPORT Bool xf86HandleColormaps(ScreenPtr pScreen,
+ int maxCol,
+ int sigRGBbits,
+ xf86LoadPaletteProc * loadPalette,
+ xf86SetOverscanProc * setOverscan,
+ unsigned int flags);
+
+extern _X_EXPORT Bool xf86ColormapAllocatePrivates(ScrnInfoPtr pScrn);
+
+extern _X_EXPORT int
+ xf86ChangeGamma(ScreenPtr pScreen, Gamma newGamma);
+
+extern _X_EXPORT int
+
+xf86ChangeGammaRamp(ScreenPtr pScreen,
+ int size,
+ unsigned short *red,
+ unsigned short *green, unsigned short *blue);
+
+extern _X_EXPORT int xf86GetGammaRampSize(ScreenPtr pScreen);
+
+extern _X_EXPORT int
+
+xf86GetGammaRamp(ScreenPtr pScreen,
+ int size,
+ unsigned short *red,
+ unsigned short *green, unsigned short *blue);
+
+#endif /* _XF86CMAP_H */
diff --git a/xorg-server/hw/xfree86/common/xf86fbman.c b/xorg-server/hw/xfree86/common/xf86fbman.c
index ccb761a2c..3c29bf531 100644
--- a/xorg-server/hw/xfree86/common/xf86fbman.c
+++ b/xorg-server/hw/xfree86/common/xf86fbman.c
@@ -1,1446 +1,1431 @@
-
-/*
- * Copyright (c) 1998-2001 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "regionstr.h"
-#include "xf86fbman.h"
-
-/*
-#define DEBUG
-*/
-
-static DevPrivateKeyRec xf86FBManagerKeyRec;
-static DevPrivateKey xf86FBManagerKey;
-
-Bool xf86RegisterOffscreenManager(
- ScreenPtr pScreen,
- FBManagerFuncsPtr funcs
-){
-
- xf86FBManagerKey = &xf86FBManagerKeyRec;
-
- if (!dixRegisterPrivateKey(&xf86FBManagerKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
-
- dixSetPrivate(&pScreen->devPrivates, xf86FBManagerKey, funcs);
-
- return TRUE;
-}
-
-
-Bool
-xf86FBManagerRunning(ScreenPtr pScreen)
-{
- if (xf86FBManagerKey == NULL)
- return FALSE;
-
- if(!dixLookupPrivate(&pScreen->devPrivates, xf86FBManagerKey))
- return FALSE;
-
- return TRUE;
-}
-
-Bool
-xf86RegisterFreeBoxCallback(
- ScreenPtr pScreen,
- FreeBoxCallbackProcPtr FreeBoxCallback,
- pointer devPriv
-){
- FBManagerFuncsPtr funcs;
-
- if(xf86FBManagerKey == NULL)
- return FALSE;
- if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBManagerKey)))
- return FALSE;
-
- return (*funcs->RegisterFreeBoxCallback)(pScreen, FreeBoxCallback, devPriv);
-}
-
-
-FBAreaPtr
-xf86AllocateOffscreenArea(
- ScreenPtr pScreen,
- int w, int h,
- int gran,
- MoveAreaCallbackProcPtr moveCB,
- RemoveAreaCallbackProcPtr removeCB,
- pointer privData
-){
- FBManagerFuncsPtr funcs;
-
- if(xf86FBManagerKey == NULL)
- return NULL;
- if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBManagerKey)))
- return NULL;
-
- return (*funcs->AllocateOffscreenArea)(
- pScreen, w, h, gran, moveCB, removeCB, privData);
-}
-
-
-FBLinearPtr
-xf86AllocateOffscreenLinear(
- ScreenPtr pScreen,
- int length,
- int gran,
- MoveLinearCallbackProcPtr moveCB,
- RemoveLinearCallbackProcPtr removeCB,
- pointer privData
-){
- FBManagerFuncsPtr funcs;
-
- if(xf86FBManagerKey == NULL)
- return NULL;
- if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBManagerKey)))
- return NULL;
-
- return (*funcs->AllocateOffscreenLinear)(
- pScreen, length, gran, moveCB, removeCB, privData);
-}
-
-
-void
-xf86FreeOffscreenArea(FBAreaPtr area)
-{
- FBManagerFuncsPtr funcs;
-
- if(!area) return;
-
- if(xf86FBManagerKey == NULL)
- return;
- if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(
- &area->pScreen->devPrivates, xf86FBManagerKey)))
- return;
-
- (*funcs->FreeOffscreenArea)(area);
-
- return;
-}
-
-
-void
-xf86FreeOffscreenLinear(FBLinearPtr linear)
-{
- FBManagerFuncsPtr funcs;
-
- if(!linear) return;
-
- if(xf86FBManagerKey == NULL)
- return;
- if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(
- &linear->pScreen->devPrivates, xf86FBManagerKey)))
- return;
-
- (*funcs->FreeOffscreenLinear)(linear);
-
- return;
-}
-
-
-Bool
-xf86ResizeOffscreenArea(
- FBAreaPtr resize,
- int w, int h
-){
- FBManagerFuncsPtr funcs;
-
- if(!resize) return FALSE;
-
- if(xf86FBManagerKey == NULL)
- return FALSE;
- if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(
- &resize->pScreen->devPrivates, xf86FBManagerKey)))
- return FALSE;
-
- return (*funcs->ResizeOffscreenArea)(resize, w, h);
-}
-
-Bool
-xf86ResizeOffscreenLinear(
- FBLinearPtr resize,
- int size
-){
- FBManagerFuncsPtr funcs;
-
- if(!resize) return FALSE;
-
- if(xf86FBManagerKey == NULL)
- return FALSE;
- if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(
- &resize->pScreen->devPrivates, xf86FBManagerKey)))
- return FALSE;
-
- return (*funcs->ResizeOffscreenLinear)(resize, size);
-}
-
-
-Bool
-xf86QueryLargestOffscreenArea(
- ScreenPtr pScreen,
- int *w, int *h,
- int gran,
- int preferences,
- int severity
-){
- FBManagerFuncsPtr funcs;
-
- *w = 0;
- *h = 0;
-
- if(xf86FBManagerKey == NULL)
- return FALSE;
- if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBManagerKey)))
- return FALSE;
-
- return (*funcs->QueryLargestOffscreenArea)(
- pScreen, w, h, gran, preferences, severity);
-}
-
-Bool
-xf86QueryLargestOffscreenLinear(
- ScreenPtr pScreen,
- int *size,
- int gran,
- int severity
-){
- FBManagerFuncsPtr funcs;
-
- *size = 0;
-
- if(xf86FBManagerKey == NULL)
- return FALSE;
- if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBManagerKey)))
- return FALSE;
-
- return (*funcs->QueryLargestOffscreenLinear)(
- pScreen, size, gran, severity);
-}
-
-
-Bool
-xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
-{
- FBManagerFuncsPtr funcs;
-
- if(xf86FBManagerKey == NULL)
- return FALSE;
- if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBManagerKey)))
- return FALSE;
-
- return (*funcs->PurgeOffscreenAreas)(pScreen);
-}
-
-/************************************************************\
-
- Below is a specific implementation of an offscreen manager.
-
-\************************************************************/
-
-static DevPrivateKeyRec xf86FBScreenKeyRec;
-#define xf86FBScreenKey (&xf86FBScreenKeyRec)
-
-typedef struct _FBLink {
- FBArea area;
- struct _FBLink *next;
-} FBLink, *FBLinkPtr;
-
-typedef struct _FBLinearLink {
- FBLinear linear;
- int free; /* need to add free here as FBLinear is publicly accessible */
- FBAreaPtr area; /* only used if allocation came from XY area */
- struct _FBLinearLink *next;
-} FBLinearLink, *FBLinearLinkPtr;
-
-
-typedef struct {
- ScreenPtr pScreen;
- RegionPtr InitialBoxes;
- RegionPtr FreeBoxes;
- FBLinkPtr UsedAreas;
- int NumUsedAreas;
- FBLinearLinkPtr LinearAreas;
- CloseScreenProcPtr CloseScreen;
- int NumCallbacks;
- FreeBoxCallbackProcPtr *FreeBoxesUpdateCallback;
- DevUnion *devPrivates;
-} FBManager, *FBManagerPtr;
-
-
-static void
-SendCallFreeBoxCallbacks(FBManagerPtr offman)
-{
- int i = offman->NumCallbacks;
-
- while(i--) {
- (*offman->FreeBoxesUpdateCallback[i])(
- offman->pScreen, offman->FreeBoxes, offman->devPrivates[i].ptr);
- }
-}
-
-static Bool
-localRegisterFreeBoxCallback(
- ScreenPtr pScreen,
- FreeBoxCallbackProcPtr FreeBoxCallback,
- pointer devPriv
-){
- FBManagerPtr offman;
- FreeBoxCallbackProcPtr *newCallbacks;
- DevUnion *newPrivates;
-
- offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBScreenKey);
- newCallbacks = realloc( offman->FreeBoxesUpdateCallback,
- sizeof(FreeBoxCallbackProcPtr) * (offman->NumCallbacks + 1));
-
- newPrivates = realloc(offman->devPrivates,
- sizeof(DevUnion) * (offman->NumCallbacks + 1));
-
- if(!newCallbacks || !newPrivates)
- return FALSE;
-
- offman->FreeBoxesUpdateCallback = newCallbacks;
- offman->devPrivates = newPrivates;
-
- offman->FreeBoxesUpdateCallback[offman->NumCallbacks] = FreeBoxCallback;
- offman->devPrivates[offman->NumCallbacks].ptr = devPriv;
- offman->NumCallbacks++;
-
- SendCallFreeBoxCallbacks(offman);
-
- return TRUE;
-}
-
-
-static FBAreaPtr
-AllocateArea(
- FBManagerPtr offman,
- int w, int h,
- int granularity,
- MoveAreaCallbackProcPtr moveCB,
- RemoveAreaCallbackProcPtr removeCB,
- pointer privData
-){
- ScreenPtr pScreen = offman->pScreen;
- FBLinkPtr link = NULL;
- FBAreaPtr area = NULL;
- RegionRec NewReg;
- int i, x = 0, num;
- BoxPtr boxp;
-
- if(granularity <= 1) granularity = 0;
-
- boxp = RegionRects(offman->FreeBoxes);
- num = RegionNumRects(offman->FreeBoxes);
-
- /* look through the free boxes */
- for(i = 0; i < num; i++, boxp++) {
- x = boxp->x1;
- if (granularity > 1)
- x = ((x + granularity - 1) / granularity) * granularity;
-
- if(((boxp->y2 - boxp->y1) < h) || ((boxp->x2 - x) < w))
- continue;
-
- link = malloc(sizeof(FBLink));
- if(!link) return NULL;
-
- area = &(link->area);
- link->next = offman->UsedAreas;
- offman->UsedAreas = link;
- offman->NumUsedAreas++;
- break;
- }
-
- /* try to boot a removeable one out if we are not expendable ourselves */
- if(!area && !removeCB) {
- link = offman->UsedAreas;
-
- while(link) {
- if(!link->area.RemoveAreaCallback) {
- link = link->next;
- continue;
- }
-
- boxp = &(link->area.box);
- x = boxp->x1;
- if (granularity > 1)
- x = ((x + granularity - 1) / granularity) * granularity;
-
- if(((boxp->y2 - boxp->y1) < h) || ((boxp->x2 - x) < w)) {
- link = link->next;
- continue;
- }
-
- /* bye, bye */
- (*link->area.RemoveAreaCallback)(&link->area);
- RegionInit(&NewReg, &(link->area.box), 1);
- RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &NewReg);
- RegionUninit(&NewReg);
-
- area = &(link->area);
- break;
- }
- }
-
- if(area) {
- area->pScreen = pScreen;
- area->granularity = granularity;
- area->box.x1 = x;
- area->box.x2 = x + w;
- area->box.y1 = boxp->y1;
- area->box.y2 = boxp->y1 + h;
- area->MoveAreaCallback = moveCB;
- area->RemoveAreaCallback = removeCB;
- area->devPrivate.ptr = privData;
-
- RegionInit(&NewReg, &(area->box), 1);
- RegionSubtract(offman->FreeBoxes, offman->FreeBoxes, &NewReg);
- RegionUninit(&NewReg);
- }
-
- return area;
-}
-
-static FBAreaPtr
-localAllocateOffscreenArea(
- ScreenPtr pScreen,
- int w, int h,
- int gran,
- MoveAreaCallbackProcPtr moveCB,
- RemoveAreaCallbackProcPtr removeCB,
- pointer privData
-){
- FBManagerPtr offman;
- FBAreaPtr area = NULL;
-
- offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBScreenKey);
- if((area = AllocateArea(offman, w, h, gran, moveCB, removeCB, privData)))
- SendCallFreeBoxCallbacks(offman);
-
- return area;
-}
-
-
-static void
-localFreeOffscreenArea(FBAreaPtr area)
-{
- FBManagerPtr offman;
- FBLinkPtr pLink, pLinkPrev = NULL;
- RegionRec FreedRegion;
- ScreenPtr pScreen;
-
- pScreen = area->pScreen;
- offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBScreenKey);
- pLink = offman->UsedAreas;
- if(!pLink) return;
-
- while(&(pLink->area) != area) {
- pLinkPrev = pLink;
- pLink = pLink->next;
- if(!pLink) return;
- }
-
- /* put the area back into the pool */
- RegionInit(&FreedRegion, &(pLink->area.box), 1);
- RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedRegion);
- RegionUninit(&FreedRegion);
-
- if(pLinkPrev)
- pLinkPrev->next = pLink->next;
- else offman->UsedAreas = pLink->next;
-
- free(pLink);
- offman->NumUsedAreas--;
-
- SendCallFreeBoxCallbacks(offman);
-}
-
-
-
-static Bool
-localResizeOffscreenArea(
- FBAreaPtr resize,
- int w, int h
-){
- FBManagerPtr offman;
- ScreenPtr pScreen;
- BoxRec OrigArea;
- RegionRec FreedReg;
- FBAreaPtr area = NULL;
- FBLinkPtr pLink, newLink, pLinkPrev = NULL;
-
- pScreen = resize->pScreen;
- offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBScreenKey);
- /* find this link */
- if(!(pLink = offman->UsedAreas))
- return FALSE;
-
- while(&(pLink->area) != resize) {
- pLinkPrev = pLink;
- pLink = pLink->next;
- if(!pLink) return FALSE;
- }
-
- OrigArea.x1 = resize->box.x1;
- OrigArea.x2 = resize->box.x2;
- OrigArea.y1 = resize->box.y1;
- OrigArea.y2 = resize->box.y2;
-
- /* if it's smaller, this is easy */
-
- if((w <= (resize->box.x2 - resize->box.x1)) &&
- (h <= (resize->box.y2 - resize->box.y1))) {
- RegionRec NewReg;
-
- resize->box.x2 = resize->box.x1 + w;
- resize->box.y2 = resize->box.y1 + h;
-
- if((resize->box.y2 == OrigArea.y2) &&
- (resize->box.x2 == OrigArea.x2))
- return TRUE;
-
- RegionInit(&FreedReg, &OrigArea, 1);
- RegionInit(&NewReg, &(resize->box), 1);
- RegionSubtract(&FreedReg, &FreedReg, &NewReg);
- RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
- RegionUninit(&FreedReg);
- RegionUninit(&NewReg);
-
- SendCallFreeBoxCallbacks(offman);
-
- return TRUE;
- }
-
-
- /* otherwise we remove the old region */
-
- RegionInit(&FreedReg, &OrigArea, 1);
- RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
-
- /* remove the old link */
- if(pLinkPrev)
- pLinkPrev->next = pLink->next;
- else offman->UsedAreas = pLink->next;
-
- /* and try to add a new one */
-
- if((area = AllocateArea(offman, w, h, resize->granularity,
- resize->MoveAreaCallback, resize->RemoveAreaCallback,
- resize->devPrivate.ptr))) {
-
- /* copy data over to our link and replace the new with old */
- memcpy(resize, area, sizeof(FBArea));
-
- pLinkPrev = NULL;
- newLink = offman->UsedAreas;
-
- while(&(newLink->area) != area) {
- pLinkPrev = newLink;
- newLink = newLink->next;
- }
-
- if(pLinkPrev)
- pLinkPrev->next = newLink->next;
- else offman->UsedAreas = newLink->next;
-
- pLink->next = offman->UsedAreas;
- offman->UsedAreas = pLink;
-
- free(newLink);
-
- /* AllocateArea added one but we really only exchanged one */
- offman->NumUsedAreas--;
- } else {
- /* reinstate the old region */
- RegionSubtract(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
- RegionUninit(&FreedReg);
-
- pLink->next = offman->UsedAreas;
- offman->UsedAreas = pLink;
- return FALSE;
- }
-
-
- RegionUninit(&FreedReg);
-
- SendCallFreeBoxCallbacks(offman);
-
- return TRUE;
-}
-
-static Bool
-localQueryLargestOffscreenArea(
- ScreenPtr pScreen,
- int *width, int *height,
- int granularity,
- int preferences,
- int severity
-){
- FBManagerPtr offman;
- RegionPtr newRegion = NULL;
- BoxPtr pbox;
- int nbox;
- int x, w, h, area, oldArea;
-
- *width = *height = oldArea = 0;
-
- if(granularity <= 1) granularity = 0;
-
- if((preferences < 0) || (preferences > 3))
- return FALSE;
-
- offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBScreenKey);
- if(severity < 0) severity = 0;
- if(severity > 2) severity = 2;
-
- switch(severity) {
- case 2:
- if(offman->NumUsedAreas) {
- FBLinkPtr pLink;
- RegionRec tmpRegion;
- newRegion = RegionCreate(NULL, 1);
- RegionCopy(newRegion, offman->InitialBoxes);
- pLink = offman->UsedAreas;
-
- while(pLink) {
- if(!pLink->area.RemoveAreaCallback) {
- RegionInit(&tmpRegion, &(pLink->area.box), 1);
- RegionSubtract(newRegion, newRegion, &tmpRegion);
- RegionUninit(&tmpRegion);
- }
- pLink = pLink->next;
- }
-
- nbox = RegionNumRects(newRegion);
- pbox = RegionRects(newRegion);
- break;
- }
- case 1:
- if(offman->NumUsedAreas) {
- FBLinkPtr pLink;
- RegionRec tmpRegion;
- newRegion = RegionCreate(NULL, 1);
- RegionCopy(newRegion, offman->FreeBoxes);
- pLink = offman->UsedAreas;
-
- while(pLink) {
- if(pLink->area.RemoveAreaCallback) {
- RegionInit(&tmpRegion, &(pLink->area.box), 1);
- RegionAppend(newRegion, &tmpRegion);
- RegionUninit(&tmpRegion);
- }
- pLink = pLink->next;
- }
-
- nbox = RegionNumRects(newRegion);
- pbox = RegionRects(newRegion);
- break;
- }
- default:
- nbox = RegionNumRects(offman->FreeBoxes);
- pbox = RegionRects(offman->FreeBoxes);
- break;
- }
-
- while(nbox--) {
- x = pbox->x1;
- if (granularity > 1)
- x = ((x + granularity - 1) / granularity) * granularity;
-
- w = pbox->x2 - x;
- h = pbox->y2 - pbox->y1;
- area = w * h;
-
- if(w > 0) {
- Bool gotIt = FALSE;
- switch(preferences) {
- case FAVOR_AREA_THEN_WIDTH:
- if((area > oldArea) || ((area == oldArea) && (w > *width)))
- gotIt = TRUE;
- break;
- case FAVOR_AREA_THEN_HEIGHT:
- if((area > oldArea) || ((area == oldArea) && (h > *height)))
- gotIt = TRUE;
- break;
- case FAVOR_WIDTH_THEN_AREA:
- if((w > *width) || ((w == *width) && (area > oldArea)))
- gotIt = TRUE;
- break;
- case FAVOR_HEIGHT_THEN_AREA:
- if((h > *height) || ((h == *height) && (area > oldArea)))
- gotIt = TRUE;
- break;
- }
- if(gotIt) {
- *width = w;
- *height = h;
- oldArea = area;
- }
- }
- pbox++;
- }
-
- if(newRegion)
- RegionDestroy(newRegion);
-
- return TRUE;
-}
-
-static Bool
-localPurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
-{
- FBManagerPtr offman;
- FBLinkPtr pLink, tmp, pPrev = NULL;
- RegionRec FreedRegion;
- Bool anyUsed = FALSE;
-
- offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBScreenKey);
- pLink = offman->UsedAreas;
- if(!pLink) return TRUE;
-
- while(pLink) {
- if(pLink->area.RemoveAreaCallback) {
- (*pLink->area.RemoveAreaCallback)(&pLink->area);
-
- RegionInit(&FreedRegion, &(pLink->area.box), 1);
- RegionAppend(offman->FreeBoxes, &FreedRegion);
- RegionUninit(&FreedRegion);
-
- if(pPrev)
- pPrev->next = pLink->next;
- else offman->UsedAreas = pLink->next;
-
- tmp = pLink;
- pLink = pLink->next;
- free(tmp);
- offman->NumUsedAreas--;
- anyUsed = TRUE;
- } else {
- pPrev = pLink;
- pLink = pLink->next;
- }
- }
-
- if(anyUsed) {
- RegionValidate(offman->FreeBoxes, &anyUsed);
- SendCallFreeBoxCallbacks(offman);
- }
-
- return TRUE;
-}
-
-static void
-LinearMoveCBWrapper(FBAreaPtr from, FBAreaPtr to)
-{
- /* this will never get called */
-}
-
-static void
-LinearRemoveCBWrapper(FBAreaPtr area)
-{
- FBManagerPtr offman;
- FBLinearLinkPtr pLink, pLinkPrev = NULL;
- ScreenPtr pScreen = area->pScreen;
-
- offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBScreenKey);
- pLink = offman->LinearAreas;
- if(!pLink) return;
-
- while(pLink->area != area) {
- pLinkPrev = pLink;
- pLink = pLink->next;
- if(!pLink) return;
- }
-
- /* give the user the callback it is expecting */
- (*pLink->linear.RemoveLinearCallback)(&(pLink->linear));
-
- if(pLinkPrev)
- pLinkPrev->next = pLink->next;
- else offman->LinearAreas = pLink->next;
-
- free(pLink);
-}
-
-static void
-DumpDebug(FBLinearLinkPtr pLink)
-{
-#ifdef DEBUG
- if (!pLink) ErrorF("MMmm, PLINK IS NULL!\n");
-
- while (pLink) {
- ErrorF(" Offset:%08x, Size:%08x, %s,%s\n",
- pLink->linear.offset,
- pLink->linear.size,
- pLink->free ? "Free" : "Used",
- pLink->area ? "Area" : "Linear");
-
- pLink = pLink->next;
- }
-#endif
-}
-
-static FBLinearPtr
-AllocateLinear(
- FBManagerPtr offman,
- int size,
- int granularity,
- pointer privData
-){
- ScreenPtr pScreen = offman->pScreen;
- FBLinearLinkPtr linear = NULL;
- FBLinearLinkPtr newlink = NULL;
- int offset, end;
-
- if(size <= 0) return NULL;
-
- if (!offman->LinearAreas) return NULL;
-
- linear = offman->LinearAreas;
- while (linear) {
- /* Make sure we get a free area that's not an XY fallback case */
- if (!linear->area && linear->free) {
- offset = linear->linear.offset;
- if (granularity > 1)
- offset = ((offset + granularity - 1) / granularity) * granularity;
- end = offset+size;
- if (end <= (linear->linear.offset + linear->linear.size))
- break;
- }
- linear = linear->next;
- }
- if (!linear)
- return NULL;
-
- /* break left */
- if (offset > linear->linear.offset) {
- newlink = malloc(sizeof(FBLinearLink));
- if (!newlink)
- return NULL;
- newlink->area = NULL;
- newlink->linear.offset = offset;
- newlink->linear.size = linear->linear.size - (offset - linear->linear.offset);
- newlink->free = 1;
- newlink->next = linear->next;
- linear->linear.size -= newlink->linear.size;
- linear->next = newlink;
- linear = newlink;
- }
-
- /* break right */
- if (size < linear->linear.size) {
- newlink = malloc(sizeof(FBLinearLink));
- if (!newlink)
- return NULL;
- newlink->area = NULL;
- newlink->linear.offset = offset + size;
- newlink->linear.size = linear->linear.size - size;
- newlink->free = 1;
- newlink->next = linear->next;
- linear->linear.size = size;
- linear->next = newlink;
- }
-
- /* p = middle block */
- linear->linear.granularity = granularity;
- linear->free = 0;
- linear->linear.pScreen = pScreen;
- linear->linear.MoveLinearCallback = NULL;
- linear->linear.RemoveLinearCallback = NULL;
- linear->linear.devPrivate.ptr = NULL;
-
- DumpDebug(offman->LinearAreas);
-
- return &(linear->linear);
-}
-
-static FBLinearPtr
-localAllocateOffscreenLinear(
- ScreenPtr pScreen,
- int length,
- int gran,
- MoveLinearCallbackProcPtr moveCB,
- RemoveLinearCallbackProcPtr removeCB,
- pointer privData
-){
- FBManagerPtr offman;
- FBLinearLinkPtr link;
- FBAreaPtr area;
- FBLinearPtr linear = NULL;
- BoxPtr extents;
- int w, h, pitch;
-
- offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBScreenKey);
-
- /* Try to allocate from linear memory first...... */
- DebugF("ALLOCATING LINEAR\n");
- if ((linear = AllocateLinear(offman, length, gran, privData)))
- return linear;
-
- DebugF("NOPE, ALLOCATING AREA\n");
-
- if(!(link = malloc(sizeof(FBLinearLink))))
- return NULL;
-
- /* No linear available, so try and pinch some from the XY areas */
- extents = RegionExtents(offman->InitialBoxes);
- pitch = extents->x2 - extents->x1;
-
- if (gran > 1) {
- if (gran > pitch) {
- /* we can't match the specified alignment with XY allocations */
- free(link);
- return NULL;
- }
-
- if (pitch % gran) {
- /* pitch and granularity aren't a perfect match, let's allocate
- * a bit more so we can align later on
- */
- length += gran - 1;
- }
- }
-
- if(length < pitch) { /* special case */
- w = length;
- h = 1;
- } else {
- w = pitch;
- h = (length + pitch - 1) / pitch;
- }
-
- if((area = localAllocateOffscreenArea(pScreen, w, h, gran,
- moveCB ? LinearMoveCBWrapper : NULL,
- removeCB ? LinearRemoveCBWrapper : NULL,
- privData)))
- {
- link->area = area;
- link->free = 0;
- link->next = offman->LinearAreas;
- offman->LinearAreas = link;
- linear = &(link->linear);
- linear->pScreen = pScreen;
- linear->size = h * w;
- linear->offset = (pitch * area->box.y1) + area->box.x1;
- if (gran > 1)
- linear->offset = ((linear->offset + gran - 1) / gran) * gran;
- linear->granularity = gran;
- linear->MoveLinearCallback = moveCB;
- linear->RemoveLinearCallback = removeCB;
- linear->devPrivate.ptr = privData;
- } else
- free(link);
-
- DumpDebug(offman->LinearAreas);
-
- return linear;
-}
-
-
-static void
-localFreeOffscreenLinear(FBLinearPtr linear)
-{
- FBManagerPtr offman;
- FBLinearLinkPtr pLink, pLinkPrev = NULL;
- ScreenPtr pScreen = linear->pScreen;
-
- offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBScreenKey);
- pLink = offman->LinearAreas;
- if(!pLink) return;
-
- while(&(pLink->linear) != linear) {
- pLinkPrev = pLink;
- pLink = pLink->next;
- if(!pLink) return;
- }
-
- if(pLink->area) { /* really an XY area */
- DebugF("FREEING AREA\n");
- localFreeOffscreenArea(pLink->area);
- if(pLinkPrev)
- pLinkPrev->next = pLink->next;
- else offman->LinearAreas = pLink->next;
- free(pLink);
- DumpDebug(offman->LinearAreas);
- return;
- }
-
- pLink->free = 1;
-
- if (pLink->next && pLink->next->free) {
- FBLinearLinkPtr p = pLink->next;
- pLink->linear.size += p->linear.size;
- pLink->next = p->next;
- free(p);
- }
-
- if(pLinkPrev) {
- if (pLinkPrev->next && pLinkPrev->next->free && !pLinkPrev->area) {
- FBLinearLinkPtr p = pLinkPrev->next;
- pLinkPrev->linear.size += p->linear.size;
- pLinkPrev->next = p->next;
- free(p);
- }
- }
-
- DebugF("FREEING LINEAR\n");
- DumpDebug(offman->LinearAreas);
-}
-
-
-static Bool
-localResizeOffscreenLinear(FBLinearPtr resize, int length)
-{
- FBManagerPtr offman;
- FBLinearLinkPtr pLink;
- ScreenPtr pScreen = resize->pScreen;
-
- offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBScreenKey);
- pLink = offman->LinearAreas;
- if(!pLink) return FALSE;
-
- while(&(pLink->linear) != resize) {
- pLink = pLink->next;
- if(!pLink) return FALSE;
- }
-
- /* This could actually be alot smarter and try to move allocations
- from XY to linear when available. For now if it was XY, we keep
- it XY */
-
- if(pLink->area) { /* really an XY area */
- BoxPtr extents;
- int pitch, w, h;
-
- extents = RegionExtents(offman->InitialBoxes);
- pitch = extents->x2 - extents->x1;
-
- if(length < pitch) { /* special case */
- w = length;
- h = 1;
- } else {
- w = pitch;
- h = (length + pitch - 1) / pitch;
- }
-
- if(localResizeOffscreenArea(pLink->area, w, h)) {
- resize->size = h * w;
- resize->offset = (pitch * pLink->area->box.y1) + pLink->area->box.x1;
- return TRUE;
- }
- } else {
- /* TODO!!!! resize the linear area */
- }
-
- return FALSE;
-}
-
-
-static Bool
-localQueryLargestOffscreenLinear(
- ScreenPtr pScreen,
- int *size,
- int gran,
- int priority
-)
-{
- FBManagerPtr offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBScreenKey);
- FBLinearLinkPtr pLink;
- FBLinearLinkPtr pLinkRet;
-
- *size = 0;
-
- pLink = offman->LinearAreas;
-
- if (pLink && !pLink->area) {
- pLinkRet = pLink;
- while (pLink) {
- if (pLink->free) {
- if (pLink->linear.size > pLinkRet->linear.size)
- pLinkRet = pLink;
- }
- pLink = pLink->next;
- }
-
- if (pLinkRet->free) {
- *size = pLinkRet->linear.size;
- return TRUE;
- }
- } else {
- int w, h;
-
- if(localQueryLargestOffscreenArea(pScreen, &w, &h, gran,
- FAVOR_WIDTH_THEN_AREA, priority))
- {
- FBManagerPtr offman;
- BoxPtr extents;
-
- offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBScreenKey);
- extents = RegionExtents(offman->InitialBoxes);
- if((extents->x2 - extents->x1) == w)
- *size = w * h;
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-
-
-static FBManagerFuncs xf86FBManFuncs = {
- localAllocateOffscreenArea,
- localFreeOffscreenArea,
- localResizeOffscreenArea,
- localQueryLargestOffscreenArea,
- localRegisterFreeBoxCallback,
- localAllocateOffscreenLinear,
- localFreeOffscreenLinear,
- localResizeOffscreenLinear,
- localQueryLargestOffscreenLinear,
- localPurgeUnlockedOffscreenAreas
- };
-
-
-static Bool
-xf86FBCloseScreen (int i, ScreenPtr pScreen)
-{
- FBLinkPtr pLink, tmp;
- FBLinearLinkPtr pLinearLink, tmp2;
- FBManagerPtr offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBScreenKey);
-
- pScreen->CloseScreen = offman->CloseScreen;
-
- pLink = offman->UsedAreas;
- while(pLink) {
- tmp = pLink;
- pLink = pLink->next;
- free(tmp);
- }
-
- pLinearLink = offman->LinearAreas;
- while(pLinearLink) {
- tmp2 = pLinearLink;
- pLinearLink = pLinearLink->next;
- free(tmp2);
- }
-
- RegionDestroy(offman->InitialBoxes);
- RegionDestroy(offman->FreeBoxes);
-
- free(offman->FreeBoxesUpdateCallback);
- free(offman->devPrivates);
- free(offman);
- dixSetPrivate(&pScreen->devPrivates, xf86FBScreenKey, NULL);
-
- 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;
- }
-
- if (FullBox->y2 < FullBox->y1) return FALSE;
- if (FullBox->x2 < FullBox->x1) return FALSE;
-
- RegionInit(&ScreenRegion, &ScreenBox, 1);
- RegionInit(&FullRegion, FullBox, 1);
-
- RegionSubtract(&FullRegion, &FullRegion, &ScreenRegion);
-
- ret = xf86InitFBManagerRegion(pScreen, &FullRegion);
-
- RegionUninit(&ScreenRegion);
- RegionUninit(&FullRegion);
-
- return ret;
-}
-
-Bool
-xf86InitFBManagerArea(
- ScreenPtr pScreen,
- int PixelArea,
- int Verbosity
-)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xRectangle Rect[3];
- RegionPtr pRegion, pScreenRegion;
- int nRect;
- Bool ret = FALSE;
-
- if (PixelArea < (pScrn->displayWidth * pScrn->virtualY))
- return FALSE;
-
- Rect[0].x = Rect[0].y = 0;
- Rect[0].width = pScrn->displayWidth;
- Rect[0].height = PixelArea / pScrn->displayWidth;
- nRect = 1;
-
- /* Add a possible partial scanline */
- if ((Rect[1].height = Rect[1].width = PixelArea % pScrn->displayWidth)) {
- Rect[1].x = 0;
- Rect[1].y = Rect[0].height;
- Rect[1].height = 1;
- nRect++;
- }
-
- /* Factor out virtual resolution */
- pRegion = RegionFromRects(nRect, Rect, 0);
- if (pRegion) {
- if (!RegionNar(pRegion)) {
- Rect[2].x = Rect[2].y = 0;
- Rect[2].width = pScrn->virtualX;
- Rect[2].height = pScrn->virtualY;
-
- pScreenRegion = RegionFromRects(1, &Rect[2], 0);
- if (pScreenRegion) {
- if (!RegionNar(pScreenRegion)) {
- RegionSubtract(pRegion, pRegion, pScreenRegion);
-
- ret = xf86InitFBManagerRegion(pScreen, pRegion);
-
- if (ret && xf86GetVerbosity() >= Verbosity) {
- int scrnIndex = pScrn->scrnIndex;
-
- xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity,
- "Largest offscreen areas (with overlaps):\n");
-
- if (Rect[2].width < Rect[0].width) {
- xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity,
- "\t%d x %d rectangle at %d,0\n",
- Rect[0].width - Rect[2].width,
- Rect[0].height,
- Rect[2].width);
- }
- if (Rect[2].width < Rect[1].width) {
- xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity,
- "\t%d x %d rectangle at %d,0\n",
- Rect[1].width - Rect[2].width,
- Rect[0].height + Rect[1].height,
- Rect[2].width);
- }
- if (Rect[2].height < Rect[0].height) {
- xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity,
- "\t%d x %d rectangle at 0,%d\n",
- Rect[0].width,
- Rect[0].height - Rect[2].height,
- Rect[2].height);
- }
- if (Rect[1].height) {
- xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity,
- "\t%d x %d rectangle at 0,%d\n",
- Rect[1].width,
- Rect[0].height - Rect[2].height +
- Rect[1].height,
- Rect[2].height);
- }
- }
- }
-
- RegionDestroy(pScreenRegion);
- }
- }
-
- RegionDestroy(pRegion);
- }
-
- return ret;
-}
-
-Bool
-xf86InitFBManagerRegion(
- ScreenPtr pScreen,
- RegionPtr FullRegion
-){
- FBManagerPtr offman;
-
- if(RegionNil(FullRegion))
- return FALSE;
-
- if (!dixRegisterPrivateKey(&xf86FBScreenKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
-
- if(!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs))
- return FALSE;
-
- offman = malloc(sizeof(FBManager));
- if(!offman) return FALSE;
-
- dixSetPrivate(&pScreen->devPrivates, xf86FBScreenKey, offman);
-
- offman->CloseScreen = pScreen->CloseScreen;
- pScreen->CloseScreen = xf86FBCloseScreen;
-
- offman->InitialBoxes = RegionCreate(NULL, 1);
- offman->FreeBoxes = RegionCreate(NULL, 1);
-
- RegionCopy(offman->InitialBoxes, FullRegion);
- RegionCopy(offman->FreeBoxes, FullRegion);
-
- offman->pScreen = pScreen;
- offman->UsedAreas = NULL;
- offman->LinearAreas = NULL;
- offman->NumUsedAreas = 0;
- offman->NumCallbacks = 0;
- offman->FreeBoxesUpdateCallback = NULL;
- offman->devPrivates = NULL;
-
- return TRUE;
-}
-
-Bool
-xf86InitFBManagerLinear(
- ScreenPtr pScreen,
- int offset,
- int size
-){
- FBManagerPtr offman;
- FBLinearLinkPtr link;
- FBLinearPtr linear;
-
- if (size <= 0)
- return FALSE;
-
- /* we expect people to have called the Area setup first for pixmap cache */
- if (!dixLookupPrivate(&pScreen->devPrivates, xf86FBScreenKey))
- return FALSE;
-
- offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBScreenKey);
- offman->LinearAreas = malloc(sizeof(FBLinearLink));
- if (!offman->LinearAreas)
- return FALSE;
-
- link = offman->LinearAreas;
- link->area = NULL;
- link->next = NULL;
- link->free = 1;
- linear = &(link->linear);
- linear->pScreen = pScreen;
- linear->size = size;
- linear->offset = offset;
- linear->granularity = 0;
- linear->MoveLinearCallback = NULL;
- linear->RemoveLinearCallback = NULL;
- linear->devPrivate.ptr = NULL;
-
- return TRUE;
-}
-
-
-/* This is an implementation specific function and should
- disappear after the next release. People should use the
- real linear functions instead */
-
-FBAreaPtr
-xf86AllocateLinearOffscreenArea (
- ScreenPtr pScreen,
- int length,
- int gran,
- MoveAreaCallbackProcPtr moveCB,
- RemoveAreaCallbackProcPtr removeCB,
- pointer privData
-){
- FBManagerFuncsPtr funcs;
- FBManagerPtr offman;
- BoxPtr extents;
- int w, h;
-
- if(xf86FBManagerKey == NULL)
- return NULL;
- if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBManagerKey)))
- return NULL;
-
- offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
- xf86FBScreenKey);
- extents = RegionExtents(offman->InitialBoxes);
- w = extents->x2 - extents->x1;
-
- if (gran > 1) {
- if (gran > w)
- return NULL;
-
- if (w % gran)
- length += gran - 1;
- }
-
- if(length <= w) { /* special case */
- h = 1;
- w = length;
- } else {
- h = (length + w - 1) / w;
- }
-
- return (*funcs->AllocateOffscreenArea)(
- pScreen, w, h, gran, moveCB, removeCB, privData);
-}
+
+/*
+ * Copyright (c) 1998-2001 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "regionstr.h"
+#include "xf86fbman.h"
+
+/*
+#define DEBUG
+*/
+
+static DevPrivateKeyRec xf86FBManagerKeyRec;
+static DevPrivateKey xf86FBManagerKey;
+
+Bool
+xf86RegisterOffscreenManager(ScreenPtr pScreen, FBManagerFuncsPtr funcs)
+{
+
+ xf86FBManagerKey = &xf86FBManagerKeyRec;
+
+ if (!dixRegisterPrivateKey(&xf86FBManagerKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ dixSetPrivate(&pScreen->devPrivates, xf86FBManagerKey, funcs);
+
+ return TRUE;
+}
+
+Bool
+xf86FBManagerRunning(ScreenPtr pScreen)
+{
+ if (xf86FBManagerKey == NULL)
+ return FALSE;
+
+ if (!dixLookupPrivate(&pScreen->devPrivates, xf86FBManagerKey))
+ return FALSE;
+
+ return TRUE;
+}
+
+Bool
+xf86RegisterFreeBoxCallback(ScreenPtr pScreen,
+ FreeBoxCallbackProcPtr FreeBoxCallback,
+ pointer devPriv)
+{
+ FBManagerFuncsPtr funcs;
+
+ if (xf86FBManagerKey == NULL)
+ return FALSE;
+ if (!(funcs = (FBManagerFuncsPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
+ return FALSE;
+
+ return (*funcs->RegisterFreeBoxCallback) (pScreen, FreeBoxCallback,
+ devPriv);
+}
+
+FBAreaPtr
+xf86AllocateOffscreenArea(ScreenPtr pScreen,
+ int w, int h,
+ int gran,
+ MoveAreaCallbackProcPtr moveCB,
+ RemoveAreaCallbackProcPtr removeCB, pointer privData)
+{
+ FBManagerFuncsPtr funcs;
+
+ if (xf86FBManagerKey == NULL)
+ return NULL;
+ if (!(funcs = (FBManagerFuncsPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
+ return NULL;
+
+ return (*funcs->AllocateOffscreenArea) (pScreen, w, h, gran, moveCB,
+ removeCB, privData);
+}
+
+FBLinearPtr
+xf86AllocateOffscreenLinear(ScreenPtr pScreen,
+ int length,
+ int gran,
+ MoveLinearCallbackProcPtr moveCB,
+ RemoveLinearCallbackProcPtr removeCB,
+ pointer privData)
+{
+ FBManagerFuncsPtr funcs;
+
+ if (xf86FBManagerKey == NULL)
+ return NULL;
+ if (!(funcs = (FBManagerFuncsPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
+ return NULL;
+
+ return (*funcs->AllocateOffscreenLinear) (pScreen, length, gran, moveCB,
+ removeCB, privData);
+}
+
+void
+xf86FreeOffscreenArea(FBAreaPtr area)
+{
+ FBManagerFuncsPtr funcs;
+
+ if (!area)
+ return;
+
+ if (xf86FBManagerKey == NULL)
+ return;
+ if (!
+ (funcs =
+ (FBManagerFuncsPtr) dixLookupPrivate(&area->pScreen->devPrivates,
+ xf86FBManagerKey)))
+ return;
+
+ (*funcs->FreeOffscreenArea) (area);
+
+ return;
+}
+
+void
+xf86FreeOffscreenLinear(FBLinearPtr linear)
+{
+ FBManagerFuncsPtr funcs;
+
+ if (!linear)
+ return;
+
+ if (xf86FBManagerKey == NULL)
+ return;
+ if (!
+ (funcs =
+ (FBManagerFuncsPtr) dixLookupPrivate(&linear->pScreen->devPrivates,
+ xf86FBManagerKey)))
+ return;
+
+ (*funcs->FreeOffscreenLinear) (linear);
+
+ return;
+}
+
+Bool
+xf86ResizeOffscreenArea(FBAreaPtr resize, int w, int h)
+{
+ FBManagerFuncsPtr funcs;
+
+ if (!resize)
+ return FALSE;
+
+ if (xf86FBManagerKey == NULL)
+ return FALSE;
+ if (!
+ (funcs =
+ (FBManagerFuncsPtr) dixLookupPrivate(&resize->pScreen->devPrivates,
+ xf86FBManagerKey)))
+ return FALSE;
+
+ return (*funcs->ResizeOffscreenArea) (resize, w, h);
+}
+
+Bool
+xf86ResizeOffscreenLinear(FBLinearPtr resize, int size)
+{
+ FBManagerFuncsPtr funcs;
+
+ if (!resize)
+ return FALSE;
+
+ if (xf86FBManagerKey == NULL)
+ return FALSE;
+ if (!
+ (funcs =
+ (FBManagerFuncsPtr) dixLookupPrivate(&resize->pScreen->devPrivates,
+ xf86FBManagerKey)))
+ return FALSE;
+
+ return (*funcs->ResizeOffscreenLinear) (resize, size);
+}
+
+Bool
+xf86QueryLargestOffscreenArea(ScreenPtr pScreen,
+ int *w, int *h,
+ int gran, int preferences, int severity)
+{
+ FBManagerFuncsPtr funcs;
+
+ *w = 0;
+ *h = 0;
+
+ if (xf86FBManagerKey == NULL)
+ return FALSE;
+ if (!(funcs = (FBManagerFuncsPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
+ return FALSE;
+
+ return (*funcs->QueryLargestOffscreenArea) (pScreen, w, h, gran,
+ preferences, severity);
+}
+
+Bool
+xf86QueryLargestOffscreenLinear(ScreenPtr pScreen,
+ int *size, int gran, int severity)
+{
+ FBManagerFuncsPtr funcs;
+
+ *size = 0;
+
+ if (xf86FBManagerKey == NULL)
+ return FALSE;
+ if (!(funcs = (FBManagerFuncsPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
+ return FALSE;
+
+ return (*funcs->QueryLargestOffscreenLinear) (pScreen, size, gran,
+ severity);
+}
+
+Bool
+xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
+{
+ FBManagerFuncsPtr funcs;
+
+ if (xf86FBManagerKey == NULL)
+ return FALSE;
+ if (!(funcs = (FBManagerFuncsPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
+ return FALSE;
+
+ return (*funcs->PurgeOffscreenAreas) (pScreen);
+}
+
+/************************************************************\
+
+ Below is a specific implementation of an offscreen manager.
+
+\************************************************************/
+
+static DevPrivateKeyRec xf86FBScreenKeyRec;
+
+#define xf86FBScreenKey (&xf86FBScreenKeyRec)
+
+typedef struct _FBLink {
+ FBArea area;
+ struct _FBLink *next;
+} FBLink, *FBLinkPtr;
+
+typedef struct _FBLinearLink {
+ FBLinear linear;
+ int free; /* need to add free here as FBLinear is publicly accessible */
+ FBAreaPtr area; /* only used if allocation came from XY area */
+ struct _FBLinearLink *next;
+} FBLinearLink, *FBLinearLinkPtr;
+
+typedef struct {
+ ScreenPtr pScreen;
+ RegionPtr InitialBoxes;
+ RegionPtr FreeBoxes;
+ FBLinkPtr UsedAreas;
+ int NumUsedAreas;
+ FBLinearLinkPtr LinearAreas;
+ CloseScreenProcPtr CloseScreen;
+ int NumCallbacks;
+ FreeBoxCallbackProcPtr *FreeBoxesUpdateCallback;
+ DevUnion *devPrivates;
+} FBManager, *FBManagerPtr;
+
+static void
+SendCallFreeBoxCallbacks(FBManagerPtr offman)
+{
+ int i = offman->NumCallbacks;
+
+ while (i--) {
+ (*offman->FreeBoxesUpdateCallback[i]) (offman->pScreen,
+ offman->FreeBoxes,
+ offman->devPrivates[i].ptr);
+ }
+}
+
+static Bool
+localRegisterFreeBoxCallback(ScreenPtr pScreen,
+ FreeBoxCallbackProcPtr FreeBoxCallback,
+ pointer devPriv)
+{
+ FBManagerPtr offman;
+ FreeBoxCallbackProcPtr *newCallbacks;
+ DevUnion *newPrivates;
+
+ offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
+ newCallbacks = realloc(offman->FreeBoxesUpdateCallback,
+ sizeof(FreeBoxCallbackProcPtr) *
+ (offman->NumCallbacks + 1));
+
+ newPrivates = realloc(offman->devPrivates,
+ sizeof(DevUnion) * (offman->NumCallbacks + 1));
+
+ if (!newCallbacks || !newPrivates)
+ return FALSE;
+
+ offman->FreeBoxesUpdateCallback = newCallbacks;
+ offman->devPrivates = newPrivates;
+
+ offman->FreeBoxesUpdateCallback[offman->NumCallbacks] = FreeBoxCallback;
+ offman->devPrivates[offman->NumCallbacks].ptr = devPriv;
+ offman->NumCallbacks++;
+
+ SendCallFreeBoxCallbacks(offman);
+
+ return TRUE;
+}
+
+static FBAreaPtr
+AllocateArea(FBManagerPtr offman,
+ int w, int h,
+ int granularity,
+ MoveAreaCallbackProcPtr moveCB,
+ RemoveAreaCallbackProcPtr removeCB, pointer privData)
+{
+ ScreenPtr pScreen = offman->pScreen;
+ FBLinkPtr link = NULL;
+ FBAreaPtr area = NULL;
+ RegionRec NewReg;
+ int i, x = 0, num;
+ BoxPtr boxp;
+
+ if (granularity <= 1)
+ granularity = 0;
+
+ boxp = RegionRects(offman->FreeBoxes);
+ num = RegionNumRects(offman->FreeBoxes);
+
+ /* look through the free boxes */
+ for (i = 0; i < num; i++, boxp++) {
+ x = boxp->x1;
+ if (granularity > 1)
+ x = ((x + granularity - 1) / granularity) * granularity;
+
+ if (((boxp->y2 - boxp->y1) < h) || ((boxp->x2 - x) < w))
+ continue;
+
+ link = malloc(sizeof(FBLink));
+ if (!link)
+ return NULL;
+
+ area = &(link->area);
+ link->next = offman->UsedAreas;
+ offman->UsedAreas = link;
+ offman->NumUsedAreas++;
+ break;
+ }
+
+ /* try to boot a removeable one out if we are not expendable ourselves */
+ if (!area && !removeCB) {
+ link = offman->UsedAreas;
+
+ while (link) {
+ if (!link->area.RemoveAreaCallback) {
+ link = link->next;
+ continue;
+ }
+
+ boxp = &(link->area.box);
+ x = boxp->x1;
+ if (granularity > 1)
+ x = ((x + granularity - 1) / granularity) * granularity;
+
+ if (((boxp->y2 - boxp->y1) < h) || ((boxp->x2 - x) < w)) {
+ link = link->next;
+ continue;
+ }
+
+ /* bye, bye */
+ (*link->area.RemoveAreaCallback) (&link->area);
+ RegionInit(&NewReg, &(link->area.box), 1);
+ RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &NewReg);
+ RegionUninit(&NewReg);
+
+ area = &(link->area);
+ break;
+ }
+ }
+
+ if (area) {
+ area->pScreen = pScreen;
+ area->granularity = granularity;
+ area->box.x1 = x;
+ area->box.x2 = x + w;
+ area->box.y1 = boxp->y1;
+ area->box.y2 = boxp->y1 + h;
+ area->MoveAreaCallback = moveCB;
+ area->RemoveAreaCallback = removeCB;
+ area->devPrivate.ptr = privData;
+
+ RegionInit(&NewReg, &(area->box), 1);
+ RegionSubtract(offman->FreeBoxes, offman->FreeBoxes, &NewReg);
+ RegionUninit(&NewReg);
+ }
+
+ return area;
+}
+
+static FBAreaPtr
+localAllocateOffscreenArea(ScreenPtr pScreen,
+ int w, int h,
+ int gran,
+ MoveAreaCallbackProcPtr moveCB,
+ RemoveAreaCallbackProcPtr removeCB, pointer privData)
+{
+ FBManagerPtr offman;
+ FBAreaPtr area = NULL;
+
+ offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
+ if ((area = AllocateArea(offman, w, h, gran, moveCB, removeCB, privData)))
+ SendCallFreeBoxCallbacks(offman);
+
+ return area;
+}
+
+static void
+localFreeOffscreenArea(FBAreaPtr area)
+{
+ FBManagerPtr offman;
+ FBLinkPtr pLink, pLinkPrev = NULL;
+ RegionRec FreedRegion;
+ ScreenPtr pScreen;
+
+ pScreen = area->pScreen;
+ offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
+ pLink = offman->UsedAreas;
+ if (!pLink)
+ return;
+
+ while (&(pLink->area) != area) {
+ pLinkPrev = pLink;
+ pLink = pLink->next;
+ if (!pLink)
+ return;
+ }
+
+ /* put the area back into the pool */
+ RegionInit(&FreedRegion, &(pLink->area.box), 1);
+ RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedRegion);
+ RegionUninit(&FreedRegion);
+
+ if (pLinkPrev)
+ pLinkPrev->next = pLink->next;
+ else
+ offman->UsedAreas = pLink->next;
+
+ free(pLink);
+ offman->NumUsedAreas--;
+
+ SendCallFreeBoxCallbacks(offman);
+}
+
+static Bool
+localResizeOffscreenArea(FBAreaPtr resize, int w, int h)
+{
+ FBManagerPtr offman;
+ ScreenPtr pScreen;
+ BoxRec OrigArea;
+ RegionRec FreedReg;
+ FBAreaPtr area = NULL;
+ FBLinkPtr pLink, newLink, pLinkPrev = NULL;
+
+ pScreen = resize->pScreen;
+ offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
+ /* find this link */
+ if (!(pLink = offman->UsedAreas))
+ return FALSE;
+
+ while (&(pLink->area) != resize) {
+ pLinkPrev = pLink;
+ pLink = pLink->next;
+ if (!pLink)
+ return FALSE;
+ }
+
+ OrigArea.x1 = resize->box.x1;
+ OrigArea.x2 = resize->box.x2;
+ OrigArea.y1 = resize->box.y1;
+ OrigArea.y2 = resize->box.y2;
+
+ /* if it's smaller, this is easy */
+
+ if ((w <= (resize->box.x2 - resize->box.x1)) &&
+ (h <= (resize->box.y2 - resize->box.y1))) {
+ RegionRec NewReg;
+
+ resize->box.x2 = resize->box.x1 + w;
+ resize->box.y2 = resize->box.y1 + h;
+
+ if ((resize->box.y2 == OrigArea.y2) && (resize->box.x2 == OrigArea.x2))
+ return TRUE;
+
+ RegionInit(&FreedReg, &OrigArea, 1);
+ RegionInit(&NewReg, &(resize->box), 1);
+ RegionSubtract(&FreedReg, &FreedReg, &NewReg);
+ RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
+ RegionUninit(&FreedReg);
+ RegionUninit(&NewReg);
+
+ SendCallFreeBoxCallbacks(offman);
+
+ return TRUE;
+ }
+
+ /* otherwise we remove the old region */
+
+ RegionInit(&FreedReg, &OrigArea, 1);
+ RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
+
+ /* remove the old link */
+ if (pLinkPrev)
+ pLinkPrev->next = pLink->next;
+ else
+ offman->UsedAreas = pLink->next;
+
+ /* and try to add a new one */
+
+ if ((area = AllocateArea(offman, w, h, resize->granularity,
+ resize->MoveAreaCallback,
+ resize->RemoveAreaCallback,
+ resize->devPrivate.ptr))) {
+
+ /* copy data over to our link and replace the new with old */
+ memcpy(resize, area, sizeof(FBArea));
+
+ pLinkPrev = NULL;
+ newLink = offman->UsedAreas;
+
+ while (&(newLink->area) != area) {
+ pLinkPrev = newLink;
+ newLink = newLink->next;
+ }
+
+ if (pLinkPrev)
+ pLinkPrev->next = newLink->next;
+ else
+ offman->UsedAreas = newLink->next;
+
+ pLink->next = offman->UsedAreas;
+ offman->UsedAreas = pLink;
+
+ free(newLink);
+
+ /* AllocateArea added one but we really only exchanged one */
+ offman->NumUsedAreas--;
+ }
+ else {
+ /* reinstate the old region */
+ RegionSubtract(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
+ RegionUninit(&FreedReg);
+
+ pLink->next = offman->UsedAreas;
+ offman->UsedAreas = pLink;
+ return FALSE;
+ }
+
+ RegionUninit(&FreedReg);
+
+ SendCallFreeBoxCallbacks(offman);
+
+ return TRUE;
+}
+
+static Bool
+localQueryLargestOffscreenArea(ScreenPtr pScreen,
+ int *width, int *height,
+ int granularity, int preferences, int severity)
+{
+ FBManagerPtr offman;
+ RegionPtr newRegion = NULL;
+ BoxPtr pbox;
+ int nbox;
+ int x, w, h, area, oldArea;
+
+ *width = *height = oldArea = 0;
+
+ if (granularity <= 1)
+ granularity = 0;
+
+ if ((preferences < 0) || (preferences > 3))
+ return FALSE;
+
+ offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
+ if (severity < 0)
+ severity = 0;
+ if (severity > 2)
+ severity = 2;
+
+ switch (severity) {
+ case 2:
+ if (offman->NumUsedAreas) {
+ FBLinkPtr pLink;
+ RegionRec tmpRegion;
+
+ newRegion = RegionCreate(NULL, 1);
+ RegionCopy(newRegion, offman->InitialBoxes);
+ pLink = offman->UsedAreas;
+
+ while (pLink) {
+ if (!pLink->area.RemoveAreaCallback) {
+ RegionInit(&tmpRegion, &(pLink->area.box), 1);
+ RegionSubtract(newRegion, newRegion, &tmpRegion);
+ RegionUninit(&tmpRegion);
+ }
+ pLink = pLink->next;
+ }
+
+ nbox = RegionNumRects(newRegion);
+ pbox = RegionRects(newRegion);
+ break;
+ }
+ case 1:
+ if (offman->NumUsedAreas) {
+ FBLinkPtr pLink;
+ RegionRec tmpRegion;
+
+ newRegion = RegionCreate(NULL, 1);
+ RegionCopy(newRegion, offman->FreeBoxes);
+ pLink = offman->UsedAreas;
+
+ while (pLink) {
+ if (pLink->area.RemoveAreaCallback) {
+ RegionInit(&tmpRegion, &(pLink->area.box), 1);
+ RegionAppend(newRegion, &tmpRegion);
+ RegionUninit(&tmpRegion);
+ }
+ pLink = pLink->next;
+ }
+
+ nbox = RegionNumRects(newRegion);
+ pbox = RegionRects(newRegion);
+ break;
+ }
+ default:
+ nbox = RegionNumRects(offman->FreeBoxes);
+ pbox = RegionRects(offman->FreeBoxes);
+ break;
+ }
+
+ while (nbox--) {
+ x = pbox->x1;
+ if (granularity > 1)
+ x = ((x + granularity - 1) / granularity) * granularity;
+
+ w = pbox->x2 - x;
+ h = pbox->y2 - pbox->y1;
+ area = w * h;
+
+ if (w > 0) {
+ Bool gotIt = FALSE;
+
+ switch (preferences) {
+ case FAVOR_AREA_THEN_WIDTH:
+ if ((area > oldArea) || ((area == oldArea) && (w > *width)))
+ gotIt = TRUE;
+ break;
+ case FAVOR_AREA_THEN_HEIGHT:
+ if ((area > oldArea) || ((area == oldArea) && (h > *height)))
+ gotIt = TRUE;
+ break;
+ case FAVOR_WIDTH_THEN_AREA:
+ if ((w > *width) || ((w == *width) && (area > oldArea)))
+ gotIt = TRUE;
+ break;
+ case FAVOR_HEIGHT_THEN_AREA:
+ if ((h > *height) || ((h == *height) && (area > oldArea)))
+ gotIt = TRUE;
+ break;
+ }
+ if (gotIt) {
+ *width = w;
+ *height = h;
+ oldArea = area;
+ }
+ }
+ pbox++;
+ }
+
+ if (newRegion)
+ RegionDestroy(newRegion);
+
+ return TRUE;
+}
+
+static Bool
+localPurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
+{
+ FBManagerPtr offman;
+ FBLinkPtr pLink, tmp, pPrev = NULL;
+ RegionRec FreedRegion;
+ Bool anyUsed = FALSE;
+
+ offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
+ pLink = offman->UsedAreas;
+ if (!pLink)
+ return TRUE;
+
+ while (pLink) {
+ if (pLink->area.RemoveAreaCallback) {
+ (*pLink->area.RemoveAreaCallback) (&pLink->area);
+
+ RegionInit(&FreedRegion, &(pLink->area.box), 1);
+ RegionAppend(offman->FreeBoxes, &FreedRegion);
+ RegionUninit(&FreedRegion);
+
+ if (pPrev)
+ pPrev->next = pLink->next;
+ else
+ offman->UsedAreas = pLink->next;
+
+ tmp = pLink;
+ pLink = pLink->next;
+ free(tmp);
+ offman->NumUsedAreas--;
+ anyUsed = TRUE;
+ }
+ else {
+ pPrev = pLink;
+ pLink = pLink->next;
+ }
+ }
+
+ if (anyUsed) {
+ RegionValidate(offman->FreeBoxes, &anyUsed);
+ SendCallFreeBoxCallbacks(offman);
+ }
+
+ return TRUE;
+}
+
+static void
+LinearMoveCBWrapper(FBAreaPtr from, FBAreaPtr to)
+{
+ /* this will never get called */
+}
+
+static void
+LinearRemoveCBWrapper(FBAreaPtr area)
+{
+ FBManagerPtr offman;
+ FBLinearLinkPtr pLink, pLinkPrev = NULL;
+ ScreenPtr pScreen = area->pScreen;
+
+ offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
+ pLink = offman->LinearAreas;
+ if (!pLink)
+ return;
+
+ while (pLink->area != area) {
+ pLinkPrev = pLink;
+ pLink = pLink->next;
+ if (!pLink)
+ return;
+ }
+
+ /* give the user the callback it is expecting */
+ (*pLink->linear.RemoveLinearCallback) (&(pLink->linear));
+
+ if (pLinkPrev)
+ pLinkPrev->next = pLink->next;
+ else
+ offman->LinearAreas = pLink->next;
+
+ free(pLink);
+}
+
+static void
+DumpDebug(FBLinearLinkPtr pLink)
+{
+#ifdef DEBUG
+ if (!pLink)
+ ErrorF("MMmm, PLINK IS NULL!\n");
+
+ while (pLink) {
+ ErrorF(" Offset:%08x, Size:%08x, %s,%s\n",
+ pLink->linear.offset,
+ pLink->linear.size,
+ pLink->free ? "Free" : "Used", pLink->area ? "Area" : "Linear");
+
+ pLink = pLink->next;
+ }
+#endif
+}
+
+static FBLinearPtr
+AllocateLinear(FBManagerPtr offman, int size, int granularity, pointer privData)
+{
+ ScreenPtr pScreen = offman->pScreen;
+ FBLinearLinkPtr linear = NULL;
+ FBLinearLinkPtr newlink = NULL;
+ int offset, end;
+
+ if (size <= 0)
+ return NULL;
+
+ if (!offman->LinearAreas)
+ return NULL;
+
+ linear = offman->LinearAreas;
+ while (linear) {
+ /* Make sure we get a free area that's not an XY fallback case */
+ if (!linear->area && linear->free) {
+ offset = linear->linear.offset;
+ if (granularity > 1)
+ offset =
+ ((offset + granularity - 1) / granularity) * granularity;
+ end = offset + size;
+ if (end <= (linear->linear.offset + linear->linear.size))
+ break;
+ }
+ linear = linear->next;
+ }
+ if (!linear)
+ return NULL;
+
+ /* break left */
+ if (offset > linear->linear.offset) {
+ newlink = malloc(sizeof(FBLinearLink));
+ if (!newlink)
+ return NULL;
+ newlink->area = NULL;
+ newlink->linear.offset = offset;
+ newlink->linear.size =
+ linear->linear.size - (offset - linear->linear.offset);
+ newlink->free = 1;
+ newlink->next = linear->next;
+ linear->linear.size -= newlink->linear.size;
+ linear->next = newlink;
+ linear = newlink;
+ }
+
+ /* break right */
+ if (size < linear->linear.size) {
+ newlink = malloc(sizeof(FBLinearLink));
+ if (!newlink)
+ return NULL;
+ newlink->area = NULL;
+ newlink->linear.offset = offset + size;
+ newlink->linear.size = linear->linear.size - size;
+ newlink->free = 1;
+ newlink->next = linear->next;
+ linear->linear.size = size;
+ linear->next = newlink;
+ }
+
+ /* p = middle block */
+ linear->linear.granularity = granularity;
+ linear->free = 0;
+ linear->linear.pScreen = pScreen;
+ linear->linear.MoveLinearCallback = NULL;
+ linear->linear.RemoveLinearCallback = NULL;
+ linear->linear.devPrivate.ptr = NULL;
+
+ DumpDebug(offman->LinearAreas);
+
+ return &(linear->linear);
+}
+
+static FBLinearPtr
+localAllocateOffscreenLinear(ScreenPtr pScreen,
+ int length,
+ int gran,
+ MoveLinearCallbackProcPtr moveCB,
+ RemoveLinearCallbackProcPtr removeCB,
+ pointer privData)
+{
+ FBManagerPtr offman;
+ FBLinearLinkPtr link;
+ FBAreaPtr area;
+ FBLinearPtr linear = NULL;
+ BoxPtr extents;
+ int w, h, pitch;
+
+ offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
+
+ /* Try to allocate from linear memory first...... */
+ DebugF("ALLOCATING LINEAR\n");
+ if ((linear = AllocateLinear(offman, length, gran, privData)))
+ return linear;
+
+ DebugF("NOPE, ALLOCATING AREA\n");
+
+ if (!(link = malloc(sizeof(FBLinearLink))))
+ return NULL;
+
+ /* No linear available, so try and pinch some from the XY areas */
+ extents = RegionExtents(offman->InitialBoxes);
+ pitch = extents->x2 - extents->x1;
+
+ if (gran > 1) {
+ if (gran > pitch) {
+ /* we can't match the specified alignment with XY allocations */
+ free(link);
+ return NULL;
+ }
+
+ if (pitch % gran) {
+ /* pitch and granularity aren't a perfect match, let's allocate
+ * a bit more so we can align later on
+ */
+ length += gran - 1;
+ }
+ }
+
+ if (length < pitch) { /* special case */
+ w = length;
+ h = 1;
+ }
+ else {
+ w = pitch;
+ h = (length + pitch - 1) / pitch;
+ }
+
+ if ((area = localAllocateOffscreenArea(pScreen, w, h, gran,
+ moveCB ? LinearMoveCBWrapper : NULL,
+ removeCB ? LinearRemoveCBWrapper :
+ NULL, privData))) {
+ link->area = area;
+ link->free = 0;
+ link->next = offman->LinearAreas;
+ offman->LinearAreas = link;
+ linear = &(link->linear);
+ linear->pScreen = pScreen;
+ linear->size = h * w;
+ linear->offset = (pitch * area->box.y1) + area->box.x1;
+ if (gran > 1)
+ linear->offset = ((linear->offset + gran - 1) / gran) * gran;
+ linear->granularity = gran;
+ linear->MoveLinearCallback = moveCB;
+ linear->RemoveLinearCallback = removeCB;
+ linear->devPrivate.ptr = privData;
+ }
+ else
+ free(link);
+
+ DumpDebug(offman->LinearAreas);
+
+ return linear;
+}
+
+static void
+localFreeOffscreenLinear(FBLinearPtr linear)
+{
+ FBManagerPtr offman;
+ FBLinearLinkPtr pLink, pLinkPrev = NULL;
+ ScreenPtr pScreen = linear->pScreen;
+
+ offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
+ pLink = offman->LinearAreas;
+ if (!pLink)
+ return;
+
+ while (&(pLink->linear) != linear) {
+ pLinkPrev = pLink;
+ pLink = pLink->next;
+ if (!pLink)
+ return;
+ }
+
+ if (pLink->area) { /* really an XY area */
+ DebugF("FREEING AREA\n");
+ localFreeOffscreenArea(pLink->area);
+ if (pLinkPrev)
+ pLinkPrev->next = pLink->next;
+ else
+ offman->LinearAreas = pLink->next;
+ free(pLink);
+ DumpDebug(offman->LinearAreas);
+ return;
+ }
+
+ pLink->free = 1;
+
+ if (pLink->next && pLink->next->free) {
+ FBLinearLinkPtr p = pLink->next;
+
+ pLink->linear.size += p->linear.size;
+ pLink->next = p->next;
+ free(p);
+ }
+
+ if (pLinkPrev) {
+ if (pLinkPrev->next && pLinkPrev->next->free && !pLinkPrev->area) {
+ FBLinearLinkPtr p = pLinkPrev->next;
+
+ pLinkPrev->linear.size += p->linear.size;
+ pLinkPrev->next = p->next;
+ free(p);
+ }
+ }
+
+ DebugF("FREEING LINEAR\n");
+ DumpDebug(offman->LinearAreas);
+}
+
+static Bool
+localResizeOffscreenLinear(FBLinearPtr resize, int length)
+{
+ FBManagerPtr offman;
+ FBLinearLinkPtr pLink;
+ ScreenPtr pScreen = resize->pScreen;
+
+ offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
+ pLink = offman->LinearAreas;
+ if (!pLink)
+ return FALSE;
+
+ while (&(pLink->linear) != resize) {
+ pLink = pLink->next;
+ if (!pLink)
+ return FALSE;
+ }
+
+ /* This could actually be alot smarter and try to move allocations
+ from XY to linear when available. For now if it was XY, we keep
+ it XY */
+
+ if (pLink->area) { /* really an XY area */
+ BoxPtr extents;
+ int pitch, w, h;
+
+ extents = RegionExtents(offman->InitialBoxes);
+ pitch = extents->x2 - extents->x1;
+
+ if (length < pitch) { /* special case */
+ w = length;
+ h = 1;
+ }
+ else {
+ w = pitch;
+ h = (length + pitch - 1) / pitch;
+ }
+
+ if (localResizeOffscreenArea(pLink->area, w, h)) {
+ resize->size = h * w;
+ resize->offset =
+ (pitch * pLink->area->box.y1) + pLink->area->box.x1;
+ return TRUE;
+ }
+ }
+ else {
+ /* TODO!!!! resize the linear area */
+ }
+
+ return FALSE;
+}
+
+static Bool
+localQueryLargestOffscreenLinear(ScreenPtr pScreen,
+ int *size, int gran, int priority)
+{
+ FBManagerPtr offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
+ FBLinearLinkPtr pLink;
+ FBLinearLinkPtr pLinkRet;
+
+ *size = 0;
+
+ pLink = offman->LinearAreas;
+
+ if (pLink && !pLink->area) {
+ pLinkRet = pLink;
+ while (pLink) {
+ if (pLink->free) {
+ if (pLink->linear.size > pLinkRet->linear.size)
+ pLinkRet = pLink;
+ }
+ pLink = pLink->next;
+ }
+
+ if (pLinkRet->free) {
+ *size = pLinkRet->linear.size;
+ return TRUE;
+ }
+ }
+ else {
+ int w, h;
+
+ if (localQueryLargestOffscreenArea(pScreen, &w, &h, gran,
+ FAVOR_WIDTH_THEN_AREA, priority)) {
+ FBManagerPtr offman;
+ BoxPtr extents;
+
+ offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
+ extents = RegionExtents(offman->InitialBoxes);
+ if ((extents->x2 - extents->x1) == w)
+ *size = w * h;
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+static FBManagerFuncs xf86FBManFuncs = {
+ localAllocateOffscreenArea,
+ localFreeOffscreenArea,
+ localResizeOffscreenArea,
+ localQueryLargestOffscreenArea,
+ localRegisterFreeBoxCallback,
+ localAllocateOffscreenLinear,
+ localFreeOffscreenLinear,
+ localResizeOffscreenLinear,
+ localQueryLargestOffscreenLinear,
+ localPurgeUnlockedOffscreenAreas
+};
+
+static Bool
+xf86FBCloseScreen(int i, ScreenPtr pScreen)
+{
+ FBLinkPtr pLink, tmp;
+ FBLinearLinkPtr pLinearLink, tmp2;
+ FBManagerPtr offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
+
+ pScreen->CloseScreen = offman->CloseScreen;
+
+ pLink = offman->UsedAreas;
+ while (pLink) {
+ tmp = pLink;
+ pLink = pLink->next;
+ free(tmp);
+ }
+
+ pLinearLink = offman->LinearAreas;
+ while (pLinearLink) {
+ tmp2 = pLinearLink;
+ pLinearLink = pLinearLink->next;
+ free(tmp2);
+ }
+
+ RegionDestroy(offman->InitialBoxes);
+ RegionDestroy(offman->FreeBoxes);
+
+ free(offman->FreeBoxesUpdateCallback);
+ free(offman->devPrivates);
+ free(offman);
+ dixSetPrivate(&pScreen->devPrivates, xf86FBScreenKey, NULL);
+
+ 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;
+ }
+
+ if (FullBox->y2 < FullBox->y1)
+ return FALSE;
+ if (FullBox->x2 < FullBox->x1)
+ return FALSE;
+
+ RegionInit(&ScreenRegion, &ScreenBox, 1);
+ RegionInit(&FullRegion, FullBox, 1);
+
+ RegionSubtract(&FullRegion, &FullRegion, &ScreenRegion);
+
+ ret = xf86InitFBManagerRegion(pScreen, &FullRegion);
+
+ RegionUninit(&ScreenRegion);
+ RegionUninit(&FullRegion);
+
+ return ret;
+}
+
+Bool
+xf86InitFBManagerArea(ScreenPtr pScreen, int PixelArea, int Verbosity)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xRectangle Rect[3];
+ RegionPtr pRegion, pScreenRegion;
+ int nRect;
+ Bool ret = FALSE;
+
+ if (PixelArea < (pScrn->displayWidth * pScrn->virtualY))
+ return FALSE;
+
+ Rect[0].x = Rect[0].y = 0;
+ Rect[0].width = pScrn->displayWidth;
+ Rect[0].height = PixelArea / pScrn->displayWidth;
+ nRect = 1;
+
+ /* Add a possible partial scanline */
+ if ((Rect[1].height = Rect[1].width = PixelArea % pScrn->displayWidth)) {
+ Rect[1].x = 0;
+ Rect[1].y = Rect[0].height;
+ Rect[1].height = 1;
+ nRect++;
+ }
+
+ /* Factor out virtual resolution */
+ pRegion = RegionFromRects(nRect, Rect, 0);
+ if (pRegion) {
+ if (!RegionNar(pRegion)) {
+ Rect[2].x = Rect[2].y = 0;
+ Rect[2].width = pScrn->virtualX;
+ Rect[2].height = pScrn->virtualY;
+
+ pScreenRegion = RegionFromRects(1, &Rect[2], 0);
+ if (pScreenRegion) {
+ if (!RegionNar(pScreenRegion)) {
+ RegionSubtract(pRegion, pRegion, pScreenRegion);
+
+ ret = xf86InitFBManagerRegion(pScreen, pRegion);
+
+ if (ret && xf86GetVerbosity() >= Verbosity) {
+ int scrnIndex = pScrn->scrnIndex;
+
+ xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity,
+ "Largest offscreen areas (with overlaps):\n");
+
+ if (Rect[2].width < Rect[0].width) {
+ xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity,
+ "\t%d x %d rectangle at %d,0\n",
+ Rect[0].width - Rect[2].width,
+ Rect[0].height, Rect[2].width);
+ }
+ if (Rect[2].width < Rect[1].width) {
+ xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity,
+ "\t%d x %d rectangle at %d,0\n",
+ Rect[1].width - Rect[2].width,
+ Rect[0].height + Rect[1].height,
+ Rect[2].width);
+ }
+ if (Rect[2].height < Rect[0].height) {
+ xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity,
+ "\t%d x %d rectangle at 0,%d\n",
+ Rect[0].width,
+ Rect[0].height - Rect[2].height,
+ Rect[2].height);
+ }
+ if (Rect[1].height) {
+ xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity,
+ "\t%d x %d rectangle at 0,%d\n",
+ Rect[1].width,
+ Rect[0].height - Rect[2].height +
+ Rect[1].height, Rect[2].height);
+ }
+ }
+ }
+
+ RegionDestroy(pScreenRegion);
+ }
+ }
+
+ RegionDestroy(pRegion);
+ }
+
+ return ret;
+}
+
+Bool
+xf86InitFBManagerRegion(ScreenPtr pScreen, RegionPtr FullRegion)
+{
+ FBManagerPtr offman;
+
+ if (RegionNil(FullRegion))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&xf86FBScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ if (!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs))
+ return FALSE;
+
+ offman = malloc(sizeof(FBManager));
+ if (!offman)
+ return FALSE;
+
+ dixSetPrivate(&pScreen->devPrivates, xf86FBScreenKey, offman);
+
+ offman->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = xf86FBCloseScreen;
+
+ offman->InitialBoxes = RegionCreate(NULL, 1);
+ offman->FreeBoxes = RegionCreate(NULL, 1);
+
+ RegionCopy(offman->InitialBoxes, FullRegion);
+ RegionCopy(offman->FreeBoxes, FullRegion);
+
+ offman->pScreen = pScreen;
+ offman->UsedAreas = NULL;
+ offman->LinearAreas = NULL;
+ offman->NumUsedAreas = 0;
+ offman->NumCallbacks = 0;
+ offman->FreeBoxesUpdateCallback = NULL;
+ offman->devPrivates = NULL;
+
+ return TRUE;
+}
+
+Bool
+xf86InitFBManagerLinear(ScreenPtr pScreen, int offset, int size)
+{
+ FBManagerPtr offman;
+ FBLinearLinkPtr link;
+ FBLinearPtr linear;
+
+ if (size <= 0)
+ return FALSE;
+
+ /* we expect people to have called the Area setup first for pixmap cache */
+ if (!dixLookupPrivate(&pScreen->devPrivates, xf86FBScreenKey))
+ return FALSE;
+
+ offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
+ offman->LinearAreas = malloc(sizeof(FBLinearLink));
+ if (!offman->LinearAreas)
+ return FALSE;
+
+ link = offman->LinearAreas;
+ link->area = NULL;
+ link->next = NULL;
+ link->free = 1;
+ linear = &(link->linear);
+ linear->pScreen = pScreen;
+ linear->size = size;
+ linear->offset = offset;
+ linear->granularity = 0;
+ linear->MoveLinearCallback = NULL;
+ linear->RemoveLinearCallback = NULL;
+ linear->devPrivate.ptr = NULL;
+
+ return TRUE;
+}
+
+/* This is an implementation specific function and should
+ disappear after the next release. People should use the
+ real linear functions instead */
+
+FBAreaPtr
+xf86AllocateLinearOffscreenArea(ScreenPtr pScreen,
+ int length,
+ int gran,
+ MoveAreaCallbackProcPtr moveCB,
+ RemoveAreaCallbackProcPtr removeCB,
+ pointer privData)
+{
+ FBManagerFuncsPtr funcs;
+ FBManagerPtr offman;
+ BoxPtr extents;
+ int w, h;
+
+ if (xf86FBManagerKey == NULL)
+ return NULL;
+ if (!(funcs = (FBManagerFuncsPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
+ return NULL;
+
+ offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
+ extents = RegionExtents(offman->InitialBoxes);
+ w = extents->x2 - extents->x1;
+
+ if (gran > 1) {
+ if (gran > w)
+ return NULL;
+
+ if (w % gran)
+ length += gran - 1;
+ }
+
+ if (length <= w) { /* special case */
+ h = 1;
+ w = length;
+ }
+ else {
+ h = (length + w - 1) / w;
+ }
+
+ return (*funcs->AllocateOffscreenArea) (pScreen, w, h, gran, moveCB,
+ removeCB, privData);
+}
diff --git a/xorg-server/hw/xfree86/common/xf86fbman.h b/xorg-server/hw/xfree86/common/xf86fbman.h
index 1b3c31635..99bf9917b 100644
--- a/xorg-server/hw/xfree86/common/xf86fbman.h
+++ b/xorg-server/hw/xfree86/common/xf86fbman.h
@@ -29,11 +29,9 @@
#ifndef _XF86FBMAN_H
#define _XF86FBMAN_H
-
#include "scrnintstr.h"
#include "regionstr.h"
-
#define FAVOR_AREA_THEN_WIDTH 0
#define FAVOR_AREA_THEN_HEIGHT 1
#define FAVOR_WIDTH_THEN_AREA 2
@@ -43,184 +41,131 @@
#define PRIORITY_NORMAL 1
#define PRIORITY_EXTREME 2
-
typedef struct _FBArea {
- ScreenPtr pScreen;
- BoxRec box;
- int granularity;
- void (*MoveAreaCallback)(struct _FBArea*, struct _FBArea*);
- void (*RemoveAreaCallback)(struct _FBArea*);
- DevUnion devPrivate;
+ ScreenPtr pScreen;
+ BoxRec box;
+ int granularity;
+ void (*MoveAreaCallback) (struct _FBArea *, struct _FBArea *);
+ void (*RemoveAreaCallback) (struct _FBArea *);
+ DevUnion devPrivate;
} FBArea, *FBAreaPtr;
typedef struct _FBLinear {
- ScreenPtr pScreen;
- int size;
- int offset;
- int granularity;
- void (*MoveLinearCallback)(struct _FBLinear*, struct _FBLinear*);
- void (*RemoveLinearCallback)(struct _FBLinear*);
- DevUnion devPrivate;
+ ScreenPtr pScreen;
+ int size;
+ int offset;
+ int granularity;
+ void (*MoveLinearCallback) (struct _FBLinear *, struct _FBLinear *);
+ void (*RemoveLinearCallback) (struct _FBLinear *);
+ DevUnion devPrivate;
} FBLinear, *FBLinearPtr;
-typedef void (*FreeBoxCallbackProcPtr)(ScreenPtr, RegionPtr, pointer);
-typedef void (*MoveAreaCallbackProcPtr)(FBAreaPtr, FBAreaPtr);
-typedef void (*RemoveAreaCallbackProcPtr)(FBAreaPtr);
-
-typedef void (*MoveLinearCallbackProcPtr)(FBLinearPtr, FBLinearPtr);
-typedef void (*RemoveLinearCallbackProcPtr)(FBLinearPtr);
+typedef void (*FreeBoxCallbackProcPtr) (ScreenPtr, RegionPtr, pointer);
+typedef void (*MoveAreaCallbackProcPtr) (FBAreaPtr, FBAreaPtr);
+typedef void (*RemoveAreaCallbackProcPtr) (FBAreaPtr);
+typedef void (*MoveLinearCallbackProcPtr) (FBLinearPtr, FBLinearPtr);
+typedef void (*RemoveLinearCallbackProcPtr) (FBLinearPtr);
typedef struct {
- FBAreaPtr (*AllocateOffscreenArea)(
- ScreenPtr pScreen,
- int w, int h,
- int granularity,
- MoveAreaCallbackProcPtr moveCB,
- RemoveAreaCallbackProcPtr removeCB,
- pointer privData);
- void (*FreeOffscreenArea)(FBAreaPtr area);
- Bool (*ResizeOffscreenArea)(FBAreaPtr area, int w, int h);
- Bool (*QueryLargestOffscreenArea)(
- ScreenPtr pScreen,
- int *width, int *height,
- int granularity,
- int preferences,
- int priority);
- Bool (*RegisterFreeBoxCallback)(
- ScreenPtr pScreen,
- FreeBoxCallbackProcPtr FreeBoxCallback,
- pointer devPriv);
+ FBAreaPtr(*AllocateOffscreenArea) (ScreenPtr pScreen,
+ int w, int h,
+ int granularity,
+ MoveAreaCallbackProcPtr moveCB,
+ RemoveAreaCallbackProcPtr removeCB,
+ pointer privData);
+ void (*FreeOffscreenArea) (FBAreaPtr area);
+ Bool (*ResizeOffscreenArea) (FBAreaPtr area, int w, int h);
+ Bool (*QueryLargestOffscreenArea) (ScreenPtr pScreen,
+ int *width, int *height,
+ int granularity,
+ int preferences, int priority);
+ Bool (*RegisterFreeBoxCallback) (ScreenPtr pScreen,
+ FreeBoxCallbackProcPtr FreeBoxCallback,
+ pointer devPriv);
/* linear functions */
- FBLinearPtr (*AllocateOffscreenLinear)(
- ScreenPtr pScreen,
- int size,
- int granularity,
- MoveLinearCallbackProcPtr moveCB,
- RemoveLinearCallbackProcPtr removeCB,
- pointer privData);
- void (*FreeOffscreenLinear)(FBLinearPtr area);
- Bool (*ResizeOffscreenLinear)(FBLinearPtr area, int size);
- Bool (*QueryLargestOffscreenLinear)(
- ScreenPtr pScreen,
- int *size,
- int granularity,
- int priority);
- Bool (*PurgeOffscreenAreas) (ScreenPtr);
+ FBLinearPtr(*AllocateOffscreenLinear) (ScreenPtr pScreen,
+ int size,
+ int granularity,
+ MoveLinearCallbackProcPtr moveCB,
+ RemoveLinearCallbackProcPtr
+ removeCB, pointer privData);
+ void (*FreeOffscreenLinear) (FBLinearPtr area);
+ Bool (*ResizeOffscreenLinear) (FBLinearPtr area, int size);
+ Bool (*QueryLargestOffscreenLinear) (ScreenPtr pScreen,
+ int *size,
+ int granularity, int priority);
+ Bool (*PurgeOffscreenAreas) (ScreenPtr);
} FBManagerFuncs, *FBManagerFuncsPtr;
-
-extern _X_EXPORT Bool xf86RegisterOffscreenManager(
- ScreenPtr pScreen,
- FBManagerFuncsPtr funcs
-);
+extern _X_EXPORT Bool xf86RegisterOffscreenManager(ScreenPtr pScreen,
+ FBManagerFuncsPtr funcs);
extern _X_EXPORT Bool
-xf86InitFBManagerRegion(
- ScreenPtr pScreen,
- RegionPtr ScreenRegion
-);
+ xf86InitFBManagerRegion(ScreenPtr pScreen, RegionPtr ScreenRegion);
extern _X_EXPORT Bool
-xf86InitFBManagerArea(
- ScreenPtr pScreen,
- int PixalArea,
- int Verbosity
-);
+ xf86InitFBManagerArea(ScreenPtr pScreen, int PixalArea, int Verbosity);
extern _X_EXPORT Bool
-xf86InitFBManager(
- ScreenPtr pScreen,
- BoxPtr FullBox
-);
+ xf86InitFBManager(ScreenPtr pScreen, BoxPtr FullBox);
extern _X_EXPORT Bool
-xf86InitFBManagerLinear(
- ScreenPtr pScreen,
- int offset,
- int size
-);
+ xf86InitFBManagerLinear(ScreenPtr pScreen, int offset, int size);
extern _X_EXPORT Bool
-xf86FBManagerRunning(
- ScreenPtr pScreen
-);
+ xf86FBManagerRunning(ScreenPtr pScreen);
extern _X_EXPORT FBAreaPtr
-xf86AllocateOffscreenArea (
- ScreenPtr pScreen,
- int w, int h,
- int granularity,
- MoveAreaCallbackProcPtr moveCB,
- RemoveAreaCallbackProcPtr removeCB,
- pointer privData
-);
+xf86AllocateOffscreenArea(ScreenPtr pScreen,
+ int w, int h,
+ int granularity,
+ MoveAreaCallbackProcPtr moveCB,
+ RemoveAreaCallbackProcPtr removeCB, pointer privData);
extern _X_EXPORT FBAreaPtr
-xf86AllocateLinearOffscreenArea (
- ScreenPtr pScreen,
- int length,
- int granularity,
- MoveAreaCallbackProcPtr moveCB,
- RemoveAreaCallbackProcPtr removeCB,
- pointer privData
-);
+xf86AllocateLinearOffscreenArea(ScreenPtr pScreen,
+ int length,
+ int granularity,
+ MoveAreaCallbackProcPtr moveCB,
+ RemoveAreaCallbackProcPtr removeCB,
+ pointer privData);
extern _X_EXPORT FBLinearPtr
-xf86AllocateOffscreenLinear (
- ScreenPtr pScreen,
- int length,
- int granularity,
- MoveLinearCallbackProcPtr moveCB,
- RemoveLinearCallbackProcPtr removeCB,
- pointer privData
-);
+xf86AllocateOffscreenLinear(ScreenPtr pScreen,
+ int length,
+ int granularity,
+ MoveLinearCallbackProcPtr moveCB,
+ RemoveLinearCallbackProcPtr removeCB,
+ pointer privData);
extern _X_EXPORT void xf86FreeOffscreenArea(FBAreaPtr area);
extern _X_EXPORT void xf86FreeOffscreenLinear(FBLinearPtr area);
extern _X_EXPORT Bool
-xf86ResizeOffscreenArea(
- FBAreaPtr resize,
- int w, int h
-);
+ xf86ResizeOffscreenArea(FBAreaPtr resize, int w, int h);
extern _X_EXPORT Bool
-xf86ResizeOffscreenLinear(
- FBLinearPtr resize,
- int size
-);
-
+ xf86ResizeOffscreenLinear(FBLinearPtr resize, int size);
extern _X_EXPORT Bool
-xf86RegisterFreeBoxCallback(
- ScreenPtr pScreen,
- FreeBoxCallbackProcPtr FreeBoxCallback,
- pointer devPriv
-);
-extern _X_EXPORT Bool
-xf86PurgeUnlockedOffscreenAreas(
- ScreenPtr pScreen
-);
+xf86RegisterFreeBoxCallback(ScreenPtr pScreen,
+ FreeBoxCallbackProcPtr FreeBoxCallback,
+ pointer devPriv);
+extern _X_EXPORT Bool
+ xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen);
extern _X_EXPORT Bool
-xf86QueryLargestOffscreenArea(
- ScreenPtr pScreen,
- int *width, int *height,
- int granularity,
- int preferences,
- int priority
-);
+
+xf86QueryLargestOffscreenArea(ScreenPtr pScreen,
+ int *width, int *height,
+ int granularity, int preferences, int priority);
extern _X_EXPORT Bool
-xf86QueryLargestOffscreenLinear(
- ScreenPtr pScreen,
- int *size,
- int granularity,
- int priority
-);
+xf86QueryLargestOffscreenLinear(ScreenPtr pScreen,
+ int *size, int granularity, int priority);
-#endif /* _XF86FBMAN_H */
+#endif /* _XF86FBMAN_H */
diff --git a/xorg-server/hw/xfree86/common/xf86pciBus.c b/xorg-server/hw/xfree86/common/xf86pciBus.c
index b95b25359..e52f1da84 100644
--- a/xorg-server/hw/xfree86/common/xf86pciBus.c
+++ b/xorg-server/hw/xfree86/common/xf86pciBus.c
@@ -41,7 +41,7 @@
#include "Pci.h"
#include "xf86.h"
#include "xf86Priv.h"
-#include "dirent.h" /* DIR, FILE type definitions */
+#include "dirent.h" /* DIR, FILE type definitions */
/* Bus-specific headers */
#include "xf86Bus.h"
@@ -77,7 +77,6 @@ Bool pciSlotClaimed = FALSE;
(((c) & 0x00ffff00) \
== ((PCI_CLASS_DISPLAY << 16) | (PCI_SUBCLASS_DISPLAY_VGA << 8)))
-
static struct pci_slot_match xf86IsolateDevice = {
PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0
};
@@ -93,108 +92,110 @@ xf86PciProbe(void)
int num = 0;
struct pci_device *info;
struct pci_device_iterator *iter;
- struct pci_device ** xf86PciVideoInfo = NULL;
-
+ struct pci_device **xf86PciVideoInfo = NULL;
if (!xf86scanpci()) {
- xf86PciVideoInfo = NULL;
- return;
+ xf86PciVideoInfo = NULL;
+ return;
}
- iter = pci_slot_match_iterator_create(& xf86IsolateDevice);
+ iter = pci_slot_match_iterator_create(&xf86IsolateDevice);
while ((info = pci_device_next(iter)) != NULL) {
- if (PCIINFOCLASSES(info->device_class)) {
- num++;
- xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo,
- (sizeof(struct pci_device *)
- * (num + 1)));
- xf86PciVideoInfo[num] = NULL;
- xf86PciVideoInfo[num - 1] = info;
-
- pci_device_probe(info);
- if (pci_device_is_boot_vga(info)) {
+ if (PCIINFOCLASSES(info->device_class)) {
+ num++;
+ xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo,
+ (sizeof(struct pci_device *)
+ * (num + 1)));
+ xf86PciVideoInfo[num] = NULL;
+ xf86PciVideoInfo[num - 1] = info;
+
+ pci_device_probe(info);
+ if (pci_device_is_boot_vga(info)) {
primaryBus.type = BUS_PCI;
primaryBus.id.pci = info;
}
- info->user_data = 0;
- }
+ info->user_data = 0;
+ }
}
free(iter);
/* If we haven't found a primary device try a different heuristic */
if (primaryBus.type == BUS_NONE && num) {
- for (i = 0; i < num; i++) {
- uint16_t command;
-
- info = xf86PciVideoInfo[i];
- pci_device_cfg_read_u16(info, & command, 4);
-
- if ((command & PCI_CMD_MEM_ENABLE)
- && ((num == 1) || IS_VGA(info->device_class))) {
- if (primaryBus.type == BUS_NONE) {
- primaryBus.type = BUS_PCI;
- primaryBus.id.pci = info;
- } else {
- xf86Msg(X_NOTICE,
- "More than one possible primary device found\n");
- primaryBus.type ^= (BusType)(-1);
- }
- }
- }
+ for (i = 0; i < num; i++) {
+ uint16_t command;
+
+ info = xf86PciVideoInfo[i];
+ pci_device_cfg_read_u16(info, &command, 4);
+
+ if ((command & PCI_CMD_MEM_ENABLE)
+ && ((num == 1) || IS_VGA(info->device_class))) {
+ if (primaryBus.type == BUS_NONE) {
+ primaryBus.type = BUS_PCI;
+ primaryBus.id.pci = info;
+ }
+ else {
+ xf86Msg(X_NOTICE,
+ "More than one possible primary device found\n");
+ primaryBus.type ^= (BusType) (-1);
+ }
+ }
+ }
}
-
+
/* Print a summary of the video devices found */
for (k = 0; k < num; k++) {
- const char *prim = " ";
- Bool memdone = FALSE, iodone = FALSE;
-
+ const char *prim = " ";
+ Bool memdone = FALSE, iodone = FALSE;
- info = xf86PciVideoInfo[k];
+ info = xf86PciVideoInfo[k];
- if (!PCIALWAYSPRINTCLASSES(info->device_class))
- continue;
+ if (!PCIALWAYSPRINTCLASSES(info->device_class))
+ continue;
- if (xf86IsPrimaryPci(info))
- prim = "*";
+ if (xf86IsPrimaryPci(info))
+ prim = "*";
- xf86Msg(X_PROBED, "PCI:%s(%u:%u:%u:%u) %04x:%04x:%04x:%04x ", prim,
- info->domain, info->bus, info->dev, info->func,
- info->vendor_id, info->device_id,
- info->subvendor_id, info->subdevice_id);
+ xf86Msg(X_PROBED, "PCI:%s(%u:%u:%u:%u) %04x:%04x:%04x:%04x ", prim,
+ info->domain, info->bus, info->dev, info->func,
+ info->vendor_id, info->device_id,
+ info->subvendor_id, info->subdevice_id);
- xf86ErrorF("rev %d", info->revision);
+ xf86ErrorF("rev %d", info->revision);
- for (i = 0; i < 6; i++) {
- struct pci_mem_region * r = & info->regions[i];
+ for (i = 0; i < 6; i++) {
+ struct pci_mem_region *r = &info->regions[i];
- if ( r->size && ! r->is_IO ) {
- if (!memdone) {
- xf86ErrorF(", Mem @ ");
- memdone = TRUE;
- } else
- xf86ErrorF(", ");
- xf86ErrorF("0x%08lx/%ld", (long)r->base_addr, (long)r->size);
- }
- }
+ if (r->size && !r->is_IO) {
+ if (!memdone) {
+ xf86ErrorF(", Mem @ ");
+ memdone = TRUE;
+ }
+ else
+ xf86ErrorF(", ");
+ xf86ErrorF("0x%08lx/%ld", (long) r->base_addr, (long) r->size);
+ }
+ }
- for (i = 0; i < 6; i++) {
- struct pci_mem_region * r = & info->regions[i];
+ for (i = 0; i < 6; i++) {
+ struct pci_mem_region *r = &info->regions[i];
- if ( r->size && r->is_IO ) {
- if (!iodone) {
- xf86ErrorF(", I/O @ ");
- iodone = TRUE;
- } else
- xf86ErrorF(", ");
- xf86ErrorF("0x%08lx/%ld", (long)r->base_addr, (long)r->size);
- }
- }
+ if (r->size && r->is_IO) {
+ if (!iodone) {
+ xf86ErrorF(", I/O @ ");
+ iodone = TRUE;
+ }
+ else
+ xf86ErrorF(", ");
+ xf86ErrorF("0x%08lx/%ld", (long) r->base_addr, (long) r->size);
+ }
+ }
- if ( info->rom_size ) {
- xf86ErrorF(", BIOS @ 0x\?\?\?\?\?\?\?\?/%ld", (long)info->rom_size);
- }
+ if (info->rom_size) {
+ xf86ErrorF(", BIOS @ 0x\?\?\?\?\?\?\?\?/%ld",
+ (long) info->rom_size);
+ }
- xf86ErrorF("\n");
+ xf86ErrorF("\n");
}
free(xf86PciVideoInfo);
}
@@ -205,28 +206,29 @@ xf86PciProbe(void)
*/
int
-xf86ClaimPciSlot(struct pci_device * d, DriverPtr drvp,
- int chipset, GDevPtr dev, Bool active)
+xf86ClaimPciSlot(struct pci_device *d, DriverPtr drvp,
+ int chipset, GDevPtr dev, Bool active)
{
EntityPtr p = NULL;
int num;
-
+
if (xf86CheckPciSlot(d)) {
- num = xf86AllocateEntity();
- p = xf86Entities[num];
- p->driver = drvp;
- p->chipset = chipset;
- p->bus.type = BUS_PCI;
- p->bus.id.pci = d;
- p->active = active;
- p->inUse = FALSE;
- if (dev)
+ num = xf86AllocateEntity();
+ p = xf86Entities[num];
+ p->driver = drvp;
+ p->chipset = chipset;
+ p->bus.type = BUS_PCI;
+ p->bus.id.pci = d;
+ p->active = active;
+ p->inUse = FALSE;
+ if (dev)
xf86AddDevToEntity(num, dev);
- pciSlotClaimed = TRUE;
+ pciSlotClaimed = TRUE;
- return num;
- } else
- return -1;
+ return num;
+ }
+ else
+ return -1;
}
/*
@@ -238,13 +240,13 @@ xf86UnclaimPciSlot(struct pci_device *d)
int i;
for (i = 0; i < xf86NumEntities; i++) {
- const EntityPtr p = xf86Entities[i];
+ const EntityPtr p = xf86Entities[i];
- if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) {
- /* Probably the slot should be deallocated? */
- p->bus.type = BUS_NONE;
- return;
- }
+ if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) {
+ /* Probably the slot should be deallocated? */
+ p->bus.type = BUS_NONE;
+ return;
+ }
}
}
@@ -267,56 +269,56 @@ xf86ParsePciBusString(const char *busID, int *bus, int *device, int *func)
int i;
if (StringToBusType(busID, &id) != BUS_PCI)
- return FALSE;
+ return FALSE;
s = xstrdup(id);
p = strtok(s, ":");
if (p == NULL || *p == 0) {
- free(s);
- return FALSE;
+ free(s);
+ return FALSE;
}
d = strpbrk(p, "@");
if (d != NULL) {
- *(d++) = 0;
- for (i = 0; d[i] != 0; i++) {
- if (!isdigit(d[i])) {
- free(s);
- return FALSE;
- }
- }
+ *(d++) = 0;
+ for (i = 0; d[i] != 0; i++) {
+ if (!isdigit(d[i])) {
+ free(s);
+ return FALSE;
+ }
+ }
}
for (i = 0; p[i] != 0; i++) {
- if (!isdigit(p[i])) {
- free(s);
- return FALSE;
- }
+ if (!isdigit(p[i])) {
+ free(s);
+ return FALSE;
+ }
}
*bus = atoi(p);
if (d != NULL && *d != 0)
- *bus += atoi(d) << 8;
+ *bus += atoi(d) << 8;
p = strtok(NULL, ":");
if (p == NULL || *p == 0) {
- free(s);
- return FALSE;
+ free(s);
+ return FALSE;
}
for (i = 0; p[i] != 0; i++) {
- if (!isdigit(p[i])) {
- free(s);
- return FALSE;
- }
+ if (!isdigit(p[i])) {
+ free(s);
+ return FALSE;
+ }
}
*device = atoi(p);
*func = 0;
p = strtok(NULL, ":");
if (p == NULL || *p == 0) {
- free(s);
- return TRUE;
+ free(s);
+ return TRUE;
}
for (i = 0; p[i] != 0; i++) {
- if (!isdigit(p[i])) {
- free(s);
- return FALSE;
- }
+ if (!isdigit(p[i])) {
+ free(s);
+ return FALSE;
+ }
}
*func = atoi(p);
free(s);
@@ -333,9 +335,10 @@ xf86ComparePciBusString(const char *busID, int bus, int device, int func)
int ibus, idevice, ifunc;
if (xf86ParsePciBusString(busID, &ibus, &idevice, &ifunc)) {
- return bus == ibus && device == idevice && func == ifunc;
- } else {
- return FALSE;
+ return bus == ibus && device == idevice && func == ifunc;
+ }
+ else {
+ return FALSE;
}
}
@@ -343,7 +346,7 @@ xf86ComparePciBusString(const char *busID, int bus, int device, int func)
* xf86IsPrimaryPci() -- return TRUE if primary device
* is PCI and bus, dev and func numbers match.
*/
-
+
Bool
xf86IsPrimaryPci(struct pci_device *pPci)
{
@@ -357,9 +360,9 @@ struct pci_device *
xf86GetPciInfoForEntity(int entityIndex)
{
EntityPtr p;
-
+
if (entityIndex >= xf86NumEntities)
- return NULL;
+ return NULL;
p = xf86Entities[entityIndex];
return (p->bus.type == BUS_PCI) ? p->bus.id.pci : NULL;
@@ -370,13 +373,13 @@ xf86GetPciInfoForEntity(int entityIndex)
* PCI base address register values for the given PCI device.
*/
Bool
-xf86CheckPciMemBase( struct pci_device * pPci, memType base )
+xf86CheckPciMemBase(struct pci_device *pPci, memType base)
{
int i;
for (i = 0; i < 6; i++)
- if (base == pPci->regions[i].base_addr)
- return TRUE;
+ if (base == pPci->regions[i].base_addr)
+ return TRUE;
return FALSE;
}
@@ -390,11 +393,11 @@ xf86CheckPciSlot(const struct pci_device *d)
int i;
for (i = 0; i < xf86NumEntities; i++) {
- const EntityPtr p = xf86Entities[i];
+ const EntityPtr p = xf86Entities[i];
- if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) {
- return FALSE;
- }
+ if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) {
+ return FALSE;
+ }
}
return TRUE;
}
@@ -405,41 +408,41 @@ xf86CheckPciSlot(const struct pci_device *d)
Bool
xf86PciAddMatchingDev(DriverPtr drvp)
{
- const struct pci_id_match * const devices = drvp->supported_devices;
+ const struct pci_id_match *const devices = drvp->supported_devices;
int j;
struct pci_device *pPci;
struct pci_device_iterator *iter;
int numFound = 0;
-
iter = pci_id_match_iterator_create(NULL);
while ((pPci = pci_device_next(iter)) != NULL) {
- /* Determine if this device is supported by the driver. If it is,
- * add it to the list of devices to configure.
- */
- for (j = 0 ; ! END_OF_MATCHES(devices[j]) ; j++) {
- if ( PCI_ID_COMPARE( devices[j].vendor_id, pPci->vendor_id )
- && PCI_ID_COMPARE( devices[j].device_id, pPci->device_id )
- && ((devices[j].device_class_mask & pPci->device_class)
- == devices[j].device_class) ) {
- if (xf86CheckPciSlot(pPci)) {
- GDevPtr pGDev = xf86AddBusDeviceToConfigure(
- drvp->driverName, BUS_PCI, pPci, -1);
- if (pGDev != NULL) {
- /* After configure pass 1, chipID and chipRev are
- * treated as over-rides, so clobber them here.
- */
- pGDev->chipID = -1;
- pGDev->chipRev = -1;
- }
+ /* Determine if this device is supported by the driver. If it is,
+ * add it to the list of devices to configure.
+ */
+ for (j = 0; !END_OF_MATCHES(devices[j]); j++) {
+ if (PCI_ID_COMPARE(devices[j].vendor_id, pPci->vendor_id)
+ && PCI_ID_COMPARE(devices[j].device_id, pPci->device_id)
+ && ((devices[j].device_class_mask & pPci->device_class)
+ == devices[j].device_class)) {
+ if (xf86CheckPciSlot(pPci)) {
+ GDevPtr pGDev =
+ xf86AddBusDeviceToConfigure(drvp->driverName, BUS_PCI,
+ pPci, -1);
+ if (pGDev != NULL) {
+ /* After configure pass 1, chipID and chipRev are
+ * treated as over-rides, so clobber them here.
+ */
+ pGDev->chipID = -1;
+ pGDev->chipRev = -1;
+ }
- numFound++;
- }
+ numFound++;
+ }
- break;
+ break;
+ }
}
}
- }
pci_iterator_destroy(iter);
@@ -450,97 +453,96 @@ Bool
xf86PciProbeDev(DriverPtr drvp)
{
int i, j;
- struct pci_device * pPci;
+ struct pci_device *pPci;
Bool foundScreen = FALSE;
- const struct pci_id_match * const devices = drvp->supported_devices;
+ const struct pci_id_match *const devices = drvp->supported_devices;
GDevPtr *devList;
- const unsigned numDevs = xf86MatchDevice(drvp->driverName, & devList);
-
- for ( i = 0 ; i < numDevs ; i++ ) {
- struct pci_device_iterator *iter;
- unsigned device_id;
-
-
- /* Find the pciVideoRec associated with this device section.
- */
- iter = pci_id_match_iterator_create(NULL);
- while ((pPci = pci_device_next(iter)) != NULL) {
- if (devList[i]->busID && *devList[i]->busID) {
- if (xf86ComparePciBusString(devList[i]->busID,
- ((pPci->domain << 8)
- | pPci->bus),
- pPci->dev,
- pPci->func)) {
- break;
- }
- }
- else if (xf86IsPrimaryPci(pPci)) {
- break;
- }
- }
-
- pci_iterator_destroy(iter);
-
- if (pPci == NULL) {
- continue;
- }
- device_id = (devList[i]->chipID > 0)
- ? devList[i]->chipID : pPci->device_id;
-
-
- /* Once the pciVideoRec is found, determine if the device is supported
- * by the driver. If it is, probe it!
- */
- for ( j = 0 ; ! END_OF_MATCHES( devices[j] ) ; j++ ) {
- if ( PCI_ID_COMPARE( devices[j].vendor_id, pPci->vendor_id )
- && PCI_ID_COMPARE( devices[j].device_id, device_id )
+ const unsigned numDevs = xf86MatchDevice(drvp->driverName, &devList);
+
+ for (i = 0; i < numDevs; i++) {
+ struct pci_device_iterator *iter;
+ unsigned device_id;
+
+ /* Find the pciVideoRec associated with this device section.
+ */
+ iter = pci_id_match_iterator_create(NULL);
+ while ((pPci = pci_device_next(iter)) != NULL) {
+ if (devList[i]->busID && *devList[i]->busID) {
+ if (xf86ComparePciBusString(devList[i]->busID,
+ ((pPci->domain << 8)
+ | pPci->bus),
+ pPci->dev, pPci->func)) {
+ break;
+ }
+ }
+ else if (xf86IsPrimaryPci(pPci)) {
+ break;
+ }
+ }
+
+ pci_iterator_destroy(iter);
+
+ if (pPci == NULL) {
+ continue;
+ }
+ device_id = (devList[i]->chipID > 0)
+ ? devList[i]->chipID : pPci->device_id;
+
+ /* Once the pciVideoRec is found, determine if the device is supported
+ * by the driver. If it is, probe it!
+ */
+ for (j = 0; !END_OF_MATCHES(devices[j]); j++) {
+ if (PCI_ID_COMPARE(devices[j].vendor_id, pPci->vendor_id)
+ && PCI_ID_COMPARE(devices[j].device_id, device_id)
&& ((devices[j].device_class_mask & pPci->device_class)
- == devices[j].device_class) ) {
- int entry;
-
- /* Allow the same entity to be used more than once for
- * devices with multiple screens per entity. This assumes
- * implicitly that there will be a screen == 0 instance.
- *
- * FIXME Need to make sure that two different drivers don't
- * FIXME claim the same screen > 0 instance.
- */
- if ((devList[i]->screen == 0) && !xf86CheckPciSlot(pPci))
- continue;
-
- DebugF("%s: card at %d:%d:%d is claimed by a Device section\n",
- drvp->driverName, pPci->bus, pPci->dev, pPci->func);
-
- /* Allocate an entry in the lists to be returned */
- entry = xf86ClaimPciSlot(pPci, drvp, device_id,
+ == devices[j].device_class)) {
+ int entry;
+
+ /* Allow the same entity to be used more than once for
+ * devices with multiple screens per entity. This assumes
+ * implicitly that there will be a screen == 0 instance.
+ *
+ * FIXME Need to make sure that two different drivers don't
+ * FIXME claim the same screen > 0 instance.
+ */
+ if ((devList[i]->screen == 0) && !xf86CheckPciSlot(pPci))
+ continue;
+
+ DebugF("%s: card at %d:%d:%d is claimed by a Device section\n",
+ drvp->driverName, pPci->bus, pPci->dev, pPci->func);
+
+ /* Allocate an entry in the lists to be returned */
+ entry = xf86ClaimPciSlot(pPci, drvp, device_id,
devList[i], devList[i]->active);
- if ((entry == -1) && (devList[i]->screen > 0)) {
- unsigned k;
-
- for (k = 0; k < xf86NumEntities; k++ ) {
- EntityPtr pEnt = xf86Entities[k];
- if (pEnt->bus.type != BUS_PCI)
- continue;
- if (pEnt->bus.id.pci == pPci) {
- entry = k;
- xf86AddDevToEntity(k, devList[i]);
- break;
- }
- }
- }
-
- if (entry != -1) {
- if ((*drvp->PciProbe)(drvp, entry, pPci,
- devices[j].match_data)) {
- foundScreen = TRUE;
- } else
- xf86UnclaimPciSlot(pPci);
- }
-
- break;
- }
- }
+ if ((entry == -1) && (devList[i]->screen > 0)) {
+ unsigned k;
+
+ for (k = 0; k < xf86NumEntities; k++) {
+ EntityPtr pEnt = xf86Entities[k];
+
+ if (pEnt->bus.type != BUS_PCI)
+ continue;
+ if (pEnt->bus.id.pci == pPci) {
+ entry = k;
+ xf86AddDevToEntity(k, devList[i]);
+ break;
+ }
+ }
+ }
+
+ if (entry != -1) {
+ if ((*drvp->PciProbe) (drvp, entry, pPci,
+ devices[j].match_data)) {
+ foundScreen = TRUE;
+ }
+ else
+ xf86UnclaimPciSlot(pPci);
+ }
+
+ break;
+ }
+ }
}
free(devList);
@@ -557,7 +559,8 @@ xf86PciIsolateDevice(char *argument)
xf86IsolateDevice.bus = PCI_BUS_NO_DOMAIN(bus);
xf86IsolateDevice.dev = device;
xf86IsolateDevice.func = func;
- } else
+ }
+ else
FatalError("Invalid isolated device specification\n");
}
@@ -567,25 +570,24 @@ pciDeviceHasBars(struct pci_device *pci)
int i;
for (i = 0; i < 6; i++)
- if (pci->regions[i].size)
- return TRUE;
+ if (pci->regions[i].size)
+ return TRUE;
if (pci->rom_size)
- return TRUE;
+ return TRUE;
return FALSE;
}
struct Inst {
- struct pci_device * pci;
- GDevPtr dev;
- Bool foundHW; /* PCIid in list of supported chipsets */
- Bool claimed; /* BusID matches with a device section */
- int chip;
- int screen;
+ struct pci_device *pci;
+ GDevPtr dev;
+ Bool foundHW; /* PCIid in list of supported chipsets */
+ Bool claimed; /* BusID matches with a device section */
+ int chip;
+ int screen;
};
-
/**
* Find set of unclaimed devices matching a given vendor ID.
*
@@ -620,12 +622,12 @@ struct Inst {
*/
int
xf86MatchPciInstances(const char *driverName, int vendorID,
- SymTabPtr chipsets, PciChipsets *PCIchipsets,
- GDevPtr *devList, int numDevs, DriverPtr drvp,
- int **foundEntities)
+ SymTabPtr chipsets, PciChipsets * PCIchipsets,
+ GDevPtr * devList, int numDevs, DriverPtr drvp,
+ int **foundEntities)
{
- int i,j;
- struct pci_device * pPci;
+ int i, j;
+ struct pci_device *pPci;
struct pci_device_iterator *iter;
struct Inst *instances = NULL;
int numClaimedInstances = 0;
@@ -637,7 +639,6 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
*foundEntities = NULL;
-
/* Each PCI device will contribute at least one entry. Each device
* section can contribute at most one entry. The sum of the two is
* guaranteed to be larger than the maximum possible number of entries.
@@ -645,199 +646,199 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
* need for realloc calls inside the loop.
*/
if (!(xf86DoConfigure && xf86DoConfigurePass1)) {
- unsigned max_entries = numDevs;
+ unsigned max_entries = numDevs;
- iter = pci_slot_match_iterator_create(NULL);
- while ((pPci = pci_device_next(iter)) != NULL) {
- max_entries++;
- }
+ iter = pci_slot_match_iterator_create(NULL);
+ while ((pPci = pci_device_next(iter)) != NULL) {
+ max_entries++;
+ }
- pci_iterator_destroy(iter);
- instances = xnfalloc(max_entries * sizeof(struct Inst));
+ pci_iterator_destroy(iter);
+ instances = xnfalloc(max_entries * sizeof(struct Inst));
}
iter = pci_slot_match_iterator_create(NULL);
while ((pPci = pci_device_next(iter)) != NULL) {
- unsigned device_class = pPci->device_class;
- Bool foundVendor = FALSE;
-
-
- /* Convert the pre-PCI 2.0 device class for a VGA adapter to the
- * 2.0 version of the same class.
- */
- if ( device_class == 0x00000101 ) {
- device_class = 0x00030000;
- }
-
-
- /* Find PCI devices that match the given vendor ID. The vendor ID is
- * either specified explicitly as a parameter to the function or
- * implicitly encoded in the high bits of id->PCIid.
- *
- * The first device with a matching vendor is recorded, even if the
- * device ID doesn't match. This is done because the Device section
- * in the xorg.conf file can over-ride the device ID. A matching PCI
- * ID might not be found now, but after the device ID over-ride is
- * applied there /might/ be a match.
- */
- for (id = PCIchipsets; id->PCIid != -1; id++) {
- const unsigned vendor_id = ((id->PCIid & 0xFFFF0000) >> 16)
- | vendorID;
- const unsigned device_id = (id->PCIid & 0x0000FFFF);
- const unsigned match_class = 0x00030000 | id->PCIid;
-
- if ((vendor_id == pPci->vendor_id)
- || ((vendorID == PCI_VENDOR_GENERIC) && (match_class == device_class))) {
- if (!foundVendor && (instances != NULL)) {
- ++allocatedInstances;
- instances[allocatedInstances - 1].pci = pPci;
- instances[allocatedInstances - 1].dev = NULL;
- instances[allocatedInstances - 1].claimed = FALSE;
- instances[allocatedInstances - 1].foundHW = FALSE;
- instances[allocatedInstances - 1].screen = 0;
- }
-
- foundVendor = TRUE;
-
- if ( (device_id == pPci->device_id)
- || ((vendorID == PCI_VENDOR_GENERIC)
- && (match_class == device_class)) ) {
- if ( instances != NULL ) {
- instances[allocatedInstances - 1].foundHW = TRUE;
- instances[allocatedInstances - 1].chip = id->numChipset;
- }
-
-
- if ( xf86DoConfigure && xf86DoConfigurePass1 ) {
- if (xf86CheckPciSlot(pPci)) {
- GDevPtr pGDev =
- xf86AddBusDeviceToConfigure(drvp->driverName,
- BUS_PCI, pPci, -1);
- if (pGDev) {
- /* After configure pass 1, chipID and chipRev
- * are treated as over-rides, so clobber them
- * here.
- */
- pGDev->chipID = -1;
- pGDev->chipRev = -1;
- }
-
- numFound++;
- }
- }
- else {
- numFound++;
- }
-
- break;
- }
- }
- }
+ unsigned device_class = pPci->device_class;
+ Bool foundVendor = FALSE;
+
+ /* Convert the pre-PCI 2.0 device class for a VGA adapter to the
+ * 2.0 version of the same class.
+ */
+ if (device_class == 0x00000101) {
+ device_class = 0x00030000;
+ }
+
+ /* Find PCI devices that match the given vendor ID. The vendor ID is
+ * either specified explicitly as a parameter to the function or
+ * implicitly encoded in the high bits of id->PCIid.
+ *
+ * The first device with a matching vendor is recorded, even if the
+ * device ID doesn't match. This is done because the Device section
+ * in the xorg.conf file can over-ride the device ID. A matching PCI
+ * ID might not be found now, but after the device ID over-ride is
+ * applied there /might/ be a match.
+ */
+ for (id = PCIchipsets; id->PCIid != -1; id++) {
+ const unsigned vendor_id = ((id->PCIid & 0xFFFF0000) >> 16)
+ | vendorID;
+ const unsigned device_id = (id->PCIid & 0x0000FFFF);
+ const unsigned match_class = 0x00030000 | id->PCIid;
+
+ if ((vendor_id == pPci->vendor_id)
+ || ((vendorID == PCI_VENDOR_GENERIC) &&
+ (match_class == device_class))) {
+ if (!foundVendor && (instances != NULL)) {
+ ++allocatedInstances;
+ instances[allocatedInstances - 1].pci = pPci;
+ instances[allocatedInstances - 1].dev = NULL;
+ instances[allocatedInstances - 1].claimed = FALSE;
+ instances[allocatedInstances - 1].foundHW = FALSE;
+ instances[allocatedInstances - 1].screen = 0;
+ }
+
+ foundVendor = TRUE;
+
+ if ((device_id == pPci->device_id)
+ || ((vendorID == PCI_VENDOR_GENERIC)
+ && (match_class == device_class))) {
+ if (instances != NULL) {
+ instances[allocatedInstances - 1].foundHW = TRUE;
+ instances[allocatedInstances - 1].chip = id->numChipset;
+ }
+
+ if (xf86DoConfigure && xf86DoConfigurePass1) {
+ if (xf86CheckPciSlot(pPci)) {
+ GDevPtr pGDev =
+ xf86AddBusDeviceToConfigure(drvp->driverName,
+ BUS_PCI, pPci, -1);
+
+ if (pGDev) {
+ /* After configure pass 1, chipID and chipRev
+ * are treated as over-rides, so clobber them
+ * here.
+ */
+ pGDev->chipID = -1;
+ pGDev->chipRev = -1;
+ }
+
+ numFound++;
+ }
+ }
+ else {
+ numFound++;
+ }
+
+ break;
+ }
+ }
+ }
}
pci_iterator_destroy(iter);
-
/* In "probe only" or "configure" mode (signaled by instances being NULL),
* our work is done. Return the number of detected devices.
*/
- if ( instances == NULL ) {
- return numFound;
+ if (instances == NULL) {
+ return numFound;
}
-
/*
* This may be debatable, but if no PCI devices with a matching vendor
* type is found, return zero now. It is probably not desirable to
* allow the config file to override this.
*/
if (allocatedInstances <= 0) {
- free(instances);
- return 0;
+ free(instances);
+ return 0;
}
-
DebugF("%s instances found: %d\n", driverName, allocatedInstances);
- /*
- * 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.
- */
+ /*
+ * Check for devices that need duplicated instances. This is required
+ * when there is more than one screen per entity.
+ *
+ * XXX This currently doesn't work for cases where the BusID isn't
+ * specified explicitly in the config file.
+ */
for (j = 0; j < numDevs; j++) {
- if (devList[j]->screen > 0 && devList[j]->busID
- && *devList[j]->busID) {
- for (i = 0; i < allocatedInstances; i++) {
- pPci = instances[i].pci;
- if (xf86ComparePciBusString(devList[j]->busID,
- PCI_MAKE_BUS( pPci->domain, pPci->bus ),
- pPci->dev,
- pPci->func)) {
- allocatedInstances++;
- instances[allocatedInstances - 1] = instances[i];
- instances[allocatedInstances - 1].screen = devList[j]->screen;
- numFound++;
- break;
- }
- }
- }
+ if (devList[j]->screen > 0 && devList[j]->busID && *devList[j]->busID) {
+ for (i = 0; i < allocatedInstances; i++) {
+ pPci = instances[i].pci;
+ if (xf86ComparePciBusString(devList[j]->busID,
+ PCI_MAKE_BUS(pPci->domain,
+ pPci->bus), pPci->dev,
+ pPci->func)) {
+ allocatedInstances++;
+ instances[allocatedInstances - 1] = instances[i];
+ instances[allocatedInstances - 1].screen =
+ devList[j]->screen;
+ numFound++;
+ break;
+ }
+ }
+ }
}
for (i = 0; i < allocatedInstances; i++) {
- GDevPtr dev = NULL;
- GDevPtr devBus = NULL;
-
- pPci = instances[i].pci;
- for (j = 0; j < numDevs; j++) {
- if (devList[j]->busID && *devList[j]->busID) {
- if (xf86ComparePciBusString(devList[j]->busID,
- PCI_MAKE_BUS( pPci->domain, pPci->bus ),
- pPci->dev,
- pPci->func) &&
- devList[j]->screen == instances[i].screen) {
-
- if (devBus)
- xf86MsgVerb(X_WARNING,0,
- "%s: More than one matching Device section for "
- "instances\n\t(BusID: %s) found: %s\n",
- driverName, devList[j]->busID,
- devList[j]->identifier);
- else
- devBus = devList[j];
- }
- } else {
- /*
- * if device section without BusID is found
- * only assign to it to the primary device.
- */
- if (xf86IsPrimaryPci(pPci)) {
- xf86Msg(X_PROBED, "Assigning device section with no busID"
- " to primary device\n");
- if (dev || devBus)
- xf86MsgVerb(X_WARNING, 0,
- "%s: More than one matching Device section "
- "found: %s\n", driverName, devList[j]->identifier);
- else
- dev = devList[j];
- }
- }
- }
- if (devBus) dev = devBus; /* busID preferred */
- if (!dev) {
- if (xf86CheckPciSlot(pPci) && pciDeviceHasBars(pPci)) {
- xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section "
- "for instance (BusID PCI:%u@%u:%u:%u) found\n",
- driverName, pPci->domain, pPci->bus, pPci->dev,
- pPci->func);
- }
- } else {
- numClaimedInstances++;
- instances[i].claimed = TRUE;
- instances[i].dev = dev;
- }
+ GDevPtr dev = NULL;
+ GDevPtr devBus = NULL;
+
+ pPci = instances[i].pci;
+ for (j = 0; j < numDevs; j++) {
+ if (devList[j]->busID && *devList[j]->busID) {
+ if (xf86ComparePciBusString(devList[j]->busID,
+ PCI_MAKE_BUS(pPci->domain,
+ pPci->bus), pPci->dev,
+ pPci->func) &&
+ devList[j]->screen == instances[i].screen) {
+
+ if (devBus)
+ xf86MsgVerb(X_WARNING, 0,
+ "%s: More than one matching Device section for "
+ "instances\n\t(BusID: %s) found: %s\n",
+ driverName, devList[j]->busID,
+ devList[j]->identifier);
+ else
+ devBus = devList[j];
+ }
+ }
+ else {
+ /*
+ * if device section without BusID is found
+ * only assign to it to the primary device.
+ */
+ if (xf86IsPrimaryPci(pPci)) {
+ xf86Msg(X_PROBED, "Assigning device section with no busID"
+ " to primary device\n");
+ if (dev || devBus)
+ xf86MsgVerb(X_WARNING, 0,
+ "%s: More than one matching Device section "
+ "found: %s\n", driverName,
+ devList[j]->identifier);
+ else
+ dev = devList[j];
+ }
+ }
+ }
+ if (devBus)
+ dev = devBus; /* busID preferred */
+ if (!dev) {
+ if (xf86CheckPciSlot(pPci) && pciDeviceHasBars(pPci)) {
+ xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section "
+ "for instance (BusID PCI:%u@%u:%u:%u) found\n",
+ driverName, pPci->domain, pPci->bus, pPci->dev,
+ pPci->func);
+ }
+ }
+ else {
+ numClaimedInstances++;
+ instances[i].claimed = TRUE;
+ instances[i].dev = dev;
+ }
}
DebugF("%s instances found: %d\n", driverName, numClaimedInstances);
/*
@@ -846,78 +847,82 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
* If chipset is not valid ignore BusSlot completely.
*/
for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) {
- MessageType from = X_PROBED;
-
- if (!instances[i].claimed) {
- continue;
- }
- if (instances[i].dev->chipset) {
- for (c = chipsets; c->token >= 0; c++) {
- if (xf86NameCmp(c->name, instances[i].dev->chipset) == 0)
- break;
- }
- if (c->token == -1) {
- instances[i].claimed = FALSE;
- numClaimedInstances--;
- xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device "
- "section \"%s\" isn't valid for this driver\n",
- driverName, instances[i].dev->chipset,
- instances[i].dev->identifier);
- } else {
- instances[i].chip = c->token;
-
- for (id = PCIchipsets; id->numChipset >= 0; id++) {
- if (id->numChipset == instances[i].chip)
- break;
- }
- if(id->numChipset >=0){
- xf86Msg(X_CONFIG,"Chipset override: %s\n",
- instances[i].dev->chipset);
- from = X_CONFIG;
- } else {
- instances[i].claimed = FALSE;
- numClaimedInstances--;
- xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device "
- "section \"%s\" isn't a valid PCI chipset\n",
- driverName, instances[i].dev->chipset,
- instances[i].dev->identifier);
- }
- }
- } else if (instances[i].dev->chipID > 0) {
- for (id = PCIchipsets; id->numChipset >= 0; id++) {
- if (id->PCIid == instances[i].dev->chipID)
- break;
- }
- if (id->numChipset == -1) {
- instances[i].claimed = FALSE;
- numClaimedInstances--;
- xf86MsgVerb(X_WARNING, 0, "%s: ChipID 0x%04X in Device "
- "section \"%s\" isn't valid for this driver\n",
- driverName, instances[i].dev->chipID,
- instances[i].dev->identifier);
- } else {
- instances[i].chip = id->numChipset;
-
- xf86Msg( X_CONFIG,"ChipID override: 0x%04X\n",
- instances[i].dev->chipID);
- from = X_CONFIG;
- }
- } else if (!instances[i].foundHW) {
- /*
- * This means that there was no override and the PCI chipType
- * doesn't match one that is supported
- */
- instances[i].claimed = FALSE;
- numClaimedInstances--;
- }
- if (instances[i].claimed == TRUE){
- for (c = chipsets; c->token >= 0; c++) {
- if (c->token == instances[i].chip)
- break;
- }
- xf86Msg(from,"Chipset %s found\n",
- c->name);
- }
+ MessageType from = X_PROBED;
+
+ if (!instances[i].claimed) {
+ continue;
+ }
+ if (instances[i].dev->chipset) {
+ for (c = chipsets; c->token >= 0; c++) {
+ if (xf86NameCmp(c->name, instances[i].dev->chipset) == 0)
+ break;
+ }
+ if (c->token == -1) {
+ instances[i].claimed = FALSE;
+ numClaimedInstances--;
+ xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device "
+ "section \"%s\" isn't valid for this driver\n",
+ driverName, instances[i].dev->chipset,
+ instances[i].dev->identifier);
+ }
+ else {
+ instances[i].chip = c->token;
+
+ for (id = PCIchipsets; id->numChipset >= 0; id++) {
+ if (id->numChipset == instances[i].chip)
+ break;
+ }
+ if (id->numChipset >= 0) {
+ xf86Msg(X_CONFIG, "Chipset override: %s\n",
+ instances[i].dev->chipset);
+ from = X_CONFIG;
+ }
+ else {
+ instances[i].claimed = FALSE;
+ numClaimedInstances--;
+ xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device "
+ "section \"%s\" isn't a valid PCI chipset\n",
+ driverName, instances[i].dev->chipset,
+ instances[i].dev->identifier);
+ }
+ }
+ }
+ else if (instances[i].dev->chipID > 0) {
+ for (id = PCIchipsets; id->numChipset >= 0; id++) {
+ if (id->PCIid == instances[i].dev->chipID)
+ break;
+ }
+ if (id->numChipset == -1) {
+ instances[i].claimed = FALSE;
+ numClaimedInstances--;
+ xf86MsgVerb(X_WARNING, 0, "%s: ChipID 0x%04X in Device "
+ "section \"%s\" isn't valid for this driver\n",
+ driverName, instances[i].dev->chipID,
+ instances[i].dev->identifier);
+ }
+ else {
+ instances[i].chip = id->numChipset;
+
+ xf86Msg(X_CONFIG, "ChipID override: 0x%04X\n",
+ instances[i].dev->chipID);
+ from = X_CONFIG;
+ }
+ }
+ else if (!instances[i].foundHW) {
+ /*
+ * This means that there was no override and the PCI chipType
+ * doesn't match one that is supported
+ */
+ instances[i].claimed = FALSE;
+ numClaimedInstances--;
+ }
+ if (instances[i].claimed == TRUE) {
+ for (c = chipsets; c->token >= 0; c++) {
+ if (c->token == instances[i].chip)
+ break;
+ }
+ xf86Msg(from, "Chipset %s found\n", c->name);
+ }
}
/*
@@ -926,48 +931,48 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
*/
numFound = 0;
for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) {
- if (!instances[i].claimed)
- continue;
- pPci = instances[i].pci;
-
+ if (!instances[i].claimed)
+ continue;
+ pPci = instances[i].pci;
/*
- * Allow the same entity to be used more than once for devices with
- * multiple screens per entity. This assumes implicitly that there
- * will be a screen == 0 instance.
- *
- * XXX Need to make sure that two different drivers don't claim
- * the same screen > 0 instance.
- */
- if (instances[i].screen == 0 && !xf86CheckPciSlot( pPci ))
- continue;
-
- DebugF("%s: card at %d:%d:%d is claimed by a Device section\n",
- driverName, pPci->bus, pPci->dev, pPci->func);
-
- /* Allocate an entry in the lists to be returned */
- numFound++;
- retEntities = xnfrealloc(retEntities, numFound * sizeof(int));
- retEntities[numFound - 1] = xf86ClaimPciSlot( pPci, drvp,
- instances[i].chip,
- instances[i].dev,
- instances[i].dev->active);
+ * Allow the same entity to be used more than once for devices with
+ * multiple screens per entity. This assumes implicitly that there
+ * will be a screen == 0 instance.
+ *
+ * XXX Need to make sure that two different drivers don't claim
+ * the same screen > 0 instance.
+ */
+ if (instances[i].screen == 0 && !xf86CheckPciSlot(pPci))
+ continue;
+
+ DebugF("%s: card at %d:%d:%d is claimed by a Device section\n",
+ driverName, pPci->bus, pPci->dev, pPci->func);
+
+ /* Allocate an entry in the lists to be returned */
+ numFound++;
+ retEntities = xnfrealloc(retEntities, numFound * sizeof(int));
+ retEntities[numFound - 1] = xf86ClaimPciSlot(pPci, drvp,
+ instances[i].chip,
+ instances[i].dev,
+ instances[i].dev->active);
if (retEntities[numFound - 1] == -1 && instances[i].screen > 0) {
- for (j = 0; j < xf86NumEntities; j++) {
- EntityPtr pEnt = xf86Entities[j];
- if (pEnt->bus.type != BUS_PCI)
- continue;
- if (pEnt->bus.id.pci == pPci) {
- retEntities[numFound - 1] = j;
- xf86AddDevToEntity(j, instances[i].dev);
- break;
- }
- }
- }
+ for (j = 0; j < xf86NumEntities; j++) {
+ EntityPtr pEnt = xf86Entities[j];
+
+ if (pEnt->bus.type != BUS_PCI)
+ continue;
+ if (pEnt->bus.id.pci == pPci) {
+ retEntities[numFound - 1] = j;
+ xf86AddDevToEntity(j, instances[i].dev);
+ break;
+ }
+ }
+ }
}
free(instances);
if (numFound > 0) {
- *foundEntities = retEntities;
+ *foundEntities = retEntities;
}
return numFound;
@@ -981,51 +986,52 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
* non-NULL all static resources listed there will be registered.
*/
static void
-xf86ConfigPciEntityInactive(EntityInfoPtr pEnt, PciChipsets *p_chip,
- EntityProc init, EntityProc enter,
- EntityProc leave, pointer private)
+xf86ConfigPciEntityInactive(EntityInfoPtr pEnt, PciChipsets * p_chip,
+ EntityProc init, EntityProc enter,
+ EntityProc leave, pointer private)
{
ScrnInfoPtr pScrn;
if ((pScrn = xf86FindScreenForEntity(pEnt->index)))
- xf86RemoveEntityFromScreen(pScrn,pEnt->index);
+ xf86RemoveEntityFromScreen(pScrn, pEnt->index);
/* shared resources are only needed when entity is active: remove */
- xf86SetEntityFuncs(pEnt->index,init,enter,leave,private);
+ xf86SetEntityFuncs(pEnt->index, init, enter, leave, private);
}
ScrnInfoPtr
xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
- PciChipsets *p_chip, void *dummy, EntityProc init,
- EntityProc enter, EntityProc leave, pointer private)
+ PciChipsets * p_chip, void *dummy, EntityProc init,
+ EntityProc enter, EntityProc leave, pointer private)
{
EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
- if (!pEnt) return pScrn;
+
+ if (!pEnt)
+ return pScrn;
if (!(pEnt->location.type == BUS_PCI)
- || !xf86GetPciInfoForEntity(entityIndex)) {
- free(pEnt);
- return pScrn;
+ || !xf86GetPciInfoForEntity(entityIndex)) {
+ free(pEnt);
+ return pScrn;
}
if (!pEnt->active) {
- xf86ConfigPciEntityInactive(pEnt, p_chip, init, enter,
- leave, private);
- free(pEnt);
- return pScrn;
+ xf86ConfigPciEntityInactive(pEnt, p_chip, init, enter, leave, private);
+ free(pEnt);
+ return pScrn;
}
if (!pScrn)
- pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag);
+ pScrn = xf86AllocateScreen(pEnt->driver, scrnFlag);
if (xf86IsEntitySharable(entityIndex)) {
xf86SetEntityShared(entityIndex);
}
- xf86AddEntityToScreen(pScrn,entityIndex);
+ xf86AddEntityToScreen(pScrn, entityIndex);
if (xf86IsEntityShared(entityIndex)) {
return pScrn;
}
free(pEnt);
- xf86SetEntityFuncs(entityIndex,init,enter,leave,private);
+ xf86SetEntityFuncs(entityIndex, init, enter, leave, private);
return pScrn;
}
@@ -1036,20 +1042,22 @@ xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
*/
Bool
xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,
- PciChipsets *p_chip, void *dummy, EntityProc init,
+ PciChipsets * p_chip, void *dummy, EntityProc init,
EntityProc enter, EntityProc leave, pointer private)
{
EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
- if (!pEnt) return FALSE;
+
+ if (!pEnt)
+ return FALSE;
if (!pEnt->active || !(pEnt->location.type == BUS_PCI)) {
free(pEnt);
return FALSE;
}
- xf86AddEntityToScreen(pScrn,entityIndex);
+ xf86AddEntityToScreen(pScrn, entityIndex);
free(pEnt);
- if (!xf86SetEntityFuncs(entityIndex,init,enter,leave,private))
+ if (!xf86SetEntityFuncs(entityIndex, init, enter, leave, private))
return FALSE;
return TRUE;
@@ -1057,106 +1065,165 @@ xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,
static int
videoPtrToDriverList(struct pci_device *dev,
- char *returnList[], int returnListMax)
+ char *returnList[], int returnListMax)
{
int i;
+
/* Add more entries here if we ever return more than 4 drivers for
any device */
const char *driverList[5] = { NULL, NULL, NULL, NULL, NULL };
- switch (dev->vendor_id)
+ switch (dev->vendor_id) {
+ /* AMD Geode LX */
+ case 0x1022:
+ if (dev->device_id == 0x2081)
+ driverList[0] = "geode";
+ break;
+ /* older Geode products acquired by AMD still carry an NSC vendor_id */
+ case 0x100b:
+ if (dev->device_id == 0x0030) {
+ /* NSC Geode GX2 specifically */
+ driverList[0] = "geode";
+ /* GX2 support started its life in the NSC tree and was later
+ forked by AMD for GEODE so we keep it as a backup */
+ driverList[1] = "nsc";
+ }
+ else
+ /* other NSC variant e.g. 0x0104 (SC1400), 0x0504 (SCx200) */
+ driverList[0] = "nsc";
+ break;
+ /* Cyrix Geode GX1 */
+ case 0x1078:
+ if (dev->device_id == 0x0104)
+ driverList[0] = "cyrix";
+ break;
+ case 0x1142:
+ driverList[0] = "apm";
+ break;
+ case 0xedd8:
+ driverList[0] = "ark";
+ break;
+ case 0x1a03:
+ driverList[0] = "ast";
+ break;
+ case 0x1002:
+ driverList[0] = "ati";
+ break;
+ case 0x102c:
+ driverList[0] = "chips";
+ break;
+ case 0x1013:
+ driverList[0] = "cirrus";
+ break;
+ case 0x3d3d:
+ driverList[0] = "glint";
+ break;
+ case 0x105d:
+ driverList[0] = "i128";
+ break;
+ case 0x8086:
+ if ((dev->device_id == 0x00d1) || (dev->device_id == 0x7800)) {
+ driverList[0] = "i740";
+ }
+ else if (dev->device_id == 0x8108) {
+ break; /* "hooray" for poulsbo */
+ }
+ else {
+ driverList[0] = "intel";
+ }
+ break;
+ case 0x102b:
+ driverList[0] = "mga";
+ break;
+ case 0x10c8:
+ driverList[0] = "neomagic";
+ break;
+ case 0x10de:
+ case 0x12d2:
{
- /* AMD Geode LX */
- case 0x1022:
- if (dev->device_id == 0x2081)
- driverList[0] = "geode";
- break;
- /* older Geode products acquired by AMD still carry an NSC vendor_id */
- case 0x100b:
- if (dev->device_id == 0x0030) {
- /* NSC Geode GX2 specifically */
- driverList[0] = "geode";
- /* GX2 support started its life in the NSC tree and was later
- forked by AMD for GEODE so we keep it as a backup */
- driverList[1] = "nsc";
- } else
- /* other NSC variant e.g. 0x0104 (SC1400), 0x0504 (SCx200) */
- driverList[0] = "nsc";
- break;
- /* Cyrix Geode GX1 */
- case 0x1078:
- if (dev->device_id == 0x0104)
- driverList[0] = "cyrix";
- break;
- case 0x1142: driverList[0] = "apm"; break;
- case 0xedd8: driverList[0] = "ark"; break;
- case 0x1a03: driverList[0] = "ast"; break;
- case 0x1002: driverList[0] = "ati"; break;
- case 0x102c: driverList[0] = "chips"; break;
- case 0x1013: driverList[0] = "cirrus"; break;
- case 0x3d3d: driverList[0] = "glint"; break;
- case 0x105d: driverList[0] = "i128"; break;
- case 0x8086:
- if ((dev->device_id == 0x00d1) || (dev->device_id == 0x7800)) {
- driverList[0] = "i740";
- } else if (dev->device_id == 0x8108) {
- break; /* "hooray" for poulsbo */
- } else {
- driverList[0] = "intel";
- }
- break;
- case 0x102b: driverList[0] = "mga"; break;
- case 0x10c8: driverList[0] = "neomagic"; break;
- case 0x10de: case 0x12d2:
- {
- int idx = 0;
+ int idx = 0;
+
#ifdef __linux__
- driverList[idx++] = "nouveau";
+ driverList[idx++] = "nouveau";
#endif
- driverList[idx++] = "nv";
- break;
- }
- case 0x1106: driverList[0] = "openchrome"; break;
- case 0x1b36: driverList[0] = "qxl"; break;
- case 0x1163: driverList[0] = "rendition"; break;
- case 0x5333:
- switch (dev->device_id)
- {
- case 0x88d0: case 0x88d1: case 0x88f0: case 0x8811:
- case 0x8812: case 0x8814: case 0x8901:
- driverList[0] = "s3"; break;
- case 0x5631: case 0x883d: case 0x8a01: case 0x8a10:
- case 0x8c01: case 0x8c03: case 0x8904: case 0x8a13:
- driverList[0] = "s3virge"; break;
- default:
- driverList[0] = "savage"; break;
- }
- break;
- case 0x1039: driverList[0] = "sis"; break;
- case 0x126f: driverList[0] = "siliconmotion"; break;
- case 0x121a:
- if (dev->device_id < 0x0003)
- driverList[0] = "voodoo";
- else
- driverList[0] = "tdfx";
- break;
- case 0x1011: driverList[0] = "tga"; break;
- case 0x1023: driverList[0] = "trident"; break;
- case 0x100c: driverList[0] = "tseng"; break;
- case 0x80ee: driverList[0] = "vboxvideo"; break;
- case 0x15ad: driverList[0] = "vmware"; break;
- case 0x18ca:
- if (dev->device_id == 0x47)
- driverList[0] = "xgixp";
- else
- driverList[0] = "xgi";
- break;
- default: break;
+ driverList[idx++] = "nv";
+ break;
+ }
+ case 0x1106:
+ driverList[0] = "openchrome";
+ break;
+ case 0x1b36:
+ driverList[0] = "qxl";
+ break;
+ case 0x1163:
+ driverList[0] = "rendition";
+ break;
+ case 0x5333:
+ switch (dev->device_id) {
+ case 0x88d0:
+ case 0x88d1:
+ case 0x88f0:
+ case 0x8811:
+ case 0x8812:
+ case 0x8814:
+ case 0x8901:
+ driverList[0] = "s3";
+ break;
+ case 0x5631:
+ case 0x883d:
+ case 0x8a01:
+ case 0x8a10:
+ case 0x8c01:
+ case 0x8c03:
+ case 0x8904:
+ case 0x8a13:
+ driverList[0] = "s3virge";
+ break;
+ default:
+ driverList[0] = "savage";
+ break;
+ }
+ break;
+ case 0x1039:
+ driverList[0] = "sis";
+ break;
+ case 0x126f:
+ driverList[0] = "siliconmotion";
+ break;
+ case 0x121a:
+ if (dev->device_id < 0x0003)
+ driverList[0] = "voodoo";
+ else
+ driverList[0] = "tdfx";
+ break;
+ case 0x1011:
+ driverList[0] = "tga";
+ break;
+ case 0x1023:
+ driverList[0] = "trident";
+ break;
+ case 0x100c:
+ driverList[0] = "tseng";
+ break;
+ case 0x80ee:
+ driverList[0] = "vboxvideo";
+ break;
+ case 0x15ad:
+ driverList[0] = "vmware";
+ break;
+ case 0x18ca:
+ if (dev->device_id == 0x47)
+ driverList[0] = "xgixp";
+ else
+ driverList[0] = "xgi";
+ break;
+ default:
+ break;
}
for (i = 0; (i < returnListMax) && (driverList[i] != NULL); i++) {
- returnList[i] = xnfstrdup(driverList[i]);
+ returnList[i] = xnfstrdup(driverList[i]);
}
- return i; /* Number of entries added */
+ return i; /* Number of entries added */
}
#ifdef __linux__
@@ -1181,7 +1248,7 @@ xchomp(char *line)
* feature it can and should be removed because the symbol-based resolution
* scheme should be the primary one */
static void
-matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip)
+matchDriverFromFiles(char **matches, uint16_t match_vendor, uint16_t match_chip)
{
DIR *idsdir;
FILE *fp;
@@ -1197,7 +1264,9 @@ matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip
if (!idsdir)
return;
- xf86Msg(X_INFO, "Scanning %s directory for additional PCI ID's supported by the drivers\n", PCI_TXT_IDS_PATH);
+ xf86Msg(X_INFO,
+ "Scanning %s directory for additional PCI ID's supported by the drivers\n",
+ PCI_TXT_IDS_PATH);
direntry = readdir(idsdir);
/* Read the directory */
while (direntry) {
@@ -1207,63 +1276,72 @@ matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip
}
len = strlen(direntry->d_name);
/* A tiny bit of sanity checking. We should probably do better */
- if (strncmp(&(direntry->d_name[len-4]), ".ids", 4) == 0) {
+ if (strncmp(&(direntry->d_name[len - 4]), ".ids", 4) == 0) {
/* We need the full path name to open the file */
snprintf(path_name, sizeof(path_name), "%s/%s",
PCI_TXT_IDS_PATH, direntry->d_name);
fp = fopen(path_name, "r");
if (fp == NULL) {
- xf86Msg(X_ERROR, "Could not open %s for reading. Exiting.\n", path_name);
+ xf86Msg(X_ERROR, "Could not open %s for reading. Exiting.\n",
+ path_name);
goto end;
}
/* Read the file */
#ifdef __GLIBC__
while ((read = getline(&line, &len, fp)) != -1) {
#else
- while ((line = fgetln(fp, &len)) != (char *)NULL) {
-#endif /* __GLIBC __ */
+ while ((line = fgetln(fp, &len)) != (char *) NULL) {
+#endif /* __GLIBC __ */
xchomp(line);
if (isdigit(line[0])) {
strlcpy(vendor_str, line, sizeof(vendor_str));
- vendor = (int)strtol(vendor_str, NULL, 16);
+ vendor = (int) strtol(vendor_str, NULL, 16);
if ((strlen(&line[4])) == 0) {
chip_str[0] = '\0';
chip = -1;
- } else {
+ }
+ else {
/* Handle trailing whitespace */
if (isspace(line[4])) {
chip_str[0] = '\0';
chip = -1;
- } else {
+ }
+ else {
/* Ok, it's a real ID */
strlcpy(chip_str, &line[4], sizeof(chip_str));
- chip = (int)strtol(chip_str, NULL, 16);
+ chip = (int) strtol(chip_str, NULL, 16);
}
}
- if (vendor == match_vendor && chip == match_chip ) {
+ if (vendor == match_vendor && chip == match_chip) {
i = 0;
while (matches[i]) {
i++;
}
- matches[i] = (char*)malloc(sizeof(char) * strlen(direntry->d_name) - 3);
+ matches[i] =
+ (char *) malloc(sizeof(char) *
+ strlen(direntry->d_name) - 3);
if (!matches[i]) {
- xf86Msg(X_ERROR, "Could not allocate space for the module name. Exiting.\n");
+ xf86Msg(X_ERROR,
+ "Could not allocate space for the module name. Exiting.\n");
goto end;
}
/* hack off the .ids suffix. This should guard
* against other problems, but it will end up
* taking off anything after the first '.' */
- for (j = 0; j < (strlen(direntry->d_name) - 3) ; j++) {
+ for (j = 0; j < (strlen(direntry->d_name) - 3); j++) {
if (direntry->d_name[j] == '.') {
matches[i][j] = '\0';
break;
- } else {
+ }
+ else {
matches[i][j] = direntry->d_name[j];
}
}
- xf86Msg(X_INFO, "Matched %s from file name %s\n", matches[i], direntry->d_name);
+ xf86Msg(X_INFO, "Matched %s from file name %s\n",
+ matches[i], direntry->d_name);
}
- } else {
+ }
+ else {
/* TODO Handle driver overrides here */
}
}
@@ -1275,38 +1353,39 @@ matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip
free(line);
closedir(idsdir);
}
-#endif /* __linux__ */
+#endif /* __linux__ */
/**
* @return The numbers of found devices that match with the current system
* drivers.
*/
int
-xf86PciMatchDriver(char* matches[], int nmatches) {
+xf86PciMatchDriver(char *matches[], int nmatches)
+{
int i;
- struct pci_device * info = NULL;
+ struct pci_device *info = NULL;
struct pci_device_iterator *iter;
/* Find the primary device, and get some information about it. */
iter = pci_slot_match_iterator_create(NULL);
while ((info = pci_device_next(iter)) != NULL) {
- if (xf86IsPrimaryPci(info)) {
- break;
- }
+ if (xf86IsPrimaryPci(info)) {
+ break;
+ }
}
pci_iterator_destroy(iter);
#ifdef __linux__
if (info)
- matchDriverFromFiles(matches, info->vendor_id, info->device_id);
+ matchDriverFromFiles(matches, info->vendor_id, info->device_id);
#endif
for (i = 0; (i < nmatches) && (matches[i]); i++) {
- /* find end of matches list */
+ /* find end of matches list */
}
if ((info != NULL) && (i < nmatches)) {
- i += videoPtrToDriverList(info, &(matches[i]), nmatches - i);
+ i += videoPtrToDriverList(info, &(matches[i]), nmatches - i);
}
return i;
@@ -1315,14 +1394,13 @@ xf86PciMatchDriver(char* matches[], int nmatches) {
Bool
xf86PciConfigure(void *busData, struct pci_device *pDev)
{
- struct pci_device * pVideo = NULL;
+ struct pci_device *pVideo = NULL;
pVideo = (struct pci_device *) busData;
if (pDev &&
(pDev->domain == pVideo->domain) &&
(pDev->bus == pVideo->bus) &&
- (pDev->dev == pVideo->dev) &&
- (pDev->func == pVideo->func))
+ (pDev->dev == pVideo->dev) && (pDev->func == pVideo->func))
return 0;
return 1;
@@ -1330,20 +1408,20 @@ xf86PciConfigure(void *busData, struct pci_device *pDev)
void
xf86PciConfigureNewDev(void *busData, struct pci_device *pVideo,
- GDevRec *GDev, int *chipset)
+ GDevRec * GDev, int *chipset)
{
char busnum[8];
pVideo = (struct pci_device *) busData;
if (pVideo->bus < 256)
- snprintf(busnum, sizeof(busnum), "%d", pVideo->bus);
+ snprintf(busnum, sizeof(busnum), "%d", pVideo->bus);
else
- snprintf(busnum, sizeof(busnum), "%d@%d",
- pVideo->bus & 0x00ff, pVideo->bus >> 8);
+ snprintf(busnum, sizeof(busnum), "%d@%d",
+ pVideo->bus & 0x00ff, pVideo->bus >> 8);
XNFasprintf(&GDev->busID, "PCI:%s:%d:%d",
- busnum, pVideo->dev, pVideo->func);
+ busnum, pVideo->dev, pVideo->func);
GDev->chipID = pVideo->device_id;
GDev->chipRev = pVideo->revision;
diff --git a/xorg-server/hw/xfree86/common/xf86sbusBus.c b/xorg-server/hw/xfree86/common/xf86sbusBus.c
index b7bb913fe..c993b603c 100644
--- a/xorg-server/hw/xfree86/common/xf86sbusBus.c
+++ b/xorg-server/hw/xfree86/common/xf86sbusBus.c
@@ -53,23 +53,24 @@ CheckSbusDevice(const char *device, int fbNum)
fd = open(device, O_RDONLY, 0);
if (fd < 0)
- return;
+ return;
memset(&fbattr, 0, sizeof(fbattr));
if (ioctl(fd, FBIOGATTR, &fbattr) < 0) {
- if (ioctl(fd, FBIOGTYPE, &fbattr.fbtype) < 0) {
- close(fd);
- return;
- }
+ 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));
+ 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);
+ xf86SbusInfo[xf86nSbusInfo - 1] = psdp = xnfcalloc(sizeof(sbusDevice), 1);
psdp->devId = sbusDeviceTable[i].devId;
psdp->fbNum = fbNum;
psdp->device = xnfstrdup(device);
@@ -88,136 +89,154 @@ xf86SbusProbe(void)
xf86SbusInfo = malloc(sizeof(psdp));
*xf86SbusInfo = NULL;
for (i = 0; i < 32; i++) {
- snprintf(fbDevName, sizeof(fbDevName), "/dev/fb%d", i);
- CheckSbusDevice(fbDevName, i);
+ snprintf(fbDevName, sizeof(fbDevName), "/dev/fb%d", i);
+ CheckSbusDevice(fbDevName, i);
}
if (sparcPromInit() >= 0) {
- useProm = 1;
- sparcPromAssignNodes();
+ useProm = 1;
+ sparcPromAssignNodes();
}
for (psdpp = xf86SbusInfo; (psdp = *psdpp); psdpp++) {
- for (i = 0; sbusDeviceTable[i].devId; i++)
- if (sbusDeviceTable[i].devId == psdp->devId)
- psdp->descr = sbusDeviceTable[i].descr;
- /*
- * If we can use PROM information and found the PROM node for this
- * device, we can tell more about the card.
- */
- if (useProm && psdp->node.node) {
- char *prop, *promPath;
- int len, chiprev, vmsize;
-
- switch (psdp->devId) {
- case SBUS_DEVICE_MGX:
- prop = sparcPromGetProperty(&psdp->node, "fb_size", &len);
- if (prop && len == 4 && *(int *)prop == 0x400000)
- psdp->descr = "Quantum 3D MGXplus with 4M VRAM";
- break;
- case SBUS_DEVICE_CG6:
- chiprev = 0;
- vmsize = 0;
- prop = sparcPromGetProperty(&psdp->node, "chiprev", &len);
- if (prop && len == 4)
- chiprev = *(int *)prop;
- prop = sparcPromGetProperty(&psdp->node, "vmsize", &len);
- if (prop && len == 4)
- vmsize = *(int *)prop;
- switch (chiprev) {
- case 1:
- case 2:
- case 3:
- case 4:
- psdp->descr = "Sun Double width GX"; break;
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- psdp->descr = "Sun Single width GX"; break;
- case 11:
- switch (vmsize) {
- case 2:
- psdp->descr = "Sun Turbo GX with 1M VSIMM"; break;
- case 4:
- psdp->descr = "Sun Turbo GX Plus"; break;
- default:
- psdp->descr = "Sun Turbo GX"; break;
- }
- }
- break;
- case SBUS_DEVICE_CG14:
- prop = sparcPromGetProperty(&psdp->node, "reg", &len);
- vmsize = 0;
- if (prop && !(len % 12) && len > 0)
- vmsize = *(int *)(prop + len - 4);
- switch (vmsize) {
- case 0x400000:
- psdp->descr = "Sun SX with 4M VSIMM"; break;
- case 0x800000:
- psdp->descr = "Sun SX with 8M VSIMM"; break;
- }
- break;
- case SBUS_DEVICE_LEO:
- prop = sparcPromGetProperty(&psdp->node, "model", &len);
- if (prop && len > 0 && !strstr(prop, "501-2503"))
- psdp->descr = "Sun Turbo ZX";
- break;
- case SBUS_DEVICE_TCX:
- if (sparcPromGetBool(&psdp->node, "tcx-8-bit"))
- psdp->descr = "Sun TCX (8bit)";
- else
- psdp->descr = "Sun TCX (S24)";
- break;
- case SBUS_DEVICE_FFB:
- prop = sparcPromGetProperty(&psdp->node, "name", &len);
- chiprev = 0;
- prop = sparcPromGetProperty(&psdp->node, "board_type", &len);
- if (prop && len == 4)
- chiprev = *(int *)prop;
- if (strstr (prop, "afb")) {
- if (chiprev == 3)
- psdp->descr = "Sun|Elite3D-M6 Horizontal";
- } else {
- switch (chiprev) {
- case 0x08:
- psdp->descr = "Sun FFB 67MHz Creator"; break;
- case 0x0b:
- psdp->descr = "Sun FFB 67MHz Creator 3D"; break;
- case 0x1b:
- psdp->descr = "Sun FFB 75MHz Creator 3D"; break;
- case 0x20:
- case 0x28:
- psdp->descr = "Sun FFB2 Vertical Creator"; break;
- case 0x23:
- case 0x2b:
- psdp->descr = "Sun FFB2 Vertical Creator 3D"; break;
- case 0x30:
- psdp->descr = "Sun FFB2+ Vertical Creator"; break;
- case 0x33:
- psdp->descr = "Sun FFB2+ Vertical Creator 3D"; break;
- case 0x40:
- case 0x48:
- psdp->descr = "Sun FFB2 Horizontal Creator"; break;
- case 0x43:
- case 0x4b:
- psdp->descr = "Sun FFB2 Horizontal Creator 3D"; break;
- }
- }
- break;
- }
-
- xf86Msg(X_PROBED, "SBUS:(0x%08x) %s", psdp->node.node, psdp->descr);
- promPath = sparcPromNode2Pathname (&psdp->node);
- if (promPath) {
- xf86ErrorF(" at %s", promPath);
- free(promPath);
- }
- } else
- xf86Msg(X_PROBED, "SBUS: %s", psdp->descr);
- xf86ErrorF("\n");
+ for (i = 0; sbusDeviceTable[i].devId; i++)
+ if (sbusDeviceTable[i].devId == psdp->devId)
+ psdp->descr = sbusDeviceTable[i].descr;
+ /*
+ * If we can use PROM information and found the PROM node for this
+ * device, we can tell more about the card.
+ */
+ if (useProm && psdp->node.node) {
+ char *prop, *promPath;
+ int len, chiprev, vmsize;
+
+ switch (psdp->devId) {
+ case SBUS_DEVICE_MGX:
+ prop = sparcPromGetProperty(&psdp->node, "fb_size", &len);
+ if (prop && len == 4 && *(int *) prop == 0x400000)
+ psdp->descr = "Quantum 3D MGXplus with 4M VRAM";
+ break;
+ case SBUS_DEVICE_CG6:
+ chiprev = 0;
+ vmsize = 0;
+ prop = sparcPromGetProperty(&psdp->node, "chiprev", &len);
+ if (prop && len == 4)
+ chiprev = *(int *) prop;
+ prop = sparcPromGetProperty(&psdp->node, "vmsize", &len);
+ if (prop && len == 4)
+ vmsize = *(int *) prop;
+ switch (chiprev) {
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ psdp->descr = "Sun Double width GX";
+ break;
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ psdp->descr = "Sun Single width GX";
+ break;
+ case 11:
+ switch (vmsize) {
+ case 2:
+ psdp->descr = "Sun Turbo GX with 1M VSIMM";
+ break;
+ case 4:
+ psdp->descr = "Sun Turbo GX Plus";
+ break;
+ default:
+ psdp->descr = "Sun Turbo GX";
+ break;
+ }
+ }
+ break;
+ case SBUS_DEVICE_CG14:
+ prop = sparcPromGetProperty(&psdp->node, "reg", &len);
+ vmsize = 0;
+ if (prop && !(len % 12) && len > 0)
+ vmsize = *(int *) (prop + len - 4);
+ switch (vmsize) {
+ case 0x400000:
+ psdp->descr = "Sun SX with 4M VSIMM";
+ break;
+ case 0x800000:
+ psdp->descr = "Sun SX with 8M VSIMM";
+ break;
+ }
+ break;
+ case SBUS_DEVICE_LEO:
+ prop = sparcPromGetProperty(&psdp->node, "model", &len);
+ if (prop && len > 0 && !strstr(prop, "501-2503"))
+ psdp->descr = "Sun Turbo ZX";
+ break;
+ case SBUS_DEVICE_TCX:
+ if (sparcPromGetBool(&psdp->node, "tcx-8-bit"))
+ psdp->descr = "Sun TCX (8bit)";
+ else
+ psdp->descr = "Sun TCX (S24)";
+ break;
+ case SBUS_DEVICE_FFB:
+ prop = sparcPromGetProperty(&psdp->node, "name", &len);
+ chiprev = 0;
+ prop = sparcPromGetProperty(&psdp->node, "board_type", &len);
+ if (prop && len == 4)
+ chiprev = *(int *) prop;
+ if (strstr(prop, "afb")) {
+ if (chiprev == 3)
+ psdp->descr = "Sun|Elite3D-M6 Horizontal";
+ }
+ else {
+ switch (chiprev) {
+ case 0x08:
+ psdp->descr = "Sun FFB 67MHz Creator";
+ break;
+ case 0x0b:
+ psdp->descr = "Sun FFB 67MHz Creator 3D";
+ break;
+ case 0x1b:
+ psdp->descr = "Sun FFB 75MHz Creator 3D";
+ break;
+ case 0x20:
+ case 0x28:
+ psdp->descr = "Sun FFB2 Vertical Creator";
+ break;
+ case 0x23:
+ case 0x2b:
+ psdp->descr = "Sun FFB2 Vertical Creator 3D";
+ break;
+ case 0x30:
+ psdp->descr = "Sun FFB2+ Vertical Creator";
+ break;
+ case 0x33:
+ psdp->descr = "Sun FFB2+ Vertical Creator 3D";
+ break;
+ case 0x40:
+ case 0x48:
+ psdp->descr = "Sun FFB2 Horizontal Creator";
+ break;
+ case 0x43:
+ case 0x4b:
+ psdp->descr = "Sun FFB2 Horizontal Creator 3D";
+ break;
+ }
+ }
+ break;
+ }
+
+ xf86Msg(X_PROBED, "SBUS:(0x%08x) %s", psdp->node.node, psdp->descr);
+ promPath = sparcPromNode2Pathname(&psdp->node);
+ if (promPath) {
+ xf86ErrorF(" at %s", promPath);
+ free(promPath);
+ }
+ }
+ else
+ xf86Msg(X_PROBED, "SBUS: %s", psdp->descr);
+ xf86ErrorF("\n");
}
if (useProm)
- sparcPromClose();
+ sparcPromClose();
}
/*
@@ -240,52 +259,55 @@ xf86ParseSbusBusString(const char *busID, int *fbNum)
int i, len;
if (StringToBusType(busID, &id) != BUS_SBUS)
- return FALSE;
+ 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 (!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;
- }
- }
- }
+ 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;
}
@@ -300,9 +322,10 @@ xf86CompareSbusBusString(const char *busID, int fbNum)
int iFbNum;
if (xf86ParseSbusBusString(busID, &iFbNum)) {
- return fbNum == iFbNum;
- } else {
- return FALSE;
+ return fbNum == iFbNum;
+ }
+ else {
+ return FALSE;
}
}
@@ -317,10 +340,10 @@ xf86CheckSbusSlot(int fbNum)
EntityPtr p;
for (i = 0; i < xf86NumEntities; i++) {
- p = xf86Entities[i];
- /* Check if this SBUS slot is taken */
- if (p->bus.type == BUS_SBUS && p->bus.id.sbus.fbNum == fbNum)
- return FALSE;
+ p = xf86Entities[i];
+ /* Check if this SBUS slot is taken */
+ if (p->bus.type == BUS_SBUS && p->bus.id.sbus.fbNum == fbNum)
+ return FALSE;
}
return TRUE;
@@ -332,8 +355,7 @@ xf86CheckSbusSlot(int fbNum)
*/
int
-xf86ClaimSbusSlot(sbusDevicePtr psdp, DriverPtr drvp,
- GDevPtr dev, Bool active)
+xf86ClaimSbusSlot(sbusDevicePtr psdp, DriverPtr drvp, GDevPtr dev, Bool active)
{
EntityPtr p = NULL;
@@ -349,18 +371,19 @@ xf86ClaimSbusSlot(sbusDevicePtr psdp, DriverPtr drvp,
p->bus.id.sbus.fbNum = psdp->fbNum;
p->active = active;
p->inUse = FALSE;
- sbusSlotClaimed = TRUE;
- return num;
- } else
- return -1;
+ sbusSlotClaimed = TRUE;
+ return num;
+ }
+ else
+ return -1;
}
int
-xf86MatchSbusInstances(const char *driverName, int sbusDevId,
- GDevPtr *devList, int numDevs, DriverPtr drvp,
- int **foundEntities)
+xf86MatchSbusInstances(const char *driverName, int sbusDevId,
+ GDevPtr * devList, int numDevs, DriverPtr drvp,
+ int **foundEntities)
{
- int i,j;
+ int i, j;
sbusDevicePtr psdp, *psdpp;
int numClaimedInstances = 0;
int allocatedInstances = 0;
@@ -371,24 +394,24 @@ xf86MatchSbusInstances(const char *driverName, int sbusDevId,
int useProm = 0;
struct Inst {
- sbusDevicePtr sbus;
- GDevPtr dev;
- Bool claimed; /* BusID matches with a device section */
+ 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++;
+ 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++;
}
/*
@@ -397,88 +420,97 @@ xf86MatchSbusInstances(const char *driverName, int sbusDevId,
* allow the config file to override this.
*/
if (allocatedInstances <= 0) {
- free(instances);
- return 0;
+ free(instances);
+ return 0;
}
if (sparcPromInit() >= 0)
- useProm = 1;
+ useProm = 1;
if (xf86DoConfigure && xf86DoConfigurePass1) {
- GDevPtr pGDev;
- int actualcards = 0;
- for (i = 0; i < allocatedInstances; i++) {
- actualcards++;
- pGDev = xf86AddBusDeviceToConfigure(drvp->driverName, BUS_SBUS,
- instances[i].sbus, -1);
- if (pGDev) {
- /*
- * XF86Match???Instances() treat chipID and chipRev as
- * overrides, so clobber them here.
- */
- pGDev->chipID = pGDev->chipRev = -1;
- }
- }
- free(instances);
- if (useProm)
- sparcPromClose();
- return actualcards;
+ GDevPtr pGDev;
+ int actualcards = 0;
+
+ for (i = 0; i < allocatedInstances; i++) {
+ actualcards++;
+ pGDev = xf86AddBusDeviceToConfigure(drvp->driverName, BUS_SBUS,
+ instances[i].sbus, -1);
+ if (pGDev) {
+ /*
+ * XF86Match???Instances() treat chipID and chipRev as
+ * overrides, so clobber them here.
+ */
+ pGDev->chipID = pGDev->chipRev = -1;
+ }
+ }
+ free(instances);
+ if (useProm)
+ sparcPromClose();
+ return actualcards;
}
DebugF("%s instances found: %d\n", driverName, allocatedInstances);
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;
- }
- free(promPath);
+ 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;
+ }
+ free(promPath);
}
DebugF("%s instances found: %d\n", driverName, numClaimedInstances);
@@ -489,29 +521,29 @@ xf86MatchSbusInstances(const char *driverName, int sbusDevId,
*/
numFound = 0;
for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) {
- if (!instances[i].claimed)
- continue;
- psdp = instances[i].sbus;
- if (!xf86CheckSbusSlot(psdp->fbNum))
- continue;
-
- DebugF("%s: card at fb%d %08x is claimed by a Device section\n",
- driverName, psdp->fbNum, psdp->node.node);
-
- /* 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);
+ if (!instances[i].claimed)
+ continue;
+ psdp = instances[i].sbus;
+ if (!xf86CheckSbusSlot(psdp->fbNum))
+ continue;
+
+ DebugF("%s: card at fb%d %08x is claimed by a Device section\n",
+ driverName, psdp->fbNum, psdp->node.node);
+
+ /* 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);
}
free(instances);
if (numFound > 0) {
- *foundEntities = retEntities;
+ *foundEntities = retEntities;
}
if (useProm)
- sparcPromClose();
+ sparcPromClose();
return numFound;
}
@@ -525,12 +557,12 @@ xf86GetSbusInfoForEntity(int entityIndex)
sbusDevicePtr *psdpp;
EntityPtr p = xf86Entities[entityIndex];
- if (entityIndex >= xf86NumEntities
- || p->bus.type != BUS_SBUS) return NULL;
+ if (entityIndex >= xf86NumEntities || p->bus.type != BUS_SBUS)
+ return NULL;
for (psdpp = xf86SbusInfo; *psdpp != NULL; psdpp++) {
- if (p->bus.id.sbus.fbNum == (*psdpp)->fbNum)
- return *psdpp;
+ if (p->bus.id.sbus.fbNum == (*psdpp)->fbNum)
+ return *psdpp;
}
return NULL;
}
@@ -541,11 +573,13 @@ xf86GetEntityForSbusInfo(sbusDevicePtr psdp)
int i;
for (i = 0; i < xf86NumEntities; i++) {
- EntityPtr p = xf86Entities[i];
- if (p->bus.type != BUS_SBUS) continue;
+ EntityPtr p = xf86Entities[i];
- if (p->bus.id.sbus.fbNum == psdp->fbNum)
- return i;
+ if (p->bus.type != BUS_SBUS)
+ continue;
+
+ if (p->bus.id.sbus.fbNum == psdp->fbNum)
+ return i;
}
return -1;
}
@@ -601,32 +635,33 @@ typedef struct _sbusCmap {
static void
xf86SbusCmapLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
- LOCO *colors, VisualPtr pVisual)
+ LOCO * colors, VisualPtr pVisual)
{
int i, index;
sbusCmapPtr cmap;
struct fbcmap fbcmap;
- unsigned char *data = malloc(numColors*3);
-
+ unsigned char *data = malloc(numColors * 3);
+
cmap = SBUSCMAPPTR(pScrn->pScreen);
- if (!cmap) return;
+ 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;
+ 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);
+ ioctl(cmap->psdp->fd, FBIOPUTCMAP, &fbcmap);
free(data);
}
@@ -635,20 +670,20 @@ 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);
+ 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;
free(cmap);
return (*pScreen->CloseScreen) (i, pScreen);
-}
+}
Bool
xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp)
@@ -665,25 +700,26 @@ xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp)
fbcmap.red = cmap->origRed;
fbcmap.green = cmap->origGreen;
fbcmap.blue = cmap->origBlue;
- if (ioctl (psdp->fd, FBIOGETCMAP, &fbcmap) >= 0)
- cmap->origCmapValid = TRUE;
+ 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;
+ data[0] = 255;
+ data[1] = 0;
+ }
+ else {
+ data[0] = 0;
+ data[1] = 255;
}
- ioctl (psdp->fd, FBIOPUTCMAP, &fbcmap);
+ ioctl(psdp->fd, FBIOPUTCMAP, &fbcmap);
cmap->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = xf86SbusCmapCloseScreen;
return xf86HandleColormaps(pScreen, 256, 8,
- xf86SbusCmapLoadPalette, NULL, 0);
+ xf86SbusCmapLoadPalette, NULL, 0);
}
Bool
@@ -695,7 +731,7 @@ xf86SbusConfigure(void *busData, sbusDevicePtr sBus)
}
void
-xf86SbusConfigureNewDev(void *busData, sbusDevicePtr sBus, GDevRec *GDev)
+xf86SbusConfigureNewDev(void *busData, sbusDevicePtr sBus, GDevRec * GDev)
{
char *promPath = NULL;
@@ -708,7 +744,8 @@ xf86SbusConfigureNewDev(void *busData, sbusDevicePtr sBus, GDevRec *GDev)
if (promPath) {
XNFasprintf(&GDev->busID, "SBUS:%s", promPath);
free(promPath);
- } else {
+ }
+ else {
XNFasprintf(&GDev->busID, "SBUS:fb%d", sBus->fbNum);
}
}
diff --git a/xorg-server/hw/xfree86/common/xf86sbusBus.h b/xorg-server/hw/xfree86/common/xf86sbusBus.h
index e210770db..a4d9c6cde 100644
--- a/xorg-server/hw/xfree86/common/xf86sbusBus.h
+++ b/xorg-server/hw/xfree86/common/xf86sbusBus.h
@@ -1,104 +1,111 @@
-/*
- * SBUS bus-specific declarations
- *
- * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef _XF86_SBUSBUS_H
-#define _XF86_SBUSBUS_H
-
-#include "xf86str.h"
-
-#define SBUS_DEVICE_BW2 0x0001
-#define SBUS_DEVICE_CG2 0x0002
-#define SBUS_DEVICE_CG3 0x0003
-#define SBUS_DEVICE_CG4 0x0004
-#define SBUS_DEVICE_CG6 0x0005
-#define SBUS_DEVICE_CG8 0x0006
-#define SBUS_DEVICE_CG12 0x0007
-#define SBUS_DEVICE_CG14 0x0008
-#define SBUS_DEVICE_LEO 0x0009
-#define SBUS_DEVICE_TCX 0x000a
-#define SBUS_DEVICE_FFB 0x000b
-#define SBUS_DEVICE_GT 0x000c
-#define SBUS_DEVICE_MGX 0x000d
-
-typedef struct sbus_prom_node {
- int node;
- /* Because of misdesigned openpromio */
- int cookie[2];
-} sbusPromNode, *sbusPromNodePtr;
-
-typedef struct sbus_device {
- int devId;
- int fbNum;
- int fd;
- int width, height;
- sbusPromNode node;
- char *descr;
- char *device;
-} sbusDevice, *sbusDevicePtr;
-
-struct sbus_devtable {
- int devId;
- int fbType;
- char *promName;
- char *driverName;
- char *descr;
-};
-
-extern _X_EXPORT void xf86SbusProbe(void);
-extern _X_EXPORT sbusDevicePtr *xf86SbusInfo;
-extern _X_EXPORT struct sbus_devtable sbusDeviceTable[];
-
-extern _X_EXPORT int xf86MatchSbusInstances(const char *driverName, int sbusDevId,
- GDevPtr *devList, int numDevs, DriverPtr drvp,
- int **foundEntities);
-extern _X_EXPORT sbusDevicePtr xf86GetSbusInfoForEntity(int entityIndex);
-extern _X_EXPORT int xf86GetEntityForSbusInfo(sbusDevicePtr psdp);
-extern _X_EXPORT void xf86SbusUseBuiltinMode(ScrnInfoPtr pScrn, sbusDevicePtr psdp);
-extern _X_EXPORT pointer xf86MapSbusMem(sbusDevicePtr psdp, unsigned long offset,
- unsigned long size);
-extern _X_EXPORT void xf86UnmapSbusMem(sbusDevicePtr psdp, pointer addr, unsigned long size);
-extern _X_EXPORT void xf86SbusHideOsHwCursor(sbusDevicePtr psdp);
-extern _X_EXPORT void xf86SbusSetOsHwCursorCmap(sbusDevicePtr psdp, int bg, int fg);
-extern _X_EXPORT Bool xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp);
-
-extern _X_EXPORT int promRootNode;
-
-extern _X_EXPORT int promGetSibling(int node);
-extern _X_EXPORT int promGetChild(int node);
-extern _X_EXPORT char * promGetProperty(const char *prop, int *lenp);
-extern _X_EXPORT int promGetBool(const char *prop);
-
-extern _X_EXPORT int sparcPromInit(void);
-extern _X_EXPORT void sparcPromClose(void);
-extern _X_EXPORT char * sparcPromGetProperty(sbusPromNodePtr pnode, const char *prop, int *lenp);
-extern _X_EXPORT int sparcPromGetBool(sbusPromNodePtr pnode, const char *prop);
-extern _X_EXPORT void sparcPromAssignNodes(void);
-extern _X_EXPORT char * sparcPromNode2Pathname(sbusPromNodePtr pnode);
-extern _X_EXPORT int sparcPromPathname2Node(const char *pathName);
-extern _X_EXPORT char *sparcDriverName(void);
-
-extern Bool xf86SbusConfigure(void *busData, sbusDevicePtr sBus);
-extern void xf86SbusConfigureNewDev(void *busData, sbusDevicePtr sBus,
- GDevRec *GDev);
-
-#endif /* _XF86_SBUSBUS_H */
+/*
+ * SBUS bus-specific declarations
+ *
+ * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _XF86_SBUSBUS_H
+#define _XF86_SBUSBUS_H
+
+#include "xf86str.h"
+
+#define SBUS_DEVICE_BW2 0x0001
+#define SBUS_DEVICE_CG2 0x0002
+#define SBUS_DEVICE_CG3 0x0003
+#define SBUS_DEVICE_CG4 0x0004
+#define SBUS_DEVICE_CG6 0x0005
+#define SBUS_DEVICE_CG8 0x0006
+#define SBUS_DEVICE_CG12 0x0007
+#define SBUS_DEVICE_CG14 0x0008
+#define SBUS_DEVICE_LEO 0x0009
+#define SBUS_DEVICE_TCX 0x000a
+#define SBUS_DEVICE_FFB 0x000b
+#define SBUS_DEVICE_GT 0x000c
+#define SBUS_DEVICE_MGX 0x000d
+
+typedef struct sbus_prom_node {
+ int node;
+ /* Because of misdesigned openpromio */
+ int cookie[2];
+} sbusPromNode, *sbusPromNodePtr;
+
+typedef struct sbus_device {
+ int devId;
+ int fbNum;
+ int fd;
+ int width, height;
+ sbusPromNode node;
+ char *descr;
+ char *device;
+} sbusDevice, *sbusDevicePtr;
+
+struct sbus_devtable {
+ int devId;
+ int fbType;
+ char *promName;
+ char *driverName;
+ char *descr;
+};
+
+extern _X_EXPORT void xf86SbusProbe(void);
+extern _X_EXPORT sbusDevicePtr *xf86SbusInfo;
+extern _X_EXPORT struct sbus_devtable sbusDeviceTable[];
+
+extern _X_EXPORT int xf86MatchSbusInstances(const char *driverName,
+ int sbusDevId, GDevPtr * devList,
+ int numDevs, DriverPtr drvp,
+ int **foundEntities);
+extern _X_EXPORT sbusDevicePtr xf86GetSbusInfoForEntity(int entityIndex);
+extern _X_EXPORT int xf86GetEntityForSbusInfo(sbusDevicePtr psdp);
+extern _X_EXPORT void xf86SbusUseBuiltinMode(ScrnInfoPtr pScrn,
+ sbusDevicePtr psdp);
+extern _X_EXPORT pointer xf86MapSbusMem(sbusDevicePtr psdp,
+ unsigned long offset,
+ unsigned long size);
+extern _X_EXPORT void xf86UnmapSbusMem(sbusDevicePtr psdp, pointer addr,
+ unsigned long size);
+extern _X_EXPORT void xf86SbusHideOsHwCursor(sbusDevicePtr psdp);
+extern _X_EXPORT void xf86SbusSetOsHwCursorCmap(sbusDevicePtr psdp, int bg,
+ int fg);
+extern _X_EXPORT Bool xf86SbusHandleColormaps(ScreenPtr pScreen,
+ sbusDevicePtr psdp);
+
+extern _X_EXPORT int promRootNode;
+
+extern _X_EXPORT int promGetSibling(int node);
+extern _X_EXPORT int promGetChild(int node);
+extern _X_EXPORT char *promGetProperty(const char *prop, int *lenp);
+extern _X_EXPORT int promGetBool(const char *prop);
+
+extern _X_EXPORT int sparcPromInit(void);
+extern _X_EXPORT void sparcPromClose(void);
+extern _X_EXPORT char *sparcPromGetProperty(sbusPromNodePtr pnode,
+ const char *prop, int *lenp);
+extern _X_EXPORT int sparcPromGetBool(sbusPromNodePtr pnode, const char *prop);
+extern _X_EXPORT void sparcPromAssignNodes(void);
+extern _X_EXPORT char *sparcPromNode2Pathname(sbusPromNodePtr pnode);
+extern _X_EXPORT int sparcPromPathname2Node(const char *pathName);
+extern _X_EXPORT char *sparcDriverName(void);
+
+extern Bool xf86SbusConfigure(void *busData, sbusDevicePtr sBus);
+extern void xf86SbusConfigureNewDev(void *busData, sbusDevicePtr sBus,
+ GDevRec * GDev);
+
+#endif /* _XF86_SBUSBUS_H */
diff --git a/xorg-server/hw/xfree86/common/xf86str.h b/xorg-server/hw/xfree86/common/xf86str.h
index e2ca55875..6294845bc 100644
--- a/xorg-server/hw/xfree86/common/xf86str.h
+++ b/xorg-server/hw/xfree86/common/xf86str.h
@@ -55,139 +55,138 @@ typedef uint64_t memType;
typedef uintptr_t memType;
#endif
-
/* Video mode flags */
typedef enum {
- V_PHSYNC = 0x0001,
- V_NHSYNC = 0x0002,
- V_PVSYNC = 0x0004,
- V_NVSYNC = 0x0008,
- V_INTERLACE = 0x0010,
- V_DBLSCAN = 0x0020,
- V_CSYNC = 0x0040,
- V_PCSYNC = 0x0080,
- V_NCSYNC = 0x0100,
- V_HSKEW = 0x0200, /* hskew provided */
- V_BCAST = 0x0400,
- V_PIXMUX = 0x1000,
- V_DBLCLK = 0x2000,
- V_CLKDIV2 = 0x4000
+ V_PHSYNC = 0x0001,
+ V_NHSYNC = 0x0002,
+ V_PVSYNC = 0x0004,
+ V_NVSYNC = 0x0008,
+ V_INTERLACE = 0x0010,
+ V_DBLSCAN = 0x0020,
+ V_CSYNC = 0x0040,
+ V_PCSYNC = 0x0080,
+ V_NCSYNC = 0x0100,
+ V_HSKEW = 0x0200, /* hskew provided */
+ V_BCAST = 0x0400,
+ V_PIXMUX = 0x1000,
+ V_DBLCLK = 0x2000,
+ V_CLKDIV2 = 0x4000
} ModeFlags;
typedef enum {
- INTERLACE_HALVE_V = 0x0001 /* Halve V values for interlacing */
+ INTERLACE_HALVE_V = 0x0001 /* Halve V values for interlacing */
} CrtcAdjustFlags;
/* Flags passed to ChipValidMode() */
typedef enum {
MODECHECK_INITIAL = 0,
- MODECHECK_FINAL = 1
+ MODECHECK_FINAL = 1
} ModeCheckFlags;
/* These are possible return values for xf86CheckMode() and ValidMode() */
typedef enum {
- MODE_OK = 0, /* Mode OK */
- MODE_HSYNC, /* hsync out of range */
- MODE_VSYNC, /* vsync out of range */
- MODE_H_ILLEGAL, /* mode has illegal horizontal timings */
- MODE_V_ILLEGAL, /* mode has illegal horizontal timings */
- MODE_BAD_WIDTH, /* requires an unsupported linepitch */
- MODE_NOMODE, /* no mode with a maching name */
- MODE_NO_INTERLACE, /* interlaced mode not supported */
- MODE_NO_DBLESCAN, /* doublescan mode not supported */
- MODE_NO_VSCAN, /* multiscan mode not supported */
- MODE_MEM, /* insufficient video memory */
- MODE_VIRTUAL_X, /* mode width too large for specified virtual size */
- MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */
- MODE_MEM_VIRT, /* insufficient video memory given virtual size */
- MODE_NOCLOCK, /* no fixed clock available */
- MODE_CLOCK_HIGH, /* clock required is too high */
- MODE_CLOCK_LOW, /* clock required is too low */
- MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */
- MODE_BAD_HVALUE, /* horizontal timing was out of range */
- MODE_BAD_VVALUE, /* vertical timing was out of range */
- MODE_BAD_VSCAN, /* VScan value out of range */
- MODE_HSYNC_NARROW, /* horizontal sync too narrow */
- MODE_HSYNC_WIDE, /* horizontal sync too wide */
- MODE_HBLANK_NARROW, /* horizontal blanking too narrow */
- MODE_HBLANK_WIDE, /* horizontal blanking too wide */
- MODE_VSYNC_NARROW, /* vertical sync too narrow */
- MODE_VSYNC_WIDE, /* vertical sync too wide */
- MODE_VBLANK_NARROW, /* vertical blanking too narrow */
- MODE_VBLANK_WIDE, /* vertical blanking too wide */
- MODE_PANEL, /* exceeds panel dimensions */
- MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */
- MODE_ONE_WIDTH, /* only one width is supported */
- MODE_ONE_HEIGHT, /* only one height is supported */
- MODE_ONE_SIZE, /* only one resolution is supported */
- MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */
- MODE_BANDWIDTH, /* mode requires too much memory bandwidth */
- MODE_BAD = -2, /* unspecified reason */
- MODE_ERROR = -1 /* error condition */
+ MODE_OK = 0, /* Mode OK */
+ MODE_HSYNC, /* hsync out of range */
+ MODE_VSYNC, /* vsync out of range */
+ MODE_H_ILLEGAL, /* mode has illegal horizontal timings */
+ MODE_V_ILLEGAL, /* mode has illegal horizontal timings */
+ MODE_BAD_WIDTH, /* requires an unsupported linepitch */
+ MODE_NOMODE, /* no mode with a maching name */
+ MODE_NO_INTERLACE, /* interlaced mode not supported */
+ MODE_NO_DBLESCAN, /* doublescan mode not supported */
+ MODE_NO_VSCAN, /* multiscan mode not supported */
+ MODE_MEM, /* insufficient video memory */
+ MODE_VIRTUAL_X, /* mode width too large for specified virtual size */
+ MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */
+ MODE_MEM_VIRT, /* insufficient video memory given virtual size */
+ MODE_NOCLOCK, /* no fixed clock available */
+ MODE_CLOCK_HIGH, /* clock required is too high */
+ MODE_CLOCK_LOW, /* clock required is too low */
+ MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */
+ MODE_BAD_HVALUE, /* horizontal timing was out of range */
+ MODE_BAD_VVALUE, /* vertical timing was out of range */
+ MODE_BAD_VSCAN, /* VScan value out of range */
+ MODE_HSYNC_NARROW, /* horizontal sync too narrow */
+ MODE_HSYNC_WIDE, /* horizontal sync too wide */
+ MODE_HBLANK_NARROW, /* horizontal blanking too narrow */
+ MODE_HBLANK_WIDE, /* horizontal blanking too wide */
+ MODE_VSYNC_NARROW, /* vertical sync too narrow */
+ MODE_VSYNC_WIDE, /* vertical sync too wide */
+ MODE_VBLANK_NARROW, /* vertical blanking too narrow */
+ MODE_VBLANK_WIDE, /* vertical blanking too wide */
+ MODE_PANEL, /* exceeds panel dimensions */
+ MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */
+ MODE_ONE_WIDTH, /* only one width is supported */
+ MODE_ONE_HEIGHT, /* only one height is supported */
+ MODE_ONE_SIZE, /* only one resolution is supported */
+ MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */
+ MODE_BANDWIDTH, /* mode requires too much memory bandwidth */
+ MODE_BAD = -2, /* unspecified reason */
+ MODE_ERROR = -1 /* error condition */
} ModeStatus;
/*
* The mode sets are, from best to worst: USERDEF, DRIVER, and DEFAULT/BUILTIN.
* Preferred will bubble a mode to the top within a set.
*/
-# define M_T_BUILTIN 0x01 /* built-in mode */
-# define M_T_CLOCK_C (0x02 | M_T_BUILTIN) /* built-in mode - configure clock */
-# define M_T_CRTC_C (0x04 | M_T_BUILTIN) /* built-in mode - configure CRTC */
-# define M_T_CLOCK_CRTC_C (M_T_CLOCK_C | M_T_CRTC_C)
+#define M_T_BUILTIN 0x01 /* built-in mode */
+#define M_T_CLOCK_C (0x02 | M_T_BUILTIN) /* built-in mode - configure clock */
+#define M_T_CRTC_C (0x04 | M_T_BUILTIN) /* built-in mode - configure CRTC */
+#define M_T_CLOCK_CRTC_C (M_T_CLOCK_C | M_T_CRTC_C)
/* built-in mode - configure CRTC and clock */
-# define M_T_PREFERRED 0x08 /* preferred mode within a set */
-# define M_T_DEFAULT 0x10 /* (VESA) default modes */
-# define M_T_USERDEF 0x20 /* One of the modes from the config file */
-# define M_T_DRIVER 0x40 /* Supplied by the driver (EDID, etc) */
-# define M_T_USERPREF 0x80 /* mode preferred by the user config */
+#define M_T_PREFERRED 0x08 /* preferred mode within a set */
+#define M_T_DEFAULT 0x10 /* (VESA) default modes */
+#define M_T_USERDEF 0x20 /* One of the modes from the config file */
+#define M_T_DRIVER 0x40 /* Supplied by the driver (EDID, etc) */
+#define M_T_USERPREF 0x80 /* mode preferred by the user config */
/* Video mode */
typedef struct _DisplayModeRec {
- struct _DisplayModeRec * prev;
- struct _DisplayModeRec * next;
- char * name; /* identifier for the mode */
- ModeStatus status;
- int type;
+ struct _DisplayModeRec *prev;
+ struct _DisplayModeRec *next;
+ char *name; /* identifier for the mode */
+ ModeStatus status;
+ int type;
/* These are the values that the user sees/provides */
- int Clock; /* pixel clock freq (kHz) */
- int HDisplay; /* horizontal timing */
- int HSyncStart;
- int HSyncEnd;
- int HTotal;
- int HSkew;
- int VDisplay; /* vertical timing */
- int VSyncStart;
- int VSyncEnd;
- int VTotal;
- int VScan;
- int Flags;
-
- /* These are the values the hardware uses */
- int ClockIndex;
- int SynthClock; /* Actual clock freq to
- * be programmed (kHz) */
- int CrtcHDisplay;
- int CrtcHBlankStart;
- int CrtcHSyncStart;
- int CrtcHSyncEnd;
- int CrtcHBlankEnd;
- int CrtcHTotal;
- int CrtcHSkew;
- int CrtcVDisplay;
- int CrtcVBlankStart;
- int CrtcVSyncStart;
- int CrtcVSyncEnd;
- int CrtcVBlankEnd;
- int CrtcVTotal;
- Bool CrtcHAdjusted;
- Bool CrtcVAdjusted;
- int PrivSize;
- INT32 * Private;
- int PrivFlags;
-
- float HSync, VRefresh;
+ int Clock; /* pixel clock freq (kHz) */
+ int HDisplay; /* horizontal timing */
+ int HSyncStart;
+ int HSyncEnd;
+ int HTotal;
+ int HSkew;
+ int VDisplay; /* vertical timing */
+ int VSyncStart;
+ int VSyncEnd;
+ int VTotal;
+ int VScan;
+ int Flags;
+
+ /* These are the values the hardware uses */
+ int ClockIndex;
+ int SynthClock; /* Actual clock freq to
+ * be programmed (kHz) */
+ int CrtcHDisplay;
+ int CrtcHBlankStart;
+ int CrtcHSyncStart;
+ int CrtcHSyncEnd;
+ int CrtcHBlankEnd;
+ int CrtcHTotal;
+ int CrtcHSkew;
+ int CrtcVDisplay;
+ int CrtcVBlankStart;
+ int CrtcVSyncStart;
+ int CrtcVSyncEnd;
+ int CrtcVBlankEnd;
+ int CrtcVTotal;
+ Bool CrtcHAdjusted;
+ Bool CrtcVAdjusted;
+ int PrivSize;
+ INT32 *Private;
+ int PrivFlags;
+
+ float HSync, VRefresh;
} DisplayModeRec, *DisplayModePtr;
/* The monitor description */
@@ -195,11 +194,17 @@ typedef struct _DisplayModeRec {
#define MAX_HSYNC 8
#define MAX_VREFRESH 8
-typedef struct { float hi, lo; } range;
+typedef struct {
+ float hi, lo;
+} range;
-typedef struct { CARD32 red, green, blue; } rgb;
+typedef struct {
+ CARD32 red, green, blue;
+} rgb;
-typedef struct { float red, green, blue; } Gamma;
+typedef struct {
+ float red, green, blue;
+} Gamma;
/* The permitted gamma range is 1 / GAMMA_MAX <= g <= GAMMA_MAX */
#define GAMMA_MAX 10.0
@@ -207,35 +212,35 @@ typedef struct { float red, green, blue; } Gamma;
#define GAMMA_ZERO (GAMMA_MIN / 100.0)
typedef struct {
- char * id;
- char * vendor;
- char * model;
- int nHsync;
- range hsync[MAX_HSYNC];
- int nVrefresh;
- range vrefresh[MAX_VREFRESH];
- DisplayModePtr Modes; /* Start of the monitor's mode list */
- DisplayModePtr Last; /* End of the monitor's mode list */
- Gamma gamma; /* Gamma of the monitor */
- int widthmm;
- int heightmm;
- pointer options;
- pointer DDC;
- Bool reducedblanking; /* Allow CVT reduced blanking modes? */
- int maxPixClock; /* in kHz, like mode->Clock */
+ char *id;
+ char *vendor;
+ char *model;
+ int nHsync;
+ range hsync[MAX_HSYNC];
+ int nVrefresh;
+ range vrefresh[MAX_VREFRESH];
+ DisplayModePtr Modes; /* Start of the monitor's mode list */
+ DisplayModePtr Last; /* End of the monitor's mode list */
+ Gamma gamma; /* Gamma of the monitor */
+ int widthmm;
+ int heightmm;
+ pointer options;
+ pointer DDC;
+ Bool reducedblanking; /* Allow CVT reduced blanking modes? */
+ int maxPixClock; /* in kHz, like mode->Clock */
} MonRec, *MonPtr;
/* the list of clock ranges */
typedef struct x_ClockRange {
struct x_ClockRange *next;
- int minClock; /* (kHz) */
- int maxClock; /* (kHz) */
- int clockIndex; /* -1 for programmable clocks */
- Bool interlaceAllowed;
- Bool doubleScanAllowed;
- int ClockMulFactor;
- int ClockDivFactor;
- int PrivFlags;
+ int minClock; /* (kHz) */
+ int maxClock; /* (kHz) */
+ int clockIndex; /* -1 for programmable clocks */
+ Bool interlaceAllowed;
+ Bool doubleScanAllowed;
+ int ClockMulFactor;
+ int ClockDivFactor;
+ int PrivFlags;
} ClockRange, *ClockRangePtr;
/*
@@ -254,8 +259,7 @@ typedef enum {
GET_REQUIRED_HW_INTERFACES = 10
} xorgDriverFuncOp;
-typedef Bool xorgDriverFuncProc (ScrnInfoPtr, xorgDriverFuncOp,
- pointer);
+typedef Bool xorgDriverFuncProc(ScrnInfoPtr, xorgDriverFuncOp, pointer);
/* RR_GET_INFO, RR_SET_CONFIG */
typedef struct {
@@ -294,13 +298,13 @@ typedef CARD32 xorgHWFlags;
struct _DriverRec;
typedef struct {
- int driverVersion;
- char * driverName;
- void (*Identify)(int flags);
- Bool (*Probe)(struct _DriverRec *drv, int flags);
- const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype);
- pointer module;
- int refCount;
+ int driverVersion;
+ char *driverName;
+ void (*Identify) (int flags);
+ Bool (*Probe) (struct _DriverRec * drv, int flags);
+ const OptionInfoRec *(*AvailableOptions) (int chipid, int bustype);
+ pointer module;
+ int refCount;
} DriverRec1;
struct _SymTabRec;
@@ -309,18 +313,18 @@ struct _PciChipsets;
struct pci_device;
typedef struct _DriverRec {
- int driverVersion;
- char * driverName;
- void (*Identify)(int flags);
- Bool (*Probe)(struct _DriverRec *drv, int flags);
- const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype);
- pointer module;
- int refCount;
- xorgDriverFuncProc *driverFunc;
-
- const struct pci_id_match * supported_devices;
- Bool (*PciProbe)( struct _DriverRec * drv, int entity_num,
- struct pci_device * dev, intptr_t match_data );
+ int driverVersion;
+ char *driverName;
+ void (*Identify) (int flags);
+ Bool (*Probe) (struct _DriverRec * drv, int flags);
+ const OptionInfoRec *(*AvailableOptions) (int chipid, int bustype);
+ pointer module;
+ int refCount;
+ xorgDriverFuncProc *driverFunc;
+
+ const struct pci_id_match *supported_devices;
+ Bool (*PciProbe) (struct _DriverRec * drv, int entity_num,
+ struct pci_device * dev, intptr_t match_data);
} DriverRec, *DriverPtr;
/*
@@ -346,18 +350,18 @@ typedef enum {
BUS_NONE,
BUS_PCI,
BUS_SBUS,
- BUS_last /* Keep last */
+ BUS_last /* Keep last */
} BusType;
typedef struct {
- int fbNum;
+ int fbNum;
} SbusBusId;
typedef struct _bus {
BusType type;
union {
- struct pci_device *pci;
- SbusBusId sbus;
+ struct pci_device *pci;
+ SbusBusId sbus;
} id;
} BusRec, *BusPtr;
@@ -371,73 +375,73 @@ typedef enum {
} DacSpeedIndex;
typedef struct {
- char * identifier;
- char * vendor;
- char * board;
- char * chipset;
- char * ramdac;
- char * driver;
- struct _confscreenrec * myScreenSection;
- Bool claimed;
- int dacSpeeds[MAXDACSPEEDS];
- int numclocks;
- int clock[MAXCLOCKS];
- char * clockchip;
- char * busID;
- Bool active;
- Bool inUse;
- int videoRam;
- int textClockFreq;
- unsigned long BiosBase; /* Base address of video BIOS */
- unsigned long MemBase; /* Frame buffer base address */
- unsigned long IOBase;
- int chipID;
- int chipRev;
- pointer options;
- int irq;
- int screen; /* For multi-CRTC cards */
+ char *identifier;
+ char *vendor;
+ char *board;
+ char *chipset;
+ char *ramdac;
+ char *driver;
+ struct _confscreenrec *myScreenSection;
+ Bool claimed;
+ int dacSpeeds[MAXDACSPEEDS];
+ int numclocks;
+ int clock[MAXCLOCKS];
+ char *clockchip;
+ char *busID;
+ Bool active;
+ Bool inUse;
+ int videoRam;
+ int textClockFreq;
+ unsigned long BiosBase; /* Base address of video BIOS */
+ unsigned long MemBase; /* Frame buffer base address */
+ unsigned long IOBase;
+ int chipID;
+ int chipRev;
+ pointer options;
+ int irq;
+ int screen; /* For multi-CRTC cards */
} GDevRec, *GDevPtr;
typedef struct {
- int frameX0;
- int frameY0;
- int virtualX;
- int virtualY;
- int depth;
- int fbbpp;
- rgb weight;
- rgb blackColour;
- rgb whiteColour;
- int defaultVisual;
- char ** modes;
- pointer options;
+ int frameX0;
+ int frameY0;
+ int virtualX;
+ int virtualY;
+ int depth;
+ int fbbpp;
+ rgb weight;
+ rgb blackColour;
+ rgb whiteColour;
+ int defaultVisual;
+ char **modes;
+ pointer options;
} DispRec, *DispPtr;
typedef struct _confxvportrec {
- char * identifier;
- pointer options;
+ char *identifier;
+ pointer options;
} confXvPortRec, *confXvPortPtr;
typedef struct _confxvadaptrec {
- char * identifier;
- int numports;
- confXvPortPtr ports;
- pointer options;
+ char *identifier;
+ int numports;
+ confXvPortPtr ports;
+ pointer options;
} confXvAdaptorRec, *confXvAdaptorPtr;
typedef struct _confscreenrec {
- char * id;
- int screennum;
- int defaultdepth;
- int defaultbpp;
- int defaultfbbpp;
- MonPtr monitor;
- GDevPtr device;
- int numdisplays;
- DispPtr displays;
- int numxvadaptors;
- confXvAdaptorPtr xvadaptors;
- pointer options;
+ char *id;
+ int screennum;
+ int defaultdepth;
+ int defaultbpp;
+ int defaultfbbpp;
+ MonPtr monitor;
+ GDevPtr device;
+ int numdisplays;
+ DispPtr displays;
+ int numxvadaptors;
+ confXvAdaptorPtr xvadaptors;
+ pointer options;
} confScreenRec, *confScreenPtr;
typedef enum {
@@ -451,45 +455,45 @@ typedef enum {
} PositionType;
typedef struct _screenlayoutrec {
- confScreenPtr screen;
- char * topname;
- confScreenPtr top;
- char * bottomname;
- confScreenPtr bottom;
- char * leftname;
- confScreenPtr left;
- char * rightname;
- confScreenPtr right;
- PositionType where;
- int x;
- int y;
- char * refname;
- confScreenPtr refscreen;
+ confScreenPtr screen;
+ char *topname;
+ confScreenPtr top;
+ char *bottomname;
+ confScreenPtr bottom;
+ char *leftname;
+ confScreenPtr left;
+ char *rightname;
+ confScreenPtr right;
+ PositionType where;
+ int x;
+ int y;
+ char *refname;
+ confScreenPtr refscreen;
} screenLayoutRec, *screenLayoutPtr;
typedef struct _InputInfoRec InputInfoRec;
typedef struct _serverlayoutrec {
- char * id;
- screenLayoutPtr screens;
- GDevPtr inactives;
- InputInfoRec** inputs; /* NULL terminated */
- pointer options;
+ char *id;
+ screenLayoutPtr screens;
+ GDevPtr inactives;
+ InputInfoRec **inputs; /* NULL terminated */
+ pointer options;
} serverLayoutRec, *serverLayoutPtr;
typedef struct _confdribufferrec {
- int count;
- int size;
+ int count;
+ int size;
enum {
- XF86DRI_WC_HINT = 0x0001 /* Placeholder: not implemented */
- } flags;
+ XF86DRI_WC_HINT = 0x0001 /* Placeholder: not implemented */
+ } flags;
} confDRIBufferRec, *confDRIBufferPtr;
typedef struct _confdrirec {
- int group;
- int mode;
- int bufs_count;
- confDRIBufferRec *bufs;
+ int group;
+ int mode;
+ int bufs_count;
+ confDRIBufferRec *bufs;
} confDRIRec, *confDRIPtr;
/* These values should be adjusted when new fields are added to ScrnInfoRec */
@@ -497,7 +501,7 @@ typedef struct _confdrirec {
#define NUM_RESERVED_POINTERS 14
#define NUM_RESERVED_FUNCS 10
-typedef pointer (*funcPointer)(void);
+typedef pointer (*funcPointer) (void);
/* flags for depth 24 pixmap options */
typedef enum {
@@ -565,9 +569,8 @@ typedef struct _PciChipsets {
void *dummy;
} PciChipsets;
-
/* Entity properties */
-typedef void (*EntityProc)(int entityIndex,pointer private);
+typedef void (*EntityProc) (int entityIndex, pointer private);
typedef struct _entityInfo {
int index;
@@ -581,37 +584,37 @@ typedef struct _entityInfo {
/* DGA */
typedef struct {
- int num; /* A unique identifier for the mode (num > 0) */
- DisplayModePtr mode;
- int flags; /* DGA_CONCURRENT_ACCESS, etc... */
- int imageWidth; /* linear accessible portion (pixels) */
- int imageHeight;
- int pixmapWidth; /* Xlib accessible portion (pixels) */
- int pixmapHeight; /* both fields ignored if no concurrent access */
- int bytesPerScanline;
- int byteOrder; /* MSBFirst, LSBFirst */
- int depth;
- int bitsPerPixel;
- unsigned long red_mask;
- unsigned long green_mask;
- unsigned long blue_mask;
- short visualClass;
- int viewportWidth;
- int viewportHeight;
- int xViewportStep; /* viewport position granularity */
- int yViewportStep;
- int maxViewportX; /* max viewport origin */
- int maxViewportY;
- int viewportFlags; /* types of page flipping possible */
- int offset; /* offset into physical memory */
- unsigned char *address; /* server's mapped framebuffer */
- int reserved1;
- int reserved2;
+ int num; /* A unique identifier for the mode (num > 0) */
+ DisplayModePtr mode;
+ int flags; /* DGA_CONCURRENT_ACCESS, etc... */
+ int imageWidth; /* linear accessible portion (pixels) */
+ int imageHeight;
+ int pixmapWidth; /* Xlib accessible portion (pixels) */
+ int pixmapHeight; /* both fields ignored if no concurrent access */
+ int bytesPerScanline;
+ int byteOrder; /* MSBFirst, LSBFirst */
+ int depth;
+ int bitsPerPixel;
+ unsigned long red_mask;
+ unsigned long green_mask;
+ unsigned long blue_mask;
+ short visualClass;
+ int viewportWidth;
+ int viewportHeight;
+ int xViewportStep; /* viewport position granularity */
+ int yViewportStep;
+ int maxViewportX; /* max viewport origin */
+ int maxViewportY;
+ int viewportFlags; /* types of page flipping possible */
+ int offset; /* offset into physical memory */
+ unsigned char *address; /* server's mapped framebuffer */
+ int reserved1;
+ int reserved2;
} DGAModeRec, *DGAModePtr;
typedef struct {
- DGAModePtr mode;
- PixmapPtr pPix;
+ DGAModePtr mode;
+ PixmapPtr pPix;
} DGADeviceRec, *DGADevicePtr;
/*
@@ -625,25 +628,24 @@ typedef struct {
* Driver entry point types
*/
-typedef Bool xf86ProbeProc (DriverPtr, int);
-typedef Bool xf86PreInitProc (ScrnInfoPtr, int);
-typedef Bool xf86ScreenInitProc (int, ScreenPtr, int, char**);
-typedef Bool xf86SwitchModeProc (int, DisplayModePtr, int);
-typedef void xf86AdjustFrameProc (int, int, int, int);
-typedef Bool xf86EnterVTProc (int, int);
-typedef void xf86LeaveVTProc (int, int);
-typedef void xf86FreeScreenProc (int, int);
-typedef ModeStatus xf86ValidModeProc (int, DisplayModePtr, Bool, int);
+typedef Bool xf86ProbeProc(DriverPtr, int);
+typedef Bool xf86PreInitProc(ScrnInfoPtr, int);
+typedef Bool xf86ScreenInitProc(int, ScreenPtr, int, char **);
+typedef Bool xf86SwitchModeProc(int, DisplayModePtr, int);
+typedef void xf86AdjustFrameProc(int, int, int, int);
+typedef Bool xf86EnterVTProc(int, int);
+typedef void xf86LeaveVTProc(int, int);
+typedef void xf86FreeScreenProc(int, int);
+typedef ModeStatus xf86ValidModeProc(int, DisplayModePtr, Bool, int);
typedef void xf86EnableDisableFBAccessProc(int, Bool);
-typedef int xf86SetDGAModeProc (int, int, DGADevicePtr);
-typedef int xf86ChangeGammaProc (int, Gamma);
-typedef void xf86PointerMovedProc (int, int, int);
-typedef Bool xf86PMEventProc (int, pmEvent, Bool);
-typedef void xf86DPMSSetProc (ScrnInfoPtr, int, int);
-typedef void xf86LoadPaletteProc (ScrnInfoPtr, int, int *, LOCO *, VisualPtr);
-typedef void xf86SetOverscanProc (ScrnInfoPtr, int);
-typedef void xf86ModeSetProc (ScrnInfoPtr);
-
+typedef int xf86SetDGAModeProc(int, int, DGADevicePtr);
+typedef int xf86ChangeGammaProc(int, Gamma);
+typedef void xf86PointerMovedProc(int, int, int);
+typedef Bool xf86PMEventProc(int, pmEvent, Bool);
+typedef void xf86DPMSSetProc(ScrnInfoPtr, int, int);
+typedef void xf86LoadPaletteProc(ScrnInfoPtr, int, int *, LOCO *, VisualPtr);
+typedef void xf86SetOverscanProc(ScrnInfoPtr, int);
+typedef void xf86ModeSetProc(ScrnInfoPtr);
/*
* ScrnInfoRec
@@ -656,217 +658,200 @@ typedef void xf86ModeSetProc (ScrnInfoPtr);
* are to be dependent on compile-time defines.
*/
-
typedef struct _ScrnInfoRec {
- int driverVersion;
- char * driverName; /* canonical name used in */
- /* the config file */
- ScreenPtr pScreen; /* Pointer to the ScreenRec */
- int scrnIndex; /* Number of this screen */
- Bool configured; /* Is this screen valid */
- int origIndex; /* initial number assigned to
- * this screen before
- * finalising the number of
- * available screens */
+ int driverVersion;
+ char *driverName; /* canonical name used in */
+ /* the config file */
+ ScreenPtr pScreen; /* Pointer to the ScreenRec */
+ int scrnIndex; /* Number of this screen */
+ Bool configured; /* Is this screen valid */
+ int origIndex; /* initial number assigned to
+ * this screen before
+ * finalising the number of
+ * available screens */
/* Display-wide screenInfo values needed by this screen */
- int imageByteOrder;
- int bitmapScanlineUnit;
- int bitmapScanlinePad;
- int bitmapBitOrder;
- int numFormats;
- PixmapFormatRec formats[MAXFORMATS];
- PixmapFormatRec fbFormat;
-
- int bitsPerPixel; /* fb bpp */
- Pix24Flags pixmap24; /* pixmap pref for depth 24 */
- int depth; /* depth of default visual */
- MessageType depthFrom; /* set from config? */
- MessageType bitsPerPixelFrom; /* set from config? */
- rgb weight; /* r/g/b weights */
- rgb mask; /* rgb masks */
- rgb offset; /* rgb offsets */
- int rgbBits; /* Number of bits in r/g/b */
- Gamma gamma; /* Gamma of the monitor */
- int defaultVisual; /* default visual class */
- int maxHValue; /* max horizontal timing */
- int maxVValue; /* max vertical timing value */
- int virtualX; /* Virtual width */
- int virtualY; /* Virtual height */
- int xInc; /* Horizontal timing increment */
- MessageType virtualFrom; /* set from config? */
- int displayWidth; /* memory pitch */
- int frameX0; /* viewport position */
- int frameY0;
- int frameX1;
- int frameY1;
- int zoomLocked; /* Disallow mode changes */
- DisplayModePtr modePool; /* list of compatible modes */
- DisplayModePtr modes; /* list of actual modes */
- DisplayModePtr currentMode; /* current mode
- * This was previously
- * overloaded with the modes
- * field, which is a pointer
- * into a circular list */
- confScreenPtr confScreen; /* Screen config info */
- MonPtr monitor; /* Monitor information */
- DispPtr display; /* Display information */
- int * entityList; /* List of device entities */
- int numEntities;
- int widthmm; /* physical display dimensions
- * in mm */
- int heightmm;
- int xDpi; /* width DPI */
- int yDpi; /* height DPI */
- char * name; /* Name to prefix messages */
- pointer driverPrivate; /* Driver private area */
- DevUnion * privates; /* Other privates can hook in
- * here */
- DriverPtr drv; /* xf86DriverList[] entry */
- pointer module; /* Pointer to module head */
- int colorKey;
- int overlayFlags;
+ int imageByteOrder;
+ int bitmapScanlineUnit;
+ int bitmapScanlinePad;
+ int bitmapBitOrder;
+ int numFormats;
+ PixmapFormatRec formats[MAXFORMATS];
+ PixmapFormatRec fbFormat;
+
+ int bitsPerPixel; /* fb bpp */
+ Pix24Flags pixmap24; /* pixmap pref for depth 24 */
+ int depth; /* depth of default visual */
+ MessageType depthFrom; /* set from config? */
+ MessageType bitsPerPixelFrom; /* set from config? */
+ rgb weight; /* r/g/b weights */
+ rgb mask; /* rgb masks */
+ rgb offset; /* rgb offsets */
+ int rgbBits; /* Number of bits in r/g/b */
+ Gamma gamma; /* Gamma of the monitor */
+ int defaultVisual; /* default visual class */
+ int maxHValue; /* max horizontal timing */
+ int maxVValue; /* max vertical timing value */
+ int virtualX; /* Virtual width */
+ int virtualY; /* Virtual height */
+ int xInc; /* Horizontal timing increment */
+ MessageType virtualFrom; /* set from config? */
+ int displayWidth; /* memory pitch */
+ int frameX0; /* viewport position */
+ int frameY0;
+ int frameX1;
+ int frameY1;
+ int zoomLocked; /* Disallow mode changes */
+ DisplayModePtr modePool; /* list of compatible modes */
+ DisplayModePtr modes; /* list of actual modes */
+ DisplayModePtr currentMode; /* current mode
+ * This was previously
+ * overloaded with the modes
+ * field, which is a pointer
+ * into a circular list */
+ confScreenPtr confScreen; /* Screen config info */
+ MonPtr monitor; /* Monitor information */
+ DispPtr display; /* Display information */
+ int *entityList; /* List of device entities */
+ int numEntities;
+ int widthmm; /* physical display dimensions
+ * in mm */
+ int heightmm;
+ int xDpi; /* width DPI */
+ int yDpi; /* height DPI */
+ char *name; /* Name to prefix messages */
+ pointer driverPrivate; /* Driver private area */
+ DevUnion *privates; /* Other privates can hook in
+ * here */
+ DriverPtr drv; /* xf86DriverList[] entry */
+ pointer module; /* Pointer to module head */
+ int colorKey;
+ int overlayFlags;
/* Some of these may be moved out of here into the driver private area */
- char * chipset; /* chipset name */
- char * ramdac; /* ramdac name */
- char * clockchip; /* clock name */
- Bool progClock; /* clock is programmable */
- int numClocks; /* number of clocks */
- int clock[MAXCLOCKS]; /* list of clock frequencies */
- int videoRam; /* amount of video ram (kb) */
- unsigned long biosBase; /* Base address of video BIOS */
- unsigned long memPhysBase; /* Physical address of FB */
- unsigned long fbOffset; /* Offset of FB in the above */
- int memClk; /* memory clock */
- int textClockFreq; /* clock of text mode */
- Bool flipPixels; /* swap default black/white */
- pointer options;
-
- int chipID;
- int chipRev;
+ char *chipset; /* chipset name */
+ char *ramdac; /* ramdac name */
+ char *clockchip; /* clock name */
+ Bool progClock; /* clock is programmable */
+ int numClocks; /* number of clocks */
+ int clock[MAXCLOCKS]; /* list of clock frequencies */
+ int videoRam; /* amount of video ram (kb) */
+ unsigned long biosBase; /* Base address of video BIOS */
+ unsigned long memPhysBase; /* Physical address of FB */
+ unsigned long fbOffset; /* Offset of FB in the above */
+ int memClk; /* memory clock */
+ int textClockFreq; /* clock of text mode */
+ Bool flipPixels; /* swap default black/white */
+ pointer options;
+
+ int chipID;
+ int chipRev;
/* Allow screens to be enabled/disabled individually */
- Bool vtSema;
+ Bool vtSema;
/* hw cursor moves at SIGIO time */
- Bool silkenMouse;
+ Bool silkenMouse;
/* Storage for clockRanges and adjustFlags for use with the VidMode ext */
- ClockRangePtr clockRanges;
- int adjustFlags;
+ ClockRangePtr clockRanges;
+ int adjustFlags;
/*
* These can be used when the minor ABI version is incremented.
* The NUM_* parameters must be reduced appropriately to keep the
* structure size and alignment unchanged.
*/
- int reservedInt[NUM_RESERVED_INTS];
+ int reservedInt[NUM_RESERVED_INTS];
- int * entityInstanceList;
- struct pci_device *vgaDev;
+ int *entityInstanceList;
+ struct pci_device *vgaDev;
- pointer reservedPtr[NUM_RESERVED_POINTERS];
+ pointer reservedPtr[NUM_RESERVED_POINTERS];
/*
* Driver entry points.
*
*/
- xf86ProbeProc *Probe;
- xf86PreInitProc *PreInit;
- xf86ScreenInitProc *ScreenInit;
- xf86SwitchModeProc *SwitchMode;
- xf86AdjustFrameProc *AdjustFrame;
- xf86EnterVTProc *EnterVT;
- xf86LeaveVTProc *LeaveVT;
- xf86FreeScreenProc *FreeScreen;
- xf86ValidModeProc *ValidMode;
- xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
- xf86SetDGAModeProc *SetDGAMode;
- xf86ChangeGammaProc *ChangeGamma;
- xf86PointerMovedProc *PointerMoved;
- xf86PMEventProc *PMEvent;
- xf86DPMSSetProc *DPMSSet;
- xf86LoadPaletteProc *LoadPalette;
- xf86SetOverscanProc *SetOverscan;
- xorgDriverFuncProc *DriverFunc;
- xf86ModeSetProc *ModeSet;
+ xf86ProbeProc *Probe;
+ xf86PreInitProc *PreInit;
+ xf86ScreenInitProc *ScreenInit;
+ xf86SwitchModeProc *SwitchMode;
+ xf86AdjustFrameProc *AdjustFrame;
+ xf86EnterVTProc *EnterVT;
+ xf86LeaveVTProc *LeaveVT;
+ xf86FreeScreenProc *FreeScreen;
+ xf86ValidModeProc *ValidMode;
+ xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
+ xf86SetDGAModeProc *SetDGAMode;
+ xf86ChangeGammaProc *ChangeGamma;
+ xf86PointerMovedProc *PointerMoved;
+ xf86PMEventProc *PMEvent;
+ xf86DPMSSetProc *DPMSSet;
+ xf86LoadPaletteProc *LoadPalette;
+ xf86SetOverscanProc *SetOverscan;
+ xorgDriverFuncProc *DriverFunc;
+ xf86ModeSetProc *ModeSet;
/*
* This can be used when the minor ABI version is incremented.
* The NUM_* parameter must be reduced appropriately to keep the
* structure size and alignment unchanged.
*/
- funcPointer reservedFuncs[NUM_RESERVED_FUNCS];
+ funcPointer reservedFuncs[NUM_RESERVED_FUNCS];
} ScrnInfoRec;
-
typedef struct {
- Bool (*OpenFramebuffer)(
- ScrnInfoPtr pScrn,
- char **name,
- unsigned char **mem,
- int *size,
- int *offset,
- int *extra
- );
- void (*CloseFramebuffer)(ScrnInfoPtr pScrn);
- Bool (*SetMode)(ScrnInfoPtr pScrn, DGAModePtr pMode);
- void (*SetViewport)(ScrnInfoPtr pScrn, int x, int y, int flags);
- int (*GetViewport)(ScrnInfoPtr pScrn);
- void (*Sync)(ScrnInfoPtr);
- void (*FillRect)(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned long color
- );
- void (*BlitRect)(
- ScrnInfoPtr pScrn,
- int srcx, int srcy,
- int w, int h,
- int dstx, int dsty
- );
- void (*BlitTransRect)(
- ScrnInfoPtr pScrn,
- int srcx, int srcy,
- int w, int h,
- int dstx, int dsty,
- unsigned long color
- );
+ Bool (*OpenFramebuffer) (ScrnInfoPtr pScrn,
+ char **name,
+ unsigned char **mem,
+ int *size, int *offset, int *extra);
+ void (*CloseFramebuffer) (ScrnInfoPtr pScrn);
+ Bool (*SetMode) (ScrnInfoPtr pScrn, DGAModePtr pMode);
+ void (*SetViewport) (ScrnInfoPtr pScrn, int x, int y, int flags);
+ int (*GetViewport) (ScrnInfoPtr pScrn);
+ void (*Sync) (ScrnInfoPtr);
+ void (*FillRect) (ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, unsigned long color);
+ void (*BlitRect) (ScrnInfoPtr pScrn,
+ int srcx, int srcy, int w, int h, int dstx, int dsty);
+ void (*BlitTransRect) (ScrnInfoPtr pScrn,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty, unsigned long color);
} DGAFunctionRec, *DGAFunctionPtr;
typedef struct _SymTabRec {
- int token; /* id of the token */
- const char * name; /* token name */
+ int token; /* id of the token */
+ const char *name; /* token name */
} SymTabRec, *SymTabPtr;
/* flags for xf86LookupMode */
typedef enum {
- LOOKUP_DEFAULT = 0, /* Use default mode lookup method */
- LOOKUP_BEST_REFRESH, /* Pick modes with best refresh */
- LOOKUP_CLOSEST_CLOCK, /* Pick modes with the closest clock */
- LOOKUP_LIST_ORDER, /* Pick first useful mode in list */
- LOOKUP_CLKDIV2 = 0x0100, /* Allow half clocks */
- LOOKUP_OPTIONAL_TOLERANCES = 0x0200 /* Allow missing hsync/vrefresh */
+ LOOKUP_DEFAULT = 0, /* Use default mode lookup method */
+ LOOKUP_BEST_REFRESH, /* Pick modes with best refresh */
+ LOOKUP_CLOSEST_CLOCK, /* Pick modes with the closest clock */
+ LOOKUP_LIST_ORDER, /* Pick first useful mode in list */
+ LOOKUP_CLKDIV2 = 0x0100, /* Allow half clocks */
+ LOOKUP_OPTIONAL_TOLERANCES = 0x0200 /* Allow missing hsync/vrefresh */
} LookupModeFlags;
#define NoDepth24Support 0x00
-#define Support24bppFb 0x01 /* 24bpp framebuffer supported */
-#define Support32bppFb 0x02 /* 32bpp framebuffer supported */
-#define SupportConvert24to32 0x04 /* Can convert 24bpp pixmap to 32bpp */
-#define SupportConvert32to24 0x08 /* Can convert 32bpp pixmap to 24bpp */
-#define PreferConvert24to32 0x10 /* prefer 24bpp pixmap to 32bpp conv */
-#define PreferConvert32to24 0x20 /* prefer 32bpp pixmap to 24bpp conv */
-
+#define Support24bppFb 0x01 /* 24bpp framebuffer supported */
+#define Support32bppFb 0x02 /* 32bpp framebuffer supported */
+#define SupportConvert24to32 0x04 /* Can convert 24bpp pixmap to 32bpp */
+#define SupportConvert32to24 0x08 /* Can convert 32bpp pixmap to 24bpp */
+#define PreferConvert24to32 0x10 /* prefer 24bpp pixmap to 32bpp conv */
+#define PreferConvert32to24 0x20 /* prefer 32bpp pixmap to 24bpp conv */
/* For DPMS */
-typedef void (*DPMSSetProcPtr)(ScrnInfoPtr, int, int);
+typedef void (*DPMSSetProcPtr) (ScrnInfoPtr, int, int);
/* Input handler proc */
-typedef void (*InputHandlerProc)(int fd, pointer data);
+typedef void (*InputHandlerProc) (int fd, pointer data);
/* These are used by xf86GetClocks */
#define CLK_REG_SAVE -1
@@ -876,9 +861,8 @@ typedef void (*InputHandlerProc)(int fd, pointer data);
* misc constants
*/
#define INTERLACE_REFRESH_WEIGHT 1.5
-#define SYNC_TOLERANCE 0.01 /* 1 percent */
-#define CLOCK_TOLERANCE 2000 /* Clock matching tolerance (2MHz) */
-
+#define SYNC_TOLERANCE 0.01 /* 1 percent */
+#define CLOCK_TOLERANCE 2000 /* Clock matching tolerance (2MHz) */
#define OVERLAY_8_32_DUALFB 0x00000001
#define OVERLAY_8_24_DUALFB 0x00000002
@@ -891,12 +875,12 @@ typedef void (*InputHandlerProc)(int fd, pointer data);
/* Action Events */
typedef enum {
- ACTION_TERMINATE = 0, /* Terminate Server */
- ACTION_NEXT_MODE = 10, /* Switch to next video mode */
+ ACTION_TERMINATE = 0, /* Terminate Server */
+ ACTION_NEXT_MODE = 10, /* Switch to next video mode */
ACTION_PREV_MODE,
- ACTION_SWITCHSCREEN = 100, /* VT switch */
+ ACTION_SWITCHSCREEN = 100, /* VT switch */
ACTION_SWITCHSCREEN_NEXT,
ACTION_SWITCHSCREEN_PREV,
} ActionEvent;
-#endif /* _XF86STR_H */
+#endif /* _XF86STR_H */
diff --git a/xorg-server/hw/xfree86/common/xf86xv.c b/xorg-server/hw/xfree86/common/xf86xv.c
index b46dfefed..88e2f314b 100644
--- a/xorg-server/hw/xfree86/common/xf86xv.c
+++ b/xorg-server/hw/xfree86/common/xf86xv.c
@@ -28,7 +28,6 @@
* authorization from the copyright holder(s) and author(s).
*/
-
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
@@ -56,7 +55,6 @@
#include "xf86xvpriv.h"
-
/* XvScreenRec fields */
static Bool xf86XVCloseScreen(int, ScreenPtr);
@@ -64,40 +62,39 @@ static int xf86XVQueryAdaptors(ScreenPtr, XvAdaptorPtr *, int *);
/* XvAdaptorRec fields */
-static int xf86XVAllocatePort(unsigned long, XvPortPtr, XvPortPtr*);
+static int xf86XVAllocatePort(unsigned long, XvPortPtr, XvPortPtr *);
static int xf86XVFreePort(XvPortPtr);
-static int xf86XVPutVideo(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
- INT16, INT16, CARD16, CARD16,
- INT16, INT16, CARD16, CARD16);
-static int xf86XVPutStill(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
- INT16, INT16, CARD16, CARD16,
- INT16, INT16, CARD16, CARD16);
-static int xf86XVGetVideo(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
- INT16, INT16, CARD16, CARD16,
- INT16, INT16, CARD16, CARD16);
-static int xf86XVGetStill(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
- INT16, INT16, CARD16, CARD16,
- INT16, INT16, CARD16, CARD16);
+static int xf86XVPutVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+static int xf86XVPutStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+static int xf86XVGetVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+static int xf86XVGetStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
static int xf86XVStopVideo(ClientPtr, XvPortPtr, DrawablePtr);
static int xf86XVSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32);
-static int xf86XVGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32*);
+static int xf86XVGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32 *);
static int xf86XVQueryBestSize(ClientPtr, XvPortPtr, CARD8,
- CARD16, CARD16,CARD16, CARD16,
- unsigned int*, unsigned int*);
+ CARD16, CARD16, CARD16, CARD16,
+ unsigned int *, unsigned int *);
static int xf86XVPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
- INT16, INT16, CARD16, CARD16,
- INT16, INT16, CARD16, CARD16,
- XvImagePtr, unsigned char*, Bool,
- CARD16, CARD16);
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16,
+ XvImagePtr, unsigned char *, Bool, CARD16, CARD16);
static int xf86XVQueryImageAttributes(ClientPtr, XvPortPtr, XvImagePtr,
- CARD16*, CARD16*, int*, int*);
-
+ CARD16 *, CARD16 *, int *, int *);
/* ScreenRec fields */
static Bool xf86XVDestroyWindow(WindowPtr pWin);
static void xf86XVWindowExposures(WindowPtr pWin, RegionPtr r1, RegionPtr r2);
-static void xf86XVPostValidateTree(WindowPtr pWin, WindowPtr pLayerWin, VTKind kind);
+static void xf86XVPostValidateTree(WindowPtr pWin, WindowPtr pLayerWin,
+ VTKind kind);
static void xf86XVClipNotify(WindowPtr pWin, int dx, int dy);
#define PostValidateTreeUndefined ((PostValidateTreeProcPtr)-1)
@@ -111,19 +108,19 @@ static void xf86XVModeSet(ScrnInfoPtr pScrn);
/* misc */
-static Bool xf86XVInitAdaptors(ScreenPtr, XF86VideoAdaptorPtr*, int);
-
+static Bool xf86XVInitAdaptors(ScreenPtr, XF86VideoAdaptorPtr *, int);
static DevPrivateKeyRec XF86XVWindowKeyRec;
+
#define XF86XVWindowKey (&XF86XVWindowKeyRec)
DevPrivateKey XF86XvScreenKey;
static unsigned long PortResource = 0;
-DevPrivateKey (*XvGetScreenKeyProc)(void) = NULL;
-unsigned long (*XvGetRTPortProc)(void) = NULL;
-int (*XvScreenInitProc)(ScreenPtr) = NULL;
+DevPrivateKey (*XvGetScreenKeyProc) (void) = NULL;
+unsigned long (*XvGetRTPortProc) (void) = NULL;
+int (*XvScreenInitProc) (ScreenPtr) = NULL;
#define GET_XV_SCREEN(pScreen) \
((XvScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XF86XvScreenKey))
@@ -138,29 +135,26 @@ static xf86XVInitGenericAdaptorPtr *GenDrivers = NULL;
static int NumGenDrivers = 0;
int
-xf86XVRegisterGenericAdaptorDriver(
- xf86XVInitGenericAdaptorPtr InitFunc
-){
- xf86XVInitGenericAdaptorPtr *newdrivers;
+xf86XVRegisterGenericAdaptorDriver(xf86XVInitGenericAdaptorPtr InitFunc)
+{
+ xf86XVInitGenericAdaptorPtr *newdrivers;
- newdrivers = realloc(GenDrivers, sizeof(xf86XVInitGenericAdaptorPtr) *
- (1 + NumGenDrivers));
- if (!newdrivers)
- return 0;
- GenDrivers = newdrivers;
+ newdrivers = realloc(GenDrivers, sizeof(xf86XVInitGenericAdaptorPtr) *
+ (1 + NumGenDrivers));
+ if (!newdrivers)
+ return 0;
+ GenDrivers = newdrivers;
- GenDrivers[NumGenDrivers++] = InitFunc;
+ GenDrivers[NumGenDrivers++] = InitFunc;
- return 1;
+ return 1;
}
int
-xf86XVListGenericAdaptors(
- ScrnInfoPtr pScrn,
- XF86VideoAdaptorPtr **adaptors
-){
- int i,j,n,num;
- XF86VideoAdaptorPtr *DrivAdap,*new;
+xf86XVListGenericAdaptors(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr ** adaptors)
+{
+ int i, j, n, num;
+ XF86VideoAdaptorPtr *DrivAdap, *new;
num = 0;
*adaptors = NULL;
@@ -168,48 +162,49 @@ xf86XVListGenericAdaptors(
* The v4l driver registers itself first, but can use surfaces registered
* by other drivers. So, call the v4l driver last.
*/
- for (i = NumGenDrivers; --i >= 0; ) {
- DrivAdap = NULL;
- n = (*GenDrivers[i])(pScrn, &DrivAdap);
- if (0 == n)
- continue;
- new = realloc(*adaptors, sizeof(XF86VideoAdaptorPtr) * (num+n));
- if (NULL == new)
- continue;
- *adaptors = new;
- for (j = 0; j < n; j++, num++)
- (*adaptors)[num] = DrivAdap[j];
+ for (i = NumGenDrivers; --i >= 0;) {
+ DrivAdap = NULL;
+ n = (*GenDrivers[i]) (pScrn, &DrivAdap);
+ if (0 == n)
+ continue;
+ new = realloc(*adaptors, sizeof(XF86VideoAdaptorPtr) * (num + n));
+ if (NULL == new)
+ continue;
+ *adaptors = new;
+ for (j = 0; j < n; j++, num++)
+ (*adaptors)[num] = DrivAdap[j];
}
return num;
}
-
/**************** Offscreen surface stuff *******************/
typedef struct {
- XF86OffscreenImagePtr images;
- int num;
+ XF86OffscreenImagePtr images;
+ int num;
} OffscreenImageRec;
static DevPrivateKeyRec OffscreenPrivateKeyRec;
+
#define OffscreenPrivateKey (&OffscreenPrivateKeyRec)
#define GetOffscreenImage(pScreen) ((OffscreenImageRec *) dixLookupPrivate(&(pScreen)->devPrivates, OffscreenPrivateKey))
Bool
-xf86XVRegisterOffscreenImages(
- ScreenPtr pScreen,
- XF86OffscreenImagePtr images,
- int num
-){
+xf86XVRegisterOffscreenImages(ScreenPtr pScreen,
+ XF86OffscreenImagePtr images, int num)
+{
OffscreenImageRec *OffscreenImage;
+
/* This function may be called before xf86XVScreenInit, so there's
* no better place than this to call dixRegisterPrivateKey to ensure we
* have space reserved. After the first call it is a no-op. */
- if(!dixRegisterPrivateKey(OffscreenPrivateKey, PRIVATE_SCREEN, sizeof(OffscreenImageRec)) ||
- !(OffscreenImage = GetOffscreenImage(pScreen)))
+ if (!dixRegisterPrivateKey
+ (OffscreenPrivateKey, PRIVATE_SCREEN, sizeof(OffscreenImageRec)) ||
+ !(OffscreenImage = GetOffscreenImage(pScreen)))
/* Every X.org driver assumes this function always succeeds, so
* just die on allocation failure. */
- FatalError("Could not allocate private storage for XV offscreen images.\n");
+ FatalError
+ ("Could not allocate private storage for XV offscreen images.\n");
OffscreenImage->num = num;
OffscreenImage->images = images;
@@ -217,16 +212,14 @@ xf86XVRegisterOffscreenImages(
}
XF86OffscreenImagePtr
-xf86XVQueryOffscreenImages(
- ScreenPtr pScreen,
- int *num
-){
+xf86XVQueryOffscreenImages(ScreenPtr pScreen, int *num)
+{
OffscreenImageRec *OffscreenImage = GetOffscreenImage(pScreen);
+
*num = OffscreenImage->num;
return OffscreenImage->images;
}
-
XF86VideoAdaptorPtr
xf86XVAllocateVideoAdaptorRec(ScrnInfoPtr pScrn)
{
@@ -239,396 +232,388 @@ xf86XVFreeVideoAdaptorRec(XF86VideoAdaptorPtr ptr)
free(ptr);
}
-
Bool
-xf86XVScreenInit(
- ScreenPtr pScreen,
- XF86VideoAdaptorPtr *adaptors,
- int num
-){
- ScrnInfoPtr pScrn;
- XF86XVScreenPtr ScreenPriv;
- XvScreenPtr pxvs;
+xf86XVScreenInit(ScreenPtr pScreen, XF86VideoAdaptorPtr * adaptors, int num)
+{
+ ScrnInfoPtr pScrn;
+ XF86XVScreenPtr ScreenPriv;
+ XvScreenPtr pxvs;
- if(num <= 0 ||
- !XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc)
- return FALSE;
+ if (num <= 0 ||
+ !XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc)
+ return FALSE;
- if(Success != (*XvScreenInitProc)(pScreen)) return FALSE;
+ if (Success != (*XvScreenInitProc) (pScreen))
+ return FALSE;
- if (!dixRegisterPrivateKey(&XF86XVWindowKeyRec, PRIVATE_WINDOW, 0))
- return FALSE;
+ if (!dixRegisterPrivateKey(&XF86XVWindowKeyRec, PRIVATE_WINDOW, 0))
+ return FALSE;
- XF86XvScreenKey = (*XvGetScreenKeyProc)();
+ XF86XvScreenKey = (*XvGetScreenKeyProc) ();
- PortResource = (*XvGetRTPortProc)();
+ PortResource = (*XvGetRTPortProc) ();
- pxvs = GET_XV_SCREEN(pScreen);
+ pxvs = GET_XV_SCREEN(pScreen);
- /* Anyone initializing the Xv layer must provide these two.
- The Xv di layer calls them without even checking if they exist! */
+ /* Anyone initializing the Xv layer must provide these two.
+ The Xv di layer calls them without even checking if they exist! */
- pxvs->ddCloseScreen = xf86XVCloseScreen;
- pxvs->ddQueryAdaptors = xf86XVQueryAdaptors;
+ pxvs->ddCloseScreen = xf86XVCloseScreen;
+ pxvs->ddQueryAdaptors = xf86XVQueryAdaptors;
- /* The Xv di layer provides us with a private hook so that we don't
- have to allocate our own screen private. They also provide
- a CloseScreen hook so that we don't have to wrap it. I'm not
- sure that I appreciate that. */
+ /* The Xv di layer provides us with a private hook so that we don't
+ have to allocate our own screen private. They also provide
+ a CloseScreen hook so that we don't have to wrap it. I'm not
+ sure that I appreciate that. */
- ScreenPriv = malloc(sizeof(XF86XVScreenRec));
- pxvs->devPriv.ptr = (pointer)ScreenPriv;
+ ScreenPriv = malloc(sizeof(XF86XVScreenRec));
+ pxvs->devPriv.ptr = (pointer) ScreenPriv;
- if(!ScreenPriv) return FALSE;
+ if (!ScreenPriv)
+ return FALSE;
- pScrn = xf86Screens[pScreen->myNum];
+ pScrn = xf86Screens[pScreen->myNum];
- ScreenPriv->DestroyWindow = pScreen->DestroyWindow;
- ScreenPriv->WindowExposures = pScreen->WindowExposures;
- ScreenPriv->PostValidateTree = PostValidateTreeUndefined;
- ScreenPriv->ClipNotify = pScreen->ClipNotify;
- ScreenPriv->EnterVT = pScrn->EnterVT;
- ScreenPriv->LeaveVT = pScrn->LeaveVT;
- ScreenPriv->AdjustFrame = pScrn->AdjustFrame;
- ScreenPriv->ModeSet = pScrn->ModeSet;
+ ScreenPriv->DestroyWindow = pScreen->DestroyWindow;
+ ScreenPriv->WindowExposures = pScreen->WindowExposures;
+ ScreenPriv->PostValidateTree = PostValidateTreeUndefined;
+ ScreenPriv->ClipNotify = pScreen->ClipNotify;
+ ScreenPriv->EnterVT = pScrn->EnterVT;
+ ScreenPriv->LeaveVT = pScrn->LeaveVT;
+ ScreenPriv->AdjustFrame = pScrn->AdjustFrame;
+ ScreenPriv->ModeSet = pScrn->ModeSet;
- pScreen->DestroyWindow = xf86XVDestroyWindow;
- pScreen->WindowExposures = xf86XVWindowExposures;
- pScreen->ClipNotify = xf86XVClipNotify;
- pScrn->EnterVT = xf86XVEnterVT;
- pScrn->LeaveVT = xf86XVLeaveVT;
- if(pScrn->AdjustFrame)
- pScrn->AdjustFrame = xf86XVAdjustFrame;
- pScrn->ModeSet = xf86XVModeSet;
+ pScreen->DestroyWindow = xf86XVDestroyWindow;
+ pScreen->WindowExposures = xf86XVWindowExposures;
+ pScreen->ClipNotify = xf86XVClipNotify;
+ pScrn->EnterVT = xf86XVEnterVT;
+ pScrn->LeaveVT = xf86XVLeaveVT;
+ if (pScrn->AdjustFrame)
+ pScrn->AdjustFrame = xf86XVAdjustFrame;
+ pScrn->ModeSet = xf86XVModeSet;
- if(!xf86XVInitAdaptors(pScreen, adaptors, num))
- return FALSE;
+ if (!xf86XVInitAdaptors(pScreen, adaptors, num))
+ return FALSE;
- return TRUE;
+ return TRUE;
}
static void
xf86XVFreeAdaptor(XvAdaptorPtr pAdaptor)
{
- int i;
-
- free(pAdaptor->name);
- pAdaptor->name = NULL;
-
- if(pAdaptor->pEncodings) {
- XvEncodingPtr pEncode = pAdaptor->pEncodings;
-
- for(i = 0; i < pAdaptor->nEncodings; i++, pEncode++)
- free(pEncode->name);
- free(pAdaptor->pEncodings);
- pAdaptor->pEncodings = NULL;
- }
-
- free(pAdaptor->pFormats);
- pAdaptor->pFormats = NULL;
-
- if(pAdaptor->pPorts) {
- XvPortPtr pPort = pAdaptor->pPorts;
- XvPortRecPrivatePtr pPriv;
-
- for(i = 0; i < pAdaptor->nPorts; i++, pPort++) {
- pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
- if(pPriv) {
- if(pPriv->clientClip)
- RegionDestroy(pPriv->clientClip);
- if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
- RegionDestroy(pPriv->pCompositeClip);
- if (pPriv->ckeyFilled)
- RegionDestroy(pPriv->ckeyFilled);
- free(pPriv);
- }
- }
- free(pAdaptor->pPorts);
- pAdaptor->pPorts = NULL;
- }
-
- if(pAdaptor->pAttributes) {
- XvAttributePtr pAttribute = pAdaptor->pAttributes;
-
- for(i = 0; i < pAdaptor->nAttributes; i++, pAttribute++)
- free(pAttribute->name);
- free(pAdaptor->pAttributes);
- pAdaptor->pAttributes = NULL;
- }
-
- free(pAdaptor->pImages);
- free(pAdaptor->devPriv.ptr);
- pAdaptor->pImages = NULL;
- pAdaptor->devPriv.ptr = NULL;
+ int i;
+
+ free(pAdaptor->name);
+ pAdaptor->name = NULL;
+
+ if (pAdaptor->pEncodings) {
+ XvEncodingPtr pEncode = pAdaptor->pEncodings;
+
+ for (i = 0; i < pAdaptor->nEncodings; i++, pEncode++)
+ free(pEncode->name);
+ free(pAdaptor->pEncodings);
+ pAdaptor->pEncodings = NULL;
+ }
+
+ free(pAdaptor->pFormats);
+ pAdaptor->pFormats = NULL;
+
+ if (pAdaptor->pPorts) {
+ XvPortPtr pPort = pAdaptor->pPorts;
+ XvPortRecPrivatePtr pPriv;
+
+ for (i = 0; i < pAdaptor->nPorts; i++, pPort++) {
+ pPriv = (XvPortRecPrivatePtr) pPort->devPriv.ptr;
+ if (pPriv) {
+ if (pPriv->clientClip)
+ RegionDestroy(pPriv->clientClip);
+ if (pPriv->pCompositeClip && pPriv->FreeCompositeClip)
+ RegionDestroy(pPriv->pCompositeClip);
+ if (pPriv->ckeyFilled)
+ RegionDestroy(pPriv->ckeyFilled);
+ free(pPriv);
+ }
+ }
+ free(pAdaptor->pPorts);
+ pAdaptor->pPorts = NULL;
+ }
+
+ if (pAdaptor->pAttributes) {
+ XvAttributePtr pAttribute = pAdaptor->pAttributes;
+
+ for (i = 0; i < pAdaptor->nAttributes; i++, pAttribute++)
+ free(pAttribute->name);
+ free(pAdaptor->pAttributes);
+ pAdaptor->pAttributes = NULL;
+ }
+
+ free(pAdaptor->pImages);
+ free(pAdaptor->devPriv.ptr);
+ pAdaptor->pImages = NULL;
+ pAdaptor->devPriv.ptr = NULL;
}
static Bool
-xf86XVInitAdaptors(
- ScreenPtr pScreen,
- XF86VideoAdaptorPtr *infoPtr,
- int number
-) {
- XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- XF86VideoAdaptorPtr adaptorPtr;
- XvAdaptorPtr pAdaptor, pa;
- XvAdaptorRecPrivatePtr adaptorPriv;
- int na, numAdaptor;
- XvPortRecPrivatePtr portPriv;
- XvPortPtr pPort, pp;
- int numPort;
- XF86AttributePtr attributePtr;
- XvAttributePtr pAttribute, pat;
- XF86VideoFormatPtr formatPtr;
- XvFormatPtr pFormat, pf;
- int numFormat, totFormat;
- XF86VideoEncodingPtr encodingPtr;
- XvEncodingPtr pEncode, pe;
- XF86ImagePtr imagePtr;
- XvImagePtr pImage, pi;
- int numVisuals;
- VisualPtr pVisual;
- int i;
-
- pxvs->nAdaptors = 0;
- pxvs->pAdaptors = NULL;
-
- if(!(pAdaptor = calloc(number, sizeof(XvAdaptorRec))))
- return FALSE;
-
- for(pa = pAdaptor, na = 0, numAdaptor = 0; na < number; na++, adaptorPtr++) {
- adaptorPtr = infoPtr[na];
-
- if(!adaptorPtr->StopVideo || !adaptorPtr->SetPortAttribute ||
- !adaptorPtr->GetPortAttribute || !adaptorPtr->QueryBestSize)
- continue;
-
- /* client libs expect at least one encoding */
- if(!adaptorPtr->nEncodings || !adaptorPtr->pEncodings)
- continue;
-
- pa->type = adaptorPtr->type;
-
- if(!adaptorPtr->PutVideo && !adaptorPtr->GetVideo)
- pa->type &= ~XvVideoMask;
-
- if(!adaptorPtr->PutStill && !adaptorPtr->GetStill)
- pa->type &= ~XvStillMask;
-
- if(!adaptorPtr->PutImage || !adaptorPtr->QueryImageAttributes)
- pa->type &= ~XvImageMask;
-
- if(!adaptorPtr->PutVideo && !adaptorPtr->PutImage &&
- !adaptorPtr->PutStill)
- pa->type &= ~XvInputMask;
-
- if(!adaptorPtr->GetVideo && !adaptorPtr->GetStill)
- pa->type &= ~XvOutputMask;
-
- if(!(adaptorPtr->type & (XvPixmapMask | XvWindowMask)))
- continue;
- if(!(adaptorPtr->type & (XvImageMask | XvVideoMask | XvStillMask)))
- continue;
-
- pa->pScreen = pScreen;
- pa->ddAllocatePort = xf86XVAllocatePort;
- pa->ddFreePort = xf86XVFreePort;
- pa->ddPutVideo = xf86XVPutVideo;
- pa->ddPutStill = xf86XVPutStill;
- pa->ddGetVideo = xf86XVGetVideo;
- pa->ddGetStill = xf86XVGetStill;
- pa->ddStopVideo = xf86XVStopVideo;
- pa->ddPutImage = xf86XVPutImage;
- pa->ddSetPortAttribute = xf86XVSetPortAttribute;
- pa->ddGetPortAttribute = xf86XVGetPortAttribute;
- pa->ddQueryBestSize = xf86XVQueryBestSize;
- pa->ddQueryImageAttributes = xf86XVQueryImageAttributes;
- pa->name = strdup(adaptorPtr->name);
-
- if(adaptorPtr->nEncodings &&
- (pEncode = calloc(adaptorPtr->nEncodings, sizeof(XvEncodingRec)))) {
-
- for(pe = pEncode, encodingPtr = adaptorPtr->pEncodings, i = 0;
- i < adaptorPtr->nEncodings; pe++, i++, encodingPtr++)
- {
- pe->id = encodingPtr->id;
- pe->pScreen = pScreen;
- pe->name = strdup(encodingPtr->name);
- pe->width = encodingPtr->width;
- pe->height = encodingPtr->height;
- pe->rate.numerator = encodingPtr->rate.numerator;
- pe->rate.denominator = encodingPtr->rate.denominator;
- }
- pa->nEncodings = adaptorPtr->nEncodings;
- pa->pEncodings = pEncode;
- }
-
- if(adaptorPtr->nImages &&
- (pImage = calloc(adaptorPtr->nImages, sizeof(XvImageRec)))) {
-
- for(i = 0, pi = pImage, imagePtr = adaptorPtr->pImages;
- i < adaptorPtr->nImages; i++, pi++, imagePtr++)
- {
- pi->id = imagePtr->id;
- pi->type = imagePtr->type;
- pi->byte_order = imagePtr->byte_order;
- memcpy(pi->guid, imagePtr->guid, 16);
- pi->bits_per_pixel = imagePtr->bits_per_pixel;
- pi->format = imagePtr->format;
- pi->num_planes = imagePtr->num_planes;
- pi->depth = imagePtr->depth;
- pi->red_mask = imagePtr->red_mask;
- pi->green_mask = imagePtr->green_mask;
- pi->blue_mask = imagePtr->blue_mask;
- pi->y_sample_bits = imagePtr->y_sample_bits;
- pi->u_sample_bits = imagePtr->u_sample_bits;
- pi->v_sample_bits = imagePtr->v_sample_bits;
- pi->horz_y_period = imagePtr->horz_y_period;
- pi->horz_u_period = imagePtr->horz_u_period;
- pi->horz_v_period = imagePtr->horz_v_period;
- pi->vert_y_period = imagePtr->vert_y_period;
- pi->vert_u_period = imagePtr->vert_u_period;
- pi->vert_v_period = imagePtr->vert_v_period;
- memcpy(pi->component_order, imagePtr->component_order, 32);
- pi->scanline_order = imagePtr->scanline_order;
- }
- pa->nImages = adaptorPtr->nImages;
- pa->pImages = pImage;
- }
-
- if(adaptorPtr->nAttributes &&
- (pAttribute = calloc(adaptorPtr->nAttributes, sizeof(XvAttributeRec))))
- {
- for(pat = pAttribute, attributePtr = adaptorPtr->pAttributes, i = 0;
- i < adaptorPtr->nAttributes; pat++, i++, attributePtr++)
- {
- pat->flags = attributePtr->flags;
- pat->min_value = attributePtr->min_value;
- pat->max_value = attributePtr->max_value;
- pat->name = strdup(attributePtr->name);
- }
- pa->nAttributes = adaptorPtr->nAttributes;
- pa->pAttributes = pAttribute;
- }
-
-
- totFormat = adaptorPtr->nFormats;
-
- if(!(pFormat = calloc(totFormat, sizeof(XvFormatRec)))) {
- xf86XVFreeAdaptor(pa);
- continue;
- }
- for(pf = pFormat, i = 0, numFormat = 0, formatPtr = adaptorPtr->pFormats;
- i < adaptorPtr->nFormats; i++, formatPtr++)
- {
- numVisuals = pScreen->numVisuals;
- pVisual = pScreen->visuals;
-
- while(numVisuals--) {
- if((pVisual->class == formatPtr->class) &&
- (pVisual->nplanes == formatPtr->depth)) {
-
- if(numFormat >= totFormat) {
- void *moreSpace;
- totFormat *= 2;
- moreSpace = realloc(pFormat,
- totFormat * sizeof(XvFormatRec));
- if(!moreSpace) break;
- pFormat = moreSpace;
- pf = pFormat + numFormat;
- }
-
- pf->visual = pVisual->vid;
- pf->depth = formatPtr->depth;
-
- pf++;
- numFormat++;
- }
- pVisual++;
- }
- }
- pa->nFormats = numFormat;
- pa->pFormats = pFormat;
- if(!numFormat) {
- xf86XVFreeAdaptor(pa);
- continue;
- }
-
- if(!(adaptorPriv = calloc(1, sizeof(XvAdaptorRecPrivate)))) {
- xf86XVFreeAdaptor(pa);
- continue;
- }
-
- adaptorPriv->flags = adaptorPtr->flags;
- adaptorPriv->PutVideo = adaptorPtr->PutVideo;
- adaptorPriv->PutStill = adaptorPtr->PutStill;
- adaptorPriv->GetVideo = adaptorPtr->GetVideo;
- adaptorPriv->GetStill = adaptorPtr->GetStill;
- adaptorPriv->StopVideo = adaptorPtr->StopVideo;
- adaptorPriv->SetPortAttribute = adaptorPtr->SetPortAttribute;
- adaptorPriv->GetPortAttribute = adaptorPtr->GetPortAttribute;
- adaptorPriv->QueryBestSize = adaptorPtr->QueryBestSize;
- adaptorPriv->QueryImageAttributes = adaptorPtr->QueryImageAttributes;
- adaptorPriv->PutImage = adaptorPtr->PutImage;
- adaptorPriv->ReputImage = adaptorPtr->ReputImage; /* image/still */
-
- pa->devPriv.ptr = (pointer)adaptorPriv;
-
- if(!(pPort = calloc(adaptorPtr->nPorts, sizeof(XvPortRec)))) {
- xf86XVFreeAdaptor(pa);
- continue;
- }
- for(pp = pPort, i = 0, numPort = 0;
- i < adaptorPtr->nPorts; i++) {
-
- if(!(pp->id = FakeClientID(0)))
- continue;
-
- if(!(portPriv = calloc(1, sizeof(XvPortRecPrivate))))
- continue;
-
- if(!AddResource(pp->id, PortResource, pp)) {
- free(portPriv);
- continue;
- }
-
- pp->pAdaptor = pa;
- pp->pNotify = (XvPortNotifyPtr)NULL;
- pp->pDraw = (DrawablePtr)NULL;
- pp->client = (ClientPtr)NULL;
- pp->grab.client = (ClientPtr)NULL;
- pp->time = currentTime;
- pp->devPriv.ptr = portPriv;
-
- portPriv->pScrn = pScrn;
- portPriv->AdaptorRec = adaptorPriv;
- portPriv->DevPriv.ptr = adaptorPtr->pPortPrivates[i].ptr;
-
- pp++;
- numPort++;
- }
- pa->nPorts = numPort;
- pa->pPorts = pPort;
- if(!numPort) {
- xf86XVFreeAdaptor(pa);
- continue;
- }
-
- pa->base_id = pPort->id;
-
- pa++;
- numAdaptor++;
- }
-
- if(numAdaptor) {
- pxvs->nAdaptors = numAdaptor;
- pxvs->pAdaptors = pAdaptor;
- } else {
- free(pAdaptor);
- return FALSE;
- }
-
- return TRUE;
+xf86XVInitAdaptors(ScreenPtr pScreen, XF86VideoAdaptorPtr * infoPtr, int number)
+{
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ XF86VideoAdaptorPtr adaptorPtr;
+ XvAdaptorPtr pAdaptor, pa;
+ XvAdaptorRecPrivatePtr adaptorPriv;
+ int na, numAdaptor;
+ XvPortRecPrivatePtr portPriv;
+ XvPortPtr pPort, pp;
+ int numPort;
+ XF86AttributePtr attributePtr;
+ XvAttributePtr pAttribute, pat;
+ XF86VideoFormatPtr formatPtr;
+ XvFormatPtr pFormat, pf;
+ int numFormat, totFormat;
+ XF86VideoEncodingPtr encodingPtr;
+ XvEncodingPtr pEncode, pe;
+ XF86ImagePtr imagePtr;
+ XvImagePtr pImage, pi;
+ int numVisuals;
+ VisualPtr pVisual;
+ int i;
+
+ pxvs->nAdaptors = 0;
+ pxvs->pAdaptors = NULL;
+
+ if (!(pAdaptor = calloc(number, sizeof(XvAdaptorRec))))
+ return FALSE;
+
+ for (pa = pAdaptor, na = 0, numAdaptor = 0; na < number; na++, adaptorPtr++) {
+ adaptorPtr = infoPtr[na];
+
+ if (!adaptorPtr->StopVideo || !adaptorPtr->SetPortAttribute ||
+ !adaptorPtr->GetPortAttribute || !adaptorPtr->QueryBestSize)
+ continue;
+
+ /* client libs expect at least one encoding */
+ if (!adaptorPtr->nEncodings || !adaptorPtr->pEncodings)
+ continue;
+
+ pa->type = adaptorPtr->type;
+
+ if (!adaptorPtr->PutVideo && !adaptorPtr->GetVideo)
+ pa->type &= ~XvVideoMask;
+
+ if (!adaptorPtr->PutStill && !adaptorPtr->GetStill)
+ pa->type &= ~XvStillMask;
+
+ if (!adaptorPtr->PutImage || !adaptorPtr->QueryImageAttributes)
+ pa->type &= ~XvImageMask;
+
+ if (!adaptorPtr->PutVideo && !adaptorPtr->PutImage &&
+ !adaptorPtr->PutStill)
+ pa->type &= ~XvInputMask;
+
+ if (!adaptorPtr->GetVideo && !adaptorPtr->GetStill)
+ pa->type &= ~XvOutputMask;
+
+ if (!(adaptorPtr->type & (XvPixmapMask | XvWindowMask)))
+ continue;
+ if (!(adaptorPtr->type & (XvImageMask | XvVideoMask | XvStillMask)))
+ continue;
+
+ pa->pScreen = pScreen;
+ pa->ddAllocatePort = xf86XVAllocatePort;
+ pa->ddFreePort = xf86XVFreePort;
+ pa->ddPutVideo = xf86XVPutVideo;
+ pa->ddPutStill = xf86XVPutStill;
+ pa->ddGetVideo = xf86XVGetVideo;
+ pa->ddGetStill = xf86XVGetStill;
+ pa->ddStopVideo = xf86XVStopVideo;
+ pa->ddPutImage = xf86XVPutImage;
+ pa->ddSetPortAttribute = xf86XVSetPortAttribute;
+ pa->ddGetPortAttribute = xf86XVGetPortAttribute;
+ pa->ddQueryBestSize = xf86XVQueryBestSize;
+ pa->ddQueryImageAttributes = xf86XVQueryImageAttributes;
+ pa->name = strdup(adaptorPtr->name);
+
+ if (adaptorPtr->nEncodings &&
+ (pEncode = calloc(adaptorPtr->nEncodings, sizeof(XvEncodingRec)))) {
+
+ for (pe = pEncode, encodingPtr = adaptorPtr->pEncodings, i = 0;
+ i < adaptorPtr->nEncodings; pe++, i++, encodingPtr++) {
+ pe->id = encodingPtr->id;
+ pe->pScreen = pScreen;
+ pe->name = strdup(encodingPtr->name);
+ pe->width = encodingPtr->width;
+ pe->height = encodingPtr->height;
+ pe->rate.numerator = encodingPtr->rate.numerator;
+ pe->rate.denominator = encodingPtr->rate.denominator;
+ }
+ pa->nEncodings = adaptorPtr->nEncodings;
+ pa->pEncodings = pEncode;
+ }
+
+ if (adaptorPtr->nImages &&
+ (pImage = calloc(adaptorPtr->nImages, sizeof(XvImageRec)))) {
+
+ for (i = 0, pi = pImage, imagePtr = adaptorPtr->pImages;
+ i < adaptorPtr->nImages; i++, pi++, imagePtr++) {
+ pi->id = imagePtr->id;
+ pi->type = imagePtr->type;
+ pi->byte_order = imagePtr->byte_order;
+ memcpy(pi->guid, imagePtr->guid, 16);
+ pi->bits_per_pixel = imagePtr->bits_per_pixel;
+ pi->format = imagePtr->format;
+ pi->num_planes = imagePtr->num_planes;
+ pi->depth = imagePtr->depth;
+ pi->red_mask = imagePtr->red_mask;
+ pi->green_mask = imagePtr->green_mask;
+ pi->blue_mask = imagePtr->blue_mask;
+ pi->y_sample_bits = imagePtr->y_sample_bits;
+ pi->u_sample_bits = imagePtr->u_sample_bits;
+ pi->v_sample_bits = imagePtr->v_sample_bits;
+ pi->horz_y_period = imagePtr->horz_y_period;
+ pi->horz_u_period = imagePtr->horz_u_period;
+ pi->horz_v_period = imagePtr->horz_v_period;
+ pi->vert_y_period = imagePtr->vert_y_period;
+ pi->vert_u_period = imagePtr->vert_u_period;
+ pi->vert_v_period = imagePtr->vert_v_period;
+ memcpy(pi->component_order, imagePtr->component_order, 32);
+ pi->scanline_order = imagePtr->scanline_order;
+ }
+ pa->nImages = adaptorPtr->nImages;
+ pa->pImages = pImage;
+ }
+
+ if (adaptorPtr->nAttributes &&
+ (pAttribute =
+ calloc(adaptorPtr->nAttributes, sizeof(XvAttributeRec)))) {
+ for (pat = pAttribute, attributePtr = adaptorPtr->pAttributes, i =
+ 0; i < adaptorPtr->nAttributes; pat++, i++, attributePtr++) {
+ pat->flags = attributePtr->flags;
+ pat->min_value = attributePtr->min_value;
+ pat->max_value = attributePtr->max_value;
+ pat->name = strdup(attributePtr->name);
+ }
+ pa->nAttributes = adaptorPtr->nAttributes;
+ pa->pAttributes = pAttribute;
+ }
+
+ totFormat = adaptorPtr->nFormats;
+
+ if (!(pFormat = calloc(totFormat, sizeof(XvFormatRec)))) {
+ xf86XVFreeAdaptor(pa);
+ continue;
+ }
+ for (pf = pFormat, i = 0, numFormat = 0, formatPtr =
+ adaptorPtr->pFormats; i < adaptorPtr->nFormats; i++, formatPtr++) {
+ numVisuals = pScreen->numVisuals;
+ pVisual = pScreen->visuals;
+
+ while (numVisuals--) {
+ if ((pVisual->class == formatPtr->class) &&
+ (pVisual->nplanes == formatPtr->depth)) {
+
+ if (numFormat >= totFormat) {
+ void *moreSpace;
+
+ totFormat *= 2;
+ moreSpace = realloc(pFormat,
+ totFormat * sizeof(XvFormatRec));
+ if (!moreSpace)
+ break;
+ pFormat = moreSpace;
+ pf = pFormat + numFormat;
+ }
+
+ pf->visual = pVisual->vid;
+ pf->depth = formatPtr->depth;
+
+ pf++;
+ numFormat++;
+ }
+ pVisual++;
+ }
+ }
+ pa->nFormats = numFormat;
+ pa->pFormats = pFormat;
+ if (!numFormat) {
+ xf86XVFreeAdaptor(pa);
+ continue;
+ }
+
+ if (!(adaptorPriv = calloc(1, sizeof(XvAdaptorRecPrivate)))) {
+ xf86XVFreeAdaptor(pa);
+ continue;
+ }
+
+ adaptorPriv->flags = adaptorPtr->flags;
+ adaptorPriv->PutVideo = adaptorPtr->PutVideo;
+ adaptorPriv->PutStill = adaptorPtr->PutStill;
+ adaptorPriv->GetVideo = adaptorPtr->GetVideo;
+ adaptorPriv->GetStill = adaptorPtr->GetStill;
+ adaptorPriv->StopVideo = adaptorPtr->StopVideo;
+ adaptorPriv->SetPortAttribute = adaptorPtr->SetPortAttribute;
+ adaptorPriv->GetPortAttribute = adaptorPtr->GetPortAttribute;
+ adaptorPriv->QueryBestSize = adaptorPtr->QueryBestSize;
+ adaptorPriv->QueryImageAttributes = adaptorPtr->QueryImageAttributes;
+ adaptorPriv->PutImage = adaptorPtr->PutImage;
+ adaptorPriv->ReputImage = adaptorPtr->ReputImage; /* image/still */
+
+ pa->devPriv.ptr = (pointer) adaptorPriv;
+
+ if (!(pPort = calloc(adaptorPtr->nPorts, sizeof(XvPortRec)))) {
+ xf86XVFreeAdaptor(pa);
+ continue;
+ }
+ for (pp = pPort, i = 0, numPort = 0; i < adaptorPtr->nPorts; i++) {
+
+ if (!(pp->id = FakeClientID(0)))
+ continue;
+
+ if (!(portPriv = calloc(1, sizeof(XvPortRecPrivate))))
+ continue;
+
+ if (!AddResource(pp->id, PortResource, pp)) {
+ free(portPriv);
+ continue;
+ }
+
+ pp->pAdaptor = pa;
+ pp->pNotify = (XvPortNotifyPtr) NULL;
+ pp->pDraw = (DrawablePtr) NULL;
+ pp->client = (ClientPtr) NULL;
+ pp->grab.client = (ClientPtr) NULL;
+ pp->time = currentTime;
+ pp->devPriv.ptr = portPriv;
+
+ portPriv->pScrn = pScrn;
+ portPriv->AdaptorRec = adaptorPriv;
+ portPriv->DevPriv.ptr = adaptorPtr->pPortPrivates[i].ptr;
+
+ pp++;
+ numPort++;
+ }
+ pa->nPorts = numPort;
+ pa->pPorts = pPort;
+ if (!numPort) {
+ xf86XVFreeAdaptor(pa);
+ continue;
+ }
+
+ pa->base_id = pPort->id;
+
+ pa++;
+ numAdaptor++;
+ }
+
+ if (numAdaptor) {
+ pxvs->nAdaptors = numAdaptor;
+ pxvs->pAdaptors = pAdaptor;
+ }
+ else {
+ free(pAdaptor);
+ return FALSE;
+ }
+
+ return TRUE;
}
/* Video should be clipped to the intersection of the window cliplist
@@ -650,66 +635,64 @@ xf86XVInitAdaptors(
static void
xf86XVUpdateCompositeClip(XvPortRecPrivatePtr portPriv)
{
- RegionPtr pregWin, pCompositeClip;
- WindowPtr pWin;
- Bool freeCompClip = FALSE;
-
- if(portPriv->pCompositeClip)
- return;
-
- pWin = (WindowPtr)portPriv->pDraw;
-
- /* get window clip list */
- if(portPriv->subWindowMode == IncludeInferiors) {
- pregWin = NotClippedByChildren(pWin);
- freeCompClip = TRUE;
- } else
- pregWin = &pWin->clipList;
-
- if(!portPriv->clientClip) {
- portPriv->pCompositeClip = pregWin;
- portPriv->FreeCompositeClip = freeCompClip;
- return;
- }
-
- pCompositeClip = RegionCreate(NullBox, 1);
- RegionCopy(pCompositeClip, portPriv->clientClip);
- RegionTranslate(pCompositeClip,
- portPriv->pDraw->x, portPriv->pDraw->y);
- RegionIntersect(pCompositeClip, pregWin, pCompositeClip);
-
- portPriv->pCompositeClip = pCompositeClip;
- portPriv->FreeCompositeClip = TRUE;
-
- if(freeCompClip) {
- RegionDestroy(pregWin);
- }
+ RegionPtr pregWin, pCompositeClip;
+ WindowPtr pWin;
+ Bool freeCompClip = FALSE;
+
+ if (portPriv->pCompositeClip)
+ return;
+
+ pWin = (WindowPtr) portPriv->pDraw;
+
+ /* get window clip list */
+ if (portPriv->subWindowMode == IncludeInferiors) {
+ pregWin = NotClippedByChildren(pWin);
+ freeCompClip = TRUE;
+ }
+ else
+ pregWin = &pWin->clipList;
+
+ if (!portPriv->clientClip) {
+ portPriv->pCompositeClip = pregWin;
+ portPriv->FreeCompositeClip = freeCompClip;
+ return;
+ }
+
+ pCompositeClip = RegionCreate(NullBox, 1);
+ RegionCopy(pCompositeClip, portPriv->clientClip);
+ RegionTranslate(pCompositeClip, portPriv->pDraw->x, portPriv->pDraw->y);
+ RegionIntersect(pCompositeClip, pregWin, pCompositeClip);
+
+ portPriv->pCompositeClip = pCompositeClip;
+ portPriv->FreeCompositeClip = TRUE;
+
+ if (freeCompClip) {
+ RegionDestroy(pregWin);
+ }
}
/* Save the current clientClip and update the CompositeClip whenever
we have a fresh GC */
static void
-xf86XVCopyClip(
- XvPortRecPrivatePtr portPriv,
- GCPtr pGC
-){
+xf86XVCopyClip(XvPortRecPrivatePtr portPriv, GCPtr pGC)
+{
/* copy the new clip if it exists */
- if((pGC->clientClipType == CT_REGION) && pGC->clientClip) {
- if(!portPriv->clientClip)
- portPriv->clientClip = RegionCreate(NullBox, 1);
- /* Note: this is in window coordinates */
- RegionCopy(portPriv->clientClip, pGC->clientClip);
- RegionTranslate(portPriv->clientClip,
- pGC->clipOrg.x, pGC->clipOrg.y);
- } else if(portPriv->clientClip) { /* free the old clientClip */
- RegionDestroy(portPriv->clientClip);
- portPriv->clientClip = NULL;
+ if ((pGC->clientClipType == CT_REGION) && pGC->clientClip) {
+ if (!portPriv->clientClip)
+ portPriv->clientClip = RegionCreate(NullBox, 1);
+ /* Note: this is in window coordinates */
+ RegionCopy(portPriv->clientClip, pGC->clientClip);
+ RegionTranslate(portPriv->clientClip, pGC->clipOrg.x, pGC->clipOrg.y);
+ }
+ else if (portPriv->clientClip) { /* free the old clientClip */
+ RegionDestroy(portPriv->clientClip);
+ portPriv->clientClip = NULL;
}
/* get rid of the old clip list */
- if(portPriv->pCompositeClip && portPriv->FreeCompositeClip) {
- RegionDestroy(portPriv->pCompositeClip);
+ if (portPriv->pCompositeClip && portPriv->FreeCompositeClip) {
+ RegionDestroy(portPriv->pCompositeClip);
}
portPriv->pCompositeClip = pGC->pCompositeClip;
@@ -719,19 +702,17 @@ xf86XVCopyClip(
static void
xf86XVCopyCompositeClip(XvPortRecPrivatePtr portPriv,
- GCPtr pGC,
- DrawablePtr pDraw)
+ GCPtr pGC, DrawablePtr pDraw)
{
if (!portPriv->clientClip)
- portPriv->clientClip = RegionCreate(NullBox, 1);
+ portPriv->clientClip = RegionCreate(NullBox, 1);
/* Keep the original GC composite clip around for ReputImage */
RegionCopy(portPriv->clientClip, pGC->pCompositeClip);
- RegionTranslate(portPriv->clientClip,
- -pDraw->x, -pDraw->y);
+ RegionTranslate(portPriv->clientClip, -pDraw->x, -pDraw->y);
/* get rid of the old clip list */
if (portPriv->pCompositeClip && portPriv->FreeCompositeClip)
- RegionDestroy(portPriv->pCompositeClip);
+ RegionDestroy(portPriv->pCompositeClip);
portPriv->pCompositeClip = pGC->pCompositeClip;
portPriv->FreeCompositeClip = FALSE;
@@ -741,257 +722,257 @@ xf86XVCopyCompositeClip(XvPortRecPrivatePtr portPriv,
static int
xf86XVRegetVideo(XvPortRecPrivatePtr portPriv)
{
- RegionRec WinRegion;
- RegionRec ClipRegion;
- BoxRec WinBox;
- int ret = Success;
- Bool clippedAway = FALSE;
-
- xf86XVUpdateCompositeClip(portPriv);
-
- /* translate the video region to the screen */
- WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
- WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
- WinBox.x2 = WinBox.x1 + portPriv->drw_w;
- WinBox.y2 = WinBox.y1 + portPriv->drw_h;
-
- /* clip to the window composite clip */
- RegionInit(&WinRegion, &WinBox, 1);
- RegionNull(&ClipRegion);
- RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
-
- /* that's all if it's totally obscured */
- if(!RegionNotEmpty(&ClipRegion)) {
- clippedAway = TRUE;
- goto CLIP_VIDEO_BAILOUT;
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
- ret = (*portPriv->AdaptorRec->GetVideo)(portPriv->pScrn,
- portPriv->vid_x, portPriv->vid_y,
- WinBox.x1, WinBox.y1,
- portPriv->vid_w, portPriv->vid_h,
- portPriv->drw_w, portPriv->drw_h,
- &ClipRegion, portPriv->DevPriv.ptr,
- portPriv->pDraw);
-
- if(ret == Success)
- portPriv->isOn = XV_ON;
-
-CLIP_VIDEO_BAILOUT:
-
- if((clippedAway || (ret != Success)) && portPriv->isOn == XV_ON) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = XV_PENDING;
- }
-
- /* This clip was copied and only good for one shot */
- if(!portPriv->FreeCompositeClip)
- portPriv->pCompositeClip = NULL;
-
- RegionUninit(&WinRegion);
- RegionUninit(&ClipRegion);
-
- return ret;
-}
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ xf86XVUpdateCompositeClip(portPriv);
+
+ /* translate the video region to the screen */
+ WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
+ WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
+ WinBox.x2 = WinBox.x1 + portPriv->drw_w;
+ WinBox.y2 = WinBox.y1 + portPriv->drw_h;
+
+ /* clip to the window composite clip */
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
+
+ /* that's all if it's totally obscured */
+ if (!RegionNotEmpty(&ClipRegion)) {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+
+ if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->GetVideo) (portPriv->pScrn,
+ portPriv->vid_x, portPriv->vid_y,
+ WinBox.x1, WinBox.y1,
+ portPriv->vid_w, portPriv->vid_h,
+ portPriv->drw_w, portPriv->drw_h,
+ &ClipRegion, portPriv->DevPriv.ptr,
+ portPriv->pDraw);
+
+ if (ret == Success)
+ portPriv->isOn = XV_ON;
+
+ CLIP_VIDEO_BAILOUT:
+
+ if ((clippedAway || (ret != Success)) && portPriv->isOn == XV_ON) {
+ (*portPriv->AdaptorRec->StopVideo) (portPriv->pScrn,
+ portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+ /* This clip was copied and only good for one shot */
+ if (!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
+
+ return ret;
+}
static int
xf86XVReputVideo(XvPortRecPrivatePtr portPriv)
{
- RegionRec WinRegion;
- RegionRec ClipRegion;
- BoxRec WinBox;
- int ret = Success;
- Bool clippedAway = FALSE;
-
- xf86XVUpdateCompositeClip(portPriv);
-
- /* translate the video region to the screen */
- WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
- WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
- WinBox.x2 = WinBox.x1 + portPriv->drw_w;
- WinBox.y2 = WinBox.y1 + portPriv->drw_h;
-
- /* clip to the window composite clip */
- RegionInit(&WinRegion, &WinBox, 1);
- RegionNull(&ClipRegion);
- RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
-
- /* clip and translate to the viewport */
- if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
- RegionRec VPReg;
- BoxRec VPBox;
-
- VPBox.x1 = portPriv->pScrn->frameX0;
- VPBox.y1 = portPriv->pScrn->frameY0;
- VPBox.x2 = portPriv->pScrn->frameX1 + 1;
- VPBox.y2 = portPriv->pScrn->frameY1 + 1;
-
- RegionInit(&VPReg, &VPBox, 1);
- RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
- RegionUninit(&VPReg);
- }
-
- /* that's all if it's totally obscured */
- if(!RegionNotEmpty(&ClipRegion)) {
- clippedAway = TRUE;
- goto CLIP_VIDEO_BAILOUT;
- }
-
- /* bailout if we have to clip but the hardware doesn't support it */
- if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = RegionRects(&ClipRegion);
- if( (RegionNumRects(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
- {
- clippedAway = TRUE;
- goto CLIP_VIDEO_BAILOUT;
- }
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
- ret = (*portPriv->AdaptorRec->PutVideo)(portPriv->pScrn,
- portPriv->vid_x, portPriv->vid_y,
- WinBox.x1, WinBox.y1,
- portPriv->vid_w, portPriv->vid_h,
- portPriv->drw_w, portPriv->drw_h,
- &ClipRegion, portPriv->DevPriv.ptr,
- portPriv->pDraw);
-
- if(ret == Success) portPriv->isOn = XV_ON;
-
-CLIP_VIDEO_BAILOUT:
-
- if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = XV_PENDING;
- }
-
- /* This clip was copied and only good for one shot */
- if(!portPriv->FreeCompositeClip)
- portPriv->pCompositeClip = NULL;
-
- RegionUninit(&WinRegion);
- RegionUninit(&ClipRegion);
-
- return ret;
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ xf86XVUpdateCompositeClip(portPriv);
+
+ /* translate the video region to the screen */
+ WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
+ WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
+ WinBox.x2 = WinBox.x1 + portPriv->drw_w;
+ WinBox.y2 = WinBox.y1 + portPriv->drw_h;
+
+ /* clip to the window composite clip */
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
+
+ /* clip and translate to the viewport */
+ if (portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = portPriv->pScrn->frameX0;
+ VPBox.y1 = portPriv->pScrn->frameY0;
+ VPBox.x2 = portPriv->pScrn->frameX1 + 1;
+ VPBox.y2 = portPriv->pScrn->frameY1 + 1;
+
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
+ }
+
+ /* that's all if it's totally obscured */
+ if (!RegionNotEmpty(&ClipRegion)) {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+
+ /* bailout if we have to clip but the hardware doesn't support it */
+ if (portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+
+ if ((RegionNumRects(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+ }
+
+ if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->PutVideo) (portPriv->pScrn,
+ portPriv->vid_x, portPriv->vid_y,
+ WinBox.x1, WinBox.y1,
+ portPriv->vid_w, portPriv->vid_h,
+ portPriv->drw_w, portPriv->drw_h,
+ &ClipRegion, portPriv->DevPriv.ptr,
+ portPriv->pDraw);
+
+ if (ret == Success)
+ portPriv->isOn = XV_ON;
+
+ CLIP_VIDEO_BAILOUT:
+
+ if ((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo) (portPriv->pScrn,
+ portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ /* This clip was copied and only good for one shot */
+ if (!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
+
+ return ret;
}
/* Reput image/still */
static int
xf86XVReputImage(XvPortRecPrivatePtr portPriv)
{
- RegionRec WinRegion;
- RegionRec ClipRegion;
- BoxRec WinBox;
- int ret = Success;
- Bool clippedAway = FALSE;
-
- xf86XVUpdateCompositeClip(portPriv);
-
- /* the clip can get smaller over time */
- RegionCopy(portPriv->clientClip, portPriv->pCompositeClip);
- RegionTranslate(portPriv->clientClip,
- -portPriv->pDraw->x, -portPriv->pDraw->y);
-
- /* translate the video region to the screen */
- WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
- WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
- WinBox.x2 = WinBox.x1 + portPriv->drw_w;
- WinBox.y2 = WinBox.y1 + portPriv->drw_h;
-
- /* clip to the window composite clip */
- RegionInit(&WinRegion, &WinBox, 1);
- RegionNull(&ClipRegion);
- RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
-
- /* clip and translate to the viewport */
- if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
- RegionRec VPReg;
- BoxRec VPBox;
-
- VPBox.x1 = portPriv->pScrn->frameX0;
- VPBox.y1 = portPriv->pScrn->frameY0;
- VPBox.x2 = portPriv->pScrn->frameX1 + 1;
- VPBox.y2 = portPriv->pScrn->frameY1 + 1;
-
- RegionInit(&VPReg, &VPBox, 1);
- RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
- RegionUninit(&VPReg);
- }
-
- /* that's all if it's totally obscured */
- if(!RegionNotEmpty(&ClipRegion)) {
- clippedAway = TRUE;
- goto CLIP_VIDEO_BAILOUT;
- }
-
- /* bailout if we have to clip but the hardware doesn't support it */
- if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = RegionRects(&ClipRegion);
- if( (RegionNumRects(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
- {
- clippedAway = TRUE;
- goto CLIP_VIDEO_BAILOUT;
- }
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
- ret = (*portPriv->AdaptorRec->ReputImage)(portPriv->pScrn,
- portPriv->vid_x, portPriv->vid_y,
- WinBox.x1, WinBox.y1,
- portPriv->vid_w, portPriv->vid_h,
- portPriv->drw_w, portPriv->drw_h,
- &ClipRegion, portPriv->DevPriv.ptr,
- portPriv->pDraw);
-
- portPriv->isOn = (ret == Success) ? XV_ON : XV_OFF;
-
-CLIP_VIDEO_BAILOUT:
-
- if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = XV_PENDING;
- }
-
- /* This clip was copied and only good for one shot */
- if(!portPriv->FreeCompositeClip)
- portPriv->pCompositeClip = NULL;
-
- RegionUninit(&WinRegion);
- RegionUninit(&ClipRegion);
-
- return ret;
-}
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ xf86XVUpdateCompositeClip(portPriv);
+
+ /* the clip can get smaller over time */
+ RegionCopy(portPriv->clientClip, portPriv->pCompositeClip);
+ RegionTranslate(portPriv->clientClip,
+ -portPriv->pDraw->x, -portPriv->pDraw->y);
+
+ /* translate the video region to the screen */
+ WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
+ WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
+ WinBox.x2 = WinBox.x1 + portPriv->drw_w;
+ WinBox.y2 = WinBox.y1 + portPriv->drw_h;
+
+ /* clip to the window composite clip */
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
+
+ /* clip and translate to the viewport */
+ if (portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = portPriv->pScrn->frameX0;
+ VPBox.y1 = portPriv->pScrn->frameY0;
+ VPBox.x2 = portPriv->pScrn->frameX1 + 1;
+ VPBox.y2 = portPriv->pScrn->frameY1 + 1;
+
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
+ }
+
+ /* that's all if it's totally obscured */
+ if (!RegionNotEmpty(&ClipRegion)) {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+
+ /* bailout if we have to clip but the hardware doesn't support it */
+ if (portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+
+ if ((RegionNumRects(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+ }
+
+ if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->ReputImage) (portPriv->pScrn,
+ portPriv->vid_x, portPriv->vid_y,
+ WinBox.x1, WinBox.y1,
+ portPriv->vid_w, portPriv->vid_h,
+ portPriv->drw_w, portPriv->drw_h,
+ &ClipRegion,
+ portPriv->DevPriv.ptr,
+ portPriv->pDraw);
+ portPriv->isOn = (ret == Success) ? XV_ON : XV_OFF;
+
+ CLIP_VIDEO_BAILOUT:
+
+ if ((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo) (portPriv->pScrn,
+ portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ /* This clip was copied and only good for one shot */
+ if (!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
+
+ return ret;
+}
static int
xf86XVReputAllVideo(WindowPtr pWin, pointer data)
{
XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin);
- while(WinPriv) {
- if(WinPriv->PortRec->type == XvInputMask)
- xf86XVReputVideo(WinPriv->PortRec);
- else
- xf86XVRegetVideo(WinPriv->PortRec);
- WinPriv = WinPriv->next;
+ while (WinPriv) {
+ if (WinPriv->PortRec->type == XvInputMask)
+ xf86XVReputVideo(WinPriv->PortRec);
+ else
+ xf86XVRegetVideo(WinPriv->PortRec);
+ WinPriv = WinPriv->next;
}
return WT_WALKCHILDREN;
@@ -1000,86 +981,86 @@ xf86XVReputAllVideo(WindowPtr pWin, pointer data)
static int
xf86XVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
{
- XF86XVWindowPtr winPriv, PrivRoot;
+ XF86XVWindowPtr winPriv, PrivRoot;
- winPriv = PrivRoot = GET_XF86XV_WINDOW(pWin);
+ winPriv = PrivRoot = GET_XF86XV_WINDOW(pWin);
- /* Enlist our port in the window private */
- while(winPriv) {
- if(winPriv->PortRec == portPriv) /* we're already listed */
- break;
- winPriv = winPriv->next;
- }
+ /* Enlist our port in the window private */
+ while (winPriv) {
+ if (winPriv->PortRec == portPriv) /* we're already listed */
+ break;
+ winPriv = winPriv->next;
+ }
- if(!winPriv) {
- winPriv = calloc(1, sizeof(XF86XVWindowRec));
- if(!winPriv) return BadAlloc;
- winPriv->PortRec = portPriv;
- winPriv->next = PrivRoot;
- dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, winPriv);
- }
+ if (!winPriv) {
+ winPriv = calloc(1, sizeof(XF86XVWindowRec));
+ if (!winPriv)
+ return BadAlloc;
+ winPriv->PortRec = portPriv;
+ winPriv->next = PrivRoot;
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, winPriv);
+ }
- portPriv->pDraw = (DrawablePtr)pWin;
+ portPriv->pDraw = (DrawablePtr) pWin;
- return Success;
+ return Success;
}
-
static void
xf86XVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
{
- XF86XVWindowPtr winPriv, prevPriv = NULL;
- winPriv = GET_XF86XV_WINDOW(pWin);
-
- while(winPriv) {
- if(winPriv->PortRec == portPriv) {
- if(prevPriv)
- prevPriv->next = winPriv->next;
- else
- dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey,
- winPriv->next);
- free(winPriv);
- break;
- }
- prevPriv = winPriv;
- winPriv = winPriv->next;
- }
- portPriv->pDraw = NULL;
- if (portPriv->ckeyFilled) {
- RegionDestroy(portPriv->ckeyFilled);
- portPriv->ckeyFilled = NULL;
- }
- portPriv->clipChanged = FALSE;
+ XF86XVWindowPtr winPriv, prevPriv = NULL;
+
+ winPriv = GET_XF86XV_WINDOW(pWin);
+
+ while (winPriv) {
+ if (winPriv->PortRec == portPriv) {
+ if (prevPriv)
+ prevPriv->next = winPriv->next;
+ else
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey,
+ winPriv->next);
+ free(winPriv);
+ break;
+ }
+ prevPriv = winPriv;
+ winPriv = winPriv->next;
+ }
+ portPriv->pDraw = NULL;
+ if (portPriv->ckeyFilled) {
+ RegionDestroy(portPriv->ckeyFilled);
+ portPriv->ckeyFilled = NULL;
+ }
+ portPriv->clipChanged = FALSE;
}
static void
-xf86XVReputOrStopPort(XvPortRecPrivatePtr pPriv,
- WindowPtr pWin,
- Bool visible)
+xf86XVReputOrStopPort(XvPortRecPrivatePtr pPriv, WindowPtr pWin, Bool visible)
{
if (!visible) {
- if (pPriv->isOn == XV_ON) {
- (*pPriv->AdaptorRec->StopVideo)(pPriv->pScrn, pPriv->DevPriv.ptr, FALSE);
- pPriv->isOn = XV_PENDING;
- }
+ if (pPriv->isOn == XV_ON) {
+ (*pPriv->AdaptorRec->StopVideo) (pPriv->pScrn, pPriv->DevPriv.ptr,
+ FALSE);
+ pPriv->isOn = XV_PENDING;
+ }
- if (!pPriv->type) /* overlaid still/image*/
- xf86XVRemovePortFromWindow(pWin, pPriv);
+ if (!pPriv->type) /* overlaid still/image */
+ xf86XVRemovePortFromWindow(pWin, pPriv);
- return;
+ return;
}
switch (pPriv->type) {
case XvInputMask:
- xf86XVReputVideo(pPriv);
- break;
+ xf86XVReputVideo(pPriv);
+ break;
case XvOutputMask:
- xf86XVRegetVideo(pPriv);
- break;
- default: /* overlaid still/image*/
- if (pPriv->AdaptorRec->ReputImage)
- xf86XVReputImage(pPriv);
- break;
+ xf86XVRegetVideo(pPriv);
+ break;
+ default: /* overlaid still/image */
+ if (pPriv->AdaptorRec->ReputImage)
+ xf86XVReputImage(pPriv);
+ break;
}
}
@@ -1092,33 +1073,34 @@ xf86XVReputOrStopAllPorts(ScrnInfoPtr pScrn, Bool onlyChanged)
int c, i;
for (c = pxvs->nAdaptors, pa = pxvs->pAdaptors; c > 0; c--, pa++) {
- XvPortPtr pPort = pa->pPorts;
+ XvPortPtr pPort = pa->pPorts;
- for (i = pa->nPorts; i > 0; i--, pPort++) {
- XvPortRecPrivatePtr pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
- WindowPtr pWin = (WindowPtr)pPriv->pDraw;
- Bool visible;
+ for (i = pa->nPorts; i > 0; i--, pPort++) {
+ XvPortRecPrivatePtr pPriv =
+ (XvPortRecPrivatePtr) pPort->devPriv.ptr;
+ WindowPtr pWin = (WindowPtr) pPriv->pDraw;
+ Bool visible;
- if (pPriv->isOn == XV_OFF || !pWin)
- continue;
+ if (pPriv->isOn == XV_OFF || !pWin)
+ continue;
- if (onlyChanged && !pPriv->clipChanged)
- continue;
+ if (onlyChanged && !pPriv->clipChanged)
+ continue;
- visible = pWin->visibility == VisibilityUnobscured ||
- pWin->visibility == VisibilityPartiallyObscured;
+ visible = pWin->visibility == VisibilityUnobscured ||
+ pWin->visibility == VisibilityPartiallyObscured;
- /*
- * Stop and remove still/images if
- * ReputImage isn't supported.
- */
- if (!pPriv->type && !pPriv->AdaptorRec->ReputImage)
- visible = FALSE;
+ /*
+ * Stop and remove still/images if
+ * ReputImage isn't supported.
+ */
+ if (!pPriv->type && !pPriv->AdaptorRec->ReputImage)
+ visible = FALSE;
- xf86XVReputOrStopPort(pPriv, pWin, visible);
+ xf86XVReputOrStopPort(pPriv, pWin, visible);
- pPriv->clipChanged = FALSE;
- }
+ pPriv->clipChanged = FALSE;
+ }
}
}
@@ -1127,33 +1109,33 @@ xf86XVReputOrStopAllPorts(ScrnInfoPtr pScrn, Bool onlyChanged)
static Bool
xf86XVDestroyWindow(WindowPtr pWin)
{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
- XF86XVWindowPtr tmp, WinPriv = GET_XF86XV_WINDOW(pWin);
- int ret;
-
- while(WinPriv) {
- XvPortRecPrivatePtr pPriv = WinPriv->PortRec;
-
- if(pPriv->isOn > XV_OFF) {
- (*pPriv->AdaptorRec->StopVideo)(
- pPriv->pScrn, pPriv->DevPriv.ptr, TRUE);
- pPriv->isOn = XV_OFF;
- }
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ XF86XVWindowPtr tmp, WinPriv = GET_XF86XV_WINDOW(pWin);
+ int ret;
- pPriv->pDraw = NULL;
- tmp = WinPriv;
- WinPriv = WinPriv->next;
- free(tmp);
- }
+ while (WinPriv) {
+ XvPortRecPrivatePtr pPriv = WinPriv->PortRec;
+
+ if (pPriv->isOn > XV_OFF) {
+ (*pPriv->AdaptorRec->StopVideo) (pPriv->pScrn, pPriv->DevPriv.ptr,
+ TRUE);
+ pPriv->isOn = XV_OFF;
+ }
+
+ pPriv->pDraw = NULL;
+ tmp = WinPriv;
+ WinPriv = WinPriv->next;
+ free(tmp);
+ }
- dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, NULL);
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, NULL);
- pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
- ret = (*pScreen->DestroyWindow)(pWin);
- pScreen->DestroyWindow = xf86XVDestroyWindow;
+ pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
+ ret = (*pScreen->DestroyWindow) (pWin);
+ pScreen->DestroyWindow = xf86XVDestroyWindow;
- return ret;
+ return ret;
}
static void
@@ -1164,9 +1146,9 @@ xf86XVPostValidateTree(WindowPtr pWin, WindowPtr pLayerWin, VTKind kind)
ScrnInfoPtr pScrn;
if (pWin)
- pScreen = pWin->drawable.pScreen;
+ pScreen = pWin->drawable.pScreen;
else
- pScreen = pLayerWin->drawable.pScreen;
+ pScreen = pLayerWin->drawable.pScreen;
ScreenPriv = GET_XF86XV_SCREEN(pScreen);
pScrn = xf86Screens[pScreen->myNum];
@@ -1175,7 +1157,7 @@ xf86XVPostValidateTree(WindowPtr pWin, WindowPtr pLayerWin, VTKind kind)
pScreen->PostValidateTree = ScreenPriv->PostValidateTree;
if (pScreen->PostValidateTree) {
- (*pScreen->PostValidateTree)(pWin, pLayerWin, kind);
+ (*pScreen->PostValidateTree) (pWin, pLayerWin, kind);
}
ScreenPriv->PostValidateTree = PostValidateTreeUndefined;
}
@@ -1183,140 +1165,137 @@ xf86XVPostValidateTree(WindowPtr pWin, WindowPtr pLayerWin, VTKind kind)
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);
- XvPortRecPrivatePtr pPriv;
- Bool AreasExposed;
-
- AreasExposed = (WinPriv && reg1 && RegionNotEmpty(reg1));
-
- pScreen->WindowExposures = ScreenPriv->WindowExposures;
- (*pScreen->WindowExposures)(pWin, reg1, reg2);
- pScreen->WindowExposures = xf86XVWindowExposures;
-
- /* filter out XClearWindow/Area */
- if (!pWin->valdata) return;
-
- while(WinPriv) {
- Bool visible = TRUE;
-
- pPriv = WinPriv->PortRec;
-
- /*
- * Stop and remove still/images if areas were exposed and
- * ReputImage isn't supported.
- */
- if (!pPriv->type && !pPriv->AdaptorRec->ReputImage)
- visible = !AreasExposed;
-
- /*
- * Subtract exposed areas from overlaid image to match textured video
- * behavior.
- */
- if (!pPriv->type && pPriv->clientClip)
- RegionSubtract(pPriv->clientClip, pPriv->clientClip, reg1);
-
- if (visible && pPriv->ckeyFilled) {
- RegionRec tmp;
- RegionNull(&tmp);
- RegionCopy(&tmp, reg1);
- RegionTranslate(&tmp, pWin->drawable.x, pWin->drawable.y);
- RegionSubtract(pPriv->ckeyFilled, pPriv->ckeyFilled, &tmp);
- }
-
- WinPriv = WinPriv->next;
- xf86XVReputOrStopPort(pPriv, pWin, visible);
-
- pPriv->clipChanged = FALSE;
- }
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin);
+ XvPortRecPrivatePtr pPriv;
+ Bool AreasExposed;
+
+ AreasExposed = (WinPriv && reg1 && RegionNotEmpty(reg1));
+
+ pScreen->WindowExposures = ScreenPriv->WindowExposures;
+ (*pScreen->WindowExposures) (pWin, reg1, reg2);
+ pScreen->WindowExposures = xf86XVWindowExposures;
+
+ /* filter out XClearWindow/Area */
+ if (!pWin->valdata)
+ return;
+
+ while (WinPriv) {
+ Bool visible = TRUE;
+
+ pPriv = WinPriv->PortRec;
+
+ /*
+ * Stop and remove still/images if areas were exposed and
+ * ReputImage isn't supported.
+ */
+ if (!pPriv->type && !pPriv->AdaptorRec->ReputImage)
+ visible = !AreasExposed;
+
+ /*
+ * Subtract exposed areas from overlaid image to match textured video
+ * behavior.
+ */
+ if (!pPriv->type && pPriv->clientClip)
+ RegionSubtract(pPriv->clientClip, pPriv->clientClip, reg1);
+
+ if (visible && pPriv->ckeyFilled) {
+ RegionRec tmp;
+
+ RegionNull(&tmp);
+ RegionCopy(&tmp, reg1);
+ RegionTranslate(&tmp, pWin->drawable.x, pWin->drawable.y);
+ RegionSubtract(pPriv->ckeyFilled, pPriv->ckeyFilled, &tmp);
+ }
+
+ WinPriv = WinPriv->next;
+ xf86XVReputOrStopPort(pPriv, pWin, visible);
+
+ pPriv->clipChanged = FALSE;
+ }
}
static void
xf86XVClipNotify(WindowPtr pWin, int dx, int dy)
{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
- XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin);
- XvPortRecPrivatePtr pPriv;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin);
+ XvPortRecPrivatePtr pPriv;
- while(WinPriv) {
- pPriv = WinPriv->PortRec;
+ while (WinPriv) {
+ pPriv = WinPriv->PortRec;
- if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
- RegionDestroy(pPriv->pCompositeClip);
+ if (pPriv->pCompositeClip && pPriv->FreeCompositeClip)
+ RegionDestroy(pPriv->pCompositeClip);
- pPriv->pCompositeClip = NULL;
+ pPriv->pCompositeClip = NULL;
- if (pPriv->AdaptorRec->ClipNotify)
- (*pPriv->AdaptorRec->ClipNotify)(pPriv->pScrn, pPriv->DevPriv.ptr,
- pWin, dx, dy);
+ if (pPriv->AdaptorRec->ClipNotify)
+ (*pPriv->AdaptorRec->ClipNotify) (pPriv->pScrn, pPriv->DevPriv.ptr,
+ pWin, dx, dy);
- pPriv->clipChanged = TRUE;
+ pPriv->clipChanged = TRUE;
- if (ScreenPriv->PostValidateTree == PostValidateTreeUndefined) {
- ScreenPriv->PostValidateTree = pScreen->PostValidateTree;
- pScreen->PostValidateTree = xf86XVPostValidateTree;
- }
+ if (ScreenPriv->PostValidateTree == PostValidateTreeUndefined) {
+ ScreenPriv->PostValidateTree = pScreen->PostValidateTree;
+ pScreen->PostValidateTree = xf86XVPostValidateTree;
+ }
- WinPriv = WinPriv->next;
- }
+ WinPriv = WinPriv->next;
+ }
- if(ScreenPriv->ClipNotify) {
- pScreen->ClipNotify = ScreenPriv->ClipNotify;
- (*pScreen->ClipNotify)(pWin, dx, dy);
- pScreen->ClipNotify = xf86XVClipNotify;
- }
+ if (ScreenPriv->ClipNotify) {
+ pScreen->ClipNotify = ScreenPriv->ClipNotify;
+ (*pScreen->ClipNotify) (pWin, dx, dy);
+ pScreen->ClipNotify = xf86XVClipNotify;
+ }
}
-
-
/**** Required XvScreenRec fields ****/
static Bool
xf86XVCloseScreen(int i, ScreenPtr pScreen)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
- XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
- XvAdaptorPtr pa;
- int c;
-
- if(!ScreenPriv) return TRUE;
-
- pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
- pScreen->WindowExposures = ScreenPriv->WindowExposures;
- pScreen->ClipNotify = ScreenPriv->ClipNotify;
-
- pScrn->EnterVT = ScreenPriv->EnterVT;
- pScrn->LeaveVT = ScreenPriv->LeaveVT;
- pScrn->AdjustFrame = ScreenPriv->AdjustFrame;
- pScrn->ModeSet = ScreenPriv->ModeSet;
-
- for(c = 0, pa = pxvs->pAdaptors; c < pxvs->nAdaptors; c++, pa++) {
- xf86XVFreeAdaptor(pa);
- }
-
- free(pxvs->pAdaptors);
- free(ScreenPriv);
- return TRUE;
-}
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ XvAdaptorPtr pa;
+ int c;
+ if (!ScreenPriv)
+ return TRUE;
-static int
-xf86XVQueryAdaptors(
- ScreenPtr pScreen,
- XvAdaptorPtr *p_pAdaptors,
- int *p_nAdaptors
-){
- XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+ pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
+ pScreen->WindowExposures = ScreenPriv->WindowExposures;
+ pScreen->ClipNotify = ScreenPriv->ClipNotify;
+
+ pScrn->EnterVT = ScreenPriv->EnterVT;
+ pScrn->LeaveVT = ScreenPriv->LeaveVT;
+ pScrn->AdjustFrame = ScreenPriv->AdjustFrame;
+ pScrn->ModeSet = ScreenPriv->ModeSet;
- *p_nAdaptors = pxvs->nAdaptors;
- *p_pAdaptors = pxvs->pAdaptors;
+ for (c = 0, pa = pxvs->pAdaptors; c < pxvs->nAdaptors; c++, pa++) {
+ xf86XVFreeAdaptor(pa);
+ }
- return Success;
+ free(pxvs->pAdaptors);
+ free(ScreenPriv);
+ return TRUE;
}
+static int
+xf86XVQueryAdaptors(ScreenPtr pScreen,
+ XvAdaptorPtr * p_pAdaptors, int *p_nAdaptors)
+{
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+
+ *p_nAdaptors = pxvs->nAdaptors;
+ *p_pAdaptors = pxvs->pAdaptors;
+
+ return Success;
+}
/**** ScrnInfoRec fields ****/
@@ -1329,11 +1308,12 @@ xf86XVEnterVT(int index, int flags)
Bool ret;
pScrn->EnterVT = ScreenPriv->EnterVT;
- ret = (*ScreenPriv->EnterVT)(index, flags);
+ ret = (*ScreenPriv->EnterVT) (index, flags);
ScreenPriv->EnterVT = pScrn->EnterVT;
pScrn->EnterVT = xf86XVEnterVT;
- if(ret) WalkTree(pScreen, xf86XVReputAllVideo, 0);
+ if (ret)
+ WalkTree(pScreen, xf86XVReputAllVideo, 0);
return ret;
}
@@ -1350,31 +1330,31 @@ xf86XVLeaveVT(int index, int flags)
XvPortRecPrivatePtr pPriv;
int i, j;
- for(i = 0; i < pxvs->nAdaptors; i++) {
- pAdaptor = &pxvs->pAdaptors[i];
- for(j = 0; j < pAdaptor->nPorts; j++) {
- pPort = &pAdaptor->pPorts[j];
- pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
- if(pPriv->isOn > XV_OFF) {
+ for (i = 0; i < pxvs->nAdaptors; i++) {
+ pAdaptor = &pxvs->pAdaptors[i];
+ for (j = 0; j < pAdaptor->nPorts; j++) {
+ pPort = &pAdaptor->pPorts[j];
+ pPriv = (XvPortRecPrivatePtr) pPort->devPriv.ptr;
+ if (pPriv->isOn > XV_OFF) {
- (*pPriv->AdaptorRec->StopVideo)(
- pPriv->pScrn, pPriv->DevPriv.ptr, TRUE);
- pPriv->isOn = XV_OFF;
+ (*pPriv->AdaptorRec->StopVideo) (pPriv->pScrn,
+ pPriv->DevPriv.ptr, TRUE);
+ pPriv->isOn = XV_OFF;
- if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
- RegionDestroy(pPriv->pCompositeClip);
+ if (pPriv->pCompositeClip && pPriv->FreeCompositeClip)
+ RegionDestroy(pPriv->pCompositeClip);
- pPriv->pCompositeClip = NULL;
+ pPriv->pCompositeClip = NULL;
- if(!pPriv->type && pPriv->pDraw) { /* still */
- xf86XVRemovePortFromWindow((WindowPtr)pPriv->pDraw, pPriv);
- }
- }
- }
+ if (!pPriv->type && pPriv->pDraw) { /* still */
+ xf86XVRemovePortFromWindow((WindowPtr) pPriv->pDraw, pPriv);
+ }
+ }
+ }
}
pScrn->LeaveVT = ScreenPriv->LeaveVT;
- (*ScreenPriv->LeaveVT)(index, flags);
+ (*ScreenPriv->LeaveVT) (index, flags);
ScreenPriv->LeaveVT = pScrn->LeaveVT;
pScrn->LeaveVT = xf86XVLeaveVT;
}
@@ -1382,17 +1362,17 @@ xf86XVLeaveVT(int index, int flags)
static void
xf86XVAdjustFrame(int index, int x, int y, int flags)
{
- ScrnInfoPtr pScrn = xf86Screens[index];
- ScreenPtr pScreen = pScrn->pScreen;
- XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ ScreenPtr pScreen = pScrn->pScreen;
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
- if(ScreenPriv->AdjustFrame) {
- pScrn->AdjustFrame = ScreenPriv->AdjustFrame;
- (*pScrn->AdjustFrame)(index, x, y, flags);
- pScrn->AdjustFrame = xf86XVAdjustFrame;
- }
+ if (ScreenPriv->AdjustFrame) {
+ pScrn->AdjustFrame = ScreenPriv->AdjustFrame;
+ (*pScrn->AdjustFrame) (index, x, y, flags);
+ pScrn->AdjustFrame = xf86XVAdjustFrame;
+ }
- xf86XVReputOrStopAllPorts(pScrn, FALSE);
+ xf86XVReputOrStopAllPorts(pScrn, FALSE);
}
static void
@@ -1403,14 +1383,14 @@ xf86XVModeSet(ScrnInfoPtr pScrn)
/* Can be called before pScrn->pScreen is set */
if (!pScreen)
- return;
+ return;
ScreenPriv = GET_XF86XV_SCREEN(pScreen);
if (ScreenPriv->ModeSet) {
- pScrn->ModeSet = ScreenPriv->ModeSet;
- (*pScrn->ModeSet)(pScrn);
- pScrn->ModeSet = xf86XVModeSet;
+ pScrn->ModeSet = ScreenPriv->ModeSet;
+ (*pScrn->ModeSet) (pScrn);
+ pScrn->ModeSet = xf86XVModeSet;
}
xf86XVReputOrStopAllPorts(pScrn, FALSE);
@@ -1419,589 +1399,583 @@ xf86XVModeSet(ScrnInfoPtr pScrn)
/**** XvAdaptorRec fields ****/
static int
-xf86XVAllocatePort(
- unsigned long port,
- XvPortPtr pPort,
- XvPortPtr *ppPort
-){
- *ppPort = pPort;
- return Success;
+xf86XVAllocatePort(unsigned long port, XvPortPtr pPort, XvPortPtr * ppPort)
+{
+ *ppPort = pPort;
+ return Success;
}
-
-
static int
xf86XVFreePort(XvPortPtr pPort)
{
- return Success;
+ return Success;
}
-
static int
-xf86XVPutVideo(
- ClientPtr client,
- DrawablePtr pDraw,
- XvPortPtr pPort,
- GCPtr pGC,
- INT16 vid_x, INT16 vid_y,
- CARD16 vid_w, CARD16 vid_h,
- INT16 drw_x, INT16 drw_y,
- CARD16 drw_w, CARD16 drw_h
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- int result;
-
- /* No dumping video to pixmaps... For now anyhow */
- if(pDraw->type != DRAWABLE_WINDOW) {
- pPort->pDraw = (DrawablePtr)NULL;
- return BadAlloc;
- }
-
- /* If we are changing windows, unregister our port in the old window */
- if(portPriv->pDraw && (portPriv->pDraw != pDraw))
- xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
-
- /* Register our port with the new window */
- result = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
- if(result != Success) return result;
-
- portPriv->type = XvInputMask;
-
- /* save a copy of these parameters */
- portPriv->vid_x = vid_x; portPriv->vid_y = vid_y;
- portPriv->vid_w = vid_w; portPriv->vid_h = vid_h;
- portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
- portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
-
- /* make sure we have the most recent copy of the clientClip */
- xf86XVCopyClip(portPriv, pGC);
-
- /* To indicate to the DI layer that we were successful */
- pPort->pDraw = pDraw;
-
- if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
-
- return(xf86XVReputVideo(portPriv));
+xf86XVPutVideo(ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h)
+{
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+ int result;
+
+ /* No dumping video to pixmaps... For now anyhow */
+ if (pDraw->type != DRAWABLE_WINDOW) {
+ pPort->pDraw = (DrawablePtr) NULL;
+ return BadAlloc;
+ }
+
+ /* If we are changing windows, unregister our port in the old window */
+ if (portPriv->pDraw && (portPriv->pDraw != pDraw))
+ xf86XVRemovePortFromWindow((WindowPtr) (portPriv->pDraw), portPriv);
+
+ /* Register our port with the new window */
+ result = xf86XVEnlistPortInWindow((WindowPtr) pDraw, portPriv);
+ if (result != Success)
+ return result;
+
+ portPriv->type = XvInputMask;
+
+ /* save a copy of these parameters */
+ portPriv->vid_x = vid_x;
+ portPriv->vid_y = vid_y;
+ portPriv->vid_w = vid_w;
+ portPriv->vid_h = vid_h;
+ portPriv->drw_x = drw_x;
+ portPriv->drw_y = drw_y;
+ portPriv->drw_w = drw_w;
+ portPriv->drw_h = drw_h;
+
+ /* make sure we have the most recent copy of the clientClip */
+ xf86XVCopyClip(portPriv, pGC);
+
+ /* To indicate to the DI layer that we were successful */
+ pPort->pDraw = pDraw;
+
+ if (!portPriv->pScrn->vtSema)
+ return Success; /* Success ? */
+
+ return (xf86XVReputVideo(portPriv));
}
static int
-xf86XVPutStill(
- ClientPtr client,
- DrawablePtr pDraw,
- XvPortPtr pPort,
- GCPtr pGC,
- INT16 vid_x, INT16 vid_y,
- CARD16 vid_w, CARD16 vid_h,
- INT16 drw_x, INT16 drw_y,
- CARD16 drw_w, CARD16 drw_h
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- RegionRec WinRegion;
- RegionRec ClipRegion;
- BoxRec WinBox;
- int ret = Success;
- Bool clippedAway = FALSE;
-
- if (pDraw->type != DRAWABLE_WINDOW)
- return BadAlloc;
-
- if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
-
- WinBox.x1 = pDraw->x + drw_x;
- WinBox.y1 = pDraw->y + drw_y;
- WinBox.x2 = WinBox.x1 + drw_w;
- WinBox.y2 = WinBox.y1 + drw_h;
-
- xf86XVCopyCompositeClip(portPriv, pGC, pDraw);
-
- RegionInit(&WinRegion, &WinBox, 1);
- RegionNull(&ClipRegion);
- RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
-
- if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
- RegionRec VPReg;
- BoxRec VPBox;
-
- VPBox.x1 = portPriv->pScrn->frameX0;
- VPBox.y1 = portPriv->pScrn->frameY0;
- VPBox.x2 = portPriv->pScrn->frameX1 + 1;
- VPBox.y2 = portPriv->pScrn->frameY1 + 1;
-
- RegionInit(&VPReg, &VPBox, 1);
- RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
- RegionUninit(&VPReg);
- }
-
- if(portPriv->pDraw) {
- xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
- }
-
- if(!RegionNotEmpty(&ClipRegion)) {
- clippedAway = TRUE;
- goto PUT_STILL_BAILOUT;
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = RegionRects(&ClipRegion);
- if( (RegionNumRects(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
- {
- clippedAway = TRUE;
- goto PUT_STILL_BAILOUT;
- }
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
- ret = (*portPriv->AdaptorRec->PutStill)(portPriv->pScrn,
- vid_x, vid_y, WinBox.x1, WinBox.y1,
- vid_w, vid_h, drw_w, drw_h,
- &ClipRegion, portPriv->DevPriv.ptr,
- pDraw);
-
- if((ret == Success) &&
- (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_STILLS)) {
-
- xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
- portPriv->isOn = XV_ON;
- portPriv->vid_x = vid_x; portPriv->vid_y = vid_y;
- portPriv->vid_w = vid_w; portPriv->vid_h = vid_h;
- portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
- portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
- portPriv->type = 0; /* no mask means it's transient and should
- not be reput once it's removed */
- pPort->pDraw = pDraw; /* make sure we can get stop requests */
- }
-
-PUT_STILL_BAILOUT:
-
- if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = XV_PENDING;
- }
-
- /* This clip was copied and only good for one shot */
- if(!portPriv->FreeCompositeClip)
- portPriv->pCompositeClip = NULL;
-
- RegionUninit(&WinRegion);
- RegionUninit(&ClipRegion);
-
- return ret;
+xf86XVPutStill(ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h)
+{
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
+
+ if (!portPriv->pScrn->vtSema)
+ return Success; /* Success ? */
+
+ WinBox.x1 = pDraw->x + drw_x;
+ WinBox.y1 = pDraw->y + drw_y;
+ WinBox.x2 = WinBox.x1 + drw_w;
+ WinBox.y2 = WinBox.y1 + drw_h;
+
+ xf86XVCopyCompositeClip(portPriv, pGC, pDraw);
+
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
+
+ if (portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = portPriv->pScrn->frameX0;
+ VPBox.y1 = portPriv->pScrn->frameY0;
+ VPBox.x2 = portPriv->pScrn->frameX1 + 1;
+ VPBox.y2 = portPriv->pScrn->frameY1 + 1;
+
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
+ }
+
+ if (portPriv->pDraw) {
+ xf86XVRemovePortFromWindow((WindowPtr) (portPriv->pDraw), portPriv);
+ }
+
+ if (!RegionNotEmpty(&ClipRegion)) {
+ clippedAway = TRUE;
+ goto PUT_STILL_BAILOUT;
+ }
+
+ if (portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+
+ if ((RegionNumRects(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) {
+ clippedAway = TRUE;
+ goto PUT_STILL_BAILOUT;
+ }
+ }
+
+ if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->PutStill) (portPriv->pScrn,
+ vid_x, vid_y, WinBox.x1, WinBox.y1,
+ vid_w, vid_h, drw_w, drw_h,
+ &ClipRegion, portPriv->DevPriv.ptr,
+ pDraw);
+
+ if ((ret == Success) &&
+ (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_STILLS)) {
+
+ xf86XVEnlistPortInWindow((WindowPtr) pDraw, portPriv);
+ portPriv->isOn = XV_ON;
+ portPriv->vid_x = vid_x;
+ portPriv->vid_y = vid_y;
+ portPriv->vid_w = vid_w;
+ portPriv->vid_h = vid_h;
+ portPriv->drw_x = drw_x;
+ portPriv->drw_y = drw_y;
+ portPriv->drw_w = drw_w;
+ portPriv->drw_h = drw_h;
+ portPriv->type = 0; /* no mask means it's transient and should
+ not be reput once it's removed */
+ pPort->pDraw = pDraw; /* make sure we can get stop requests */
+ }
+
+ PUT_STILL_BAILOUT:
+
+ if ((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo) (portPriv->pScrn,
+ portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ /* This clip was copied and only good for one shot */
+ if (!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
+
+ return ret;
}
static int
-xf86XVGetVideo(
- ClientPtr client,
- DrawablePtr pDraw,
- XvPortPtr pPort,
- GCPtr pGC,
- INT16 vid_x, INT16 vid_y,
- CARD16 vid_w, CARD16 vid_h,
- INT16 drw_x, INT16 drw_y,
- CARD16 drw_w, CARD16 drw_h
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- int result;
-
- /* No pixmaps... For now anyhow */
- if(pDraw->type != DRAWABLE_WINDOW) {
- pPort->pDraw = (DrawablePtr)NULL;
- return BadAlloc;
- }
-
- /* If we are changing windows, unregister our port in the old window */
- if(portPriv->pDraw && (portPriv->pDraw != pDraw))
- xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
-
- /* Register our port with the new window */
- result = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
- if(result != Success) return result;
-
- portPriv->type = XvOutputMask;
-
- /* save a copy of these parameters */
- portPriv->vid_x = vid_x; portPriv->vid_y = vid_y;
- portPriv->vid_w = vid_w; portPriv->vid_h = vid_h;
- portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
- portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
-
- /* make sure we have the most recent copy of the clientClip */
- xf86XVCopyClip(portPriv, pGC);
-
- /* To indicate to the DI layer that we were successful */
- pPort->pDraw = pDraw;
-
- if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
-
- return(xf86XVRegetVideo(portPriv));
+xf86XVGetVideo(ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h)
+{
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+ int result;
+
+ /* No pixmaps... For now anyhow */
+ if (pDraw->type != DRAWABLE_WINDOW) {
+ pPort->pDraw = (DrawablePtr) NULL;
+ return BadAlloc;
+ }
+
+ /* If we are changing windows, unregister our port in the old window */
+ if (portPriv->pDraw && (portPriv->pDraw != pDraw))
+ xf86XVRemovePortFromWindow((WindowPtr) (portPriv->pDraw), portPriv);
+
+ /* Register our port with the new window */
+ result = xf86XVEnlistPortInWindow((WindowPtr) pDraw, portPriv);
+ if (result != Success)
+ return result;
+
+ portPriv->type = XvOutputMask;
+
+ /* save a copy of these parameters */
+ portPriv->vid_x = vid_x;
+ portPriv->vid_y = vid_y;
+ portPriv->vid_w = vid_w;
+ portPriv->vid_h = vid_h;
+ portPriv->drw_x = drw_x;
+ portPriv->drw_y = drw_y;
+ portPriv->drw_w = drw_w;
+ portPriv->drw_h = drw_h;
+
+ /* make sure we have the most recent copy of the clientClip */
+ xf86XVCopyClip(portPriv, pGC);
+
+ /* To indicate to the DI layer that we were successful */
+ pPort->pDraw = pDraw;
+
+ if (!portPriv->pScrn->vtSema)
+ return Success; /* Success ? */
+
+ return (xf86XVRegetVideo(portPriv));
}
static int
-xf86XVGetStill(
- ClientPtr client,
- DrawablePtr pDraw,
- XvPortPtr pPort,
- GCPtr pGC,
- INT16 vid_x, INT16 vid_y,
- CARD16 vid_w, CARD16 vid_h,
- INT16 drw_x, INT16 drw_y,
- CARD16 drw_w, CARD16 drw_h
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- RegionRec WinRegion;
- RegionRec ClipRegion;
- BoxRec WinBox;
- int ret = Success;
- Bool clippedAway = FALSE;
-
- if (pDraw->type != DRAWABLE_WINDOW)
- return BadAlloc;
-
- if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
-
- WinBox.x1 = pDraw->x + drw_x;
- WinBox.y1 = pDraw->y + drw_y;
- WinBox.x2 = WinBox.x1 + drw_w;
- WinBox.y2 = WinBox.y1 + drw_h;
-
- RegionInit(&WinRegion, &WinBox, 1);
- RegionNull(&ClipRegion);
- RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
-
- if(portPriv->pDraw) {
- xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
- }
-
- if(!RegionNotEmpty(&ClipRegion)) {
- clippedAway = TRUE;
- goto GET_STILL_BAILOUT;
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
- ret = (*portPriv->AdaptorRec->GetStill)(portPriv->pScrn,
- vid_x, vid_y, WinBox.x1, WinBox.y1,
- vid_w, vid_h, drw_w, drw_h,
- &ClipRegion, portPriv->DevPriv.ptr,
- pDraw);
-
-GET_STILL_BAILOUT:
-
- if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = XV_PENDING;
- }
-
- RegionUninit(&WinRegion);
- RegionUninit(&ClipRegion);
-
- return ret;
-}
+xf86XVGetStill(ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h)
+{
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
+
+ if (!portPriv->pScrn->vtSema)
+ return Success; /* Success ? */
+
+ WinBox.x1 = pDraw->x + drw_x;
+ WinBox.y1 = pDraw->y + drw_y;
+ WinBox.x2 = WinBox.x1 + drw_w;
+ WinBox.y2 = WinBox.y1 + drw_h;
+
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
+
+ if (portPriv->pDraw) {
+ xf86XVRemovePortFromWindow((WindowPtr) (portPriv->pDraw), portPriv);
+ }
+
+ if (!RegionNotEmpty(&ClipRegion)) {
+ clippedAway = TRUE;
+ goto GET_STILL_BAILOUT;
+ }
+
+ if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->GetStill) (portPriv->pScrn,
+ vid_x, vid_y, WinBox.x1, WinBox.y1,
+ vid_w, vid_h, drw_w, drw_h,
+ &ClipRegion, portPriv->DevPriv.ptr,
+ pDraw);
+ GET_STILL_BAILOUT:
+ if ((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo) (portPriv->pScrn,
+ portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
+
+ return ret;
+}
static int
-xf86XVStopVideo(
- ClientPtr client,
- XvPortPtr pPort,
- DrawablePtr pDraw
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+xf86XVStopVideo(ClientPtr client, XvPortPtr pPort, DrawablePtr pDraw)
+{
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
- if(pDraw->type != DRAWABLE_WINDOW)
- return BadAlloc;
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
- xf86XVRemovePortFromWindow((WindowPtr)pDraw, portPriv);
+ xf86XVRemovePortFromWindow((WindowPtr) pDraw, portPriv);
- if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
+ if (!portPriv->pScrn->vtSema)
+ return Success; /* Success ? */
- /* Must free resources. */
+ /* Must free resources. */
- if(portPriv->isOn > XV_OFF) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->pScrn, portPriv->DevPriv.ptr, TRUE);
- portPriv->isOn = XV_OFF;
- }
+ if (portPriv->isOn > XV_OFF) {
+ (*portPriv->AdaptorRec->StopVideo) (portPriv->pScrn,
+ portPriv->DevPriv.ptr, TRUE);
+ portPriv->isOn = XV_OFF;
+ }
- return Success;
+ return Success;
}
static int
-xf86XVSetPortAttribute(
- ClientPtr client,
- XvPortPtr pPort,
- Atom attribute,
- INT32 value
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
-
- return((*portPriv->AdaptorRec->SetPortAttribute)(portPriv->pScrn,
- attribute, value, portPriv->DevPriv.ptr));
-}
+xf86XVSetPortAttribute(ClientPtr client,
+ XvPortPtr pPort, Atom attribute, INT32 value)
+{
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+ return ((*portPriv->AdaptorRec->SetPortAttribute) (portPriv->pScrn,
+ attribute, value,
+ portPriv->DevPriv.ptr));
+}
static int
-xf86XVGetPortAttribute(
- ClientPtr client,
- XvPortPtr pPort,
- Atom attribute,
- INT32 *p_value
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
-
- return((*portPriv->AdaptorRec->GetPortAttribute)(portPriv->pScrn,
- attribute, p_value, portPriv->DevPriv.ptr));
+xf86XVGetPortAttribute(ClientPtr client,
+ XvPortPtr pPort, Atom attribute, INT32 *p_value)
+{
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+
+ return ((*portPriv->AdaptorRec->GetPortAttribute) (portPriv->pScrn,
+ attribute, p_value,
+ portPriv->DevPriv.ptr));
}
+static int
+xf86XVQueryBestSize(ClientPtr client,
+ XvPortPtr pPort,
+ CARD8 motion,
+ CARD16 vid_w, CARD16 vid_h,
+ CARD16 drw_w, CARD16 drw_h,
+ unsigned int *p_w, unsigned int *p_h)
+{
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+ (*portPriv->AdaptorRec->QueryBestSize) (portPriv->pScrn,
+ (Bool) motion, vid_w, vid_h, drw_w,
+ drw_h, p_w, p_h,
+ portPriv->DevPriv.ptr);
-static int
-xf86XVQueryBestSize(
- ClientPtr client,
- XvPortPtr pPort,
- CARD8 motion,
- CARD16 vid_w, CARD16 vid_h,
- CARD16 drw_w, CARD16 drw_h,
- unsigned int *p_w, unsigned int *p_h
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
-
- (*portPriv->AdaptorRec->QueryBestSize)(portPriv->pScrn,
- (Bool)motion, vid_w, vid_h, drw_w, drw_h,
- p_w, p_h, portPriv->DevPriv.ptr);
-
- return Success;
+ return Success;
}
-
static int
-xf86XVPutImage(
- ClientPtr client,
- DrawablePtr pDraw,
- XvPortPtr pPort,
- GCPtr pGC,
- INT16 src_x, INT16 src_y,
- CARD16 src_w, CARD16 src_h,
- INT16 drw_x, INT16 drw_y,
- CARD16 drw_w, CARD16 drw_h,
- XvImagePtr format,
- unsigned char* data,
- Bool sync,
- CARD16 width, CARD16 height
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- RegionRec WinRegion;
- RegionRec ClipRegion;
- BoxRec WinBox;
- int ret = Success;
- Bool clippedAway = FALSE;
-
- if (pDraw->type != DRAWABLE_WINDOW)
- return BadAlloc;
-
- if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
-
- xf86XVCopyCompositeClip(portPriv, pGC, pDraw);
-
- WinBox.x1 = pDraw->x + drw_x;
- WinBox.y1 = pDraw->y + drw_y;
- WinBox.x2 = WinBox.x1 + drw_w;
- WinBox.y2 = WinBox.y1 + drw_h;
-
- RegionInit(&WinRegion, &WinBox, 1);
- RegionNull(&ClipRegion);
- RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
-
- if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
- RegionRec VPReg;
- BoxRec VPBox;
-
- VPBox.x1 = portPriv->pScrn->frameX0;
- VPBox.y1 = portPriv->pScrn->frameY0;
- VPBox.x2 = portPriv->pScrn->frameX1 + 1;
- VPBox.y2 = portPriv->pScrn->frameY1 + 1;
-
- RegionInit(&VPReg, &VPBox, 1);
- RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
- RegionUninit(&VPReg);
- }
-
- /* If we are changing windows, unregister our port in the old window */
- if(portPriv->pDraw && (portPriv->pDraw != pDraw))
- xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
-
- /* Register our port with the new window */
- ret = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
- if(ret != Success) goto PUT_IMAGE_BAILOUT;
-
- if(!RegionNotEmpty(&ClipRegion)) {
- clippedAway = TRUE;
- goto PUT_IMAGE_BAILOUT;
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = RegionRects(&ClipRegion);
- if( (RegionNumRects(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
- {
- clippedAway = TRUE;
- goto PUT_IMAGE_BAILOUT;
- }
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
- ret = (*portPriv->AdaptorRec->PutImage)(portPriv->pScrn,
- src_x, src_y, WinBox.x1, WinBox.y1,
- src_w, src_h, drw_w, drw_h, format->id, data, width, height,
- sync, &ClipRegion, portPriv->DevPriv.ptr,
- pDraw);
-
- if((ret == Success) &&
- (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_IMAGES)) {
-
- portPriv->isOn = XV_ON;
- portPriv->vid_x = src_x; portPriv->vid_y = src_y;
- portPriv->vid_w = src_w; portPriv->vid_h = src_h;
- portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
- portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
- portPriv->type = 0; /* no mask means it's transient and should
- not be reput once it's removed */
- pPort->pDraw = pDraw; /* make sure we can get stop requests */
- }
-
-PUT_IMAGE_BAILOUT:
-
- if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = XV_PENDING;
- }
-
- /* This clip was copied and only good for one shot */
- if(!portPriv->FreeCompositeClip)
- portPriv->pCompositeClip = NULL;
-
- RegionUninit(&WinRegion);
- RegionUninit(&ClipRegion);
-
- return ret;
+xf86XVPutImage(ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 src_x, INT16 src_y,
+ CARD16 src_w, CARD16 src_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h,
+ XvImagePtr format,
+ unsigned char *data, Bool sync, CARD16 width, CARD16 height)
+{
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
+
+ if (!portPriv->pScrn->vtSema)
+ return Success; /* Success ? */
+
+ xf86XVCopyCompositeClip(portPriv, pGC, pDraw);
+
+ WinBox.x1 = pDraw->x + drw_x;
+ WinBox.y1 = pDraw->y + drw_y;
+ WinBox.x2 = WinBox.x1 + drw_w;
+ WinBox.y2 = WinBox.y1 + drw_h;
+
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
+
+ if (portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = portPriv->pScrn->frameX0;
+ VPBox.y1 = portPriv->pScrn->frameY0;
+ VPBox.x2 = portPriv->pScrn->frameX1 + 1;
+ VPBox.y2 = portPriv->pScrn->frameY1 + 1;
+
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
+ }
+
+ /* If we are changing windows, unregister our port in the old window */
+ if (portPriv->pDraw && (portPriv->pDraw != pDraw))
+ xf86XVRemovePortFromWindow((WindowPtr) (portPriv->pDraw), portPriv);
+
+ /* Register our port with the new window */
+ ret = xf86XVEnlistPortInWindow((WindowPtr) pDraw, portPriv);
+ if (ret != Success)
+ goto PUT_IMAGE_BAILOUT;
+
+ if (!RegionNotEmpty(&ClipRegion)) {
+ clippedAway = TRUE;
+ goto PUT_IMAGE_BAILOUT;
+ }
+
+ if (portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+
+ if ((RegionNumRects(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) {
+ clippedAway = TRUE;
+ goto PUT_IMAGE_BAILOUT;
+ }
+ }
+
+ if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->PutImage) (portPriv->pScrn,
+ src_x, src_y, WinBox.x1, WinBox.y1,
+ src_w, src_h, drw_w, drw_h,
+ format->id, data, width, height,
+ sync, &ClipRegion,
+ portPriv->DevPriv.ptr, pDraw);
+
+ if ((ret == Success) &&
+ (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_IMAGES)) {
+
+ portPriv->isOn = XV_ON;
+ portPriv->vid_x = src_x;
+ portPriv->vid_y = src_y;
+ portPriv->vid_w = src_w;
+ portPriv->vid_h = src_h;
+ portPriv->drw_x = drw_x;
+ portPriv->drw_y = drw_y;
+ portPriv->drw_w = drw_w;
+ portPriv->drw_h = drw_h;
+ portPriv->type = 0; /* no mask means it's transient and should
+ not be reput once it's removed */
+ pPort->pDraw = pDraw; /* make sure we can get stop requests */
+ }
+
+ PUT_IMAGE_BAILOUT:
+
+ if ((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo) (portPriv->pScrn,
+ portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ /* This clip was copied and only good for one shot */
+ if (!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
+
+ return ret;
}
+static int
+xf86XVQueryImageAttributes(ClientPtr client,
+ XvPortPtr pPort,
+ XvImagePtr format,
+ CARD16 *width,
+ CARD16 *height, int *pitches, int *offsets)
+{
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
-static int
-xf86XVQueryImageAttributes(
- ClientPtr client,
- XvPortPtr pPort,
- XvImagePtr format,
- CARD16 *width,
- CARD16 *height,
- int *pitches,
- int *offsets
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
-
- return (*portPriv->AdaptorRec->QueryImageAttributes)(portPriv->pScrn,
- format->id, width, height, pitches, offsets);
+ return (*portPriv->AdaptorRec->QueryImageAttributes) (portPriv->pScrn,
+ format->id, width,
+ height, pitches,
+ offsets);
}
void
-xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr fillboxes)
+xf86XVFillKeyHelperDrawable(DrawablePtr pDraw, CARD32 key, RegionPtr fillboxes)
{
- ScreenPtr pScreen = pDraw->pScreen;
- ChangeGCVal pval[2];
- BoxPtr pbox = RegionRects(fillboxes);
- int i, nbox = RegionNumRects(fillboxes);
- xRectangle *rects;
- GCPtr gc;
-
- if(!xf86Screens[pScreen->myNum]->vtSema) return;
-
- gc = GetScratchGC(pDraw->depth, pScreen);
- pval[0].val = key;
- pval[1].val = IncludeInferiors;
- (void) ChangeGC(NullClient, gc, GCForeground|GCSubwindowMode, pval);
- ValidateGC(pDraw, gc);
-
- rects = malloc(nbox * sizeof(xRectangle));
-
- for(i = 0; i < nbox; i++, pbox++)
- {
- rects[i].x = pbox->x1 - pDraw->x;
- rects[i].y = pbox->y1 - pDraw->y;
- rects[i].width = pbox->x2 - pbox->x1;
- rects[i].height = pbox->y2 - pbox->y1;
- }
-
- (*gc->ops->PolyFillRect)(pDraw, gc, nbox, rects);
-
- free(rects);
- FreeScratchGC (gc);
+ ScreenPtr pScreen = pDraw->pScreen;
+ ChangeGCVal pval[2];
+ BoxPtr pbox = RegionRects(fillboxes);
+ int i, nbox = RegionNumRects(fillboxes);
+ xRectangle *rects;
+ GCPtr gc;
+
+ if (!xf86Screens[pScreen->myNum]->vtSema)
+ return;
+
+ gc = GetScratchGC(pDraw->depth, pScreen);
+ pval[0].val = key;
+ pval[1].val = IncludeInferiors;
+ (void) ChangeGC(NullClient, gc, GCForeground | GCSubwindowMode, pval);
+ ValidateGC(pDraw, gc);
+
+ rects = malloc(nbox * sizeof(xRectangle));
+
+ for (i = 0; i < nbox; i++, pbox++) {
+ rects[i].x = pbox->x1 - pDraw->x;
+ rects[i].y = pbox->y1 - pDraw->y;
+ rects[i].width = pbox->x2 - pbox->x1;
+ rects[i].height = pbox->y2 - pbox->y1;
+ }
+
+ (*gc->ops->PolyFillRect) (pDraw, gc, nbox, rects);
+
+ free(rects);
+ FreeScratchGC(gc);
}
void
-xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr fillboxes)
+xf86XVFillKeyHelper(ScreenPtr pScreen, CARD32 key, RegionPtr fillboxes)
{
- xf86XVFillKeyHelperDrawable (&pScreen->root->drawable, key, fillboxes);
+ xf86XVFillKeyHelperDrawable(&pScreen->root->drawable, key, fillboxes);
}
void
-xf86XVFillKeyHelperPort (DrawablePtr pDraw, pointer data, CARD32 key, RegionPtr clipboxes, Bool fillEverything)
+xf86XVFillKeyHelperPort(DrawablePtr pDraw, pointer data, CARD32 key,
+ RegionPtr clipboxes, Bool fillEverything)
{
- WindowPtr pWin = (WindowPtr)pDraw;
+ WindowPtr pWin = (WindowPtr) pDraw;
XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin);
XvPortRecPrivatePtr portPriv = NULL;
RegionRec reg;
RegionPtr fillboxes;
while (WinPriv) {
- XvPortRecPrivatePtr pPriv = WinPriv->PortRec;
+ XvPortRecPrivatePtr pPriv = WinPriv->PortRec;
- if (data == pPriv->DevPriv.ptr) {
- portPriv = pPriv;
- break;
- }
+ if (data == pPriv->DevPriv.ptr) {
+ portPriv = pPriv;
+ break;
+ }
- WinPriv = WinPriv->next;
+ WinPriv = WinPriv->next;
}
if (!portPriv)
- return;
+ return;
if (!portPriv->ckeyFilled)
- portPriv->ckeyFilled = RegionCreate(NULL, 0);
+ portPriv->ckeyFilled = RegionCreate(NULL, 0);
if (!fillEverything) {
- RegionNull(&reg);
- fillboxes = &reg;
- RegionSubtract(fillboxes, clipboxes, portPriv->ckeyFilled);
-
- if (!RegionNotEmpty(fillboxes))
- goto out;
- } else
- fillboxes = clipboxes;
+ RegionNull(&reg);
+ fillboxes = &reg;
+ RegionSubtract(fillboxes, clipboxes, portPriv->ckeyFilled);
+ if (!RegionNotEmpty(fillboxes))
+ goto out;
+ }
+ else
+ fillboxes = clipboxes;
RegionCopy(portPriv->ckeyFilled, clipboxes);
xf86XVFillKeyHelperDrawable(pDraw, key, fillboxes);
-out:
+ out:
if (!fillEverything)
RegionUninit(&reg);
}
-
/* xf86XVClipVideoHelper -
Takes the dst box in standard X BoxRec form (top and left
@@ -2012,16 +1986,12 @@ out:
*/
Bool
-xf86XVClipVideoHelper(
- BoxPtr dst,
- INT32 *xa,
- INT32 *xb,
- INT32 *ya,
- INT32 *yb,
- RegionPtr reg,
- INT32 width,
- INT32 height
-){
+xf86XVClipVideoHelper(BoxPtr dst,
+ INT32 *xa,
+ INT32 *xb,
+ INT32 *ya,
+ INT32 *yb, RegionPtr reg, INT32 width, INT32 height)
+{
double xsw, xdw, ysw, ydw;
INT32 delta;
BoxPtr extents = RegionExtents(reg);
@@ -2032,159 +2002,168 @@ xf86XVClipVideoHelper(
ysw = (*yb - *ya) << 16;
ydw = dst->y2 - dst->y1;
- *xa <<= 16; *xb <<= 16;
- *ya <<= 16; *yb <<= 16;
+ *xa <<= 16;
+ *xb <<= 16;
+ *ya <<= 16;
+ *yb <<= 16;
diff = extents->x1 - dst->x1;
if (diff > 0) {
- dst->x1 = extents->x1;
- *xa += (diff * xsw) / xdw;
+ dst->x1 = extents->x1;
+ *xa += (diff * xsw) / xdw;
}
diff = dst->x2 - extents->x2;
if (diff > 0) {
- dst->x2 = extents->x2;
- *xb -= (diff * xsw) / xdw;
+ dst->x2 = extents->x2;
+ *xb -= (diff * xsw) / xdw;
}
diff = extents->y1 - dst->y1;
if (diff > 0) {
- dst->y1 = extents->y1;
- *ya += (diff * ysw) / ydw;
+ dst->y1 = extents->y1;
+ *ya += (diff * ysw) / ydw;
}
diff = dst->y2 - extents->y2;
if (diff > 0) {
- dst->y2 = extents->y2;
- *yb -= (diff * ysw) / ydw;
+ dst->y2 = extents->y2;
+ *yb -= (diff * ysw) / ydw;
}
if (*xa < 0) {
- diff = (((-*xa) * xdw) + xsw - 1) / xsw;
- dst->x1 += diff;
- *xa += (diff * xsw) / xdw;
+ diff = (((-*xa) * xdw) + xsw - 1) / xsw;
+ dst->x1 += diff;
+ *xa += (diff * xsw) / xdw;
}
delta = *xb - (width << 16);
if (delta > 0) {
- diff = ((delta * xdw) + xsw - 1) / xsw;
- dst->x2 -= diff;
- *xb -= (diff * xsw) / xdw;
+ diff = ((delta * xdw) + xsw - 1) / xsw;
+ dst->x2 -= diff;
+ *xb -= (diff * xsw) / xdw;
}
- if (*xa >= *xb) return FALSE;
+ if (*xa >= *xb)
+ return FALSE;
if (*ya < 0) {
- diff = (((-*ya) * ydw) + ysw - 1) / ysw;
- dst->y1 += diff;
- *ya += (diff * ysw) / ydw;
+ diff = (((-*ya) * ydw) + ysw - 1) / ysw;
+ dst->y1 += diff;
+ *ya += (diff * ysw) / ydw;
}
delta = *yb - (height << 16);
if (delta > 0) {
- diff = ((delta * ydw) + ysw - 1) / ysw;
- dst->y2 -= diff;
- *yb -= (diff * ysw) / ydw;
+ diff = ((delta * ydw) + ysw - 1) / ysw;
+ dst->y2 -= diff;
+ *yb -= (diff * ysw) / ydw;
}
- if (*ya >= *yb) return FALSE;
+ if (*ya >= *yb)
+ return FALSE;
if ((dst->x1 > extents->x1) || (dst->x2 < extents->x2) ||
- (dst->y1 > extents->y1) || (dst->y2 < extents->y2))
- {
- RegionRec clipReg;
- RegionInit(&clipReg, dst, 1);
- RegionIntersect(reg, reg, &clipReg);
- RegionUninit(&clipReg);
+ (dst->y1 > extents->y1) || (dst->y2 < extents->y2)) {
+ RegionRec clipReg;
+
+ RegionInit(&clipReg, dst, 1);
+ RegionIntersect(reg, reg, &clipReg);
+ RegionUninit(&clipReg);
}
return TRUE;
}
void
-xf86XVCopyYUV12ToPacked(
- const void *srcy,
- const void *srcv,
- const void *srcu,
- void *dst,
- int srcPitchy,
- int srcPitchuv,
- int dstPitch,
- int h,
- int w
-){
+xf86XVCopyYUV12ToPacked(const void *srcy,
+ const void *srcv,
+ const void *srcu,
+ void *dst,
+ int srcPitchy,
+ int srcPitchuv, int dstPitch, int h, int w)
+{
CARD32 *Dst;
const CARD8 *Y, *U, *V;
int i, j;
w >>= 1;
- for (j = 0; j < h; j++) {
- Dst = dst;
- Y = srcy; V = srcv; U = srcu;
- i = w;
- while (i >= 4) {
+ for (j = 0; j < h; j++) {
+ Dst = dst;
+ Y = srcy;
+ V = srcv;
+ U = srcu;
+ i = w;
+ while (i >= 4) {
#if X_BYTE_ORDER == X_LITTLE_ENDIAN
- Dst[0] = Y[0] | (Y[1] << 16) | (U[0] << 8) | (V[0] << 24);
- Dst[1] = Y[2] | (Y[3] << 16) | (U[1] << 8) | (V[1] << 24);
- Dst[2] = Y[4] | (Y[5] << 16) | (U[2] << 8) | (V[2] << 24);
- Dst[3] = Y[6] | (Y[7] << 16) | (U[3] << 8) | (V[3] << 24);
+ Dst[0] = Y[0] | (Y[1] << 16) | (U[0] << 8) | (V[0] << 24);
+ Dst[1] = Y[2] | (Y[3] << 16) | (U[1] << 8) | (V[1] << 24);
+ Dst[2] = Y[4] | (Y[5] << 16) | (U[2] << 8) | (V[2] << 24);
+ Dst[3] = Y[6] | (Y[7] << 16) | (U[3] << 8) | (V[3] << 24);
#else
- /* This assumes a little-endian framebuffer */
- Dst[0] = (Y[0] << 24) | (Y[1] << 8) | (U[0] << 16) | V[0];
- Dst[1] = (Y[2] << 24) | (Y[3] << 8) | (U[1] << 16) | V[1];
- Dst[2] = (Y[4] << 24) | (Y[5] << 8) | (U[2] << 16) | V[2];
- Dst[3] = (Y[6] << 24) | (Y[7] << 8) | (U[3] << 16) | V[3];
+ /* This assumes a little-endian framebuffer */
+ Dst[0] = (Y[0] << 24) | (Y[1] << 8) | (U[0] << 16) | V[0];
+ Dst[1] = (Y[2] << 24) | (Y[3] << 8) | (U[1] << 16) | V[1];
+ Dst[2] = (Y[4] << 24) | (Y[5] << 8) | (U[2] << 16) | V[2];
+ Dst[3] = (Y[6] << 24) | (Y[7] << 8) | (U[3] << 16) | V[3];
#endif
- Dst += 4; Y += 8; V += 4; U += 4;
- i -= 4;
- }
-
- while (i--) {
+ Dst += 4;
+ Y += 8;
+ V += 4;
+ U += 4;
+ i -= 4;
+ }
+
+ while (i--) {
#if X_BYTE_ORDER == X_LITTLE_ENDIAN
- Dst[0] = Y[0] | (Y[1] << 16) | (U[0] << 8) | (V[0] << 24);
+ Dst[0] = Y[0] | (Y[1] << 16) | (U[0] << 8) | (V[0] << 24);
#else
- /* This assumes a little-endian framebuffer */
- Dst[0] = (Y[0] << 24) | (Y[1] << 8) | (U[0] << 16) | V[0];
+ /* This assumes a little-endian framebuffer */
+ Dst[0] = (Y[0] << 24) | (Y[1] << 8) | (U[0] << 16) | V[0];
#endif
- Dst++; Y += 2; V++; U++;
- }
-
- dst = (CARD8 *)dst + dstPitch;
- srcy = (const CARD8 *)srcy + srcPitchy;
- if (j & 1) {
- srcu = (const CARD8 *)srcu + srcPitchuv;
- srcv = (const CARD8 *)srcv + srcPitchuv;
- }
+ Dst++;
+ Y += 2;
+ V++;
+ U++;
+ }
+
+ dst = (CARD8 *) dst + dstPitch;
+ srcy = (const CARD8 *) srcy + srcPitchy;
+ if (j & 1) {
+ srcu = (const CARD8 *) srcu + srcPitchuv;
+ srcv = (const CARD8 *) srcv + srcPitchuv;
+ }
}
}
void
-xf86XVCopyPacked(
- const void *src,
- void *dst,
- int srcPitch,
- int dstPitch,
- int h,
- int w
-){
+xf86XVCopyPacked(const void *src,
+ void *dst, int srcPitch, int dstPitch, int h, int w)
+{
const CARD32 *Src;
CARD32 *Dst;
int i;
w >>= 1;
while (--h >= 0) {
- do {
- Dst = dst; Src = src;
- i = w;
- while (i >= 4) {
- Dst[0] = Src[0];
- Dst[1] = Src[1];
- Dst[2] = Src[2];
- Dst[3] = Src[3];
- Dst += 4; Src += 4; i -= 4;
- }
- if (!i) break;
- Dst[0] = Src[0];
- if (i == 1) break;
- Dst[1] = Src[1];
- if (i == 2) break;
- Dst[2] = Src[2];
- } while (0);
-
- src = (const CARD8 *)src + srcPitch;
- dst = (CARD8 *)dst + dstPitch;
+ do {
+ Dst = dst;
+ Src = src;
+ i = w;
+ while (i >= 4) {
+ Dst[0] = Src[0];
+ Dst[1] = Src[1];
+ Dst[2] = Src[2];
+ Dst[3] = Src[3];
+ Dst += 4;
+ Src += 4;
+ i -= 4;
+ }
+ if (!i)
+ break;
+ Dst[0] = Src[0];
+ if (i == 1)
+ break;
+ Dst[1] = Src[1];
+ if (i == 2)
+ break;
+ Dst[2] = Src[2];
+ } while (0);
+
+ src = (const CARD8 *) src + srcPitch;
+ dst = (CARD8 *) dst + dstPitch;
}
}
diff --git a/xorg-server/hw/xfree86/common/xf86xv.h b/xorg-server/hw/xfree86/common/xf86xv.h
index 08e5c790d..2db00a83f 100644
--- a/xorg-server/hw/xfree86/common/xf86xv.h
+++ b/xorg-server/hw/xfree86/common/xf86xv.h
@@ -1,289 +1,270 @@
-
-/*
- * Copyright (c) 1998-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-#ifndef _XF86XV_H_
-#define _XF86XV_H_
-
-#include "xvdix.h"
-#include "xf86str.h"
-
-#define VIDEO_NO_CLIPPING 0x00000001
-#define VIDEO_INVERT_CLIPLIST 0x00000002
-#define VIDEO_OVERLAID_IMAGES 0x00000004
-#define VIDEO_OVERLAID_STILLS 0x00000008
-/*
- * Usage of VIDEO_CLIP_TO_VIEWPORT is not recommended.
- * It can make reput behaviour inconsistent.
- */
-#define VIDEO_CLIP_TO_VIEWPORT 0x00000010
-
-typedef struct {
- int id;
- int type;
- int byte_order;
- unsigned char guid[16];
- int bits_per_pixel;
- int format;
- int num_planes;
-
- /* for RGB formats only */
- int depth;
- unsigned int red_mask;
- unsigned int green_mask;
- unsigned int blue_mask;
-
- /* for YUV formats only */
- unsigned int y_sample_bits;
- unsigned int u_sample_bits;
- unsigned int v_sample_bits;
- unsigned int horz_y_period;
- unsigned int horz_u_period;
- unsigned int horz_v_period;
- unsigned int vert_y_period;
- unsigned int vert_u_period;
- unsigned int vert_v_period;
- char component_order[32];
- int scanline_order;
-} XF86ImageRec, *XF86ImagePtr;
-
-
-typedef struct {
- ScrnInfoPtr pScrn;
- int id;
- unsigned short width, height;
- int *pitches; /* bytes */
- int *offsets; /* in bytes from start of framebuffer */
- DevUnion devPrivate;
-} XF86SurfaceRec, *XF86SurfacePtr;
-
-
-typedef int (* PutVideoFuncPtr)( ScrnInfoPtr pScrn,
- short vid_x, short vid_y, short drw_x, short drw_y,
- short vid_w, short vid_h, short drw_w, short drw_h,
- RegionPtr clipBoxes, pointer data, DrawablePtr pDraw );
-typedef int (* PutStillFuncPtr)( ScrnInfoPtr pScrn,
- short vid_x, short vid_y, short drw_x, short drw_y,
- short vid_w, short vid_h, short drw_w, short drw_h,
- RegionPtr clipBoxes, pointer data, DrawablePtr pDraw );
-typedef int (* GetVideoFuncPtr)( ScrnInfoPtr pScrn,
- short vid_x, short vid_y, short drw_x, short drw_y,
- short vid_w, short vid_h, short drw_w, short drw_h,
- RegionPtr clipBoxes, pointer data, DrawablePtr pDraw );
-typedef int (* GetStillFuncPtr)( ScrnInfoPtr pScrn,
- short vid_x, short vid_y, short drw_x, short drw_y,
- short vid_w, short vid_h, short drw_w, short drw_h,
- RegionPtr clipBoxes, pointer data, DrawablePtr pDraw );
-typedef void (* StopVideoFuncPtr)(ScrnInfoPtr pScrn, pointer data, Bool Exit);
-typedef int (* SetPortAttributeFuncPtr)(ScrnInfoPtr pScrn, Atom attribute,
- INT32 value, pointer data);
-typedef int (* GetPortAttributeFuncPtr)(ScrnInfoPtr pScrn, Atom attribute,
- INT32 *value, pointer data);
-typedef void (* QueryBestSizeFuncPtr)(ScrnInfoPtr pScrn, Bool motion,
- short vid_w, short vid_h, short drw_w, short drw_h,
- unsigned int *p_w, unsigned int *p_h, pointer data);
-typedef int (* PutImageFuncPtr)( ScrnInfoPtr pScrn,
- short src_x, short src_y, short drw_x, short drw_y,
- short src_w, short src_h, short drw_w, short drw_h,
- int image, unsigned char* buf, short width, short height, Bool Sync,
- RegionPtr clipBoxes, pointer data, DrawablePtr pDraw );
-typedef int (* ReputImageFuncPtr)( ScrnInfoPtr pScrn,
- short 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, pointer data, DrawablePtr pDraw );
-typedef int (*QueryImageAttributesFuncPtr)(ScrnInfoPtr pScrn,
- int image, unsigned short *width, unsigned short *height,
- int *pitches, int *offsets);
-typedef void (*ClipNotifyFuncPtr)(ScrnInfoPtr pScrn, pointer data,
- WindowPtr window, int dx, int dy);
-
-typedef enum {
- XV_OFF,
- XV_PENDING,
- XV_ON
-} XvStatus;
-
-/*** this is what the driver needs to fill out ***/
-
-typedef struct {
- int id;
- char *name;
- unsigned short width, height;
- XvRationalRec rate;
-} XF86VideoEncodingRec, *XF86VideoEncodingPtr;
-
-typedef struct {
- char depth;
- short class;
-} XF86VideoFormatRec, *XF86VideoFormatPtr;
-
-typedef struct {
- int flags;
- int min_value;
- int max_value;
- char *name;
-} XF86AttributeRec, *XF86AttributePtr;
-
-typedef struct {
- unsigned int type;
- int flags;
- char *name;
- int nEncodings;
- XF86VideoEncodingPtr pEncodings;
- int nFormats;
- XF86VideoFormatPtr pFormats;
- int nPorts;
- DevUnion *pPortPrivates;
- int nAttributes;
- XF86AttributePtr pAttributes;
- int nImages;
- XF86ImagePtr pImages;
- PutVideoFuncPtr PutVideo;
- PutStillFuncPtr PutStill;
- GetVideoFuncPtr GetVideo;
- GetStillFuncPtr GetStill;
- StopVideoFuncPtr StopVideo;
- SetPortAttributeFuncPtr SetPortAttribute;
- GetPortAttributeFuncPtr GetPortAttribute;
- QueryBestSizeFuncPtr QueryBestSize;
- PutImageFuncPtr PutImage;
- ReputImageFuncPtr ReputImage; /* image/still */
- QueryImageAttributesFuncPtr QueryImageAttributes;
- ClipNotifyFuncPtr ClipNotify;
-} XF86VideoAdaptorRec, *XF86VideoAdaptorPtr;
-
-typedef struct {
- XF86ImagePtr image;
- int flags;
- int (*alloc_surface)(ScrnInfoPtr pScrn,
- int id,
- unsigned short width,
- unsigned short height,
- XF86SurfacePtr surface);
- int (*free_surface)(XF86SurfacePtr surface);
- int (*display) (XF86SurfacePtr surface,
- short vid_x, short vid_y,
- short drw_x, short drw_y,
- short vid_w, short vid_h,
- short drw_w, short drw_h,
- RegionPtr clipBoxes);
- int (*stop) (XF86SurfacePtr surface);
- int (*getAttribute) (ScrnInfoPtr pScrn, Atom attr, INT32 *value);
- int (*setAttribute) (ScrnInfoPtr pScrn, Atom attr, INT32 value);
- int max_width;
- int max_height;
- int num_attributes;
- XF86AttributePtr attributes;
-} XF86OffscreenImageRec, *XF86OffscreenImagePtr;
-
-extern _X_EXPORT Bool
-xf86XVScreenInit(
- ScreenPtr pScreen,
- XF86VideoAdaptorPtr *Adaptors,
- int num
-);
-
-typedef int (* xf86XVInitGenericAdaptorPtr)(ScrnInfoPtr pScrn,
- XF86VideoAdaptorPtr **Adaptors);
-
-extern _X_EXPORT int
-xf86XVRegisterGenericAdaptorDriver(
- xf86XVInitGenericAdaptorPtr InitFunc
-);
-
-extern _X_EXPORT int
-xf86XVListGenericAdaptors(
- ScrnInfoPtr pScrn,
- XF86VideoAdaptorPtr **Adaptors
-);
-
-extern _X_EXPORT Bool
-xf86XVRegisterOffscreenImages(
- ScreenPtr pScreen,
- XF86OffscreenImagePtr images,
- int num
-);
-
-extern _X_EXPORT XF86OffscreenImagePtr
-xf86XVQueryOffscreenImages(
- ScreenPtr pScreen,
- int *num
-);
-
-extern _X_EXPORT XF86VideoAdaptorPtr xf86XVAllocateVideoAdaptorRec(ScrnInfoPtr pScrn);
-
-extern _X_EXPORT void xf86XVFreeVideoAdaptorRec(XF86VideoAdaptorPtr ptr);
-
-extern _X_EXPORT void
-xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes);
-
-extern _X_EXPORT void
-xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes);
-
-extern _X_EXPORT void
-xf86XVFillKeyHelperPort (DrawablePtr pDraw, pointer data, CARD32 key, RegionPtr clipboxes, Bool fillEverything);
-
-extern _X_EXPORT Bool
-xf86XVClipVideoHelper(
- BoxPtr dst,
- INT32 *xa,
- INT32 *xb,
- INT32 *ya,
- INT32 *yb,
- RegionPtr reg,
- INT32 width,
- INT32 height
-);
-
-extern _X_EXPORT void
-xf86XVCopyYUV12ToPacked(
- const void *srcy,
- const void *srcv,
- const void *srcu,
- void *dst,
- int srcPitchy,
- int srcPitchuv,
- int dstPitch,
- int h,
- int w
-);
-
-extern _X_EXPORT void
-xf86XVCopyPacked(
- const void *src,
- void *dst,
- int srcPitch,
- int dstPitch,
- int h,
- int w
-);
-
-extern _X_EXPORT DevPrivateKey (*XvGetScreenKeyProc)(void);
-extern _X_EXPORT unsigned long (*XvGetRTPortProc)(void);
-extern _X_EXPORT int (*XvScreenInitProc)(ScreenPtr);
-
-#endif /* _XF86XV_H_ */
+
+/*
+ * Copyright (c) 1998-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifndef _XF86XV_H_
+#define _XF86XV_H_
+
+#include "xvdix.h"
+#include "xf86str.h"
+
+#define VIDEO_NO_CLIPPING 0x00000001
+#define VIDEO_INVERT_CLIPLIST 0x00000002
+#define VIDEO_OVERLAID_IMAGES 0x00000004
+#define VIDEO_OVERLAID_STILLS 0x00000008
+/*
+ * Usage of VIDEO_CLIP_TO_VIEWPORT is not recommended.
+ * It can make reput behaviour inconsistent.
+ */
+#define VIDEO_CLIP_TO_VIEWPORT 0x00000010
+
+typedef struct {
+ int id;
+ int type;
+ int byte_order;
+ unsigned char guid[16];
+ int bits_per_pixel;
+ int format;
+ int num_planes;
+
+ /* for RGB formats only */
+ int depth;
+ unsigned int red_mask;
+ unsigned int green_mask;
+ unsigned int blue_mask;
+
+ /* for YUV formats only */
+ unsigned int y_sample_bits;
+ unsigned int u_sample_bits;
+ unsigned int v_sample_bits;
+ unsigned int horz_y_period;
+ unsigned int horz_u_period;
+ unsigned int horz_v_period;
+ unsigned int vert_y_period;
+ unsigned int vert_u_period;
+ unsigned int vert_v_period;
+ char component_order[32];
+ int scanline_order;
+} XF86ImageRec, *XF86ImagePtr;
+
+typedef struct {
+ ScrnInfoPtr pScrn;
+ int id;
+ unsigned short width, height;
+ int *pitches; /* bytes */
+ int *offsets; /* in bytes from start of framebuffer */
+ DevUnion devPrivate;
+} XF86SurfaceRec, *XF86SurfacePtr;
+
+typedef int (*PutVideoFuncPtr) (ScrnInfoPtr pScrn,
+ short vid_x, short vid_y, short drw_x,
+ short drw_y, short vid_w, short vid_h,
+ short drw_w, short drw_h, RegionPtr clipBoxes,
+ pointer data, DrawablePtr pDraw);
+typedef int (*PutStillFuncPtr) (ScrnInfoPtr pScrn, short vid_x, short vid_y,
+ short drw_x, short drw_y, short vid_w,
+ short vid_h, short drw_w, short drw_h,
+ RegionPtr clipBoxes, pointer data,
+ DrawablePtr pDraw);
+typedef int (*GetVideoFuncPtr) (ScrnInfoPtr pScrn, short vid_x, short vid_y,
+ short drw_x, short drw_y, short vid_w,
+ short vid_h, short drw_w, short drw_h,
+ RegionPtr clipBoxes, pointer data,
+ DrawablePtr pDraw);
+typedef int (*GetStillFuncPtr) (ScrnInfoPtr pScrn, short vid_x, short vid_y,
+ short drw_x, short drw_y, short vid_w,
+ short vid_h, short drw_w, short drw_h,
+ RegionPtr clipBoxes, pointer data,
+ DrawablePtr pDraw);
+typedef void (*StopVideoFuncPtr) (ScrnInfoPtr pScrn, pointer data, Bool Exit);
+typedef int (*SetPortAttributeFuncPtr) (ScrnInfoPtr pScrn, Atom attribute,
+ INT32 value, pointer data);
+typedef int (*GetPortAttributeFuncPtr) (ScrnInfoPtr pScrn, Atom attribute,
+ INT32 *value, pointer data);
+typedef void (*QueryBestSizeFuncPtr) (ScrnInfoPtr pScrn, Bool motion,
+ short vid_w, short vid_h, short drw_w,
+ short drw_h, unsigned int *p_w,
+ unsigned int *p_h, pointer data);
+typedef int (*PutImageFuncPtr) (ScrnInfoPtr pScrn, short src_x, short src_y,
+ short drw_x, short drw_y, short src_w,
+ short src_h, short drw_w, short drw_h,
+ int image, unsigned char *buf, short width,
+ short height, Bool Sync, RegionPtr clipBoxes,
+ pointer data, DrawablePtr pDraw);
+typedef int (*ReputImageFuncPtr) (ScrnInfoPtr pScrn, short 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, pointer data,
+ DrawablePtr pDraw);
+typedef int (*QueryImageAttributesFuncPtr) (ScrnInfoPtr pScrn, int image,
+ unsigned short *width,
+ unsigned short *height,
+ int *pitches, int *offsets);
+typedef void (*ClipNotifyFuncPtr) (ScrnInfoPtr pScrn, pointer data,
+ WindowPtr window, int dx, int dy);
+
+typedef enum {
+ XV_OFF,
+ XV_PENDING,
+ XV_ON
+} XvStatus;
+
+/*** this is what the driver needs to fill out ***/
+
+typedef struct {
+ int id;
+ char *name;
+ unsigned short width, height;
+ XvRationalRec rate;
+} XF86VideoEncodingRec, *XF86VideoEncodingPtr;
+
+typedef struct {
+ char depth;
+ short class;
+} XF86VideoFormatRec, *XF86VideoFormatPtr;
+
+typedef struct {
+ int flags;
+ int min_value;
+ int max_value;
+ char *name;
+} XF86AttributeRec, *XF86AttributePtr;
+
+typedef struct {
+ unsigned int type;
+ int flags;
+ char *name;
+ int nEncodings;
+ XF86VideoEncodingPtr pEncodings;
+ int nFormats;
+ XF86VideoFormatPtr pFormats;
+ int nPorts;
+ DevUnion *pPortPrivates;
+ int nAttributes;
+ XF86AttributePtr pAttributes;
+ int nImages;
+ XF86ImagePtr pImages;
+ PutVideoFuncPtr PutVideo;
+ PutStillFuncPtr PutStill;
+ GetVideoFuncPtr GetVideo;
+ GetStillFuncPtr GetStill;
+ StopVideoFuncPtr StopVideo;
+ SetPortAttributeFuncPtr SetPortAttribute;
+ GetPortAttributeFuncPtr GetPortAttribute;
+ QueryBestSizeFuncPtr QueryBestSize;
+ PutImageFuncPtr PutImage;
+ ReputImageFuncPtr ReputImage; /* image/still */
+ QueryImageAttributesFuncPtr QueryImageAttributes;
+ ClipNotifyFuncPtr ClipNotify;
+} XF86VideoAdaptorRec, *XF86VideoAdaptorPtr;
+
+typedef struct {
+ XF86ImagePtr image;
+ int flags;
+ int (*alloc_surface) (ScrnInfoPtr pScrn,
+ int id,
+ unsigned short width,
+ unsigned short height, XF86SurfacePtr surface);
+ int (*free_surface) (XF86SurfacePtr surface);
+ int (*display) (XF86SurfacePtr surface,
+ short vid_x, short vid_y,
+ short drw_x, short drw_y,
+ short vid_w, short vid_h,
+ short drw_w, short drw_h, RegionPtr clipBoxes);
+ int (*stop) (XF86SurfacePtr surface);
+ int (*getAttribute) (ScrnInfoPtr pScrn, Atom attr, INT32 *value);
+ int (*setAttribute) (ScrnInfoPtr pScrn, Atom attr, INT32 value);
+ int max_width;
+ int max_height;
+ int num_attributes;
+ XF86AttributePtr attributes;
+} XF86OffscreenImageRec, *XF86OffscreenImagePtr;
+
+extern _X_EXPORT Bool
+ xf86XVScreenInit(ScreenPtr pScreen, XF86VideoAdaptorPtr * Adaptors, int num);
+
+typedef int (*xf86XVInitGenericAdaptorPtr) (ScrnInfoPtr pScrn,
+ XF86VideoAdaptorPtr ** Adaptors);
+
+extern _X_EXPORT int
+ xf86XVRegisterGenericAdaptorDriver(xf86XVInitGenericAdaptorPtr InitFunc);
+
+extern _X_EXPORT int
+ xf86XVListGenericAdaptors(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr ** Adaptors);
+
+extern _X_EXPORT Bool
+
+xf86XVRegisterOffscreenImages(ScreenPtr pScreen,
+ XF86OffscreenImagePtr images, int num);
+
+extern _X_EXPORT XF86OffscreenImagePtr
+xf86XVQueryOffscreenImages(ScreenPtr pScreen, int *num);
+
+extern _X_EXPORT XF86VideoAdaptorPtr xf86XVAllocateVideoAdaptorRec(ScrnInfoPtr
+ pScrn);
+
+extern _X_EXPORT void xf86XVFreeVideoAdaptorRec(XF86VideoAdaptorPtr ptr);
+
+extern _X_EXPORT void
+ xf86XVFillKeyHelper(ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes);
+
+extern _X_EXPORT void
+
+xf86XVFillKeyHelperDrawable(DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes);
+
+extern _X_EXPORT void
+
+xf86XVFillKeyHelperPort(DrawablePtr pDraw, pointer data, CARD32 key,
+ RegionPtr clipboxes, Bool fillEverything);
+
+extern _X_EXPORT Bool
+
+xf86XVClipVideoHelper(BoxPtr dst,
+ INT32 *xa,
+ INT32 *xb,
+ INT32 *ya,
+ INT32 *yb, RegionPtr reg, INT32 width, INT32 height);
+
+extern _X_EXPORT void
+
+xf86XVCopyYUV12ToPacked(const void *srcy,
+ const void *srcv,
+ const void *srcu,
+ void *dst,
+ int srcPitchy,
+ int srcPitchuv, int dstPitch, int h, int w);
+
+extern _X_EXPORT void
+
+xf86XVCopyPacked(const void *src,
+ void *dst, int srcPitch, int dstPitch, int h, int w);
+
+extern _X_EXPORT DevPrivateKey (*XvGetScreenKeyProc) (void);
+extern _X_EXPORT unsigned long (*XvGetRTPortProc) (void);
+extern _X_EXPORT int (*XvScreenInitProc) (ScreenPtr);
+
+#endif /* _XF86XV_H_ */
diff --git a/xorg-server/hw/xfree86/common/xf86xvmc.c b/xorg-server/hw/xfree86/common/xf86xvmc.c
index 5a7f69d8a..e58465289 100644
--- a/xorg-server/hw/xfree86/common/xf86xvmc.c
+++ b/xorg-server/hw/xfree86/common/xf86xvmc.c
@@ -1,232 +1,224 @@
-
-/*
- * Copyright (c) 2001-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "scrnintstr.h"
-#include "resource.h"
-#include "dixstruct.h"
-
-#include "xvmodproc.h"
-
-#include "xf86xvpriv.h"
-#include "xf86xvmc.h"
-
-XvMCScreenInitProcPtr XvMCScreenInitProc = NULL;
-
-
-typedef struct {
- CloseScreenProcPtr CloseScreen;
- int num_adaptors;
- XF86MCAdaptorPtr *adaptors;
- XvMCAdaptorPtr dixinfo;
-} xf86XvMCScreenRec, *xf86XvMCScreenPtr;
-
-static DevPrivateKeyRec XF86XvMCScreenKeyRec;
-#define XF86XvMCScreenKey (&XF86XvMCScreenKeyRec)
-
-#define XF86XVMC_GET_PRIVATE(pScreen) (xf86XvMCScreenPtr) \
- dixLookupPrivate(&(pScreen)->devPrivates, XF86XvMCScreenKey)
-
-
-static int
-xf86XvMCCreateContext (
- XvPortPtr pPort,
- XvMCContextPtr pContext,
- int *num_priv,
- CARD32 **priv
-)
-{
- xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
- ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
-
- pContext->port_priv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
-
- return (*pScreenPriv->adaptors[pContext->adapt_num]->CreateContext)(
- pScrn, pContext, num_priv, priv);
-}
-
-static void
-xf86XvMCDestroyContext ( XvMCContextPtr pContext)
-{
- xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
- ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
-
- (*pScreenPriv->adaptors[pContext->adapt_num]->DestroyContext)(
- pScrn, pContext);
-}
-
-static int
-xf86XvMCCreateSurface (
- XvMCSurfacePtr pSurface,
- int *num_priv,
- CARD32 **priv
-)
-{
- XvMCContextPtr pContext = pSurface->context;
- xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
- ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
-
- return (*pScreenPriv->adaptors[pContext->adapt_num]->CreateSurface)(
- pScrn, pSurface, num_priv, priv);
-}
-
-static void
-xf86XvMCDestroySurface (XvMCSurfacePtr pSurface)
-{
- XvMCContextPtr pContext = pSurface->context;
- xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
- ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
-
- (*pScreenPriv->adaptors[pContext->adapt_num]->DestroySurface)(
- pScrn, pSurface);
-}
-
-static int
-xf86XvMCCreateSubpicture (
- XvMCSubpicturePtr pSubpicture,
- int *num_priv,
- CARD32 **priv
-)
-{
- XvMCContextPtr pContext = pSubpicture->context;
- xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
- ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
-
- return (*pScreenPriv->adaptors[pContext->adapt_num]->CreateSubpicture)(
- pScrn, pSubpicture, num_priv, priv);
-}
-
-static void
-xf86XvMCDestroySubpicture (XvMCSubpicturePtr pSubpicture)
-{
- XvMCContextPtr pContext = pSubpicture->context;
- xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
- ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
-
- (*pScreenPriv->adaptors[pContext->adapt_num]->DestroySubpicture)(
- pScrn, pSubpicture);
-}
-
-
-static Bool
-xf86XvMCCloseScreen (int i, ScreenPtr pScreen)
-{
- xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pScreen);
-
- pScreen->CloseScreen = pScreenPriv->CloseScreen;
-
- free(pScreenPriv->dixinfo);
- free(pScreenPriv);
-
- return (*pScreen->CloseScreen)(i, pScreen);
-}
-
-Bool xf86XvMCScreenInit(
- ScreenPtr pScreen,
- int num_adaptors,
- XF86MCAdaptorPtr *adaptors
-)
-{
- XvMCAdaptorPtr pAdapt;
- xf86XvMCScreenPtr pScreenPriv;
- XvScreenPtr pxvs = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
- XF86XvScreenKey);
- int i, j;
-
- if(!XvMCScreenInitProc) return FALSE;
-
- if(!(pAdapt = malloc(sizeof(XvMCAdaptorRec) * num_adaptors)))
- return FALSE;
-
- if (!dixRegisterPrivateKey(&XF86XvMCScreenKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
-
- if(!(pScreenPriv = malloc(sizeof(xf86XvMCScreenRec)))) {
- free(pAdapt);
- return FALSE;
- }
-
- dixSetPrivate(&pScreen->devPrivates, XF86XvMCScreenKey, pScreenPriv);
-
- pScreenPriv->CloseScreen = pScreen->CloseScreen;
- pScreen->CloseScreen = xf86XvMCCloseScreen;
-
- pScreenPriv->num_adaptors = num_adaptors;
- pScreenPriv->adaptors = adaptors;
- pScreenPriv->dixinfo = pAdapt;
-
- for(i = 0; i < num_adaptors; i++) {
- pAdapt[i].xv_adaptor = NULL;
- for(j = 0; j < pxvs->nAdaptors; j++) {
- if(!strcmp((*adaptors)->name, pxvs->pAdaptors[j].name)) {
- pAdapt[i].xv_adaptor = &(pxvs->pAdaptors[j]);
- break;
- }
- }
- if(!pAdapt[i].xv_adaptor) {
- /* no adaptor by that name */
- free(pAdapt);
- return FALSE;
- }
- pAdapt[i].num_surfaces = (*adaptors)->num_surfaces;
- pAdapt[i].surfaces = (XvMCSurfaceInfoPtr*)((*adaptors)->surfaces);
- pAdapt[i].num_subpictures = (*adaptors)->num_subpictures;
- pAdapt[i].subpictures = (XvImagePtr*)((*adaptors)->subpictures);
- pAdapt[i].CreateContext = xf86XvMCCreateContext;
- pAdapt[i].DestroyContext = xf86XvMCDestroyContext;
- pAdapt[i].CreateSurface = xf86XvMCCreateSurface;
- pAdapt[i].DestroySurface = xf86XvMCDestroySurface;
- pAdapt[i].CreateSubpicture = xf86XvMCCreateSubpicture;
- pAdapt[i].DestroySubpicture = xf86XvMCDestroySubpicture;
- adaptors++;
- }
-
- if(Success != (*XvMCScreenInitProc)(pScreen, num_adaptors, pAdapt))
- return FALSE;
-
- return TRUE;
-}
-
-XF86MCAdaptorPtr xf86XvMCCreateAdaptorRec (void)
-{
- return calloc(1, sizeof(XF86MCAdaptorRec));
-}
-
-void xf86XvMCDestroyAdaptorRec(XF86MCAdaptorPtr adaptor)
-{
- free(adaptor);
-}
+
+/*
+ * Copyright (c) 2001-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "resource.h"
+#include "dixstruct.h"
+
+#include "xvmodproc.h"
+
+#include "xf86xvpriv.h"
+#include "xf86xvmc.h"
+
+XvMCScreenInitProcPtr XvMCScreenInitProc = NULL;
+
+typedef struct {
+ CloseScreenProcPtr CloseScreen;
+ int num_adaptors;
+ XF86MCAdaptorPtr *adaptors;
+ XvMCAdaptorPtr dixinfo;
+} xf86XvMCScreenRec, *xf86XvMCScreenPtr;
+
+static DevPrivateKeyRec XF86XvMCScreenKeyRec;
+
+#define XF86XvMCScreenKey (&XF86XvMCScreenKeyRec)
+
+#define XF86XVMC_GET_PRIVATE(pScreen) (xf86XvMCScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, XF86XvMCScreenKey)
+
+static int
+xf86XvMCCreateContext(XvPortPtr pPort,
+ XvMCContextPtr pContext, int *num_priv, CARD32 **priv)
+{
+ xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+
+ pContext->port_priv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+
+ return (*pScreenPriv->adaptors[pContext->adapt_num]->CreateContext) (pScrn,
+ pContext,
+ num_priv,
+ priv);
+}
+
+static void
+xf86XvMCDestroyContext(XvMCContextPtr pContext)
+{
+ xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+
+ (*pScreenPriv->adaptors[pContext->adapt_num]->DestroyContext) (pScrn,
+ pContext);
+}
+
+static int
+xf86XvMCCreateSurface(XvMCSurfacePtr pSurface, int *num_priv, CARD32 **priv)
+{
+ XvMCContextPtr pContext = pSurface->context;
+ xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+
+ return (*pScreenPriv->adaptors[pContext->adapt_num]->CreateSurface) (pScrn,
+ pSurface,
+ num_priv,
+ priv);
+}
+
+static void
+xf86XvMCDestroySurface(XvMCSurfacePtr pSurface)
+{
+ XvMCContextPtr pContext = pSurface->context;
+ xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+
+ (*pScreenPriv->adaptors[pContext->adapt_num]->DestroySurface) (pScrn,
+ pSurface);
+}
+
+static int
+xf86XvMCCreateSubpicture(XvMCSubpicturePtr pSubpicture,
+ int *num_priv, CARD32 **priv)
+{
+ XvMCContextPtr pContext = pSubpicture->context;
+ xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+
+ return (*pScreenPriv->adaptors[pContext->adapt_num]->
+ CreateSubpicture) (pScrn, pSubpicture, num_priv, priv);
+}
+
+static void
+xf86XvMCDestroySubpicture(XvMCSubpicturePtr pSubpicture)
+{
+ XvMCContextPtr pContext = pSubpicture->context;
+ xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+
+ (*pScreenPriv->adaptors[pContext->adapt_num]->DestroySubpicture) (pScrn,
+ pSubpicture);
+}
+
+static Bool
+xf86XvMCCloseScreen(int i, ScreenPtr pScreen)
+{
+ xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pScreen);
+
+ pScreen->CloseScreen = pScreenPriv->CloseScreen;
+
+ free(pScreenPriv->dixinfo);
+ free(pScreenPriv);
+
+ return (*pScreen->CloseScreen) (i, pScreen);
+}
+
+Bool
+xf86XvMCScreenInit(ScreenPtr pScreen,
+ int num_adaptors, XF86MCAdaptorPtr * adaptors)
+{
+ XvMCAdaptorPtr pAdapt;
+ xf86XvMCScreenPtr pScreenPriv;
+ XvScreenPtr pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ XF86XvScreenKey);
+ int i, j;
+
+ if (!XvMCScreenInitProc)
+ return FALSE;
+
+ if (!(pAdapt = malloc(sizeof(XvMCAdaptorRec) * num_adaptors)))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&XF86XvMCScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ if (!(pScreenPriv = malloc(sizeof(xf86XvMCScreenRec)))) {
+ free(pAdapt);
+ return FALSE;
+ }
+
+ dixSetPrivate(&pScreen->devPrivates, XF86XvMCScreenKey, pScreenPriv);
+
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = xf86XvMCCloseScreen;
+
+ pScreenPriv->num_adaptors = num_adaptors;
+ pScreenPriv->adaptors = adaptors;
+ pScreenPriv->dixinfo = pAdapt;
+
+ for (i = 0; i < num_adaptors; i++) {
+ pAdapt[i].xv_adaptor = NULL;
+ for (j = 0; j < pxvs->nAdaptors; j++) {
+ if (!strcmp((*adaptors)->name, pxvs->pAdaptors[j].name)) {
+ pAdapt[i].xv_adaptor = &(pxvs->pAdaptors[j]);
+ break;
+ }
+ }
+ if (!pAdapt[i].xv_adaptor) {
+ /* no adaptor by that name */
+ free(pAdapt);
+ return FALSE;
+ }
+ pAdapt[i].num_surfaces = (*adaptors)->num_surfaces;
+ pAdapt[i].surfaces = (XvMCSurfaceInfoPtr *) ((*adaptors)->surfaces);
+ pAdapt[i].num_subpictures = (*adaptors)->num_subpictures;
+ pAdapt[i].subpictures = (XvImagePtr *) ((*adaptors)->subpictures);
+ pAdapt[i].CreateContext = xf86XvMCCreateContext;
+ pAdapt[i].DestroyContext = xf86XvMCDestroyContext;
+ pAdapt[i].CreateSurface = xf86XvMCCreateSurface;
+ pAdapt[i].DestroySurface = xf86XvMCDestroySurface;
+ pAdapt[i].CreateSubpicture = xf86XvMCCreateSubpicture;
+ pAdapt[i].DestroySubpicture = xf86XvMCDestroySubpicture;
+ adaptors++;
+ }
+
+ if (Success != (*XvMCScreenInitProc) (pScreen, num_adaptors, pAdapt))
+ return FALSE;
+
+ return TRUE;
+}
+
+XF86MCAdaptorPtr
+xf86XvMCCreateAdaptorRec(void)
+{
+ return calloc(1, sizeof(XF86MCAdaptorRec));
+}
+
+void
+xf86XvMCDestroyAdaptorRec(XF86MCAdaptorPtr adaptor)
+{
+ free(adaptor);
+}
diff --git a/xorg-server/hw/xfree86/common/xf86xvmc.h b/xorg-server/hw/xfree86/common/xf86xvmc.h
index 902b4f8fc..ff32379fe 100644
--- a/xorg-server/hw/xfree86/common/xf86xvmc.h
+++ b/xorg-server/hw/xfree86/common/xf86xvmc.h
@@ -33,24 +33,23 @@
#include "xf86xv.h"
typedef struct {
- int num_xvimages;
- int *xvimage_ids; /* reference the subpictures in the XF86MCAdaptorRec */
-} XF86MCImageIDList;
+ int num_xvimages;
+ int *xvimage_ids; /* reference the subpictures in the XF86MCAdaptorRec */
+} XF86MCImageIDList;
typedef struct {
- int surface_type_id; /* Driver generated. Must be unique on the port */
- int chroma_format;
- int color_description; /* no longer used */
- unsigned short max_width;
- unsigned short max_height;
- unsigned short subpicture_max_width;
- unsigned short subpicture_max_height;
- int mc_type;
- int flags;
- XF86MCImageIDList *compatible_subpictures; /* can be null, if none */
+ int surface_type_id; /* Driver generated. Must be unique on the port */
+ int chroma_format;
+ int color_description; /* no longer used */
+ unsigned short max_width;
+ unsigned short max_height;
+ unsigned short subpicture_max_width;
+ unsigned short subpicture_max_height;
+ int mc_type;
+ int flags;
+ XF86MCImageIDList *compatible_subpictures; /* can be null, if none */
} XF86MCSurfaceInfoRec, *XF86MCSurfaceInfoPtr;
-
/*
xf86XvMCCreateContextProc
@@ -63,19 +62,13 @@ typedef struct {
of 32 bit words in num_priv. This must be dynamically allocated
space because DIX will free it after it passes it to the client.
*/
-
-typedef int (*xf86XvMCCreateContextProcPtr) (
- ScrnInfoPtr pScrn,
- XvMCContextPtr context,
- int *num_priv,
- CARD32 **priv
-);
+typedef int (*xf86XvMCCreateContextProcPtr) (ScrnInfoPtr pScrn,
+ XvMCContextPtr context,
+ int *num_priv, CARD32 **priv);
-typedef void (*xf86XvMCDestroyContextProcPtr) (
- ScrnInfoPtr pScrn,
- XvMCContextPtr context
-);
+typedef void (*xf86XvMCDestroyContextProcPtr) (ScrnInfoPtr pScrn,
+ XvMCContextPtr context);
/*
xf86XvMCCreateSurfaceProc
@@ -86,18 +79,12 @@ typedef void (*xf86XvMCDestroyContextProcPtr) (
xf86XvMCCreateContextProc.
*/
+typedef int (*xf86XvMCCreateSurfaceProcPtr) (ScrnInfoPtr pScrn,
+ XvMCSurfacePtr surface,
+ int *num_priv, CARD32 **priv);
-typedef int (*xf86XvMCCreateSurfaceProcPtr) (
- ScrnInfoPtr pScrn,
- XvMCSurfacePtr surface,
- int *num_priv,
- CARD32 **priv
-);
-
-typedef void (*xf86XvMCDestroySurfaceProcPtr) (
- ScrnInfoPtr pScrn,
- XvMCSurfacePtr surface
-);
+typedef void (*xf86XvMCDestroySurfaceProcPtr) (ScrnInfoPtr pScrn,
+ XvMCSurfacePtr surface);
/*
xf86XvMCCreateSubpictureProc
@@ -114,32 +101,25 @@ typedef void (*xf86XvMCDestroySurfaceProcPtr) (
xf86XvMCCreateContextProc.
*/
+typedef int (*xf86XvMCCreateSubpictureProcPtr) (ScrnInfoPtr pScrn,
+ XvMCSubpicturePtr subpicture,
+ int *num_priv, CARD32 **priv);
-typedef int (*xf86XvMCCreateSubpictureProcPtr) (
- ScrnInfoPtr pScrn,
- XvMCSubpicturePtr subpicture,
- int *num_priv,
- CARD32 **priv
-);
-
-typedef void (*xf86XvMCDestroySubpictureProcPtr) (
- ScrnInfoPtr pScrn,
- XvMCSubpicturePtr subpicture
-);
-
+typedef void (*xf86XvMCDestroySubpictureProcPtr) (ScrnInfoPtr pScrn,
+ XvMCSubpicturePtr subpicture);
typedef struct {
- char *name;
- int num_surfaces;
- XF86MCSurfaceInfoPtr *surfaces;
- int num_subpictures;
- XF86ImagePtr *subpictures;
- xf86XvMCCreateContextProcPtr CreateContext;
- xf86XvMCDestroyContextProcPtr DestroyContext;
- xf86XvMCCreateSurfaceProcPtr CreateSurface;
- xf86XvMCDestroySurfaceProcPtr DestroySurface;
- xf86XvMCCreateSubpictureProcPtr CreateSubpicture;
- xf86XvMCDestroySubpictureProcPtr DestroySubpicture;
+ char *name;
+ int num_surfaces;
+ XF86MCSurfaceInfoPtr *surfaces;
+ int num_subpictures;
+ XF86ImagePtr *subpictures;
+ xf86XvMCCreateContextProcPtr CreateContext;
+ xf86XvMCDestroyContextProcPtr DestroyContext;
+ xf86XvMCCreateSurfaceProcPtr CreateSurface;
+ xf86XvMCDestroySurfaceProcPtr DestroySurface;
+ xf86XvMCCreateSubpictureProcPtr CreateSubpicture;
+ xf86XvMCDestroySubpictureProcPtr DestroySubpicture;
} XF86MCAdaptorRec, *XF86MCAdaptorPtr;
/*
@@ -151,16 +131,14 @@ typedef struct {
an array of structures.
*/
-extern _X_EXPORT Bool xf86XvMCScreenInit(
- ScreenPtr pScreen,
- int num_adaptors,
- XF86MCAdaptorPtr *adaptors
-);
+extern _X_EXPORT Bool xf86XvMCScreenInit(ScreenPtr pScreen,
+ int num_adaptors,
+ XF86MCAdaptorPtr * adaptors);
-extern _X_EXPORT XF86MCAdaptorPtr xf86XvMCCreateAdaptorRec (void);
+extern _X_EXPORT XF86MCAdaptorPtr xf86XvMCCreateAdaptorRec(void);
extern _X_EXPORT void xf86XvMCDestroyAdaptorRec(XF86MCAdaptorPtr adaptor);
-typedef int (*XvMCScreenInitProcPtr)(ScreenPtr, int, XvMCAdaptorPtr);
+typedef int (*XvMCScreenInitProcPtr) (ScreenPtr, int, XvMCAdaptorPtr);
extern _X_EXPORT XvMCScreenInitProcPtr XvMCScreenInitProc;
-#endif /* _XF86XVMC_H */
+#endif /* _XF86XVMC_H */
diff --git a/xorg-server/hw/xfree86/common/xisb.c b/xorg-server/hw/xfree86/common/xisb.c
index 287a98b53..3568a578c 100644
--- a/xorg-server/hw/xfree86/common/xisb.c
+++ b/xorg-server/hw/xfree86/common/xisb.c
@@ -1,174 +1,168 @@
-/*
- * Copyright (c) 1997 Metro Link Incorporated
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- *
- */
-
-/*
- X Input Serial Buffer routines for use in any XInput driver that accesses
- a serial device.
-*/
-
-
-/*****************************************************************************
- * Standard Headers
- ****************************************************************************/
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <misc.h>
-#include <xf86.h>
-#include <xf86_OSproc.h>
-#include <xf86_OSlib.h>
-#include <xf86Xinput.h>
-#include "xisb.h"
-
-/*****************************************************************************
- * Local Headers
- ****************************************************************************/
-
-/*****************************************************************************
- * Variables without includable headers
- ****************************************************************************/
-
-/*****************************************************************************
- * Local Variables
- ****************************************************************************/
-
-/*****************************************************************************
- * Function Definitions
- ****************************************************************************/
-
-XISBuffer *
-XisbNew (int fd, ssize_t size)
-{
- XISBuffer *b;
-
- b = malloc(sizeof (XISBuffer));
- if (!b)
- return NULL;
- b->buf = malloc((sizeof (unsigned char) * size));
- if (!b->buf)
- {
- free(b);
- return NULL;
- }
-
- b->fd = fd;
- b->trace = 0;
- b->block_duration = 0;
- b->current = 1; /* force it to be past the end to trigger initial read */
- b->end = 0;
- b->buffer_size = size;
- return b;
-}
-
-void
-XisbFree (XISBuffer *b)
-{
- free(b->buf);
- free(b);
-}
-
-int
-XisbRead (XISBuffer *b)
-{
- int ret;
-
- if (b->current >= b->end)
- {
- if (b->block_duration >= 0)
- {
- if (xf86WaitForInput (b->fd, b->block_duration) < 1)
- return -1;
- }
- else
- {
- /*
- * automatically clear it so if XisbRead is called in a loop
- * the next call will make sure there is data with select and
- * thus prevent a blocking read
- */
- b->block_duration = 0;
- }
-
- ret = xf86ReadSerial (b->fd, b->buf, b->buffer_size);
- switch (ret)
- {
- case 0:
- return -1; /* timeout */
- case -1:
- return -2; /* error */
- default:
- b->end = ret;
- b->current = 0;
- break;
- }
- }
- if (b->trace)
- ErrorF ("read 0x%02x (%c)\n", b->buf[b->current],
- isprint(b->buf[b->current])?b->buf[b->current]:'.');
-
- return b->buf[b->current++];
-}
-
-/* the only purpose of this function is to provide output tracing */
-ssize_t
-XisbWrite (XISBuffer *b, unsigned char *msg, ssize_t len)
-{
- if (b->trace)
- {
- int i = 0;
- for (i = 0; i < len; i++)
- ErrorF ("\t\twrote 0x%02x (%c)\n", msg[i], msg[i]);
- }
- return (xf86WriteSerial (b->fd, msg, len));
-}
-
-/* turn tracing of this buffer on (1) or off (0) */
-void
-XisbTrace (XISBuffer *b, int trace)
-{
- b->trace = trace;
-}
-
-/*
- * specify a block_duration of -1 when you know the buffer's fd is ready to
- * read. After a read, it is automatically set to 0 so that the next read
- * will use check to select for data and prevent a block.
- * It is the caller's responsibility to set the block_duration to -1 if it
- * knows that there is data to read (because the main select loop triggered
- * the read) and want's to avoid the unnecessary overhead of the select call
- *
- * a zero or positive block duration will cause the select to block for the
- * give duration in usecs.
- */
-
-void
-XisbBlockDuration (XISBuffer *b, int block_duration)
-{
- b->block_duration = block_duration;
-}
+/*
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+
+/*
+ X Input Serial Buffer routines for use in any XInput driver that accesses
+ a serial device.
+*/
+
+/*****************************************************************************
+ * Standard Headers
+ ****************************************************************************/
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <misc.h>
+#include <xf86.h>
+#include <xf86_OSproc.h>
+#include <xf86_OSlib.h>
+#include <xf86Xinput.h>
+#include "xisb.h"
+
+/*****************************************************************************
+ * Local Headers
+ ****************************************************************************/
+
+/*****************************************************************************
+ * Variables without includable headers
+ ****************************************************************************/
+
+/*****************************************************************************
+ * Local Variables
+ ****************************************************************************/
+
+/*****************************************************************************
+ * Function Definitions
+ ****************************************************************************/
+
+XISBuffer *
+XisbNew(int fd, ssize_t size)
+{
+ XISBuffer *b;
+
+ b = malloc(sizeof(XISBuffer));
+ if (!b)
+ return NULL;
+ b->buf = malloc((sizeof(unsigned char) * size));
+ if (!b->buf) {
+ free(b);
+ return NULL;
+ }
+
+ b->fd = fd;
+ b->trace = 0;
+ b->block_duration = 0;
+ b->current = 1; /* force it to be past the end to trigger initial read */
+ b->end = 0;
+ b->buffer_size = size;
+ return b;
+}
+
+void
+XisbFree(XISBuffer * b)
+{
+ free(b->buf);
+ free(b);
+}
+
+int
+XisbRead(XISBuffer * b)
+{
+ int ret;
+
+ if (b->current >= b->end) {
+ if (b->block_duration >= 0) {
+ if (xf86WaitForInput(b->fd, b->block_duration) < 1)
+ return -1;
+ }
+ else {
+ /*
+ * automatically clear it so if XisbRead is called in a loop
+ * the next call will make sure there is data with select and
+ * thus prevent a blocking read
+ */
+ b->block_duration = 0;
+ }
+
+ ret = xf86ReadSerial(b->fd, b->buf, b->buffer_size);
+ switch (ret) {
+ case 0:
+ return -1; /* timeout */
+ case -1:
+ return -2; /* error */
+ default:
+ b->end = ret;
+ b->current = 0;
+ break;
+ }
+ }
+ if (b->trace)
+ ErrorF("read 0x%02x (%c)\n", b->buf[b->current],
+ isprint(b->buf[b->current]) ? b->buf[b->current] : '.');
+
+ return b->buf[b->current++];
+}
+
+/* the only purpose of this function is to provide output tracing */
+ssize_t
+XisbWrite(XISBuffer * b, unsigned char *msg, ssize_t len)
+{
+ if (b->trace) {
+ int i = 0;
+
+ for (i = 0; i < len; i++)
+ ErrorF("\t\twrote 0x%02x (%c)\n", msg[i], msg[i]);
+ }
+ return (xf86WriteSerial(b->fd, msg, len));
+}
+
+/* turn tracing of this buffer on (1) or off (0) */
+void
+XisbTrace(XISBuffer * b, int trace)
+{
+ b->trace = trace;
+}
+
+/*
+ * specify a block_duration of -1 when you know the buffer's fd is ready to
+ * read. After a read, it is automatically set to 0 so that the next read
+ * will use check to select for data and prevent a block.
+ * It is the caller's responsibility to set the block_duration to -1 if it
+ * knows that there is data to read (because the main select loop triggered
+ * the read) and want's to avoid the unnecessary overhead of the select call
+ *
+ * a zero or positive block duration will cause the select to block for the
+ * give duration in usecs.
+ */
+
+void
+XisbBlockDuration(XISBuffer * b, int block_duration)
+{
+ b->block_duration = block_duration;
+}
diff --git a/xorg-server/hw/xfree86/common/xisb.h b/xorg-server/hw/xfree86/common/xisb.h
index bacfde166..6ac1a6e37 100644
--- a/xorg-server/hw/xfree86/common/xisb.h
+++ b/xorg-server/hw/xfree86/common/xisb.h
@@ -35,15 +35,14 @@
* structs, typedefs, #defines, enums
*****************************************************************************/
-typedef struct _XISBuffer
-{
- int fd;
- int trace;
- int block_duration;
- ssize_t current; /* bytes read */
- ssize_t end;
- ssize_t buffer_size;
- unsigned char *buf;
+typedef struct _XISBuffer {
+ int fd;
+ int trace;
+ int block_duration;
+ ssize_t current; /* bytes read */
+ ssize_t end;
+ ssize_t buffer_size;
+ unsigned char *buf;
} XISBuffer;
/******************************************************************************
@@ -52,12 +51,13 @@ typedef struct _XISBuffer
* of globals.
* put locals in the .c file.
*****************************************************************************/
-extern _X_EXPORT XISBuffer * XisbNew (int fd, ssize_t size);
-extern _X_EXPORT void XisbFree (XISBuffer *b);
-extern _X_EXPORT int XisbRead (XISBuffer *b);
-extern _X_EXPORT ssize_t XisbWrite (XISBuffer *b, unsigned char *msg, ssize_t len);
-extern _X_EXPORT void XisbTrace (XISBuffer *b, int trace);
-extern _X_EXPORT void XisbBlockDuration (XISBuffer *b, int block_duration);
+extern _X_EXPORT XISBuffer *XisbNew(int fd, ssize_t size);
+extern _X_EXPORT void XisbFree(XISBuffer * b);
+extern _X_EXPORT int XisbRead(XISBuffer * b);
+extern _X_EXPORT ssize_t XisbWrite(XISBuffer * b, unsigned char *msg,
+ ssize_t len);
+extern _X_EXPORT void XisbTrace(XISBuffer * b, int trace);
+extern _X_EXPORT void XisbBlockDuration(XISBuffer * b, int block_duration);
/*
* DO NOT PUT ANYTHING AFTER THIS ENDIF
diff --git a/xorg-server/hw/xfree86/ddc/ddc.c b/xorg-server/hw/xfree86/ddc/ddc.c
index 179f42ccd..a1281d735 100644
--- a/xorg-server/hw/xfree86/ddc/ddc.c
+++ b/xorg-server/hw/xfree86/ddc/ddc.c
@@ -29,10 +29,10 @@ typedef enum {
} DDCOpts;
static const OptionInfoRec DDCOptions[] = {
- { DDCOPT_NODDC1, "NoDDC1", OPTV_BOOLEAN, {0}, FALSE },
- { DDCOPT_NODDC2, "NoDDC2", OPTV_BOOLEAN, {0}, FALSE },
- { DDCOPT_NODDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE },
- { -1, NULL, OPTV_NONE, {0}, FALSE },
+ {DDCOPT_NODDC1, "NoDDC1", OPTV_BOOLEAN, {0}, FALSE},
+ {DDCOPT_NODDC2, "NoDDC2", OPTV_BOOLEAN, {0}, FALSE},
+ {DDCOPT_NODDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE},
+ {-1, NULL, OPTV_NONE, {0}, FALSE},
};
/* DDC1 */
@@ -41,19 +41,20 @@ static int
find_start(unsigned int *ptr)
{
unsigned int comp[9], test[9];
- int i,j;
-
- for (i=0;i<9;i++){
- comp[i] = *(ptr++);
- test[i] = 1;
+ int i, j;
+
+ for (i = 0; i < 9; i++) {
+ comp[i] = *(ptr++);
+ test[i] = 1;
}
- for (i=0;i<127;i++){
- for (j=0;j<9;j++){
- test[j] = test[j] & !(comp[j] ^ *(ptr++));
- }
+ for (i = 0; i < 127; i++) {
+ for (j = 0; j < 9; j++) {
+ test[j] = test[j] & !(comp[j] ^ *(ptr++));
+ }
}
- for (i=0;i<9;i++)
- if (test[i]) return i+1;
+ for (i = 0; i < 9; i++)
+ if (test[i])
+ return i + 1;
return -1;
}
@@ -61,21 +62,26 @@ static unsigned char *
find_header(unsigned char *block)
{
unsigned char *ptr, *head_ptr, *end;
- unsigned char header[]={0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00};
-
+ unsigned char header[] = { 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 };
+
ptr = block;
end = block + EDID1_LEN;
- while (ptr<end) {
- int i;
- head_ptr = ptr;
- for (i=0;i<8;i++){
- if (header[i] != *(head_ptr++)) break;
- if (head_ptr == end) head_ptr = block;
- }
- if (i==8) break;
- ptr++;
+ while (ptr < end) {
+ int i;
+
+ head_ptr = ptr;
+ for (i = 0; i < 8; i++) {
+ if (header[i] != *(head_ptr++))
+ break;
+ if (head_ptr == end)
+ head_ptr = block;
+ }
+ if (i == 8)
+ break;
+ ptr++;
}
- if (ptr == end) return NULL;
+ if (ptr == end)
+ return NULL;
return ptr;
}
@@ -87,15 +93,18 @@ resort(unsigned char *s_block)
s_end = s_block + EDID1_LEN;
d_new = malloc(EDID1_LEN);
- if (!d_new) return NULL;
+ if (!d_new)
+ return NULL;
d_end = d_new + EDID1_LEN;
s_ptr = find_header(s_block);
- if (!s_ptr) return NULL;
- for (d_ptr=d_new;d_ptr<d_end;d_ptr++){
- tmp = *(s_ptr++);
- *d_ptr = tmp;
- if (s_ptr == s_end) s_ptr = s_block;
+ if (!s_ptr)
+ return NULL;
+ for (d_ptr = d_new; d_ptr < d_end; d_ptr++) {
+ tmp = *(s_ptr++);
+ *d_ptr = tmp;
+ if (s_ptr == s_end)
+ s_ptr = s_block;
}
free(s_block);
return d_new;
@@ -106,21 +115,24 @@ DDC_checksum(const unsigned char *block, int len)
{
int i, result = 0;
int not_null = 0;
-
- for (i=0;i<len;i++) {
- not_null |= block[i];
- result += block[i];
+
+ for (i = 0; i < len; i++) {
+ not_null |= block[i];
+ result += block[i];
}
-
+
#ifdef DEBUG
- if (result & 0xFF) ErrorF("DDC checksum not correct\n");
- if (!not_null) ErrorF("DDC read all Null\n");
+ if (result & 0xFF)
+ ErrorF("DDC checksum not correct\n");
+ if (!not_null)
+ ErrorF("DDC read all Null\n");
#endif
/* catch the trivial case where all bytes are 0 */
- if (!not_null) return 1;
+ if (!not_null)
+ return 1;
- return result&0xFF;
+ return result & 0xFF;
}
static unsigned char *
@@ -129,64 +141,73 @@ GetEDID_DDC1(unsigned int *s_ptr)
unsigned char *d_block, *d_pos;
unsigned int *s_pos, *s_end;
int s_start;
- int i,j;
+ int i, j;
+
s_start = find_start(s_ptr);
- if (s_start==-1) return NULL;
+ if (s_start == -1)
+ return NULL;
s_end = s_ptr + NUM;
s_pos = s_ptr + s_start;
- d_block=malloc(EDID1_LEN);
- if (!d_block) return NULL;
+ d_block = malloc(EDID1_LEN);
+ if (!d_block)
+ return NULL;
d_pos = d_block;
- for (i=0;i<EDID1_LEN;i++) {
- for (j=0;j<8;j++) {
- *d_pos <<= 1;
- if (*s_pos) {
- *d_pos |= 0x01;
- }
- s_pos++; if (s_pos == s_end) s_pos=s_ptr;
- };
- s_pos++; if (s_pos == s_end) s_pos=s_ptr;
- d_pos++;
+ for (i = 0; i < EDID1_LEN; i++) {
+ for (j = 0; j < 8; j++) {
+ *d_pos <<= 1;
+ if (*s_pos) {
+ *d_pos |= 0x01;
+ }
+ s_pos++;
+ if (s_pos == s_end)
+ s_pos = s_ptr;
+ };
+ s_pos++;
+ if (s_pos == s_end)
+ s_pos = s_ptr;
+ d_pos++;
}
free(s_ptr);
- if (d_block && DDC_checksum(d_block,EDID1_LEN)) {
- free(d_block);
- return NULL;
+ if (d_block && DDC_checksum(d_block, EDID1_LEN)) {
+ free(d_block);
+ return NULL;
}
return (resort(d_block));
}
/* fetch entire EDID record; DDC bit needs to be masked */
-static unsigned int *
+static unsigned int *
FetchEDID_DDC1(register ScrnInfoPtr pScrn,
- register unsigned int (*read_DDC)(ScrnInfoPtr))
+ register unsigned int (*read_DDC) (ScrnInfoPtr))
{
int count = NUM;
unsigned int *ptr, *xp;
- ptr=xp=malloc(sizeof(int)*NUM);
+ ptr = xp = malloc(sizeof(int) * NUM);
- if (!ptr) return NULL;
+ if (!ptr)
+ return NULL;
do {
- /* wait for next retrace */
- *xp = read_DDC(pScrn);
- xp++;
- } while(--count);
+ /* wait for next retrace */
+ *xp = read_DDC(pScrn);
+ xp++;
+ } while (--count);
return ptr;
}
/* test if DDC1 return 0 if not */
static Bool
-TestDDC1(ScrnInfoPtr pScrn, unsigned int (*read_DDC)(ScrnInfoPtr))
+TestDDC1(ScrnInfoPtr pScrn, unsigned int (*read_DDC) (ScrnInfoPtr))
{
int old, count;
old = read_DDC(pScrn);
count = HEADER * BITS_PER_BYTE;
do {
- /* wait for next retrace */
- if (old != read_DDC(pScrn)) break;
- } while(count--);
+ /* wait for next retrace */
+ if (old != read_DDC(pScrn))
+ break;
+ } while (count--);
return count;
}
@@ -196,29 +217,31 @@ TestDDC1(ScrnInfoPtr pScrn, unsigned int (*read_DDC)(ScrnInfoPtr))
* function; it will also decide if we need to reread it
*/
static unsigned char *
-EDIDRead_DDC1(ScrnInfoPtr pScrn, DDC1SetSpeedProc DDCSpeed,
- unsigned int (*read_DDC)(ScrnInfoPtr))
+EDIDRead_DDC1(ScrnInfoPtr pScrn, DDC1SetSpeedProc DDCSpeed,
+ unsigned int (*read_DDC) (ScrnInfoPtr))
{
unsigned char *EDID_block = NULL;
int count = RETRIES;
- if (!read_DDC) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "chipset doesn't support DDC1\n");
- return NULL;
+ if (!read_DDC) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "chipset doesn't support DDC1\n");
+ return NULL;
};
- if (TestDDC1(pScrn,read_DDC)==-1) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "No DDC signal\n");
- return NULL;
+ if (TestDDC1(pScrn, read_DDC) == -1) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "No DDC signal\n");
+ return NULL;
};
- if (DDCSpeed) DDCSpeed(pScrn,DDC_FAST);
+ if (DDCSpeed)
+ DDCSpeed(pScrn, DDC_FAST);
do {
- EDID_block = GetEDID_DDC1(FetchEDID_DDC1(pScrn,read_DDC));
- count --;
+ EDID_block = GetEDID_DDC1(FetchEDID_DDC1(pScrn, read_DDC));
+ count--;
} while (!EDID_block && count);
- if (DDCSpeed) DDCSpeed(pScrn,DDC_SLOW);
+ if (DDCSpeed)
+ DDCSpeed(pScrn, DDC_SLOW);
return EDID_block;
}
@@ -235,40 +258,42 @@ EDIDRead_DDC1(ScrnInfoPtr pScrn, DDC1SetSpeedProc DDCSpeed,
* @return NULL if no monitor attached or failure to interpret the EDID.
*/
xf86MonPtr
-xf86DoEDID_DDC1(int scrnIndex, DDC1SetSpeedProc DDC1SetSpeed,
- unsigned int (*DDC1Read)(ScrnInfoPtr))
+xf86DoEDID_DDC1(int scrnIndex, DDC1SetSpeedProc DDC1SetSpeed,
+ unsigned int (*DDC1Read) (ScrnInfoPtr))
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
unsigned char *EDID_block = NULL;
xf86MonPtr tmp = NULL;
+
/* Default DDC and DDC1 to enabled. */
Bool noddc = FALSE, noddc1 = FALSE;
OptionInfoPtr options;
options = xnfalloc(sizeof(DDCOptions));
- (void)memcpy(options, DDCOptions, sizeof(DDCOptions));
+ (void) memcpy(options, DDCOptions, sizeof(DDCOptions));
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
xf86GetOptValBool(options, DDCOPT_NODDC, &noddc);
xf86GetOptValBool(options, DDCOPT_NODDC1, &noddc1);
free(options);
-
+
if (noddc || noddc1)
- return NULL;
-
+ return NULL;
+
OsBlockSignals();
- EDID_block = EDIDRead_DDC1(pScrn,DDC1SetSpeed,DDC1Read);
+ EDID_block = EDIDRead_DDC1(pScrn, DDC1SetSpeed, DDC1Read);
OsReleaseSignals();
- if (EDID_block){
- tmp = xf86InterpretEDID(scrnIndex,EDID_block);
+ if (EDID_block) {
+ tmp = xf86InterpretEDID(scrnIndex, EDID_block);
}
#ifdef DEBUG
- else ErrorF("No EDID block returned\n");
+ else
+ ErrorF("No EDID block returned\n");
if (!tmp)
- ErrorF("Cannot interpret EDID block\n");
+ ErrorF("Cannot interpret EDID block\n");
#endif
- return tmp;
+ return tmp;
}
/* DDC2 */
@@ -279,19 +304,19 @@ DDC2MakeDevice(I2CBusPtr pBus, int address, char *name)
I2CDevPtr dev = NULL;
if (!(dev = xf86I2CFindDev(pBus, address))) {
- dev = xf86CreateI2CDevRec();
- dev->DevName = name;
- dev->SlaveAddr = address;
- dev->ByteTimeout = 2200; /* VESA DDC spec 3 p. 43 (+10 %) */
- dev->StartTimeout = 550;
- dev->BitTimeout = 40;
- dev->AcknTimeout = 40;
-
- dev->pI2CBus = pBus;
- if (!xf86I2CDevInit(dev)) {
- xf86DrvMsg(pBus->scrnIndex, X_PROBED, "No DDC2 device\n");
- return NULL;
- }
+ dev = xf86CreateI2CDevRec();
+ dev->DevName = name;
+ dev->SlaveAddr = address;
+ dev->ByteTimeout = 2200; /* VESA DDC spec 3 p. 43 (+10 %) */
+ dev->StartTimeout = 550;
+ dev->BitTimeout = 40;
+ dev->AcknTimeout = 40;
+
+ dev->pI2CBus = pBus;
+ if (!xf86I2CDevInit(dev)) {
+ xf86DrvMsg(pBus->scrnIndex, X_PROBED, "No DDC2 device\n");
+ return NULL;
+ }
}
return dev;
@@ -307,10 +332,10 @@ DDC2Init(int scrnIndex, I2CBusPtr pBus)
* miss things.
*/
pBus->RiseFallTime = 20;
-
+
dev = DDC2MakeDevice(pBus, 0x00A0, "ddc2");
if (xf86I2CProbeAddress(pBus, 0x0060))
- DDC2MakeDevice(pBus, 0x0060, "E-EDID segment register");
+ DDC2MakeDevice(pBus, 0x0060, "E-EDID segment register");
return dev;
}
@@ -328,39 +353,39 @@ DDC2Read(I2CDevPtr dev, int block, unsigned char *R_Buffer)
unsigned char W_Buffer[1];
int i, segment;
I2CDevPtr seg;
- void (*stop)(I2CDevPtr);
+ void (*stop) (I2CDevPtr);
for (i = 0; i < RETRIES; i++) {
- /* Stop bits reset the segment pointer to 0, so be careful here. */
- segment = block >> 1;
- if (segment) {
- Bool b;
-
- if (!(seg = xf86I2CFindDev(dev->pI2CBus, 0x0060)))
- return FALSE;
-
- W_Buffer[0] = segment;
-
- stop = dev->pI2CBus->I2CStop;
- dev->pI2CBus->I2CStop = EEDIDStop;
-
- b = xf86I2CWriteRead(seg, W_Buffer, 1, NULL, 0);
-
- dev->pI2CBus->I2CStop = stop;
- if (!b) {
- dev->pI2CBus->I2CStop(dev);
- continue;
- }
- }
-
- W_Buffer[0] = (block & 0x01) * EDID1_LEN;
-
- if (xf86I2CWriteRead(dev, W_Buffer, 1, R_Buffer, EDID1_LEN)) {
- if (!DDC_checksum(R_Buffer, EDID1_LEN))
- return TRUE;
- }
+ /* Stop bits reset the segment pointer to 0, so be careful here. */
+ segment = block >> 1;
+ if (segment) {
+ Bool b;
+
+ if (!(seg = xf86I2CFindDev(dev->pI2CBus, 0x0060)))
+ return FALSE;
+
+ W_Buffer[0] = segment;
+
+ stop = dev->pI2CBus->I2CStop;
+ dev->pI2CBus->I2CStop = EEDIDStop;
+
+ b = xf86I2CWriteRead(seg, W_Buffer, 1, NULL, 0);
+
+ dev->pI2CBus->I2CStop = stop;
+ if (!b) {
+ dev->pI2CBus->I2CStop(dev);
+ continue;
+ }
+ }
+
+ W_Buffer[0] = (block & 0x01) * EDID1_LEN;
+
+ if (xf86I2CWriteRead(dev, W_Buffer, 1, R_Buffer, EDID1_LEN)) {
+ if (!DDC_checksum(R_Buffer, EDID1_LEN))
+ return TRUE;
+ }
}
-
+
return FALSE;
}
@@ -384,13 +409,14 @@ xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, Bool complete)
unsigned char *EDID_block = NULL;
xf86MonPtr tmp = NULL;
I2CDevPtr dev = NULL;
+
/* Default DDC and DDC2 to enabled. */
Bool noddc = FALSE, noddc2 = FALSE;
OptionInfoPtr options;
options = malloc(sizeof(DDCOptions));
if (!options)
- return NULL;
+ return NULL;
memcpy(options, DDCOptions, sizeof(DDCOptions));
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
@@ -399,30 +425,30 @@ xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, Bool complete)
free(options);
if (noddc || noddc2)
- return NULL;
+ return NULL;
if (!(dev = DDC2Init(scrnIndex, pBus)))
- return NULL;
+ return NULL;
EDID_block = calloc(1, EDID1_LEN);
if (!EDID_block)
- return NULL;
+ return NULL;
if (DDC2Read(dev, 0, EDID_block)) {
- int i, n = EDID_block[0x7e];
+ int i, n = EDID_block[0x7e];
- if (complete && n) {
- EDID_block = realloc(EDID_block, EDID1_LEN * (1+n));
+ if (complete && n) {
+ EDID_block = realloc(EDID_block, EDID1_LEN * (1 + n));
- for (i = 0; i < n; i++)
- DDC2Read(dev, i+1, EDID_block + (EDID1_LEN * (1+i)));
- }
+ for (i = 0; i < n; i++)
+ DDC2Read(dev, i + 1, EDID_block + (EDID1_LEN * (1 + i)));
+ }
- tmp = xf86InterpretEEDID(scrnIndex, EDID_block);
+ tmp = xf86InterpretEEDID(scrnIndex, EDID_block);
}
if (tmp && complete)
- tmp->flags |= MONITOR_EDID_COMPLETE_RAWDATA;
+ tmp->flags |= MONITOR_EDID_COMPLETE_RAWDATA;
return tmp;
}
@@ -469,13 +495,14 @@ xf86DoDisplayID(int scrnIndex, I2CBusPtr pBus)
unsigned char *did = NULL;
xf86MonPtr tmp = NULL;
I2CDevPtr dev = NULL;
+
/* Default DDC and DDC2 to enabled. */
Bool noddc = FALSE, noddc2 = FALSE;
OptionInfoPtr options;
options = malloc(sizeof(DDCOptions));
if (!options)
- return NULL;
+ return NULL;
memcpy(options, DDCOptions, sizeof(DDCOptions));
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
@@ -484,19 +511,19 @@ xf86DoDisplayID(int scrnIndex, I2CBusPtr pBus)
free(options);
if (noddc || noddc2)
- return NULL;
+ return NULL;
if (!(dev = DDC2Init(scrnIndex, pBus)))
- return NULL;
+ return NULL;
if ((did = DDC2ReadDisplayID())) {
- tmp = calloc(1, sizeof(*tmp));
- if (!tmp)
- return NULL;
+ tmp = calloc(1, sizeof(*tmp));
+ if (!tmp)
+ return NULL;
- tmp->scrnIndex = scrnIndex;
- tmp->flags |= MONITOR_DISPLAYID;
- tmp->rawData = did;
+ tmp->scrnIndex = scrnIndex;
+ tmp->flags |= MONITOR_DISPLAYID;
+ tmp->rawData = did;
}
return tmp;
diff --git a/xorg-server/hw/xfree86/ddc/ddcProperty.c b/xorg-server/hw/xfree86/ddc/ddcProperty.c
index c3aced5c2..fc63f0e8a 100644
--- a/xorg-server/hw/xfree86/ddc/ddcProperty.c
+++ b/xorg-server/hw/xfree86/ddc/ddcProperty.c
@@ -40,8 +40,8 @@ edidMakeAtom(int i, const char *name, CARD8 *data, int size)
Atom atom;
unsigned char *atom_data;
- if (!(atom_data = malloc(size*sizeof(CARD8))))
- return;
+ if (!(atom_data = malloc(size * sizeof(CARD8))))
+ return;
atom = MakeAtom(name, strlen(name), TRUE);
memcpy(atom_data, data, size);
@@ -54,17 +54,19 @@ addRootWindowProperties(ScrnInfoPtr pScrn, xf86MonPtr DDC)
int scrnIndex = pScrn->scrnIndex;
if (DDC->flags & MONITOR_DISPLAYID) {
- /* Don't bother, use RANDR already */
- return;
- } else if (DDC->ver.version == 1) {
- int size = 128 +
- (DDC->flags & EDID_COMPLETE_RAWDATA ? DDC->no_sections * 128 : 0);
+ /* Don't bother, use RANDR already */
+ return;
+ }
+ else if (DDC->ver.version == 1) {
+ int size = 128 +
+ (DDC->flags & EDID_COMPLETE_RAWDATA ? DDC->no_sections * 128 : 0);
- edidMakeAtom(scrnIndex, EDID1_ATOM_NAME, DDC->rawData, size);
- } else {
- xf86DrvMsg(scrnIndex, X_PROBED, "unexpected EDID version %d.%d\n",
- DDC->ver.version, DDC->ver.revision);
- return;
+ edidMakeAtom(scrnIndex, EDID1_ATOM_NAME, DDC->rawData, size);
+ }
+ else {
+ xf86DrvMsg(scrnIndex, X_PROBED, "unexpected EDID version %d.%d\n",
+ DDC->ver.version, DDC->ver.revision);
+ return;
}
}
@@ -74,10 +76,9 @@ xf86SetDDCproperties(ScrnInfoPtr pScrn, xf86MonPtr DDC)
if (!pScrn || !pScrn->monitor || !DDC)
return FALSE;
- if (DDC->flags & MONITOR_DISPLAYID)
- ;
+ if (DDC->flags & MONITOR_DISPLAYID);
else
- xf86EdidMonitorSet(pScrn->scrnIndex, pScrn->monitor, DDC);
+ xf86EdidMonitorSet(pScrn->scrnIndex, pScrn->monitor, DDC);
addRootWindowProperties(pScrn, DDC);
diff --git a/xorg-server/hw/xfree86/ddc/edid.h b/xorg-server/hw/xfree86/ddc/edid.h
index cc4bd02ea..91565a2cf 100644
--- a/xorg-server/hw/xfree86/ddc/edid.h
+++ b/xorg-server/hw/xfree86/ddc/edid.h
@@ -10,12 +10,12 @@
*/
#ifndef _EDID_H_
-#define _EDID_H_
+#define _EDID_H_
#include <X11/Xmd.h>
#ifndef _X_EXPORT
-# include <X11/Xfuncproto.h>
+#include <X11/Xfuncproto.h>
#endif
/* read complete EDID record */
@@ -72,7 +72,7 @@
#define E_T1 0
#define E_T2 (E_T1 + 1)
#define E_TMANU (E_T2 + 1)
-#define E_TIMING_LENGTH (E_TMANU + 1)
+#define E_TIMING_LENGTH (E_TMANU + 1)
/* non predefined standard timings supported by display */
#define STD_TIMING_SECTION (ESTABLISHED_TIMING_SECTION + E_TIMING_LENGTH)
@@ -90,13 +90,12 @@
/* number of EDID sections to follow */
#define NO_EDID (DET_TIMING_SECTION + DET_TIMING_LENGTH)
/* one byte checksum */
-#define CHECKSUM (NO_EDID + 1)
+#define CHECKSUM (NO_EDID + 1)
#if (CHECKSUM != (EDID1_LEN - 1))
-# error "EDID1 length != 128!"
+#error "EDID1 length != 128!"
#endif
-
#define SECTION(x,y) (Uchar *)(x + y)
#define GET_ARRAY(y) ((Uchar *)(c + y))
#define GET(y) *(Uchar *)(c + y)
@@ -146,7 +145,6 @@
#define _MSC(x) (x & 0x7)
#define MSC _MSC(GET(FEAT_S))
-
/* color characteristics */
#define CC_L(x,y) ((x & (0x03 << y)) >> y)
#define CC_H(x) (x << 2)
@@ -198,7 +196,6 @@
#define _NEXT_STD_TIMING(x) (x = (x + STD_TIMING_INFO_LEN))
#define NEXT_STD_TIMING _NEXT_STD_TIMING(c)
-
/* EDID Ver. >= 1.2 */
/**
* Returns true if the pointer is the start of a monitor descriptor block
@@ -264,7 +261,7 @@
#define _MAX_H(x) x[8]
#define MAX_H (_MAX_H(c) + _MAX_H_OFFSET(c))
#define _MAX_CLOCK(x) x[9]
-#define MAX_CLOCK _MAX_CLOCK(c)
+#define MAX_CLOCK _MAX_CLOCK(c)
#define _HAVE_2ND_GTF(x) (x[10] == 0x02)
#define HAVE_2ND_GTF _HAVE_2ND_GTF(c)
#define _F_2ND_GTF(x) (x[12] * 2)
@@ -325,7 +322,7 @@
#define WHITEX2 _WHITEX_ADD(c,12)
#define WHITEY2 _WHITEY_ADD(c,12)
#define _WHITE_GAMMA1(x) _GAMMA(x[9])
-#define WHITE_GAMMA1 _WHITE_GAMMA1(c)
+#define WHITE_GAMMA1 _WHITE_GAMMA1(c)
#define _WHITE_GAMMA2(x) _GAMMA(x[14])
#define WHITE_GAMMA2 _WHITE_GAMMA2(c)
#define ADD_STD_TIMINGS 0xFA
@@ -337,7 +334,7 @@
#define _NEXT_DT_MD_SECTION(x) (x = (x + DET_TIMING_INFO_LEN))
#define NEXT_DT_MD_SECTION _NEXT_DT_MD_SECTION(c)
-#endif /* _PARSE_EDID_ */
+#endif /* _PARSE_EDID_ */
/* input type */
#define DIGITAL(x) x
@@ -346,10 +343,10 @@
#define DFP1(x) x
/* input voltage level */
-#define V070 0 /* 0.700V/0.300V */
-#define V071 1 /* 0.714V/0.286V */
-#define V100 2 /* 1.000V/0.400V */
-#define V007 3 /* 0.700V/0.000V */
+#define V070 0 /* 0.700V/0.300V */
+#define V071 1 /* 0.714V/0.286V */
+#define V100 2 /* 1.000V/0.400V */
+#define V007 3 /* 0.700V/0.000V */
/* Signal level setup */
#define SIG_SETUP(x) (x)
@@ -382,88 +379,87 @@
#define CVT_SUPPORTED(x) (x & 0x1)
/* detailed timing misc */
-#define IS_INTERLACED(x) (x)
-#define IS_STEREO(x) (x)
+#define IS_INTERLACED(x) (x)
+#define IS_STEREO(x) (x)
#define IS_RIGHT_STEREO(x) (x & 0x01)
#define IS_LEFT_STEREO(x) (x & 0x02)
#define IS_4WAY_STEREO(x) (x & 0x03)
#define IS_RIGHT_ON_SYNC(x) IS_RIGHT_STEREO(x)
#define IS_LEFT_ON_SYNC(x) IS_LEFT_STEREO(x)
-
typedef unsigned int Uint;
typedef unsigned char Uchar;
struct vendor {
- char name[4];
- int prod_id;
- Uint serial;
- int week;
- int year;
+ char name[4];
+ int prod_id;
+ Uint serial;
+ int week;
+ int year;
};
struct edid_version {
- int version;
- int revision;
+ int version;
+ int revision;
};
struct disp_features {
- unsigned int input_type:1;
- unsigned int input_voltage:2;
- unsigned int input_setup:1;
- unsigned int input_sync:5;
- unsigned int input_dfp:1;
- unsigned int input_bpc:3;
- unsigned int input_interface:4;
- /* 15 bit hole */
- int hsize;
- int vsize;
- float gamma;
- unsigned int dpms:3;
- unsigned int display_type:2;
- unsigned int msc:3;
- float redx;
- float redy;
- float greenx;
- float greeny;
- float bluex;
- float bluey;
- float whitex;
- float whitey;
+ unsigned int input_type:1;
+ unsigned int input_voltage:2;
+ unsigned int input_setup:1;
+ unsigned int input_sync:5;
+ unsigned int input_dfp:1;
+ unsigned int input_bpc:3;
+ unsigned int input_interface:4;
+ /* 15 bit hole */
+ int hsize;
+ int vsize;
+ float gamma;
+ unsigned int dpms:3;
+ unsigned int display_type:2;
+ unsigned int msc:3;
+ float redx;
+ float redy;
+ float greenx;
+ float greeny;
+ float bluex;
+ float bluey;
+ float whitex;
+ float whitey;
};
struct established_timings {
- Uchar t1;
- Uchar t2;
- Uchar t_manu;
+ Uchar t1;
+ Uchar t2;
+ Uchar t_manu;
};
struct std_timings {
- int hsize;
- int vsize;
- int refresh;
- CARD16 id;
+ int hsize;
+ int vsize;
+ int refresh;
+ CARD16 id;
};
struct detailed_timings {
- int clock;
- int h_active;
- int h_blanking;
- int v_active;
- int v_blanking;
- int h_sync_off;
- int h_sync_width;
- int v_sync_off;
- int v_sync_width;
- int h_size;
- int v_size;
- int h_border;
- int v_border;
- unsigned int interlaced:1;
- unsigned int stereo:2;
- unsigned int sync:2;
- unsigned int misc:2;
- unsigned int stereo_1:1;
+ int clock;
+ int h_active;
+ int h_blanking;
+ int v_active;
+ int v_blanking;
+ int h_sync_off;
+ int h_sync_width;
+ int v_sync_off;
+ int v_sync_width;
+ int h_size;
+ int v_size;
+ int h_border;
+ int v_border;
+ unsigned int interlaced:1;
+ unsigned int stereo:2;
+ unsigned int sync:2;
+ unsigned int misc:2;
+ unsigned int stereo_1:1;
};
#define DT 0
@@ -477,35 +473,35 @@ struct detailed_timings {
#define DS_CVT 0xF8
#define DS_EST_III 0xF7
#define DS_DUMMY 0x10
-#define DS_UNKOWN 0x100 /* type is an int */
+#define DS_UNKOWN 0x100 /* type is an int */
#define DS_VENDOR 0x101
#define DS_VENDOR_MAX 0x110
struct monitor_ranges {
- int min_v;
- int max_v;
- int min_h;
- int max_h;
- int max_clock; /* in mhz */
- int gtf_2nd_f;
- int gtf_2nd_c;
- int gtf_2nd_m;
- int gtf_2nd_k;
- int gtf_2nd_j;
- int max_clock_khz;
- int maxwidth; /* in pixels */
- char supported_aspect;
- char preferred_aspect;
- char supported_blanking;
- char supported_scaling;
- int preferred_refresh; /* in hz */
+ int min_v;
+ int max_v;
+ int min_h;
+ int max_h;
+ int max_clock; /* in mhz */
+ int gtf_2nd_f;
+ int gtf_2nd_c;
+ int gtf_2nd_m;
+ int gtf_2nd_k;
+ int gtf_2nd_j;
+ int max_clock_khz;
+ int maxwidth; /* in pixels */
+ char supported_aspect;
+ char preferred_aspect;
+ char supported_blanking;
+ char supported_scaling;
+ int preferred_refresh; /* in hz */
};
-struct whitePoints{
- int index;
- float white_x;
- float white_y;
- float white_gamma;
+struct whitePoints {
+ int index;
+ float white_x;
+ float white_y;
+ float white_gamma;
};
struct cvt_timings {
@@ -522,19 +518,19 @@ struct cvt_timings {
* literally like serial and friends.
*/
struct detailed_monitor_section {
- int type;
- union {
- struct detailed_timings d_timings; /* 56 */
- Uchar serial[13];
- Uchar ascii_data[13];
- Uchar name[13];
- struct monitor_ranges ranges; /* 56 */
- struct std_timings std_t[5]; /* 80 */
- struct whitePoints wp[2]; /* 32 */
- /* color management data */
- struct cvt_timings cvt[4]; /* 64 */
- Uchar est_iii[6]; /* 6 */
- } section; /* max: 80 */
+ int type;
+ union {
+ struct detailed_timings d_timings; /* 56 */
+ Uchar serial[13];
+ Uchar ascii_data[13];
+ Uchar name[13];
+ struct monitor_ranges ranges; /* 56 */
+ struct std_timings std_t[5]; /* 80 */
+ struct whitePoints wp[2]; /* 32 */
+ /* color management data */
+ struct cvt_timings cvt[4]; /* 64 */
+ Uchar est_iii[6]; /* 6 */
+ } section; /* max: 80 */
};
/* flags */
@@ -548,16 +544,16 @@ struct detailed_monitor_section {
* are meaningful. For EDID, they all are.
*/
typedef struct {
- int scrnIndex;
- struct vendor vendor;
- struct edid_version ver;
- struct disp_features features;
- struct established_timings timings1;
- struct std_timings timings2[8];
- struct detailed_monitor_section det_mon[4];
- unsigned long flags;
- int no_sections;
- Uchar *rawData;
+ int scrnIndex;
+ struct vendor vendor;
+ struct edid_version ver;
+ struct disp_features features;
+ struct established_timings timings1;
+ struct std_timings timings2[8];
+ struct detailed_monitor_section det_mon[4];
+ unsigned long flags;
+ int no_sections;
+ Uchar *rawData;
} xf86Monitor, *xf86MonPtr;
extern _X_EXPORT xf86MonPtr ConfiguredMonitor;
@@ -590,73 +586,72 @@ extern _X_EXPORT xf86MonPtr ConfiguredMonitor;
#define HDMI_MAX_TMDS_UNIT (5000)
struct cea_video_block {
- Uchar video_code;
+ Uchar video_code;
};
struct cea_audio_block_descriptor {
- Uchar audio_code[3];
+ Uchar audio_code[3];
};
struct cea_audio_block {
- struct cea_audio_block_descriptor descriptor[10];
+ struct cea_audio_block_descriptor descriptor[10];
};
struct cea_vendor_block_hdmi {
- Uchar portB:4;
- Uchar portA:4;
- Uchar portD:4;
- Uchar portC:4;
- Uchar support_flags;
- Uchar max_tmds_clock;
- Uchar latency_present;
- Uchar video_latency;
- Uchar audio_latency;
- Uchar interlaced_video_latency;
- Uchar interlaced_audio_latency;
+ Uchar portB:4;
+ Uchar portA:4;
+ Uchar portD:4;
+ Uchar portC:4;
+ Uchar support_flags;
+ Uchar max_tmds_clock;
+ Uchar latency_present;
+ Uchar video_latency;
+ Uchar audio_latency;
+ Uchar interlaced_video_latency;
+ Uchar interlaced_audio_latency;
};
struct cea_vendor_block {
- unsigned char ieee_id[3];
- union {
- struct cea_vendor_block_hdmi hdmi;
- /* any other vendor blocks we know about */
- };
+ unsigned char ieee_id[3];
+ union {
+ struct cea_vendor_block_hdmi hdmi;
+ /* any other vendor blocks we know about */
+ };
};
-struct cea_speaker_block
-{
- Uchar FLR:1;
- Uchar LFE:1;
- Uchar FC:1;
- Uchar RLR:1;
- Uchar RC:1;
- Uchar FLRC:1;
- Uchar RLRC:1;
- Uchar FLRW:1;
- Uchar FLRH:1;
- Uchar TC:1;
- Uchar FCH:1;
- Uchar Resv:5;
- Uchar ResvByte;
+struct cea_speaker_block {
+ Uchar FLR:1;
+ Uchar LFE:1;
+ Uchar FC:1;
+ Uchar RLR:1;
+ Uchar RC:1;
+ Uchar FLRC:1;
+ Uchar RLRC:1;
+ Uchar FLRW:1;
+ Uchar FLRH:1;
+ Uchar TC:1;
+ Uchar FCH:1;
+ Uchar Resv:5;
+ Uchar ResvByte;
};
struct cea_data_block {
- Uchar len:5;
- Uchar tag:3;
- union{
- struct cea_video_block video;
- struct cea_audio_block audio;
- struct cea_vendor_block vendor;
- struct cea_speaker_block speaker;
- }u;
+ Uchar len:5;
+ Uchar tag:3;
+ union {
+ struct cea_video_block video;
+ struct cea_audio_block audio;
+ struct cea_vendor_block vendor;
+ struct cea_speaker_block speaker;
+ } u;
};
struct cea_ext_body {
- Uchar tag;
- Uchar rev;
- Uchar dt_offset;
- Uchar flags;
- struct cea_data_block data_collection;
+ Uchar tag;
+ Uchar rev;
+ Uchar dt_offset;
+ Uchar flags;
+ struct cea_data_block data_collection;
};
-#endif /* _EDID_H_ */
+#endif /* _EDID_H_ */
diff --git a/xorg-server/hw/xfree86/ddc/interpret_edid.c b/xorg-server/hw/xfree86/ddc/interpret_edid.c
index d1001a21f..882a6b201 100644
--- a/xorg-server/hw/xfree86/ddc/interpret_edid.c
+++ b/xorg-server/hw/xfree86/ddc/interpret_edid.c
@@ -1,685 +1,714 @@
-/*
- * Copyright 1998 by Egbert Eich <Egbert.Eich@Physik.TU-Darmstadt.DE>
- * Copyright 2007 Red Hat, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * interpret_edid.c: interpret a primary EDID block
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-#define _PARSE_EDID_
-#include "xf86DDC.h"
-#include <string.h>
-
-static void get_vendor_section(Uchar*, struct vendor *);
-static void get_version_section(Uchar*, struct edid_version *);
-static void get_display_section(Uchar*, struct disp_features *,
- struct edid_version *);
-static void get_established_timing_section(Uchar*, struct established_timings *);
-static void get_std_timing_section(Uchar*, struct std_timings *,
- struct edid_version *);
-static void fetch_detailed_block(Uchar *c, struct edid_version *ver,
- struct detailed_monitor_section *det_mon);
-static void get_dt_md_section(Uchar *, struct edid_version *,
- struct detailed_monitor_section *det_mon);
-static void copy_string(Uchar *, Uchar *);
-static void get_dst_timing_section(Uchar *, struct std_timings *,
- struct edid_version *);
-static void get_monitor_ranges(Uchar *, struct monitor_ranges *);
-static void get_whitepoint_section(Uchar *, struct whitePoints *);
-static void get_detailed_timing_section(Uchar*, struct detailed_timings *);
-static Bool validate_version(int scrnIndex, struct edid_version *);
-
-static void
-find_ranges_section(struct detailed_monitor_section *det, void *ranges)
-{
- if (det->type == DS_RANGES && det->section.ranges.max_clock)
- *(struct monitor_ranges **)ranges = &det->section.ranges;
-}
-
-static void
-find_max_detailed_clock(struct detailed_monitor_section *det, void *ret)
-{
- if (det->type == DT) {
- *(int *)ret = max(*((int *)ret),
- det->section.d_timings.clock);
- }
-}
-
-static void
-handle_edid_quirks(xf86MonPtr m)
-{
- struct monitor_ranges *ranges = NULL;
-
- /*
- * max_clock is only encoded in EDID in tens of MHz, so occasionally we
- * find a monitor claiming a max of 160 with a mode requiring 162, or
- * similar. Strictly we should refuse to round up too far, but let's
- * see how well this works.
- */
-
- /* Try to find Monitor Range and max clock, then re-set range value*/
- xf86ForEachDetailedBlock(m, find_ranges_section, &ranges);
- if (ranges && ranges->max_clock) {
- int clock = 0;
- xf86ForEachDetailedBlock(m, find_max_detailed_clock, &clock);
- if (clock && (ranges->max_clock * 1e6 < clock)) {
- xf86Msg(X_WARNING, "EDID timing clock %.2f exceeds claimed max "
- "%dMHz, fixing\n", clock / 1.0e6, ranges->max_clock);
- ranges->max_clock = (clock+999999)/1e6;
- }
- }
-}
-
-struct det_hv_parameter {
- int real_hsize;
- int real_vsize;
- float target_aspect;
-};
-
-static void handle_detailed_hvsize(struct detailed_monitor_section *det_mon,
- void *data)
-{
- struct det_hv_parameter *p = (struct det_hv_parameter *)data;
- float timing_aspect;
-
- if (det_mon->type == DT) {
- struct detailed_timings *timing;
- timing = &det_mon->section.d_timings;
-
- if (!timing->v_size)
- return;
-
- timing_aspect = (float)timing->h_size / timing->v_size;
- if (fabs(1 - (timing_aspect / p->target_aspect)) < 0.05) {
- p->real_hsize = max(p->real_hsize, timing->h_size);
- p->real_vsize = max(p->real_vsize, timing->v_size);
- }
- }
-}
-
-static void encode_aspect_ratio(xf86MonPtr m)
-{
- /*
- * some monitors encode the aspect ratio instead of the physical size.
- * try to find the largest detailed timing that matches that aspect
- * ratio and use that to fill in the feature section.
- */
- if ((m->features.hsize == 16 && m->features.vsize == 9) ||
- (m->features.hsize == 16 && m->features.vsize == 10) ||
- (m->features.hsize == 4 && m->features.vsize == 3) ||
- (m->features.hsize == 5 && m->features.vsize == 4)) {
-
- struct det_hv_parameter p;
- p.real_hsize = 0;
- p.real_vsize = 0;
- p.target_aspect = (float)m->features.hsize /m->features.vsize;
-
- xf86ForEachDetailedBlock(m, handle_detailed_hvsize, &p);
-
- if (!p.real_hsize || !p.real_vsize) {
- m->features.hsize = m->features.vsize = 0;
- } else if ((m->features.hsize * 10 == p.real_hsize) &&
- (m->features.vsize * 10 == p.real_vsize)) {
- /* exact match is just unlikely, should do a better check though */
- m->features.hsize = m->features.vsize = 0;
- } else {
- /* convert mm to cm */
- m->features.hsize = (p.real_hsize + 5) / 10;
- m->features.vsize = (p.real_vsize + 5) / 10;
- }
-
- xf86Msg(X_INFO, "Quirked EDID physical size to %dx%d cm\n",
- m->features.hsize, m->features.vsize);
- }
-}
-
-xf86MonPtr
-xf86InterpretEDID(int scrnIndex, Uchar *block)
-{
- xf86MonPtr m;
-
- if (!block) return NULL;
- if (! (m = xnfcalloc(sizeof(xf86Monitor),1))) return NULL;
- m->scrnIndex = scrnIndex;
- m->rawData = block;
-
- get_vendor_section(SECTION(VENDOR_SECTION,block),&m->vendor);
- get_version_section(SECTION(VERSION_SECTION,block),&m->ver);
- if (!validate_version(scrnIndex, &m->ver)) goto error;
- get_display_section(SECTION(DISPLAY_SECTION,block),&m->features,
- &m->ver);
- get_established_timing_section(SECTION(ESTABLISHED_TIMING_SECTION,block),
- &m->timings1);
- get_std_timing_section(SECTION(STD_TIMING_SECTION,block),m->timings2,
- &m->ver);
- get_dt_md_section(SECTION(DET_TIMING_SECTION,block),&m->ver, m->det_mon);
- m->no_sections = (int)*(char *)SECTION(NO_EDID,block);
-
- handle_edid_quirks(m);
- encode_aspect_ratio(m);
-
- return m;
-
- error:
- free(m);
- return NULL;
-}
-
-static int get_cea_detail_timing(Uchar *blk, xf86MonPtr mon,
- struct detailed_monitor_section *det_mon)
-{
- int dt_num;
- int dt_offset = ((struct cea_ext_body *)blk)->dt_offset;
-
- dt_num = 0;
-
- if (dt_offset < CEA_EXT_MIN_DATA_OFFSET)
- return dt_num;
-
- for (; dt_offset < (CEA_EXT_MAX_DATA_OFFSET - DET_TIMING_INFO_LEN) &&
- dt_num < CEA_EXT_DET_TIMING_NUM;
- _NEXT_DT_MD_SECTION(dt_offset)) {
-
- fetch_detailed_block(blk + dt_offset, &mon->ver, det_mon + dt_num);
- dt_num = dt_num + 1 ;
- }
-
- return dt_num;
-}
-
-static void handle_cea_detail_block(Uchar *ext, xf86MonPtr mon,
- handle_detailed_fn fn,
- void *data)
-{
- int i;
- struct detailed_monitor_section det_mon[CEA_EXT_DET_TIMING_NUM];
- int det_mon_num;
-
- det_mon_num = get_cea_detail_timing(ext, mon, det_mon);
-
- for (i = 0; i < det_mon_num; i++)
- fn(det_mon + i, data);
-}
-
-void xf86ForEachDetailedBlock(xf86MonPtr mon,
- handle_detailed_fn fn,
- void *data)
-{
- int i;
- Uchar *ext;
-
- if (mon == NULL)
- return;
-
- for (i = 0; i < DET_TIMINGS; i++)
- fn(mon->det_mon + i, data);
-
- for (i = 0; i < mon->no_sections; i++) {
- ext = mon->rawData + EDID1_LEN * (i + 1);
- switch (ext[EXT_TAG]){
- case CEA_EXT:
- handle_cea_detail_block(ext, mon, fn, data);
- break;
- case VTB_EXT:
- case DI_EXT:
- case LS_EXT:
- case MI_EXT:
- break;
- }
- }
-}
-
-static struct cea_data_block *
-extract_cea_data_block(Uchar *ext, int data_type)
-{
- struct cea_ext_body *cea;
- struct cea_data_block *data_collection;
- struct cea_data_block *data_end;
-
- cea = (struct cea_ext_body *)ext;
-
- if (cea->dt_offset <= CEA_EXT_MIN_DATA_OFFSET)
- return NULL;
-
- data_collection = &cea->data_collection;
- data_end = (struct cea_data_block *)(cea->dt_offset + ext);
-
- for ( ;data_collection < data_end;) {
-
- if (data_type == data_collection->tag) {
- return data_collection;
- }
- data_collection = (void *)((unsigned char *)data_collection +
- data_collection->len + 1);
- }
-
- return NULL;
-}
-
-static void handle_cea_video_block(Uchar *ext, handle_video_fn fn, void *data)
-{
- struct cea_video_block *video;
- struct cea_video_block *video_end;
- struct cea_data_block *data_collection;
-
- data_collection = extract_cea_data_block(ext, CEA_VIDEO_BLK);
- if (data_collection == NULL)
- return;
-
- video = &data_collection->u.video;
- video_end = (struct cea_video_block *)
- ((Uchar *)video + data_collection->len);
-
- for (; video < video_end; video = video + 1) {
- fn(video, data);
- }
-}
-
-void xf86ForEachVideoBlock(xf86MonPtr mon,
- handle_video_fn fn,
- void *data)
-{
- int i;
- Uchar *ext;
-
- if (mon == NULL)
- return;
-
- for (i = 0; i < mon->no_sections; i++) {
- ext = mon->rawData + EDID1_LEN * (i + 1);
- switch (ext[EXT_TAG]) {
- case CEA_EXT:
- handle_cea_video_block(ext, fn, data);
- break;
- case VTB_EXT:
- case DI_EXT:
- case LS_EXT:
- case MI_EXT:
- break;
- }
- }
-}
-
-xf86MonPtr
-xf86InterpretEEDID(int scrnIndex, Uchar *block)
-{
- xf86MonPtr m;
-
- m = xf86InterpretEDID(scrnIndex, block);
- if (!m)
- return NULL;
-
- /* extension parse */
-
- return m;
-}
-
-static void
-get_vendor_section(Uchar *c, struct vendor *r)
-{
- r->name[0] = L1;
- r->name[1] = L2;
- r->name[2] = L3;
- r->name[3] = '\0';
-
- r->prod_id = PROD_ID;
- r->serial = SERIAL_NO;
- r->week = WEEK;
- r->year = YEAR;
-}
-
-static void
-get_version_section(Uchar *c, struct edid_version *r)
-{
- r->version = VERSION;
- r->revision = REVISION;
-}
-
-static void
-get_display_section(Uchar *c, struct disp_features *r,
- struct edid_version *v)
-{
- r->input_type = INPUT_TYPE;
- if (!DIGITAL(r->input_type)) {
- r->input_voltage = INPUT_VOLTAGE;
- r->input_setup = SETUP;
- r->input_sync = SYNC;
- } else if (v->revision == 2 || v->revision == 3) {
- r->input_dfp = DFP;
- } else if (v->revision >= 4) {
- r->input_bpc = BPC;
- r->input_interface = DIGITAL_INTERFACE;
- }
- r->hsize = HSIZE_MAX;
- r->vsize = VSIZE_MAX;
- r->gamma = GAMMA;
- r->dpms = DPMS;
- r->display_type = DISPLAY_TYPE;
- r->msc = MSC;
- r->redx = REDX;
- r->redy = REDY;
- r->greenx = GREENX;
- r->greeny = GREENY;
- r->bluex = BLUEX;
- r->bluey = BLUEY;
- r->whitex = WHITEX;
- r->whitey = WHITEY;
-}
-
-static void
-get_established_timing_section(Uchar *c, struct established_timings *r)
-{
- r->t1 = T1;
- r->t2 = T2;
- r->t_manu = T_MANU;
-}
-
-static void
-get_cvt_timing_section(Uchar *c, struct cvt_timings *r)
-{
- int i;
-
- for (i = 0; i < 4; i++) {
- if (c[0] && c[1] && c[2]) {
- r[i].height = (c[0] + ((c[1] & 0xF0) << 8) + 1) * 2;
- switch (c[1] & 0xc0) {
- case 0x00: r[i].width = r[i].height * 4 / 3; break;
- case 0x40: r[i].width = r[i].height * 16 / 9; break;
- case 0x80: r[i].width = r[i].height * 16 / 10; break;
- case 0xc0: r[i].width = r[i].height * 15 / 9; break;
- }
- switch (c[2] & 0x60) {
- case 0x00: r[i].rate = 50; break;
- case 0x20: r[i].rate = 60; break;
- case 0x40: r[i].rate = 75; break;
- case 0x60: r[i].rate = 85; break;
- }
- r[i].rates = c[2] & 0x1f;
- } else {
- return;
- }
- c += 3;
- }
-}
-
-static void
-get_std_timing_section(Uchar *c, struct std_timings *r,
- struct edid_version *v)
-{
- int i;
-
- for (i=0;i<STD_TIMINGS;i++){
- if (VALID_TIMING) {
- r[i].hsize = HSIZE1;
- VSIZE1(r[i].vsize);
- r[i].refresh = REFRESH_R;
- r[i].id = STD_TIMING_ID;
- } else {
- r[i].hsize = r[i].vsize = r[i].refresh = r[i].id = 0;
- }
- NEXT_STD_TIMING;
- }
-}
-
-static const unsigned char empty_block[18];
-
-static void
-fetch_detailed_block(Uchar *c, struct edid_version *ver,
- struct detailed_monitor_section *det_mon)
-{
- if (ver->version == 1 && ver->revision >= 1 && IS_MONITOR_DESC) {
- switch (MONITOR_DESC_TYPE) {
- case SERIAL_NUMBER:
- det_mon->type = DS_SERIAL;
- copy_string(c,det_mon->section.serial);
- break;
- case ASCII_STR:
- det_mon->type = DS_ASCII_STR;
- copy_string(c,det_mon->section.ascii_data);
- break;
- case MONITOR_RANGES:
- det_mon->type = DS_RANGES;
- get_monitor_ranges(c,&det_mon->section.ranges);
- break;
- case MONITOR_NAME:
- det_mon->type = DS_NAME;
- copy_string(c,det_mon->section.name);
- break;
- case ADD_COLOR_POINT:
- det_mon->type = DS_WHITE_P;
- get_whitepoint_section(c,det_mon->section.wp);
- break;
- case ADD_STD_TIMINGS:
- det_mon->type = DS_STD_TIMINGS;
- get_dst_timing_section(c,det_mon->section.std_t, ver);
- break;
- case COLOR_MANAGEMENT_DATA:
- det_mon->type = DS_CMD;
- break;
- case CVT_3BYTE_DATA:
- det_mon->type = DS_CVT;
- get_cvt_timing_section(c, det_mon->section.cvt);
- break;
- case ADD_EST_TIMINGS:
- det_mon->type = DS_EST_III;
- memcpy(det_mon->section.est_iii, c + 6, 6);
- break;
- case ADD_DUMMY:
- det_mon->type = DS_DUMMY;
- break;
- default:
- det_mon->type = DS_UNKOWN;
- break;
- }
- if (c[3] <= 0x0F && memcmp(c, empty_block, sizeof(empty_block))) {
- det_mon->type = DS_VENDOR + c[3];
- }
- } else {
- det_mon->type = DT;
- get_detailed_timing_section(c, &det_mon->section.d_timings);
- }
-}
-
-static void
-get_dt_md_section(Uchar *c, struct edid_version *ver,
- struct detailed_monitor_section *det_mon)
-{
- int i;
-
- for (i=0; i < DET_TIMINGS; i++) {
- fetch_detailed_block(c, ver, det_mon + i);
- NEXT_DT_MD_SECTION;
- }
-}
-
-static void
-copy_string(Uchar *c, Uchar *s)
-{
- int i;
- c = c + 5;
- for (i = 0; (i < 13 && *c != 0x0A); i++)
- *(s++) = *(c++);
- *s = 0;
- while (i-- && (*--s == 0x20)) *s = 0;
-}
-
-static void
-get_dst_timing_section(Uchar *c, struct std_timings *t,
- struct edid_version *v)
-{
- int j;
- c = c + 5;
- for (j = 0; j < 5; j++) {
- t[j].hsize = HSIZE1;
- VSIZE1(t[j].vsize);
- t[j].refresh = REFRESH_R;
- t[j].id = STD_TIMING_ID;
- NEXT_STD_TIMING;
- }
-}
-
-static void
-get_monitor_ranges(Uchar *c, struct monitor_ranges *r)
-{
- r->min_v = MIN_V;
- r->max_v = MAX_V;
- r->min_h = MIN_H;
- r->max_h = MAX_H;
- r->max_clock = 0;
- if(MAX_CLOCK != 0xff) /* is specified? */
- r->max_clock = MAX_CLOCK * 10 + 5;
- if (HAVE_2ND_GTF) {
- r->gtf_2nd_f = F_2ND_GTF;
- r->gtf_2nd_c = C_2ND_GTF;
- r->gtf_2nd_m = M_2ND_GTF;
- r->gtf_2nd_k = K_2ND_GTF;
- r->gtf_2nd_j = J_2ND_GTF;
- } else {
- r->gtf_2nd_f = 0;
- }
- if (HAVE_CVT) {
- r->max_clock_khz = MAX_CLOCK_KHZ;
- r->max_clock = r->max_clock_khz / 1000;
- r->maxwidth = MAXWIDTH;
- r->supported_aspect = SUPPORTED_ASPECT;
- r->preferred_aspect = PREFERRED_ASPECT;
- r->supported_blanking = SUPPORTED_BLANKING;
- r->supported_scaling = SUPPORTED_SCALING;
- r->preferred_refresh = PREFERRED_REFRESH;
- } else {
- r->max_clock_khz = 0;
- }
-}
-
-static void
-get_whitepoint_section(Uchar *c, struct whitePoints *wp)
-{
- wp[0].white_x = WHITEX1;
- wp[0].white_y = WHITEY1;
- wp[1].white_x = WHITEX2;
- wp[1].white_y = WHITEY2;
- wp[0].index = WHITE_INDEX1;
- wp[1].index = WHITE_INDEX2;
- wp[0].white_gamma = WHITE_GAMMA1;
- wp[1].white_gamma = WHITE_GAMMA2;
-}
-
-static void
-get_detailed_timing_section(Uchar *c, struct detailed_timings *r)
-{
- r->clock = PIXEL_CLOCK;
- r->h_active = H_ACTIVE;
- r->h_blanking = H_BLANK;
- r->v_active = V_ACTIVE;
- r->v_blanking = V_BLANK;
- r->h_sync_off = H_SYNC_OFF;
- r->h_sync_width = H_SYNC_WIDTH;
- r->v_sync_off = V_SYNC_OFF;
- r->v_sync_width = V_SYNC_WIDTH;
- r->h_size = H_SIZE;
- r->v_size = V_SIZE;
- r->h_border = H_BORDER;
- r->v_border = V_BORDER;
- r->interlaced = INTERLACED;
- r->stereo = STEREO;
- r->stereo_1 = STEREO1;
- r->sync = SYNC_T;
- r->misc = MISC;
-}
-
-#define MAX_EDID_MINOR 4
-
-static Bool
-validate_version(int scrnIndex, struct edid_version *r)
-{
- if (r->version != 1) {
- xf86DrvMsg(scrnIndex, X_ERROR, "Unknown EDID version %d\n",
- r->version);
- return FALSE;
- }
-
- if (r->revision > MAX_EDID_MINOR)
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Assuming version 1.%d is compatible with 1.%d\n",
- r->revision, MAX_EDID_MINOR);
-
- return TRUE;
-}
-
-/*
- * Returns true if HDMI, false if definitely not or unknown.
- */
-Bool
-xf86MonitorIsHDMI(xf86MonPtr mon)
-{
- int i = 0, version, offset;
- char *edid = NULL;
-
- if (!mon)
- return FALSE;
-
- if (!(mon->flags & EDID_COMPLETE_RAWDATA))
- return FALSE;
-
- if (!mon->no_sections)
- return FALSE;
-
- edid = (char *)mon->rawData;
- if (!edid)
- return FALSE;
-
- /* find the CEA extension block */
- for (i = 1; i <= mon->no_sections; i++)
- if (edid[i * 128] == 0x02)
- break;
- if (i == mon->no_sections + 1)
- return FALSE;
- edid += (i * 128);
-
- version = edid[1];
- offset = edid[2];
- if (version < 3 || offset < 4)
- return FALSE;
-
- /* walk the cea data blocks */
- for (i = 4; i < offset; i += (edid[i] & 0x1f) + 1) {
- char *x = edid + i;
-
- /* find a vendor specific block */
- if ((x[0] & 0xe0) >> 5 == 0x03) {
- int oui = (x[3] << 16) + (x[2] << 8) + x[1];
-
- /* find the HDMI vendor OUI */
- if (oui == 0x000c03)
- return TRUE;
- }
- }
-
- /* guess it's not HDMI after all */
- return FALSE;
-}
+/*
+ * Copyright 1998 by Egbert Eich <Egbert.Eich@Physik.TU-Darmstadt.DE>
+ * Copyright 2007 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * interpret_edid.c: interpret a primary EDID block
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#define _PARSE_EDID_
+#include "xf86DDC.h"
+#include <string.h>
+
+static void get_vendor_section(Uchar *, struct vendor *);
+static void get_version_section(Uchar *, struct edid_version *);
+static void get_display_section(Uchar *, struct disp_features *,
+ struct edid_version *);
+static void get_established_timing_section(Uchar *,
+ struct established_timings *);
+static void get_std_timing_section(Uchar *, struct std_timings *,
+ struct edid_version *);
+static void fetch_detailed_block(Uchar * c, struct edid_version *ver,
+ struct detailed_monitor_section *det_mon);
+static void get_dt_md_section(Uchar *, struct edid_version *,
+ struct detailed_monitor_section *det_mon);
+static void copy_string(Uchar *, Uchar *);
+static void get_dst_timing_section(Uchar *, struct std_timings *,
+ struct edid_version *);
+static void get_monitor_ranges(Uchar *, struct monitor_ranges *);
+static void get_whitepoint_section(Uchar *, struct whitePoints *);
+static void get_detailed_timing_section(Uchar *, struct detailed_timings *);
+static Bool validate_version(int scrnIndex, struct edid_version *);
+
+static void
+find_ranges_section(struct detailed_monitor_section *det, void *ranges)
+{
+ if (det->type == DS_RANGES && det->section.ranges.max_clock)
+ *(struct monitor_ranges **) ranges = &det->section.ranges;
+}
+
+static void
+find_max_detailed_clock(struct detailed_monitor_section *det, void *ret)
+{
+ if (det->type == DT) {
+ *(int *) ret = max(*((int *) ret), det->section.d_timings.clock);
+ }
+}
+
+static void
+handle_edid_quirks(xf86MonPtr m)
+{
+ struct monitor_ranges *ranges = NULL;
+
+ /*
+ * max_clock is only encoded in EDID in tens of MHz, so occasionally we
+ * find a monitor claiming a max of 160 with a mode requiring 162, or
+ * similar. Strictly we should refuse to round up too far, but let's
+ * see how well this works.
+ */
+
+ /* Try to find Monitor Range and max clock, then re-set range value */
+ xf86ForEachDetailedBlock(m, find_ranges_section, &ranges);
+ if (ranges && ranges->max_clock) {
+ int clock = 0;
+
+ xf86ForEachDetailedBlock(m, find_max_detailed_clock, &clock);
+ if (clock && (ranges->max_clock * 1e6 < clock)) {
+ xf86Msg(X_WARNING, "EDID timing clock %.2f exceeds claimed max "
+ "%dMHz, fixing\n", clock / 1.0e6, ranges->max_clock);
+ ranges->max_clock = (clock + 999999) / 1e6;
+ }
+ }
+}
+
+struct det_hv_parameter {
+ int real_hsize;
+ int real_vsize;
+ float target_aspect;
+};
+
+static void
+handle_detailed_hvsize(struct detailed_monitor_section *det_mon, void *data)
+{
+ struct det_hv_parameter *p = (struct det_hv_parameter *) data;
+ float timing_aspect;
+
+ if (det_mon->type == DT) {
+ struct detailed_timings *timing;
+
+ timing = &det_mon->section.d_timings;
+
+ if (!timing->v_size)
+ return;
+
+ timing_aspect = (float) timing->h_size / timing->v_size;
+ if (fabs(1 - (timing_aspect / p->target_aspect)) < 0.05) {
+ p->real_hsize = max(p->real_hsize, timing->h_size);
+ p->real_vsize = max(p->real_vsize, timing->v_size);
+ }
+ }
+}
+
+static void
+encode_aspect_ratio(xf86MonPtr m)
+{
+ /*
+ * some monitors encode the aspect ratio instead of the physical size.
+ * try to find the largest detailed timing that matches that aspect
+ * ratio and use that to fill in the feature section.
+ */
+ if ((m->features.hsize == 16 && m->features.vsize == 9) ||
+ (m->features.hsize == 16 && m->features.vsize == 10) ||
+ (m->features.hsize == 4 && m->features.vsize == 3) ||
+ (m->features.hsize == 5 && m->features.vsize == 4)) {
+
+ struct det_hv_parameter p;
+
+ p.real_hsize = 0;
+ p.real_vsize = 0;
+ p.target_aspect = (float) m->features.hsize / m->features.vsize;
+
+ xf86ForEachDetailedBlock(m, handle_detailed_hvsize, &p);
+
+ if (!p.real_hsize || !p.real_vsize) {
+ m->features.hsize = m->features.vsize = 0;
+ }
+ else if ((m->features.hsize * 10 == p.real_hsize) &&
+ (m->features.vsize * 10 == p.real_vsize)) {
+ /* exact match is just unlikely, should do a better check though */
+ m->features.hsize = m->features.vsize = 0;
+ }
+ else {
+ /* convert mm to cm */
+ m->features.hsize = (p.real_hsize + 5) / 10;
+ m->features.vsize = (p.real_vsize + 5) / 10;
+ }
+
+ xf86Msg(X_INFO, "Quirked EDID physical size to %dx%d cm\n",
+ m->features.hsize, m->features.vsize);
+ }
+}
+
+xf86MonPtr
+xf86InterpretEDID(int scrnIndex, Uchar * block)
+{
+ xf86MonPtr m;
+
+ if (!block)
+ return NULL;
+ if (!(m = xnfcalloc(sizeof(xf86Monitor), 1)))
+ return NULL;
+ m->scrnIndex = scrnIndex;
+ m->rawData = block;
+
+ get_vendor_section(SECTION(VENDOR_SECTION, block), &m->vendor);
+ get_version_section(SECTION(VERSION_SECTION, block), &m->ver);
+ if (!validate_version(scrnIndex, &m->ver))
+ goto error;
+ get_display_section(SECTION(DISPLAY_SECTION, block), &m->features, &m->ver);
+ get_established_timing_section(SECTION(ESTABLISHED_TIMING_SECTION, block),
+ &m->timings1);
+ get_std_timing_section(SECTION(STD_TIMING_SECTION, block), m->timings2,
+ &m->ver);
+ get_dt_md_section(SECTION(DET_TIMING_SECTION, block), &m->ver, m->det_mon);
+ m->no_sections = (int) *(char *) SECTION(NO_EDID, block);
+
+ handle_edid_quirks(m);
+ encode_aspect_ratio(m);
+
+ return m;
+
+ error:
+ free(m);
+ return NULL;
+}
+
+static int
+get_cea_detail_timing(Uchar * blk, xf86MonPtr mon,
+ struct detailed_monitor_section *det_mon)
+{
+ int dt_num;
+ int dt_offset = ((struct cea_ext_body *) blk)->dt_offset;
+
+ dt_num = 0;
+
+ if (dt_offset < CEA_EXT_MIN_DATA_OFFSET)
+ return dt_num;
+
+ for (; dt_offset < (CEA_EXT_MAX_DATA_OFFSET - DET_TIMING_INFO_LEN) &&
+ dt_num < CEA_EXT_DET_TIMING_NUM; _NEXT_DT_MD_SECTION(dt_offset)) {
+
+ fetch_detailed_block(blk + dt_offset, &mon->ver, det_mon + dt_num);
+ dt_num = dt_num + 1;
+ }
+
+ return dt_num;
+}
+
+static void
+handle_cea_detail_block(Uchar * ext, xf86MonPtr mon,
+ handle_detailed_fn fn, void *data)
+{
+ int i;
+ struct detailed_monitor_section det_mon[CEA_EXT_DET_TIMING_NUM];
+ int det_mon_num;
+
+ det_mon_num = get_cea_detail_timing(ext, mon, det_mon);
+
+ for (i = 0; i < det_mon_num; i++)
+ fn(det_mon + i, data);
+}
+
+void
+xf86ForEachDetailedBlock(xf86MonPtr mon, handle_detailed_fn fn, void *data)
+{
+ int i;
+ Uchar *ext;
+
+ if (mon == NULL)
+ return;
+
+ for (i = 0; i < DET_TIMINGS; i++)
+ fn(mon->det_mon + i, data);
+
+ for (i = 0; i < mon->no_sections; i++) {
+ ext = mon->rawData + EDID1_LEN * (i + 1);
+ switch (ext[EXT_TAG]) {
+ case CEA_EXT:
+ handle_cea_detail_block(ext, mon, fn, data);
+ break;
+ case VTB_EXT:
+ case DI_EXT:
+ case LS_EXT:
+ case MI_EXT:
+ break;
+ }
+ }
+}
+
+static struct cea_data_block *
+extract_cea_data_block(Uchar * ext, int data_type)
+{
+ struct cea_ext_body *cea;
+ struct cea_data_block *data_collection;
+ struct cea_data_block *data_end;
+
+ cea = (struct cea_ext_body *) ext;
+
+ if (cea->dt_offset <= CEA_EXT_MIN_DATA_OFFSET)
+ return NULL;
+
+ data_collection = &cea->data_collection;
+ data_end = (struct cea_data_block *) (cea->dt_offset + ext);
+
+ for (; data_collection < data_end;) {
+
+ if (data_type == data_collection->tag) {
+ return data_collection;
+ }
+ data_collection = (void *) ((unsigned char *) data_collection +
+ data_collection->len + 1);
+ }
+
+ return NULL;
+}
+
+static void
+handle_cea_video_block(Uchar * ext, handle_video_fn fn, void *data)
+{
+ struct cea_video_block *video;
+ struct cea_video_block *video_end;
+ struct cea_data_block *data_collection;
+
+ data_collection = extract_cea_data_block(ext, CEA_VIDEO_BLK);
+ if (data_collection == NULL)
+ return;
+
+ video = &data_collection->u.video;
+ video_end = (struct cea_video_block *)
+ ((Uchar *) video + data_collection->len);
+
+ for (; video < video_end; video = video + 1) {
+ fn(video, data);
+ }
+}
+
+void
+xf86ForEachVideoBlock(xf86MonPtr mon, handle_video_fn fn, void *data)
+{
+ int i;
+ Uchar *ext;
+
+ if (mon == NULL)
+ return;
+
+ for (i = 0; i < mon->no_sections; i++) {
+ ext = mon->rawData + EDID1_LEN * (i + 1);
+ switch (ext[EXT_TAG]) {
+ case CEA_EXT:
+ handle_cea_video_block(ext, fn, data);
+ break;
+ case VTB_EXT:
+ case DI_EXT:
+ case LS_EXT:
+ case MI_EXT:
+ break;
+ }
+ }
+}
+
+xf86MonPtr
+xf86InterpretEEDID(int scrnIndex, Uchar * block)
+{
+ xf86MonPtr m;
+
+ m = xf86InterpretEDID(scrnIndex, block);
+ if (!m)
+ return NULL;
+
+ /* extension parse */
+
+ return m;
+}
+
+static void
+get_vendor_section(Uchar * c, struct vendor *r)
+{
+ r->name[0] = L1;
+ r->name[1] = L2;
+ r->name[2] = L3;
+ r->name[3] = '\0';
+
+ r->prod_id = PROD_ID;
+ r->serial = SERIAL_NO;
+ r->week = WEEK;
+ r->year = YEAR;
+}
+
+static void
+get_version_section(Uchar * c, struct edid_version *r)
+{
+ r->version = VERSION;
+ r->revision = REVISION;
+}
+
+static void
+get_display_section(Uchar * c, struct disp_features *r, struct edid_version *v)
+{
+ r->input_type = INPUT_TYPE;
+ if (!DIGITAL(r->input_type)) {
+ r->input_voltage = INPUT_VOLTAGE;
+ r->input_setup = SETUP;
+ r->input_sync = SYNC;
+ }
+ else if (v->revision == 2 || v->revision == 3) {
+ r->input_dfp = DFP;
+ }
+ else if (v->revision >= 4) {
+ r->input_bpc = BPC;
+ r->input_interface = DIGITAL_INTERFACE;
+ }
+ r->hsize = HSIZE_MAX;
+ r->vsize = VSIZE_MAX;
+ r->gamma = GAMMA;
+ r->dpms = DPMS;
+ r->display_type = DISPLAY_TYPE;
+ r->msc = MSC;
+ r->redx = REDX;
+ r->redy = REDY;
+ r->greenx = GREENX;
+ r->greeny = GREENY;
+ r->bluex = BLUEX;
+ r->bluey = BLUEY;
+ r->whitex = WHITEX;
+ r->whitey = WHITEY;
+}
+
+static void
+get_established_timing_section(Uchar * c, struct established_timings *r)
+{
+ r->t1 = T1;
+ r->t2 = T2;
+ r->t_manu = T_MANU;
+}
+
+static void
+get_cvt_timing_section(Uchar * c, struct cvt_timings *r)
+{
+ int i;
+
+ for (i = 0; i < 4; i++) {
+ if (c[0] && c[1] && c[2]) {
+ r[i].height = (c[0] + ((c[1] & 0xF0) << 8) + 1) * 2;
+ switch (c[1] & 0xc0) {
+ case 0x00:
+ r[i].width = r[i].height * 4 / 3;
+ break;
+ case 0x40:
+ r[i].width = r[i].height * 16 / 9;
+ break;
+ case 0x80:
+ r[i].width = r[i].height * 16 / 10;
+ break;
+ case 0xc0:
+ r[i].width = r[i].height * 15 / 9;
+ break;
+ }
+ switch (c[2] & 0x60) {
+ case 0x00:
+ r[i].rate = 50;
+ break;
+ case 0x20:
+ r[i].rate = 60;
+ break;
+ case 0x40:
+ r[i].rate = 75;
+ break;
+ case 0x60:
+ r[i].rate = 85;
+ break;
+ }
+ r[i].rates = c[2] & 0x1f;
+ }
+ else {
+ return;
+ }
+ c += 3;
+ }
+}
+
+static void
+get_std_timing_section(Uchar * c, struct std_timings *r, struct edid_version *v)
+{
+ int i;
+
+ for (i = 0; i < STD_TIMINGS; i++) {
+ if (VALID_TIMING) {
+ r[i].hsize = HSIZE1;
+ VSIZE1(r[i].vsize);
+ r[i].refresh = REFRESH_R;
+ r[i].id = STD_TIMING_ID;
+ }
+ else {
+ r[i].hsize = r[i].vsize = r[i].refresh = r[i].id = 0;
+ }
+ NEXT_STD_TIMING;
+ }
+}
+
+static const unsigned char empty_block[18];
+
+static void
+fetch_detailed_block(Uchar * c, struct edid_version *ver,
+ struct detailed_monitor_section *det_mon)
+{
+ if (ver->version == 1 && ver->revision >= 1 && IS_MONITOR_DESC) {
+ switch (MONITOR_DESC_TYPE) {
+ case SERIAL_NUMBER:
+ det_mon->type = DS_SERIAL;
+ copy_string(c, det_mon->section.serial);
+ break;
+ case ASCII_STR:
+ det_mon->type = DS_ASCII_STR;
+ copy_string(c, det_mon->section.ascii_data);
+ break;
+ case MONITOR_RANGES:
+ det_mon->type = DS_RANGES;
+ get_monitor_ranges(c, &det_mon->section.ranges);
+ break;
+ case MONITOR_NAME:
+ det_mon->type = DS_NAME;
+ copy_string(c, det_mon->section.name);
+ break;
+ case ADD_COLOR_POINT:
+ det_mon->type = DS_WHITE_P;
+ get_whitepoint_section(c, det_mon->section.wp);
+ break;
+ case ADD_STD_TIMINGS:
+ det_mon->type = DS_STD_TIMINGS;
+ get_dst_timing_section(c, det_mon->section.std_t, ver);
+ break;
+ case COLOR_MANAGEMENT_DATA:
+ det_mon->type = DS_CMD;
+ break;
+ case CVT_3BYTE_DATA:
+ det_mon->type = DS_CVT;
+ get_cvt_timing_section(c, det_mon->section.cvt);
+ break;
+ case ADD_EST_TIMINGS:
+ det_mon->type = DS_EST_III;
+ memcpy(det_mon->section.est_iii, c + 6, 6);
+ break;
+ case ADD_DUMMY:
+ det_mon->type = DS_DUMMY;
+ break;
+ default:
+ det_mon->type = DS_UNKOWN;
+ break;
+ }
+ if (c[3] <= 0x0F && memcmp(c, empty_block, sizeof(empty_block))) {
+ det_mon->type = DS_VENDOR + c[3];
+ }
+ }
+ else {
+ det_mon->type = DT;
+ get_detailed_timing_section(c, &det_mon->section.d_timings);
+ }
+}
+
+static void
+get_dt_md_section(Uchar * c, struct edid_version *ver,
+ struct detailed_monitor_section *det_mon)
+{
+ int i;
+
+ for (i = 0; i < DET_TIMINGS; i++) {
+ fetch_detailed_block(c, ver, det_mon + i);
+ NEXT_DT_MD_SECTION;
+ }
+}
+
+static void
+copy_string(Uchar * c, Uchar * s)
+{
+ int i;
+
+ c = c + 5;
+ for (i = 0; (i < 13 && *c != 0x0A); i++)
+ *(s++) = *(c++);
+ *s = 0;
+ while (i-- && (*--s == 0x20))
+ *s = 0;
+}
+
+static void
+get_dst_timing_section(Uchar * c, struct std_timings *t, struct edid_version *v)
+{
+ int j;
+
+ c = c + 5;
+ for (j = 0; j < 5; j++) {
+ t[j].hsize = HSIZE1;
+ VSIZE1(t[j].vsize);
+ t[j].refresh = REFRESH_R;
+ t[j].id = STD_TIMING_ID;
+ NEXT_STD_TIMING;
+ }
+}
+
+static void
+get_monitor_ranges(Uchar * c, struct monitor_ranges *r)
+{
+ r->min_v = MIN_V;
+ r->max_v = MAX_V;
+ r->min_h = MIN_H;
+ r->max_h = MAX_H;
+ r->max_clock = 0;
+ if (MAX_CLOCK != 0xff) /* is specified? */
+ r->max_clock = MAX_CLOCK * 10 + 5;
+ if (HAVE_2ND_GTF) {
+ r->gtf_2nd_f = F_2ND_GTF;
+ r->gtf_2nd_c = C_2ND_GTF;
+ r->gtf_2nd_m = M_2ND_GTF;
+ r->gtf_2nd_k = K_2ND_GTF;
+ r->gtf_2nd_j = J_2ND_GTF;
+ }
+ else {
+ r->gtf_2nd_f = 0;
+ }
+ if (HAVE_CVT) {
+ r->max_clock_khz = MAX_CLOCK_KHZ;
+ r->max_clock = r->max_clock_khz / 1000;
+ r->maxwidth = MAXWIDTH;
+ r->supported_aspect = SUPPORTED_ASPECT;
+ r->preferred_aspect = PREFERRED_ASPECT;
+ r->supported_blanking = SUPPORTED_BLANKING;
+ r->supported_scaling = SUPPORTED_SCALING;
+ r->preferred_refresh = PREFERRED_REFRESH;
+ }
+ else {
+ r->max_clock_khz = 0;
+ }
+}
+
+static void
+get_whitepoint_section(Uchar * c, struct whitePoints *wp)
+{
+ wp[0].white_x = WHITEX1;
+ wp[0].white_y = WHITEY1;
+ wp[1].white_x = WHITEX2;
+ wp[1].white_y = WHITEY2;
+ wp[0].index = WHITE_INDEX1;
+ wp[1].index = WHITE_INDEX2;
+ wp[0].white_gamma = WHITE_GAMMA1;
+ wp[1].white_gamma = WHITE_GAMMA2;
+}
+
+static void
+get_detailed_timing_section(Uchar * c, struct detailed_timings *r)
+{
+ r->clock = PIXEL_CLOCK;
+ r->h_active = H_ACTIVE;
+ r->h_blanking = H_BLANK;
+ r->v_active = V_ACTIVE;
+ r->v_blanking = V_BLANK;
+ r->h_sync_off = H_SYNC_OFF;
+ r->h_sync_width = H_SYNC_WIDTH;
+ r->v_sync_off = V_SYNC_OFF;
+ r->v_sync_width = V_SYNC_WIDTH;
+ r->h_size = H_SIZE;
+ r->v_size = V_SIZE;
+ r->h_border = H_BORDER;
+ r->v_border = V_BORDER;
+ r->interlaced = INTERLACED;
+ r->stereo = STEREO;
+ r->stereo_1 = STEREO1;
+ r->sync = SYNC_T;
+ r->misc = MISC;
+}
+
+#define MAX_EDID_MINOR 4
+
+static Bool
+validate_version(int scrnIndex, struct edid_version *r)
+{
+ if (r->version != 1) {
+ xf86DrvMsg(scrnIndex, X_ERROR, "Unknown EDID version %d\n", r->version);
+ return FALSE;
+ }
+
+ if (r->revision > MAX_EDID_MINOR)
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Assuming version 1.%d is compatible with 1.%d\n",
+ r->revision, MAX_EDID_MINOR);
+
+ return TRUE;
+}
+
+/*
+ * Returns true if HDMI, false if definitely not or unknown.
+ */
+Bool
+xf86MonitorIsHDMI(xf86MonPtr mon)
+{
+ int i = 0, version, offset;
+ char *edid = NULL;
+
+ if (!mon)
+ return FALSE;
+
+ if (!(mon->flags & EDID_COMPLETE_RAWDATA))
+ return FALSE;
+
+ if (!mon->no_sections)
+ return FALSE;
+
+ edid = (char *) mon->rawData;
+ if (!edid)
+ return FALSE;
+
+ /* find the CEA extension block */
+ for (i = 1; i <= mon->no_sections; i++)
+ if (edid[i * 128] == 0x02)
+ break;
+ if (i == mon->no_sections + 1)
+ return FALSE;
+ edid += (i * 128);
+
+ version = edid[1];
+ offset = edid[2];
+ if (version < 3 || offset < 4)
+ return FALSE;
+
+ /* walk the cea data blocks */
+ for (i = 4; i < offset; i += (edid[i] & 0x1f) + 1) {
+ char *x = edid + i;
+
+ /* find a vendor specific block */
+ if ((x[0] & 0xe0) >> 5 == 0x03) {
+ int oui = (x[3] << 16) + (x[2] << 8) + x[1];
+
+ /* find the HDMI vendor OUI */
+ if (oui == 0x000c03)
+ return TRUE;
+ }
+ }
+
+ /* guess it's not HDMI after all */
+ return FALSE;
+}
diff --git a/xorg-server/hw/xfree86/ddc/print_edid.c b/xorg-server/hw/xfree86/ddc/print_edid.c
index 1faae1e33..4f983f934 100644
--- a/xorg-server/hw/xfree86/ddc/print_edid.c
+++ b/xorg-server/hw/xfree86/ddc/print_edid.c
@@ -36,24 +36,24 @@
#include "xf86_OSproc.h"
#include "xf86DDC.h"
#include "edid.h"
-
+
#define EDID_WIDTH 16
-
+
static void
print_vendor(int scrnIndex, struct vendor *c)
{
xf86DrvMsg(scrnIndex, X_INFO, "Manufacturer: %s Model: %x Serial#: %u\n",
- (char *)&c->name, c->prod_id, c->serial);
+ (char *) &c->name, c->prod_id, c->serial);
xf86DrvMsg(scrnIndex, X_INFO, "Year: %u Week: %u\n", c->year, c->week);
}
static void
print_version(int scrnIndex, struct edid_version *c)
{
- xf86DrvMsg(scrnIndex,X_INFO,"EDID Version: %u.%u\n",c->version,
- c->revision);
+ xf86DrvMsg(scrnIndex, X_INFO, "EDID Version: %u.%u\n", c->version,
+ c->revision);
}
-
+
static const char *digital_interfaces[] = {
"undefined",
"DVI",
@@ -64,212 +64,241 @@ static const char *digital_interfaces[] = {
"unknown"
};
-static void
+static void
print_input_features(int scrnIndex, struct disp_features *c,
- struct edid_version *v)
+ struct edid_version *v)
{
if (DIGITAL(c->input_type)) {
- xf86DrvMsg(scrnIndex, X_INFO, "Digital Display Input\n");
- if (v->revision == 2 || v->revision == 3) {
- if (DFP1(c->input_dfp))
- xf86DrvMsg(scrnIndex, X_INFO, "DFP 1.x compatible TMDS\n");
- } else if (v->revision >= 4) {
- int interface = c->input_interface;
- int bpc = c->input_bpc;
- if (interface > 6)
- interface = 6; /* unknown */
- if (bpc == 0 || bpc == 7)
- xf86DrvMsg(scrnIndex, X_INFO, "Undefined color depth\n");
- else
- xf86DrvMsg(scrnIndex, X_INFO, "%d bits per channel\n",
- bpc * 2 + 4);
- xf86DrvMsg(scrnIndex, X_INFO, "Digital interface is %s\n",
- digital_interfaces[interface]);
- }
- } else {
- xf86DrvMsg(scrnIndex,X_INFO,"Analog Display Input, ");
- xf86ErrorF("Input Voltage Level: ");
- switch (c->input_voltage){
- case V070:
- xf86ErrorF("0.700/0.300 V\n");
- break;
- case V071:
- xf86ErrorF("0.714/0.286 V\n");
- break;
- case V100:
- xf86ErrorF("1.000/0.400 V\n");
- break;
- case V007:
+ xf86DrvMsg(scrnIndex, X_INFO, "Digital Display Input\n");
+ if (v->revision == 2 || v->revision == 3) {
+ if (DFP1(c->input_dfp))
+ xf86DrvMsg(scrnIndex, X_INFO, "DFP 1.x compatible TMDS\n");
+ }
+ else if (v->revision >= 4) {
+ int interface = c->input_interface;
+ int bpc = c->input_bpc;
+
+ if (interface > 6)
+ interface = 6; /* unknown */
+ if (bpc == 0 || bpc == 7)
+ xf86DrvMsg(scrnIndex, X_INFO, "Undefined color depth\n");
+ else
+ xf86DrvMsg(scrnIndex, X_INFO, "%d bits per channel\n",
+ bpc * 2 + 4);
+ xf86DrvMsg(scrnIndex, X_INFO, "Digital interface is %s\n",
+ digital_interfaces[interface]);
+ }
+ }
+ else {
+ xf86DrvMsg(scrnIndex, X_INFO, "Analog Display Input, ");
+ xf86ErrorF("Input Voltage Level: ");
+ switch (c->input_voltage) {
+ case V070:
+ xf86ErrorF("0.700/0.300 V\n");
+ break;
+ case V071:
+ xf86ErrorF("0.714/0.286 V\n");
+ break;
+ case V100:
+ xf86ErrorF("1.000/0.400 V\n");
+ break;
+ case V007:
xf86ErrorF("0.700/0.700 V\n");
- break;
- default:
- xf86ErrorF("undefined\n");
- }
- if (SIG_SETUP(c->input_setup))
- xf86DrvMsg(scrnIndex,X_INFO,"Signal levels configurable\n");
- xf86DrvMsg(scrnIndex,X_INFO,"Sync:");
- if (SEP_SYNC(c->input_sync))
- xf86ErrorF(" Separate");
- if (COMP_SYNC(c->input_sync))
- xf86ErrorF(" Composite");
- if (SYNC_O_GREEN(c->input_sync))
- xf86ErrorF(" SyncOnGreen");
- if (SYNC_SERR(c->input_sync))
- xf86ErrorF("Serration on. "
- "V.Sync Pulse req. if CompSync or SyncOnGreen\n");
- else xf86ErrorF("\n");
+ break;
+ default:
+ xf86ErrorF("undefined\n");
+ }
+ if (SIG_SETUP(c->input_setup))
+ xf86DrvMsg(scrnIndex, X_INFO, "Signal levels configurable\n");
+ xf86DrvMsg(scrnIndex, X_INFO, "Sync:");
+ if (SEP_SYNC(c->input_sync))
+ xf86ErrorF(" Separate");
+ if (COMP_SYNC(c->input_sync))
+ xf86ErrorF(" Composite");
+ if (SYNC_O_GREEN(c->input_sync))
+ xf86ErrorF(" SyncOnGreen");
+ if (SYNC_SERR(c->input_sync))
+ xf86ErrorF("Serration on. "
+ "V.Sync Pulse req. if CompSync or SyncOnGreen\n");
+ else
+ xf86ErrorF("\n");
}
}
-
-static void
+
+static void
print_dpms_features(int scrnIndex, struct disp_features *c,
- struct edid_version *v)
+ struct edid_version *v)
{
- if (c->dpms) {
- xf86DrvMsg(scrnIndex,X_INFO,"DPMS capabilities:");
- if (DPMS_STANDBY(c->dpms)) xf86ErrorF(" StandBy");
- if (DPMS_SUSPEND(c->dpms)) xf86ErrorF(" Suspend");
- if (DPMS_OFF(c->dpms)) xf86ErrorF(" Off");
- } else
- xf86DrvMsg(scrnIndex,X_INFO,"No DPMS capabilities specified");
- if (!c->input_type) { /* analog */
- switch (c->display_type){
- case DISP_MONO:
- xf86ErrorF("; Monochorome/GrayScale Display\n");
- break;
- case DISP_RGB:
- xf86ErrorF("; RGB/Color Display\n");
- break;
- case DISP_MULTCOLOR:
- xf86ErrorF("; Non RGB Multicolor Display\n");
- break;
- default:
- xf86ErrorF("\n");
- break;
- }
- } else {
- int enc = c->display_type;
- xf86ErrorF("\n");
- xf86DrvMsg(scrnIndex, X_INFO, "Supported color encodings: "
- "RGB 4:4:4 %s%s\n",
- enc & DISP_YCRCB444 ? "YCrCb 4:4:4 " : "",
- enc & DISP_YCRCB422 ? "YCrCb 4:2:2" : "");
+ if (c->dpms) {
+ xf86DrvMsg(scrnIndex, X_INFO, "DPMS capabilities:");
+ if (DPMS_STANDBY(c->dpms))
+ xf86ErrorF(" StandBy");
+ if (DPMS_SUSPEND(c->dpms))
+ xf86ErrorF(" Suspend");
+ if (DPMS_OFF(c->dpms))
+ xf86ErrorF(" Off");
+ }
+ else
+ xf86DrvMsg(scrnIndex, X_INFO, "No DPMS capabilities specified");
+ if (!c->input_type) { /* analog */
+ switch (c->display_type) {
+ case DISP_MONO:
+ xf86ErrorF("; Monochorome/GrayScale Display\n");
+ break;
+ case DISP_RGB:
+ xf86ErrorF("; RGB/Color Display\n");
+ break;
+ case DISP_MULTCOLOR:
+ xf86ErrorF("; Non RGB Multicolor Display\n");
+ break;
+ default:
+ xf86ErrorF("\n");
+ break;
+ }
+ }
+ else {
+ int enc = c->display_type;
+
+ xf86ErrorF("\n");
+ xf86DrvMsg(scrnIndex, X_INFO, "Supported color encodings: "
+ "RGB 4:4:4 %s%s\n",
+ enc & DISP_YCRCB444 ? "YCrCb 4:4:4 " : "",
+ enc & DISP_YCRCB422 ? "YCrCb 4:2:2" : "");
}
if (STD_COLOR_SPACE(c->msc))
- xf86DrvMsg(scrnIndex,X_INFO,
- "Default color space is primary color space\n");
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Default color space is primary color space\n");
if (PREFERRED_TIMING_MODE(c->msc) || v->revision >= 4) {
- xf86DrvMsg(scrnIndex, X_INFO,
- "First detailed timing is preferred mode\n");
- if (v->revision >= 4)
- xf86DrvMsg(scrnIndex, X_INFO,
- "Preferred mode is native pixel format and refresh rate\n");
- } else if (v->revision == 3) {
- xf86DrvMsg(scrnIndex,X_INFO,
- "First detailed timing not preferred "
- "mode in violation of standard!\n");
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "First detailed timing is preferred mode\n");
+ if (v->revision >= 4)
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Preferred mode is native pixel format and refresh rate\n");
+ }
+ else if (v->revision == 3) {
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "First detailed timing not preferred "
+ "mode in violation of standard!\n");
}
if (v->revision >= 4) {
- if (GFT_SUPPORTED(c->msc)) {
- xf86DrvMsg(scrnIndex, X_INFO, "Display is continuous-frequency\n");
- }
- } else {
- if (GFT_SUPPORTED(c->msc))
- xf86DrvMsg(scrnIndex, X_INFO, "GTF timings supported\n");
+ if (GFT_SUPPORTED(c->msc)) {
+ xf86DrvMsg(scrnIndex, X_INFO, "Display is continuous-frequency\n");
+ }
+ }
+ else {
+ if (GFT_SUPPORTED(c->msc))
+ xf86DrvMsg(scrnIndex, X_INFO, "GTF timings supported\n");
}
}
-
-static void
+
+static void
print_whitepoint(int scrnIndex, struct disp_features *disp)
{
- xf86DrvMsg(scrnIndex,X_INFO,"redX: %.3f redY: %.3f ",
- disp->redx,disp->redy);
- xf86ErrorF("greenX: %.3f greenY: %.3f\n",
- disp->greenx,disp->greeny);
- xf86DrvMsg(scrnIndex,X_INFO,"blueX: %.3f blueY: %.3f ",
- disp->bluex,disp->bluey);
- xf86ErrorF("whiteX: %.3f whiteY: %.3f\n",
- disp->whitex,disp->whitey);
+ xf86DrvMsg(scrnIndex, X_INFO, "redX: %.3f redY: %.3f ",
+ disp->redx, disp->redy);
+ xf86ErrorF("greenX: %.3f greenY: %.3f\n", disp->greenx, disp->greeny);
+ xf86DrvMsg(scrnIndex, X_INFO, "blueX: %.3f blueY: %.3f ",
+ disp->bluex, disp->bluey);
+ xf86ErrorF("whiteX: %.3f whiteY: %.3f\n", disp->whitex, disp->whitey);
}
static void
-print_display(int scrnIndex, struct disp_features *disp,
- struct edid_version *v)
+print_display(int scrnIndex, struct disp_features *disp, struct edid_version *v)
{
print_input_features(scrnIndex, disp, v);
if (disp->hsize && disp->vsize) {
- xf86DrvMsg(scrnIndex, X_INFO, "Max Image Size [cm]: ");
- xf86ErrorF("horiz.: %i ", disp->hsize);
- xf86ErrorF("vert.: %i\n", disp->vsize);
- } else if (v->revision >= 4 && (disp->hsize || disp->vsize)) {
- if (disp->hsize)
- xf86DrvMsg(scrnIndex, X_INFO, "Aspect ratio: %.2f (landscape)\n",
- (disp->hsize + 99) / 100.0);
- if (disp->vsize)
- xf86DrvMsg(scrnIndex, X_INFO, "Aspect ratio: %.2f (portrait)\n",
- 100.0 / (float)(disp->vsize + 99));
-
- } else {
- xf86DrvMsg(scrnIndex, X_INFO, "Indeterminate output size\n");
+ xf86DrvMsg(scrnIndex, X_INFO, "Max Image Size [cm]: ");
+ xf86ErrorF("horiz.: %i ", disp->hsize);
+ xf86ErrorF("vert.: %i\n", disp->vsize);
+ }
+ else if (v->revision >= 4 && (disp->hsize || disp->vsize)) {
+ if (disp->hsize)
+ xf86DrvMsg(scrnIndex, X_INFO, "Aspect ratio: %.2f (landscape)\n",
+ (disp->hsize + 99) / 100.0);
+ if (disp->vsize)
+ xf86DrvMsg(scrnIndex, X_INFO, "Aspect ratio: %.2f (portrait)\n",
+ 100.0 / (float) (disp->vsize + 99));
+
+ }
+ else {
+ xf86DrvMsg(scrnIndex, X_INFO, "Indeterminate output size\n");
}
if (!disp->gamma && v->revision >= 1.4)
- xf86DrvMsg(scrnIndex, X_INFO, "Gamma defined in extension block\n");
+ xf86DrvMsg(scrnIndex, X_INFO, "Gamma defined in extension block\n");
else
- xf86DrvMsg(scrnIndex, X_INFO, "Gamma: %.2f\n", disp->gamma);
+ xf86DrvMsg(scrnIndex, X_INFO, "Gamma: %.2f\n", disp->gamma);
print_dpms_features(scrnIndex, disp, v);
print_whitepoint(scrnIndex, disp);
}
-static void
+static void
print_established_timings(int scrnIndex, struct established_timings *t)
{
unsigned char c;
if (t->t1 || t->t2 || t->t_manu)
- xf86DrvMsg(scrnIndex,X_INFO,"Supported established timings:\n");
- c=t->t1;
- if (c&0x80) xf86DrvMsg(scrnIndex,X_INFO,"720x400@70Hz\n");
- if (c&0x40) xf86DrvMsg(scrnIndex,X_INFO,"720x400@88Hz\n");
- if (c&0x20) xf86DrvMsg(scrnIndex,X_INFO,"640x480@60Hz\n");
- if (c&0x10) xf86DrvMsg(scrnIndex,X_INFO,"640x480@67Hz\n");
- if (c&0x08) xf86DrvMsg(scrnIndex,X_INFO,"640x480@72Hz\n");
- if (c&0x04) xf86DrvMsg(scrnIndex,X_INFO,"640x480@75Hz\n");
- if (c&0x02) xf86DrvMsg(scrnIndex,X_INFO,"800x600@56Hz\n");
- if (c&0x01) xf86DrvMsg(scrnIndex,X_INFO,"800x600@60Hz\n");
- c=t->t2;
- if (c&0x80) xf86DrvMsg(scrnIndex,X_INFO,"800x600@72Hz\n");
- if (c&0x40) xf86DrvMsg(scrnIndex,X_INFO,"800x600@75Hz\n");
- if (c&0x20) xf86DrvMsg(scrnIndex,X_INFO,"832x624@75Hz\n");
- if (c&0x10) xf86DrvMsg(scrnIndex,X_INFO,"1024x768@87Hz (interlaced)\n");
- if (c&0x08) xf86DrvMsg(scrnIndex,X_INFO,"1024x768@60Hz\n");
- if (c&0x04) xf86DrvMsg(scrnIndex,X_INFO,"1024x768@70Hz\n");
- if (c&0x02) xf86DrvMsg(scrnIndex,X_INFO,"1024x768@75Hz\n");
- if (c&0x01) xf86DrvMsg(scrnIndex,X_INFO,"1280x1024@75Hz\n");
- c=t->t_manu;
- if (c&0x80) xf86DrvMsg(scrnIndex,X_INFO,"1152x864@75Hz\n");
- xf86DrvMsg(scrnIndex,X_INFO,"Manufacturer's mask: %X\n",c&0x7F);
+ xf86DrvMsg(scrnIndex, X_INFO, "Supported established timings:\n");
+ c = t->t1;
+ if (c & 0x80)
+ xf86DrvMsg(scrnIndex, X_INFO, "720x400@70Hz\n");
+ if (c & 0x40)
+ xf86DrvMsg(scrnIndex, X_INFO, "720x400@88Hz\n");
+ if (c & 0x20)
+ xf86DrvMsg(scrnIndex, X_INFO, "640x480@60Hz\n");
+ if (c & 0x10)
+ xf86DrvMsg(scrnIndex, X_INFO, "640x480@67Hz\n");
+ if (c & 0x08)
+ xf86DrvMsg(scrnIndex, X_INFO, "640x480@72Hz\n");
+ if (c & 0x04)
+ xf86DrvMsg(scrnIndex, X_INFO, "640x480@75Hz\n");
+ if (c & 0x02)
+ xf86DrvMsg(scrnIndex, X_INFO, "800x600@56Hz\n");
+ if (c & 0x01)
+ xf86DrvMsg(scrnIndex, X_INFO, "800x600@60Hz\n");
+ c = t->t2;
+ if (c & 0x80)
+ xf86DrvMsg(scrnIndex, X_INFO, "800x600@72Hz\n");
+ if (c & 0x40)
+ xf86DrvMsg(scrnIndex, X_INFO, "800x600@75Hz\n");
+ if (c & 0x20)
+ xf86DrvMsg(scrnIndex, X_INFO, "832x624@75Hz\n");
+ if (c & 0x10)
+ xf86DrvMsg(scrnIndex, X_INFO, "1024x768@87Hz (interlaced)\n");
+ if (c & 0x08)
+ xf86DrvMsg(scrnIndex, X_INFO, "1024x768@60Hz\n");
+ if (c & 0x04)
+ xf86DrvMsg(scrnIndex, X_INFO, "1024x768@70Hz\n");
+ if (c & 0x02)
+ xf86DrvMsg(scrnIndex, X_INFO, "1024x768@75Hz\n");
+ if (c & 0x01)
+ xf86DrvMsg(scrnIndex, X_INFO, "1280x1024@75Hz\n");
+ c = t->t_manu;
+ if (c & 0x80)
+ xf86DrvMsg(scrnIndex, X_INFO, "1152x864@75Hz\n");
+ xf86DrvMsg(scrnIndex, X_INFO, "Manufacturer's mask: %X\n", c & 0x7F);
}
-
+
static void
print_std_timings(int scrnIndex, struct std_timings *t)
{
int i;
char done = 0;
- for (i=0;i<STD_TIMINGS;i++) {
- if (t[i].hsize > 256) { /* sanity check */
- if (!done) {
- xf86DrvMsg(scrnIndex,X_INFO,"Supported standard timings:\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);
- }
+
+ for (i = 0; i < STD_TIMINGS; i++) {
+ if (t[i].hsize > 256) { /* sanity check */
+ if (!done) {
+ xf86DrvMsg(scrnIndex, X_INFO, "Supported standard timings:\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);
+ }
}
}
@@ -279,15 +308,17 @@ print_cvt_timings(int si, struct cvt_timings *t)
int i;
for (i = 0; i < 4; i++) {
- if (t[i].height) {
- xf86DrvMsg(si, X_INFO, "%dx%d @ %s%s%s%s%s Hz\n",
- t[i].width, t[i].height,
- t[i].rates & 0x10 ? "50," : "",
- t[i].rates & 0x08 ? "60," : "",
- t[i].rates & 0x04 ? "75," : "",
- t[i].rates & 0x02 ? "85," : "",
- t[i].rates & 0x01 ? "60RB" : "");
- } else break;
+ if (t[i].height) {
+ xf86DrvMsg(si, X_INFO, "%dx%d @ %s%s%s%s%s Hz\n",
+ t[i].width, t[i].height,
+ t[i].rates & 0x10 ? "50," : "",
+ t[i].rates & 0x08 ? "60," : "",
+ t[i].rates & 0x04 ? "75," : "",
+ t[i].rates & 0x02 ? "85," : "",
+ t[i].rates & 0x01 ? "60RB" : "");
+ }
+ else
+ break;
}
}
@@ -296,166 +327,174 @@ print_detailed_timings(int scrnIndex, struct detailed_timings *t)
{
if (t->clock > 15000000) { /* sanity check */
- xf86DrvMsg(scrnIndex,X_INFO,"Supported detailed timing:\n");
- xf86DrvMsg(scrnIndex,X_INFO,"clock: %.1f MHz ",t->clock/1000000.0);
- xf86ErrorF("Image Size: %i x %i mm\n",t->h_size,t->v_size);
- xf86DrvMsg(scrnIndex,X_INFO,
- "h_active: %i h_sync: %i h_sync_end %i h_blank_end %i ",
- t->h_active, t->h_sync_off + t->h_active,
- t->h_sync_off + t->h_sync_width + t->h_active,
- t->h_active + t->h_blanking);
- xf86ErrorF("h_border: %i\n",t->h_border);
- xf86DrvMsg(scrnIndex,X_INFO,
- "v_active: %i v_sync: %i v_sync_end %i v_blanking: %i ",
- t->v_active, t->v_sync_off + t->v_active,
- t->v_sync_off + t->v_sync_width + t->v_active,
- t->v_active + t->v_blanking);
- xf86ErrorF("v_border: %i\n",t->v_border);
- if (IS_STEREO(t->stereo)) {
- xf86DrvMsg(scrnIndex,X_INFO,"Stereo: ");
- if (IS_RIGHT_STEREO(t->stereo)) {
- if (!t->stereo_1)
- xf86ErrorF("right channel on sync\n");
- else
- xf86ErrorF("left channel on sync\n");
- } else if (IS_LEFT_STEREO(t->stereo)) {
- if (!t->stereo_1)
- xf86ErrorF("right channel on even line\n");
- else
- xf86ErrorF("left channel on evel line\n");
- }
- if (IS_4WAY_STEREO(t->stereo)) {
- if (!t->stereo_1)
- xf86ErrorF("4-way interleaved\n");
- else
- xf86ErrorF("side-by-side interleaved");
- }
- }
+ xf86DrvMsg(scrnIndex, X_INFO, "Supported detailed timing:\n");
+ xf86DrvMsg(scrnIndex, X_INFO, "clock: %.1f MHz ",
+ t->clock / 1000000.0);
+ xf86ErrorF("Image Size: %i x %i mm\n", t->h_size, t->v_size);
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "h_active: %i h_sync: %i h_sync_end %i h_blank_end %i ",
+ t->h_active, t->h_sync_off + t->h_active,
+ t->h_sync_off + t->h_sync_width + t->h_active,
+ t->h_active + t->h_blanking);
+ xf86ErrorF("h_border: %i\n", t->h_border);
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "v_active: %i v_sync: %i v_sync_end %i v_blanking: %i ",
+ t->v_active, t->v_sync_off + t->v_active,
+ t->v_sync_off + t->v_sync_width + t->v_active,
+ t->v_active + t->v_blanking);
+ xf86ErrorF("v_border: %i\n", t->v_border);
+ if (IS_STEREO(t->stereo)) {
+ xf86DrvMsg(scrnIndex, X_INFO, "Stereo: ");
+ if (IS_RIGHT_STEREO(t->stereo)) {
+ if (!t->stereo_1)
+ xf86ErrorF("right channel on sync\n");
+ else
+ xf86ErrorF("left channel on sync\n");
+ }
+ else if (IS_LEFT_STEREO(t->stereo)) {
+ if (!t->stereo_1)
+ xf86ErrorF("right channel on even line\n");
+ else
+ xf86ErrorF("left channel on evel line\n");
+ }
+ if (IS_4WAY_STEREO(t->stereo)) {
+ if (!t->stereo_1)
+ xf86ErrorF("4-way interleaved\n");
+ else
+ xf86ErrorF("side-by-side interleaved");
+ }
+ }
}
}
/* This function handle all detailed patchs,
* including EDID and EDID-extension
*/
-struct det_print_parameter{
- xf86MonPtr m;
- int index;
- ddc_quirk_t quirks;
+struct det_print_parameter {
+ xf86MonPtr m;
+ int index;
+ ddc_quirk_t quirks;
};
static void
-handle_detailed_print(struct detailed_monitor_section *det_mon,
- void *data)
+handle_detailed_print(struct detailed_monitor_section *det_mon, void *data)
{
int j, scrnIndex;
struct det_print_parameter *p;
- p = (struct det_print_parameter *)data;
+ p = (struct det_print_parameter *) data;
scrnIndex = p->m->scrnIndex;
- xf86DetTimingApplyQuirks(det_mon,p->quirks,
- p->m->features.hsize,
- p->m->features.vsize);
+ xf86DetTimingApplyQuirks(det_mon, p->quirks,
+ p->m->features.hsize, p->m->features.vsize);
switch (det_mon->type) {
case DT:
- print_detailed_timings(scrnIndex,&det_mon->section.d_timings);
+ print_detailed_timings(scrnIndex, &det_mon->section.d_timings);
break;
case DS_SERIAL:
- xf86DrvMsg(scrnIndex,X_INFO,"Serial No: %s\n",det_mon->section.serial);
+ xf86DrvMsg(scrnIndex, X_INFO, "Serial No: %s\n",
+ det_mon->section.serial);
break;
case DS_ASCII_STR:
- xf86DrvMsg(scrnIndex,X_INFO," %s\n",det_mon->section.ascii_data);
+ xf86DrvMsg(scrnIndex, X_INFO, " %s\n", det_mon->section.ascii_data);
break;
case DS_NAME:
- xf86DrvMsg(scrnIndex,X_INFO,"Monitor name: %s\n",det_mon->section.name);
+ xf86DrvMsg(scrnIndex, X_INFO, "Monitor name: %s\n",
+ det_mon->section.name);
break;
case DS_RANGES:
{
struct monitor_ranges *r = &det_mon->section.ranges;
- xf86DrvMsg(scrnIndex,X_INFO,
+
+ xf86DrvMsg(scrnIndex, X_INFO,
"Ranges: V min: %i V max: %i Hz, H min: %i H max: %i kHz,",
r->min_v, r->max_v, r->min_h, r->max_h);
if (r->max_clock_khz != 0) {
xf86ErrorF(" PixClock max %i kHz\n", r->max_clock_khz);
- if (r->maxwidth)
- xf86DrvMsg(scrnIndex, X_INFO, "Maximum pixel width: %d\n",
- r->maxwidth);
- xf86DrvMsg(scrnIndex, X_INFO, "Supported aspect ratios:");
- if (r->supported_aspect & SUPPORTED_ASPECT_4_3)
- xf86ErrorF(" 4:3%s",
- r->preferred_aspect == PREFERRED_ASPECT_4_3?"*":"");
- if (r->supported_aspect & SUPPORTED_ASPECT_16_9)
- xf86ErrorF(" 16:9%s",
- r->preferred_aspect == PREFERRED_ASPECT_16_9?"*":"");
- if (r->supported_aspect & SUPPORTED_ASPECT_16_10)
- xf86ErrorF(" 16:10%s",
- r->preferred_aspect == PREFERRED_ASPECT_16_10?"*":"");
- if (r->supported_aspect & SUPPORTED_ASPECT_5_4)
- xf86ErrorF(" 5:4%s",
- r->preferred_aspect == PREFERRED_ASPECT_5_4?"*":"");
- if (r->supported_aspect & SUPPORTED_ASPECT_15_9)
- xf86ErrorF(" 15:9%s",
- r->preferred_aspect == PREFERRED_ASPECT_15_9?"*":"");
- xf86ErrorF("\n");
- xf86DrvMsg(scrnIndex, X_INFO, "Supported blankings:");
- if (r->supported_blanking & CVT_STANDARD)
- xf86ErrorF(" standard");
- if (r->supported_blanking & CVT_REDUCED)
- xf86ErrorF(" reduced");
- xf86ErrorF("\n");
- xf86DrvMsg(scrnIndex, X_INFO, "Supported scalings:");
- if (r->supported_scaling & SCALING_HSHRINK)
- xf86ErrorF(" hshrink");
- if (r->supported_scaling & SCALING_HSTRETCH)
- xf86ErrorF(" hstretch");
- if (r->supported_scaling & SCALING_VSHRINK)
- xf86ErrorF(" vshrink");
- if (r->supported_scaling & SCALING_VSTRETCH)
- xf86ErrorF(" vstretch");
- xf86ErrorF("\n");
- if (r->preferred_refresh)
- xf86DrvMsg(scrnIndex, X_INFO, "Preferred refresh rate: %d\n",
- r->preferred_refresh);
- else
- xf86DrvMsg(scrnIndex, X_INFO, "Buggy monitor, no preferred "
- "refresh rate given\n");
- } else if (r->max_clock != 0) {
- xf86ErrorF(" PixClock max %i MHz\n", r->max_clock);
- } else {
- xf86ErrorF("\n");
+ if (r->maxwidth)
+ xf86DrvMsg(scrnIndex, X_INFO, "Maximum pixel width: %d\n",
+ r->maxwidth);
+ xf86DrvMsg(scrnIndex, X_INFO, "Supported aspect ratios:");
+ if (r->supported_aspect & SUPPORTED_ASPECT_4_3)
+ xf86ErrorF(" 4:3%s",
+ r->preferred_aspect ==
+ PREFERRED_ASPECT_4_3 ? "*" : "");
+ if (r->supported_aspect & SUPPORTED_ASPECT_16_9)
+ xf86ErrorF(" 16:9%s",
+ r->preferred_aspect ==
+ PREFERRED_ASPECT_16_9 ? "*" : "");
+ if (r->supported_aspect & SUPPORTED_ASPECT_16_10)
+ xf86ErrorF(" 16:10%s",
+ r->preferred_aspect ==
+ PREFERRED_ASPECT_16_10 ? "*" : "");
+ if (r->supported_aspect & SUPPORTED_ASPECT_5_4)
+ xf86ErrorF(" 5:4%s",
+ r->preferred_aspect ==
+ PREFERRED_ASPECT_5_4 ? "*" : "");
+ if (r->supported_aspect & SUPPORTED_ASPECT_15_9)
+ xf86ErrorF(" 15:9%s",
+ r->preferred_aspect ==
+ PREFERRED_ASPECT_15_9 ? "*" : "");
+ xf86ErrorF("\n");
+ xf86DrvMsg(scrnIndex, X_INFO, "Supported blankings:");
+ if (r->supported_blanking & CVT_STANDARD)
+ xf86ErrorF(" standard");
+ if (r->supported_blanking & CVT_REDUCED)
+ xf86ErrorF(" reduced");
+ xf86ErrorF("\n");
+ xf86DrvMsg(scrnIndex, X_INFO, "Supported scalings:");
+ if (r->supported_scaling & SCALING_HSHRINK)
+ xf86ErrorF(" hshrink");
+ if (r->supported_scaling & SCALING_HSTRETCH)
+ xf86ErrorF(" hstretch");
+ if (r->supported_scaling & SCALING_VSHRINK)
+ xf86ErrorF(" vshrink");
+ if (r->supported_scaling & SCALING_VSTRETCH)
+ xf86ErrorF(" vstretch");
+ xf86ErrorF("\n");
+ if (r->preferred_refresh)
+ xf86DrvMsg(scrnIndex, X_INFO, "Preferred refresh rate: %d\n",
+ r->preferred_refresh);
+ else
+ xf86DrvMsg(scrnIndex, X_INFO, "Buggy monitor, no preferred "
+ "refresh rate given\n");
+ }
+ else if (r->max_clock != 0) {
+ xf86ErrorF(" PixClock max %i MHz\n", r->max_clock);
+ }
+ else {
+ xf86ErrorF("\n");
}
if (r->gtf_2nd_f > 0)
- xf86DrvMsg(scrnIndex,X_INFO," 2nd GTF parameters: f: %i kHz "
+ xf86DrvMsg(scrnIndex, X_INFO, " 2nd GTF parameters: f: %i kHz "
"c: %i m: %i k %i j %i\n", r->gtf_2nd_f,
- r->gtf_2nd_c, r->gtf_2nd_m, r->gtf_2nd_k,
- r->gtf_2nd_j);
+ r->gtf_2nd_c, r->gtf_2nd_m, r->gtf_2nd_k, r->gtf_2nd_j);
break;
}
case DS_STD_TIMINGS:
- for (j = 0; j<5; j++)
- xf86DrvMsg(scrnIndex,X_INFO,
- "#%i: hsize: %i vsize %i refresh: %i "
- "vid: %i\n",p->index ,det_mon->section.std_t[j].hsize,
- det_mon->section.std_t[j].vsize,
- det_mon->section.std_t[j].refresh,
- det_mon->section.std_t[j].id);
+ for (j = 0; j < 5; j++)
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "#%i: hsize: %i vsize %i refresh: %i "
+ "vid: %i\n", p->index, det_mon->section.std_t[j].hsize,
+ det_mon->section.std_t[j].vsize,
+ det_mon->section.std_t[j].refresh,
+ det_mon->section.std_t[j].id);
break;
case DS_WHITE_P:
- for (j = 0; j<2; j++)
- if (det_mon->section.wp[j].index != 0)
- xf86DrvMsg(scrnIndex,X_INFO,
- "White point %i: whiteX: %f, whiteY: %f; gamma: %f\n",
- det_mon->section.wp[j].index,det_mon->section.wp[j].white_x,
- det_mon->section.wp[j].white_y,
- det_mon->section.wp[j].white_gamma);
+ for (j = 0; j < 2; j++)
+ if (det_mon->section.wp[j].index != 0)
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "White point %i: whiteX: %f, whiteY: %f; gamma: %f\n",
+ det_mon->section.wp[j].index,
+ det_mon->section.wp[j].white_x,
+ det_mon->section.wp[j].white_y,
+ det_mon->section.wp[j].white_gamma);
break;
case DS_CMD:
- xf86DrvMsg(scrnIndex, X_INFO,
- "Color management data: (not decoded)\n");
+ xf86DrvMsg(scrnIndex, X_INFO, "Color management data: (not decoded)\n");
break;
case DS_CVT:
- xf86DrvMsg(scrnIndex, X_INFO,
- "CVT 3-byte-code modes:\n");
+ xf86DrvMsg(scrnIndex, X_INFO, "CVT 3-byte-code modes:\n");
print_cvt_timings(scrnIndex, det_mon->section.cvt);
break;
case DS_EST_III:
@@ -479,8 +518,8 @@ static void
print_number_sections(int scrnIndex, int num)
{
if (num)
- xf86DrvMsg(scrnIndex,X_INFO,"Number of EDID sections to follow: %i\n",
- num);
+ xf86DrvMsg(scrnIndex, X_INFO, "Number of EDID sections to follow: %i\n",
+ num);
}
xf86MonPtr
@@ -490,7 +529,8 @@ xf86PrintEDID(xf86MonPtr m)
char buf[EDID_WIDTH * 2 + 1];
struct det_print_parameter p;
- if (!m) return NULL;
+ if (!m)
+ return NULL;
print_vendor(m->scrnIndex, &m->vendor);
print_version(m->scrnIndex, &m->ver);
@@ -500,9 +540,7 @@ xf86PrintEDID(xf86MonPtr m)
p.m = m;
p.index = 0;
p.quirks = xf86DDCDetectQuirks(m->scrnIndex, m, FALSE);
- xf86ForEachDetailedBlock(m,
- handle_detailed_print ,
- &p);
+ xf86ForEachDetailedBlock(m, handle_detailed_print, &p);
print_number_sections(m->scrnIndex, m->no_sections);
/* extension block section stuff */
@@ -511,13 +549,13 @@ xf86PrintEDID(xf86MonPtr m)
n = 128;
if (m->flags & EDID_COMPLETE_RAWDATA)
- n += m->no_sections * 128;
+ n += m->no_sections * 128;
for (i = 0; i < n; i += j) {
- for (j = 0; j < EDID_WIDTH; ++j) {
- sprintf(&buf[j * 2], "%02x", m->rawData[i + j]);
- }
- xf86DrvMsg(m->scrnIndex, X_INFO, "\t%s\n", buf);
+ for (j = 0; j < EDID_WIDTH; ++j) {
+ sprintf(&buf[j * 2], "%02x", m->rawData[i + j]);
+ }
+ xf86DrvMsg(m->scrnIndex, X_INFO, "\t%s\n", buf);
}
return m;
diff --git a/xorg-server/hw/xfree86/ddc/xf86DDC.h b/xorg-server/hw/xfree86/ddc/xf86DDC.h
index 16a8641c6..2071d530d 100644
--- a/xorg-server/hw/xfree86/ddc/xf86DDC.h
+++ b/xorg-server/hw/xfree86/ddc/xf86DDC.h
@@ -10,7 +10,7 @@
*/
#ifndef XF86_DDC_H
-# define XF86_DDC_H
+#define XF86_DDC_H
#include "edid.h"
#include "xf86i2c.h"
@@ -18,55 +18,42 @@
/* speed up / slow down */
typedef enum {
- DDC_SLOW,
- DDC_FAST
+ DDC_SLOW,
+ DDC_FAST
} xf86ddcSpeed;
-typedef void (* DDC1SetSpeedProc)(ScrnInfoPtr, xf86ddcSpeed);
+typedef void (*DDC1SetSpeedProc) (ScrnInfoPtr, xf86ddcSpeed);
-extern _X_EXPORT xf86MonPtr xf86DoEDID_DDC1(
- int scrnIndex,
- DDC1SetSpeedProc DDC1SetSpeed,
- unsigned int (*DDC1Read)(ScrnInfoPtr)
-);
+extern _X_EXPORT xf86MonPtr xf86DoEDID_DDC1(int scrnIndex,
+ DDC1SetSpeedProc DDC1SetSpeed,
+ unsigned
+ int (*DDC1Read) (ScrnInfoPtr)
+ );
-extern _X_EXPORT xf86MonPtr xf86DoEDID_DDC2(
- int scrnIndex,
- I2CBusPtr pBus
-);
+extern _X_EXPORT xf86MonPtr xf86DoEDID_DDC2(int scrnIndex, I2CBusPtr pBus);
extern _X_EXPORT xf86MonPtr xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, Bool);
-extern _X_EXPORT xf86MonPtr xf86PrintEDID(
- xf86MonPtr monPtr
-);
+extern _X_EXPORT xf86MonPtr xf86PrintEDID(xf86MonPtr monPtr);
-extern _X_EXPORT xf86MonPtr xf86InterpretEDID(
- int screenIndex, Uchar *block
-);
+extern _X_EXPORT xf86MonPtr xf86InterpretEDID(int screenIndex, Uchar * block);
-extern _X_EXPORT xf86MonPtr xf86InterpretEEDID(
- int screenIndex, Uchar *block
-);
+extern _X_EXPORT xf86MonPtr xf86InterpretEEDID(int screenIndex, Uchar * block);
extern _X_EXPORT void
-xf86EdidMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC);
+ xf86EdidMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC);
-extern _X_EXPORT Bool xf86SetDDCproperties(
- ScrnInfoPtr pScreen,
- xf86MonPtr DDC
-);
+extern _X_EXPORT Bool xf86SetDDCproperties(ScrnInfoPtr pScreen, xf86MonPtr DDC);
extern _X_EXPORT DisplayModePtr xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC);
extern _X_EXPORT Bool
-xf86MonitorIsHDMI(xf86MonPtr mon);
+ xf86MonitorIsHDMI(xf86MonPtr mon);
-extern _X_EXPORT xf86MonPtr
-xf86DoDisplayID(int scrnIndex, I2CBusPtr pBus);
+extern _X_EXPORT xf86MonPtr xf86DoDisplayID(int scrnIndex, I2CBusPtr pBus);
extern _X_EXPORT void
-xf86DisplayIDMonitorSet(int scrnIndex, MonPtr mon, xf86MonPtr DDC);
+ xf86DisplayIDMonitorSet(int scrnIndex, MonPtr mon, xf86MonPtr DDC);
extern _X_EXPORT DisplayModePtr
FindDMTMode(int hsize, int vsize, int refresh, Bool rb);
@@ -100,22 +87,17 @@ typedef enum {
DDC_QUIRK_DVI_SINGLE_LINK = 1 << 8,
} ddc_quirk_t;
-typedef void (* handle_detailed_fn)(struct detailed_monitor_section *,void *);
+typedef void (*handle_detailed_fn) (struct detailed_monitor_section *, void *);
-void xf86ForEachDetailedBlock(xf86MonPtr mon,
- handle_detailed_fn,
- void *data);
+void xf86ForEachDetailedBlock(xf86MonPtr mon, handle_detailed_fn, void *data);
-ddc_quirk_t
-xf86DDCDetectQuirks(int scrnIndex, xf86MonPtr DDC, Bool verbose);
+ddc_quirk_t xf86DDCDetectQuirks(int scrnIndex, xf86MonPtr DDC, Bool verbose);
void xf86DetTimingApplyQuirks(struct detailed_monitor_section *det_mon,
ddc_quirk_t quirks, int hsize, int vsize);
-typedef void (* handle_video_fn)(struct cea_video_block *, void *);
+typedef void (*handle_video_fn) (struct cea_video_block *, void *);
-void xf86ForEachVideoBlock(xf86MonPtr,
- handle_video_fn,
- void *);
+void xf86ForEachVideoBlock(xf86MonPtr, handle_video_fn, void *);
#endif
diff --git a/xorg-server/hw/xfree86/dixmods/dbemodule.c b/xorg-server/hw/xfree86/dixmods/dbemodule.c
index 73639886f..5541eacab 100644
--- a/xorg-server/hw/xfree86/dixmods/dbemodule.c
+++ b/xorg-server/hw/xfree86/dixmods/dbemodule.c
@@ -17,18 +17,17 @@ static ExtensionModule dbeExt = {
NULL
};
-static XF86ModuleVersionInfo VersRec =
-{
- "dbe",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 0, 0,
- ABI_CLASS_EXTENSION,
- ABI_EXTENSION_VERSION,
- MOD_CLASS_EXTENSION,
- {0,0,0,0}
+static XF86ModuleVersionInfo VersRec = {
+ "dbe",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_EXTENSION,
+ ABI_EXTENSION_VERSION,
+ MOD_CLASS_EXTENSION,
+ {0, 0, 0, 0}
};
/*
@@ -42,5 +41,5 @@ dbeSetup(pointer module, pointer opts, int *errmaj, int *errmin)
LoadExtension(&dbeExt, FALSE);
/* Need a non-NULL return value to indicate success */
- return (pointer)1;
+ return (pointer) 1;
}
diff --git a/xorg-server/hw/xfree86/dixmods/extmod/dgaproc.h b/xorg-server/hw/xfree86/dixmods/extmod/dgaproc.h
index a13a51794..b4e0ddfea 100644
--- a/xorg-server/hw/xfree86/dixmods/extmod/dgaproc.h
+++ b/xorg-server/hw/xfree86/dixmods/extmod/dgaproc.h
@@ -23,58 +23,45 @@
#define DGA_NEED_ROOT 0x00000001
typedef struct {
- int num; /* A unique identifier for the mode (num > 0) */
- char *name; /* name of mode given in the XF86Config */
- int VSync_num;
- int VSync_den;
- int flags; /* DGA_CONCURRENT_ACCESS, etc... */
- int imageWidth; /* linear accessible portion (pixels) */
- int imageHeight;
- int pixmapWidth; /* Xlib accessible portion (pixels) */
- int pixmapHeight; /* both fields ignored if no concurrent access */
- int bytesPerScanline;
- int byteOrder; /* MSBFirst, LSBFirst */
- int depth;
- int bitsPerPixel;
- unsigned long red_mask;
- unsigned long green_mask;
- unsigned long blue_mask;
- short visualClass;
- int viewportWidth;
- int viewportHeight;
- int xViewportStep; /* viewport position granularity */
- int yViewportStep;
- int maxViewportX; /* max viewport origin */
- int maxViewportY;
- int viewportFlags; /* types of page flipping possible */
- int offset;
- int reserved1;
- int reserved2;
+ int num; /* A unique identifier for the mode (num > 0) */
+ char *name; /* name of mode given in the XF86Config */
+ int VSync_num;
+ int VSync_den;
+ int flags; /* DGA_CONCURRENT_ACCESS, etc... */
+ int imageWidth; /* linear accessible portion (pixels) */
+ int imageHeight;
+ int pixmapWidth; /* Xlib accessible portion (pixels) */
+ int pixmapHeight; /* both fields ignored if no concurrent access */
+ int bytesPerScanline;
+ int byteOrder; /* MSBFirst, LSBFirst */
+ int depth;
+ int bitsPerPixel;
+ unsigned long red_mask;
+ unsigned long green_mask;
+ unsigned long blue_mask;
+ short visualClass;
+ int viewportWidth;
+ int viewportHeight;
+ int xViewportStep; /* viewport position granularity */
+ int yViewportStep;
+ int maxViewportX; /* max viewport origin */
+ int maxViewportY;
+ int viewportFlags; /* types of page flipping possible */
+ int offset;
+ int reserved1;
+ int reserved2;
} XDGAModeRec, *XDGAModePtr;
/* DDX interface */
extern _X_EXPORT int
-DGASetMode(
- int Index,
- int num,
- XDGAModePtr mode,
- PixmapPtr *pPix
-);
+ DGASetMode(int Index, int num, XDGAModePtr mode, PixmapPtr *pPix);
extern _X_EXPORT void
-DGASetInputMode(
- int Index,
- Bool keyboard,
- Bool mouse
-);
+ DGASetInputMode(int Index, Bool keyboard, Bool mouse);
extern _X_EXPORT void
-DGASelectInput(
- int Index,
- ClientPtr client,
- long mask
-);
+ DGASelectInput(int Index, ClientPtr client, long mask);
extern _X_EXPORT Bool DGAAvailable(int Index);
extern _X_EXPORT Bool DGAActive(int Index);
@@ -84,35 +71,19 @@ extern _X_EXPORT int DGAGetViewportStatus(int Index);
extern _X_EXPORT int DGASync(int Index);
extern _X_EXPORT int
-DGAFillRect(
- int Index,
- int x, int y, int w, int h,
- unsigned long color
-);
+ DGAFillRect(int Index, int x, int y, int w, int h, unsigned long color);
extern _X_EXPORT int
-DGABlitRect(
- int Index,
- int srcx, int srcy,
- int w, int h,
- int dstx, int dsty
-);
+ DGABlitRect(int Index, int srcx, int srcy, int w, int h, int dstx, int dsty);
extern _X_EXPORT int
-DGABlitTransRect(
- int Index,
- int srcx, int srcy,
- int w, int h,
- int dstx, int dsty,
- unsigned long color
-);
+
+DGABlitTransRect(int Index,
+ int srcx, int srcy,
+ int w, int h, int dstx, int dsty, unsigned long color);
extern _X_EXPORT int
-DGASetViewport(
- int Index,
- int x, int y,
- int mode
-);
+ DGASetViewport(int Index, int x, int y, int mode);
extern _X_EXPORT int DGAGetModes(int Index);
extern _X_EXPORT int DGAGetOldDGAMode(int Index);
@@ -120,23 +91,24 @@ extern _X_EXPORT int DGAGetOldDGAMode(int Index);
extern _X_EXPORT int DGAGetModeInfo(int Index, XDGAModePtr mode, int num);
extern _X_EXPORT Bool DGAVTSwitch(void);
-extern _X_EXPORT Bool DGAStealButtonEvent(DeviceIntPtr dev, int Index, int button,
- int is_down);
-extern _X_EXPORT Bool DGAStealMotionEvent(DeviceIntPtr dev, int Index, int dx, int dy);
-extern _X_EXPORT Bool DGAStealKeyEvent(DeviceIntPtr dev, int Index, int key_code, int is_down);
-
-extern _X_EXPORT Bool DGAOpenFramebuffer(int Index, char **name, unsigned char **mem,
- int *size, int *offset, int *flags);
+extern _X_EXPORT Bool DGAStealButtonEvent(DeviceIntPtr dev, int Index,
+ int button, int is_down);
+extern _X_EXPORT Bool DGAStealMotionEvent(DeviceIntPtr dev, int Index, int dx,
+ int dy);
+extern _X_EXPORT Bool DGAStealKeyEvent(DeviceIntPtr dev, int Index,
+ int key_code, int is_down);
+
+extern _X_EXPORT Bool DGAOpenFramebuffer(int Index, char **name,
+ unsigned char **mem, int *size,
+ int *offset, int *flags);
extern _X_EXPORT void DGACloseFramebuffer(int Index);
extern _X_EXPORT Bool DGAChangePixmapMode(int Index, int *x, int *y, int mode);
-extern _X_EXPORT int DGACreateColormap(int Index, ClientPtr client, int id, int mode,
- int alloc);
+extern _X_EXPORT int DGACreateColormap(int Index, ClientPtr client, int id,
+ int mode, int alloc);
extern _X_EXPORT unsigned char DGAReqCode;
extern _X_EXPORT int DGAErrorBase;
extern _X_EXPORT int DGAEventBase;
extern _X_EXPORT int *XDGAEventBase;
-
-
-#endif /* __DGAPROC_H */
+#endif /* __DGAPROC_H */
diff --git a/xorg-server/hw/xfree86/dixmods/extmod/modinit.c b/xorg-server/hw/xfree86/dixmods/extmod/modinit.c
index 632454f37..ca15ee0e7 100644
--- a/xorg-server/hw/xfree86/dixmods/extmod/modinit.c
+++ b/xorg-server/hw/xfree86/dixmods/extmod/modinit.c
@@ -1,184 +1,177 @@
-/*
- * Copyright (c) 1997 Matthieu Herrb
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Matthieu Herrb not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Matthieu Herrb makes no
- * representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *
- * MATTHIEU HERRB DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL MATTHIEU HERRB BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Module.h"
-#include "xf86Opt.h"
-
-#include <X11/Xproto.h>
-
-#include "modinit.h"
-#include "globals.h"
-
-static MODULESETUPPROTO(extmodSetup);
-
-/*
- * Array describing extensions to be initialized
- */
-static ExtensionModule extensionModules[] = {
-#ifdef XSELINUX
- {
- SELinuxExtensionInit,
- SELINUX_EXTENSION_NAME,
- &noSELinuxExtension,
- NULL,
- NULL
- },
-#endif
-#ifdef SCREENSAVER
- {
- ScreenSaverExtensionInit,
- ScreenSaverName,
- &noScreenSaverExtension,
- NULL,
- NULL
- },
-#endif
-#ifdef XF86VIDMODE
- {
- XFree86VidModeExtensionInit,
- XF86VIDMODENAME,
- &noXFree86VidModeExtension,
- NULL,
- NULL
- },
-#endif
-#ifdef XFreeXDGA
- {
- XFree86DGAExtensionInit,
- XF86DGANAME,
- &noXFree86DGAExtension,
- XFree86DGARegister,
- NULL
- },
-#endif
-#ifdef DPMSExtension
- {
- DPMSExtensionInit,
- DPMSExtensionName,
- &noDPMSExtension,
- NULL,
- NULL
- },
-#endif
-#ifdef XV
- {
- XvExtensionInit,
- XvName,
- &noXvExtension,
- XvRegister,
- NULL
- },
- {
- XvMCExtensionInit,
- XvMCName,
- &noXvExtension,
- NULL,
- NULL
- },
-#endif
-#ifdef RES
- {
- ResExtensionInit,
- XRES_NAME,
- &noResExtension,
- NULL,
- NULL
- },
-#endif
- { /* DON'T delete this entry ! */
- NULL,
- NULL,
- NULL,
- NULL,
- NULL
- }
-};
-
-static XF86ModuleVersionInfo VersRec =
-{
- "extmod",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 0, 0,
- ABI_CLASS_EXTENSION,
- ABI_EXTENSION_VERSION,
- MOD_CLASS_EXTENSION,
- {0,0,0,0}
-};
-
-/*
- * Data for the loader
- */
-_X_EXPORT XF86ModuleData extmodModuleData = { &VersRec, extmodSetup, NULL };
-
-static pointer
-extmodSetup(pointer module, pointer opts, int *errmaj, int *errmin)
-{
- int i;
-
- /* XXX the option stuff here is largely a sample/test case */
-
- for (i = 0; extensionModules[i].name != NULL; i++) {
- if (opts) {
- char *s;
- if (asprintf(&s, "omit%s", extensionModules[i].name) != -1) {
- pointer o;
- o = xf86FindOption(opts, s);
- free(s);
- if (o) {
- xf86MarkOptionUsed(o);
- continue;
- }
- }
- }
-
-#ifdef XSELINUX
- if (! strcmp(SELINUX_EXTENSION_NAME, extensionModules[i].name)) {
- pointer o;
- selinuxEnforcingState = SELINUX_MODE_DEFAULT;
-
- if ((o = xf86FindOption(opts, "SELinux mode disabled"))) {
- xf86MarkOptionUsed(o);
- selinuxEnforcingState = SELINUX_MODE_DISABLED;
- }
- if ((o = xf86FindOption(opts, "SELinux mode permissive"))) {
- xf86MarkOptionUsed(o);
- selinuxEnforcingState = SELINUX_MODE_PERMISSIVE;
- }
- if ((o = xf86FindOption(opts, "SELinux mode enforcing"))) {
- xf86MarkOptionUsed(o);
- selinuxEnforcingState = SELINUX_MODE_ENFORCING;
- }
- }
-#endif
-
- LoadExtension(&extensionModules[i], FALSE);
- }
- /* Need a non-NULL return */
- return (pointer)1;
-}
+/*
+ * Copyright (c) 1997 Matthieu Herrb
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Matthieu Herrb not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Matthieu Herrb makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * MATTHIEU HERRB DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL MATTHIEU HERRB BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Module.h"
+#include "xf86Opt.h"
+
+#include <X11/Xproto.h>
+
+#include "modinit.h"
+#include "globals.h"
+
+static MODULESETUPPROTO(extmodSetup);
+
+/*
+ * Array describing extensions to be initialized
+ */
+static ExtensionModule extensionModules[] = {
+#ifdef XSELINUX
+ {
+ SELinuxExtensionInit,
+ SELINUX_EXTENSION_NAME,
+ &noSELinuxExtension,
+ NULL,
+ NULL},
+#endif
+#ifdef SCREENSAVER
+ {
+ ScreenSaverExtensionInit,
+ ScreenSaverName,
+ &noScreenSaverExtension,
+ NULL,
+ NULL},
+#endif
+#ifdef XF86VIDMODE
+ {
+ XFree86VidModeExtensionInit,
+ XF86VIDMODENAME,
+ &noXFree86VidModeExtension,
+ NULL,
+ NULL},
+#endif
+#ifdef XFreeXDGA
+ {
+ XFree86DGAExtensionInit,
+ XF86DGANAME,
+ &noXFree86DGAExtension,
+ XFree86DGARegister,
+ NULL},
+#endif
+#ifdef DPMSExtension
+ {
+ DPMSExtensionInit,
+ DPMSExtensionName,
+ &noDPMSExtension,
+ NULL,
+ NULL},
+#endif
+#ifdef XV
+ {
+ XvExtensionInit,
+ XvName,
+ &noXvExtension,
+ XvRegister,
+ NULL},
+ {
+ XvMCExtensionInit,
+ XvMCName,
+ &noXvExtension,
+ NULL,
+ NULL},
+#endif
+#ifdef RES
+ {
+ ResExtensionInit,
+ XRES_NAME,
+ &noResExtension,
+ NULL,
+ NULL},
+#endif
+ { /* DON'T delete this entry ! */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL}
+};
+
+static XF86ModuleVersionInfo VersRec = {
+ "extmod",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_EXTENSION,
+ ABI_EXTENSION_VERSION,
+ MOD_CLASS_EXTENSION,
+ {0, 0, 0, 0}
+};
+
+/*
+ * Data for the loader
+ */
+_X_EXPORT XF86ModuleData extmodModuleData = { &VersRec, extmodSetup, NULL };
+
+static pointer
+extmodSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ int i;
+
+ /* XXX the option stuff here is largely a sample/test case */
+
+ for (i = 0; extensionModules[i].name != NULL; i++) {
+ if (opts) {
+ char *s;
+
+ if (asprintf(&s, "omit%s", extensionModules[i].name) != -1) {
+ pointer o;
+
+ o = xf86FindOption(opts, s);
+ free(s);
+ if (o) {
+ xf86MarkOptionUsed(o);
+ continue;
+ }
+ }
+ }
+
+#ifdef XSELINUX
+ if (!strcmp(SELINUX_EXTENSION_NAME, extensionModules[i].name)) {
+ pointer o;
+
+ selinuxEnforcingState = SELINUX_MODE_DEFAULT;
+
+ if ((o = xf86FindOption(opts, "SELinux mode disabled"))) {
+ xf86MarkOptionUsed(o);
+ selinuxEnforcingState = SELINUX_MODE_DISABLED;
+ }
+ if ((o = xf86FindOption(opts, "SELinux mode permissive"))) {
+ xf86MarkOptionUsed(o);
+ selinuxEnforcingState = SELINUX_MODE_PERMISSIVE;
+ }
+ if ((o = xf86FindOption(opts, "SELinux mode enforcing"))) {
+ xf86MarkOptionUsed(o);
+ selinuxEnforcingState = SELINUX_MODE_ENFORCING;
+ }
+ }
+#endif
+
+ LoadExtension(&extensionModules[i], FALSE);
+ }
+ /* Need a non-NULL return */
+ return (pointer) 1;
+}
diff --git a/xorg-server/hw/xfree86/dixmods/extmod/modinit.h b/xorg-server/hw/xfree86/dixmods/extmod/modinit.h
index 9753e6f14..9753fe0fd 100644
--- a/xorg-server/hw/xfree86/dixmods/extmod/modinit.h
+++ b/xorg-server/hw/xfree86/dixmods/extmod/modinit.h
@@ -1,86 +1,93 @@
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifndef INITARGS
-#define INITARGS void
-#endif
-
-#include <X11/extensions/shapeproto.h>
-
-#ifdef XTEST
-extern void XTestExtensionInit(INITARGS);
-#include <X11/extensions/xtestproto.h>
-#endif
-
-#if 1
-extern void XTestExtension1Init(INITARGS);
-#endif
-
-#if 1
-extern void XCMiscExtensionInit(INITARGS);
-#endif
-
-#ifdef SCREENSAVER
-extern void ScreenSaverExtensionInit (INITARGS);
-#include <X11/extensions/saver.h>
-#endif
-
-#ifdef XF86VIDMODE
-extern void XFree86VidModeExtensionInit(INITARGS);
-#include <X11/extensions/xf86vmproto.h>
-#endif
-
-#ifdef XFreeXDGA
-extern void XFree86DGAExtensionInit(INITARGS);
-extern void XFree86DGARegister(INITARGS);
-#include <X11/extensions/xf86dgaproto.h>
-#endif
-
-#ifdef DPMSExtension
-extern void DPMSExtensionInit(INITARGS);
-#include <X11/extensions/dpmsconst.h>
-#endif
-
-#ifdef XV
-extern void XvExtensionInit(INITARGS);
-extern void XvMCExtensionInit(INITARGS);
-extern void XvRegister(INITARGS);
-#include <X11/extensions/Xv.h>
-#include <X11/extensions/XvMC.h>
-#endif
-
-#ifdef RES
-extern void ResExtensionInit(INITARGS);
-#include <X11/extensions/XResproto.h>
-#endif
-
-#ifdef SHM
-extern void ShmExtensionInit(INITARGS);
-#include <X11/extensions/shmproto.h>
-extern void ShmRegisterFuncs(
- ScreenPtr pScreen,
- ShmFuncsPtr funcs);
-#endif
-
-#ifdef XSELINUX
-extern void SELinuxExtensionInit(INITARGS);
-#include "xselinux.h"
-#endif
-
-#ifdef XEVIE
-extern void XevieExtensionInit(INITARGS);
-#endif
-
-#if 1
-extern void SecurityExtensionInit(INITARGS);
-#endif
-
-#if 1
-extern void PanoramiXExtensionInit(int argc, char *argv[]);
-#endif
-
-#if 1
-extern void XkbExtensionInit(INITARGS);
-#endif
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef INITARGS
+#define INITARGS void
+#endif
+
+#include <X11/extensions/shapeproto.h>
+
+#ifdef XTEST
+extern void XTestExtensionInit(INITARGS);
+
+#include <X11/extensions/xtestproto.h>
+#endif
+
+#if 1
+extern void XTestExtension1Init(INITARGS);
+#endif
+
+#if 1
+extern void XCMiscExtensionInit(INITARGS);
+#endif
+
+#ifdef SCREENSAVER
+extern void ScreenSaverExtensionInit(INITARGS);
+
+#include <X11/extensions/saver.h>
+#endif
+
+#ifdef XF86VIDMODE
+extern void XFree86VidModeExtensionInit(INITARGS);
+
+#include <X11/extensions/xf86vmproto.h>
+#endif
+
+#ifdef XFreeXDGA
+extern void XFree86DGAExtensionInit(INITARGS);
+extern void XFree86DGARegister(INITARGS);
+
+#include <X11/extensions/xf86dgaproto.h>
+#endif
+
+#ifdef DPMSExtension
+extern void DPMSExtensionInit(INITARGS);
+
+#include <X11/extensions/dpmsconst.h>
+#endif
+
+#ifdef XV
+extern void XvExtensionInit(INITARGS);
+extern void XvMCExtensionInit(INITARGS);
+extern void XvRegister(INITARGS);
+
+#include <X11/extensions/Xv.h>
+#include <X11/extensions/XvMC.h>
+#endif
+
+#ifdef RES
+extern void ResExtensionInit(INITARGS);
+
+#include <X11/extensions/XResproto.h>
+#endif
+
+#ifdef SHM
+extern void ShmExtensionInit(INITARGS);
+
+#include <X11/extensions/shmproto.h>
+extern void ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs);
+#endif
+
+#ifdef XSELINUX
+extern void SELinuxExtensionInit(INITARGS);
+
+#include "xselinux.h"
+#endif
+
+#ifdef XEVIE
+extern void XevieExtensionInit(INITARGS);
+#endif
+
+#if 1
+extern void SecurityExtensionInit(INITARGS);
+#endif
+
+#if 1
+extern void PanoramiXExtensionInit(int argc, char *argv[]);
+#endif
+
+#if 1
+extern void XkbExtensionInit(INITARGS);
+#endif
diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c b/xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c
index 4bcf77efd..6b33941ef 100644
--- a/xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c
+++ b/xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c
@@ -6,7 +6,6 @@
* Written by Mark Vojkovich
*/
-
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
@@ -33,26 +32,27 @@
#define DGA_PROTOCOL_OLD_SUPPORT 1
+static void XDGAResetProc(ExtensionEntry * extEntry);
-static void XDGAResetProc(ExtensionEntry *extEntry);
-
-static void DGAClientStateChange (CallbackListPtr*, pointer, pointer);
+static void DGAClientStateChange(CallbackListPtr *, pointer, pointer);
unsigned char DGAReqCode = 0;
int DGAErrorBase;
int DGAEventBase;
static DevPrivateKeyRec DGAScreenPrivateKeyRec;
+
#define DGAScreenPrivateKey (&DGAScreenPrivateKeyRec)
#define DGAScreenPrivateKeyRegistered (DGAScreenPrivateKeyRec.initialized)
static DevPrivateKeyRec DGAClientPrivateKeyRec;
+
#define DGAClientPrivateKey (&DGAClientPrivateKeyRec)
static int DGACallbackRefCount = 0;
/* This holds the client's version information */
typedef struct {
- int major;
- int minor;
+ int major;
+ int minor;
} DGAPrivRec, *DGAPrivPtr;
#define DGA_GETCLIENT(idx) ((ClientPtr) \
@@ -65,15 +65,13 @@ typedef struct {
#define DGA_SETPRIV(c,p) \
dixSetPrivate(&(c)->devPrivates, DGAClientPrivateKey, p)
-
static void
-XDGAResetProc (ExtensionEntry *extEntry)
+XDGAResetProc(ExtensionEntry * extEntry)
{
- DeleteCallback (&ClientStateCallback, DGAClientStateChange, NULL);
- DGACallbackRefCount = 0;
+ DeleteCallback(&ClientStateCallback, DGAClientStateChange, NULL);
+ DGACallbackRefCount = 0;
}
-
static int
ProcXDGAQueryVersion(ClientPtr client)
{
@@ -86,11 +84,10 @@ ProcXDGAQueryVersion(ClientPtr client)
rep.majorVersion = SERVER_XDGA_MAJOR_VERSION;
rep.minorVersion = SERVER_XDGA_MINOR_VERSION;
- WriteToClient(client, sizeof(xXDGAQueryVersionReply), (char *)&rep);
+ WriteToClient(client, sizeof(xXDGAQueryVersionReply), (char *) &rep);
return Success;
}
-
static int
ProcXDGAOpenFramebuffer(ClientPtr client)
{
@@ -110,24 +107,23 @@ ProcXDGAOpenFramebuffer(ClientPtr client)
rep.length = 0;
rep.sequenceNumber = client->sequence;
- if(!DGAOpenFramebuffer(stuff->screen, &deviceName,
- (unsigned char**)(&rep.mem1),
- (int*)&rep.size, (int*)&rep.offset, (int*)&rep.extra))
- {
- return BadAlloc;
+ if (!DGAOpenFramebuffer(stuff->screen, &deviceName,
+ (unsigned char **) (&rep.mem1),
+ (int *) &rep.size, (int *) &rep.offset,
+ (int *) &rep.extra)) {
+ return BadAlloc;
}
nameSize = deviceName ? (strlen(deviceName) + 1) : 0;
rep.length = bytes_to_int32(nameSize);
- WriteToClient(client, sizeof(xXDGAOpenFramebufferReply), (char *)&rep);
- if(rep.length)
- WriteToClient(client, nameSize, deviceName);
+ WriteToClient(client, sizeof(xXDGAOpenFramebufferReply), (char *) &rep);
+ if (rep.length)
+ WriteToClient(client, nameSize, deviceName);
return Success;
}
-
static int
ProcXDGACloseFramebuffer(ClientPtr client)
{
@@ -150,6 +146,7 @@ static int
ProcXDGAQueryModes(ClientPtr client)
{
int i, num, size;
+
REQUEST(xXDGAQueryModesReq);
xXDGAQueryModesReply rep;
xXDGAModeInfo info;
@@ -165,64 +162,64 @@ ProcXDGAQueryModes(ClientPtr client)
rep.sequenceNumber = client->sequence;
if (!DGAAvailable(stuff->screen)) {
- rep.number = 0;
- rep.length = 0;
- WriteToClient(client, sz_xXDGAQueryModesReply, (char*)&rep);
- return Success;
+ rep.number = 0;
+ rep.length = 0;
+ WriteToClient(client, sz_xXDGAQueryModesReply, (char *) &rep);
+ return Success;
}
- if(!(num = DGAGetModes(stuff->screen))) {
- WriteToClient(client, sz_xXDGAQueryModesReply, (char*)&rep);
- return Success;
+ if (!(num = DGAGetModes(stuff->screen))) {
+ WriteToClient(client, sz_xXDGAQueryModesReply, (char *) &rep);
+ return Success;
}
- if(!(mode = (XDGAModePtr)malloc(num * sizeof(XDGAModeRec))))
- return BadAlloc;
+ if (!(mode = (XDGAModePtr) malloc(num * sizeof(XDGAModeRec))))
+ return BadAlloc;
- for(i = 0; i < num; i++)
- DGAGetModeInfo(stuff->screen, mode + i, i + 1);
+ for (i = 0; i < num; i++)
+ DGAGetModeInfo(stuff->screen, mode + i, i + 1);
size = num * sz_xXDGAModeInfo;
- for(i = 0; i < num; i++)
- size += pad_to_int32(strlen(mode[i].name) + 1); /* plus NULL */
+ for (i = 0; i < num; i++)
+ size += pad_to_int32(strlen(mode[i].name) + 1); /* plus NULL */
rep.number = num;
rep.length = bytes_to_int32(size);
- WriteToClient(client, sz_xXDGAQueryModesReply, (char*)&rep);
-
- for(i = 0; i < num; i++) {
- size = strlen(mode[i].name) + 1;
-
- info.byte_order = mode[i].byteOrder;
- info.depth = mode[i].depth;
- info.num = mode[i].num;
- info.bpp = mode[i].bitsPerPixel;
- info.name_size = (size + 3) & ~3L;
- info.vsync_num = mode[i].VSync_num;
- info.vsync_den = mode[i].VSync_den;
- info.flags = mode[i].flags;
- info.image_width = mode[i].imageWidth;
- info.image_height = mode[i].imageHeight;
- info.pixmap_width = mode[i].pixmapWidth;
- info.pixmap_height = mode[i].pixmapHeight;
- info.bytes_per_scanline = mode[i].bytesPerScanline;
- info.red_mask = mode[i].red_mask;
- info.green_mask = mode[i].green_mask;
- info.blue_mask = mode[i].blue_mask;
- info.visual_class = mode[i].visualClass;
- info.viewport_width = mode[i].viewportWidth;
- info.viewport_height = mode[i].viewportHeight;
- info.viewport_xstep = mode[i].xViewportStep;
- info.viewport_ystep = mode[i].yViewportStep;
- info.viewport_xmax = mode[i].maxViewportX;
- info.viewport_ymax = mode[i].maxViewportY;
- info.viewport_flags = mode[i].viewportFlags;
- info.reserved1 = mode[i].reserved1;
- info.reserved2 = mode[i].reserved2;
-
- WriteToClient(client, sz_xXDGAModeInfo, (char*)(&info));
- WriteToClient(client, size, mode[i].name);
+ WriteToClient(client, sz_xXDGAQueryModesReply, (char *) &rep);
+
+ for (i = 0; i < num; i++) {
+ size = strlen(mode[i].name) + 1;
+
+ info.byte_order = mode[i].byteOrder;
+ info.depth = mode[i].depth;
+ info.num = mode[i].num;
+ info.bpp = mode[i].bitsPerPixel;
+ info.name_size = (size + 3) & ~3L;
+ info.vsync_num = mode[i].VSync_num;
+ info.vsync_den = mode[i].VSync_den;
+ info.flags = mode[i].flags;
+ info.image_width = mode[i].imageWidth;
+ info.image_height = mode[i].imageHeight;
+ info.pixmap_width = mode[i].pixmapWidth;
+ info.pixmap_height = mode[i].pixmapHeight;
+ info.bytes_per_scanline = mode[i].bytesPerScanline;
+ info.red_mask = mode[i].red_mask;
+ info.green_mask = mode[i].green_mask;
+ info.blue_mask = mode[i].blue_mask;
+ info.visual_class = mode[i].visualClass;
+ info.viewport_width = mode[i].viewportWidth;
+ info.viewport_height = mode[i].viewportHeight;
+ info.viewport_xstep = mode[i].xViewportStep;
+ info.viewport_ystep = mode[i].yViewportStep;
+ info.viewport_xmax = mode[i].maxViewportX;
+ info.viewport_ymax = mode[i].maxViewportY;
+ info.viewport_flags = mode[i].viewportFlags;
+ info.reserved1 = mode[i].reserved1;
+ info.reserved2 = mode[i].reserved2;
+
+ WriteToClient(client, sz_xXDGAModeInfo, (char *) (&info));
+ WriteToClient(client, size, mode[i].name);
}
free(mode);
@@ -230,36 +227,32 @@ ProcXDGAQueryModes(ClientPtr client)
return Success;
}
-
static void
-DGAClientStateChange (
- CallbackListPtr* pcbl,
- pointer nulldata,
- pointer calldata
-){
- NewClientInfoRec* pci = (NewClientInfoRec*) calldata;
+DGAClientStateChange(CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
+{
+ NewClientInfoRec *pci = (NewClientInfoRec *) calldata;
ClientPtr client = NULL;
int i;
- for(i = 0; i < screenInfo.numScreens; i++) {
- if(DGA_GETCLIENT(i) == pci->client) {
- client = pci->client;
- break;
- }
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ if (DGA_GETCLIENT(i) == pci->client) {
+ client = pci->client;
+ break;
+ }
}
- if(client &&
- ((client->clientState == ClientStateGone) ||
- (client->clientState == ClientStateRetained))) {
- XDGAModeRec mode;
- PixmapPtr pPix;
+ if (client &&
+ ((client->clientState == ClientStateGone) ||
+ (client->clientState == ClientStateRetained))) {
+ XDGAModeRec mode;
+ PixmapPtr pPix;
- DGA_SETCLIENT(i, NULL);
- DGASelectInput(i, NULL, 0);
- DGASetMode(i, 0, &mode, &pPix);
+ DGA_SETCLIENT(i, NULL);
+ DGASelectInput(i, NULL, 0);
+ DGASetMode(i, 0, &mode, &pPix);
- if(--DGACallbackRefCount == 0)
- DeleteCallback(&ClientStateCallback, DGAClientStateChange, NULL);
+ if (--DGACallbackRefCount == 0)
+ DeleteCallback(&ClientStateCallback, DGAClientStateChange, NULL);
}
}
@@ -288,36 +281,37 @@ ProcXDGASetMode(ClientPtr client)
if (!DGAAvailable(stuff->screen))
return DGAErrorBase + XF86DGANoDirectVideoMode;
- if(owner && owner != client)
+ if (owner && owner != client)
return DGAErrorBase + XF86DGANoDirectVideoMode;
- if(!stuff->mode) {
- if(owner) {
- if(--DGACallbackRefCount == 0)
- DeleteCallback(&ClientStateCallback, DGAClientStateChange, NULL);
- }
- DGA_SETCLIENT(stuff->screen, NULL);
- DGASelectInput(stuff->screen, NULL, 0);
- DGASetMode(stuff->screen, 0, &mode, &pPix);
- WriteToClient(client, sz_xXDGASetModeReply, (char*)&rep);
- return Success;
+ if (!stuff->mode) {
+ if (owner) {
+ if (--DGACallbackRefCount == 0)
+ DeleteCallback(&ClientStateCallback, DGAClientStateChange,
+ NULL);
+ }
+ DGA_SETCLIENT(stuff->screen, NULL);
+ DGASelectInput(stuff->screen, NULL, 0);
+ DGASetMode(stuff->screen, 0, &mode, &pPix);
+ WriteToClient(client, sz_xXDGASetModeReply, (char *) &rep);
+ return Success;
}
- if(Success != DGASetMode(stuff->screen, stuff->mode, &mode, &pPix))
- return BadValue;
+ if (Success != DGASetMode(stuff->screen, stuff->mode, &mode, &pPix))
+ return BadValue;
- if(!owner) {
- if(DGACallbackRefCount++ == 0)
- AddCallback (&ClientStateCallback, DGAClientStateChange, NULL);
+ if (!owner) {
+ if (DGACallbackRefCount++ == 0)
+ AddCallback(&ClientStateCallback, DGAClientStateChange, NULL);
}
DGA_SETCLIENT(stuff->screen, client);
- if(pPix) {
- if(AddResource(stuff->pid, RT_PIXMAP, (pointer)(pPix))) {
- pPix->drawable.id = (int)stuff->pid;
- rep.flags = DGA_PIXMAP_AVAILABLE;
- }
+ if (pPix) {
+ if (AddResource(stuff->pid, RT_PIXMAP, (pointer) (pPix))) {
+ pPix->drawable.id = (int) stuff->pid;
+ rep.flags = DGA_PIXMAP_AVAILABLE;
+ }
}
size = strlen(mode.name) + 1;
@@ -351,8 +345,8 @@ ProcXDGASetMode(ClientPtr client)
rep.length = bytes_to_int32(sz_xXDGAModeInfo + info.name_size);
- WriteToClient(client, sz_xXDGASetModeReply, (char*)&rep);
- WriteToClient(client, sz_xXDGAModeInfo, (char*)(&info));
+ WriteToClient(client, sz_xXDGASetModeReply, (char *) &rep);
+ WriteToClient(client, sz_xXDGAModeInfo, (char *) (&info));
WriteToClient(client, size, mode.name);
return Success;
@@ -366,7 +360,7 @@ ProcXDGASetViewport(ClientPtr client)
if (stuff->screen >= screenInfo.numScreens)
return BadValue;
- if(DGA_GETCLIENT(stuff->screen) != client)
+ if (DGA_GETCLIENT(stuff->screen) != client)
return DGAErrorBase + XF86DGADirectNotActivated;
REQUEST_SIZE_MATCH(xXDGASetViewportReq);
@@ -381,25 +375,25 @@ ProcXDGAInstallColormap(ClientPtr client)
{
ColormapPtr cmap;
int rc;
+
REQUEST(xXDGAInstallColormapReq);
if (stuff->screen >= screenInfo.numScreens)
return BadValue;
- if(DGA_GETCLIENT(stuff->screen) != client)
+ if (DGA_GETCLIENT(stuff->screen) != client)
return DGAErrorBase + XF86DGADirectNotActivated;
REQUEST_SIZE_MATCH(xXDGAInstallColormapReq);
- rc = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, RT_COLORMAP,
- client, DixInstallAccess);
+ rc = dixLookupResourceByType((pointer *) &cmap, stuff->cmap, RT_COLORMAP,
+ client, DixInstallAccess);
if (rc != Success)
return rc;
DGAInstallCmap(cmap);
return Success;
}
-
static int
ProcXDGASelectInput(ClientPtr client)
{
@@ -408,18 +402,17 @@ ProcXDGASelectInput(ClientPtr client)
if (stuff->screen >= screenInfo.numScreens)
return BadValue;
- if(DGA_GETCLIENT(stuff->screen) != client)
+ if (DGA_GETCLIENT(stuff->screen) != client)
return DGAErrorBase + XF86DGADirectNotActivated;
REQUEST_SIZE_MATCH(xXDGASelectInputReq);
- if(DGA_GETCLIENT(stuff->screen) == client)
- DGASelectInput(stuff->screen, client, stuff->mask);
+ if (DGA_GETCLIENT(stuff->screen) == client)
+ DGASelectInput(stuff->screen, client, stuff->mask);
return Success;
}
-
static int
ProcXDGAFillRectangle(ClientPtr client)
{
@@ -428,14 +421,14 @@ ProcXDGAFillRectangle(ClientPtr client)
if (stuff->screen >= screenInfo.numScreens)
return BadValue;
- if(DGA_GETCLIENT(stuff->screen) != client)
+ if (DGA_GETCLIENT(stuff->screen) != client)
return DGAErrorBase + XF86DGADirectNotActivated;
REQUEST_SIZE_MATCH(xXDGAFillRectangleReq);
- if(Success != DGAFillRect(stuff->screen, stuff->x, stuff->y,
- stuff->width, stuff->height, stuff->color))
- return BadMatch;
+ if (Success != DGAFillRect(stuff->screen, stuff->x, stuff->y,
+ stuff->width, stuff->height, stuff->color))
+ return BadMatch;
return Success;
}
@@ -448,19 +441,19 @@ ProcXDGACopyArea(ClientPtr client)
if (stuff->screen >= screenInfo.numScreens)
return BadValue;
- if(DGA_GETCLIENT(stuff->screen) != client)
+ if (DGA_GETCLIENT(stuff->screen) != client)
return DGAErrorBase + XF86DGADirectNotActivated;
REQUEST_SIZE_MATCH(xXDGACopyAreaReq);
- if(Success != DGABlitRect(stuff->screen, stuff->srcx, stuff->srcy,
- stuff->width, stuff->height, stuff->dstx, stuff->dsty))
- return BadMatch;
+ if (Success != DGABlitRect(stuff->screen, stuff->srcx, stuff->srcy,
+ stuff->width, stuff->height, stuff->dstx,
+ stuff->dsty))
+ return BadMatch;
return Success;
}
-
static int
ProcXDGACopyTransparentArea(ClientPtr client)
{
@@ -469,19 +462,19 @@ ProcXDGACopyTransparentArea(ClientPtr client)
if (stuff->screen >= screenInfo.numScreens)
return BadValue;
- if(DGA_GETCLIENT(stuff->screen) != client)
+ if (DGA_GETCLIENT(stuff->screen) != client)
return DGAErrorBase + XF86DGADirectNotActivated;
REQUEST_SIZE_MATCH(xXDGACopyTransparentAreaReq);
- if(Success != DGABlitTransRect(stuff->screen, stuff->srcx, stuff->srcy,
- stuff->width, stuff->height, stuff->dstx, stuff->dsty, stuff->key))
- return BadMatch;
+ if (Success != DGABlitTransRect(stuff->screen, stuff->srcx, stuff->srcy,
+ stuff->width, stuff->height, stuff->dstx,
+ stuff->dsty, stuff->key))
+ return BadMatch;
return Success;
}
-
static int
ProcXDGAGetViewportStatus(ClientPtr client)
{
@@ -491,7 +484,7 @@ ProcXDGAGetViewportStatus(ClientPtr client)
if (stuff->screen >= screenInfo.numScreens)
return BadValue;
- if(DGA_GETCLIENT(stuff->screen) != client)
+ if (DGA_GETCLIENT(stuff->screen) != client)
return DGAErrorBase + XF86DGADirectNotActivated;
REQUEST_SIZE_MATCH(xXDGAGetViewportStatusReq);
@@ -501,7 +494,7 @@ ProcXDGAGetViewportStatus(ClientPtr client)
rep.status = DGAGetViewportStatus(stuff->screen);
- WriteToClient(client, sizeof(xXDGAGetViewportStatusReply), (char *)&rep);
+ WriteToClient(client, sizeof(xXDGAGetViewportStatusReply), (char *) &rep);
return Success;
}
@@ -514,7 +507,7 @@ ProcXDGASync(ClientPtr client)
if (stuff->screen >= screenInfo.numScreens)
return BadValue;
- if(DGA_GETCLIENT(stuff->screen) != client)
+ if (DGA_GETCLIENT(stuff->screen) != client)
return DGAErrorBase + XF86DGADirectNotActivated;
REQUEST_SIZE_MATCH(xXDGASyncReq);
@@ -524,7 +517,7 @@ ProcXDGASync(ClientPtr client)
DGASync(stuff->screen);
- WriteToClient(client, sizeof(xXDGASyncReply), (char *)&rep);
+ WriteToClient(client, sizeof(xXDGASyncReply), (char *) &rep);
return Success;
}
@@ -537,11 +530,11 @@ ProcXDGASetClientVersion(ClientPtr client)
REQUEST_SIZE_MATCH(xXDGASetClientVersionReq);
if ((pPriv = DGA_GETPRIV(client)) == NULL) {
- pPriv = malloc(sizeof(DGAPrivRec));
- /* XXX Need to look into freeing this */
- if (!pPriv)
- return BadAlloc;
- DGA_SETPRIV(client, pPriv);
+ pPriv = malloc(sizeof(DGAPrivRec));
+ /* XXX Need to look into freeing this */
+ if (!pPriv)
+ return BadAlloc;
+ DGA_SETPRIV(client, pPriv);
}
pPriv->major = stuff->major;
pPriv->minor = stuff->minor;
@@ -559,7 +552,7 @@ ProcXDGAChangePixmapMode(ClientPtr client)
if (stuff->screen >= screenInfo.numScreens)
return BadValue;
- if(DGA_GETCLIENT(stuff->screen) != client)
+ if (DGA_GETCLIENT(stuff->screen) != client)
return DGAErrorBase + XF86DGADirectNotActivated;
REQUEST_SIZE_MATCH(xXDGAChangePixmapModeReq);
@@ -570,17 +563,16 @@ ProcXDGAChangePixmapMode(ClientPtr client)
x = stuff->x;
y = stuff->y;
- if(!DGAChangePixmapMode(stuff->screen, &x, &y, stuff->flags))
- return BadMatch;
+ if (!DGAChangePixmapMode(stuff->screen, &x, &y, stuff->flags))
+ return BadMatch;
rep.x = x;
rep.y = y;
- WriteToClient(client, sizeof(xXDGAChangePixmapModeReply), (char *)&rep);
+ WriteToClient(client, sizeof(xXDGAChangePixmapModeReply), (char *) &rep);
return Success;
}
-
static int
ProcXDGACreateColormap(ClientPtr client)
{
@@ -590,18 +582,18 @@ ProcXDGACreateColormap(ClientPtr client)
if (stuff->screen >= screenInfo.numScreens)
return BadValue;
- if(DGA_GETCLIENT(stuff->screen) != client)
+ if (DGA_GETCLIENT(stuff->screen) != client)
return DGAErrorBase + XF86DGADirectNotActivated;
REQUEST_SIZE_MATCH(xXDGACreateColormapReq);
- if(!stuff->mode)
- return BadValue;
+ if (!stuff->mode)
+ return BadValue;
result = DGACreateColormap(stuff->screen, client, stuff->id,
- stuff->mode, stuff->alloc);
- if(result != Success)
- return result;
+ stuff->mode, stuff->alloc);
+ if (result != Success)
+ return result;
return Success;
}
@@ -614,8 +606,6 @@ ProcXDGACreateColormap(ClientPtr client)
#ifdef DGA_PROTOCOL_OLD_SUPPORT
-
-
static int
ProcXF86DGAGetVideoLL(ClientPtr client)
{
@@ -626,32 +616,32 @@ ProcXF86DGAGetVideoLL(ClientPtr client)
char *name;
if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
+ return BadValue;
REQUEST_SIZE_MATCH(xXF86DGAGetVideoLLReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
- if(!DGAAvailable(stuff->screen))
- return DGAErrorBase + XF86DGANoDirectVideoMode;
+ if (!DGAAvailable(stuff->screen))
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
- if(!(num = DGAGetOldDGAMode(stuff->screen)))
- return DGAErrorBase + XF86DGANoDirectVideoMode;
+ if (!(num = DGAGetOldDGAMode(stuff->screen)))
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
/* get the parameters for the mode that best matches */
DGAGetModeInfo(stuff->screen, &mode, num);
- if(!DGAOpenFramebuffer(stuff->screen, &name,
- (unsigned char**)(&rep.offset),
- (int*)(&rep.bank_size), &offset, &flags))
- return BadAlloc;
+ if (!DGAOpenFramebuffer(stuff->screen, &name,
+ (unsigned char **) (&rep.offset),
+ (int *) (&rep.bank_size), &offset, &flags))
+ return BadAlloc;
rep.offset += mode.offset;
rep.width = mode.bytesPerScanline / (mode.bitsPerPixel >> 3);
rep.ram_size = rep.bank_size >> 10;
- WriteToClient(client, SIZEOF(xXF86DGAGetVideoLLReply), (char *)&rep);
+ WriteToClient(client, SIZEOF(xXF86DGAGetVideoLLReply), (char *) &rep);
return Success;
}
@@ -662,14 +652,15 @@ ProcXF86DGADirectVideo(ClientPtr client)
PixmapPtr pix;
XDGAModeRec mode;
ClientPtr owner;
+
REQUEST(xXF86DGADirectVideoReq);
if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
+ return BadValue;
REQUEST_SIZE_MATCH(xXF86DGADirectVideoReq);
if (!DGAAvailable(stuff->screen))
- return DGAErrorBase + XF86DGANoDirectVideoMode;
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
owner = DGA_GETCLIENT(stuff->screen);
@@ -677,34 +668,37 @@ ProcXF86DGADirectVideo(ClientPtr client)
return DGAErrorBase + XF86DGANoDirectVideoMode;
if (stuff->enable & XF86DGADirectGraphics) {
- if(!(num = DGAGetOldDGAMode(stuff->screen)))
- return DGAErrorBase + XF86DGANoDirectVideoMode;
- } else
- num = 0;
+ if (!(num = DGAGetOldDGAMode(stuff->screen)))
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
+ }
+ else
+ num = 0;
- if(Success != DGASetMode(stuff->screen, num, &mode, &pix))
- return DGAErrorBase + XF86DGAScreenNotActive;
+ if (Success != DGASetMode(stuff->screen, num, &mode, &pix))
+ return DGAErrorBase + XF86DGAScreenNotActive;
- DGASetInputMode (stuff->screen,
- (stuff->enable & XF86DGADirectKeyb) != 0,
- (stuff->enable & XF86DGADirectMouse) != 0);
+ DGASetInputMode(stuff->screen,
+ (stuff->enable & XF86DGADirectKeyb) != 0,
+ (stuff->enable & XF86DGADirectMouse) != 0);
/* We need to track the client and attach the teardown callback */
if (stuff->enable &
- (XF86DGADirectGraphics | XF86DGADirectKeyb | XF86DGADirectMouse)) {
- if (!owner) {
- if (DGACallbackRefCount++ == 0)
- AddCallback (&ClientStateCallback, DGAClientStateChange, NULL);
- }
-
- DGA_SETCLIENT(stuff->screen, client);
- } else {
- if (owner) {
- if (--DGACallbackRefCount == 0)
- DeleteCallback(&ClientStateCallback, DGAClientStateChange, NULL);
- }
-
- DGA_SETCLIENT(stuff->screen, NULL);
+ (XF86DGADirectGraphics | XF86DGADirectKeyb | XF86DGADirectMouse)) {
+ if (!owner) {
+ if (DGACallbackRefCount++ == 0)
+ AddCallback(&ClientStateCallback, DGAClientStateChange, NULL);
+ }
+
+ DGA_SETCLIENT(stuff->screen, client);
+ }
+ else {
+ if (owner) {
+ if (--DGACallbackRefCount == 0)
+ DeleteCallback(&ClientStateCallback, DGAClientStateChange,
+ NULL);
+ }
+
+ DGA_SETCLIENT(stuff->screen, NULL);
}
return Success;
@@ -715,11 +709,12 @@ ProcXF86DGAGetViewPortSize(ClientPtr client)
{
int num;
XDGAModeRec mode;
+
REQUEST(xXF86DGAGetViewPortSizeReq);
xXF86DGAGetViewPortSizeReply rep;
if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
+ return BadValue;
REQUEST_SIZE_MATCH(xXF86DGAGetViewPortSizeReq);
rep.type = X_Reply;
@@ -727,17 +722,17 @@ ProcXF86DGAGetViewPortSize(ClientPtr client)
rep.sequenceNumber = client->sequence;
if (!DGAAvailable(stuff->screen))
- return DGAErrorBase + XF86DGANoDirectVideoMode;
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
- if(!(num = DGAGetOldDGAMode(stuff->screen)))
- return DGAErrorBase + XF86DGANoDirectVideoMode;
+ if (!(num = DGAGetOldDGAMode(stuff->screen)))
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
DGAGetModeInfo(stuff->screen, &mode, num);
rep.width = mode.viewportWidth;
rep.height = mode.viewportHeight;
- WriteToClient(client, SIZEOF(xXF86DGAGetViewPortSizeReply), (char *)&rep);
+ WriteToClient(client, SIZEOF(xXF86DGAGetViewPortSizeReply), (char *) &rep);
return Success;
}
@@ -747,7 +742,7 @@ ProcXF86DGASetViewPort(ClientPtr client)
REQUEST(xXF86DGASetViewPortReq);
if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
+ return BadValue;
if (DGA_GETCLIENT(stuff->screen) != client)
return DGAErrorBase + XF86DGADirectNotActivated;
@@ -755,14 +750,14 @@ ProcXF86DGASetViewPort(ClientPtr client)
REQUEST_SIZE_MATCH(xXF86DGASetViewPortReq);
if (!DGAAvailable(stuff->screen))
- return DGAErrorBase + XF86DGANoDirectVideoMode;
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
if (!DGAActive(stuff->screen))
- return DGAErrorBase + XF86DGADirectNotActivated;
+ return DGAErrorBase + XF86DGADirectNotActivated;
if (DGASetViewport(stuff->screen, stuff->x, stuff->y, DGA_FLIP_RETRACE)
- != Success)
- return DGAErrorBase + XF86DGADirectNotActivated;
+ != Success)
+ return DGAErrorBase + XF86DGADirectNotActivated;
return Success;
}
@@ -774,26 +769,25 @@ ProcXF86DGAGetVidPage(ClientPtr client)
xXF86DGAGetVidPageReply rep;
if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
+ return BadValue;
REQUEST_SIZE_MATCH(xXF86DGAGetVidPageReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
- rep.vpage = 0; /* silently fail */
+ rep.vpage = 0; /* silently fail */
- WriteToClient(client, SIZEOF(xXF86DGAGetVidPageReply), (char *)&rep);
+ WriteToClient(client, SIZEOF(xXF86DGAGetVidPageReply), (char *) &rep);
return Success;
}
-
static int
ProcXF86DGASetVidPage(ClientPtr client)
{
REQUEST(xXF86DGASetVidPageReq);
if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
+ return BadValue;
REQUEST_SIZE_MATCH(xXF86DGASetVidPageReq);
@@ -802,16 +796,16 @@ ProcXF86DGASetVidPage(ClientPtr client)
return Success;
}
-
static int
ProcXF86DGAInstallColormap(ClientPtr client)
{
ColormapPtr pcmp;
int rc;
+
REQUEST(xXF86DGAInstallColormapReq);
if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
+ return BadValue;
if (DGA_GETCLIENT(stuff->screen) != client)
return DGAErrorBase + XF86DGADirectNotActivated;
@@ -819,14 +813,15 @@ ProcXF86DGAInstallColormap(ClientPtr client)
REQUEST_SIZE_MATCH(xXF86DGAInstallColormapReq);
if (!DGAActive(stuff->screen))
- return DGAErrorBase + XF86DGADirectNotActivated;
+ return DGAErrorBase + XF86DGADirectNotActivated;
- rc = dixLookupResourceByType((pointer *)&pcmp, stuff->id, RT_COLORMAP,
- client, DixInstallAccess);
+ rc = dixLookupResourceByType((pointer *) &pcmp, stuff->id, RT_COLORMAP,
+ client, DixInstallAccess);
if (rc == Success) {
- DGAInstallCmap(pcmp);
+ DGAInstallCmap(pcmp);
return Success;
- } else {
+ }
+ else {
return rc;
}
}
@@ -838,7 +833,7 @@ ProcXF86DGAQueryDirectVideo(ClientPtr client)
xXF86DGAQueryDirectVideoReply rep;
if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
+ return BadValue;
REQUEST_SIZE_MATCH(xXF86DGAQueryDirectVideoReq);
rep.type = X_Reply;
@@ -847,9 +842,9 @@ ProcXF86DGAQueryDirectVideo(ClientPtr client)
rep.flags = 0;
if (DGAAvailable(stuff->screen))
- rep.flags = XF86DGADirectPresent;
+ rep.flags = XF86DGADirectPresent;
- WriteToClient(client, SIZEOF(xXF86DGAQueryDirectVideoReply), (char *)&rep);
+ WriteToClient(client, SIZEOF(xXF86DGAQueryDirectVideoReply), (char *) &rep);
return Success;
}
@@ -860,7 +855,7 @@ ProcXF86DGAViewPortChanged(ClientPtr client)
xXF86DGAViewPortChangedReply rep;
if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
+ return BadValue;
if (DGA_GETCLIENT(stuff->screen) != client)
return DGAErrorBase + XF86DGADirectNotActivated;
@@ -868,23 +863,23 @@ ProcXF86DGAViewPortChanged(ClientPtr client)
REQUEST_SIZE_MATCH(xXF86DGAViewPortChangedReq);
if (!DGAActive(stuff->screen))
- return DGAErrorBase + XF86DGADirectNotActivated;
+ return DGAErrorBase + XF86DGADirectNotActivated;
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.result = 1;
- WriteToClient(client, SIZEOF(xXF86DGAViewPortChangedReply), (char *)&rep);
+ WriteToClient(client, SIZEOF(xXF86DGAViewPortChangedReply), (char *) &rep);
return Success;
}
-#endif /* DGA_PROTOCOL_OLD_SUPPORT */
+#endif /* DGA_PROTOCOL_OLD_SUPPORT */
static int
-SProcXDGADispatch (ClientPtr client)
+SProcXDGADispatch(ClientPtr client)
{
- return DGAErrorBase + XF86DGAClientNotLocal;
+ return DGAErrorBase + XF86DGAClientNotLocal;
}
#if 0
@@ -924,112 +919,111 @@ static char *dgaMinor[] = {
#endif
static int
-ProcXDGADispatch (ClientPtr client)
+ProcXDGADispatch(ClientPtr client)
{
REQUEST(xReq);
if (!LocalClient(client))
- return DGAErrorBase + XF86DGAClientNotLocal;
+ return DGAErrorBase + XF86DGAClientNotLocal;
#ifdef DGA_REQ_DEBUG
if (stuff->data <= X_XDGACreateColormap)
- fprintf (stderr, " DGA %s\n", dgaMinor[stuff->data]);
+ fprintf(stderr, " DGA %s\n", dgaMinor[stuff->data]);
#endif
- switch (stuff->data){
- /*
- * DGA2 Protocol
- */
+ switch (stuff->data) {
+ /*
+ * DGA2 Protocol
+ */
case X_XDGAQueryVersion:
- return ProcXDGAQueryVersion(client);
+ return ProcXDGAQueryVersion(client);
case X_XDGAQueryModes:
- return ProcXDGAQueryModes(client);
+ return ProcXDGAQueryModes(client);
case X_XDGASetMode:
- return ProcXDGASetMode(client);
+ return ProcXDGASetMode(client);
case X_XDGAOpenFramebuffer:
- return ProcXDGAOpenFramebuffer(client);
+ return ProcXDGAOpenFramebuffer(client);
case X_XDGACloseFramebuffer:
- return ProcXDGACloseFramebuffer(client);
+ return ProcXDGACloseFramebuffer(client);
case X_XDGASetViewport:
- return ProcXDGASetViewport(client);
+ return ProcXDGASetViewport(client);
case X_XDGAInstallColormap:
- return ProcXDGAInstallColormap(client);
+ return ProcXDGAInstallColormap(client);
case X_XDGASelectInput:
- return ProcXDGASelectInput(client);
+ return ProcXDGASelectInput(client);
case X_XDGAFillRectangle:
- return ProcXDGAFillRectangle(client);
+ return ProcXDGAFillRectangle(client);
case X_XDGACopyArea:
- return ProcXDGACopyArea(client);
+ return ProcXDGACopyArea(client);
case X_XDGACopyTransparentArea:
- return ProcXDGACopyTransparentArea(client);
+ return ProcXDGACopyTransparentArea(client);
case X_XDGAGetViewportStatus:
- return ProcXDGAGetViewportStatus(client);
+ return ProcXDGAGetViewportStatus(client);
case X_XDGASync:
- return ProcXDGASync(client);
+ return ProcXDGASync(client);
case X_XDGASetClientVersion:
- return ProcXDGASetClientVersion(client);
+ return ProcXDGASetClientVersion(client);
case X_XDGAChangePixmapMode:
- return ProcXDGAChangePixmapMode(client);
+ return ProcXDGAChangePixmapMode(client);
case X_XDGACreateColormap:
- return ProcXDGACreateColormap(client);
- /*
- * Old DGA Protocol
- */
+ return ProcXDGACreateColormap(client);
+ /*
+ * Old DGA Protocol
+ */
#ifdef DGA_PROTOCOL_OLD_SUPPORT
case X_XF86DGAGetVideoLL:
- return ProcXF86DGAGetVideoLL(client);
+ return ProcXF86DGAGetVideoLL(client);
case X_XF86DGADirectVideo:
- return ProcXF86DGADirectVideo(client);
+ return ProcXF86DGADirectVideo(client);
case X_XF86DGAGetViewPortSize:
- return ProcXF86DGAGetViewPortSize(client);
+ return ProcXF86DGAGetViewPortSize(client);
case X_XF86DGASetViewPort:
- return ProcXF86DGASetViewPort(client);
+ return ProcXF86DGASetViewPort(client);
case X_XF86DGAGetVidPage:
- return ProcXF86DGAGetVidPage(client);
+ return ProcXF86DGAGetVidPage(client);
case X_XF86DGASetVidPage:
- return ProcXF86DGASetVidPage(client);
+ return ProcXF86DGASetVidPage(client);
case X_XF86DGAInstallColormap:
- return ProcXF86DGAInstallColormap(client);
+ return ProcXF86DGAInstallColormap(client);
case X_XF86DGAQueryDirectVideo:
- return ProcXF86DGAQueryDirectVideo(client);
+ return ProcXF86DGAQueryDirectVideo(client);
case X_XF86DGAViewPortChanged:
- return ProcXF86DGAViewPortChanged(client);
-#endif /* DGA_PROTOCOL_OLD_SUPPORT */
+ return ProcXF86DGAViewPortChanged(client);
+#endif /* DGA_PROTOCOL_OLD_SUPPORT */
default:
- return BadRequest;
+ return BadRequest;
}
}
void
XFree86DGARegister(INITARGS)
{
- XDGAEventBase = &DGAEventBase;
+ XDGAEventBase = &DGAEventBase;
}
void
XFree86DGAExtensionInit(INITARGS)
{
- ExtensionEntry* extEntry;
+ ExtensionEntry *extEntry;
if (!dixRegisterPrivateKey(&DGAClientPrivateKeyRec, PRIVATE_CLIENT, 0))
- return;
+ return;
if (!dixRegisterPrivateKey(&DGAScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
- return;
+ return;
if ((extEntry = AddExtension(XF86DGANAME,
- XF86DGANumberEvents,
- XF86DGANumberErrors,
- ProcXDGADispatch,
- SProcXDGADispatch,
- XDGAResetProc,
- StandardMinorOpcode))) {
- int i;
-
- DGAReqCode = (unsigned char)extEntry->base;
- DGAErrorBase = extEntry->errorBase;
- DGAEventBase = extEntry->eventBase;
- for (i = KeyPress; i <= MotionNotify; i++)
- SetCriticalEvent (DGAEventBase + i);
+ XF86DGANumberEvents,
+ XF86DGANumberErrors,
+ ProcXDGADispatch,
+ SProcXDGADispatch,
+ XDGAResetProc, StandardMinorOpcode))) {
+ int i;
+
+ DGAReqCode = (unsigned char) extEntry->base;
+ DGAErrorBase = extEntry->errorBase;
+ DGAEventBase = extEntry->eventBase;
+ for (i = KeyPress; i <= MotionNotify; i++)
+ SetCriticalEvent(DGAEventBase + i);
}
}
diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c b/xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c
index 6d3d5fcbc..6e2a8e9b2 100644
--- a/xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c
+++ b/xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c
@@ -52,12 +52,13 @@ from Kaleb S. KEITHLEY
static int VidModeErrorBase;
static DevPrivateKeyRec VidModeClientPrivateKeyRec;
+
#define VidModeClientPrivateKey (&VidModeClientPrivateKeyRec)
/* This holds the client's version information */
typedef struct {
- int major;
- int minor;
+ int major;
+ int minor;
} VidModePrivRec, *VidModePrivPtr;
#define VM_GETPRIV(c) ((VidModePrivPtr) \
@@ -65,7 +66,6 @@ typedef struct {
#define VM_SETPRIV(c,p) \
dixSetPrivate(&(c)->devPrivates, VidModeClientPrivateKey, p)
-
#if 0
static unsigned char XF86VidModeReqCode = 0;
#endif
@@ -76,30 +76,30 @@ static unsigned char XF86VidModeReqCode = 0;
static int XF86VidModeEventBase = 0;
static void SXF86VidModeNotifyEvent();
- xXF86VidModeNotifyEvent * /* from */,
- xXF86VidModeNotifyEvent * /* to */
-);
+xXF86VidModeNotifyEvent * /* from */ , xXF86VidModeNotifyEvent * /* to */
+ );
-static RESTYPE EventType; /* resource type for event masks */
+static RESTYPE EventType; /* resource type for event masks */
typedef struct _XF86VidModeEvent *XF86VidModeEventPtr;
typedef struct _XF86VidModeEvent {
- XF86VidModeEventPtr next;
- ClientPtr client;
- ScreenPtr screen;
- XID resource;
- CARD32 mask;
+ XF86VidModeEventPtr next;
+ ClientPtr client;
+ ScreenPtr screen;
+ XID resource;
+ CARD32 mask;
} XF86VidModeEventRec;
static int XF86VidModeFreeEvents();
typedef struct _XF86VidModeScreenPrivate {
- XF86VidModeEventPtr events;
- Bool hasWindow;
+ XF86VidModeEventPtr events;
+ Bool hasWindow;
} XF86VidModeScreenPrivateRec, *XF86VidModeScreenPrivatePtr;
static DevPrivateKeyRec ScreenPrivateKeyRec;
+
#define ScreenPrivateKey (&ScreenPrivateKeyRec)
#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \
@@ -112,198 +112,181 @@ static DevPrivateKeyRec ScreenPrivateKeyRec;
#endif
#ifdef DEBUG
-# define DEBUG_P(x) ErrorF(x"\n");
+#define DEBUG_P(x) ErrorF(x"\n");
#else
-# define DEBUG_P(x) /**/
+#define DEBUG_P(x) /**/
#endif
-
-static int
-ClientMajorVersion(ClientPtr client)
-{
+ static int
+ ClientMajorVersion(ClientPtr client) {
VidModePrivPtr pPriv;
- pPriv = VM_GETPRIV(client);
+ pPriv = VM_GETPRIV(client);
if (!pPriv)
- return 0;
+ return 0;
else
- return pPriv->major;
+ return pPriv->major;
}
-
#ifdef XF86VIDMODE_EVENTS
static void
-CheckScreenPrivate (pScreen)
- ScreenPtr pScreen;
+ CheckScreenPrivate(pScreen)
+ScreenPtr
+ pScreen;
{
- SetupScreen (pScreen);
+ SetupScreen(pScreen);
if (!pPriv)
- return;
+ return;
if (!pPriv->events && !pPriv->hasWindow) {
- free(pPriv);
- SetScreenPrivate (pScreen, NULL);
+ free(pPriv);
+ SetScreenPrivate(pScreen, NULL);
}
}
-
-static XF86VidModeScreenPrivatePtr
-MakeScreenPrivate (pScreen)
- ScreenPtr pScreen;
+
+static XF86VidModeScreenPrivatePtr MakeScreenPrivate(pScreen)
+ScreenPtr
+ pScreen;
{
- SetupScreen (pScreen);
+ SetupScreen(pScreen);
if (pPriv)
- return pPriv;
- pPriv = New (XF86VidModeScreenPrivateRec);
+ return pPriv;
+ pPriv = New(XF86VidModeScreenPrivateRec);
if (!pPriv)
- return 0;
+ return 0;
pPriv->events = 0;
pPriv->hasWindow = FALSE;
- SetScreenPrivate (pScreen, pPriv);
+ SetScreenPrivate(pScreen, pPriv);
return pPriv;
}
static unsigned long
-getEventMask (ScreenPtr pScreen, ClientPtr client)
-{
+ getEventMask(ScreenPtr pScreen, ClientPtr client) {
SetupScreen(pScreen);
XF86VidModeEventPtr pEv;
if (!pPriv)
- return 0;
+ return 0;
for (pEv = pPriv->events; pEv; pEv = pEv->next)
- if (pEv->client == client)
- return pEv->mask;
- return 0;
-}
-
-static Bool
-setEventMask (ScreenPtr pScreen, ClientPtr client, unsigned long mask)
-{
+ if (pEv->client == client)
+ return pEv->mask;
+ return 0;
+} static Bool
+ setEventMask(ScreenPtr pScreen, ClientPtr client, unsigned long mask) {
SetupScreen(pScreen);
XF86VidModeEventPtr pEv, *pPrev;
- if (getEventMask (pScreen, client) == mask)
- return TRUE;
+ if (getEventMask(pScreen, client) == mask)
+ return TRUE;
if (!pPriv) {
- pPriv = MakeScreenPrivate (pScreen);
- if (!pPriv)
- return FALSE;
- }
- for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next)
- if (pEv->client == client)
- break;
+ pPriv = MakeScreenPrivate(pScreen);
+ if (!pPriv)
+ return FALSE;
+ } for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next)
+ if (pEv->client == client)
+ break;
if (mask == 0) {
- *pPrev = pEv->next;
- free(pEv);
- CheckScreenPrivate (pScreen);
- } else {
- if (!pEv) {
- pEv = New (ScreenSaverEventRec);
- if (!pEv) {
- CheckScreenPrivate (pScreen);
- return FALSE;
- }
- *pPrev = pEv;
- pEv->next = NULL;
- pEv->client = client;
- pEv->screen = pScreen;
- pEv->resource = FakeClientID (client->index);
- }
- pEv->mask = mask;
+ *pPrev = pEv->next;
+ free(pEv);
+ CheckScreenPrivate(pScreen);
+ }
+ else {
+ if (!pEv) {
+ pEv = New(ScreenSaverEventRec);
+ if (!pEv) {
+ CheckScreenPrivate(pScreen);
+ return FALSE;
+ }
+ *pPrev = pEv;
+ pEv->next = NULL;
+ pEv->client = client;
+ pEv->screen = pScreen;
+ pEv->resource = FakeClientID(client->index);
+ }
+ pEv->mask = mask;
}
return TRUE;
}
static int
-XF86VidModeFreeEvents(pointer value, XID id)
-{
- XF86VidModeEventPtr pOld = (XF86VidModeEventPtr)value;
+ XF86VidModeFreeEvents(pointer value, XID id) {
+ XF86VidModeEventPtr pOld = (XF86VidModeEventPtr) value;
ScreenPtr pScreen = pOld->screen;
- SetupScreen (pScreen);
- XF86VidModeEventPtr pEv, *pPrev;
+ SetupScreen(pScreen);
+ XF86VidModeEventPtr pEv, *pPrev;
if (!pPriv)
- return TRUE;
+ return TRUE;
for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next)
- if (pEv == pOld)
- break;
+ if (pEv == pOld)
+ break;
if (!pEv)
- return TRUE;
+ return TRUE;
*pPrev = pEv->next;
- free(pEv);
- CheckScreenPrivate (pScreen);
- return TRUE;
-}
-
-static void
-SendXF86VidModeNotify(ScreenPtr pScreen, int state, Bool forced)
-{
- XF86VidModeScreenPrivatePtr pPriv;
- XF86VidModeEventPtr pEv;
- unsigned long mask;
- xXF86VidModeNotifyEvent ev;
- int kind;
-
- UpdateCurrentTimeIf ();
- mask = XF86VidModeNotifyMask;
- pScreen = screenInfo.screens[pScreen->myNum];
- pPriv = GetScreenPrivate(pScreen);
+ free(pEv);
+ CheckScreenPrivate(pScreen);
+ return TRUE;
+} static void
+ SendXF86VidModeNotify(ScreenPtr pScreen, int state, Bool forced) {
+ XF86VidModeScreenPrivatePtr pPriv;
+ XF86VidModeEventPtr pEv;
+ unsigned long mask;
+ xXF86VidModeNotifyEvent ev;
+ int kind;
+
+ UpdateCurrentTimeIf();
+ mask = XF86VidModeNotifyMask;
+ pScreen = screenInfo.screens[pScreen->myNum];
+ pPriv = GetScreenPrivate(pScreen);
if (!pPriv)
- return;
- kind = XF86VidModeModeChange;
- for (pEv = pPriv->events; pEv; pEv = pEv->next)
- {
- if (!(pEv->mask & mask))
- continue;
- ev.type = XF86VidModeNotify + XF86VidModeEventBase;
- ev.state = state;
- ev.timestamp = currentTime.milliseconds;
- ev.root = pScreen->root->drawable.id;
- ev.kind = kind;
- ev.forced = forced;
- WriteEventsToClient (pEv->client, 1, (xEvent *) &ev);
- }
-}
-
-static void
-SXF86VidModeNotifyEvent(xXF86VidModeNotifyEvent *from,
- xXF86VidModeNotifyEvent *to)
-{
+ return;
+ kind = XF86VidModeModeChange;
+ for (pEv = pPriv->events; pEv; pEv = pEv->next) {
+ if (!(pEv->mask & mask))
+ continue;
+ ev.type = XF86VidModeNotify + XF86VidModeEventBase;
+ ev.state = state;
+ ev.timestamp = currentTime.milliseconds;
+ ev.root = pScreen->root->drawable.id;
+ ev.kind = kind;
+ ev.forced = forced;
+ WriteEventsToClient(pEv->client, 1, (xEvent *) &ev);
+}} static void
+ SXF86VidModeNotifyEvent(xXF86VidModeNotifyEvent * from,
+ xXF86VidModeNotifyEvent * to) {
to->type = from->type;
to->state = from->state;
- cpswaps (from->sequenceNumber, to->sequenceNumber);
- cpswapl (from->timestamp, to->timestamp);
- cpswapl (from->root, to->root);
+ cpswaps(from->sequenceNumber, to->sequenceNumber);
+ cpswapl(from->timestamp, to->timestamp);
+ cpswapl(from->root, to->root);
to->kind = from->kind;
to->forced = from->forced;
}
#endif
-
+
static int
-ProcXF86VidModeQueryVersion(ClientPtr client)
-{
+ ProcXF86VidModeQueryVersion(ClientPtr client) {
xXF86VidModeQueryVersionReply rep;
- DEBUG_P("XF86VidModeQueryVersion");
+ DEBUG_P("XF86VidModeQueryVersion");
- REQUEST_SIZE_MATCH(xXF86VidModeQueryVersionReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.majorVersion = SERVER_XF86VIDMODE_MAJOR_VERSION;
- rep.minorVersion = SERVER_XF86VIDMODE_MINOR_VERSION;
+ REQUEST_SIZE_MATCH(xXF86VidModeQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = SERVER_XF86VIDMODE_MAJOR_VERSION;
+ rep.minorVersion = SERVER_XF86VIDMODE_MINOR_VERSION;
if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swaps(&rep.majorVersion);
- swaps(&rep.minorVersion);
- }
- WriteToClient(client, sizeof(xXF86VidModeQueryVersionReply), (char *)&rep);
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
+ swaps(&rep.majorVersion);
+ swaps(&rep.minorVersion);
+ } WriteToClient(client, sizeof(xXF86VidModeQueryVersionReply),
+ (char *) &rep);
return Success;
}
static int
-ProcXF86VidModeGetModeLine(ClientPtr client)
-{
+ ProcXF86VidModeGetModeLine(ClientPtr client) {
REQUEST(xXF86VidModeGetModeLineReq);
xXF86VidModeGetModeLineReply rep;
xXF86OldVidModeGetModeLineReply oldrep;
@@ -311,25 +294,26 @@ ProcXF86VidModeGetModeLine(ClientPtr client)
int dotClock;
int ver;
- DEBUG_P("XF86VidModeGetModeline");
+ DEBUG_P("XF86VidModeGetModeline");
- ver = ClientMajorVersion(client);
- REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq);
- rep.type = X_Reply;
+ ver = ClientMajorVersion(client);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq);
+ rep.type = X_Reply;
if (ver < 2) {
- rep.length = bytes_to_int32(SIZEOF(xXF86OldVidModeGetModeLineReply) -
- SIZEOF(xGenericReply));
- } else {
- rep.length = bytes_to_int32(SIZEOF(xXF86VidModeGetModeLineReply) -
- SIZEOF(xGenericReply));
+ rep.length = bytes_to_int32(SIZEOF(xXF86OldVidModeGetModeLineReply) -
+ SIZEOF(xGenericReply));
+ }
+ else {
+ rep.length = bytes_to_int32(SIZEOF(xXF86VidModeGetModeLineReply) -
+ SIZEOF(xGenericReply));
}
rep.sequenceNumber = client->sequence;
- if(stuff->screen >= screenInfo.numScreens)
+ if (stuff->screen >= screenInfo.numScreens)
return BadValue;
if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
- return BadValue;
+ return BadValue;
rep.dotclock = dotClock;
rep.hdisplay = VidModeGetModeValue(mode, VIDMODE_H_DISPLAY);
@@ -344,16 +328,15 @@ ProcXF86VidModeGetModeLine(ClientPtr client)
rep.flags = VidModeGetModeValue(mode, VIDMODE_FLAGS);
if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
- ErrorF("GetModeLine - scrn: %d clock: %ld\n",
- stuff->screen, (unsigned long)rep.dotclock);
- ErrorF("GetModeLine - hdsp: %d hbeg: %d hend: %d httl: %d\n",
- rep.hdisplay, rep.hsyncstart,
- rep.hsyncend, rep.htotal);
- ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
- rep.vdisplay, rep.vsyncstart, rep.vsyncend,
- rep.vtotal, (unsigned long)rep.flags);
+ ErrorF("GetModeLine - scrn: %d clock: %ld\n",
+ stuff->screen, (unsigned long) rep.dotclock);
+ ErrorF("GetModeLine - hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ rep.hdisplay, rep.hsyncstart, rep.hsyncend, rep.htotal);
+ ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
+ rep.vdisplay, rep.vsyncstart, rep.vsyncend,
+ rep.vtotal, (unsigned long) rep.flags);
}
-
+
/*
* Older servers sometimes had server privates that the VidMode
* extention made available. So to be compatiable pretend that
@@ -362,48 +345,48 @@ ProcXF86VidModeGetModeLine(ClientPtr client)
rep.privsize = 0;
if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swapl(&rep.dotclock);
- swaps(&rep.hdisplay);
- swaps(&rep.hsyncstart);
- swaps(&rep.hsyncend);
- swaps(&rep.htotal);
- swaps(&rep.hskew);
- swaps(&rep.vdisplay);
- swaps(&rep.vsyncstart);
- swaps(&rep.vsyncend);
- swaps(&rep.vtotal);
- swapl(&rep.flags);
- swapl(&rep.privsize);
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
+ swapl(&rep.dotclock);
+ swaps(&rep.hdisplay);
+ swaps(&rep.hsyncstart);
+ swaps(&rep.hsyncend);
+ swaps(&rep.htotal);
+ swaps(&rep.hskew);
+ swaps(&rep.vdisplay);
+ swaps(&rep.vsyncstart);
+ swaps(&rep.vsyncend);
+ swaps(&rep.vtotal);
+ swapl(&rep.flags);
+ swapl(&rep.privsize);
}
if (ver < 2) {
- oldrep.type = rep.type;
- oldrep.sequenceNumber = rep.sequenceNumber;
- oldrep.length = rep.length;
- oldrep.dotclock = rep.dotclock;
- oldrep.hdisplay = rep.hdisplay;
- oldrep.hsyncstart = rep.hsyncstart;
- oldrep.hsyncend = rep.hsyncend;
- oldrep.htotal = rep.htotal;
- oldrep.vdisplay = rep.vdisplay;
- oldrep.vsyncstart = rep.vsyncstart;
- oldrep.vsyncend = rep.vsyncend;
- oldrep.vtotal = rep.vtotal;
- oldrep.flags = rep.flags;
- oldrep.privsize = rep.privsize;
- WriteToClient(client, sizeof(xXF86OldVidModeGetModeLineReply),
- (char *)&oldrep);
- } else {
- WriteToClient(client, sizeof(xXF86VidModeGetModeLineReply),
- (char *)&rep);
+ oldrep.type = rep.type;
+ oldrep.sequenceNumber = rep.sequenceNumber;
+ oldrep.length = rep.length;
+ oldrep.dotclock = rep.dotclock;
+ oldrep.hdisplay = rep.hdisplay;
+ oldrep.hsyncstart = rep.hsyncstart;
+ oldrep.hsyncend = rep.hsyncend;
+ oldrep.htotal = rep.htotal;
+ oldrep.vdisplay = rep.vdisplay;
+ oldrep.vsyncstart = rep.vsyncstart;
+ oldrep.vsyncend = rep.vsyncend;
+ oldrep.vtotal = rep.vtotal;
+ oldrep.flags = rep.flags;
+ oldrep.privsize = rep.privsize;
+ WriteToClient(client, sizeof(xXF86OldVidModeGetModeLineReply),
+ (char *) &oldrep);
+ }
+ else {
+ WriteToClient(client, sizeof(xXF86VidModeGetModeLineReply),
+ (char *) &rep);
}
return Success;
}
static int
-ProcXF86VidModeGetAllModeLines(ClientPtr client)
-{
+ ProcXF86VidModeGetAllModeLines(ClientPtr client) {
REQUEST(xXF86VidModeGetAllModeLinesReq);
xXF86VidModeGetAllModeLinesReply rep;
xXF86VidModeModeInfo mdinf;
@@ -412,85 +395,87 @@ ProcXF86VidModeGetAllModeLines(ClientPtr client)
int modecount, dotClock;
int ver;
- DEBUG_P("XF86VidModeGetAllModelines");
+ DEBUG_P("XF86VidModeGetAllModelines");
- REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq);
- if(stuff->screen >= screenInfo.numScreens)
- return BadValue;
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
- ver = ClientMajorVersion(client);
+ ver = ClientMajorVersion(client);
- modecount = VidModeGetNumOfModes(stuff->screen);
+ modecount = VidModeGetNumOfModes(stuff->screen);
if (modecount < 1)
- return VidModeErrorBase + XF86VidModeExtensionDisabled;
+ return VidModeErrorBase + XF86VidModeExtensionDisabled;
if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock))
- return BadValue;
-
- rep.type = X_Reply;
- rep.length = SIZEOF(xXF86VidModeGetAllModeLinesReply) -
- SIZEOF(xGenericReply);
+ return BadValue;
+
+ rep.type = X_Reply;
+ rep.length = SIZEOF(xXF86VidModeGetAllModeLinesReply) -
+ SIZEOF(xGenericReply);
if (ver < 2)
- rep.length += modecount * sizeof(xXF86OldVidModeModeInfo);
+ rep.length += modecount * sizeof(xXF86OldVidModeModeInfo);
else
- rep.length += modecount * sizeof(xXF86VidModeModeInfo);
- rep.length >>= 2;
- rep.sequenceNumber = client->sequence;
- rep.modecount = modecount;
+ rep.length += modecount * sizeof(xXF86VidModeModeInfo);
+ rep.length >>= 2;
+ rep.sequenceNumber = client->sequence;
+ rep.modecount = modecount;
if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swapl(&rep.modecount);
- }
- WriteToClient(client, sizeof(xXF86VidModeGetAllModeLinesReply), (char *)&rep);
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
+ swapl(&rep.modecount);
+ } WriteToClient(client, sizeof(xXF86VidModeGetAllModeLinesReply),
+ (char *) &rep);
do {
- mdinf.dotclock = dotClock;
- mdinf.hdisplay = VidModeGetModeValue(mode, VIDMODE_H_DISPLAY);
- mdinf.hsyncstart = VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART);
- mdinf.hsyncend = VidModeGetModeValue(mode, VIDMODE_H_SYNCEND);
- mdinf.htotal = VidModeGetModeValue(mode, VIDMODE_H_TOTAL);
- mdinf.hskew = VidModeGetModeValue(mode, VIDMODE_H_SKEW);
- mdinf.vdisplay = VidModeGetModeValue(mode, VIDMODE_V_DISPLAY);
- mdinf.vsyncstart = VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART);
- mdinf.vsyncend = VidModeGetModeValue(mode, VIDMODE_V_SYNCEND);
- mdinf.vtotal = VidModeGetModeValue(mode, VIDMODE_V_TOTAL);
- mdinf.flags = VidModeGetModeValue(mode, VIDMODE_FLAGS);
- mdinf.privsize = 0;
+ mdinf.dotclock = dotClock;
+ mdinf.hdisplay = VidModeGetModeValue(mode, VIDMODE_H_DISPLAY);
+ mdinf.hsyncstart = VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART);
+ mdinf.hsyncend = VidModeGetModeValue(mode, VIDMODE_H_SYNCEND);
+ mdinf.htotal = VidModeGetModeValue(mode, VIDMODE_H_TOTAL);
+ mdinf.hskew = VidModeGetModeValue(mode, VIDMODE_H_SKEW);
+ mdinf.vdisplay = VidModeGetModeValue(mode, VIDMODE_V_DISPLAY);
+ mdinf.vsyncstart = VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART);
+ mdinf.vsyncend = VidModeGetModeValue(mode, VIDMODE_V_SYNCEND);
+ mdinf.vtotal = VidModeGetModeValue(mode, VIDMODE_V_TOTAL);
+ mdinf.flags = VidModeGetModeValue(mode, VIDMODE_FLAGS);
+ mdinf.privsize = 0;
if (client->swapped) {
- swapl(&mdinf.dotclock);
- swaps(&mdinf.hdisplay);
- swaps(&mdinf.hsyncstart);
- swaps(&mdinf.hsyncend);
- swaps(&mdinf.htotal);
- swapl(&mdinf.hskew);
- swaps(&mdinf.vdisplay);
- swaps(&mdinf.vsyncstart);
- swaps(&mdinf.vsyncend);
- swaps(&mdinf.vtotal);
- swapl(&mdinf.flags);
- swapl(&mdinf.privsize);
- }
- if (ver < 2) {
- oldmdinf.dotclock = mdinf.dotclock;
- oldmdinf.hdisplay = mdinf.hdisplay;
- oldmdinf.hsyncstart = mdinf.hsyncstart;
- oldmdinf.hsyncend = mdinf.hsyncend;
- oldmdinf.htotal = mdinf.htotal;
- oldmdinf.vdisplay = mdinf.vdisplay;
- oldmdinf.vsyncstart = mdinf.vsyncstart;
- oldmdinf.vsyncend = mdinf.vsyncend;
- oldmdinf.vtotal = mdinf.vtotal;
- oldmdinf.flags = mdinf.flags;
- oldmdinf.privsize = mdinf.privsize;
+ swapl(&mdinf.dotclock);
+ swaps(&mdinf.hdisplay);
+ swaps(&mdinf.hsyncstart);
+ swaps(&mdinf.hsyncend);
+ swaps(&mdinf.htotal);
+ swapl(&mdinf.hskew);
+ swaps(&mdinf.vdisplay);
+ swaps(&mdinf.vsyncstart);
+ swaps(&mdinf.vsyncend);
+ swaps(&mdinf.vtotal);
+ swapl(&mdinf.flags);
+ swapl(&mdinf.privsize);
+ }
+ if (ver < 2) {
+ oldmdinf.dotclock = mdinf.dotclock;
+ oldmdinf.hdisplay = mdinf.hdisplay;
+ oldmdinf.hsyncstart = mdinf.hsyncstart;
+ oldmdinf.hsyncend = mdinf.hsyncend;
+ oldmdinf.htotal = mdinf.htotal;
+ oldmdinf.vdisplay = mdinf.vdisplay;
+ oldmdinf.vsyncstart = mdinf.vsyncstart;
+ oldmdinf.vsyncend = mdinf.vsyncend;
+ oldmdinf.vtotal = mdinf.vtotal;
+ oldmdinf.flags = mdinf.flags;
+ oldmdinf.privsize = mdinf.privsize;
WriteToClient(client, sizeof(xXF86OldVidModeModeInfo),
- (char *)&oldmdinf);
- } else {
- WriteToClient(client, sizeof(xXF86VidModeModeInfo), (char *)&mdinf);
- }
+ (char *) &oldmdinf);
+ }
+ else {
+ WriteToClient(client, sizeof(xXF86VidModeModeInfo),
+ (char *) &mdinf);
+ }
- } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
+ } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
return Success;
}
@@ -507,394 +492,404 @@ ProcXF86VidModeGetAllModeLines(ClientPtr client)
&& VidModeGetModeValue(mode, VIDMODE_FLAGS) == stuff->flags )
static int
-ProcXF86VidModeAddModeLine(ClientPtr client)
-{
+ ProcXF86VidModeAddModeLine(ClientPtr client) {
REQUEST(xXF86VidModeAddModeLineReq);
xXF86OldVidModeAddModeLineReq *oldstuff =
- (xXF86OldVidModeAddModeLineReq *)client->requestBuffer;
+ (xXF86OldVidModeAddModeLineReq *) client->requestBuffer;
xXF86VidModeAddModeLineReq newstuff;
pointer mode;
int len;
int dotClock;
int ver;
- DEBUG_P("XF86VidModeAddModeline");
+ DEBUG_P("XF86VidModeAddModeline");
- ver = ClientMajorVersion(client);
+ ver = ClientMajorVersion(client);
if (ver < 2) {
- /* convert from old format */
- stuff = &newstuff;
- stuff->length = oldstuff->length;
- stuff->screen = oldstuff->screen;
- stuff->dotclock = oldstuff->dotclock;
- stuff->hdisplay = oldstuff->hdisplay;
- stuff->hsyncstart = oldstuff->hsyncstart;
- stuff->hsyncend = oldstuff->hsyncend;
- stuff->htotal = oldstuff->htotal;
- stuff->hskew = 0;
- stuff->vdisplay = oldstuff->vdisplay;
- stuff->vsyncstart = oldstuff->vsyncstart;
- stuff->vsyncend = oldstuff->vsyncend;
- stuff->vtotal = oldstuff->vtotal;
- stuff->flags = oldstuff->flags;
- stuff->privsize = oldstuff->privsize;
- stuff->after_dotclock = oldstuff->after_dotclock;
- stuff->after_hdisplay = oldstuff->after_hdisplay;
- stuff->after_hsyncstart = oldstuff->after_hsyncstart;
- stuff->after_hsyncend = oldstuff->after_hsyncend;
- stuff->after_htotal = oldstuff->after_htotal;
- stuff->after_hskew = 0;
- stuff->after_vdisplay = oldstuff->after_vdisplay;
- stuff->after_vsyncstart = oldstuff->after_vsyncstart;
- stuff->after_vsyncend = oldstuff->after_vsyncend;
- stuff->after_vtotal = oldstuff->after_vtotal;
- stuff->after_flags = oldstuff->after_flags;
- }
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
- ErrorF("AddModeLine - scrn: %d clock: %ld\n",
- (int)stuff->screen, (unsigned long)stuff->dotclock);
- ErrorF("AddModeLine - hdsp: %d hbeg: %d hend: %d httl: %d\n",
- stuff->hdisplay, stuff->hsyncstart,
- stuff->hsyncend, stuff->htotal);
- ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
- stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
- stuff->vtotal, (unsigned long)stuff->flags);
- ErrorF(" after - scrn: %d clock: %ld\n",
- (int)stuff->screen, (unsigned long)stuff->after_dotclock);
- ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
- stuff->after_hdisplay, stuff->after_hsyncstart,
- stuff->after_hsyncend, stuff->after_htotal);
- ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
- stuff->after_vdisplay, stuff->after_vsyncstart,
- stuff->after_vsyncend, stuff->after_vtotal,
- (unsigned long)stuff->after_flags);
+ /* convert from old format */
+ stuff = &newstuff;
+ stuff->length = oldstuff->length;
+ stuff->screen = oldstuff->screen;
+ stuff->dotclock = oldstuff->dotclock;
+ stuff->hdisplay = oldstuff->hdisplay;
+ stuff->hsyncstart = oldstuff->hsyncstart;
+ stuff->hsyncend = oldstuff->hsyncend;
+ stuff->htotal = oldstuff->htotal;
+ stuff->hskew = 0;
+ stuff->vdisplay = oldstuff->vdisplay;
+ stuff->vsyncstart = oldstuff->vsyncstart;
+ stuff->vsyncend = oldstuff->vsyncend;
+ stuff->vtotal = oldstuff->vtotal;
+ stuff->flags = oldstuff->flags;
+ stuff->privsize = oldstuff->privsize;
+ stuff->after_dotclock = oldstuff->after_dotclock;
+ stuff->after_hdisplay = oldstuff->after_hdisplay;
+ stuff->after_hsyncstart = oldstuff->after_hsyncstart;
+ stuff->after_hsyncend = oldstuff->after_hsyncend;
+ stuff->after_htotal = oldstuff->after_htotal;
+ stuff->after_hskew = 0;
+ stuff->after_vdisplay = oldstuff->after_vdisplay;
+ stuff->after_vsyncstart = oldstuff->after_vsyncstart;
+ stuff->after_vsyncend = oldstuff->after_vsyncend;
+ stuff->after_vtotal = oldstuff->after_vtotal;
+ stuff->after_flags = oldstuff->after_flags;
+ } if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+ ErrorF("AddModeLine - scrn: %d clock: %ld\n",
+ (int) stuff->screen, (unsigned long) stuff->dotclock);
+ ErrorF("AddModeLine - hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ stuff->hdisplay, stuff->hsyncstart,
+ stuff->hsyncend, stuff->htotal);
+ ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
+ stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
+ stuff->vtotal, (unsigned long) stuff->flags);
+ ErrorF(" after - scrn: %d clock: %ld\n",
+ (int) stuff->screen, (unsigned long) stuff->after_dotclock);
+ ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ stuff->after_hdisplay, stuff->after_hsyncstart,
+ stuff->after_hsyncend, stuff->after_htotal);
+ ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
+ stuff->after_vdisplay, stuff->after_vsyncstart,
+ stuff->after_vsyncend, stuff->after_vtotal,
+ (unsigned long) stuff->after_flags);
}
if (ver < 2) {
- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq);
- len = client->req_len - bytes_to_int32(sizeof(xXF86OldVidModeAddModeLineReq));
- } else {
- REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq);
- len = client->req_len - bytes_to_int32(sizeof(xXF86VidModeAddModeLineReq));
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq);
+ len =
+ client->req_len -
+ bytes_to_int32(sizeof(xXF86OldVidModeAddModeLineReq));
+ }
+ else {
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq);
+ len =
+ client->req_len -
+ bytes_to_int32(sizeof(xXF86VidModeAddModeLineReq));
}
if (len != stuff->privsize)
- return BadLength;
+ return BadLength;
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
- if(stuff->screen >= screenInfo.numScreens)
+ if (stuff->hsyncstart < stuff->hdisplay ||
+ stuff->hsyncend < stuff->hsyncstart ||
+ stuff->htotal < stuff->hsyncend ||
+ stuff->vsyncstart < stuff->vdisplay ||
+ stuff->vsyncend < stuff->vsyncstart || stuff->vtotal < stuff->vsyncend)
return BadValue;
- if (stuff->hsyncstart < stuff->hdisplay ||
- stuff->hsyncend < stuff->hsyncstart ||
- stuff->htotal < stuff->hsyncend ||
- stuff->vsyncstart < stuff->vdisplay ||
- stuff->vsyncend < stuff->vsyncstart ||
- stuff->vtotal < stuff->vsyncend)
- return BadValue;
-
- if (stuff->after_hsyncstart < stuff->after_hdisplay ||
- stuff->after_hsyncend < stuff->after_hsyncstart ||
- stuff->after_htotal < stuff->after_hsyncend ||
- stuff->after_vsyncstart < stuff->after_vdisplay ||
- stuff->after_vsyncend < stuff->after_vsyncstart ||
- stuff->after_vtotal < stuff->after_vsyncend)
- return BadValue;
+ if (stuff->after_hsyncstart < stuff->after_hdisplay ||
+ stuff->after_hsyncend < stuff->after_hsyncstart ||
+ stuff->after_htotal < stuff->after_hsyncend ||
+ stuff->after_vsyncstart < stuff->after_vdisplay ||
+ stuff->after_vsyncend < stuff->after_vsyncstart ||
+ stuff->after_vtotal < stuff->after_vsyncend)
+ return BadValue;
if (stuff->after_htotal != 0 || stuff->after_vtotal != 0) {
- Bool found = FALSE;
- if (VidModeGetFirstModeline(stuff->screen, &mode, &dotClock)) {
- do {
- if ((VidModeGetDotClock(stuff->screen, stuff->dotclock)
- == dotClock) && MODEMATCH(mode, stuff)) {
- found = TRUE;
- break;
- }
- } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
- }
- if (!found)
- return BadValue;
+ Bool found = FALSE;
+
+ if (VidModeGetFirstModeline(stuff->screen, &mode, &dotClock)) {
+ do {
+ if ((VidModeGetDotClock(stuff->screen, stuff->dotclock)
+ == dotClock) && MODEMATCH(mode, stuff)) {
+ found = TRUE;
+ break;
+ }
+ } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
+ }
+ if (!found)
+ return BadValue;
}
-
mode = VidModeCreateMode();
if (mode == NULL)
- return BadValue;
+ return BadValue;
VidModeSetModeValue(mode, VIDMODE_CLOCK, stuff->dotclock);
VidModeSetModeValue(mode, VIDMODE_H_DISPLAY, stuff->hdisplay);
- VidModeSetModeValue(mode, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
+ VidModeSetModeValue(mode, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
VidModeSetModeValue(mode, VIDMODE_H_SYNCEND, stuff->hsyncend);
VidModeSetModeValue(mode, VIDMODE_H_TOTAL, stuff->htotal);
VidModeSetModeValue(mode, VIDMODE_H_SKEW, stuff->hskew);
VidModeSetModeValue(mode, VIDMODE_V_DISPLAY, stuff->vdisplay);
- VidModeSetModeValue(mode, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
+ VidModeSetModeValue(mode, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
VidModeSetModeValue(mode, VIDMODE_V_SYNCEND, stuff->vsyncend);
VidModeSetModeValue(mode, VIDMODE_V_TOTAL, stuff->vtotal);
VidModeSetModeValue(mode, VIDMODE_FLAGS, stuff->flags);
if (stuff->privsize)
- ErrorF("AddModeLine - Privates in request have been ignored\n");
+ ErrorF("AddModeLine - Privates in request have been ignored\n");
/* Check that the mode is consistent with the monitor specs */
switch (VidModeCheckModeForMonitor(stuff->screen, mode)) {
- case MODE_OK:
- break;
- case MODE_HSYNC:
- case MODE_H_ILLEGAL:
- free(mode);
- return VidModeErrorBase + XF86VidModeBadHTimings;
- case MODE_VSYNC:
- case MODE_V_ILLEGAL:
- free(mode);
- return VidModeErrorBase + XF86VidModeBadVTimings;
- default:
- free(mode);
- return VidModeErrorBase + XF86VidModeModeUnsuitable;
+ case MODE_OK:
+ break;
+ case MODE_HSYNC:
+ case MODE_H_ILLEGAL:
+ free(mode);
+ return VidModeErrorBase + XF86VidModeBadHTimings;
+ case MODE_VSYNC:
+ case MODE_V_ILLEGAL:
+ free(mode);
+ return VidModeErrorBase + XF86VidModeBadVTimings;
+ default:
+ free(mode);
+ return VidModeErrorBase + XF86VidModeModeUnsuitable;
}
/* Check that the driver is happy with the mode */
if (VidModeCheckModeForDriver(stuff->screen, mode) != MODE_OK) {
- free(mode);
- return VidModeErrorBase + XF86VidModeModeUnsuitable;
+ free(mode);
+ return VidModeErrorBase + XF86VidModeModeUnsuitable;
}
VidModeSetCrtcForMode(stuff->screen, mode);
-
+
VidModeAddModeline(stuff->screen, mode);
-
+
if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
- ErrorF("AddModeLine - Succeeded\n");
+ ErrorF("AddModeLine - Succeeded\n");
return Success;
}
static int
-ProcXF86VidModeDeleteModeLine(ClientPtr client)
-{
+ ProcXF86VidModeDeleteModeLine(ClientPtr client) {
REQUEST(xXF86VidModeDeleteModeLineReq);
xXF86OldVidModeDeleteModeLineReq *oldstuff =
- (xXF86OldVidModeDeleteModeLineReq *)client->requestBuffer;
+ (xXF86OldVidModeDeleteModeLineReq *) client->requestBuffer;
xXF86VidModeDeleteModeLineReq newstuff;
pointer mode;
int len, dotClock;
int ver;
- DEBUG_P("XF86VidModeDeleteModeline");
+ DEBUG_P("XF86VidModeDeleteModeline");
- ver = ClientMajorVersion(client);
+ ver = ClientMajorVersion(client);
if (ver < 2) {
- /* convert from old format */
- stuff = &newstuff;
- stuff->length = oldstuff->length;
- stuff->screen = oldstuff->screen;
- stuff->dotclock = oldstuff->dotclock;
- stuff->hdisplay = oldstuff->hdisplay;
- stuff->hsyncstart = oldstuff->hsyncstart;
- stuff->hsyncend = oldstuff->hsyncend;
- stuff->htotal = oldstuff->htotal;
- stuff->hskew = 0;
- stuff->vdisplay = oldstuff->vdisplay;
- stuff->vsyncstart = oldstuff->vsyncstart;
- stuff->vsyncend = oldstuff->vsyncend;
- stuff->vtotal = oldstuff->vtotal;
- stuff->flags = oldstuff->flags;
- stuff->privsize = oldstuff->privsize;
- }
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
- ErrorF("DeleteModeLine - scrn: %d clock: %ld\n",
- (int)stuff->screen, (unsigned long)stuff->dotclock);
- ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
- stuff->hdisplay, stuff->hsyncstart,
- stuff->hsyncend, stuff->htotal);
- ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
- stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
- stuff->vtotal, (unsigned long)stuff->flags);
+ /* convert from old format */
+ stuff = &newstuff;
+ stuff->length = oldstuff->length;
+ stuff->screen = oldstuff->screen;
+ stuff->dotclock = oldstuff->dotclock;
+ stuff->hdisplay = oldstuff->hdisplay;
+ stuff->hsyncstart = oldstuff->hsyncstart;
+ stuff->hsyncend = oldstuff->hsyncend;
+ stuff->htotal = oldstuff->htotal;
+ stuff->hskew = 0;
+ stuff->vdisplay = oldstuff->vdisplay;
+ stuff->vsyncstart = oldstuff->vsyncstart;
+ stuff->vsyncend = oldstuff->vsyncend;
+ stuff->vtotal = oldstuff->vtotal;
+ stuff->flags = oldstuff->flags;
+ stuff->privsize = oldstuff->privsize;
+ } if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+ ErrorF("DeleteModeLine - scrn: %d clock: %ld\n",
+ (int) stuff->screen, (unsigned long) stuff->dotclock);
+ ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ stuff->hdisplay, stuff->hsyncstart,
+ stuff->hsyncend, stuff->htotal);
+ ErrorF
+ (" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
+ stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, stuff->vtotal,
+ (unsigned long) stuff->flags);
}
if (ver < 2) {
- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq);
- len = client->req_len - bytes_to_int32(sizeof(xXF86OldVidModeDeleteModeLineReq));
- } else {
- REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq);
- len = client->req_len - bytes_to_int32(sizeof(xXF86VidModeDeleteModeLineReq));
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq);
+ len =
+ client->req_len -
+ bytes_to_int32(sizeof(xXF86OldVidModeDeleteModeLineReq));
+ }
+ else {
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq);
+ len =
+ client->req_len -
+ bytes_to_int32(sizeof(xXF86VidModeDeleteModeLineReq));
}
if (len != stuff->privsize) {
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
- ErrorF("req_len = %ld, sizeof(Req) = %d, privsize = %ld, "
- "len = %d, length = %d\n",
- (unsigned long)client->req_len,
- (int)sizeof(xXF86VidModeDeleteModeLineReq)>>2,
- (unsigned long)stuff->privsize, len, stuff->length);
- }
- return BadLength;
+ if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+ ErrorF("req_len = %ld, sizeof(Req) = %d, privsize = %ld, "
+ "len = %d, length = %d\n",
+ (unsigned long) client->req_len,
+ (int) sizeof(xXF86VidModeDeleteModeLineReq) >> 2,
+ (unsigned long) stuff->privsize, len, stuff->length);
+ }
+ return BadLength;
}
- if(stuff->screen >= screenInfo.numScreens)
+ if (stuff->screen >= screenInfo.numScreens)
return BadValue;
if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
- return BadValue;
+ return BadValue;
if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
- ErrorF("Checking against clock: %d (%d)\n",
- VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock);
- ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
- VidModeGetModeValue(mode, VIDMODE_H_DISPLAY),
- VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART),
- VidModeGetModeValue(mode, VIDMODE_H_SYNCEND),
- VidModeGetModeValue(mode, VIDMODE_H_TOTAL));
- ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
- VidModeGetModeValue(mode, VIDMODE_V_DISPLAY),
- VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART),
- VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
- VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
- VidModeGetModeValue(mode, VIDMODE_FLAGS));
+ ErrorF("Checking against clock: %d (%d)\n",
+ VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock);
+ ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ VidModeGetModeValue(mode, VIDMODE_H_DISPLAY),
+ VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART),
+ VidModeGetModeValue(mode, VIDMODE_H_SYNCEND),
+ VidModeGetModeValue(mode, VIDMODE_H_TOTAL));
+ ErrorF
+ (" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
+ VidModeGetModeValue(mode, VIDMODE_V_DISPLAY),
+ VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART),
+ VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
+ VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
+ VidModeGetModeValue(mode, VIDMODE_FLAGS));
}
if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) &&
- MODEMATCH(mode, stuff))
- return BadValue;
+ MODEMATCH(mode, stuff))
+ return BadValue;
if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock))
- return BadValue;
-
- do {
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
- ErrorF("Checking against clock: %d (%d)\n",
- VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock);
- ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
- VidModeGetModeValue(mode, VIDMODE_H_DISPLAY),
- VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART),
- VidModeGetModeValue(mode, VIDMODE_H_SYNCEND),
- VidModeGetModeValue(mode, VIDMODE_H_TOTAL));
- ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
- VidModeGetModeValue(mode, VIDMODE_V_DISPLAY),
- VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART),
- VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
- VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
- VidModeGetModeValue(mode, VIDMODE_FLAGS));
- }
- if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) &&
- MODEMATCH(mode, stuff)) {
- VidModeDeleteModeline(stuff->screen, mode);
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
- ErrorF("DeleteModeLine - Succeeded\n");
- return Success;
- }
+ return BadValue;
+
+ do {
+ if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+ ErrorF("Checking against clock: %d (%d)\n",
+ VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock);
+ ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ VidModeGetModeValue(mode, VIDMODE_H_DISPLAY),
+ VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART),
+ VidModeGetModeValue(mode, VIDMODE_H_SYNCEND),
+ VidModeGetModeValue(mode, VIDMODE_H_TOTAL));
+ ErrorF
+ (" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
+ VidModeGetModeValue(mode, VIDMODE_V_DISPLAY),
+ VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART),
+ VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
+ VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
+ VidModeGetModeValue(mode, VIDMODE_FLAGS));
+ }
+ if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) &&
+ MODEMATCH(mode, stuff)) {
+ VidModeDeleteModeline(stuff->screen, mode);
+ if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
+ ErrorF("DeleteModeLine - Succeeded\n");
+ return Success;
+ }
} while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
return BadValue;
}
static int
-ProcXF86VidModeModModeLine(ClientPtr client)
-{
+ ProcXF86VidModeModModeLine(ClientPtr client) {
REQUEST(xXF86VidModeModModeLineReq);
xXF86OldVidModeModModeLineReq *oldstuff =
- (xXF86OldVidModeModModeLineReq *)client->requestBuffer;
+ (xXF86OldVidModeModModeLineReq *) client->requestBuffer;
xXF86VidModeModModeLineReq newstuff;
pointer mode, modetmp;
int len, dotClock;
int ver;
- DEBUG_P("XF86VidModeModModeline");
-
- ver = ClientMajorVersion(client);
- if (ver < 2 ) {
- /* convert from old format */
- stuff = &newstuff;
- stuff->length = oldstuff->length;
- stuff->screen = oldstuff->screen;
- stuff->hdisplay = oldstuff->hdisplay;
- stuff->hsyncstart = oldstuff->hsyncstart;
- stuff->hsyncend = oldstuff->hsyncend;
- stuff->htotal = oldstuff->htotal;
- stuff->hskew = 0;
- stuff->vdisplay = oldstuff->vdisplay;
- stuff->vsyncstart = oldstuff->vsyncstart;
- stuff->vsyncend = oldstuff->vsyncend;
- stuff->vtotal = oldstuff->vtotal;
- stuff->flags = oldstuff->flags;
- stuff->privsize = oldstuff->privsize;
- }
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
- ErrorF("ModModeLine - scrn: %d hdsp: %d hbeg: %d hend: %d httl: %d\n",
- (int)stuff->screen, stuff->hdisplay, stuff->hsyncstart,
- stuff->hsyncend, stuff->htotal);
- ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
- stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
- stuff->vtotal, (unsigned long)stuff->flags);
+ DEBUG_P("XF86VidModeModModeline");
+
+ ver = ClientMajorVersion(client);
+ if (ver < 2) {
+ /* convert from old format */
+ stuff = &newstuff;
+ stuff->length = oldstuff->length;
+ stuff->screen = oldstuff->screen;
+ stuff->hdisplay = oldstuff->hdisplay;
+ stuff->hsyncstart = oldstuff->hsyncstart;
+ stuff->hsyncend = oldstuff->hsyncend;
+ stuff->htotal = oldstuff->htotal;
+ stuff->hskew = 0;
+ stuff->vdisplay = oldstuff->vdisplay;
+ stuff->vsyncstart = oldstuff->vsyncstart;
+ stuff->vsyncend = oldstuff->vsyncend;
+ stuff->vtotal = oldstuff->vtotal;
+ stuff->flags = oldstuff->flags;
+ stuff->privsize = oldstuff->privsize;
+ } if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+ ErrorF("ModModeLine - scrn: %d hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ (int) stuff->screen, stuff->hdisplay, stuff->hsyncstart,
+ stuff->hsyncend, stuff->htotal);
+ ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
+ stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
+ stuff->vtotal, (unsigned long) stuff->flags);
}
if (ver < 2) {
- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq);
- len = client->req_len - bytes_to_int32(sizeof(xXF86OldVidModeModModeLineReq));
- } else {
- REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq);
- len = client->req_len - bytes_to_int32(sizeof(xXF86VidModeModModeLineReq));
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq);
+ len =
+ client->req_len -
+ bytes_to_int32(sizeof(xXF86OldVidModeModModeLineReq));
+ }
+ else {
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq);
+ len =
+ client->req_len -
+ bytes_to_int32(sizeof(xXF86VidModeModModeLineReq));
}
if (len != stuff->privsize)
- return BadLength;
+ return BadLength;
- if (stuff->hsyncstart < stuff->hdisplay ||
- stuff->hsyncend < stuff->hsyncstart ||
- stuff->htotal < stuff->hsyncend ||
- stuff->vsyncstart < stuff->vdisplay ||
- stuff->vsyncend < stuff->vsyncstart ||
- stuff->vtotal < stuff->vsyncend)
- return BadValue;
+ if (stuff->hsyncstart < stuff->hdisplay ||
+ stuff->hsyncend < stuff->hsyncstart ||
+ stuff->htotal < stuff->hsyncend ||
+ stuff->vsyncstart < stuff->vdisplay ||
+ stuff->vsyncend < stuff->vsyncstart || stuff->vtotal < stuff->vsyncend)
+ return BadValue;
- if(stuff->screen >= screenInfo.numScreens)
+ if (stuff->screen >= screenInfo.numScreens)
return BadValue;
if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
- return BadValue;
+ return BadValue;
modetmp = VidModeCreateMode();
VidModeCopyMode(mode, modetmp);
VidModeSetModeValue(modetmp, VIDMODE_H_DISPLAY, stuff->hdisplay);
- VidModeSetModeValue(modetmp, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
+ VidModeSetModeValue(modetmp, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
VidModeSetModeValue(modetmp, VIDMODE_H_SYNCEND, stuff->hsyncend);
VidModeSetModeValue(modetmp, VIDMODE_H_TOTAL, stuff->htotal);
VidModeSetModeValue(modetmp, VIDMODE_H_SKEW, stuff->hskew);
VidModeSetModeValue(modetmp, VIDMODE_V_DISPLAY, stuff->vdisplay);
- VidModeSetModeValue(modetmp, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
+ VidModeSetModeValue(modetmp, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
VidModeSetModeValue(modetmp, VIDMODE_V_SYNCEND, stuff->vsyncend);
VidModeSetModeValue(modetmp, VIDMODE_V_TOTAL, stuff->vtotal);
VidModeSetModeValue(modetmp, VIDMODE_FLAGS, stuff->flags);
if (stuff->privsize)
- ErrorF("ModModeLine - Privates in request have been ignored\n");
+ ErrorF("ModModeLine - Privates in request have been ignored\n");
/* Check that the mode is consistent with the monitor specs */
switch (VidModeCheckModeForMonitor(stuff->screen, modetmp)) {
- case MODE_OK:
- break;
- case MODE_HSYNC:
- case MODE_H_ILLEGAL:
- free(modetmp);
- return VidModeErrorBase + XF86VidModeBadHTimings;
- case MODE_VSYNC:
- case MODE_V_ILLEGAL:
- free(modetmp);
- return VidModeErrorBase + XF86VidModeBadVTimings;
- default:
- free(modetmp);
- return VidModeErrorBase + XF86VidModeModeUnsuitable;
+ case MODE_OK:
+ break;
+ case MODE_HSYNC:
+ case MODE_H_ILLEGAL:
+ free(modetmp);
+ return VidModeErrorBase + XF86VidModeBadHTimings;
+ case MODE_VSYNC:
+ case MODE_V_ILLEGAL:
+ free(modetmp);
+ return VidModeErrorBase + XF86VidModeBadVTimings;
+ default:
+ free(modetmp);
+ return VidModeErrorBase + XF86VidModeModeUnsuitable;
}
/* Check that the driver is happy with the mode */
if (VidModeCheckModeForDriver(stuff->screen, modetmp) != MODE_OK) {
- free(modetmp);
- return VidModeErrorBase + XF86VidModeModeUnsuitable;
+ free(modetmp);
+ return VidModeErrorBase + XF86VidModeModeUnsuitable;
}
free(modetmp);
VidModeSetModeValue(mode, VIDMODE_H_DISPLAY, stuff->hdisplay);
- VidModeSetModeValue(mode, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
+ VidModeSetModeValue(mode, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
VidModeSetModeValue(mode, VIDMODE_H_SYNCEND, stuff->hsyncend);
VidModeSetModeValue(mode, VIDMODE_H_TOTAL, stuff->htotal);
VidModeSetModeValue(mode, VIDMODE_H_SKEW, stuff->hskew);
VidModeSetModeValue(mode, VIDMODE_V_DISPLAY, stuff->vdisplay);
- VidModeSetModeValue(mode, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
+ VidModeSetModeValue(mode, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
VidModeSetModeValue(mode, VIDMODE_V_SYNCEND, stuff->vsyncend);
VidModeSetModeValue(mode, VIDMODE_V_TOTAL, stuff->vtotal);
VidModeSetModeValue(mode, VIDMODE_FLAGS, stuff->flags);
@@ -903,337 +898,349 @@ ProcXF86VidModeModModeLine(ClientPtr client)
VidModeSwitchMode(stuff->screen, mode);
if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
- ErrorF("ModModeLine - Succeeded\n");
+ ErrorF("ModModeLine - Succeeded\n");
return Success;
}
static int
-ProcXF86VidModeValidateModeLine(ClientPtr client)
-{
+ ProcXF86VidModeValidateModeLine(ClientPtr client) {
REQUEST(xXF86VidModeValidateModeLineReq);
xXF86OldVidModeValidateModeLineReq *oldstuff =
- (xXF86OldVidModeValidateModeLineReq *)client->requestBuffer;
+ (xXF86OldVidModeValidateModeLineReq *) client->requestBuffer;
xXF86VidModeValidateModeLineReq newstuff;
xXF86VidModeValidateModeLineReply rep;
pointer mode, modetmp = NULL;
int len, status, dotClock;
int ver;
- DEBUG_P("XF86VidModeValidateModeline");
+ DEBUG_P("XF86VidModeValidateModeline");
- ver = ClientMajorVersion(client);
+ ver = ClientMajorVersion(client);
if (ver < 2) {
- /* convert from old format */
- stuff = &newstuff;
- stuff->length = oldstuff->length;
- stuff->screen = oldstuff->screen;
- stuff->dotclock = oldstuff->dotclock;
- stuff->hdisplay = oldstuff->hdisplay;
- stuff->hsyncstart = oldstuff->hsyncstart;
- stuff->hsyncend = oldstuff->hsyncend;
- stuff->htotal = oldstuff->htotal;
- stuff->hskew = 0;
- stuff->vdisplay = oldstuff->vdisplay;
- stuff->vsyncstart = oldstuff->vsyncstart;
- stuff->vsyncend = oldstuff->vsyncend;
- stuff->vtotal = oldstuff->vtotal;
- stuff->flags = oldstuff->flags;
- stuff->privsize = oldstuff->privsize;
- }
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
- ErrorF("ValidateModeLine - scrn: %d clock: %ld\n",
- (int)stuff->screen, (unsigned long)stuff->dotclock);
- ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
- stuff->hdisplay, stuff->hsyncstart,
- stuff->hsyncend, stuff->htotal);
- ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
- stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
- stuff->vtotal, (unsigned long)stuff->flags);
+ /* convert from old format */
+ stuff = &newstuff;
+ stuff->length = oldstuff->length;
+ stuff->screen = oldstuff->screen;
+ stuff->dotclock = oldstuff->dotclock;
+ stuff->hdisplay = oldstuff->hdisplay;
+ stuff->hsyncstart = oldstuff->hsyncstart;
+ stuff->hsyncend = oldstuff->hsyncend;
+ stuff->htotal = oldstuff->htotal;
+ stuff->hskew = 0;
+ stuff->vdisplay = oldstuff->vdisplay;
+ stuff->vsyncstart = oldstuff->vsyncstart;
+ stuff->vsyncend = oldstuff->vsyncend;
+ stuff->vtotal = oldstuff->vtotal;
+ stuff->flags = oldstuff->flags;
+ stuff->privsize = oldstuff->privsize;
+ } if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+ ErrorF("ValidateModeLine - scrn: %d clock: %ld\n",
+ (int) stuff->screen, (unsigned long) stuff->dotclock);
+ ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ stuff->hdisplay, stuff->hsyncstart,
+ stuff->hsyncend, stuff->htotal);
+ ErrorF
+ (" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
+ stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, stuff->vtotal,
+ (unsigned long) stuff->flags);
}
if (ver < 2) {
- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq);
- len = client->req_len -
- bytes_to_int32(sizeof(xXF86OldVidModeValidateModeLineReq));
- } else {
- REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq);
- len = client->req_len - bytes_to_int32(sizeof(xXF86VidModeValidateModeLineReq));
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq);
+ len = client->req_len -
+ bytes_to_int32(sizeof(xXF86OldVidModeValidateModeLineReq));
+ }
+ else {
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq);
+ len =
+ client->req_len -
+ bytes_to_int32(sizeof(xXF86VidModeValidateModeLineReq));
}
if (len != stuff->privsize)
- return BadLength;
+ return BadLength;
- if(stuff->screen >= screenInfo.numScreens)
+ if (stuff->screen >= screenInfo.numScreens)
return BadValue;
status = MODE_OK;
- if (stuff->hsyncstart < stuff->hdisplay ||
- stuff->hsyncend < stuff->hsyncstart ||
- stuff->htotal < stuff->hsyncend ||
- stuff->vsyncstart < stuff->vdisplay ||
- stuff->vsyncend < stuff->vsyncstart ||
- stuff->vtotal < stuff->vsyncend)
- {
- status = MODE_BAD;
- goto status_reply;
+ if (stuff->hsyncstart < stuff->hdisplay ||
+ stuff->hsyncend < stuff->hsyncstart ||
+ stuff->htotal < stuff->hsyncend ||
+ stuff->vsyncstart < stuff->vdisplay ||
+ stuff->vsyncend < stuff->vsyncstart ||
+ stuff->vtotal < stuff->vsyncend) {
+ status = MODE_BAD;
+ goto status_reply;
}
if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
- return BadValue;
+ return BadValue;
modetmp = VidModeCreateMode();
VidModeCopyMode(mode, modetmp);
VidModeSetModeValue(modetmp, VIDMODE_H_DISPLAY, stuff->hdisplay);
- VidModeSetModeValue(modetmp, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
+ VidModeSetModeValue(modetmp, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
VidModeSetModeValue(modetmp, VIDMODE_H_SYNCEND, stuff->hsyncend);
VidModeSetModeValue(modetmp, VIDMODE_H_TOTAL, stuff->htotal);
VidModeSetModeValue(modetmp, VIDMODE_H_SKEW, stuff->hskew);
VidModeSetModeValue(modetmp, VIDMODE_V_DISPLAY, stuff->vdisplay);
- VidModeSetModeValue(modetmp, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
+ VidModeSetModeValue(modetmp, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
VidModeSetModeValue(modetmp, VIDMODE_V_SYNCEND, stuff->vsyncend);
VidModeSetModeValue(modetmp, VIDMODE_V_TOTAL, stuff->vtotal);
VidModeSetModeValue(modetmp, VIDMODE_FLAGS, stuff->flags);
if (stuff->privsize)
- ErrorF("ValidateModeLine - Privates in request have been ignored\n");
+ ErrorF("ValidateModeLine - Privates in request have been ignored\n");
/* Check that the mode is consistent with the monitor specs */
- if ((status = VidModeCheckModeForMonitor(stuff->screen, modetmp)) != MODE_OK)
- goto status_reply;
+ if ((status =
+ VidModeCheckModeForMonitor(stuff->screen, modetmp)) != MODE_OK)
+ goto status_reply;
/* Check that the driver is happy with the mode */
status = VidModeCheckModeForDriver(stuff->screen, modetmp);
-status_reply:
+ status_reply:
free(modetmp);
rep.type = X_Reply;
rep.length = bytes_to_int32(SIZEOF(xXF86VidModeValidateModeLineReply)
- - SIZEOF(xGenericReply));
+ - SIZEOF(xGenericReply));
rep.sequenceNumber = client->sequence;
rep.status = status;
if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swapl(&rep.status);
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
+ swapl(&rep.status);
}
- WriteToClient(client, sizeof(xXF86VidModeValidateModeLineReply), (char *)&rep);
+ WriteToClient(client, sizeof(xXF86VidModeValidateModeLineReply),
+ (char *) &rep);
if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
- ErrorF("ValidateModeLine - Succeeded (status = %d)\n", status);
+ ErrorF("ValidateModeLine - Succeeded (status = %d)\n", status);
return Success;
}
static int
-ProcXF86VidModeSwitchMode(ClientPtr client)
-{
+ ProcXF86VidModeSwitchMode(ClientPtr client) {
REQUEST(xXF86VidModeSwitchModeReq);
DEBUG_P("XF86VidModeSwitchMode");
REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq);
- if(stuff->screen >= screenInfo.numScreens)
+ if (stuff->screen >= screenInfo.numScreens)
return BadValue;
- VidModeZoomViewport(stuff->screen, (short)stuff->zoom);
+ VidModeZoomViewport(stuff->screen, (short) stuff->zoom);
return Success;
-}
-
-static int
-ProcXF86VidModeSwitchToMode(ClientPtr client)
-{
+} static int
+ ProcXF86VidModeSwitchToMode(ClientPtr client) {
REQUEST(xXF86VidModeSwitchToModeReq);
xXF86OldVidModeSwitchToModeReq *oldstuff =
- (xXF86OldVidModeSwitchToModeReq *)client->requestBuffer;
+ (xXF86OldVidModeSwitchToModeReq *) client->requestBuffer;
xXF86VidModeSwitchToModeReq newstuff;
pointer mode;
int len, dotClock;
int ver;
- DEBUG_P("XF86VidModeSwitchToMode");
+ DEBUG_P("XF86VidModeSwitchToMode");
- ver = ClientMajorVersion(client);
+ ver = ClientMajorVersion(client);
if (ver < 2) {
- /* convert from old format */
- stuff = &newstuff;
- stuff->length = oldstuff->length;
- stuff->screen = oldstuff->screen;
- stuff->dotclock = oldstuff->dotclock;
- stuff->hdisplay = oldstuff->hdisplay;
- stuff->hsyncstart = oldstuff->hsyncstart;
- stuff->hsyncend = oldstuff->hsyncend;
- stuff->htotal = oldstuff->htotal;
- stuff->hskew = 0;
- stuff->vdisplay = oldstuff->vdisplay;
- stuff->vsyncstart = oldstuff->vsyncstart;
- stuff->vsyncend = oldstuff->vsyncend;
- stuff->vtotal = oldstuff->vtotal;
- stuff->flags = oldstuff->flags;
- stuff->privsize = oldstuff->privsize;
- }
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
- ErrorF("SwitchToMode - scrn: %d clock: %ld\n",
- (int)stuff->screen, (unsigned long)stuff->dotclock);
- ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
- stuff->hdisplay, stuff->hsyncstart,
- stuff->hsyncend, stuff->htotal);
- ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
- stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
- stuff->vtotal, (unsigned long)stuff->flags);
+ /* convert from old format */
+ stuff = &newstuff;
+ stuff->length = oldstuff->length;
+ stuff->screen = oldstuff->screen;
+ stuff->dotclock = oldstuff->dotclock;
+ stuff->hdisplay = oldstuff->hdisplay;
+ stuff->hsyncstart = oldstuff->hsyncstart;
+ stuff->hsyncend = oldstuff->hsyncend;
+ stuff->htotal = oldstuff->htotal;
+ stuff->hskew = 0;
+ stuff->vdisplay = oldstuff->vdisplay;
+ stuff->vsyncstart = oldstuff->vsyncstart;
+ stuff->vsyncend = oldstuff->vsyncend;
+ stuff->vtotal = oldstuff->vtotal;
+ stuff->flags = oldstuff->flags;
+ stuff->privsize = oldstuff->privsize;
+ } if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+ ErrorF("SwitchToMode - scrn: %d clock: %ld\n",
+ (int) stuff->screen, (unsigned long) stuff->dotclock);
+ ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ stuff->hdisplay, stuff->hsyncstart,
+ stuff->hsyncend, stuff->htotal);
+ ErrorF
+ (" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
+ stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, stuff->vtotal,
+ (unsigned long) stuff->flags);
}
if (ver < 2) {
- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeSwitchToModeReq);
- len = client->req_len - bytes_to_int32(sizeof(xXF86OldVidModeSwitchToModeReq));
- } else {
- REQUEST_AT_LEAST_SIZE(xXF86VidModeSwitchToModeReq);
- len = client->req_len - bytes_to_int32(sizeof(xXF86VidModeSwitchToModeReq));
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeSwitchToModeReq);
+ len =
+ client->req_len -
+ bytes_to_int32(sizeof(xXF86OldVidModeSwitchToModeReq));
+ }
+ else {
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeSwitchToModeReq);
+ len =
+ client->req_len -
+ bytes_to_int32(sizeof(xXF86VidModeSwitchToModeReq));
}
if (len != stuff->privsize)
- return BadLength;
+ return BadLength;
- if(stuff->screen >= screenInfo.numScreens)
+ if (stuff->screen >= screenInfo.numScreens)
return BadValue;
if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
- return BadValue;
+ return BadValue;
if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock)
- && MODEMATCH(mode, stuff))
- return Success;
+ && MODEMATCH(mode, stuff))
+ return Success;
if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock))
- return BadValue;
+ return BadValue;
do {
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
- ErrorF("Checking against clock: %d (%d)\n",
- VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock);
- ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
- VidModeGetModeValue(mode, VIDMODE_H_DISPLAY),
- VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART),
- VidModeGetModeValue(mode, VIDMODE_H_SYNCEND),
- VidModeGetModeValue(mode, VIDMODE_H_TOTAL));
- ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
- VidModeGetModeValue(mode, VIDMODE_V_DISPLAY),
- VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART),
- VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
- VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
- VidModeGetModeValue(mode, VIDMODE_FLAGS));
- }
- if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) &&
- MODEMATCH(mode, stuff)) {
-
- if (!VidModeSwitchMode(stuff->screen, mode))
- return BadValue;
-
- if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
- ErrorF("SwitchToMode - Succeeded\n");
- return Success;
- }
+ if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+ ErrorF("Checking against clock: %d (%d)\n",
+ VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock);
+ ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ VidModeGetModeValue(mode, VIDMODE_H_DISPLAY),
+ VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART),
+ VidModeGetModeValue(mode, VIDMODE_H_SYNCEND),
+ VidModeGetModeValue(mode, VIDMODE_H_TOTAL));
+ ErrorF
+ (" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
+ VidModeGetModeValue(mode, VIDMODE_V_DISPLAY),
+ VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART),
+ VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
+ VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
+ VidModeGetModeValue(mode, VIDMODE_FLAGS));
+ }
+ if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) &&
+ MODEMATCH(mode, stuff)) {
+
+ if (!VidModeSwitchMode(stuff->screen, mode))
+ return BadValue;
+
+ if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
+ ErrorF("SwitchToMode - Succeeded\n");
+ return Success;
+ }
} while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
return BadValue;
}
static int
-ProcXF86VidModeLockModeSwitch(ClientPtr client)
-{
+ ProcXF86VidModeLockModeSwitch(ClientPtr client) {
REQUEST(xXF86VidModeLockModeSwitchReq);
REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq);
DEBUG_P("XF86VidModeLockModeSwitch");
- if(stuff->screen >= screenInfo.numScreens)
+ if (stuff->screen >= screenInfo.numScreens)
return BadValue;
- if (!VidModeLockZoom(stuff->screen, (short)stuff->lock))
- return VidModeErrorBase + XF86VidModeZoomLocked;
+ if (!VidModeLockZoom(stuff->screen, (short) stuff->lock))
+ return VidModeErrorBase + XF86VidModeZoomLocked;
return Success;
-}
-
-static int
-ProcXF86VidModeGetMonitor(ClientPtr client)
-{
+} static int
+ ProcXF86VidModeGetMonitor(ClientPtr client) {
REQUEST(xXF86VidModeGetMonitorReq);
xXF86VidModeGetMonitorReply rep;
CARD32 *hsyncdata, *vsyncdata;
int i, nHsync, nVrefresh;
pointer monitor;
-
- DEBUG_P("XF86VidModeGetMonitor");
- REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq);
+ DEBUG_P("XF86VidModeGetMonitor");
- if(stuff->screen >= screenInfo.numScreens)
- return BadValue;
+ REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq);
+
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
if (!VidModeGetMonitor(stuff->screen, &monitor))
- return BadValue;
+ return BadValue;
- nHsync = VidModeGetMonitorValue(monitor, VIDMODE_MON_NHSYNC, 0).i;
- nVrefresh = VidModeGetMonitorValue(monitor, VIDMODE_MON_NVREFRESH, 0).i;
-
- rep.type = X_Reply;
- if ((char *)(VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR, 0)).ptr)
- rep.vendorLength = strlen((char *)(VidModeGetMonitorValue(monitor,
- VIDMODE_MON_VENDOR, 0)).ptr);
+ nHsync = VidModeGetMonitorValue(monitor, VIDMODE_MON_NHSYNC, 0).i;
+ nVrefresh = VidModeGetMonitorValue(monitor, VIDMODE_MON_NVREFRESH, 0).i;
+
+ rep.type = X_Reply;
+ if ((char *) (VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR, 0)).ptr)
+ rep.vendorLength = strlen((char *) (VidModeGetMonitorValue(monitor,
+ VIDMODE_MON_VENDOR,
+ 0)).ptr);
else
- rep.vendorLength = 0;
- if ((char *)(VidModeGetMonitorValue(monitor, VIDMODE_MON_MODEL, 0)).ptr)
- rep.modelLength = strlen((char *)(VidModeGetMonitorValue(monitor,
- VIDMODE_MON_MODEL, 0)).ptr);
+ rep.vendorLength = 0;
+ if ((char *) (VidModeGetMonitorValue(monitor, VIDMODE_MON_MODEL, 0)).ptr)
+ rep.modelLength = strlen((char *) (VidModeGetMonitorValue(monitor,
+ VIDMODE_MON_MODEL,
+ 0)).ptr);
else
- rep.modelLength = 0;
- rep.length = bytes_to_int32(SIZEOF(xXF86VidModeGetMonitorReply) - SIZEOF(xGenericReply) +
- (nHsync + nVrefresh) * sizeof(CARD32) +
- pad_to_int32(rep.vendorLength) +
- pad_to_int32(rep.modelLength));
- rep.sequenceNumber = client->sequence;
- rep.nhsync = nHsync;
- rep.nvsync = nVrefresh;
- hsyncdata = malloc(nHsync * sizeof(CARD32));
+ rep.modelLength = 0;
+ rep.length =
+ bytes_to_int32(SIZEOF(xXF86VidModeGetMonitorReply) -
+ SIZEOF(xGenericReply) + (nHsync +
+ nVrefresh) * sizeof(CARD32) +
+ pad_to_int32(rep.vendorLength) +
+ pad_to_int32(rep.modelLength));
+ rep.sequenceNumber = client->sequence;
+ rep.nhsync = nHsync;
+ rep.nvsync = nVrefresh;
+ hsyncdata = malloc(nHsync * sizeof(CARD32));
if (!hsyncdata) {
- return BadAlloc;
- }
+ return BadAlloc;
+ } vsyncdata = malloc(nVrefresh * sizeof(CARD32));
- vsyncdata = malloc(nVrefresh * sizeof(CARD32));
if (!vsyncdata) {
- free(hsyncdata);
- return BadAlloc;
+ free(hsyncdata);
+ return BadAlloc;
}
for (i = 0; i < nHsync; i++) {
- hsyncdata[i] = (unsigned short)(VidModeGetMonitorValue(monitor,
- VIDMODE_MON_HSYNC_LO, i)).f |
- (unsigned short)(VidModeGetMonitorValue(monitor,
- VIDMODE_MON_HSYNC_HI, i)).f << 16;
+ hsyncdata[i] = (unsigned short) (VidModeGetMonitorValue(monitor,
+ VIDMODE_MON_HSYNC_LO,
+ i)).
+ f | (unsigned
+ short) (VidModeGetMonitorValue(monitor, VIDMODE_MON_HSYNC_HI,
+ i)).f << 16;
}
for (i = 0; i < nVrefresh; i++) {
- vsyncdata[i] = (unsigned short)(VidModeGetMonitorValue(monitor,
- VIDMODE_MON_VREFRESH_LO, i)).f |
- (unsigned short)(VidModeGetMonitorValue(monitor,
- VIDMODE_MON_VREFRESH_HI, i)).f << 16;
+ vsyncdata[i] = (unsigned short) (VidModeGetMonitorValue(monitor,
+ VIDMODE_MON_VREFRESH_LO,
+ i)).
+ f | (unsigned
+ short) (VidModeGetMonitorValue(monitor,
+ VIDMODE_MON_VREFRESH_HI,
+ i)).f << 16;
}
-
if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
}
- WriteToClient(client, SIZEOF(xXF86VidModeGetMonitorReply), (char *)&rep);
+ WriteToClient(client, SIZEOF(xXF86VidModeGetMonitorReply), (char *) &rep);
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
- WriteSwappedDataToClient(client, nHsync * sizeof(CARD32),
- hsyncdata);
- WriteSwappedDataToClient(client, nVrefresh * sizeof(CARD32),
- vsyncdata);
+ WriteSwappedDataToClient(client, nHsync * sizeof(CARD32), hsyncdata);
+ WriteSwappedDataToClient(client, nVrefresh * sizeof(CARD32), vsyncdata);
if (rep.vendorLength)
- WriteToClient(client, rep.vendorLength, (char *)(VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR, 0)).ptr);
+ WriteToClient(client, rep.vendorLength,
+ (char
+ *) (VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR,
+ 0)).ptr);
if (rep.modelLength)
- WriteToClient(client, rep.modelLength, (char *)(VidModeGetMonitorValue(monitor, VIDMODE_MON_MODEL, 0)).ptr);
+ WriteToClient(client, rep.modelLength,
+ (char
+ *) (VidModeGetMonitorValue(monitor, VIDMODE_MON_MODEL,
+ 0)).ptr);
free(hsyncdata);
free(vsyncdata);
@@ -1242,113 +1249,106 @@ ProcXF86VidModeGetMonitor(ClientPtr client)
}
static int
-ProcXF86VidModeGetViewPort(ClientPtr client)
-{
+ ProcXF86VidModeGetViewPort(ClientPtr client) {
REQUEST(xXF86VidModeGetViewPortReq);
xXF86VidModeGetViewPortReply rep;
int x, y;
- DEBUG_P("XF86VidModeGetViewPort");
+ DEBUG_P("XF86VidModeGetViewPort");
- REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq);
- if(stuff->screen >= screenInfo.numScreens)
- return BadValue;
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
- VidModeGetViewPort(stuff->screen, &x, &y);
- rep.x = x;
- rep.y = y;
+ VidModeGetViewPort(stuff->screen, &x, &y);
+ rep.x = x;
+ rep.y = y;
if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swapl(&rep.x);
- swapl(&rep.y);
- }
- WriteToClient(client, SIZEOF(xXF86VidModeGetViewPortReply), (char *)&rep);
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
+ swapl(&rep.x);
+ swapl(&rep.y);
+ } WriteToClient(client, SIZEOF(xXF86VidModeGetViewPortReply),
+ (char *) &rep);
return Success;
}
static int
-ProcXF86VidModeSetViewPort(ClientPtr client)
-{
+ ProcXF86VidModeSetViewPort(ClientPtr client) {
REQUEST(xXF86VidModeSetViewPortReq);
DEBUG_P("XF86VidModeSetViewPort");
REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq);
- if(stuff->screen >= screenInfo.numScreens)
+ if (stuff->screen >= screenInfo.numScreens)
return BadValue;
if (!VidModeSetViewPort(stuff->screen, stuff->x, stuff->y))
- return BadValue;
+ return BadValue;
return Success;
-}
-
-static int
-ProcXF86VidModeGetDotClocks(ClientPtr client)
-{
+} static int
+ ProcXF86VidModeGetDotClocks(ClientPtr client) {
REQUEST(xXF86VidModeGetDotClocksReq);
xXF86VidModeGetDotClocksReply rep;
- int n;
+ int n;
int numClocks;
CARD32 dotclock;
int *Clocks = NULL;
Bool ClockProg;
- DEBUG_P("XF86VidModeGetDotClocks");
+ DEBUG_P("XF86VidModeGetDotClocks");
- REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq);
- if(stuff->screen >= screenInfo.numScreens)
- return BadValue;
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
- numClocks = VidModeGetNumOfClocks(stuff->screen, &ClockProg);
+ numClocks = VidModeGetNumOfClocks(stuff->screen, &ClockProg);
- rep.type = X_Reply;
- rep.length = bytes_to_int32(SIZEOF(xXF86VidModeGetDotClocksReply)
- - SIZEOF(xGenericReply) + numClocks);
- rep.sequenceNumber = client->sequence;
- rep.clocks = numClocks;
- rep.maxclocks = MAXCLOCKS;
- rep.flags = 0;
+ rep.type = X_Reply;
+ rep.length = bytes_to_int32(SIZEOF(xXF86VidModeGetDotClocksReply)
+ - SIZEOF(xGenericReply) + numClocks);
+ rep.sequenceNumber = client->sequence;
+ rep.clocks = numClocks;
+ rep.maxclocks = MAXCLOCKS;
+ rep.flags = 0;
if (!ClockProg) {
- Clocks = malloc(numClocks * sizeof(int));
- if (!Clocks)
- return BadValue;
- if (!VidModeGetClocks(stuff->screen, Clocks)) {
- free(Clocks);
- return BadValue;
- }
- }
-
- if (ClockProg) {
- rep.flags |= CLKFLAG_PROGRAMABLE;
+ Clocks = malloc(numClocks * sizeof(int));
+ if (!Clocks)
+ return BadValue;
+ if (!VidModeGetClocks(stuff->screen, Clocks)) {
+ free(Clocks);
+ return BadValue;
+ }} if (ClockProg) {
+ rep.flags |= CLKFLAG_PROGRAMABLE;
}
if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swapl(&rep.clocks);
- swapl(&rep.maxclocks);
- swapl(&rep.flags);
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
+ swapl(&rep.clocks);
+ swapl(&rep.maxclocks);
+ swapl(&rep.flags);
}
- WriteToClient(client, sizeof(xXF86VidModeGetDotClocksReply), (char *)&rep);
+ WriteToClient(client, sizeof(xXF86VidModeGetDotClocksReply), (char *) &rep);
if (!ClockProg) {
- for (n = 0; n < numClocks; n++) {
- dotclock = *Clocks++;
- if (client->swapped) {
- WriteSwappedDataToClient(client, 4, (char *)&dotclock);
- } else {
- WriteToClient(client, 4, (char *)&dotclock);
- }
- }
+ for (n = 0; n < numClocks; n++) {
+ dotclock = *Clocks++;
+ if (client->swapped) {
+ WriteSwappedDataToClient(client, 4, (char *) &dotclock);
+ }
+ else {
+ WriteToClient(client, 4, (char *) &dotclock);
+ }
+ }
}
free(Clocks);
@@ -1356,534 +1356,486 @@ ProcXF86VidModeGetDotClocks(ClientPtr client)
}
static int
-ProcXF86VidModeSetGamma(ClientPtr client)
-{
+ ProcXF86VidModeSetGamma(ClientPtr client) {
REQUEST(xXF86VidModeSetGammaReq);
DEBUG_P("XF86VidModeSetGamma");
REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq);
- if(stuff->screen >= screenInfo.numScreens)
+ if (stuff->screen >= screenInfo.numScreens)
return BadValue;
- if (!VidModeSetGamma(stuff->screen, ((float)stuff->red)/10000.,
- ((float)stuff->green)/10000., ((float)stuff->blue)/10000.))
- return BadValue;
+ if (!VidModeSetGamma(stuff->screen, ((float) stuff->red) / 10000.,
+ ((float) stuff->green) / 10000.,
+ ((float) stuff->blue) / 10000.))
+ return BadValue;
return Success;
-}
-
-static int
-ProcXF86VidModeGetGamma(ClientPtr client)
-{
+} static int
+ ProcXF86VidModeGetGamma(ClientPtr client) {
REQUEST(xXF86VidModeGetGammaReq);
xXF86VidModeGetGammaReply rep;
float red, green, blue;
- DEBUG_P("XF86VidModeGetGamma");
+ DEBUG_P("XF86VidModeGetGamma");
- REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq);
- if(stuff->screen >= screenInfo.numScreens)
- return BadValue;
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
if (!VidModeGetGamma(stuff->screen, &red, &green, &blue))
- return BadValue;
- rep.red = (CARD32)(red * 10000.);
- rep.green = (CARD32)(green * 10000.);
- rep.blue = (CARD32)(blue * 10000.);
+ return BadValue;
+ rep.red = (CARD32) (red * 10000.);
+ rep.green = (CARD32) (green * 10000.);
+ rep.blue = (CARD32) (blue * 10000.);
if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swapl(&rep.red);
- swapl(&rep.green);
- swapl(&rep.blue);
- }
- WriteToClient(client, sizeof(xXF86VidModeGetGammaReply), (char *)&rep);
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
+ swapl(&rep.red);
+ swapl(&rep.green);
+ swapl(&rep.blue);
+ } WriteToClient(client, sizeof(xXF86VidModeGetGammaReply), (char *) &rep);
+
return Success;
}
static int
-ProcXF86VidModeSetGammaRamp(ClientPtr client)
-{
+ ProcXF86VidModeSetGammaRamp(ClientPtr client) {
CARD16 *r, *g, *b;
int length;
- REQUEST(xXF86VidModeSetGammaRampReq);
+ REQUEST(xXF86VidModeSetGammaRampReq);
- if(stuff->screen >= screenInfo.numScreens)
- return BadValue;
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
- if(stuff->size != VidModeGetGammaRampSize(stuff->screen))
- return BadValue;
+ if (stuff->size != VidModeGetGammaRampSize(stuff->screen))
+ return BadValue;
- length = (stuff->size + 1) & ~1;
+ length = (stuff->size + 1) & ~1;
- REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length * 6);
+ REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length * 6);
- r = (CARD16*)&stuff[1];
- g = r + length;
- b = g + length;
+ r = (CARD16 *) &stuff[1];
+ g = r + length;
+ b = g + length;
if (!VidModeSetGammaRamp(stuff->screen, stuff->size, r, g, b))
- return BadValue;
-
- return Success;
-}
+ return BadValue;
-static int
-ProcXF86VidModeGetGammaRamp(ClientPtr client)
-{
+ return Success;
+} static int
+ ProcXF86VidModeGetGammaRamp(ClientPtr client) {
CARD16 *ramp = NULL;
int length;
size_t ramplen = 0;
xXF86VidModeGetGammaRampReply rep;
- REQUEST(xXF86VidModeGetGammaRampReq);
+ REQUEST(xXF86VidModeGetGammaRampReq);
- if(stuff->screen >= screenInfo.numScreens)
- return BadValue;
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
- if(stuff->size != VidModeGetGammaRampSize(stuff->screen))
- return BadValue;
+ if (stuff->size != VidModeGetGammaRampSize(stuff->screen))
+ return BadValue;
- REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq);
- length = (stuff->size + 1) & ~1;
+ length = (stuff->size + 1) & ~1;
- if(stuff->size) {
- ramplen = length * 3 * sizeof(CARD16);
- if (!(ramp = malloc(ramplen)))
- return BadAlloc;
-
- if (!VidModeGetGammaRamp(stuff->screen, stuff->size,
- ramp, ramp + length, ramp + (length * 2))) {
- free(ramp);
- return BadValue;
- }
- }
+ if (stuff->size) {
+ ramplen = length * 3 * sizeof(CARD16);
+ if (!(ramp = malloc(ramplen)))
+ return BadAlloc;
- rep.type = X_Reply;
+ if (!VidModeGetGammaRamp(stuff->screen, stuff->size,
+ ramp, ramp + length, ramp + (length * 2))) {
+ free(ramp);
+ return BadValue;
+ }} rep.type = X_Reply;
rep.length = (length >> 1) * 3;
rep.sequenceNumber = client->sequence;
rep.size = stuff->size;
- if(client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swaps(&rep.size);
- SwapShorts((short*)ramp, length * 3);
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
+ swaps(&rep.size);
+ SwapShorts((short *) ramp, length * 3);
}
- WriteToClient(client, sizeof(xXF86VidModeGetGammaRampReply), (char *)&rep);
+ WriteToClient(client, sizeof(xXF86VidModeGetGammaRampReply), (char *) &rep);
- if(stuff->size) {
- WriteToClient(client, ramplen, (char*)ramp);
+ if (stuff->size) {
+ WriteToClient(client, ramplen, (char *) ramp);
free(ramp);
}
return Success;
}
-
static int
-ProcXF86VidModeGetGammaRampSize(ClientPtr client)
-{
+ ProcXF86VidModeGetGammaRampSize(ClientPtr client) {
xXF86VidModeGetGammaRampSizeReply rep;
- REQUEST(xXF86VidModeGetGammaRampSizeReq);
+ REQUEST(xXF86VidModeGetGammaRampSizeReq);
- if(stuff->screen >= screenInfo.numScreens)
- return BadValue;
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
- REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.size = VidModeGetGammaRampSize(stuff->screen);
- if(client->swapped) {
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.size = VidModeGetGammaRampSize(stuff->screen);
+ if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.size);
- }
- WriteToClient(client,sizeof(xXF86VidModeGetGammaRampSizeReply),(char*)&rep);
+ } WriteToClient(client, sizeof(xXF86VidModeGetGammaRampSizeReply),
+ (char *) &rep);
return Success;
}
static int
-ProcXF86VidModeGetPermissions(ClientPtr client)
-{
+ ProcXF86VidModeGetPermissions(ClientPtr client) {
xXF86VidModeGetPermissionsReply rep;
- REQUEST(xXF86VidModeGetPermissionsReq);
+ REQUEST(xXF86VidModeGetPermissionsReq);
- if(stuff->screen >= screenInfo.numScreens)
- return BadValue;
+ if (stuff->screen >= screenInfo.numScreens)
+ return BadValue;
- REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.permissions = XF86VM_READ_PERMISSION;
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.permissions = XF86VM_READ_PERMISSION;
if (xf86GetVidModeEnabled() &&
- (xf86GetVidModeAllowNonLocal() || LocalClient (client))) {
- rep.permissions |= XF86VM_WRITE_PERMISSION;
- }
- if(client->swapped) {
+ (xf86GetVidModeAllowNonLocal() || LocalClient(client))) {
+ rep.permissions |= XF86VM_WRITE_PERMISSION;
+ } if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.permissions);
}
- WriteToClient(client,sizeof(xXF86VidModeGetPermissionsReply),(char*)&rep);
+ WriteToClient(client, sizeof(xXF86VidModeGetPermissionsReply),
+ (char *) &rep);
return Success;
}
-
static int
-ProcXF86VidModeSetClientVersion(ClientPtr client)
-{
+ ProcXF86VidModeSetClientVersion(ClientPtr client) {
REQUEST(xXF86VidModeSetClientVersionReq);
VidModePrivPtr pPriv;
- DEBUG_P("XF86VidModeSetClientVersion");
+ DEBUG_P("XF86VidModeSetClientVersion");
- REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq);
+ REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq);
if ((pPriv = VM_GETPRIV(client)) == NULL) {
- pPriv = malloc(sizeof(VidModePrivRec));
- if (!pPriv)
- return BadAlloc;
- VM_SETPRIV(client, pPriv);
- }
- pPriv->major = stuff->major;
+ pPriv = malloc(sizeof(VidModePrivRec));
+ if (!pPriv)
+ return BadAlloc;
+ VM_SETPRIV(client, pPriv);
+ } pPriv->major = stuff->major;
+
pPriv->minor = stuff->minor;
-
+
return Success;
}
static int
-ProcXF86VidModeDispatch(ClientPtr client)
-{
+ ProcXF86VidModeDispatch(ClientPtr client) {
REQUEST(xReq);
- switch (stuff->data)
- {
+ switch (stuff->data) {
case X_XF86VidModeQueryVersion:
- return ProcXF86VidModeQueryVersion(client);
- case X_XF86VidModeGetModeLine:
- return ProcXF86VidModeGetModeLine(client);
- case X_XF86VidModeGetMonitor:
- return ProcXF86VidModeGetMonitor(client);
- case X_XF86VidModeGetAllModeLines:
- return ProcXF86VidModeGetAllModeLines(client);
- case X_XF86VidModeValidateModeLine:
- return ProcXF86VidModeValidateModeLine(client);
- case X_XF86VidModeGetViewPort:
- return ProcXF86VidModeGetViewPort(client);
- case X_XF86VidModeGetDotClocks:
- return ProcXF86VidModeGetDotClocks(client);
- case X_XF86VidModeSetClientVersion:
- return ProcXF86VidModeSetClientVersion(client);
- case X_XF86VidModeGetGamma:
- return ProcXF86VidModeGetGamma(client);
- case X_XF86VidModeGetGammaRamp:
- return ProcXF86VidModeGetGammaRamp(client);
- case X_XF86VidModeGetGammaRampSize:
- return ProcXF86VidModeGetGammaRampSize(client);
- case X_XF86VidModeGetPermissions:
- return ProcXF86VidModeGetPermissions(client);
- default:
- if (!xf86GetVidModeEnabled())
- return VidModeErrorBase + XF86VidModeExtensionDisabled;
- if (xf86GetVidModeAllowNonLocal() || LocalClient (client)) {
- switch (stuff->data) {
- case X_XF86VidModeAddModeLine:
- return ProcXF86VidModeAddModeLine(client);
- case X_XF86VidModeDeleteModeLine:
- return ProcXF86VidModeDeleteModeLine(client);
- case X_XF86VidModeModModeLine:
- return ProcXF86VidModeModModeLine(client);
- case X_XF86VidModeSwitchMode:
- return ProcXF86VidModeSwitchMode(client);
- case X_XF86VidModeSwitchToMode:
- return ProcXF86VidModeSwitchToMode(client);
- case X_XF86VidModeLockModeSwitch:
- return ProcXF86VidModeLockModeSwitch(client);
- case X_XF86VidModeSetViewPort:
- return ProcXF86VidModeSetViewPort(client);
- case X_XF86VidModeSetGamma:
- return ProcXF86VidModeSetGamma(client);
- case X_XF86VidModeSetGammaRamp:
- return ProcXF86VidModeSetGammaRamp(client);
- default:
- return BadRequest;
- }
- } else
- return VidModeErrorBase + XF86VidModeClientNotLocal;
+ return ProcXF86VidModeQueryVersion(client);
+ case X_XF86VidModeGetModeLine:return ProcXF86VidModeGetModeLine(client);
+ case X_XF86VidModeGetMonitor:return ProcXF86VidModeGetMonitor(client);
+ case X_XF86VidModeGetAllModeLines:return
+ ProcXF86VidModeGetAllModeLines(client);
+ case X_XF86VidModeValidateModeLine:return
+ ProcXF86VidModeValidateModeLine(client);
+ case X_XF86VidModeGetViewPort:return ProcXF86VidModeGetViewPort(client);
+ case X_XF86VidModeGetDotClocks:return
+ ProcXF86VidModeGetDotClocks(client);
+ case X_XF86VidModeSetClientVersion:return
+ ProcXF86VidModeSetClientVersion(client);
+ case X_XF86VidModeGetGamma:return ProcXF86VidModeGetGamma(client);
+ case X_XF86VidModeGetGammaRamp:return
+ ProcXF86VidModeGetGammaRamp(client);
+ case X_XF86VidModeGetGammaRampSize:return
+ ProcXF86VidModeGetGammaRampSize(client);
+ case X_XF86VidModeGetPermissions:return
+ ProcXF86VidModeGetPermissions(client);
+ default:if (!xf86GetVidModeEnabled())
+ return VidModeErrorBase + XF86VidModeExtensionDisabled;
+ if (xf86GetVidModeAllowNonLocal() || LocalClient(client)) {
+ switch (stuff->data) {
+ case X_XF86VidModeAddModeLine:
+ return ProcXF86VidModeAddModeLine(client);
+ case X_XF86VidModeDeleteModeLine:return
+ ProcXF86VidModeDeleteModeLine(client);
+ case X_XF86VidModeModModeLine:return
+ ProcXF86VidModeModModeLine(client);
+ case X_XF86VidModeSwitchMode:return
+ ProcXF86VidModeSwitchMode(client);
+ case X_XF86VidModeSwitchToMode:return
+ ProcXF86VidModeSwitchToMode(client);
+ case X_XF86VidModeLockModeSwitch:return
+ ProcXF86VidModeLockModeSwitch(client);
+ case X_XF86VidModeSetViewPort:return
+ ProcXF86VidModeSetViewPort(client);
+ case X_XF86VidModeSetGamma:return
+ ProcXF86VidModeSetGamma(client);
+ case X_XF86VidModeSetGammaRamp:return
+ ProcXF86VidModeSetGammaRamp(client);
+ default:return BadRequest;
+ }}
+ else
+ return VidModeErrorBase + XF86VidModeClientNotLocal;
}
}
static int
-SProcXF86VidModeQueryVersion(ClientPtr client)
-{
+ SProcXF86VidModeQueryVersion(ClientPtr client) {
REQUEST(xXF86VidModeQueryVersionReq);
swaps(&stuff->length);
return ProcXF86VidModeQueryVersion(client);
-}
-
-static int
-SProcXF86VidModeGetModeLine(ClientPtr client)
-{
+} static int
+ SProcXF86VidModeGetModeLine(ClientPtr client) {
REQUEST(xXF86VidModeGetModeLineReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq);
swaps(&stuff->screen);
return ProcXF86VidModeGetModeLine(client);
-}
-
-static int
-SProcXF86VidModeGetAllModeLines(ClientPtr client)
-{
+} static int
+ SProcXF86VidModeGetAllModeLines(ClientPtr client) {
REQUEST(xXF86VidModeGetAllModeLinesReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq);
swaps(&stuff->screen);
return ProcXF86VidModeGetAllModeLines(client);
-}
-
-static int
-SProcXF86VidModeAddModeLine(ClientPtr client)
-{
+} static int
+ SProcXF86VidModeAddModeLine(ClientPtr client) {
xXF86OldVidModeAddModeLineReq *oldstuff =
- (xXF86OldVidModeAddModeLineReq *)client->requestBuffer;
+ (xXF86OldVidModeAddModeLineReq *) client->requestBuffer;
int ver;
-
- REQUEST(xXF86VidModeAddModeLineReq);
- ver = ClientMajorVersion(client);
+
+ REQUEST(xXF86VidModeAddModeLineReq);
+ ver = ClientMajorVersion(client);
if (ver < 2) {
- swaps(&oldstuff->length);
- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq);
- swapl(&oldstuff->screen);
- swaps(&oldstuff->hdisplay);
- swaps(&oldstuff->hsyncstart);
- swaps(&oldstuff->hsyncend);
- swaps(&oldstuff->htotal);
- swaps(&oldstuff->vdisplay);
- swaps(&oldstuff->vsyncstart);
- swaps(&oldstuff->vsyncend);
- swaps(&oldstuff->vtotal);
- swapl(&oldstuff->flags);
- swapl(&oldstuff->privsize);
- SwapRestL(oldstuff);
- } else {
- swaps(&stuff->length);
- REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq);
- swapl(&stuff->screen);
- swaps(&stuff->hdisplay);
- swaps(&stuff->hsyncstart);
- swaps(&stuff->hsyncend);
- swaps(&stuff->htotal);
- swaps(&stuff->hskew);
- swaps(&stuff->vdisplay);
- swaps(&stuff->vsyncstart);
- swaps(&stuff->vsyncend);
- swaps(&stuff->vtotal);
- swapl(&stuff->flags);
- swapl(&stuff->privsize);
- SwapRestL(stuff);
+ swaps(&oldstuff->length);
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq);
+ swapl(&oldstuff->screen);
+ swaps(&oldstuff->hdisplay);
+ swaps(&oldstuff->hsyncstart);
+ swaps(&oldstuff->hsyncend);
+ swaps(&oldstuff->htotal);
+ swaps(&oldstuff->vdisplay);
+ swaps(&oldstuff->vsyncstart);
+ swaps(&oldstuff->vsyncend);
+ swaps(&oldstuff->vtotal);
+ swapl(&oldstuff->flags);
+ swapl(&oldstuff->privsize);
+ SwapRestL(oldstuff);
+ }
+ else {
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq);
+ swapl(&stuff->screen);
+ swaps(&stuff->hdisplay);
+ swaps(&stuff->hsyncstart);
+ swaps(&stuff->hsyncend);
+ swaps(&stuff->htotal);
+ swaps(&stuff->hskew);
+ swaps(&stuff->vdisplay);
+ swaps(&stuff->vsyncstart);
+ swaps(&stuff->vsyncend);
+ swaps(&stuff->vtotal);
+ swapl(&stuff->flags);
+ swapl(&stuff->privsize);
+ SwapRestL(stuff);
}
return ProcXF86VidModeAddModeLine(client);
}
static int
-SProcXF86VidModeDeleteModeLine(ClientPtr client)
-{
+ SProcXF86VidModeDeleteModeLine(ClientPtr client) {
xXF86OldVidModeDeleteModeLineReq *oldstuff =
- (xXF86OldVidModeDeleteModeLineReq *)client->requestBuffer;
+ (xXF86OldVidModeDeleteModeLineReq *) client->requestBuffer;
int ver;
- REQUEST(xXF86VidModeDeleteModeLineReq);
- ver = ClientMajorVersion(client);
+ REQUEST(xXF86VidModeDeleteModeLineReq);
+ ver = ClientMajorVersion(client);
if (ver < 2) {
- swaps(&oldstuff->length);
- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq);
- swapl(&oldstuff->screen);
- swaps(&oldstuff->hdisplay);
- swaps(&oldstuff->hsyncstart);
- swaps(&oldstuff->hsyncend);
- swaps(&oldstuff->htotal);
- swaps(&oldstuff->vdisplay);
- swaps(&oldstuff->vsyncstart);
- swaps(&oldstuff->vsyncend);
- swaps(&oldstuff->vtotal);
- swapl(&oldstuff->flags);
- swapl(&oldstuff->privsize);
- SwapRestL(oldstuff);
- } else {
- swaps(&stuff->length);
- REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq);
- swapl(&stuff->screen);
- swaps(&stuff->hdisplay);
- swaps(&stuff->hsyncstart);
- swaps(&stuff->hsyncend);
- swaps(&stuff->htotal);
- swaps(&stuff->hskew);
- swaps(&stuff->vdisplay);
- swaps(&stuff->vsyncstart);
- swaps(&stuff->vsyncend);
- swaps(&stuff->vtotal);
- swapl(&stuff->flags);
- swapl(&stuff->privsize);
- SwapRestL(stuff);
+ swaps(&oldstuff->length);
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq);
+ swapl(&oldstuff->screen);
+ swaps(&oldstuff->hdisplay);
+ swaps(&oldstuff->hsyncstart);
+ swaps(&oldstuff->hsyncend);
+ swaps(&oldstuff->htotal);
+ swaps(&oldstuff->vdisplay);
+ swaps(&oldstuff->vsyncstart);
+ swaps(&oldstuff->vsyncend);
+ swaps(&oldstuff->vtotal);
+ swapl(&oldstuff->flags);
+ swapl(&oldstuff->privsize);
+ SwapRestL(oldstuff);
+ }
+ else {
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq);
+ swapl(&stuff->screen);
+ swaps(&stuff->hdisplay);
+ swaps(&stuff->hsyncstart);
+ swaps(&stuff->hsyncend);
+ swaps(&stuff->htotal);
+ swaps(&stuff->hskew);
+ swaps(&stuff->vdisplay);
+ swaps(&stuff->vsyncstart);
+ swaps(&stuff->vsyncend);
+ swaps(&stuff->vtotal);
+ swapl(&stuff->flags);
+ swapl(&stuff->privsize);
+ SwapRestL(stuff);
}
return ProcXF86VidModeDeleteModeLine(client);
}
static int
-SProcXF86VidModeModModeLine(ClientPtr client)
-{
+ SProcXF86VidModeModModeLine(ClientPtr client) {
xXF86OldVidModeModModeLineReq *oldstuff =
- (xXF86OldVidModeModModeLineReq *)client->requestBuffer;
+ (xXF86OldVidModeModModeLineReq *) client->requestBuffer;
int ver;
- REQUEST(xXF86VidModeModModeLineReq);
- ver = ClientMajorVersion(client);
+ REQUEST(xXF86VidModeModModeLineReq);
+ ver = ClientMajorVersion(client);
if (ver < 2) {
- swaps(&oldstuff->length);
- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq);
- swapl(&oldstuff->screen);
- swaps(&oldstuff->hdisplay);
- swaps(&oldstuff->hsyncstart);
- swaps(&oldstuff->hsyncend);
- swaps(&oldstuff->htotal);
- swaps(&oldstuff->vdisplay);
- swaps(&oldstuff->vsyncstart);
- swaps(&oldstuff->vsyncend);
- swaps(&oldstuff->vtotal);
- swapl(&oldstuff->flags);
- swapl(&oldstuff->privsize);
- SwapRestL(oldstuff);
- } else {
- swaps(&stuff->length);
- REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq);
- swapl(&stuff->screen);
- swaps(&stuff->hdisplay);
- swaps(&stuff->hsyncstart);
- swaps(&stuff->hsyncend);
- swaps(&stuff->htotal);
- swaps(&stuff->hskew);
- swaps(&stuff->vdisplay);
- swaps(&stuff->vsyncstart);
- swaps(&stuff->vsyncend);
- swaps(&stuff->vtotal);
- swapl(&stuff->flags);
- swapl(&stuff->privsize);
- SwapRestL(stuff);
+ swaps(&oldstuff->length);
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq);
+ swapl(&oldstuff->screen);
+ swaps(&oldstuff->hdisplay);
+ swaps(&oldstuff->hsyncstart);
+ swaps(&oldstuff->hsyncend);
+ swaps(&oldstuff->htotal);
+ swaps(&oldstuff->vdisplay);
+ swaps(&oldstuff->vsyncstart);
+ swaps(&oldstuff->vsyncend);
+ swaps(&oldstuff->vtotal);
+ swapl(&oldstuff->flags);
+ swapl(&oldstuff->privsize);
+ SwapRestL(oldstuff);
+ }
+ else {
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq);
+ swapl(&stuff->screen);
+ swaps(&stuff->hdisplay);
+ swaps(&stuff->hsyncstart);
+ swaps(&stuff->hsyncend);
+ swaps(&stuff->htotal);
+ swaps(&stuff->hskew);
+ swaps(&stuff->vdisplay);
+ swaps(&stuff->vsyncstart);
+ swaps(&stuff->vsyncend);
+ swaps(&stuff->vtotal);
+ swapl(&stuff->flags);
+ swapl(&stuff->privsize);
+ SwapRestL(stuff);
}
return ProcXF86VidModeModModeLine(client);
}
static int
-SProcXF86VidModeValidateModeLine(ClientPtr client)
-{
+ SProcXF86VidModeValidateModeLine(ClientPtr client) {
xXF86OldVidModeValidateModeLineReq *oldstuff =
- (xXF86OldVidModeValidateModeLineReq *)client->requestBuffer;
+ (xXF86OldVidModeValidateModeLineReq *) client->requestBuffer;
int ver;
- REQUEST(xXF86VidModeValidateModeLineReq);
- ver = ClientMajorVersion(client);
+ REQUEST(xXF86VidModeValidateModeLineReq);
+ ver = ClientMajorVersion(client);
if (ver < 2) {
- swaps(&oldstuff->length);
- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq);
- swapl(&oldstuff->screen);
- swaps(&oldstuff->hdisplay);
- swaps(&oldstuff->hsyncstart);
- swaps(&oldstuff->hsyncend);
- swaps(&oldstuff->htotal);
- swaps(&oldstuff->vdisplay);
- swaps(&oldstuff->vsyncstart);
- swaps(&oldstuff->vsyncend);
- swaps(&oldstuff->vtotal);
- swapl(&oldstuff->flags);
- swapl(&oldstuff->privsize);
- SwapRestL(oldstuff);
- } else {
- swaps(&stuff->length);
- REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq);
- swapl(&stuff->screen);
- swaps(&stuff->hdisplay);
- swaps(&stuff->hsyncstart);
- swaps(&stuff->hsyncend);
- swaps(&stuff->htotal);
- swaps(&stuff->hskew);
- swaps(&stuff->vdisplay);
- swaps(&stuff->vsyncstart);
- swaps(&stuff->vsyncend);
- swaps(&stuff->vtotal);
- swapl(&stuff->flags);
- swapl(&stuff->privsize);
- SwapRestL(stuff);
+ swaps(&oldstuff->length);
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq);
+ swapl(&oldstuff->screen);
+ swaps(&oldstuff->hdisplay);
+ swaps(&oldstuff->hsyncstart);
+ swaps(&oldstuff->hsyncend);
+ swaps(&oldstuff->htotal);
+ swaps(&oldstuff->vdisplay);
+ swaps(&oldstuff->vsyncstart);
+ swaps(&oldstuff->vsyncend);
+ swaps(&oldstuff->vtotal);
+ swapl(&oldstuff->flags);
+ swapl(&oldstuff->privsize);
+ SwapRestL(oldstuff);
+ }
+ else {
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq);
+ swapl(&stuff->screen);
+ swaps(&stuff->hdisplay);
+ swaps(&stuff->hsyncstart);
+ swaps(&stuff->hsyncend);
+ swaps(&stuff->htotal);
+ swaps(&stuff->hskew);
+ swaps(&stuff->vdisplay);
+ swaps(&stuff->vsyncstart);
+ swaps(&stuff->vsyncend);
+ swaps(&stuff->vtotal);
+ swapl(&stuff->flags);
+ swapl(&stuff->privsize);
+ SwapRestL(stuff);
}
return ProcXF86VidModeValidateModeLine(client);
}
static int
-SProcXF86VidModeSwitchMode(ClientPtr client)
-{
+ SProcXF86VidModeSwitchMode(ClientPtr client) {
REQUEST(xXF86VidModeSwitchModeReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq);
swaps(&stuff->screen);
swaps(&stuff->zoom);
return ProcXF86VidModeSwitchMode(client);
-}
-
-static int
-SProcXF86VidModeSwitchToMode(ClientPtr client)
-{
+} static int
+ SProcXF86VidModeSwitchToMode(ClientPtr client) {
REQUEST(xXF86VidModeSwitchToModeReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXF86VidModeSwitchToModeReq);
swapl(&stuff->screen);
return ProcXF86VidModeSwitchToMode(client);
-}
-
-static int
-SProcXF86VidModeLockModeSwitch(ClientPtr client)
-{
+} static int
+ SProcXF86VidModeLockModeSwitch(ClientPtr client) {
REQUEST(xXF86VidModeLockModeSwitchReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq);
swaps(&stuff->screen);
swaps(&stuff->lock);
return ProcXF86VidModeLockModeSwitch(client);
-}
-
-static int
-SProcXF86VidModeGetMonitor(ClientPtr client)
-{
+} static int
+ SProcXF86VidModeGetMonitor(ClientPtr client) {
REQUEST(xXF86VidModeGetMonitorReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq);
swaps(&stuff->screen);
return ProcXF86VidModeGetMonitor(client);
-}
-
-static int
-SProcXF86VidModeGetViewPort(ClientPtr client)
-{
+} static int
+ SProcXF86VidModeGetViewPort(ClientPtr client) {
REQUEST(xXF86VidModeGetViewPortReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq);
swaps(&stuff->screen);
return ProcXF86VidModeGetViewPort(client);
-}
-
-static int
-SProcXF86VidModeSetViewPort(ClientPtr client)
-{
+} static int
+ SProcXF86VidModeSetViewPort(ClientPtr client) {
REQUEST(xXF86VidModeSetViewPortReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq);
@@ -1891,32 +1843,23 @@ SProcXF86VidModeSetViewPort(ClientPtr client)
swapl(&stuff->x);
swapl(&stuff->y);
return ProcXF86VidModeSetViewPort(client);
-}
-
-static int
-SProcXF86VidModeGetDotClocks(ClientPtr client)
-{
+} static int
+ SProcXF86VidModeGetDotClocks(ClientPtr client) {
REQUEST(xXF86VidModeGetDotClocksReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq);
swaps(&stuff->screen);
return ProcXF86VidModeGetDotClocks(client);
-}
-
-static int
-SProcXF86VidModeSetClientVersion(ClientPtr client)
-{
+} static int
+ SProcXF86VidModeSetClientVersion(ClientPtr client) {
REQUEST(xXF86VidModeSetClientVersionReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq);
swaps(&stuff->major);
swaps(&stuff->minor);
return ProcXF86VidModeSetClientVersion(client);
-}
-
-static int
-SProcXF86VidModeSetGamma(ClientPtr client)
-{
+} static int
+ SProcXF86VidModeSetGamma(ClientPtr client) {
REQUEST(xXF86VidModeSetGammaReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq);
@@ -1925,174 +1868,149 @@ SProcXF86VidModeSetGamma(ClientPtr client)
swapl(&stuff->green);
swapl(&stuff->blue);
return ProcXF86VidModeSetGamma(client);
-}
-
-static int
-SProcXF86VidModeGetGamma(ClientPtr client)
-{
+} static int
+ SProcXF86VidModeGetGamma(ClientPtr client) {
REQUEST(xXF86VidModeGetGammaReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq);
swaps(&stuff->screen);
return ProcXF86VidModeGetGamma(client);
-}
-
-static int
-SProcXF86VidModeSetGammaRamp(ClientPtr client)
-{
+} static int
+ SProcXF86VidModeSetGammaRamp(ClientPtr client) {
int length;
- REQUEST(xXF86VidModeSetGammaRampReq);
- swaps(&stuff->length);
- REQUEST_AT_LEAST_SIZE(xXF86VidModeSetGammaRampReq);
- swaps(&stuff->size);
- swaps(&stuff->screen);
- length = ((stuff->size + 1) & ~1) * 6;
- REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length);
- SwapRestS(stuff);
- return ProcXF86VidModeSetGammaRamp(client);
-}
-
-static int
-SProcXF86VidModeGetGammaRamp(ClientPtr client)
-{
+ REQUEST(xXF86VidModeSetGammaRampReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeSetGammaRampReq);
+ swaps(&stuff->size);
+ swaps(&stuff->screen);
+ length = ((stuff->size + 1) & ~1) * 6;
+ REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length);
+ SwapRestS(stuff);
+ return ProcXF86VidModeSetGammaRamp(client);
+} static int
+ SProcXF86VidModeGetGammaRamp(ClientPtr client) {
REQUEST(xXF86VidModeGetGammaRampReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq);
swaps(&stuff->size);
swaps(&stuff->screen);
return ProcXF86VidModeGetGammaRamp(client);
-}
-
-static int
-SProcXF86VidModeGetGammaRampSize(ClientPtr client)
-{
+} static int
+ SProcXF86VidModeGetGammaRampSize(ClientPtr client) {
REQUEST(xXF86VidModeGetGammaRampSizeReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq);
swaps(&stuff->screen);
return ProcXF86VidModeGetGammaRampSize(client);
-}
-
-static int
-SProcXF86VidModeGetPermissions(ClientPtr client)
-{
+} static int
+ SProcXF86VidModeGetPermissions(ClientPtr client) {
REQUEST(xXF86VidModeGetPermissionsReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq);
swaps(&stuff->screen);
return ProcXF86VidModeGetPermissions(client);
-}
-
-
-static int
-SProcXF86VidModeDispatch(ClientPtr client)
-{
+} static int
+ SProcXF86VidModeDispatch(ClientPtr client) {
REQUEST(xReq);
- switch (stuff->data)
- {
+ switch (stuff->data) {
case X_XF86VidModeQueryVersion:
- return SProcXF86VidModeQueryVersion(client);
- case X_XF86VidModeGetModeLine:
- return SProcXF86VidModeGetModeLine(client);
- case X_XF86VidModeGetMonitor:
- return SProcXF86VidModeGetMonitor(client);
- case X_XF86VidModeGetAllModeLines:
- return SProcXF86VidModeGetAllModeLines(client);
- case X_XF86VidModeGetViewPort:
- return SProcXF86VidModeGetViewPort(client);
- case X_XF86VidModeValidateModeLine:
- return SProcXF86VidModeValidateModeLine(client);
- case X_XF86VidModeGetDotClocks:
- return SProcXF86VidModeGetDotClocks(client);
- case X_XF86VidModeSetClientVersion:
- return SProcXF86VidModeSetClientVersion(client);
- case X_XF86VidModeGetGamma:
- return SProcXF86VidModeGetGamma(client);
- case X_XF86VidModeGetGammaRamp:
- return SProcXF86VidModeGetGammaRamp(client);
- case X_XF86VidModeGetGammaRampSize:
- return SProcXF86VidModeGetGammaRampSize(client);
- case X_XF86VidModeGetPermissions:
- return SProcXF86VidModeGetPermissions(client);
- default:
- if (!xf86GetVidModeEnabled())
- return VidModeErrorBase + XF86VidModeExtensionDisabled;
- if (xf86GetVidModeAllowNonLocal() || LocalClient(client)) {
- switch (stuff->data) {
- case X_XF86VidModeAddModeLine:
- return SProcXF86VidModeAddModeLine(client);
- case X_XF86VidModeDeleteModeLine:
- return SProcXF86VidModeDeleteModeLine(client);
- case X_XF86VidModeModModeLine:
- return SProcXF86VidModeModModeLine(client);
- case X_XF86VidModeSwitchMode:
- return SProcXF86VidModeSwitchMode(client);
- case X_XF86VidModeSwitchToMode:
- return SProcXF86VidModeSwitchToMode(client);
- case X_XF86VidModeLockModeSwitch:
- return SProcXF86VidModeLockModeSwitch(client);
- case X_XF86VidModeSetViewPort:
- return SProcXF86VidModeSetViewPort(client);
- case X_XF86VidModeSetGamma:
- return SProcXF86VidModeSetGamma(client);
- case X_XF86VidModeSetGammaRamp:
- return SProcXF86VidModeSetGammaRamp(client);
- default:
- return BadRequest;
- }
- } else
- return VidModeErrorBase + XF86VidModeClientNotLocal;
+ return SProcXF86VidModeQueryVersion(client);
+ case X_XF86VidModeGetModeLine:return
+ SProcXF86VidModeGetModeLine(client);
+ case X_XF86VidModeGetMonitor:return SProcXF86VidModeGetMonitor(client);
+ case X_XF86VidModeGetAllModeLines:return
+ SProcXF86VidModeGetAllModeLines(client);
+ case X_XF86VidModeGetViewPort:return
+ SProcXF86VidModeGetViewPort(client);
+ case X_XF86VidModeValidateModeLine:return
+ SProcXF86VidModeValidateModeLine(client);
+ case X_XF86VidModeGetDotClocks:return
+ SProcXF86VidModeGetDotClocks(client);
+ case X_XF86VidModeSetClientVersion:return
+ SProcXF86VidModeSetClientVersion(client);
+ case X_XF86VidModeGetGamma:return SProcXF86VidModeGetGamma(client);
+ case X_XF86VidModeGetGammaRamp:return
+ SProcXF86VidModeGetGammaRamp(client);
+ case X_XF86VidModeGetGammaRampSize:return
+ SProcXF86VidModeGetGammaRampSize(client);
+ case X_XF86VidModeGetPermissions:return
+ SProcXF86VidModeGetPermissions(client);
+ default:if (!xf86GetVidModeEnabled())
+ return VidModeErrorBase + XF86VidModeExtensionDisabled;
+ if (xf86GetVidModeAllowNonLocal() || LocalClient(client)) {
+ switch (stuff->data) {
+ case X_XF86VidModeAddModeLine:
+ return SProcXF86VidModeAddModeLine(client);
+ case X_XF86VidModeDeleteModeLine:return
+ SProcXF86VidModeDeleteModeLine(client);
+ case X_XF86VidModeModModeLine:return
+ SProcXF86VidModeModModeLine(client);
+ case X_XF86VidModeSwitchMode:return
+ SProcXF86VidModeSwitchMode(client);
+ case X_XF86VidModeSwitchToMode:return
+ SProcXF86VidModeSwitchToMode(client);
+ case X_XF86VidModeLockModeSwitch:return
+ SProcXF86VidModeLockModeSwitch(client);
+ case X_XF86VidModeSetViewPort:return
+ SProcXF86VidModeSetViewPort(client);
+ case X_XF86VidModeSetGamma:return
+ SProcXF86VidModeSetGamma(client);
+ case X_XF86VidModeSetGammaRamp:return
+ SProcXF86VidModeSetGammaRamp(client);
+ default:return BadRequest;
+ }}
+ else
+ return VidModeErrorBase + XF86VidModeClientNotLocal;
}
}
void
-XFree86VidModeExtensionInit(void)
-{
- ExtensionEntry* extEntry;
+ XFree86VidModeExtensionInit(void) {
+ ExtensionEntry *extEntry;
ScreenPtr pScreen;
- int i;
- Bool enabled = FALSE;
+ int i;
+ Bool enabled = FALSE;
- DEBUG_P("XFree86VidModeExtensionInit");
+ DEBUG_P("XFree86VidModeExtensionInit");
if (!dixRegisterPrivateKey(&VidModeClientPrivateKeyRec, PRIVATE_CLIENT, 0))
- return;
+ return;
#ifdef XF86VIDMODE_EVENTS
if (!dixRegisterPrivateKey(&ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
- return;
+ return;
#endif
#ifdef XF86VIDMODE_EVENTS
- EventType = CreateNewResourceType(XF86VidModeFreeEvents, "VidModeEvent");
+ EventType = CreateNewResourceType(XF86VidModeFreeEvents, "VidModeEvent");
#endif
- for(i = 0; i < screenInfo.numScreens; i++) {
+ for (i = 0; i < screenInfo.numScreens; i++) {
pScreen = screenInfo.screens[i];
- if (VidModeExtensionInit(pScreen))
- enabled = TRUE;
+ if (VidModeExtensionInit(pScreen))
+ enabled = TRUE;
}
/* This means that the DDX doesn't want the vidmode extension enabled */
- if (!enabled)
- return;
+ if (!enabled)
+ return;
if (
#ifdef XF86VIDMODE_EVENTS
- EventType &&
+ EventType &&
#endif
- (extEntry = AddExtension(XF86VIDMODENAME,
- XF86VidModeNumberEvents,
- XF86VidModeNumberErrors,
- ProcXF86VidModeDispatch,
- SProcXF86VidModeDispatch,
- NULL,
- StandardMinorOpcode))) {
+ (extEntry = AddExtension(XF86VIDMODENAME,
+ XF86VidModeNumberEvents,
+ XF86VidModeNumberErrors,
+ ProcXF86VidModeDispatch,
+ SProcXF86VidModeDispatch,
+ NULL, StandardMinorOpcode))) {
#if 0
- XF86VidModeReqCode = (unsigned char)extEntry->base;
+ XF86VidModeReqCode = (unsigned char) extEntry->base;
#endif
- VidModeErrorBase = extEntry->errorBase;
+ VidModeErrorBase = extEntry->errorBase;
#ifdef XF86VIDMODE_EVENTS
- XF86VidModeEventBase = extEntry->eventBase;
- EventSwapVector[XF86VidModeEventBase] = (EventSwapPtr)SXF86VidModeNotifyEvent;
+ XF86VidModeEventBase = extEntry->eventBase;
+ EventSwapVector[XF86VidModeEventBase] =
+ (EventSwapPtr) SXF86VidModeNotifyEvent;
#endif
}
}
diff --git a/xorg-server/hw/xfree86/dixmods/fbmodule.c b/xorg-server/hw/xfree86/dixmods/fbmodule.c
index 4df2646dd..5895ba296 100644
--- a/xorg-server/hw/xfree86/dixmods/fbmodule.c
+++ b/xorg-server/hw/xfree86/dixmods/fbmodule.c
@@ -31,22 +31,22 @@
#include "xf86Module.h"
#include "fb.h"
-static XF86ModuleVersionInfo VersRec =
-{
+static XF86ModuleVersionInfo VersRec = {
#ifdef FB_ACCESS_WRAPPER
- "wfb",
+ "wfb",
#else
- "fb",
+ "fb",
#endif
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 0, 0,
- ABI_CLASS_ANSIC, /* Only need the ansic layer */
- ABI_ANSIC_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0} /* signature, to be patched into the file by a tool */
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_ANSIC, /* Only need the ansic layer */
+ ABI_ANSIC_VERSION,
+ MOD_CLASS_NONE,
+ {0, 0, 0, 0} /* signature, to be patched into the file by a tool */
};
-_X_EXPORT XF86ModuleData FBPREFIX(ModuleData) = { &VersRec, NULL, NULL };
+_X_EXPORT XF86ModuleData FBPREFIX(ModuleData) = {
+&VersRec, NULL, NULL};
diff --git a/xorg-server/hw/xfree86/dixmods/glxmodule.c b/xorg-server/hw/xfree86/dixmods/glxmodule.c
index 62a047e26..e72f3821a 100644
--- a/xorg-server/hw/xfree86/dixmods/glxmodule.c
+++ b/xorg-server/hw/xfree86/dixmods/glxmodule.c
@@ -47,8 +47,7 @@ static MODULESETUPPROTO(glxSetup);
static const char *initdeps[] = { "DOUBLE-BUFFER", "COMPOSITE", NULL };
-static ExtensionModule GLXExt =
-{
+static ExtensionModule GLXExt = {
GlxExtensionInit,
"GLX",
&noGlxExtension,
@@ -56,18 +55,17 @@ static ExtensionModule GLXExt =
initdeps
};
-static XF86ModuleVersionInfo VersRec =
-{
- "glx",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 0, 0,
- ABI_CLASS_EXTENSION,
- ABI_EXTENSION_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0}
+static XF86ModuleVersionInfo VersRec = {
+ "glx",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_EXTENSION,
+ ABI_EXTENSION_VERSION,
+ MOD_CLASS_NONE,
+ {0, 0, 0, 0}
};
_X_EXPORT XF86ModuleData glxModuleData = { &VersRec, glxSetup, NULL };
@@ -79,26 +77,27 @@ glxSetup(pointer module, pointer opts, int *errmaj, int *errmin)
__GLXprovider *provider;
if (setupDone) {
- if (errmaj) *errmaj = LDR_ONCEONLY;
- return NULL;
- }
+ if (errmaj)
+ *errmaj = LDR_ONCEONLY;
+ return NULL;
+ }
setupDone = TRUE;
provider = LoaderSymbol("__glXDRISWRastProvider");
if (provider == NULL)
- return NULL;
+ return NULL;
GlxPushProvider(provider);
- xf86Msg(xf86Info.aiglxFrom, "AIGLX %s\n",
- xf86Info.aiglx ? "enabled" : "disabled");
+ xf86Msg(xf86Info.aiglxFrom, "AIGLX %s\n",
+ xf86Info.aiglx ? "enabled" : "disabled");
if (xf86Info.aiglx) {
- provider = LoaderSymbol("__glXDRIProvider");
- if (provider)
- GlxPushProvider(provider);
- provider = LoaderSymbol("__glXDRI2Provider");
- if (provider)
- GlxPushProvider(provider);
+ provider = LoaderSymbol("__glXDRIProvider");
+ if (provider)
+ GlxPushProvider(provider);
+ provider = LoaderSymbol("__glXDRI2Provider");
+ if (provider)
+ GlxPushProvider(provider);
}
LoadExtension(&GLXExt, FALSE);
diff --git a/xorg-server/hw/xfree86/dixmods/shmodule.c b/xorg-server/hw/xfree86/dixmods/shmodule.c
index 3136c0c05..0cbb9df71 100644
--- a/xorg-server/hw/xfree86/dixmods/shmodule.c
+++ b/xorg-server/hw/xfree86/dixmods/shmodule.c
@@ -37,18 +37,17 @@
#include "gcstruct.h"
#include "shadow.h"
-static XF86ModuleVersionInfo VersRec =
-{
- "shadow",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 1, 0,
- ABI_CLASS_ANSIC, /* Only need the ansic layer */
- ABI_ANSIC_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0} /* signature, to be patched into the file by a tool */
+static XF86ModuleVersionInfo VersRec = {
+ "shadow",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 1, 0,
+ ABI_CLASS_ANSIC, /* Only need the ansic layer */
+ ABI_ANSIC_VERSION,
+ MOD_CLASS_NONE,
+ {0, 0, 0, 0} /* signature, to be patched into the file by a tool */
};
_X_EXPORT XF86ModuleData shadowModuleData = { &VersRec, NULL, NULL };
diff --git a/xorg-server/hw/xfree86/dri/dri.c b/xorg-server/hw/xfree86/dri/dri.c
index 1726960ae..9530eb40e 100644
--- a/xorg-server/hw/xfree86/dri/dri.c
+++ b/xorg-server/hw/xfree86/dri/dri.c
@@ -71,23 +71,25 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
static int DRIEntPrivIndex = -1;
static DevPrivateKeyRec DRIScreenPrivKeyRec;
+
#define DRIScreenPrivKey (&DRIScreenPrivKeyRec)
static DevPrivateKeyRec DRIWindowPrivKeyRec;
+
#define DRIWindowPrivKey (&DRIWindowPrivKeyRec)
static unsigned long DRIGeneration = 0;
static unsigned int DRIDrawableValidationStamp = 0;
static RESTYPE DRIDrawablePrivResType;
static RESTYPE DRIContextPrivResType;
-static void DRIDestroyDummyContext(ScreenPtr pScreen, Bool hasCtxPriv);
+static void DRIDestroyDummyContext(ScreenPtr pScreen, Bool hasCtxPriv);
drmServerInfo DRIDRMServerInfo;
- /* Wrapper just like xf86DrvMsg, but
- without the verbosity level checking.
- This will make it easy to turn off some
- messages later, based on verbosity
- level. */
+ /* Wrapper just like xf86DrvMsg, but
+ without the verbosity level checking.
+ This will make it easy to turn off some
+ messages later, based on verbosity
+ level. */
/*
* Since we're already referencing things from the XFree86 common layer in
@@ -99,27 +101,26 @@ drmServerInfo DRIDRMServerInfo;
static void
DRIDrvMsg(int scrnIndex, MessageType type, const char *format, ...)
{
- va_list ap;
+ va_list ap;
va_start(ap, format);
xf86VDrvMsgVerb(scrnIndex, type, DRI_MSG_VERBOSITY, format, ap);
va_end(ap);
}
-
static void
DRIOpenDRMCleanup(DRIEntPrivPtr pDRIEntPriv)
{
if (pDRIEntPriv->pLSAREA != NULL) {
- drmUnmap(pDRIEntPriv->pLSAREA, pDRIEntPriv->sAreaSize);
- pDRIEntPriv->pLSAREA = NULL;
+ drmUnmap(pDRIEntPriv->pLSAREA, pDRIEntPriv->sAreaSize);
+ pDRIEntPriv->pLSAREA = NULL;
}
if (pDRIEntPriv->hLSAREA != 0) {
- drmRmMap(pDRIEntPriv->drmFD, pDRIEntPriv->hLSAREA);
+ drmRmMap(pDRIEntPriv->drmFD, pDRIEntPriv->hLSAREA);
}
if (pDRIEntPriv->drmFD >= 0) {
- drmClose(pDRIEntPriv->drmFD);
- pDRIEntPriv->drmFD = 0;
+ drmClose(pDRIEntPriv->drmFD);
+ pDRIEntPriv->drmFD = 0;
}
}
@@ -141,12 +142,10 @@ DRIMasterSareaHandle(ScrnInfoPtr pScrn)
return DRI_ENT_PRIV(pScrn)->hLSAREA;
}
-
Bool
DRIOpenDRMMaster(ScrnInfoPtr pScrn,
- unsigned long sAreaSize,
- const char *busID,
- const char *drmDriverName)
+ unsigned long sAreaSize,
+ const char *busID, const char *drmDriverName)
{
drmSetVersion saveSv, sv;
Bool drmWasAvailable;
@@ -159,12 +158,12 @@ DRIOpenDRMMaster(ScrnInfoPtr pScrn,
int err;
if (DRIEntPrivIndex == -1)
- DRIEntPrivIndex = xf86AllocateEntityPrivateIndex();
+ DRIEntPrivIndex = xf86AllocateEntityPrivateIndex();
pDRIEntPriv = DRI_ENT_PRIV(pScrn);
if (pDRIEntPriv && pDRIEntPriv->drmFD != -1)
- return TRUE;
+ return TRUE;
drmWasAvailable = drmAvailable();
@@ -178,12 +177,12 @@ DRIOpenDRMMaster(ScrnInfoPtr pScrn,
drmlibmajor = 1;
drmlibminor = 0;
if (xf86LoaderCheckSymbol("drmGetLibVersion")) {
- drmlibv = drmGetLibVersion(-1);
- if (drmlibv != NULL) {
- drmlibmajor = drmlibv->version_major;
- drmlibminor = drmlibv->version_minor;
- drmFreeVersion(drmlibv);
- }
+ drmlibv = drmGetLibVersion(-1);
+ if (drmlibv != NULL) {
+ drmlibmajor = drmlibv->version_major;
+ drmlibminor = drmlibv->version_minor;
+ drmFreeVersion(drmlibv);
+ }
}
/* Check if the libdrm can handle falling back to loading based on name
@@ -199,69 +198,69 @@ DRIOpenDRMMaster(ScrnInfoPtr pScrn,
saveSv = sv;
count = 10;
while (count--) {
- tmp.drmFD = drmOpen(drmDriverName, openBusID);
+ tmp.drmFD = drmOpen(drmDriverName, openBusID);
- if (tmp.drmFD < 0) {
- DRIDrvMsg(-1, X_ERROR, "[drm] drmOpen failed.\n");
- goto out_err;
- }
+ if (tmp.drmFD < 0) {
+ DRIDrvMsg(-1, X_ERROR, "[drm] drmOpen failed.\n");
+ goto out_err;
+ }
- err = drmSetInterfaceVersion(tmp.drmFD, &sv);
+ err = drmSetInterfaceVersion(tmp.drmFD, &sv);
- if (err != -EPERM)
- break;
+ if (err != -EPERM)
+ break;
- sv = saveSv;
- drmClose(tmp.drmFD);
- tmp.drmFD = -1;
- usleep(100000);
+ sv = saveSv;
+ drmClose(tmp.drmFD);
+ tmp.drmFD = -1;
+ usleep(100000);
}
if (tmp.drmFD <= 0) {
- DRIDrvMsg(-1, X_ERROR, "[drm] DRM was busy with another master.\n");
- goto out_err;
+ DRIDrvMsg(-1, X_ERROR, "[drm] DRM was busy with another master.\n");
+ goto out_err;
}
if (!drmWasAvailable) {
- DRIDrvMsg(-1, X_INFO,
- "[drm] loaded kernel module for \"%s\" driver.\n",
- drmDriverName);
+ DRIDrvMsg(-1, X_INFO,
+ "[drm] loaded kernel module for \"%s\" driver.\n",
+ drmDriverName);
}
if (err != 0) {
- sv.drm_di_major = 1;
- sv.drm_di_minor = 0;
+ sv.drm_di_major = 1;
+ sv.drm_di_minor = 0;
}
DRIDrvMsg(-1, X_INFO, "[drm] DRM interface version %d.%d\n",
- sv.drm_di_major, sv.drm_di_minor);
+ sv.drm_di_major, sv.drm_di_minor);
if (sv.drm_di_major == 1 && sv.drm_di_minor >= 1)
- err = 0;
+ err = 0;
else
- err = drmSetBusid(tmp.drmFD, busID);
+ err = drmSetBusid(tmp.drmFD, busID);
if (err) {
- DRIDrvMsg(-1, X_ERROR, "[drm] Could not set DRM device bus ID.\n");
- goto out_err;
+ DRIDrvMsg(-1, X_ERROR, "[drm] Could not set DRM device bus ID.\n");
+ goto out_err;
}
/*
* Create a lock-containing sarea.
*/
- if (drmAddMap( tmp.drmFD, 0, sAreaSize, DRM_SHM,
- DRM_CONTAINS_LOCK, &tmp.hLSAREA) < 0) {
+ if (drmAddMap(tmp.drmFD, 0, sAreaSize, DRM_SHM,
+ DRM_CONTAINS_LOCK, &tmp.hLSAREA) < 0) {
DRIDrvMsg(-1, X_INFO, "[drm] Could not create SAREA for DRM lock.\n");
- tmp.hLSAREA = 0;
- goto out_err;
+ tmp.hLSAREA = 0;
+ goto out_err;
}
- if (drmMap( tmp.drmFD, tmp.hLSAREA, sAreaSize,
- (drmAddressPtr)(&tmp.pLSAREA)) < 0) {
+ if (drmMap(tmp.drmFD, tmp.hLSAREA, sAreaSize,
+ (drmAddressPtr) (&tmp.pLSAREA)) < 0) {
DRIDrvMsg(-1, X_INFO, "[drm] Mapping SAREA for DRM lock failed.\n");
- tmp.pLSAREA = NULL;
- goto out_err;
+ tmp.pLSAREA = NULL;
+ goto out_err;
}
memset(tmp.pLSAREA, 0, sAreaSize);
@@ -273,62 +272,64 @@ DRIOpenDRMMaster(ScrnInfoPtr pScrn,
tmp.resOwner = NULL;
if (!pDRIEntPriv)
- pDRIEntPriv = xnfcalloc(sizeof(*pDRIEntPriv), 1);
+ pDRIEntPriv = xnfcalloc(sizeof(*pDRIEntPriv), 1);
if (!pDRIEntPriv) {
DRIDrvMsg(-1, X_INFO, "[drm] Failed to allocate memory for "
- "DRM device.\n");
- goto out_err;
+ "DRM device.\n");
+ goto out_err;
}
*pDRIEntPriv = tmp;
- xf86GetEntityPrivate((pScrn)->entityList[0],DRIEntPrivIndex)->ptr =
- pDRIEntPriv;
+ xf86GetEntityPrivate((pScrn)->entityList[0], DRIEntPrivIndex)->ptr =
+ pDRIEntPriv;
DRIDrvMsg(-1, X_INFO, "[drm] DRM open master succeeded.\n");
return TRUE;
- out_err:
+ out_err:
DRIOpenDRMCleanup(&tmp);
return FALSE;
}
static void
-DRIClipNotifyAllDrawables(ScreenPtr pScreen);
+ DRIClipNotifyAllDrawables(ScreenPtr pScreen);
static void
dri_crtc_notify(ScreenPtr pScreen)
{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
DRIClipNotifyAllDrawables(pScreen);
xf86_unwrap_crtc_notify(pScreen, pDRIPriv->xf86_crtc_notify);
xf86_crtc_notify(pScreen);
- pDRIPriv->xf86_crtc_notify = xf86_wrap_crtc_notify(pScreen, dri_crtc_notify);
+ pDRIPriv->xf86_crtc_notify =
+ xf86_wrap_crtc_notify(pScreen, dri_crtc_notify);
}
Bool
DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
{
- DRIScreenPrivPtr pDRIPriv;
- drm_context_t * reserved;
- int reserved_count;
- int i;
- DRIEntPrivPtr pDRIEntPriv;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- DRIContextFlags flags = 0;
- DRIContextPrivPtr pDRIContextPriv;
+ DRIScreenPrivPtr pDRIPriv;
+ drm_context_t *reserved;
+ int reserved_count;
+ int i;
+ DRIEntPrivPtr pDRIEntPriv;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ DRIContextFlags flags = 0;
+ DRIContextPrivPtr pDRIContextPriv;
/* If the DRI extension is disabled, do not initialize the DRI */
if (noXFree86DRIExtension) {
- DRIDrvMsg(pScreen->myNum, X_WARNING,
- "Direct rendering has been disabled.\n");
- return FALSE;
+ DRIDrvMsg(pScreen->myNum, X_WARNING,
+ "Direct rendering has been disabled.\n");
+ return FALSE;
}
if (!xf86VGAarbiterAllowDRI(pScreen)) {
DRIDrvMsg(pScreen->myNum, X_WARNING,
"Direct rendering is not supported when VGA arb is necessary for the device\n");
- return FALSE;
+ return FALSE;
}
#ifdef PANORAMIX
@@ -336,31 +337,30 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
* If Xinerama is on, don't allow DRI to initialise. It won't be usable
* anyway.
*/
- if (!noPanoramiXExtension) {
- DRIDrvMsg(pScreen->myNum, X_WARNING,
- "Direct rendering is not supported when Xinerama is enabled\n");
- return FALSE;
- }
+ if (!noPanoramiXExtension) {
+ DRIDrvMsg(pScreen->myNum, X_WARNING,
+ "Direct rendering is not supported when Xinerama is enabled\n");
+ return FALSE;
+ }
#endif
if (!DRIOpenDRMMaster(pScrn, pDRIInfo->SAREASize,
- pDRIInfo->busIdString,
- pDRIInfo->drmDriverName))
- return FALSE;
+ pDRIInfo->busIdString, pDRIInfo->drmDriverName))
+ return FALSE;
pDRIEntPriv = DRI_ENT_PRIV(pScrn);
if (DRIGeneration != serverGeneration)
- DRIGeneration = serverGeneration;
+ DRIGeneration = serverGeneration;
if (!dixRegisterPrivateKey(&DRIScreenPrivKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
+ return FALSE;
if (!dixRegisterPrivateKey(&DRIWindowPrivKeyRec, PRIVATE_WINDOW, 0))
- return FALSE;
+ return FALSE;
pDRIPriv = (DRIScreenPrivPtr) calloc(1, sizeof(DRIScreenPrivRec));
if (!pDRIPriv) {
- dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
return FALSE;
}
@@ -372,7 +372,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
pDRIPriv->nrWindowsVisible = 0;
pDRIPriv->fullscreen = NULL;
- pDRIPriv->createDummyCtx = pDRIInfo->createDummyCtx;
+ pDRIPriv->createDummyCtx = pDRIInfo->createDummyCtx;
pDRIPriv->createDummyCtxPriv = pDRIInfo->createDummyCtxPriv;
pDRIPriv->grabbedDRILock = FALSE;
@@ -381,141 +381,132 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
if (pDRIEntPriv->sAreaGrabbed || pDRIInfo->allocSarea) {
- if (drmAddMap( pDRIPriv->drmFD,
- 0,
- pDRIPriv->pDriverInfo->SAREASize,
- DRM_SHM,
- 0,
- &pDRIPriv->hSAREA) < 0)
- {
- pDRIPriv->directRenderingSupport = FALSE;
- dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
- drmClose(pDRIPriv->drmFD);
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] drmAddMap failed\n");
- return FALSE;
- }
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] added %d byte SAREA at %p\n",
- pDRIPriv->pDriverInfo->SAREASize, pDRIPriv->hSAREA);
-
- /* Backwards compat. */
- if (drmMap( pDRIPriv->drmFD,
- pDRIPriv->hSAREA,
- pDRIPriv->pDriverInfo->SAREASize,
- (drmAddressPtr)(&pDRIPriv->pSAREA)) < 0)
- {
- pDRIPriv->directRenderingSupport = FALSE;
- dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
- drmClose(pDRIPriv->drmFD);
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] drmMap failed\n");
- return FALSE;
- }
- DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] mapped SAREA %p to %p\n",
- pDRIPriv->hSAREA, pDRIPriv->pSAREA);
- memset(pDRIPriv->pSAREA, 0, pDRIPriv->pDriverInfo->SAREASize);
- } else {
- DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] Using the DRM lock "
- "SAREA also for drawables.\n");
- pDRIPriv->hSAREA = pDRIEntPriv->hLSAREA;
- pDRIPriv->pSAREA = (XF86DRISAREAPtr) pDRIEntPriv->pLSAREA;
- pDRIEntPriv->sAreaGrabbed = TRUE;
+ if (drmAddMap(pDRIPriv->drmFD,
+ 0,
+ pDRIPriv->pDriverInfo->SAREASize,
+ DRM_SHM, 0, &pDRIPriv->hSAREA) < 0) {
+ pDRIPriv->directRenderingSupport = FALSE;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
+ drmClose(pDRIPriv->drmFD);
+ DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] drmAddMap failed\n");
+ return FALSE;
+ }
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] added %d byte SAREA at %p\n",
+ pDRIPriv->pDriverInfo->SAREASize, pDRIPriv->hSAREA);
+
+ /* Backwards compat. */
+ if (drmMap(pDRIPriv->drmFD,
+ pDRIPriv->hSAREA,
+ pDRIPriv->pDriverInfo->SAREASize,
+ (drmAddressPtr) (&pDRIPriv->pSAREA)) < 0) {
+ pDRIPriv->directRenderingSupport = FALSE;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
+ drmClose(pDRIPriv->drmFD);
+ DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] drmMap failed\n");
+ return FALSE;
+ }
+ DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] mapped SAREA %p to %p\n",
+ pDRIPriv->hSAREA, pDRIPriv->pSAREA);
+ memset(pDRIPriv->pSAREA, 0, pDRIPriv->pDriverInfo->SAREASize);
+ }
+ else {
+ DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] Using the DRM lock "
+ "SAREA also for drawables.\n");
+ pDRIPriv->hSAREA = pDRIEntPriv->hLSAREA;
+ pDRIPriv->pSAREA = (XF86DRISAREAPtr) pDRIEntPriv->pLSAREA;
+ pDRIEntPriv->sAreaGrabbed = TRUE;
}
pDRIPriv->hLSAREA = pDRIEntPriv->hLSAREA;
pDRIPriv->pLSAREA = pDRIEntPriv->pLSAREA;
- if (!pDRIPriv->pDriverInfo->dontMapFrameBuffer)
- {
- if (drmAddMap( pDRIPriv->drmFD,
- (uintptr_t)pDRIPriv->pDriverInfo->frameBufferPhysicalAddress,
- pDRIPriv->pDriverInfo->frameBufferSize,
- DRM_FRAME_BUFFER,
- 0,
- &pDRIPriv->pDriverInfo->hFrameBuffer) < 0)
- {
- pDRIPriv->directRenderingSupport = FALSE;
- dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
- drmUnmap(pDRIPriv->pSAREA, pDRIPriv->pDriverInfo->SAREASize);
- drmClose(pDRIPriv->drmFD);
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] drmAddMap failed\n");
- return FALSE;
- }
- DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] framebuffer handle = %p\n",
- pDRIPriv->pDriverInfo->hFrameBuffer);
- } else {
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] framebuffer mapped by ddx driver\n");
+ if (!pDRIPriv->pDriverInfo->dontMapFrameBuffer) {
+ if (drmAddMap(pDRIPriv->drmFD,
+ (uintptr_t) pDRIPriv->pDriverInfo->
+ frameBufferPhysicalAddress,
+ pDRIPriv->pDriverInfo->frameBufferSize, DRM_FRAME_BUFFER,
+ 0, &pDRIPriv->pDriverInfo->hFrameBuffer) < 0) {
+ pDRIPriv->directRenderingSupport = FALSE;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
+ drmUnmap(pDRIPriv->pSAREA, pDRIPriv->pDriverInfo->SAREASize);
+ drmClose(pDRIPriv->drmFD);
+ DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] drmAddMap failed\n");
+ return FALSE;
+ }
+ DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] framebuffer handle = %p\n",
+ pDRIPriv->pDriverInfo->hFrameBuffer);
+ }
+ else {
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] framebuffer mapped by ddx driver\n");
}
if (pDRIEntPriv->resOwner == NULL) {
- pDRIEntPriv->resOwner = pScreen;
-
- /* Add tags for reserved contexts */
- if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
- &reserved_count))) {
- int i;
- void *tag;
-
- for (i = 0; i < reserved_count; i++) {
- tag = DRICreateContextPrivFromHandle(pScreen,
- reserved[i],
- DRI_CONTEXT_RESERVED);
- drmAddContextTag(pDRIPriv->drmFD, reserved[i], tag);
- }
- drmFreeReservedContextList(reserved);
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] added %d reserved context%s for kernel\n",
- reserved_count, reserved_count > 1 ? "s" : "");
- }
+ pDRIEntPriv->resOwner = pScreen;
+
+ /* Add tags for reserved contexts */
+ if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
+ &reserved_count))) {
+ int i;
+ void *tag;
+
+ for (i = 0; i < reserved_count; i++) {
+ tag = DRICreateContextPrivFromHandle(pScreen,
+ reserved[i],
+ DRI_CONTEXT_RESERVED);
+ drmAddContextTag(pDRIPriv->drmFD, reserved[i], tag);
+ }
+ drmFreeReservedContextList(reserved);
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] added %d reserved context%s for kernel\n",
+ reserved_count, reserved_count > 1 ? "s" : "");
+ }
}
/* validate max drawable table entry set by driver */
if ((pDRIPriv->pDriverInfo->maxDrawableTableEntry <= 0) ||
(pDRIPriv->pDriverInfo->maxDrawableTableEntry > SAREA_MAX_DRAWABLES)) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "Invalid max drawable table size set by driver: %d\n",
- pDRIPriv->pDriverInfo->maxDrawableTableEntry);
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "Invalid max drawable table size set by driver: %d\n",
+ pDRIPriv->pDriverInfo->maxDrawableTableEntry);
}
/* Initialize drawable tables (screen private and SAREA) */
- for( i=0; i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; i++) {
- pDRIPriv->DRIDrawables[i] = NULL;
- pDRIPriv->pSAREA->drawableTable[i].stamp = 0;
- pDRIPriv->pSAREA->drawableTable[i].flags = 0;
+ for (i = 0; i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; i++) {
+ pDRIPriv->DRIDrawables[i] = NULL;
+ pDRIPriv->pSAREA->drawableTable[i].stamp = 0;
+ pDRIPriv->pSAREA->drawableTable[i].flags = 0;
}
pDRIPriv->pLockRefCount = &pDRIEntPriv->lockRefCount;
pDRIPriv->pLockingContext = &pDRIEntPriv->lockingContext;
if (!pDRIEntPriv->keepFDOpen)
- pDRIEntPriv->keepFDOpen = pDRIInfo->keepFDOpen;
+ pDRIEntPriv->keepFDOpen = pDRIInfo->keepFDOpen;
pDRIEntPriv->refCount++;
/* Set up flags for DRICreateContextPriv */
switch (pDRIInfo->driverSwapMethod) {
case DRI_KERNEL_SWAP:
- flags = DRI_CONTEXT_2DONLY;
- break;
+ flags = DRI_CONTEXT_2DONLY;
+ break;
case DRI_HIDE_X_CONTEXT:
- flags = DRI_CONTEXT_PRESERVED;
- break;
+ flags = DRI_CONTEXT_PRESERVED;
+ break;
}
if (!(pDRIContextPriv = DRICreateContextPriv(pScreen,
- &pDRIPriv->myContext,
- flags))) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "failed to create server context\n");
- return FALSE;
+ &pDRIPriv->myContext,
+ flags))) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR, "failed to create server context\n");
+ return FALSE;
}
pDRIPriv->myContextPriv = pDRIContextPriv;
DRIDrvMsg(pScreen->myNum, X_INFO,
- "X context handle = %p\n", pDRIPriv->myContext);
+ "X context handle = %p\n", pDRIPriv->myContext);
/* Now that we have created the X server's context, we can grab the
* hardware lock for the X server.
@@ -524,67 +515,66 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
pDRIPriv->grabbedDRILock = TRUE;
/* pointers so that we can prevent memory leaks later */
- pDRIPriv->hiddenContextStore = NULL;
+ pDRIPriv->hiddenContextStore = NULL;
pDRIPriv->partial3DContextStore = NULL;
- switch(pDRIInfo->driverSwapMethod) {
+ switch (pDRIInfo->driverSwapMethod) {
case DRI_HIDE_X_CONTEXT:
- /* Server will handle 3D swaps, and hide 2D swaps from kernel.
- * Register server context as a preserved context.
- */
-
- /* allocate memory for hidden context store */
- pDRIPriv->hiddenContextStore
- = (void *)calloc(1, pDRIInfo->contextSize);
- if (!pDRIPriv->hiddenContextStore) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "failed to allocate hidden context\n");
- DRIDestroyContextPriv(pDRIContextPriv);
- return FALSE;
- }
-
- /* allocate memory for partial 3D context store */
- pDRIPriv->partial3DContextStore
- = (void *)calloc(1, pDRIInfo->contextSize);
- if (!pDRIPriv->partial3DContextStore) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[DRI] failed to allocate partial 3D context\n");
- free(pDRIPriv->hiddenContextStore);
- DRIDestroyContextPriv(pDRIContextPriv);
- return FALSE;
- }
-
- /* save initial context store */
- if (pDRIInfo->SwapContext) {
- (*pDRIInfo->SwapContext)(
- pScreen,
- DRI_NO_SYNC,
- DRI_2D_CONTEXT,
- pDRIPriv->hiddenContextStore,
- DRI_NO_CONTEXT,
- NULL);
- }
- /* fall through */
+ /* Server will handle 3D swaps, and hide 2D swaps from kernel.
+ * Register server context as a preserved context.
+ */
+
+ /* allocate memory for hidden context store */
+ pDRIPriv->hiddenContextStore
+ = (void *) calloc(1, pDRIInfo->contextSize);
+ if (!pDRIPriv->hiddenContextStore) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "failed to allocate hidden context\n");
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return FALSE;
+ }
+
+ /* allocate memory for partial 3D context store */
+ pDRIPriv->partial3DContextStore
+ = (void *) calloc(1, pDRIInfo->contextSize);
+ if (!pDRIPriv->partial3DContextStore) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI] failed to allocate partial 3D context\n");
+ free(pDRIPriv->hiddenContextStore);
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return FALSE;
+ }
+
+ /* save initial context store */
+ if (pDRIInfo->SwapContext) {
+ (*pDRIInfo->SwapContext) (pScreen,
+ DRI_NO_SYNC,
+ DRI_2D_CONTEXT,
+ pDRIPriv->hiddenContextStore,
+ DRI_NO_CONTEXT, NULL);
+ }
+ /* fall through */
case DRI_SERVER_SWAP:
/* For swap methods of DRI_SERVER_SWAP and DRI_HIDE_X_CONTEXT
* setup signal handler for receiving swap requests from kernel
- */
- if (!(pDRIPriv->drmSIGIOHandlerInstalled =
- drmInstallSIGIOHandler(pDRIPriv->drmFD, DRISwapContext))) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[drm] failed to setup DRM signal handler\n");
- free(pDRIPriv->hiddenContextStore);
- free(pDRIPriv->partial3DContextStore);
- DRIDestroyContextPriv(pDRIContextPriv);
- return FALSE;
- } else {
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] installed DRM signal handler\n");
- }
+ */
+ if (!(pDRIPriv->drmSIGIOHandlerInstalled =
+ drmInstallSIGIOHandler(pDRIPriv->drmFD, DRISwapContext))) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] failed to setup DRM signal handler\n");
+ free(pDRIPriv->hiddenContextStore);
+ free(pDRIPriv->partial3DContextStore);
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return FALSE;
+ }
+ else {
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] installed DRM signal handler\n");
+ }
default:
- break;
+ break;
}
return TRUE;
@@ -593,41 +583,42 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
Bool
DRIFinishScreenInit(ScreenPtr pScreen)
{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
/* Wrap DRI support */
if (pDRIInfo->wrap.ValidateTree) {
- pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
- pScreen->ValidateTree = pDRIInfo->wrap.ValidateTree;
+ pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
+ pScreen->ValidateTree = pDRIInfo->wrap.ValidateTree;
}
if (pDRIInfo->wrap.PostValidateTree) {
- pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
- pScreen->PostValidateTree = pDRIInfo->wrap.PostValidateTree;
+ pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
+ pScreen->PostValidateTree = pDRIInfo->wrap.PostValidateTree;
}
if (pDRIInfo->wrap.WindowExposures) {
- pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
- pScreen->WindowExposures = pDRIInfo->wrap.WindowExposures;
+ pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
+ pScreen->WindowExposures = pDRIInfo->wrap.WindowExposures;
}
- pDRIPriv->DestroyWindow = pScreen->DestroyWindow;
- pScreen->DestroyWindow = DRIDestroyWindow;
+ pDRIPriv->DestroyWindow = pScreen->DestroyWindow;
+ pScreen->DestroyWindow = DRIDestroyWindow;
pDRIPriv->xf86_crtc_notify = xf86_wrap_crtc_notify(pScreen,
- dri_crtc_notify);
-
+ dri_crtc_notify);
+
if (pDRIInfo->wrap.CopyWindow) {
- pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
- pScreen->CopyWindow = pDRIInfo->wrap.CopyWindow;
+ pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
+ pScreen->CopyWindow = pDRIInfo->wrap.CopyWindow;
}
if (pDRIInfo->wrap.ClipNotify) {
- pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
- pScreen->ClipNotify = pDRIInfo->wrap.ClipNotify;
+ pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
+ pScreen->ClipNotify = pDRIInfo->wrap.ClipNotify;
}
if (pDRIInfo->wrap.AdjustFrame) {
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame;
- pScrn->AdjustFrame = pDRIInfo->wrap.AdjustFrame;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+ pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame;
+ pScrn->AdjustFrame = pDRIInfo->wrap.AdjustFrame;
}
pDRIPriv->wrapped = TRUE;
@@ -640,161 +631,161 @@ void
DRICloseScreen(ScreenPtr pScreen)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIInfoPtr pDRIInfo;
- drm_context_t * reserved;
- int reserved_count;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- DRIEntPrivPtr pDRIEntPriv = DRI_ENT_PRIV(pScrn);
+ DRIInfoPtr pDRIInfo;
+ drm_context_t *reserved;
+ int reserved_count;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ DRIEntPrivPtr pDRIEntPriv = DRI_ENT_PRIV(pScrn);
Bool closeMaster;
if (pDRIPriv) {
pDRIInfo = pDRIPriv->pDriverInfo;
- if (pDRIPriv->wrapped) {
- /* Unwrap DRI Functions */
- if (pDRIInfo->wrap.ValidateTree) {
- pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
- pDRIPriv->wrap.ValidateTree = NULL;
- }
- if (pDRIInfo->wrap.PostValidateTree) {
- pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
- pDRIPriv->wrap.PostValidateTree = NULL;
- }
- if (pDRIInfo->wrap.WindowExposures) {
- pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
- pDRIPriv->wrap.WindowExposures = NULL;
- }
- if (pDRIPriv->DestroyWindow) {
- pScreen->DestroyWindow = pDRIPriv->DestroyWindow;
- pDRIPriv->DestroyWindow = NULL;
- }
-
- xf86_unwrap_crtc_notify(pScreen, pDRIPriv->xf86_crtc_notify);
-
- if (pDRIInfo->wrap.CopyWindow) {
- pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow;
- pDRIPriv->wrap.CopyWindow = NULL;
- }
- if (pDRIInfo->wrap.ClipNotify) {
- pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify;
- pDRIPriv->wrap.ClipNotify = NULL;
- }
- if (pDRIInfo->wrap.AdjustFrame) {
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame;
- pDRIPriv->wrap.AdjustFrame = NULL;
- }
-
- pDRIPriv->wrapped = FALSE;
- }
-
- if (pDRIPriv->drmSIGIOHandlerInstalled) {
- if (!drmRemoveSIGIOHandler(pDRIPriv->drmFD)) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[drm] failed to remove DRM signal handler\n");
- }
- }
+ if (pDRIPriv->wrapped) {
+ /* Unwrap DRI Functions */
+ if (pDRIInfo->wrap.ValidateTree) {
+ pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
+ pDRIPriv->wrap.ValidateTree = NULL;
+ }
+ if (pDRIInfo->wrap.PostValidateTree) {
+ pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
+ pDRIPriv->wrap.PostValidateTree = NULL;
+ }
+ if (pDRIInfo->wrap.WindowExposures) {
+ pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
+ pDRIPriv->wrap.WindowExposures = NULL;
+ }
+ if (pDRIPriv->DestroyWindow) {
+ pScreen->DestroyWindow = pDRIPriv->DestroyWindow;
+ pDRIPriv->DestroyWindow = NULL;
+ }
+
+ xf86_unwrap_crtc_notify(pScreen, pDRIPriv->xf86_crtc_notify);
+
+ if (pDRIInfo->wrap.CopyWindow) {
+ pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow;
+ pDRIPriv->wrap.CopyWindow = NULL;
+ }
+ if (pDRIInfo->wrap.ClipNotify) {
+ pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify;
+ pDRIPriv->wrap.ClipNotify = NULL;
+ }
+ if (pDRIInfo->wrap.AdjustFrame) {
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+ pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame;
+ pDRIPriv->wrap.AdjustFrame = NULL;
+ }
+
+ pDRIPriv->wrapped = FALSE;
+ }
+
+ if (pDRIPriv->drmSIGIOHandlerInstalled) {
+ if (!drmRemoveSIGIOHandler(pDRIPriv->drmFD)) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] failed to remove DRM signal handler\n");
+ }
+ }
if (pDRIPriv->dummyCtxPriv && pDRIPriv->createDummyCtx) {
- DRIDestroyDummyContext(pScreen, pDRIPriv->createDummyCtxPriv);
- }
-
- if (!DRIDestroyContextPriv(pDRIPriv->myContextPriv)) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "failed to destroy server context\n");
- }
-
- /* Remove tags for reserved contexts */
- if (pDRIEntPriv->resOwner == pScreen) {
- pDRIEntPriv->resOwner = NULL;
-
- if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
- &reserved_count))) {
- int i;
-
- for (i = 0; i < reserved_count; i++) {
- DRIDestroyContextPriv(drmGetContextTag(pDRIPriv->drmFD,
- reserved[i]));
- }
- drmFreeReservedContextList(reserved);
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] removed %d reserved context%s for kernel\n",
- reserved_count, reserved_count > 1 ? "s" : "");
- }
- }
-
- /* Make sure signals get unblocked etc. */
- drmUnlock(pDRIPriv->drmFD, pDRIPriv->myContext);
- pDRIPriv->pLockRefCount = NULL;
- closeMaster = (--pDRIEntPriv->refCount == 0) &&
- !pDRIEntPriv->keepFDOpen;
- if (closeMaster || pDRIPriv->hSAREA != pDRIEntPriv->hLSAREA) {
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] unmapping %d bytes of SAREA %p at %p\n",
- pDRIInfo->SAREASize,
- pDRIPriv->hSAREA,
- pDRIPriv->pSAREA);
- if (drmUnmap(pDRIPriv->pSAREA, pDRIInfo->SAREASize)) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[drm] unable to unmap %d bytes"
- " of SAREA %p at %p\n",
- pDRIInfo->SAREASize,
- pDRIPriv->hSAREA,
- pDRIPriv->pSAREA);
- }
- } else {
- pDRIEntPriv->sAreaGrabbed = FALSE;
- }
-
- if (closeMaster || (pDRIEntPriv->drmFD != pDRIPriv->drmFD)) {
- drmClose(pDRIPriv->drmFD);
- if (pDRIEntPriv->drmFD == pDRIPriv->drmFD) {
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] Closed DRM master.\n");
- pDRIEntPriv->drmFD = -1;
- }
- }
-
- free(pDRIPriv);
- dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
+ DRIDestroyDummyContext(pScreen, pDRIPriv->createDummyCtxPriv);
+ }
+
+ if (!DRIDestroyContextPriv(pDRIPriv->myContextPriv)) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "failed to destroy server context\n");
+ }
+
+ /* Remove tags for reserved contexts */
+ if (pDRIEntPriv->resOwner == pScreen) {
+ pDRIEntPriv->resOwner = NULL;
+
+ if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
+ &reserved_count))) {
+ int i;
+
+ for (i = 0; i < reserved_count; i++) {
+ DRIDestroyContextPriv(drmGetContextTag(pDRIPriv->drmFD,
+ reserved[i]));
+ }
+ drmFreeReservedContextList(reserved);
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] removed %d reserved context%s for kernel\n",
+ reserved_count, reserved_count > 1 ? "s" : "");
+ }
+ }
+
+ /* Make sure signals get unblocked etc. */
+ drmUnlock(pDRIPriv->drmFD, pDRIPriv->myContext);
+ pDRIPriv->pLockRefCount = NULL;
+ closeMaster = (--pDRIEntPriv->refCount == 0) &&
+ !pDRIEntPriv->keepFDOpen;
+ if (closeMaster || pDRIPriv->hSAREA != pDRIEntPriv->hLSAREA) {
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] unmapping %d bytes of SAREA %p at %p\n",
+ pDRIInfo->SAREASize, pDRIPriv->hSAREA, pDRIPriv->pSAREA);
+ if (drmUnmap(pDRIPriv->pSAREA, pDRIInfo->SAREASize)) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] unable to unmap %d bytes"
+ " of SAREA %p at %p\n",
+ pDRIInfo->SAREASize,
+ pDRIPriv->hSAREA, pDRIPriv->pSAREA);
+ }
+ }
+ else {
+ pDRIEntPriv->sAreaGrabbed = FALSE;
+ }
+
+ if (closeMaster || (pDRIEntPriv->drmFD != pDRIPriv->drmFD)) {
+ drmClose(pDRIPriv->drmFD);
+ if (pDRIEntPriv->drmFD == pDRIPriv->drmFD) {
+ DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] Closed DRM master.\n");
+ pDRIEntPriv->drmFD = -1;
+ }
+ }
+
+ free(pDRIPriv);
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
}
}
#define DRM_MSG_VERBOSITY 3
-static int dri_drm_debug_print(const char *format, va_list ap)
+static int
+dri_drm_debug_print(const char *format, va_list ap)
{
- xf86VDrvMsgVerb(-1, X_NONE, DRM_MSG_VERBOSITY, format, ap);
- return 0;
+ xf86VDrvMsgVerb(-1, X_NONE, DRM_MSG_VERBOSITY, format, ap);
+ return 0;
}
-static void dri_drm_get_perms(gid_t *group, mode_t *mode)
+static void
+dri_drm_get_perms(gid_t * group, mode_t * mode)
{
- *group = xf86ConfigDRI.group;
- *mode = xf86ConfigDRI.mode;
+ *group = xf86ConfigDRI.group;
+ *mode = xf86ConfigDRI.mode;
}
-drmServerInfo DRIDRMServerInfo = {
- dri_drm_debug_print,
- xf86LoadKernelModule,
- dri_drm_get_perms,
+drmServerInfo DRIDRMServerInfo = {
+ dri_drm_debug_print,
+ xf86LoadKernelModule,
+ dri_drm_get_perms,
};
Bool
DRIExtensionInit(void)
{
if (DRIGeneration != serverGeneration) {
- return FALSE;
+ return FALSE;
}
DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete,
- "DRIDrawable");
+ "DRIDrawable");
DRIContextPrivResType = CreateNewResourceType(DRIContextPrivDelete,
- "DRIContext");
+ "DRIContext");
if (!DRIDrawablePrivResType || !DRIContextPrivResType)
- return FALSE;
+ return FALSE;
RegisterBlockAndWakeupHandlers(DRIBlockHandler, DRIWakeupHandler, NULL);
@@ -814,14 +805,14 @@ DRIReset(void)
}
Bool
-DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool* isCapable)
+DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool *isCapable)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
if (pDRIPriv)
- *isCapable = pDRIPriv->directRenderingSupport;
+ *isCapable = pDRIPriv->directRenderingSupport;
else
- *isCapable = FALSE;
+ *isCapable = FALSE;
return TRUE;
}
@@ -831,8 +822,8 @@ DRIOpenConnection(ScreenPtr pScreen, drm_handle_t * hSAREA, char **busIdString)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- *hSAREA = pDRIPriv->hSAREA;
- *busIdString = pDRIPriv->pDriverInfo->busIdString;
+ *hSAREA = pDRIPriv->hSAREA;
+ *busIdString = pDRIPriv->pDriverInfo->busIdString;
return TRUE;
}
@@ -842,7 +833,8 @@ DRIAuthConnection(ScreenPtr pScreen, drm_magic_t magic)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE;
+ if (drmAuthMagic(pDRIPriv->drmFD, magic))
+ return FALSE;
return TRUE;
}
@@ -856,15 +848,14 @@ Bool
DRIGetClientDriverName(ScreenPtr pScreen,
int *ddxDriverMajorVersion,
int *ddxDriverMinorVersion,
- int *ddxDriverPatchVersion,
- char **clientDriverName)
+ int *ddxDriverPatchVersion, char **clientDriverName)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
*ddxDriverMajorVersion = pDRIPriv->pDriverInfo->ddxDriverMajorVersion;
*ddxDriverMinorVersion = pDRIPriv->pDriverInfo->ddxDriverMinorVersion;
*ddxDriverPatchVersion = pDRIPriv->pDriverInfo->ddxDriverPatchVersion;
- *clientDriverName = pDRIPriv->pDriverInfo->clientDriverName;
+ *clientDriverName = pDRIPriv->pDriverInfo->clientDriverName;
return TRUE;
}
@@ -883,13 +874,12 @@ DRIGetClientDriverName(ScreenPtr pScreen,
DRIContextPrivPtr
DRICreateContextPriv(ScreenPtr pScreen,
- drm_context_t * pHWContext,
- DRIContextFlags flags)
+ drm_context_t * pHWContext, DRIContextFlags flags)
{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
if (drmCreateContext(pDRIPriv->drmFD, pHWContext)) {
- return NULL;
+ return NULL;
}
return DRICreateContextPrivFromHandle(pScreen, *pHWContext, flags);
@@ -897,46 +887,42 @@ DRICreateContextPriv(ScreenPtr pScreen,
DRIContextPrivPtr
DRICreateContextPrivFromHandle(ScreenPtr pScreen,
- drm_context_t hHWContext,
- DRIContextFlags flags)
+ drm_context_t hHWContext, DRIContextFlags flags)
{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
DRIContextPrivPtr pDRIContextPriv;
- int contextPrivSize;
+ int contextPrivSize;
contextPrivSize = sizeof(DRIContextPrivRec) +
- pDRIPriv->pDriverInfo->contextSize;
+ pDRIPriv->pDriverInfo->contextSize;
if (!(pDRIContextPriv = calloc(1, contextPrivSize))) {
- return NULL;
+ return NULL;
}
- pDRIContextPriv->pContextStore = (void *)(pDRIContextPriv + 1);
+ pDRIContextPriv->pContextStore = (void *) (pDRIContextPriv + 1);
drmAddContextTag(pDRIPriv->drmFD, hHWContext, pDRIContextPriv);
pDRIContextPriv->hwContext = hHWContext;
- pDRIContextPriv->pScreen = pScreen;
- pDRIContextPriv->flags = flags;
- pDRIContextPriv->valid3D = FALSE;
+ pDRIContextPriv->pScreen = pScreen;
+ pDRIContextPriv->flags = flags;
+ pDRIContextPriv->valid3D = FALSE;
if (flags & DRI_CONTEXT_2DONLY) {
- if (drmSetContextFlags(pDRIPriv->drmFD,
- hHWContext,
- DRM_CONTEXT_2DONLY)) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[drm] failed to set 2D context flag\n");
- DRIDestroyContextPriv(pDRIContextPriv);
- return NULL;
- }
+ if (drmSetContextFlags(pDRIPriv->drmFD, hHWContext, DRM_CONTEXT_2DONLY)) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] failed to set 2D context flag\n");
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return NULL;
+ }
}
if (flags & DRI_CONTEXT_PRESERVED) {
- if (drmSetContextFlags(pDRIPriv->drmFD,
- hHWContext,
- DRM_CONTEXT_PRESERVED)) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[drm] failed to set preserved flag\n");
- DRIDestroyContextPriv(pDRIContextPriv);
- return NULL;
- }
+ if (drmSetContextFlags(pDRIPriv->drmFD,
+ hHWContext, DRM_CONTEXT_PRESERVED)) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] failed to set preserved flag\n");
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return NULL;
+ }
}
return pDRIContextPriv;
}
@@ -946,23 +932,24 @@ DRIDestroyContextPriv(DRIContextPrivPtr pDRIContextPriv)
{
DRIScreenPrivPtr pDRIPriv;
- if (!pDRIContextPriv) return TRUE;
+ if (!pDRIContextPriv)
+ return TRUE;
pDRIPriv = DRI_SCREEN_PRIV(pDRIContextPriv->pScreen);
if (!(pDRIContextPriv->flags & DRI_CONTEXT_RESERVED)) {
- /* Don't delete reserved contexts from
- kernel area -- the kernel manages its
- reserved contexts itself. */
- if (drmDestroyContext(pDRIPriv->drmFD, pDRIContextPriv->hwContext))
- return FALSE;
- }
-
- /* Remove the tag last to prevent a race
- condition where the context has pending
- buffers. The context can't be re-used
- while in this thread, but buffers can be
- dispatched asynchronously. */
+ /* Don't delete reserved contexts from
+ kernel area -- the kernel manages its
+ reserved contexts itself. */
+ if (drmDestroyContext(pDRIPriv->drmFD, pDRIContextPriv->hwContext))
+ return FALSE;
+ }
+
+ /* Remove the tag last to prevent a race
+ condition where the context has pending
+ buffers. The context can't be re-used
+ while in this thread, but buffers can be
+ dispatched asynchronously. */
drmDelContextTag(pDRIPriv->drmFD, pDRIContextPriv->hwContext);
free(pDRIContextPriv);
return TRUE;
@@ -976,20 +963,20 @@ DRICreateDummyContext(ScreenPtr pScreen, Bool needCtxPriv)
void *contextStore;
if (!(pDRIContextPriv =
- DRICreateContextPriv(pScreen,
- &pDRIPriv->pSAREA->dummy_context, 0))) {
- return FALSE;
+ DRICreateContextPriv(pScreen, &pDRIPriv->pSAREA->dummy_context, 0))) {
+ return FALSE;
}
contextStore = DRIGetContextStore(pDRIContextPriv);
if (pDRIPriv->pDriverInfo->CreateContext && needCtxPriv) {
- if (!pDRIPriv->pDriverInfo->CreateContext(pScreen, NULL,
- pDRIPriv->pSAREA->dummy_context,
- NULL,
- (DRIContextType)(long)contextStore)) {
- DRIDestroyContextPriv(pDRIContextPriv);
- return FALSE;
- }
+ if (!pDRIPriv->pDriverInfo->CreateContext(pScreen, NULL,
+ pDRIPriv->pSAREA->
+ dummy_context, NULL,
+ (DRIContextType) (long)
+ contextStore)) {
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return FALSE;
+ }
}
pDRIPriv->dummyCtxPriv = pDRIContextPriv;
@@ -1003,12 +990,14 @@ DRIDestroyDummyContext(ScreenPtr pScreen, Bool hasCtxPriv)
DRIContextPrivPtr pDRIContextPriv = pDRIPriv->dummyCtxPriv;
void *contextStore;
- if (!pDRIContextPriv) return;
+ if (!pDRIContextPriv)
+ return;
if (pDRIPriv->pDriverInfo->DestroyContext && hasCtxPriv) {
- contextStore = DRIGetContextStore(pDRIContextPriv);
- pDRIPriv->pDriverInfo->DestroyContext(pDRIContextPriv->pScreen,
- pDRIContextPriv->hwContext,
- (DRIContextType)(long)contextStore);
+ contextStore = DRIGetContextStore(pDRIContextPriv);
+ pDRIPriv->pDriverInfo->DestroyContext(pDRIContextPriv->pScreen,
+ pDRIContextPriv->hwContext,
+ (DRIContextType) (long)
+ contextStore);
}
DRIDestroyContextPriv(pDRIPriv->dummyCtxPriv);
@@ -1025,28 +1014,29 @@ DRICreateContext(ScreenPtr pScreen, VisualPtr visual,
if (pDRIPriv->createDummyCtx && !pDRIPriv->dummyCtxPriv) {
if (!DRICreateDummyContext(pScreen, pDRIPriv->createDummyCtxPriv)) {
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] Could not create dummy context\n");
- return FALSE;
- }
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] Could not create dummy context\n");
+ return FALSE;
+ }
}
if (!(pDRIContextPriv = DRICreateContextPriv(pScreen, pHWContext, 0))) {
- return FALSE;
+ return FALSE;
}
contextStore = DRIGetContextStore(pDRIContextPriv);
if (pDRIPriv->pDriverInfo->CreateContext) {
- if (!((*pDRIPriv->pDriverInfo->CreateContext)(pScreen, NULL,
- *pHWContext, NULL,
- (DRIContextType)(long)contextStore))) {
- DRIDestroyContextPriv(pDRIContextPriv);
- return FALSE;
- }
+ if (!((*pDRIPriv->pDriverInfo->CreateContext) (pScreen, NULL,
+ *pHWContext, NULL,
+ (DRIContextType) (long)
+ contextStore))) {
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return FALSE;
+ }
}
/* track this in case the client dies before cleanup */
- AddResource(context, DRIContextPrivResType, (pointer)pDRIContextPriv);
+ AddResource(context, DRIContextPrivResType, (pointer) pDRIContextPriv);
return TRUE;
}
@@ -1063,21 +1053,21 @@ DRIDestroyContext(ScreenPtr pScreen, XID context)
Bool
DRIContextPrivDelete(pointer pResource, XID id)
{
- DRIContextPrivPtr pDRIContextPriv = (DRIContextPrivPtr)pResource;
+ DRIContextPrivPtr pDRIContextPriv = (DRIContextPrivPtr) pResource;
DRIScreenPrivPtr pDRIPriv;
void *contextStore;
pDRIPriv = DRI_SCREEN_PRIV(pDRIContextPriv->pScreen);
if (pDRIPriv->pDriverInfo->DestroyContext) {
- contextStore = DRIGetContextStore(pDRIContextPriv);
- pDRIPriv->pDriverInfo->DestroyContext(pDRIContextPriv->pScreen,
- pDRIContextPriv->hwContext,
- (DRIContextType)(long)contextStore);
+ contextStore = DRIGetContextStore(pDRIContextPriv);
+ pDRIPriv->pDriverInfo->DestroyContext(pDRIContextPriv->pScreen,
+ pDRIContextPriv->hwContext,
+ (DRIContextType) (long)
+ contextStore);
}
return DRIDestroyContextPriv(pDRIContextPriv);
}
-
/* This walks the drawable timestamp array and invalidates all of them
* in the case of transition from private to shared backbuffers. It's
* not necessary for correctness, because DRIClipNotify gets called in
@@ -1087,51 +1077,48 @@ DRIContextPrivDelete(pointer pResource, XID id)
static void
DRIClipNotifyAllDrawables(ScreenPtr pScreen)
{
- int i;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ int i;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- for( i=0; i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; i++) {
- pDRIPriv->pSAREA->drawableTable[i].stamp = DRIDrawableValidationStamp++;
- }
+ for (i = 0; i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; i++) {
+ pDRIPriv->pSAREA->drawableTable[i].stamp = DRIDrawableValidationStamp++;
+ }
}
-
static void
DRITransitionToSharedBuffers(ScreenPtr pScreen)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
- DRIClipNotifyAllDrawables( pScreen );
+ DRIClipNotifyAllDrawables(pScreen);
if (pDRIInfo->TransitionSingleToMulti3D)
- pDRIInfo->TransitionSingleToMulti3D( pScreen );
+ pDRIInfo->TransitionSingleToMulti3D(pScreen);
}
-
static void
DRITransitionToPrivateBuffers(ScreenPtr pScreen)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
- DRIClipNotifyAllDrawables( pScreen );
+ DRIClipNotifyAllDrawables(pScreen);
if (pDRIInfo->TransitionMultiToSingle3D)
- pDRIInfo->TransitionMultiToSingle3D( pScreen );
+ pDRIInfo->TransitionMultiToSingle3D(pScreen);
}
-
static void
DRITransitionTo3d(ScreenPtr pScreen)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
- DRIClipNotifyAllDrawables( pScreen );
+ DRIClipNotifyAllDrawables(pScreen);
if (pDRIInfo->TransitionTo3d)
- pDRIInfo->TransitionTo3d( pScreen );
+ pDRIInfo->TransitionTo3d(pScreen);
}
static void
@@ -1140,36 +1127,35 @@ DRITransitionTo2d(ScreenPtr pScreen)
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
- DRIClipNotifyAllDrawables( pScreen );
+ DRIClipNotifyAllDrawables(pScreen);
if (pDRIInfo->TransitionTo2d)
- pDRIInfo->TransitionTo2d( pScreen );
+ pDRIInfo->TransitionTo2d(pScreen);
}
-
static int
DRIDCNTreeTraversal(WindowPtr pWin, pointer data)
{
DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
if (pDRIDrawablePriv) {
- ScreenPtr pScreen = pWin->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if (RegionNumRects(&pWin->clipList) > 0) {
- WindowPtr *pDRIWindows = (WindowPtr*)data;
- int i = 0;
+ if (RegionNumRects(&pWin->clipList) > 0) {
+ WindowPtr *pDRIWindows = (WindowPtr *) data;
+ int i = 0;
- while (pDRIWindows[i])
- i++;
+ while (pDRIWindows[i])
+ i++;
- pDRIWindows[i] = pWin;
+ pDRIWindows[i] = pWin;
- pDRIPriv->nrWalked++;
- }
+ pDRIPriv->nrWalked++;
+ }
- if (pDRIPriv->nrWindows == pDRIPriv->nrWalked)
- return WT_STOPWALKING;
+ if (pDRIPriv->nrWindows == pDRIPriv->nrWalked)
+ return WT_STOPWALKING;
}
return WT_WALKCHILDREN;
@@ -1181,18 +1167,18 @@ DRIDriverClipNotify(ScreenPtr pScreen)
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
if (pDRIPriv->pDriverInfo->ClipNotify) {
- WindowPtr *pDRIWindows = calloc(sizeof(WindowPtr), pDRIPriv->nrWindows);
- DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
+ WindowPtr *pDRIWindows = calloc(sizeof(WindowPtr), pDRIPriv->nrWindows);
+ DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
- if (pDRIPriv->nrWindows > 0) {
- pDRIPriv->nrWalked = 0;
- TraverseTree(pScreen->root, DRIDCNTreeTraversal,
- (pointer)pDRIWindows);
- }
+ if (pDRIPriv->nrWindows > 0) {
+ pDRIPriv->nrWalked = 0;
+ TraverseTree(pScreen->root, DRIDCNTreeTraversal,
+ (pointer) pDRIWindows);
+ }
- pDRIInfo->ClipNotify(pScreen, pDRIWindows, pDRIPriv->nrWindows);
+ pDRIInfo->ClipNotify(pScreen, pDRIWindows, pDRIPriv->nrWindows);
- free(pDRIWindows);
+ free(pDRIWindows);
}
}
@@ -1203,13 +1189,13 @@ DRIIncreaseNumberVisible(ScreenPtr pScreen)
switch (++pDRIPriv->nrWindowsVisible) {
case 1:
- DRITransitionTo3d( pScreen );
- break;
+ DRITransitionTo3d(pScreen);
+ break;
case 2:
- DRITransitionToSharedBuffers( pScreen );
- break;
+ DRITransitionToSharedBuffers(pScreen);
+ break;
default:
- break;
+ break;
}
DRIDriverClipNotify(pScreen);
@@ -1222,13 +1208,13 @@ DRIDecreaseNumberVisible(ScreenPtr pScreen)
switch (--pDRIPriv->nrWindowsVisible) {
case 0:
- DRITransitionTo2d( pScreen );
- break;
+ DRITransitionTo2d(pScreen);
+ break;
case 1:
- DRITransitionToPrivateBuffers( pScreen );
- break;
+ DRITransitionToPrivateBuffers(pScreen);
+ break;
default:
- break;
+ break;
}
DRIDriverClipNotify(pScreen);
@@ -1236,65 +1222,66 @@ DRIDecreaseNumberVisible(ScreenPtr pScreen)
Bool
DRICreateDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable,
- drm_drawable_t * hHWDrawable)
+ drm_drawable_t * hHWDrawable)
{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv;
- WindowPtr pWin;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv;
+ WindowPtr pWin;
if (pDrawable->type == DRAWABLE_WINDOW) {
- pWin = (WindowPtr)pDrawable;
- if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
- pDRIDrawablePriv->refCount++;
-
- if (!pDRIDrawablePriv->hwDrawable) {
- drmCreateDrawable(pDRIPriv->drmFD, &pDRIDrawablePriv->hwDrawable);
- }
- }
- else {
- /* allocate a DRI Window Private record */
- if (!(pDRIDrawablePriv = malloc(sizeof(DRIDrawablePrivRec)))) {
- return FALSE;
- }
-
- /* Only create a drm_drawable_t once */
- if (drmCreateDrawable(pDRIPriv->drmFD,
- &pDRIDrawablePriv->hwDrawable)) {
- free(pDRIDrawablePriv);
- return FALSE;
- }
-
- /* add it to the list of DRI drawables for this screen */
- pDRIDrawablePriv->pScreen = pScreen;
- pDRIDrawablePriv->refCount = 1;
- pDRIDrawablePriv->drawableIndex = -1;
- pDRIDrawablePriv->nrects = RegionNumRects(&pWin->clipList);
-
- /* save private off of preallocated index */
- dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey,
- pDRIDrawablePriv);
- pDRIPriv->nrWindows++;
-
- if (pDRIDrawablePriv->nrects)
- DRIIncreaseNumberVisible(pScreen);
- }
-
- /* track this in case the client dies */
- AddResource(FakeClientID(client->index), DRIDrawablePrivResType,
- (pointer)(intptr_t)pDrawable->id);
-
- if (pDRIDrawablePriv->hwDrawable) {
- drmUpdateDrawableInfo(pDRIPriv->drmFD,
- pDRIDrawablePriv->hwDrawable,
- DRM_DRAWABLE_CLIPRECTS,
- RegionNumRects(&pWin->clipList),
- RegionRects(&pWin->clipList));
- *hHWDrawable = pDRIDrawablePriv->hwDrawable;
- }
- }
- else if (pDrawable->type != DRAWABLE_PIXMAP) { /* PBuffer */
- /* NOT_DONE */
- return FALSE;
+ pWin = (WindowPtr) pDrawable;
+ if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
+ pDRIDrawablePriv->refCount++;
+
+ if (!pDRIDrawablePriv->hwDrawable) {
+ drmCreateDrawable(pDRIPriv->drmFD,
+ &pDRIDrawablePriv->hwDrawable);
+ }
+ }
+ else {
+ /* allocate a DRI Window Private record */
+ if (!(pDRIDrawablePriv = malloc(sizeof(DRIDrawablePrivRec)))) {
+ return FALSE;
+ }
+
+ /* Only create a drm_drawable_t once */
+ if (drmCreateDrawable(pDRIPriv->drmFD,
+ &pDRIDrawablePriv->hwDrawable)) {
+ free(pDRIDrawablePriv);
+ return FALSE;
+ }
+
+ /* add it to the list of DRI drawables for this screen */
+ pDRIDrawablePriv->pScreen = pScreen;
+ pDRIDrawablePriv->refCount = 1;
+ pDRIDrawablePriv->drawableIndex = -1;
+ pDRIDrawablePriv->nrects = RegionNumRects(&pWin->clipList);
+
+ /* save private off of preallocated index */
+ dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey,
+ pDRIDrawablePriv);
+ pDRIPriv->nrWindows++;
+
+ if (pDRIDrawablePriv->nrects)
+ DRIIncreaseNumberVisible(pScreen);
+ }
+
+ /* track this in case the client dies */
+ AddResource(FakeClientID(client->index), DRIDrawablePrivResType,
+ (pointer) (intptr_t) pDrawable->id);
+
+ if (pDRIDrawablePriv->hwDrawable) {
+ drmUpdateDrawableInfo(pDRIPriv->drmFD,
+ pDRIDrawablePriv->hwDrawable,
+ DRM_DRAWABLE_CLIPRECTS,
+ RegionNumRects(&pWin->clipList),
+ RegionRects(&pWin->clipList));
+ *hHWDrawable = pDRIDrawablePriv->hwDrawable;
+ }
+ }
+ else if (pDrawable->type != DRAWABLE_PIXMAP) { /* PBuffer */
+ /* NOT_DONE */
+ return FALSE;
}
return TRUE;
@@ -1308,24 +1295,24 @@ DRIDrawablePrivDestroy(WindowPtr pWin)
DRIScreenPrivPtr pDRIPriv;
if (!pDRIDrawablePriv)
- return;
+ return;
pScreen = pWin->drawable.pScreen;
pDRIPriv = DRI_SCREEN_PRIV(pScreen);
if (pDRIDrawablePriv->drawableIndex != -1) {
- /* bump stamp to force outstanding 3D requests to resync */
- pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp
- = DRIDrawableValidationStamp++;
+ /* bump stamp to force outstanding 3D requests to resync */
+ pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp
+ = DRIDrawableValidationStamp++;
- /* release drawable table entry */
- pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL;
+ /* release drawable table entry */
+ pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL;
}
pDRIPriv->nrWindows--;
if (pDRIDrawablePriv->nrects)
- DRIDecreaseNumberVisible(pScreen);
+ DRIDecreaseNumberVisible(pScreen);
drmDestroyDrawable(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable);
@@ -1337,10 +1324,10 @@ static Bool
DRIDestroyDrawableCB(pointer value, XID id, pointer data)
{
if (value == data) {
- /* This calls back DRIDrawablePrivDelete which frees private area */
- FreeResourceByType(id, DRIDrawablePrivResType, FALSE);
+ /* This calls back DRIDrawablePrivDelete which frees private area */
+ FreeResourceByType(id, DRIDrawablePrivResType, FALSE);
- return TRUE;
+ return TRUE;
}
return FALSE;
@@ -1350,13 +1337,13 @@ Bool
DRIDestroyDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable)
{
if (pDrawable->type == DRAWABLE_WINDOW) {
- LookupClientResourceComplex(client, DRIDrawablePrivResType,
- DRIDestroyDrawableCB,
- (pointer)(intptr_t)pDrawable->id);
+ LookupClientResourceComplex(client, DRIDrawablePrivResType,
+ DRIDestroyDrawableCB,
+ (pointer) (intptr_t) pDrawable->id);
}
- else { /* pixmap (or for GLX 1.3, a PBuffer) */
- /* NOT_DONE */
- return FALSE;
+ else { /* pixmap (or for GLX 1.3, a PBuffer) */
+ /* NOT_DONE */
+ return FALSE;
}
return TRUE;
@@ -1370,189 +1357,198 @@ DRIDrawablePrivDelete(pointer pResource, XID id)
/* For DRIDrawablePrivResType, the XID is the client's fake ID. The
* important XID is the value in pResource. */
- id = (XID)(intptr_t)pResource;
+ id = (XID) (intptr_t) pResource;
rc = dixLookupWindow(&pWin, id, serverClient, DixGetAttrAccess);
if (rc == Success) {
- DRIDrawablePrivPtr pDRIDrwPriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+ DRIDrawablePrivPtr pDRIDrwPriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
- if (!pDRIDrwPriv)
- return FALSE;
+ if (!pDRIDrwPriv)
+ return FALSE;
- if (--pDRIDrwPriv->refCount == 0)
- DRIDrawablePrivDestroy(pWin);
+ if (--pDRIDrwPriv->refCount == 0)
+ DRIDrawablePrivDestroy(pWin);
- return TRUE;
+ return TRUE;
}
- else { /* pixmap (or for GLX 1.3, a PBuffer) */
- /* NOT_DONE */
- return FALSE;
+ else { /* pixmap (or for GLX 1.3, a PBuffer) */
+ /* NOT_DONE */
+ return FALSE;
}
}
Bool
DRIGetDrawableInfo(ScreenPtr pScreen,
DrawablePtr pDrawable,
- unsigned int* index,
- unsigned int* stamp,
- int* X,
- int* Y,
- int* W,
- int* H,
- int* numClipRects,
+ unsigned int *index,
+ unsigned int *stamp,
+ int *X,
+ int *Y,
+ int *W,
+ int *H,
+ int *numClipRects,
drm_clip_rect_t ** pClipRects,
- int* backX,
- int* backY,
- int* numBackClipRects,
- drm_clip_rect_t ** pBackClipRects)
+ int *backX,
+ int *backY,
+ int *numBackClipRects, drm_clip_rect_t ** pBackClipRects)
{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv, pOldDrawPriv;
- WindowPtr pWin, pOldWin;
- int i;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv, pOldDrawPriv;
+ WindowPtr pWin, pOldWin;
+ int i;
#if 0
- printf("maxDrawableTableEntry = %d\n", pDRIPriv->pDriverInfo->maxDrawableTableEntry);
+ printf("maxDrawableTableEntry = %d\n",
+ pDRIPriv->pDriverInfo->maxDrawableTableEntry);
#endif
if (pDrawable->type == DRAWABLE_WINDOW) {
- pWin = (WindowPtr)pDrawable;
- if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
-
- /* Manage drawable table */
- if (pDRIDrawablePriv->drawableIndex == -1) { /* load SAREA table */
-
- /* Search table for empty entry */
- i = 0;
- while (i < pDRIPriv->pDriverInfo->maxDrawableTableEntry) {
- if (!(pDRIPriv->DRIDrawables[i])) {
- pDRIPriv->DRIDrawables[i] = pDrawable;
- pDRIDrawablePriv->drawableIndex = i;
- pDRIPriv->pSAREA->drawableTable[i].stamp =
- DRIDrawableValidationStamp++;
- break;
- }
- i++;
- }
-
- /* Search table for oldest entry */
- if (i == pDRIPriv->pDriverInfo->maxDrawableTableEntry) {
+ pWin = (WindowPtr) pDrawable;
+ if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
+
+ /* Manage drawable table */
+ if (pDRIDrawablePriv->drawableIndex == -1) { /* load SAREA table */
+
+ /* Search table for empty entry */
+ i = 0;
+ while (i < pDRIPriv->pDriverInfo->maxDrawableTableEntry) {
+ if (!(pDRIPriv->DRIDrawables[i])) {
+ pDRIPriv->DRIDrawables[i] = pDrawable;
+ pDRIDrawablePriv->drawableIndex = i;
+ pDRIPriv->pSAREA->drawableTable[i].stamp =
+ DRIDrawableValidationStamp++;
+ break;
+ }
+ i++;
+ }
+
+ /* Search table for oldest entry */
+ if (i == pDRIPriv->pDriverInfo->maxDrawableTableEntry) {
unsigned int oldestStamp = ~0;
int oldestIndex = 0;
- i = pDRIPriv->pDriverInfo->maxDrawableTableEntry;
- while (i--) {
- if (pDRIPriv->pSAREA->drawableTable[i].stamp <
- oldestStamp) {
- oldestIndex = i;
- oldestStamp =
- pDRIPriv->pSAREA->drawableTable[i].stamp;
- }
- }
- pDRIDrawablePriv->drawableIndex = oldestIndex;
-
- /* release oldest drawable table entry */
- pOldWin = (WindowPtr)pDRIPriv->DRIDrawables[oldestIndex];
- pOldDrawPriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pOldWin);
- pOldDrawPriv->drawableIndex = -1;
-
- /* claim drawable table entry */
- pDRIPriv->DRIDrawables[oldestIndex] = pDrawable;
-
- /* validate SAREA entry */
- pDRIPriv->pSAREA->drawableTable[oldestIndex].stamp =
- DRIDrawableValidationStamp++;
-
- /* check for stamp wrap around */
- if (oldestStamp > DRIDrawableValidationStamp) {
-
- /* walk SAREA table and invalidate all drawables */
- for( i=0;
+
+ i = pDRIPriv->pDriverInfo->maxDrawableTableEntry;
+ while (i--) {
+ if (pDRIPriv->pSAREA->drawableTable[i].stamp <
+ oldestStamp) {
+ oldestIndex = i;
+ oldestStamp =
+ pDRIPriv->pSAREA->drawableTable[i].stamp;
+ }
+ }
+ pDRIDrawablePriv->drawableIndex = oldestIndex;
+
+ /* release oldest drawable table entry */
+ pOldWin = (WindowPtr) pDRIPriv->DRIDrawables[oldestIndex];
+ pOldDrawPriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pOldWin);
+ pOldDrawPriv->drawableIndex = -1;
+
+ /* claim drawable table entry */
+ pDRIPriv->DRIDrawables[oldestIndex] = pDrawable;
+
+ /* validate SAREA entry */
+ pDRIPriv->pSAREA->drawableTable[oldestIndex].stamp =
+ DRIDrawableValidationStamp++;
+
+ /* check for stamp wrap around */
+ if (oldestStamp > DRIDrawableValidationStamp) {
+
+ /* walk SAREA table and invalidate all drawables */
+ for (i = 0;
i < pDRIPriv->pDriverInfo->maxDrawableTableEntry;
i++) {
- pDRIPriv->pSAREA->drawableTable[i].stamp =
- DRIDrawableValidationStamp++;
- }
- }
- }
-
- /* If the driver wants to be notified when the index is
- * set for a drawable, let it know now.
- */
- if (pDRIPriv->pDriverInfo->SetDrawableIndex)
- pDRIPriv->pDriverInfo->SetDrawableIndex(pWin,
- pDRIDrawablePriv->drawableIndex);
-
- /* reinit drawable ID if window is visible */
- if ((pWin->viewable) &&
- (pDRIPriv->pDriverInfo->bufferRequests != DRI_NO_WINDOWS))
- {
- (*pDRIPriv->pDriverInfo->InitBuffers)(pWin,
- &pWin->clipList, pDRIDrawablePriv->drawableIndex);
- }
- }
-
- *index = pDRIDrawablePriv->drawableIndex;
- *stamp = pDRIPriv->pSAREA->drawableTable[*index].stamp;
- *X = (int)(pWin->drawable.x);
- *Y = (int)(pWin->drawable.y);
- *W = (int)(pWin->drawable.width);
- *H = (int)(pWin->drawable.height);
- *numClipRects = RegionNumRects(&pWin->clipList);
- *pClipRects = (drm_clip_rect_t *)RegionRects(&pWin->clipList);
-
- if (!*numClipRects && pDRIPriv->fullscreen) {
- /* use fake full-screen clip rect */
- pDRIPriv->fullscreen_rect.x1 = *X;
- pDRIPriv->fullscreen_rect.y1 = *Y;
- pDRIPriv->fullscreen_rect.x2 = *X + *W;
- pDRIPriv->fullscreen_rect.y2 = *Y + *H;
-
- *numClipRects = 1;
- *pClipRects = &pDRIPriv->fullscreen_rect;
- }
-
- *backX = *X;
- *backY = *Y;
-
- if (pDRIPriv->nrWindowsVisible == 1 && *numClipRects) {
- /* Use a single cliprect. */
-
- int x0 = *X;
- int y0 = *Y;
- int x1 = x0 + *W;
- int y1 = y0 + *H;
-
- if (x0 < 0) x0 = 0;
- if (y0 < 0) y0 = 0;
- if (x1 > pScreen->width) x1 = pScreen->width;
- if (y1 > pScreen->height) y1 = pScreen->height;
-
- if (y0 >= y1 || x0 >= x1) {
- *numBackClipRects = 0;
- *pBackClipRects = NULL;
- } else {
- pDRIPriv->private_buffer_rect.x1 = x0;
- pDRIPriv->private_buffer_rect.y1 = y0;
- pDRIPriv->private_buffer_rect.x2 = x1;
- pDRIPriv->private_buffer_rect.y2 = y1;
-
- *numBackClipRects = 1;
- *pBackClipRects = &(pDRIPriv->private_buffer_rect);
- }
- } else {
- /* Use the frontbuffer cliprects for back buffers. */
- *numBackClipRects = 0;
- *pBackClipRects = 0;
- }
- }
- else {
- /* Not a DRIDrawable */
- return FALSE;
- }
- }
- else { /* pixmap (or for GLX 1.3, a PBuffer) */
- /* NOT_DONE */
- return FALSE;
+ pDRIPriv->pSAREA->drawableTable[i].stamp =
+ DRIDrawableValidationStamp++;
+ }
+ }
+ }
+
+ /* If the driver wants to be notified when the index is
+ * set for a drawable, let it know now.
+ */
+ if (pDRIPriv->pDriverInfo->SetDrawableIndex)
+ pDRIPriv->pDriverInfo->SetDrawableIndex(pWin,
+ pDRIDrawablePriv->
+ drawableIndex);
+
+ /* reinit drawable ID if window is visible */
+ if ((pWin->viewable) &&
+ (pDRIPriv->pDriverInfo->bufferRequests != DRI_NO_WINDOWS)) {
+ (*pDRIPriv->pDriverInfo->InitBuffers) (pWin,
+ &pWin->clipList,
+ pDRIDrawablePriv->
+ drawableIndex);
+ }
+ }
+
+ *index = pDRIDrawablePriv->drawableIndex;
+ *stamp = pDRIPriv->pSAREA->drawableTable[*index].stamp;
+ *X = (int) (pWin->drawable.x);
+ *Y = (int) (pWin->drawable.y);
+ *W = (int) (pWin->drawable.width);
+ *H = (int) (pWin->drawable.height);
+ *numClipRects = RegionNumRects(&pWin->clipList);
+ *pClipRects = (drm_clip_rect_t *) RegionRects(&pWin->clipList);
+
+ if (!*numClipRects && pDRIPriv->fullscreen) {
+ /* use fake full-screen clip rect */
+ pDRIPriv->fullscreen_rect.x1 = *X;
+ pDRIPriv->fullscreen_rect.y1 = *Y;
+ pDRIPriv->fullscreen_rect.x2 = *X + *W;
+ pDRIPriv->fullscreen_rect.y2 = *Y + *H;
+
+ *numClipRects = 1;
+ *pClipRects = &pDRIPriv->fullscreen_rect;
+ }
+
+ *backX = *X;
+ *backY = *Y;
+
+ if (pDRIPriv->nrWindowsVisible == 1 && *numClipRects) {
+ /* Use a single cliprect. */
+
+ int x0 = *X;
+ int y0 = *Y;
+ int x1 = x0 + *W;
+ int y1 = y0 + *H;
+
+ if (x0 < 0)
+ x0 = 0;
+ if (y0 < 0)
+ y0 = 0;
+ if (x1 > pScreen->width)
+ x1 = pScreen->width;
+ if (y1 > pScreen->height)
+ y1 = pScreen->height;
+
+ if (y0 >= y1 || x0 >= x1) {
+ *numBackClipRects = 0;
+ *pBackClipRects = NULL;
+ }
+ else {
+ pDRIPriv->private_buffer_rect.x1 = x0;
+ pDRIPriv->private_buffer_rect.y1 = y0;
+ pDRIPriv->private_buffer_rect.x2 = x1;
+ pDRIPriv->private_buffer_rect.y2 = y1;
+
+ *numBackClipRects = 1;
+ *pBackClipRects = &(pDRIPriv->private_buffer_rect);
+ }
+ }
+ else {
+ /* Use the frontbuffer cliprects for back buffers. */
+ *numBackClipRects = 0;
+ *pBackClipRects = 0;
+ }
+ }
+ else {
+ /* Not a DRIDrawable */
+ return FALSE;
+ }
+ }
+ else { /* pixmap (or for GLX 1.3, a PBuffer) */
+ /* NOT_DONE */
+ return FALSE;
}
return TRUE;
@@ -1561,11 +1557,9 @@ DRIGetDrawableInfo(ScreenPtr pScreen,
Bool
DRIGetDeviceInfo(ScreenPtr pScreen,
drm_handle_t * hFrameBuffer,
- int* fbOrigin,
- int* fbSize,
- int* fbStride,
- int* devPrivateSize,
- void** pDevPrivate)
+ int *fbOrigin,
+ int *fbSize,
+ int *fbStride, int *devPrivateSize, void **pDevPrivate)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
@@ -1582,21 +1576,23 @@ DRIGetDeviceInfo(ScreenPtr pScreen,
DRIInfoPtr
DRICreateInfoRec(void)
{
- DRIInfoPtr inforec = (DRIInfoPtr)calloc(1, sizeof(DRIInfoRec));
- if (!inforec) return NULL;
+ DRIInfoPtr inforec = (DRIInfoPtr) calloc(1, sizeof(DRIInfoRec));
+
+ if (!inforec)
+ return NULL;
/* Initialize defaults */
inforec->busIdString = NULL;
/* Wrapped function defaults */
- inforec->wrap.WakeupHandler = DRIDoWakeupHandler;
- inforec->wrap.BlockHandler = DRIDoBlockHandler;
- inforec->wrap.WindowExposures = DRIWindowExposures;
- inforec->wrap.CopyWindow = DRICopyWindow;
- inforec->wrap.ValidateTree = DRIValidateTree;
- inforec->wrap.PostValidateTree = DRIPostValidateTree;
- inforec->wrap.ClipNotify = DRIClipNotify;
- inforec->wrap.AdjustFrame = DRIAdjustFrame;
+ inforec->wrap.WakeupHandler = DRIDoWakeupHandler;
+ inforec->wrap.BlockHandler = DRIDoBlockHandler;
+ inforec->wrap.WindowExposures = DRIWindowExposures;
+ inforec->wrap.CopyWindow = DRICopyWindow;
+ inforec->wrap.ValidateTree = DRIValidateTree;
+ inforec->wrap.PostValidateTree = DRIPostValidateTree;
+ inforec->wrap.ClipNotify = DRIClipNotify;
+ inforec->wrap.AdjustFrame = DRIAdjustFrame;
inforec->TransitionTo2d = 0;
inforec->TransitionTo3d = 0;
@@ -1609,23 +1605,21 @@ void
DRIDestroyInfoRec(DRIInfoPtr DRIInfo)
{
free(DRIInfo->busIdString);
- free((char*)DRIInfo);
+ free((char *) DRIInfo);
}
-
void
DRIWakeupHandler(pointer wakeupData, int result, pointer pReadmask)
{
int i;
for (i = 0; i < screenInfo.numScreens; i++) {
- ScreenPtr pScreen = screenInfo.screens[i];
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ ScreenPtr pScreen = screenInfo.screens[i];
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if (pDRIPriv &&
- pDRIPriv->pDriverInfo->wrap.WakeupHandler)
- (*pDRIPriv->pDriverInfo->wrap.WakeupHandler)(i, wakeupData,
- result, pReadmask);
+ if (pDRIPriv && pDRIPriv->pDriverInfo->wrap.WakeupHandler)
+ (*pDRIPriv->pDriverInfo->wrap.WakeupHandler) (i, wakeupData,
+ result, pReadmask);
}
}
@@ -1635,13 +1629,12 @@ DRIBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
int i;
for (i = 0; i < screenInfo.numScreens; i++) {
- ScreenPtr pScreen = screenInfo.screens[i];
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ ScreenPtr pScreen = screenInfo.screens[i];
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if (pDRIPriv &&
- pDRIPriv->pDriverInfo->wrap.BlockHandler)
- (*pDRIPriv->pDriverInfo->wrap.BlockHandler)(i, blockData,
- pTimeout, pReadmask);
+ if (pDRIPriv && pDRIPriv->pDriverInfo->wrap.BlockHandler)
+ (*pDRIPriv->pDriverInfo->wrap.BlockHandler) (i, blockData,
+ pTimeout, pReadmask);
}
}
@@ -1654,13 +1647,13 @@ DRIDoWakeupHandler(int screenNum, pointer wakeupData,
DRILock(pScreen, 0);
if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
- /* hide X context by swapping 2D component here */
- (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
- DRI_3D_SYNC,
- DRI_2D_CONTEXT,
- pDRIPriv->partial3DContextStore,
- DRI_2D_CONTEXT,
- pDRIPriv->hiddenContextStore);
+ /* hide X context by swapping 2D component here */
+ (*pDRIPriv->pDriverInfo->SwapContext) (pScreen,
+ DRI_3D_SYNC,
+ DRI_2D_CONTEXT,
+ pDRIPriv->partial3DContextStore,
+ DRI_2D_CONTEXT,
+ pDRIPriv->hiddenContextStore);
}
}
@@ -1672,13 +1665,13 @@ DRIDoBlockHandler(int screenNum, pointer blockData,
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
- /* hide X context by swapping 2D component here */
- (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
- DRI_2D_SYNC,
- DRI_NO_CONTEXT,
- NULL,
- DRI_2D_CONTEXT,
- pDRIPriv->partial3DContextStore);
+ /* hide X context by swapping 2D component here */
+ (*pDRIPriv->pDriverInfo->SwapContext) (pScreen,
+ DRI_2D_SYNC,
+ DRI_NO_CONTEXT,
+ NULL,
+ DRI_2D_CONTEXT,
+ pDRIPriv->partial3DContextStore);
}
if (pDRIPriv->windowsTouched)
@@ -1691,154 +1684,155 @@ DRIDoBlockHandler(int screenNum, pointer blockData,
void
DRISwapContext(int drmFD, void *oldctx, void *newctx)
{
- DRIContextPrivPtr oldContext = (DRIContextPrivPtr)oldctx;
- DRIContextPrivPtr newContext = (DRIContextPrivPtr)newctx;
- ScreenPtr pScreen = newContext->pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- void* oldContextStore = NULL;
- DRIContextType oldContextType;
- void* newContextStore = NULL;
- DRIContextType newContextType;
- DRISyncType syncType;
+ DRIContextPrivPtr oldContext = (DRIContextPrivPtr) oldctx;
+ DRIContextPrivPtr newContext = (DRIContextPrivPtr) newctx;
+ ScreenPtr pScreen = newContext->pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ void *oldContextStore = NULL;
+ DRIContextType oldContextType;
+ void *newContextStore = NULL;
+ DRIContextType newContextType;
+ DRISyncType syncType;
+
#ifdef DEBUG
- static int count = 0;
+ static int count = 0;
if (!newContext) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[DRI] Context Switch Error: oldContext=%x, newContext=%x\n",
- oldContext, newContext);
- return;
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI] Context Switch Error: oldContext=%x, newContext=%x\n",
+ oldContext, newContext);
+ return;
}
/* usefull for debugging, just print out after n context switches */
if (!count || !(count % 1)) {
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[DRI] Context switch %5d from %p/0x%08x (%d)\n",
- count,
- oldContext,
- oldContext ? oldContext->flags : 0,
- oldContext ? oldContext->hwContext : -1);
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[DRI] Context switch %5d to %p/0x%08x (%d)\n",
- count,
- newContext,
- newContext ? newContext->flags : 0,
- newContext ? newContext->hwContext : -1);
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[DRI] Context switch %5d from %p/0x%08x (%d)\n",
+ count,
+ oldContext,
+ oldContext ? oldContext->flags : 0,
+ oldContext ? oldContext->hwContext : -1);
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[DRI] Context switch %5d to %p/0x%08x (%d)\n",
+ count,
+ newContext,
+ newContext ? newContext->flags : 0,
+ newContext ? newContext->hwContext : -1);
}
++count;
#endif
if (!pDRIPriv->pDriverInfo->SwapContext) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[DRI] DDX driver missing context swap call back\n");
- return;
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI] DDX driver missing context swap call back\n");
+ return;
}
if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
/* only 3D contexts are swapped in this case */
- if (oldContext) {
- oldContextStore = DRIGetContextStore(oldContext);
- oldContext->valid3D = TRUE;
- oldContextType = DRI_3D_CONTEXT;
- } else {
- oldContextType = DRI_NO_CONTEXT;
- }
- newContextStore = DRIGetContextStore(newContext);
- if ((newContext->valid3D) &&
- (newContext->hwContext != pDRIPriv->myContext)) {
- newContextType = DRI_3D_CONTEXT;
- }
- else {
- newContextType = DRI_2D_CONTEXT;
- }
- syncType = DRI_3D_SYNC;
- }
- else /* default: driverSwapMethod == DRI_SERVER_SWAP */ {
+ if (oldContext) {
+ oldContextStore = DRIGetContextStore(oldContext);
+ oldContext->valid3D = TRUE;
+ oldContextType = DRI_3D_CONTEXT;
+ }
+ else {
+ oldContextType = DRI_NO_CONTEXT;
+ }
+ newContextStore = DRIGetContextStore(newContext);
+ if ((newContext->valid3D) &&
+ (newContext->hwContext != pDRIPriv->myContext)) {
+ newContextType = DRI_3D_CONTEXT;
+ }
+ else {
+ newContextType = DRI_2D_CONTEXT;
+ }
+ syncType = DRI_3D_SYNC;
+ }
+ else { /* default: driverSwapMethod == DRI_SERVER_SWAP */
/* optimize 2D context swaps */
- if (newContext->flags & DRI_CONTEXT_2DONLY) {
- /* go from 3D context to 2D context and only save 2D
+ if (newContext->flags & DRI_CONTEXT_2DONLY) {
+ /* go from 3D context to 2D context and only save 2D
* subset of 3D state
*/
- oldContextStore = DRIGetContextStore(oldContext);
- oldContextType = DRI_2D_CONTEXT;
- newContextStore = DRIGetContextStore(newContext);
- newContextType = DRI_2D_CONTEXT;
- syncType = DRI_3D_SYNC;
- pDRIPriv->lastPartial3DContext = oldContext;
- }
- else if (oldContext->flags & DRI_CONTEXT_2DONLY) {
- if (pDRIPriv->lastPartial3DContext == newContext) {
- /* go from 2D context back to previous 3D context and
- * only restore 2D subset of previous 3D state
- */
- oldContextStore = DRIGetContextStore(oldContext);
- oldContextType = DRI_2D_CONTEXT;
- newContextStore = DRIGetContextStore(newContext);
- newContextType = DRI_2D_CONTEXT;
- syncType = DRI_2D_SYNC;
- }
- else {
- /* go from 2D context to a different 3D context */
-
- /* call DDX driver to do partial restore */
- oldContextStore = DRIGetContextStore(oldContext);
- newContextStore =
- DRIGetContextStore(pDRIPriv->lastPartial3DContext);
- (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
- DRI_2D_SYNC,
- DRI_2D_CONTEXT,
- oldContextStore,
- DRI_2D_CONTEXT,
- newContextStore);
-
- /* now setup for a complete 3D swap */
- oldContextStore = newContextStore;
- oldContext->valid3D = TRUE;
- oldContextType = DRI_3D_CONTEXT;
- newContextStore = DRIGetContextStore(newContext);
- if ((newContext->valid3D) &&
- (newContext->hwContext != pDRIPriv->myContext)) {
- newContextType = DRI_3D_CONTEXT;
- }
- else {
- newContextType = DRI_2D_CONTEXT;
- }
- syncType = DRI_NO_SYNC;
- }
- }
- else {
- /* now setup for a complete 3D swap */
- oldContextStore = newContextStore;
- oldContext->valid3D = TRUE;
- oldContextType = DRI_3D_CONTEXT;
- newContextStore = DRIGetContextStore(newContext);
- if ((newContext->valid3D) &&
- (newContext->hwContext != pDRIPriv->myContext)) {
- newContextType = DRI_3D_CONTEXT;
- }
- else {
- newContextType = DRI_2D_CONTEXT;
- }
- syncType = DRI_3D_SYNC;
- }
+ oldContextStore = DRIGetContextStore(oldContext);
+ oldContextType = DRI_2D_CONTEXT;
+ newContextStore = DRIGetContextStore(newContext);
+ newContextType = DRI_2D_CONTEXT;
+ syncType = DRI_3D_SYNC;
+ pDRIPriv->lastPartial3DContext = oldContext;
+ }
+ else if (oldContext->flags & DRI_CONTEXT_2DONLY) {
+ if (pDRIPriv->lastPartial3DContext == newContext) {
+ /* go from 2D context back to previous 3D context and
+ * only restore 2D subset of previous 3D state
+ */
+ oldContextStore = DRIGetContextStore(oldContext);
+ oldContextType = DRI_2D_CONTEXT;
+ newContextStore = DRIGetContextStore(newContext);
+ newContextType = DRI_2D_CONTEXT;
+ syncType = DRI_2D_SYNC;
+ }
+ else {
+ /* go from 2D context to a different 3D context */
+
+ /* call DDX driver to do partial restore */
+ oldContextStore = DRIGetContextStore(oldContext);
+ newContextStore =
+ DRIGetContextStore(pDRIPriv->lastPartial3DContext);
+ (*pDRIPriv->pDriverInfo->SwapContext) (pScreen,
+ DRI_2D_SYNC,
+ DRI_2D_CONTEXT,
+ oldContextStore,
+ DRI_2D_CONTEXT,
+ newContextStore);
+
+ /* now setup for a complete 3D swap */
+ oldContextStore = newContextStore;
+ oldContext->valid3D = TRUE;
+ oldContextType = DRI_3D_CONTEXT;
+ newContextStore = DRIGetContextStore(newContext);
+ if ((newContext->valid3D) &&
+ (newContext->hwContext != pDRIPriv->myContext)) {
+ newContextType = DRI_3D_CONTEXT;
+ }
+ else {
+ newContextType = DRI_2D_CONTEXT;
+ }
+ syncType = DRI_NO_SYNC;
+ }
+ }
+ else {
+ /* now setup for a complete 3D swap */
+ oldContextStore = newContextStore;
+ oldContext->valid3D = TRUE;
+ oldContextType = DRI_3D_CONTEXT;
+ newContextStore = DRIGetContextStore(newContext);
+ if ((newContext->valid3D) &&
+ (newContext->hwContext != pDRIPriv->myContext)) {
+ newContextType = DRI_3D_CONTEXT;
+ }
+ else {
+ newContextType = DRI_2D_CONTEXT;
+ }
+ syncType = DRI_3D_SYNC;
+ }
}
/* call DDX driver to perform the swap */
- (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
- syncType,
- oldContextType,
- oldContextStore,
- newContextType,
- newContextStore);
+ (*pDRIPriv->pDriverInfo->SwapContext) (pScreen,
+ syncType,
+ oldContextType,
+ oldContextStore,
+ newContextType, newContextStore);
}
-void*
+void *
DRIGetContextStore(DRIContextPrivPtr context)
{
- return((void *)context->pContextStore);
+ return ((void *) context->pContextStore);
}
void
@@ -1848,45 +1842,44 @@ DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg)
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
- if(pDRIDrawablePriv) {
- (*pDRIPriv->pDriverInfo->InitBuffers)(pWin, prgn,
+ if (pDRIDrawablePriv) {
+ (*pDRIPriv->pDriverInfo->InitBuffers) (pWin, prgn,
pDRIDrawablePriv->drawableIndex);
}
/* call lower wrapped functions */
if (pDRIPriv && pDRIPriv->wrap.WindowExposures) {
- /* unwrap */
- pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
+ /* unwrap */
+ pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
- /* call lower layers */
- (*pScreen->WindowExposures)(pWin, prgn, bsreg);
+ /* call lower layers */
+ (*pScreen->WindowExposures) (pWin, prgn, bsreg);
- /* rewrap */
- pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
- pScreen->WindowExposures = DRIWindowExposures;
+ /* rewrap */
+ pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
+ pScreen->WindowExposures = DRIWindowExposures;
}
}
-
static int
DRITreeTraversal(WindowPtr pWin, pointer data)
{
DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
- if(pDRIDrawablePriv) {
+ if (pDRIDrawablePriv) {
ScreenPtr pScreen = pWin->drawable.pScreen;
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if(RegionNumRects(&(pWin->clipList)) > 0) {
- RegionPtr reg = (RegionPtr)data;
+ if (RegionNumRects(&(pWin->clipList)) > 0) {
+ RegionPtr reg = (RegionPtr) data;
- RegionUnion(reg, reg, &(pWin->clipList));
- pDRIPriv->nrWalked++;
- }
+ RegionUnion(reg, reg, &(pWin->clipList));
+ pDRIPriv->nrWalked++;
+ }
- if(pDRIPriv->nrWindows == pDRIPriv->nrWalked)
- return WT_STOPWALKING;
+ if (pDRIPriv->nrWindows == pDRIPriv->nrWalked)
+ return WT_STOPWALKING;
}
return WT_WALKCHILDREN;
}
@@ -1901,16 +1894,16 @@ DRIDestroyWindow(WindowPtr pWin)
DRIDrawablePrivDestroy(pWin);
/* call lower wrapped functions */
- if(pDRIPriv->DestroyWindow) {
- /* unwrap */
- pScreen->DestroyWindow = pDRIPriv->DestroyWindow;
+ if (pDRIPriv->DestroyWindow) {
+ /* unwrap */
+ pScreen->DestroyWindow = pDRIPriv->DestroyWindow;
- /* call lower layers */
- retval = (*pScreen->DestroyWindow)(pWin);
+ /* call lower layers */
+ retval = (*pScreen->DestroyWindow) (pWin);
- /* rewrap */
- pDRIPriv->DestroyWindow = pScreen->DestroyWindow;
- pScreen->DestroyWindow = DRIDestroyWindow;
+ /* rewrap */
+ pDRIPriv->DestroyWindow = pScreen->DestroyWindow;
+ pScreen->DestroyWindow = DRIDestroyWindow;
}
return retval;
@@ -1922,39 +1915,41 @@ DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
ScreenPtr pScreen = pWin->drawable.pScreen;
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if(!pDRIPriv) return;
+ if (!pDRIPriv)
+ return;
- if(pDRIPriv->nrWindowsVisible > 0) {
- RegionRec reg;
+ if (pDRIPriv->nrWindowsVisible > 0) {
+ RegionRec reg;
- RegionNull(&reg);
- pDRIPriv->nrWalked = 0;
- TraverseTree(pWin, DRITreeTraversal, (pointer)(&reg));
+ RegionNull(&reg);
+ pDRIPriv->nrWalked = 0;
+ TraverseTree(pWin, DRITreeTraversal, (pointer) (&reg));
- if(RegionNotEmpty(&reg)) {
- RegionTranslate(&reg, ptOldOrg.x - pWin->drawable.x,
- ptOldOrg.y - pWin->drawable.y);
- RegionIntersect(&reg, &reg, prgnSrc);
+ if (RegionNotEmpty(&reg)) {
+ RegionTranslate(&reg, ptOldOrg.x - pWin->drawable.x,
+ ptOldOrg.y - pWin->drawable.y);
+ RegionIntersect(&reg, &reg, prgnSrc);
- /* The MoveBuffers interface is not ideal */
- (*pDRIPriv->pDriverInfo->MoveBuffers)(pWin, ptOldOrg, &reg,
- pDRIPriv->pDriverInfo->ddxDrawableTableEntry);
- }
+ /* The MoveBuffers interface is not ideal */
+ (*pDRIPriv->pDriverInfo->MoveBuffers) (pWin, ptOldOrg, &reg,
+ pDRIPriv->pDriverInfo->
+ ddxDrawableTableEntry);
+ }
- RegionUninit(&reg);
+ RegionUninit(&reg);
}
/* call lower wrapped functions */
- if(pDRIPriv->wrap.CopyWindow) {
- /* unwrap */
- pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow;
+ if (pDRIPriv->wrap.CopyWindow) {
+ /* unwrap */
+ pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow;
- /* call lower layers */
- (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc);
+ /* call lower layers */
+ (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
- /* rewrap */
- pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
- pScreen->CopyWindow = DRICopyWindow;
+ /* rewrap */
+ pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
+ pScreen->CopyWindow = DRICopyWindow;
}
}
@@ -1965,25 +1960,26 @@ DRIGetSecs(long *secs, long *usecs)
gettimeofday(&tv, NULL);
- *secs = tv.tv_sec;
+ *secs = tv.tv_sec;
*usecs = tv.tv_usec;
}
static unsigned long
DRIComputeMilliSeconds(unsigned long s_secs, unsigned long s_usecs,
- unsigned long f_secs, unsigned long f_usecs)
+ unsigned long f_secs, unsigned long f_usecs)
{
if (f_usecs < s_usecs) {
- --f_secs;
- f_usecs += 1000000;
+ --f_secs;
+ f_usecs += 1000000;
}
return (f_secs - s_secs) * 1000 + (f_usecs - s_usecs) / 1000;
}
static void
-DRISpinLockTimeout(drmLock *lock, int val, unsigned long timeout /* in mS */)
+DRISpinLockTimeout(drmLock * lock, int val, unsigned long timeout /* in mS */ )
{
- int count = 10000;
+ int count = 10000;
+
#if !defined(__alpha__) && !defined(__powerpc__)
char ret;
#else
@@ -1992,25 +1988,27 @@ DRISpinLockTimeout(drmLock *lock, int val, unsigned long timeout /* in mS */)
long s_secs, s_usecs;
long f_secs, f_usecs;
long msecs;
- long prev = 0;
+ long prev = 0;
DRIGetSecs(&s_secs, &s_usecs);
do {
- DRM_SPINLOCK_COUNT(lock, val, count, ret);
- if (!ret) return; /* Got lock */
- DRIGetSecs(&f_secs, &f_usecs);
- msecs = DRIComputeMilliSeconds(s_secs, s_usecs, f_secs, f_usecs);
- if (msecs - prev < 250) count *= 2; /* Not more than 0.5S */
+ DRM_SPINLOCK_COUNT(lock, val, count, ret);
+ if (!ret)
+ return; /* Got lock */
+ DRIGetSecs(&f_secs, &f_usecs);
+ msecs = DRIComputeMilliSeconds(s_secs, s_usecs, f_secs, f_usecs);
+ if (msecs - prev < 250)
+ count *= 2; /* Not more than 0.5S */
} while (msecs < timeout);
- /* Didn't get lock, so take it. The worst
- that can happen is that there is some
- garbage written to the wrong part of the
- framebuffer that a refresh will repair.
- That's undesirable, but better than
- locking the server. This should be a
- very rare event. */
+ /* Didn't get lock, so take it. The worst
+ that can happen is that there is some
+ garbage written to the wrong part of the
+ framebuffer that a refresh will repair.
+ That's undesirable, but better than
+ locking the server. This should be a
+ very rare event. */
DRM_SPINLOCK_TAKE(lock, val);
}
@@ -2019,16 +2017,17 @@ DRILockTree(ScreenPtr pScreen)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if(!pDRIPriv) return;
+ if (!pDRIPriv)
+ return;
/* Restore the last known 3D context if the X context is hidden */
if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
- (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
- DRI_2D_SYNC,
- DRI_NO_CONTEXT,
- NULL,
- DRI_2D_CONTEXT,
- pDRIPriv->partial3DContextStore);
+ (*pDRIPriv->pDriverInfo->SwapContext) (pScreen,
+ DRI_2D_SYNC,
+ DRI_NO_CONTEXT,
+ NULL,
+ DRI_2D_CONTEXT,
+ pDRIPriv->partial3DContextStore);
}
/* Call kernel to release lock */
@@ -2038,20 +2037,20 @@ DRILockTree(ScreenPtr pScreen)
appropriate, since this should never time out except in the case of
client death while the lock is being held. The timeout must be
greater than any reasonable rendering time. */
- DRISpinLockTimeout(&pDRIPriv->pSAREA->drawable_lock, 1, 10000); /*10 secs*/
+ DRISpinLockTimeout(&pDRIPriv->pSAREA->drawable_lock, 1, 10000); /*10 secs */
/* Call kernel flush outstanding buffers and relock */
- DRILock(pScreen, DRM_LOCK_QUIESCENT|DRM_LOCK_FLUSH_ALL);
+ DRILock(pScreen, DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH_ALL);
/* Switch back to our 2D context if the X context is hidden */
if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
- /* hide X context by swapping 2D component here */
- (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
- DRI_3D_SYNC,
- DRI_2D_CONTEXT,
- pDRIPriv->partial3DContextStore,
- DRI_2D_CONTEXT,
- pDRIPriv->hiddenContextStore);
+ /* hide X context by swapping 2D component here */
+ (*pDRIPriv->pDriverInfo->SwapContext) (pScreen,
+ DRI_3D_SYNC,
+ DRI_2D_CONTEXT,
+ pDRIPriv->partial3DContextStore,
+ DRI_2D_CONTEXT,
+ pDRIPriv->hiddenContextStore);
}
}
@@ -2061,21 +2060,22 @@ DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
ScreenPtr pScreen = pParent->drawable.pScreen;
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- int returnValue = 1; /* always return 1, not checked by dix/window.c */
+ int returnValue = 1; /* always return 1, not checked by dix/window.c */
- if(!pDRIPriv) return returnValue;
+ if (!pDRIPriv)
+ return returnValue;
/* call lower wrapped functions */
- if(pDRIPriv->wrap.ValidateTree) {
- /* unwrap */
- pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
+ if (pDRIPriv->wrap.ValidateTree) {
+ /* unwrap */
+ pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
- /* call lower layers */
- returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind);
+ /* call lower layers */
+ returnValue = (*pScreen->ValidateTree) (pParent, pChild, kind);
- /* rewrap */
- pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
- pScreen->ValidateTree = DRIValidateTree;
+ /* rewrap */
+ pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
+ pScreen->ValidateTree = DRIValidateTree;
}
return returnValue;
@@ -2088,22 +2088,24 @@ DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
DRIScreenPrivPtr pDRIPriv;
if (pParent) {
- pScreen = pParent->drawable.pScreen;
- } else {
- pScreen = pChild->drawable.pScreen;
+ pScreen = pParent->drawable.pScreen;
}
- if(!(pDRIPriv = DRI_SCREEN_PRIV(pScreen))) return;
+ else {
+ pScreen = pChild->drawable.pScreen;
+ }
+ if (!(pDRIPriv = DRI_SCREEN_PRIV(pScreen)))
+ return;
if (pDRIPriv->wrap.PostValidateTree) {
- /* unwrap */
- pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
+ /* unwrap */
+ pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
- /* call lower layers */
- (*pScreen->PostValidateTree)(pParent, pChild, kind);
+ /* call lower layers */
+ (*pScreen->PostValidateTree) (pParent, pChild, kind);
- /* rewrap */
- pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
- pScreen->PostValidateTree = DRIPostValidateTree;
+ /* rewrap */
+ pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
+ pScreen->PostValidateTree = DRIPostValidateTree;
}
}
@@ -2112,45 +2114,46 @@ DRIClipNotify(WindowPtr pWin, int dx, int dy)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv;
+ DRIDrawablePrivPtr pDRIDrawablePriv;
- if(!pDRIPriv) return;
+ if (!pDRIPriv)
+ return;
if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
int nrects = RegionNumRects(&pWin->clipList);
- if(!pDRIPriv->windowsTouched) {
+ if (!pDRIPriv->windowsTouched) {
DRILockTree(pScreen);
pDRIPriv->windowsTouched = TRUE;
}
- if (nrects && !pDRIDrawablePriv->nrects)
- DRIIncreaseNumberVisible(pScreen);
- else if (!nrects && pDRIDrawablePriv->nrects)
- DRIDecreaseNumberVisible(pScreen);
- else
- DRIDriverClipNotify(pScreen);
+ if (nrects && !pDRIDrawablePriv->nrects)
+ DRIIncreaseNumberVisible(pScreen);
+ else if (!nrects && pDRIDrawablePriv->nrects)
+ DRIDecreaseNumberVisible(pScreen);
+ else
+ DRIDriverClipNotify(pScreen);
- pDRIDrawablePriv->nrects = nrects;
+ pDRIDrawablePriv->nrects = nrects;
- pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp
- = DRIDrawableValidationStamp++;
+ pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp
+ = DRIDrawableValidationStamp++;
- drmUpdateDrawableInfo(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable,
- DRM_DRAWABLE_CLIPRECTS,
- nrects, RegionRects(&pWin->clipList));
+ drmUpdateDrawableInfo(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable,
+ DRM_DRAWABLE_CLIPRECTS,
+ nrects, RegionRects(&pWin->clipList));
}
/* call lower wrapped functions */
- if(pDRIPriv->wrap.ClipNotify) {
+ if (pDRIPriv->wrap.ClipNotify) {
- /* unwrap */
+ /* unwrap */
pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify;
- /* call lower layers */
- (*pScreen->ClipNotify)(pWin, dx, dy);
+ /* call lower layers */
+ (*pScreen->ClipNotify) (pWin, dx, dy);
- /* rewrap */
+ /* rewrap */
pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
pScreen->ClipNotify = DRIClipNotify;
}
@@ -2165,10 +2168,10 @@ DRIGetDrawableIndex(WindowPtr pWin)
CARD32 index;
if (pDRIDrawablePriv) {
- index = pDRIDrawablePriv->drawableIndex;
+ index = pDRIDrawablePriv->drawableIndex;
}
else {
- index = pDRIPriv->pDriverInfo->ddxDrawableTableEntry;
+ index = pDRIPriv->pDriverInfo->ddxDrawableTableEntry;
}
return index;
@@ -2178,16 +2181,16 @@ unsigned int
DRIGetDrawableStamp(ScreenPtr pScreen, CARD32 drawable_index)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
return pDRIPriv->pSAREA->drawableTable[drawable_index].stamp;
}
-
void
DRIPrintDrawableLock(ScreenPtr pScreen, char *msg)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- ErrorF("%s: %d\n", msg, pDRIPriv->pSAREA->drawable_lock.lock);
+ ErrorF("%s: %d\n", msg, pDRIPriv->pSAREA->drawable_lock.lock);
}
void
@@ -2195,18 +2198,20 @@ DRILock(ScreenPtr pScreen, int flags)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if(!pDRIPriv || !pDRIPriv->pLockRefCount) return;
+ if (!pDRIPriv || !pDRIPriv->pLockRefCount)
+ return;
if (!*pDRIPriv->pLockRefCount) {
- DRM_LOCK(pDRIPriv->drmFD, pDRIPriv->pLSAREA, pDRIPriv->myContext, flags);
- *pDRIPriv->pLockingContext = pDRIPriv->myContext;
- } else if (*pDRIPriv->pLockingContext != pDRIPriv->myContext) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[DRI] Locking deadlock.\n"
- "\tAlready locked with context %d,\n"
- "\ttrying to lock with context %d.\n",
- pDRIPriv->pLockingContext,
- pDRIPriv->myContext);
+ DRM_LOCK(pDRIPriv->drmFD, pDRIPriv->pLSAREA, pDRIPriv->myContext,
+ flags);
+ *pDRIPriv->pLockingContext = pDRIPriv->myContext;
+ }
+ else if (*pDRIPriv->pLockingContext != pDRIPriv->myContext) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI] Locking deadlock.\n"
+ "\tAlready locked with context %d,\n"
+ "\ttrying to lock with context %d.\n",
+ pDRIPriv->pLockingContext, pDRIPriv->myContext);
}
(*pDRIPriv->pLockRefCount)++;
}
@@ -2216,23 +2221,24 @@ DRIUnlock(ScreenPtr pScreen)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if(!pDRIPriv || !pDRIPriv->pLockRefCount) return;
+ if (!pDRIPriv || !pDRIPriv->pLockRefCount)
+ return;
if (*pDRIPriv->pLockRefCount > 0) {
- if (pDRIPriv->myContext != *pDRIPriv->pLockingContext) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[DRI] Unlocking inconsistency:\n"
- "\tContext %d trying to unlock lock held by context %d\n",
- pDRIPriv->pLockingContext,
- pDRIPriv->myContext);
- }
- (*pDRIPriv->pLockRefCount)--;
- } else {
+ if (pDRIPriv->myContext != *pDRIPriv->pLockingContext) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI] Unlocking inconsistency:\n"
+ "\tContext %d trying to unlock lock held by context %d\n",
+ pDRIPriv->pLockingContext, pDRIPriv->myContext);
+ }
+ (*pDRIPriv->pLockRefCount)--;
+ }
+ else {
DRIDrvMsg(pScreen->myNum, X_ERROR,
- "DRIUnlock called when not locked.\n");
+ "DRIUnlock called when not locked.\n");
return;
}
- if (! *pDRIPriv->pLockRefCount)
+ if (!*pDRIPriv->pLockRefCount)
DRM_UNLOCK(pDRIPriv->drmFD, pDRIPriv->pLSAREA, pDRIPriv->myContext);
}
@@ -2240,30 +2246,35 @@ void *
DRIGetSAREAPrivate(ScreenPtr pScreen)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if (!pDRIPriv) return 0;
- return (void *)(((char*)pDRIPriv->pSAREA)+sizeof(XF86DRISAREARec));
+ if (!pDRIPriv)
+ return 0;
+
+ return (void *) (((char *) pDRIPriv->pSAREA) + sizeof(XF86DRISAREARec));
}
drm_context_t
DRIGetContext(ScreenPtr pScreen)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if (!pDRIPriv) return 0;
+
+ if (!pDRIPriv)
+ return 0;
return pDRIPriv->myContext;
}
void
DRIGetTexOffsetFuncs(ScreenPtr pScreen,
- DRITexOffsetStartProcPtr *texOffsetStartFunc,
- DRITexOffsetFinishProcPtr *texOffsetFinishFunc)
+ DRITexOffsetStartProcPtr * texOffsetStartFunc,
+ DRITexOffsetFinishProcPtr * texOffsetFinishFunc)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if (!pDRIPriv) return;
+ if (!pDRIPriv)
+ return;
- *texOffsetStartFunc = pDRIPriv->pDriverInfo->texOffsetStart;
+ *texOffsetStartFunc = pDRIPriv->pDriverInfo->texOffsetStart;
*texOffsetFinishFunc = pDRIPriv->pDriverInfo->texOffsetFinish;
}
@@ -2279,9 +2290,7 @@ DRIGetWrappedFuncs(ScreenPtr pScreen)
/* note that this returns the library version, not the protocol version */
void
-DRIQueryVersion(int *majorVersion,
- int *minorVersion,
- int *patchVersion)
+DRIQueryVersion(int *majorVersion, int *minorVersion, int *patchVersion)
{
*majorVersion = DRIINFO_MAJOR_VERSION;
*minorVersion = DRIINFO_MINOR_VERSION;
@@ -2291,51 +2300,57 @@ DRIQueryVersion(int *majorVersion,
static void
_DRIAdjustFrame(ScrnInfoPtr pScrn, DRIScreenPrivPtr pDRIPriv, int x, int y)
{
- pDRIPriv->pSAREA->frame.x = x;
- pDRIPriv->pSAREA->frame.y = y;
- pDRIPriv->pSAREA->frame.width = pScrn->frameX1 - x + 1;
+ pDRIPriv->pSAREA->frame.x = x;
+ pDRIPriv->pSAREA->frame.y = y;
+ pDRIPriv->pSAREA->frame.width = pScrn->frameX1 - x + 1;
pDRIPriv->pSAREA->frame.height = pScrn->frameY1 - y + 1;
}
void
DRIAdjustFrame(int scrnIndex, int x, int y, int flags)
{
- ScreenPtr pScreen = screenInfo.screens[scrnIndex];
+ ScreenPtr pScreen = screenInfo.screens[scrnIndex];
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- int px, py;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ int px, py;
if (!pDRIPriv || !pDRIPriv->pSAREA) {
- DRIDrvMsg(scrnIndex, X_ERROR, "[DRI] No SAREA (%p %p)\n",
- pDRIPriv, pDRIPriv ? pDRIPriv->pSAREA : NULL);
- return;
+ DRIDrvMsg(scrnIndex, X_ERROR, "[DRI] No SAREA (%p %p)\n",
+ pDRIPriv, pDRIPriv ? pDRIPriv->pSAREA : NULL);
+ return;
}
if (pDRIPriv->fullscreen) {
- /* Fix up frame */
- pScrn->frameX0 = pDRIPriv->pSAREA->frame.x;
- pScrn->frameY0 = pDRIPriv->pSAREA->frame.y;
- pScrn->frameX1 = pScrn->frameX0 + pDRIPriv->pSAREA->frame.width - 1;
- pScrn->frameY1 = pScrn->frameY0 + pDRIPriv->pSAREA->frame.height - 1;
-
- /* Fix up cursor */
- miPointerGetPosition(inputInfo.pointer, &px, &py);
- if (px < pScrn->frameX0) px = pScrn->frameX0;
- if (px > pScrn->frameX1) px = pScrn->frameX1;
- if (py < pScrn->frameY0) py = pScrn->frameY0;
- if (py > pScrn->frameY1) py = pScrn->frameY1;
- pScreen->SetCursorPosition(inputInfo.pointer, pScreen, px, py, TRUE);
- return;
+ /* Fix up frame */
+ pScrn->frameX0 = pDRIPriv->pSAREA->frame.x;
+ pScrn->frameY0 = pDRIPriv->pSAREA->frame.y;
+ pScrn->frameX1 = pScrn->frameX0 + pDRIPriv->pSAREA->frame.width - 1;
+ pScrn->frameY1 = pScrn->frameY0 + pDRIPriv->pSAREA->frame.height - 1;
+
+ /* Fix up cursor */
+ miPointerGetPosition(inputInfo.pointer, &px, &py);
+
+ if (px < pScrn->frameX0)
+ px = pScrn->frameX0;
+ if (px > pScrn->frameX1)
+ px = pScrn->frameX1;
+ if (py < pScrn->frameY0)
+ py = pScrn->frameY0;
+ if (py > pScrn->frameY1)
+ py = pScrn->frameY1;
+ pScreen->SetCursorPosition(inputInfo.pointer, pScreen, px, py, TRUE);
+
+ return;
}
if (pDRIPriv->wrap.AdjustFrame) {
- /* unwrap */
- pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame;
- /* call lower layers */
- (*pScrn->AdjustFrame)(scrnIndex, x, y, flags);
- /* rewrap */
- pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame;
- pScrn->AdjustFrame = DRIAdjustFrame;
+ /* unwrap */
+ pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame;
+ /* call lower layers */
+ (*pScrn->AdjustFrame) (scrnIndex, x, y, flags);
+ /* rewrap */
+ pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame;
+ pScrn->AdjustFrame = DRIAdjustFrame;
}
_DRIAdjustFrame(pScrn, pDRIPriv, x, y);
@@ -2350,145 +2365,147 @@ DRIAdjustFrame(int scrnIndex, int x, int y, int flags)
*/
void
-DRIMoveBuffersHelper(
- ScreenPtr pScreen,
- int dx,
- int dy,
- int *xdir,
- int *ydir,
- RegionPtr reg
-)
-{
- BoxPtr extents, pbox, firstBox, lastBox;
- BoxRec tmpBox;
- int y, nbox;
-
- extents = RegionExtents(reg);
- nbox = RegionNumRects(reg);
- pbox = RegionRects(reg);
-
- if((dy > 0) && (dy < (extents->y2 - extents->y1))) {
- *ydir = -1;
- if(nbox > 1) {
- firstBox = pbox;
- lastBox = pbox + nbox - 1;
- while((unsigned long)firstBox < (unsigned long)lastBox) {
- tmpBox = *firstBox;
- *firstBox = *lastBox;
- *lastBox = tmpBox;
- firstBox++;
- lastBox--;
+DRIMoveBuffersHelper(ScreenPtr pScreen,
+ int dx, int dy, int *xdir, int *ydir, RegionPtr reg)
+{
+ BoxPtr extents, pbox, firstBox, lastBox;
+ BoxRec tmpBox;
+ int y, nbox;
+
+ extents = RegionExtents(reg);
+ nbox = RegionNumRects(reg);
+ pbox = RegionRects(reg);
+
+ if ((dy > 0) && (dy < (extents->y2 - extents->y1))) {
+ *ydir = -1;
+ if (nbox > 1) {
+ firstBox = pbox;
+ lastBox = pbox + nbox - 1;
+ while ((unsigned long) firstBox < (unsigned long) lastBox) {
+ tmpBox = *firstBox;
+ *firstBox = *lastBox;
+ *lastBox = tmpBox;
+ firstBox++;
+ lastBox--;
+ }
}
- }
- } else *ydir = 1;
-
- if((dx > 0) && (dx < (extents->x2 - extents->x1))) {
- *xdir = -1;
- if(nbox > 1) {
- firstBox = lastBox = pbox;
- y = pbox->y1;
- while(--nbox) {
- pbox++;
- if(pbox->y1 == y) lastBox++;
- else {
- while((unsigned long)firstBox < (unsigned long)lastBox) {
- tmpBox = *firstBox;
- *firstBox = *lastBox;
- *lastBox = tmpBox;
- firstBox++;
- lastBox--;
- }
-
- firstBox = lastBox = pbox;
- y = pbox->y1;
- }
- }
- while((unsigned long)firstBox < (unsigned long)lastBox) {
- tmpBox = *firstBox;
- *firstBox = *lastBox;
- *lastBox = tmpBox;
- firstBox++;
- lastBox--;
+ }
+ else
+ *ydir = 1;
+
+ if ((dx > 0) && (dx < (extents->x2 - extents->x1))) {
+ *xdir = -1;
+ if (nbox > 1) {
+ firstBox = lastBox = pbox;
+ y = pbox->y1;
+ while (--nbox) {
+ pbox++;
+ if (pbox->y1 == y)
+ lastBox++;
+ else {
+ while ((unsigned long) firstBox < (unsigned long) lastBox) {
+ tmpBox = *firstBox;
+ *firstBox = *lastBox;
+ *lastBox = tmpBox;
+ firstBox++;
+ lastBox--;
+ }
+
+ firstBox = lastBox = pbox;
+ y = pbox->y1;
+ }
+ }
+ while ((unsigned long) firstBox < (unsigned long) lastBox) {
+ tmpBox = *firstBox;
+ *firstBox = *lastBox;
+ *lastBox = tmpBox;
+ firstBox++;
+ lastBox--;
+ }
}
- }
- } else *xdir = 1;
+ }
+ else
+ *xdir = 1;
}
char *
-DRICreatePCIBusID(const struct pci_device * dev)
+DRICreatePCIBusID(const struct pci_device *dev)
{
char *busID;
if (asprintf(&busID, "pci:%04x:%02x:%02x.%d",
- dev->domain, dev->bus, dev->dev, dev->func) == -1)
- return NULL;
+ dev->domain, dev->bus, dev->dev, dev->func) == -1)
+ return NULL;
return busID;
}
-static void drmSIGIOHandler(int interrupt, void *closure)
+static void
+drmSIGIOHandler(int interrupt, void *closure)
{
unsigned long key;
- void *value;
- ssize_t count;
- drm_ctx_t ctx;
- typedef void (*_drmCallback)(int, void *, void *);
- char buf[256];
- drm_context_t old;
- drm_context_t new;
- void *oldctx;
- void *newctx;
- char *pt;
- drmHashEntry *entry;
+ void *value;
+ ssize_t count;
+ drm_ctx_t ctx;
+ typedef void (*_drmCallback) (int, void *, void *);
+ char buf[256];
+ drm_context_t old;
+ drm_context_t new;
+ void *oldctx;
+ void *newctx;
+ char *pt;
+ drmHashEntry *entry;
void *hash_table;
hash_table = drmGetHashTable();
- if (!hash_table) return;
+ if (!hash_table)
+ return;
if (drmHashFirst(hash_table, &key, &value)) {
- entry = value;
- do {
+ entry = value;
+ do {
#if 0
- fprintf(stderr, "Trying %d\n", entry->fd);
+ fprintf(stderr, "Trying %d\n", entry->fd);
#endif
- if ((count = read(entry->fd, buf, sizeof(buf) - 1)) > 0) {
- buf[count] = '\0';
+ if ((count = read(entry->fd, buf, sizeof(buf) - 1)) > 0) {
+ buf[count] = '\0';
#if 0
- fprintf(stderr, "Got %s\n", buf);
+ 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);
+ for (pt = buf; *pt != ' '; ++pt); /* Find first space */
+ ++pt;
+ old = strtol(pt, &pt, 0);
+ new = strtol(pt, NULL, 0);
+ oldctx = drmGetContextTag(entry->fd, old);
+ newctx = drmGetContextTag(entry->fd, new);
#if 0
- fprintf(stderr, "%d %d %p %p\n", old, new, oldctx, newctx);
+ fprintf(stderr, "%d %d %p %p\n", old, new, oldctx, newctx);
#endif
- ((_drmCallback)entry->f)(entry->fd, oldctx, newctx);
- ctx.handle = new;
- ioctl(entry->fd, DRM_IOCTL_NEW_CTX, &ctx);
- }
- } while (drmHashNext(hash_table, &key, &value));
+ ((_drmCallback) entry->f) (entry->fd, oldctx, newctx);
+ ctx.handle = new;
+ ioctl(entry->fd, DRM_IOCTL_NEW_CTX, &ctx);
+ }
+ } while (drmHashNext(hash_table, &key, &value));
}
}
-
-int drmInstallSIGIOHandler(int fd, void (*f)(int, void *, void *))
+int
+drmInstallSIGIOHandler(int fd, void (*f) (int, void *, void *))
{
- drmHashEntry *entry;
+ drmHashEntry *entry;
- entry = drmGetEntry(fd);
- entry->f = f;
+ entry = drmGetEntry(fd);
+ entry->f = f;
return xf86InstallSIGIOHandler(fd, drmSIGIOHandler, 0);
}
-int drmRemoveSIGIOHandler(int fd)
+int
+drmRemoveSIGIOHandler(int fd)
{
- drmHashEntry *entry = drmGetEntry(fd);
+ drmHashEntry *entry = drmGetEntry(fd);
entry->f = NULL;
diff --git a/xorg-server/hw/xfree86/dri/dri.h b/xorg-server/hw/xfree86/dri/dri.h
index f690e234b..53458bb4a 100644
--- a/xorg-server/hw/xfree86/dri/dri.h
+++ b/xorg-server/hw/xfree86/dri/dri.h
@@ -50,11 +50,10 @@ typedef int DRIContextType;
typedef struct _DRIContextPrivRec DRIContextPrivRec, *DRIContextPrivPtr;
-typedef enum _DRIContextFlags
-{
- DRI_CONTEXT_2DONLY = 0x01,
+typedef enum _DRIContextFlags {
+ DRI_CONTEXT_2DONLY = 0x01,
DRI_CONTEXT_PRESERVED = 0x02,
- DRI_CONTEXT_RESERVED = 0x04 /* DRI Only -- no kernel equivalent */
+ DRI_CONTEXT_RESERVED = 0x04 /* DRI Only -- no kernel equivalent */
} DRIContextFlags;
#define DRI_NO_CONTEXT 0
@@ -73,10 +72,8 @@ typedef int DRIWindowRequests;
#define DRI_3D_WINDOWS_ONLY 1
#define DRI_ALL_WINDOWS 2
-
-typedef void (*ClipNotifyPtr)( WindowPtr, int, int );
-typedef void (*AdjustFramePtr)(int scrnIndex, int x, int y, int flags);
-
+typedef void (*ClipNotifyPtr) (WindowPtr, int, int);
+typedef void (*AdjustFramePtr) (int scrnIndex, int x, int y, int flags);
/*
* These functions can be wrapped by the DRI. Each of these have
@@ -84,17 +81,16 @@ typedef void (*AdjustFramePtr)(int scrnIndex, int x, int y, int flags);
* overridden by the driver in its [driver]DRIScreenInit function.
*/
typedef struct {
- ScreenWakeupHandlerProcPtr WakeupHandler;
- ScreenBlockHandlerProcPtr BlockHandler;
- WindowExposuresProcPtr WindowExposures;
- CopyWindowProcPtr CopyWindow;
- ValidateTreeProcPtr ValidateTree;
- PostValidateTreeProcPtr PostValidateTree;
- ClipNotifyProcPtr ClipNotify;
- AdjustFramePtr AdjustFrame;
+ ScreenWakeupHandlerProcPtr WakeupHandler;
+ ScreenBlockHandlerProcPtr BlockHandler;
+ WindowExposuresProcPtr WindowExposures;
+ CopyWindowProcPtr CopyWindow;
+ ValidateTreeProcPtr ValidateTree;
+ PostValidateTreeProcPtr PostValidateTree;
+ ClipNotifyProcPtr ClipNotify;
+ AdjustFramePtr AdjustFrame;
} DRIWrappedFuncsRec, *DRIWrappedFuncsPtr;
-
/*
* Prior to Xorg 6.8.99.8, the DRIInfoRec structure was implicitly versioned
* by the XF86DRI_*_VERSION defines in xf86dristr.h. These numbers were also
@@ -112,8 +108,8 @@ typedef struct {
#define DRIINFO_MINOR_VERSION 4
#define DRIINFO_PATCH_VERSION 0
-typedef unsigned long long (*DRITexOffsetStartProcPtr)(PixmapPtr pPix);
-typedef void (*DRITexOffsetFinishProcPtr)(PixmapPtr pPix);
+typedef unsigned long long (*DRITexOffsetStartProcPtr) (PixmapPtr pPix);
+typedef void (*DRITexOffsetFinishProcPtr) (PixmapPtr pPix);
typedef struct {
/* driver call back functions
@@ -123,88 +119,81 @@ typedef struct {
* Bump the DRIINFO minor number to indicate new fields.
* Bump the DRIINFO major number to indicate binary-incompatible changes.
*/
- Bool (*CreateContext)(ScreenPtr pScreen,
- VisualPtr visual,
- drm_context_t hHWContext,
- void* pVisualConfigPriv,
- DRIContextType context);
- void (*DestroyContext)(ScreenPtr pScreen,
- drm_context_t hHWContext,
- DRIContextType context);
- void (*SwapContext)(ScreenPtr pScreen,
- DRISyncType syncType,
- DRIContextType readContextType,
- void* readContextStore,
- DRIContextType writeContextType,
- void* writeContextStore);
- void (*InitBuffers)(WindowPtr pWin,
- RegionPtr prgn,
- CARD32 indx);
- void (*MoveBuffers)(WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgnSrc,
- CARD32 indx);
- void (*TransitionTo3d)(ScreenPtr pScreen);
- void (*TransitionTo2d)(ScreenPtr pScreen);
-
- void (*SetDrawableIndex)(WindowPtr pWin, CARD32 indx);
- Bool (*OpenFullScreen)(ScreenPtr pScreen);
- Bool (*CloseFullScreen)(ScreenPtr pScreen);
+ Bool (*CreateContext) (ScreenPtr pScreen,
+ VisualPtr visual,
+ drm_context_t hHWContext,
+ void *pVisualConfigPriv, DRIContextType context);
+ void (*DestroyContext) (ScreenPtr pScreen,
+ drm_context_t hHWContext, DRIContextType context);
+ void (*SwapContext) (ScreenPtr pScreen,
+ DRISyncType syncType,
+ DRIContextType readContextType,
+ void *readContextStore,
+ DRIContextType writeContextType,
+ void *writeContextStore);
+ void (*InitBuffers) (WindowPtr pWin, RegionPtr prgn, CARD32 indx);
+ void (*MoveBuffers) (WindowPtr pWin,
+ DDXPointRec ptOldOrg, RegionPtr prgnSrc, CARD32 indx);
+ void (*TransitionTo3d) (ScreenPtr pScreen);
+ void (*TransitionTo2d) (ScreenPtr pScreen);
+
+ void (*SetDrawableIndex) (WindowPtr pWin, CARD32 indx);
+ Bool (*OpenFullScreen) (ScreenPtr pScreen);
+ Bool (*CloseFullScreen) (ScreenPtr pScreen);
/* wrapped functions */
- DRIWrappedFuncsRec wrap;
+ DRIWrappedFuncsRec wrap;
/* device info */
- char* drmDriverName;
- char* clientDriverName;
- char* busIdString;
- int ddxDriverMajorVersion;
- int ddxDriverMinorVersion;
- int ddxDriverPatchVersion;
- pointer frameBufferPhysicalAddress;
- long frameBufferSize;
- long frameBufferStride;
- long SAREASize;
- int maxDrawableTableEntry;
- int ddxDrawableTableEntry;
- long contextSize;
- DRISwapMethod driverSwapMethod;
- DRIWindowRequests bufferRequests;
- int devPrivateSize;
- void* devPrivate;
- Bool createDummyCtx;
- Bool createDummyCtxPriv;
+ char *drmDriverName;
+ char *clientDriverName;
+ char *busIdString;
+ int ddxDriverMajorVersion;
+ int ddxDriverMinorVersion;
+ int ddxDriverPatchVersion;
+ pointer frameBufferPhysicalAddress;
+ long frameBufferSize;
+ long frameBufferStride;
+ long SAREASize;
+ int maxDrawableTableEntry;
+ int ddxDrawableTableEntry;
+ long contextSize;
+ DRISwapMethod driverSwapMethod;
+ DRIWindowRequests bufferRequests;
+ int devPrivateSize;
+ void *devPrivate;
+ Bool createDummyCtx;
+ Bool createDummyCtxPriv;
/* New with DRI version 4.1.0 */
- void (*TransitionSingleToMulti3D)(ScreenPtr pScreen);
- void (*TransitionMultiToSingle3D)(ScreenPtr pScreen);
+ void (*TransitionSingleToMulti3D) (ScreenPtr pScreen);
+ void (*TransitionMultiToSingle3D) (ScreenPtr pScreen);
/* New with DRI version 5.1.0 */
- void (*ClipNotify)(ScreenPtr pScreen, WindowPtr *ppWin, int num);
+ void (*ClipNotify) (ScreenPtr pScreen, WindowPtr *ppWin, int num);
/* New with DRI version 5.2.0 */
- Bool allocSarea;
- Bool keepFDOpen;
+ Bool allocSarea;
+ Bool keepFDOpen;
/* New with DRI version 5.3.0 */
- DRITexOffsetStartProcPtr texOffsetStart;
+ DRITexOffsetStartProcPtr texOffsetStart;
DRITexOffsetFinishProcPtr texOffsetFinish;
/* New with DRI version 5.4.0 */
- int dontMapFrameBuffer;
- drm_handle_t hFrameBuffer; /* Handle to framebuffer, either
- * mapped by DDX driver or DRI */
-
-} DRIInfoRec, *DRIInfoPtr;
+ int dontMapFrameBuffer;
+ drm_handle_t hFrameBuffer; /* Handle to framebuffer, either
+ * mapped by DDX driver or DRI */
+} DRIInfoRec, *DRIInfoPtr;
-extern _X_EXPORT Bool DRIOpenDRMMaster(ScrnInfoPtr pScrn, unsigned long sAreaSize,
- const char *busID,
- const char *drmDriverName);
+extern _X_EXPORT Bool DRIOpenDRMMaster(ScrnInfoPtr pScrn,
+ unsigned long sAreaSize,
+ const char *busID,
+ const char *drmDriverName);
extern _X_EXPORT Bool DRIScreenInit(ScreenPtr pScreen,
- DRIInfoPtr pDRIInfo,
- int *pDRMFD);
+ DRIInfoPtr pDRIInfo, int *pDRMFD);
extern _X_EXPORT void DRICloseScreen(ScreenPtr pScreen);
@@ -213,65 +202,62 @@ extern _X_EXPORT Bool DRIExtensionInit(void);
extern _X_EXPORT void DRIReset(void);
extern _X_EXPORT Bool DRIQueryDirectRenderingCapable(ScreenPtr pScreen,
- Bool *isCapable);
+ Bool *isCapable);
extern _X_EXPORT Bool DRIOpenConnection(ScreenPtr pScreen,
- drm_handle_t * hSAREA,
- char **busIdString);
+ drm_handle_t * hSAREA,
+ char **busIdString);
extern _X_EXPORT Bool DRIAuthConnection(ScreenPtr pScreen, drm_magic_t magic);
extern _X_EXPORT Bool DRICloseConnection(ScreenPtr pScreen);
extern _X_EXPORT Bool DRIGetClientDriverName(ScreenPtr pScreen,
- int* ddxDriverMajorVersion,
- int* ddxDriverMinorVersion,
- int* ddxDriverPatchVersion,
- char** clientDriverName);
+ int *ddxDriverMajorVersion,
+ int *ddxDriverMinorVersion,
+ int *ddxDriverPatchVersion,
+ char **clientDriverName);
extern _X_EXPORT Bool DRICreateContext(ScreenPtr pScreen,
- VisualPtr visual,
- XID context,
- drm_context_t * pHWContext);
+ VisualPtr visual,
+ XID context, drm_context_t * pHWContext);
extern _X_EXPORT Bool DRIDestroyContext(ScreenPtr pScreen, XID context);
extern _X_EXPORT Bool DRIContextPrivDelete(pointer pResource, XID id);
extern _X_EXPORT Bool DRICreateDrawable(ScreenPtr pScreen,
- ClientPtr client,
- DrawablePtr pDrawable,
- drm_drawable_t * hHWDrawable);
+ ClientPtr client,
+ DrawablePtr pDrawable,
+ drm_drawable_t * hHWDrawable);
extern _X_EXPORT Bool DRIDestroyDrawable(ScreenPtr pScreen,
- ClientPtr client,
- DrawablePtr pDrawable);
+ ClientPtr client,
+ DrawablePtr pDrawable);
-extern _X_EXPORT Bool DRIDrawablePrivDelete(pointer pResource,
- XID id);
+extern _X_EXPORT Bool DRIDrawablePrivDelete(pointer pResource, XID id);
extern _X_EXPORT Bool DRIGetDrawableInfo(ScreenPtr pScreen,
- DrawablePtr pDrawable,
- unsigned int* indx,
- unsigned int* stamp,
- int* X,
- int* Y,
- int* W,
- int* H,
- int* numClipRects,
- drm_clip_rect_t ** pClipRects,
- int* backX,
- int* backY,
- int* numBackClipRects,
- drm_clip_rect_t ** pBackClipRects);
+ DrawablePtr pDrawable,
+ unsigned int *indx,
+ unsigned int *stamp,
+ int *X,
+ int *Y,
+ int *W,
+ int *H,
+ int *numClipRects,
+ drm_clip_rect_t ** pClipRects,
+ int *backX,
+ int *backY,
+ int *numBackClipRects,
+ drm_clip_rect_t ** pBackClipRects);
extern _X_EXPORT Bool DRIGetDeviceInfo(ScreenPtr pScreen,
- drm_handle_t * hFrameBuffer,
- int* fbOrigin,
- int* fbSize,
- int* fbStride,
- int* devPrivateSize,
- void** pDevPrivate);
+ drm_handle_t * hFrameBuffer,
+ int *fbOrigin,
+ int *fbSize,
+ int *fbStride,
+ int *devPrivateSize, void **pDevPrivate);
extern _X_EXPORT DRIInfoPtr DRICreateInfoRec(void);
@@ -280,50 +266,39 @@ extern _X_EXPORT void DRIDestroyInfoRec(DRIInfoPtr DRIInfo);
extern _X_EXPORT Bool DRIFinishScreenInit(ScreenPtr pScreen);
extern _X_EXPORT void DRIWakeupHandler(pointer wakeupData,
- int result,
- pointer pReadmask);
+ int result, pointer pReadmask);
extern _X_EXPORT void DRIBlockHandler(pointer blockData,
- OSTimePtr pTimeout,
- pointer pReadmask);
+ OSTimePtr pTimeout, pointer pReadmask);
extern _X_EXPORT void DRIDoWakeupHandler(int screenNum,
- pointer wakeupData,
- unsigned long result,
- pointer pReadmask);
+ pointer wakeupData,
+ unsigned long result,
+ pointer pReadmask);
extern _X_EXPORT void DRIDoBlockHandler(int screenNum,
- pointer blockData,
- pointer pTimeout,
- pointer pReadmask);
+ pointer blockData,
+ pointer pTimeout, pointer pReadmask);
-extern _X_EXPORT void DRISwapContext(int drmFD,
- void *oldctx,
- void *newctx);
+extern _X_EXPORT void DRISwapContext(int drmFD, void *oldctx, void *newctx);
extern _X_EXPORT void *DRIGetContextStore(DRIContextPrivPtr context);
extern _X_EXPORT void DRIWindowExposures(WindowPtr pWin,
- RegionPtr prgn,
- RegionPtr bsreg);
+ RegionPtr prgn, RegionPtr bsreg);
extern _X_EXPORT Bool DRIDestroyWindow(WindowPtr pWin);
extern _X_EXPORT void DRICopyWindow(WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgnSrc);
+ DDXPointRec ptOldOrg, RegionPtr prgnSrc);
extern _X_EXPORT int DRIValidateTree(WindowPtr pParent,
- WindowPtr pChild,
- VTKind kind);
+ WindowPtr pChild, VTKind kind);
extern _X_EXPORT void DRIPostValidateTree(WindowPtr pParent,
- WindowPtr pChild,
- VTKind kind);
+ WindowPtr pChild, VTKind kind);
-extern _X_EXPORT void DRIClipNotify(WindowPtr pWin,
- int dx,
- int dy);
+extern _X_EXPORT void DRIClipNotify(WindowPtr pWin, int dx, int dy);
extern _X_EXPORT CARD32 DRIGetDrawableIndex(WindowPtr pWin);
@@ -338,36 +313,38 @@ extern _X_EXPORT DRIWrappedFuncsRec *DRIGetWrappedFuncs(ScreenPtr pScreen);
extern _X_EXPORT void *DRIGetSAREAPrivate(ScreenPtr pScreen);
extern _X_EXPORT unsigned int DRIGetDrawableStamp(ScreenPtr pScreen,
- CARD32 drawable_index);
+ CARD32 drawable_index);
extern _X_EXPORT DRIContextPrivPtr DRICreateContextPriv(ScreenPtr pScreen,
- drm_context_t * pHWContext,
- DRIContextFlags flags);
-
-extern _X_EXPORT DRIContextPrivPtr DRICreateContextPrivFromHandle(ScreenPtr pScreen,
- drm_context_t hHWContext,
+ drm_context_t *
+ pHWContext,
DRIContextFlags flags);
+extern _X_EXPORT DRIContextPrivPtr DRICreateContextPrivFromHandle(ScreenPtr
+ pScreen,
+ drm_context_t
+ hHWContext,
+ DRIContextFlags
+ flags);
+
extern _X_EXPORT Bool DRIDestroyContextPriv(DRIContextPrivPtr pDRIContextPriv);
extern _X_EXPORT drm_context_t DRIGetContext(ScreenPtr pScreen);
extern _X_EXPORT void DRIQueryVersion(int *majorVersion,
- int *minorVersion,
- int *patchVersion);
+ int *minorVersion, int *patchVersion);
extern _X_EXPORT void DRIAdjustFrame(int scrnIndex, int x, int y, int flags);
extern _X_EXPORT void DRIMoveBuffersHelper(ScreenPtr pScreen,
- int dx,
- int dy,
- int *xdir,
- int *ydir,
- RegionPtr reg);
+ int dx,
+ int dy,
+ int *xdir, int *ydir, RegionPtr reg);
extern _X_EXPORT char *DRICreatePCIBusID(const struct pci_device *PciInfo);
-extern _X_EXPORT int drmInstallSIGIOHandler(int fd, void (*f)(int, void *, void *));
+extern _X_EXPORT int drmInstallSIGIOHandler(int fd,
+ void (*f) (int, void *, void *));
extern _X_EXPORT int drmRemoveSIGIOHandler(int fd);
extern _X_EXPORT int DRIMasterFD(ScrnInfoPtr pScrn);
@@ -376,8 +353,10 @@ extern _X_EXPORT void *DRIMasterSareaPointer(ScrnInfoPtr pScrn);
extern _X_EXPORT drm_handle_t DRIMasterSareaHandle(ScrnInfoPtr pScrn);
extern _X_EXPORT void DRIGetTexOffsetFuncs(ScreenPtr pScreen,
- DRITexOffsetStartProcPtr *texOffsetStartFunc,
- DRITexOffsetFinishProcPtr *texOffsetFinishFunc);
+ DRITexOffsetStartProcPtr *
+ texOffsetStartFunc,
+ DRITexOffsetFinishProcPtr *
+ texOffsetFinishFunc);
#define _DRI_H_
diff --git a/xorg-server/hw/xfree86/dri/drimodule.c b/xorg-server/hw/xfree86/dri/drimodule.c
index 28f6ad8c0..83eca4eb9 100644
--- a/xorg-server/hw/xfree86/dri/drimodule.c
+++ b/xorg-server/hw/xfree86/dri/drimodule.c
@@ -44,26 +44,25 @@ static MODULESETUPPROTO(driSetup);
drmServerInfo DRIDRMServerInfo;
-static XF86ModuleVersionInfo VersRec =
-{
- "dri",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 0, 0,
- ABI_CLASS_EXTENSION,
- ABI_EXTENSION_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0}
+static XF86ModuleVersionInfo VersRec = {
+ "dri",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_EXTENSION,
+ ABI_EXTENSION_VERSION,
+ MOD_CLASS_NONE,
+ {0, 0, 0, 0}
};
extern void XFree86DRIExtensionInit(INITARGS);
+
#define _XF86DRI_SERVER_
#include <X11/dri/xf86driproto.h>
-static ExtensionModule XF86DRIExt =
-{
+static ExtensionModule XF86DRIExt = {
XFree86DRIExtensionInit,
XF86DRINAME,
&noXFree86DRIExtension,
@@ -79,15 +78,16 @@ driSetup(pointer module, pointer opts, int *errmaj, int *errmin)
static Bool setupDone = FALSE;
if (!setupDone) {
- setupDone = TRUE;
- LoadExtension(&XF86DRIExt, FALSE);
- } else {
- if (errmaj) *errmaj = LDR_ONCEONLY;
+ setupDone = TRUE;
+ LoadExtension(&XF86DRIExt, FALSE);
+ }
+ else {
+ if (errmaj)
+ *errmaj = LDR_ONCEONLY;
}
drmSetServerInfo(&DRIDRMServerInfo);
/* Need a non-NULL return value to indicate success */
- return (pointer)1;
+ return (pointer) 1;
}
-
diff --git a/xorg-server/hw/xfree86/dri/dristruct.h b/xorg-server/hw/xfree86/dri/dristruct.h
index bbd158e11..9f944a793 100644
--- a/xorg-server/hw/xfree86/dri/dristruct.h
+++ b/xorg-server/hw/xfree86/dri/dristruct.h
@@ -1,129 +1,124 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Jens Owen <jens@tungstengraphics.com>
- *
- */
-
-#ifndef DRI_STRUCT_H
-#define DRI_STRUCT_H
-
-#include "xf86drm.h"
-#include "xf86Crtc.h"
-
-
-#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) ((DRIDrawablePrivPtr) \
- dixLookupPrivate(&(pWin)->devPrivates, DRIWindowPrivKey))
-#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) ((DRIDrawablePrivPtr) \
- dixLookupPrivate(&(pPix)->devPrivates, DRIWindowPrivKey))
-
-typedef struct _DRIDrawablePrivRec
-{
- drm_drawable_t hwDrawable;
- int drawableIndex;
- ScreenPtr pScreen;
- int refCount;
- int nrects;
-} DRIDrawablePrivRec, *DRIDrawablePrivPtr;
-
-struct _DRIContextPrivRec
-{
- drm_context_t hwContext;
- ScreenPtr pScreen;
- Bool valid3D;
- DRIContextFlags flags;
- void** pContextStore;
-};
-
-#define DRI_SCREEN_PRIV(pScreen) ((DRIScreenPrivPtr) \
- (dixPrivateKeyRegistered(DRIScreenPrivKey) ? \
- dixLookupPrivate(&(pScreen)->devPrivates, DRIScreenPrivKey) : NULL))
-
-#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
- dixLookupPrivate(&screenInfo.screens[screenIndex]->devPrivates, \
- DRIScreenPrivKey))
-
-#define DRI_ENT_PRIV(pScrn) \
- ((DRIEntPrivIndex < 0) ? \
- NULL: \
- ((DRIEntPrivPtr)(xf86GetEntityPrivate((pScrn)->entityList[0], \
- DRIEntPrivIndex)->ptr)))
-
-typedef struct _DRIScreenPrivRec
-{
- Bool directRenderingSupport;
- int drmFD; /* File descriptor for /dev/video/? */
- drm_handle_t hSAREA; /* Handle to SAREA, for mapping */
- XF86DRISAREAPtr pSAREA; /* Mapped pointer to SAREA */
- drm_context_t myContext; /* DDX Driver's context */
- DRIContextPrivPtr myContextPriv;/* Pointer to server's private area */
- DRIContextPrivPtr lastPartial3DContext; /* last one partially saved */
- void** hiddenContextStore; /* hidden X context */
- void** partial3DContextStore; /* parital 3D context */
- DRIInfoPtr pDriverInfo;
- int nrWindows;
- int nrWindowsVisible;
- int nrWalked;
- drm_clip_rect_t private_buffer_rect; /* management of private buffers */
- DrawablePtr fullscreen; /* pointer to fullscreen drawable */
- drm_clip_rect_t fullscreen_rect; /* fake rect for fullscreen mode */
- DRIWrappedFuncsRec wrap;
- DestroyWindowProcPtr DestroyWindow;
- DrawablePtr DRIDrawables[SAREA_MAX_DRAWABLES];
- DRIContextPrivPtr dummyCtxPriv; /* Pointer to dummy context */
- Bool createDummyCtx;
- Bool createDummyCtxPriv;
- Bool grabbedDRILock;
- Bool drmSIGIOHandlerInstalled;
- Bool wrapped;
- Bool windowsTouched;
- int lockRefCount;
- drm_handle_t hLSAREA; /* Handle to SAREA containing lock, for mapping */
- XF86DRILSAREAPtr pLSAREA; /* Mapped pointer to SAREA containing lock */
- int* pLockRefCount;
- int* pLockingContext;
- xf86_crtc_notify_proc_ptr xf86_crtc_notify;
-} DRIScreenPrivRec, *DRIScreenPrivPtr;
-
-
-typedef struct _DRIEntPrivRec {
- int drmFD;
- Bool drmOpened;
- Bool sAreaGrabbed;
- drm_handle_t hLSAREA;
- XF86DRILSAREAPtr pLSAREA;
- unsigned long sAreaSize;
- int lockRefCount;
- int lockingContext;
- ScreenPtr resOwner;
- Bool keepFDOpen;
- int refCount;
-} DRIEntPrivRec, *DRIEntPrivPtr;
-
-#endif /* DRI_STRUCT_H */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Jens Owen <jens@tungstengraphics.com>
+ *
+ */
+
+#ifndef DRI_STRUCT_H
+#define DRI_STRUCT_H
+
+#include "xf86drm.h"
+#include "xf86Crtc.h"
+
+#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) ((DRIDrawablePrivPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, DRIWindowPrivKey))
+#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) ((DRIDrawablePrivPtr) \
+ dixLookupPrivate(&(pPix)->devPrivates, DRIWindowPrivKey))
+
+typedef struct _DRIDrawablePrivRec {
+ drm_drawable_t hwDrawable;
+ int drawableIndex;
+ ScreenPtr pScreen;
+ int refCount;
+ int nrects;
+} DRIDrawablePrivRec, *DRIDrawablePrivPtr;
+
+struct _DRIContextPrivRec {
+ drm_context_t hwContext;
+ ScreenPtr pScreen;
+ Bool valid3D;
+ DRIContextFlags flags;
+ void **pContextStore;
+};
+
+#define DRI_SCREEN_PRIV(pScreen) ((DRIScreenPrivPtr) \
+ (dixPrivateKeyRegistered(DRIScreenPrivKey) ? \
+ dixLookupPrivate(&(pScreen)->devPrivates, DRIScreenPrivKey) : NULL))
+
+#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
+ dixLookupPrivate(&screenInfo.screens[screenIndex]->devPrivates, \
+ DRIScreenPrivKey))
+
+#define DRI_ENT_PRIV(pScrn) \
+ ((DRIEntPrivIndex < 0) ? \
+ NULL: \
+ ((DRIEntPrivPtr)(xf86GetEntityPrivate((pScrn)->entityList[0], \
+ DRIEntPrivIndex)->ptr)))
+
+typedef struct _DRIScreenPrivRec {
+ Bool directRenderingSupport;
+ int drmFD; /* File descriptor for /dev/video/? */
+ drm_handle_t hSAREA; /* Handle to SAREA, for mapping */
+ XF86DRISAREAPtr pSAREA; /* Mapped pointer to SAREA */
+ drm_context_t myContext; /* DDX Driver's context */
+ DRIContextPrivPtr myContextPriv; /* Pointer to server's private area */
+ DRIContextPrivPtr lastPartial3DContext; /* last one partially saved */
+ void **hiddenContextStore; /* hidden X context */
+ void **partial3DContextStore; /* parital 3D context */
+ DRIInfoPtr pDriverInfo;
+ int nrWindows;
+ int nrWindowsVisible;
+ int nrWalked;
+ drm_clip_rect_t private_buffer_rect; /* management of private buffers */
+ DrawablePtr fullscreen; /* pointer to fullscreen drawable */
+ drm_clip_rect_t fullscreen_rect; /* fake rect for fullscreen mode */
+ DRIWrappedFuncsRec wrap;
+ DestroyWindowProcPtr DestroyWindow;
+ DrawablePtr DRIDrawables[SAREA_MAX_DRAWABLES];
+ DRIContextPrivPtr dummyCtxPriv; /* Pointer to dummy context */
+ Bool createDummyCtx;
+ Bool createDummyCtxPriv;
+ Bool grabbedDRILock;
+ Bool drmSIGIOHandlerInstalled;
+ Bool wrapped;
+ Bool windowsTouched;
+ int lockRefCount;
+ drm_handle_t hLSAREA; /* Handle to SAREA containing lock, for mapping */
+ XF86DRILSAREAPtr pLSAREA; /* Mapped pointer to SAREA containing lock */
+ int *pLockRefCount;
+ int *pLockingContext;
+ xf86_crtc_notify_proc_ptr xf86_crtc_notify;
+} DRIScreenPrivRec, *DRIScreenPrivPtr;
+
+typedef struct _DRIEntPrivRec {
+ int drmFD;
+ Bool drmOpened;
+ Bool sAreaGrabbed;
+ drm_handle_t hLSAREA;
+ XF86DRILSAREAPtr pLSAREA;
+ unsigned long sAreaSize;
+ int lockRefCount;
+ int lockingContext;
+ ScreenPtr resOwner;
+ Bool keepFDOpen;
+ int refCount;
+} DRIEntPrivRec, *DRIEntPrivPtr;
+
+#endif /* DRI_STRUCT_H */
diff --git a/xorg-server/hw/xfree86/dri/xf86dri.c b/xorg-server/hw/xfree86/dri/xf86dri.c
index c35ba2f94..72ce8690d 100644
--- a/xorg-server/hw/xfree86/dri/xf86dri.c
+++ b/xorg-server/hw/xfree86/dri/xf86dri.c
@@ -63,27 +63,20 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
static int DRIErrorBase;
-
-
-static void XF86DRIResetProc(ExtensionEntry* extEntry);
+static void XF86DRIResetProc(ExtensionEntry * extEntry);
static unsigned char DRIReqCode = 0;
extern void XFree86DRIExtensionInit(void);
-/*ARGSUSED*/
-static void
-XF86DRIResetProc (
- ExtensionEntry* extEntry
-)
+ /*ARGSUSED*/ static void
+XF86DRIResetProc(ExtensionEntry * extEntry)
{
DRIReset();
}
static int
-ProcXF86DRIQueryVersion(
- register ClientPtr client
-)
+ProcXF86DRIQueryVersion(register ClientPtr client)
{
xXF86DRIQueryVersionReply rep;
@@ -95,109 +88,105 @@ ProcXF86DRIQueryVersion(
rep.minorVersion = SERVER_XF86DRI_MINOR_VERSION;
rep.patchVersion = SERVER_XF86DRI_PATCH_VERSION;
if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swaps(&rep.majorVersion);
- swaps(&rep.minorVersion);
- swapl(&rep.patchVersion);
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
+ swaps(&rep.majorVersion);
+ swaps(&rep.minorVersion);
+ swapl(&rep.patchVersion);
}
- WriteToClient(client, sizeof(xXF86DRIQueryVersionReply), (char *)&rep);
+ WriteToClient(client, sizeof(xXF86DRIQueryVersionReply), (char *) &rep);
return Success;
}
static int
-ProcXF86DRIQueryDirectRenderingCapable(
- register ClientPtr client
-)
+ProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client)
{
- xXF86DRIQueryDirectRenderingCapableReply rep;
+ xXF86DRIQueryDirectRenderingCapableReply rep;
Bool isCapable;
REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
REQUEST_SIZE_MATCH(xXF86DRIQueryDirectRenderingCapableReq);
if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
+ client->errorValue = stuff->screen;
+ return BadValue;
}
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
- if (!DRIQueryDirectRenderingCapable( screenInfo.screens[stuff->screen],
- &isCapable)) {
- return BadValue;
+ if (!DRIQueryDirectRenderingCapable(screenInfo.screens[stuff->screen],
+ &isCapable)) {
+ return BadValue;
}
rep.isCapable = isCapable;
if (!LocalClient(client) || client->swapped)
- rep.isCapable = 0;
+ rep.isCapable = 0;
if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
}
- WriteToClient(client,
- sizeof(xXF86DRIQueryDirectRenderingCapableReply), (char *)&rep);
+ WriteToClient(client,
+ sizeof(xXF86DRIQueryDirectRenderingCapableReply),
+ (char *) &rep);
return Success;
}
static int
-ProcXF86DRIOpenConnection(
- register ClientPtr client
-)
+ProcXF86DRIOpenConnection(register ClientPtr client)
{
xXF86DRIOpenConnectionReply rep;
- drm_handle_t hSAREA;
- char* busIdString;
+ drm_handle_t hSAREA;
+ char *busIdString;
REQUEST(xXF86DRIOpenConnectionReq);
REQUEST_SIZE_MATCH(xXF86DRIOpenConnectionReq);
if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
+ client->errorValue = stuff->screen;
+ return BadValue;
}
- if (!DRIOpenConnection( screenInfo.screens[stuff->screen],
- &hSAREA,
- &busIdString)) {
- return BadValue;
+ if (!DRIOpenConnection(screenInfo.screens[stuff->screen],
+ &hSAREA, &busIdString)) {
+ return BadValue;
}
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.busIdStringLength = 0;
if (busIdString)
- rep.busIdStringLength = strlen(busIdString);
- rep.length = bytes_to_int32(SIZEOF(xXF86DRIOpenConnectionReply) - SIZEOF(xGenericReply) +
- pad_to_int32(rep.busIdStringLength));
+ rep.busIdStringLength = strlen(busIdString);
+ rep.length =
+ bytes_to_int32(SIZEOF(xXF86DRIOpenConnectionReply) -
+ SIZEOF(xGenericReply) +
+ pad_to_int32(rep.busIdStringLength));
- rep.hSAREALow = (CARD32)(hSAREA & 0xffffffff);
+ rep.hSAREALow = (CARD32) (hSAREA & 0xffffffff);
#if defined(LONG64) && !defined(__linux__)
- rep.hSAREAHigh = (CARD32)(hSAREA >> 32);
+ rep.hSAREAHigh = (CARD32) (hSAREA >> 32);
#else
rep.hSAREAHigh = 0;
#endif
- WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), (char *)&rep);
+ WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), (char *) &rep);
if (rep.busIdStringLength)
- WriteToClient(client, rep.busIdStringLength, busIdString);
+ WriteToClient(client, rep.busIdStringLength, busIdString);
return Success;
}
static int
-ProcXF86DRIAuthConnection(
- register ClientPtr client
-)
+ProcXF86DRIAuthConnection(register ClientPtr client)
{
xXF86DRIAuthConnectionReply rep;
-
+
REQUEST(xXF86DRIAuthConnectionReq);
REQUEST_SIZE_MATCH(xXF86DRIAuthConnectionReq);
if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
+ client->errorValue = stuff->screen;
+ return BadValue;
}
rep.type = X_Reply;
@@ -205,83 +194,75 @@ ProcXF86DRIAuthConnection(
rep.sequenceNumber = client->sequence;
rep.authenticated = 1;
- if (!DRIAuthConnection( screenInfo.screens[stuff->screen], stuff->magic)) {
- ErrorF("Failed to authenticate %lu\n", (unsigned long)stuff->magic);
- rep.authenticated = 0;
+ if (!DRIAuthConnection(screenInfo.screens[stuff->screen], stuff->magic)) {
+ ErrorF("Failed to authenticate %lu\n", (unsigned long) stuff->magic);
+ rep.authenticated = 0;
}
- WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), (char *)&rep);
+ WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), (char *) &rep);
return Success;
}
static int
-ProcXF86DRICloseConnection(
- register ClientPtr client
-)
+ProcXF86DRICloseConnection(register ClientPtr client)
{
REQUEST(xXF86DRICloseConnectionReq);
REQUEST_SIZE_MATCH(xXF86DRICloseConnectionReq);
if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
+ client->errorValue = stuff->screen;
+ return BadValue;
}
- DRICloseConnection( screenInfo.screens[stuff->screen]);
+ DRICloseConnection(screenInfo.screens[stuff->screen]);
return Success;
}
static int
-ProcXF86DRIGetClientDriverName(
- register ClientPtr client
-)
+ProcXF86DRIGetClientDriverName(register ClientPtr client)
{
- xXF86DRIGetClientDriverNameReply rep;
- char* clientDriverName;
+ xXF86DRIGetClientDriverNameReply rep;
+ char *clientDriverName;
REQUEST(xXF86DRIGetClientDriverNameReq);
REQUEST_SIZE_MATCH(xXF86DRIGetClientDriverNameReq);
if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
+ client->errorValue = stuff->screen;
+ return BadValue;
}
- DRIGetClientDriverName( screenInfo.screens[stuff->screen],
- (int *)&rep.ddxDriverMajorVersion,
- (int *)&rep.ddxDriverMinorVersion,
- (int *)&rep.ddxDriverPatchVersion,
- &clientDriverName);
+ DRIGetClientDriverName(screenInfo.screens[stuff->screen],
+ (int *) &rep.ddxDriverMajorVersion,
+ (int *) &rep.ddxDriverMinorVersion,
+ (int *) &rep.ddxDriverPatchVersion,
+ &clientDriverName);
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.clientDriverNameLength = 0;
if (clientDriverName)
- rep.clientDriverNameLength = strlen(clientDriverName);
+ rep.clientDriverNameLength = strlen(clientDriverName);
rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetClientDriverNameReply) -
- SIZEOF(xGenericReply) +
- pad_to_int32(rep.clientDriverNameLength));
+ SIZEOF(xGenericReply) +
+ pad_to_int32(rep.clientDriverNameLength));
- WriteToClient(client,
- sizeof(xXF86DRIGetClientDriverNameReply), (char *)&rep);
+ WriteToClient(client,
+ sizeof(xXF86DRIGetClientDriverNameReply), (char *) &rep);
if (rep.clientDriverNameLength)
- WriteToClient(client,
- rep.clientDriverNameLength,
- clientDriverName);
+ WriteToClient(client, rep.clientDriverNameLength, clientDriverName);
return Success;
}
static int
-ProcXF86DRICreateContext(
- register ClientPtr client
-)
+ProcXF86DRICreateContext(register ClientPtr client)
{
- xXF86DRICreateContextReply rep;
+ xXF86DRICreateContextReply rep;
ScreenPtr pScreen;
REQUEST(xXF86DRICreateContextReq);
REQUEST_SIZE_MATCH(xXF86DRICreateContextReq);
if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
+ client->errorValue = stuff->screen;
+ return BadValue;
}
rep.type = X_Reply;
@@ -290,51 +271,45 @@ ProcXF86DRICreateContext(
pScreen = screenInfo.screens[stuff->screen];
- if (!DRICreateContext( pScreen,
- NULL,
- stuff->context,
- (drm_context_t *)&rep.hHWContext)) {
- return BadValue;
+ if (!DRICreateContext(pScreen,
+ NULL,
+ stuff->context, (drm_context_t *) & rep.hHWContext)) {
+ return BadValue;
}
- WriteToClient(client, sizeof(xXF86DRICreateContextReply), (char *)&rep);
+ WriteToClient(client, sizeof(xXF86DRICreateContextReply), (char *) &rep);
return Success;
}
static int
-ProcXF86DRIDestroyContext(
- register ClientPtr client
-)
+ProcXF86DRIDestroyContext(register ClientPtr client)
{
REQUEST(xXF86DRIDestroyContextReq);
REQUEST_SIZE_MATCH(xXF86DRIDestroyContextReq);
if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
+ client->errorValue = stuff->screen;
+ return BadValue;
}
- if (!DRIDestroyContext( screenInfo.screens[stuff->screen],
- stuff->context)) {
- return BadValue;
+ if (!DRIDestroyContext(screenInfo.screens[stuff->screen], stuff->context)) {
+ return BadValue;
}
return Success;
}
static int
-ProcXF86DRICreateDrawable(
- ClientPtr client
-)
+ProcXF86DRICreateDrawable(ClientPtr client)
{
- xXF86DRICreateDrawableReply rep;
+ xXF86DRICreateDrawableReply rep;
DrawablePtr pDrawable;
int rc;
REQUEST(xXF86DRICreateDrawableReq);
REQUEST_SIZE_MATCH(xXF86DRICreateDrawableReq);
if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
+ client->errorValue = stuff->screen;
+ return BadValue;
}
rep.type = X_Reply;
@@ -342,64 +317,61 @@ ProcXF86DRICreateDrawable(
rep.sequenceNumber = client->sequence;
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
- DixReadAccess);
+ DixReadAccess);
if (rc != Success)
- return rc;
+ return rc;
if (!DRICreateDrawable(screenInfo.screens[stuff->screen], client,
- pDrawable, (drm_drawable_t *)&rep.hHWDrawable)) {
- return BadValue;
+ pDrawable, (drm_drawable_t *) & rep.hHWDrawable)) {
+ return BadValue;
}
- WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), (char *)&rep);
+ WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), (char *) &rep);
return Success;
}
static int
-ProcXF86DRIDestroyDrawable(
- register ClientPtr client
-)
+ProcXF86DRIDestroyDrawable(register ClientPtr client)
{
REQUEST(xXF86DRIDestroyDrawableReq);
DrawablePtr pDrawable;
int rc;
+
REQUEST_SIZE_MATCH(xXF86DRIDestroyDrawableReq);
if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
+ client->errorValue = stuff->screen;
+ return BadValue;
}
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
- DixReadAccess);
+ DixReadAccess);
if (rc != Success)
- return rc;
+ return rc;
if (!DRIDestroyDrawable(screenInfo.screens[stuff->screen], client,
- pDrawable)) {
- return BadValue;
+ pDrawable)) {
+ return BadValue;
}
return Success;
}
static int
-ProcXF86DRIGetDrawableInfo(
- register ClientPtr client
-)
+ProcXF86DRIGetDrawableInfo(register ClientPtr client)
{
- xXF86DRIGetDrawableInfoReply rep;
+ xXF86DRIGetDrawableInfoReply rep;
DrawablePtr pDrawable;
int X, Y, W, H;
- drm_clip_rect_t * pClipRects, *pClippedRects;
- drm_clip_rect_t * pBackClipRects;
+ drm_clip_rect_t *pClipRects, *pClippedRects;
+ drm_clip_rect_t *pBackClipRects;
int backX, backY, rc;
REQUEST(xXF86DRIGetDrawableInfoReq);
REQUEST_SIZE_MATCH(xXF86DRIGetDrawableInfoReq);
if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
+ client->errorValue = stuff->screen;
+ return BadValue;
}
rep.type = X_Reply;
@@ -407,191 +379,181 @@ ProcXF86DRIGetDrawableInfo(
rep.sequenceNumber = client->sequence;
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
- DixReadAccess);
+ DixReadAccess);
if (rc != Success)
- return rc;
-
- if (!DRIGetDrawableInfo( screenInfo.screens[stuff->screen],
- pDrawable,
- (unsigned int*)&rep.drawableTableIndex,
- (unsigned int*)&rep.drawableTableStamp,
- (int*)&X,
- (int*)&Y,
- (int*)&W,
- (int*)&H,
- (int*)&rep.numClipRects,
- &pClipRects,
- &backX,
- &backY,
- (int*)&rep.numBackClipRects,
- &pBackClipRects)) {
- return BadValue;
+ return rc;
+
+ if (!DRIGetDrawableInfo(screenInfo.screens[stuff->screen],
+ pDrawable,
+ (unsigned int *) &rep.drawableTableIndex,
+ (unsigned int *) &rep.drawableTableStamp,
+ (int *) &X,
+ (int *) &Y,
+ (int *) &W,
+ (int *) &H,
+ (int *) &rep.numClipRects,
+ &pClipRects,
+ &backX,
+ &backY,
+ (int *) &rep.numBackClipRects, &pBackClipRects)) {
+ return BadValue;
}
rep.drawableX = X;
rep.drawableY = Y;
rep.drawableWidth = W;
rep.drawableHeight = H;
- rep.length = (SIZEOF(xXF86DRIGetDrawableInfoReply) -
- SIZEOF(xGenericReply));
+ rep.length = (SIZEOF(xXF86DRIGetDrawableInfoReply) - SIZEOF(xGenericReply));
rep.backX = backX;
rep.backY = backY;
-
- if (rep.numBackClipRects)
- rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects;
+
+ if (rep.numBackClipRects)
+ rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects;
pClippedRects = pClipRects;
if (rep.numClipRects) {
- /* Clip cliprects to screen dimensions (redirected windows) */
- pClippedRects = malloc(rep.numClipRects * sizeof(drm_clip_rect_t));
-
- if (pClippedRects) {
- ScreenPtr pScreen = screenInfo.screens[stuff->screen];
- int i, j;
-
- for (i = 0, j = 0; i < rep.numClipRects; i++) {
- pClippedRects[j].x1 = max(pClipRects[i].x1, 0);
- pClippedRects[j].y1 = max(pClipRects[i].y1, 0);
- pClippedRects[j].x2 = min(pClipRects[i].x2, pScreen->width);
- pClippedRects[j].y2 = min(pClipRects[i].y2, pScreen->height);
-
- if (pClippedRects[j].x1 < pClippedRects[j].x2 &&
- pClippedRects[j].y1 < pClippedRects[j].y2) {
- j++;
- }
- }
-
- rep.numClipRects = j;
- } else {
- rep.numClipRects = 0;
- }
-
- rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects;
+ /* Clip cliprects to screen dimensions (redirected windows) */
+ pClippedRects = malloc(rep.numClipRects * sizeof(drm_clip_rect_t));
+
+ if (pClippedRects) {
+ ScreenPtr pScreen = screenInfo.screens[stuff->screen];
+ int i, j;
+
+ for (i = 0, j = 0; i < rep.numClipRects; i++) {
+ pClippedRects[j].x1 = max(pClipRects[i].x1, 0);
+ pClippedRects[j].y1 = max(pClipRects[i].y1, 0);
+ pClippedRects[j].x2 = min(pClipRects[i].x2, pScreen->width);
+ pClippedRects[j].y2 = min(pClipRects[i].y2, pScreen->height);
+
+ if (pClippedRects[j].x1 < pClippedRects[j].x2 &&
+ pClippedRects[j].y1 < pClippedRects[j].y2) {
+ j++;
+ }
+ }
+
+ rep.numClipRects = j;
+ }
+ else {
+ rep.numClipRects = 0;
+ }
+
+ rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects;
}
-
+
rep.length = bytes_to_int32(rep.length);
- WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), (char *)&rep);
+ WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), (char *) &rep);
if (rep.numClipRects) {
- WriteToClient(client,
- sizeof(drm_clip_rect_t) * rep.numClipRects,
- (char *)pClippedRects);
- free(pClippedRects);
+ WriteToClient(client,
+ sizeof(drm_clip_rect_t) * rep.numClipRects,
+ (char *) pClippedRects);
+ free(pClippedRects);
}
if (rep.numBackClipRects) {
- WriteToClient(client,
- sizeof(drm_clip_rect_t) * rep.numBackClipRects,
- (char *)pBackClipRects);
+ WriteToClient(client,
+ sizeof(drm_clip_rect_t) * rep.numBackClipRects,
+ (char *) pBackClipRects);
}
return Success;
}
static int
-ProcXF86DRIGetDeviceInfo(
- register ClientPtr client
-)
+ProcXF86DRIGetDeviceInfo(register ClientPtr client)
{
- xXF86DRIGetDeviceInfoReply rep;
+ xXF86DRIGetDeviceInfoReply rep;
drm_handle_t hFrameBuffer;
void *pDevPrivate;
REQUEST(xXF86DRIGetDeviceInfoReq);
REQUEST_SIZE_MATCH(xXF86DRIGetDeviceInfoReq);
if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
+ client->errorValue = stuff->screen;
+ return BadValue;
}
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
- if (!DRIGetDeviceInfo( screenInfo.screens[stuff->screen],
- &hFrameBuffer,
- (int*)&rep.framebufferOrigin,
- (int*)&rep.framebufferSize,
- (int*)&rep.framebufferStride,
- (int*)&rep.devPrivateSize,
- &pDevPrivate)) {
- return BadValue;
+ if (!DRIGetDeviceInfo(screenInfo.screens[stuff->screen],
+ &hFrameBuffer,
+ (int *) &rep.framebufferOrigin,
+ (int *) &rep.framebufferSize,
+ (int *) &rep.framebufferStride,
+ (int *) &rep.devPrivateSize, &pDevPrivate)) {
+ return BadValue;
}
- rep.hFrameBufferLow = (CARD32)(hFrameBuffer & 0xffffffff);
+ rep.hFrameBufferLow = (CARD32) (hFrameBuffer & 0xffffffff);
#if defined(LONG64) && !defined(__linux__)
- rep.hFrameBufferHigh = (CARD32)(hFrameBuffer >> 32);
+ rep.hFrameBufferHigh = (CARD32) (hFrameBuffer >> 32);
#else
rep.hFrameBufferHigh = 0;
#endif
rep.length = 0;
if (rep.devPrivateSize) {
- rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetDeviceInfoReply) -
- SIZEOF(xGenericReply) +
- pad_to_int32(rep.devPrivateSize));
+ rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetDeviceInfoReply) -
+ SIZEOF(xGenericReply) +
+ pad_to_int32(rep.devPrivateSize));
}
- WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), (char *)&rep);
+ WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), (char *) &rep);
if (rep.length) {
- WriteToClient(client, rep.devPrivateSize, (char *)pDevPrivate);
+ WriteToClient(client, rep.devPrivateSize, (char *) pDevPrivate);
}
return Success;
}
static int
-ProcXF86DRIDispatch (
- register ClientPtr client
-)
+ProcXF86DRIDispatch(register ClientPtr client)
{
REQUEST(xReq);
- switch (stuff->data)
- {
+ switch (stuff->data) {
case X_XF86DRIQueryVersion:
- return ProcXF86DRIQueryVersion(client);
+ return ProcXF86DRIQueryVersion(client);
case X_XF86DRIQueryDirectRenderingCapable:
- return ProcXF86DRIQueryDirectRenderingCapable(client);
+ return ProcXF86DRIQueryDirectRenderingCapable(client);
}
if (!LocalClient(client))
- return DRIErrorBase + XF86DRIClientNotLocal;
+ return DRIErrorBase + XF86DRIClientNotLocal;
- switch (stuff->data)
- {
+ switch (stuff->data) {
case X_XF86DRIOpenConnection:
- return ProcXF86DRIOpenConnection(client);
+ return ProcXF86DRIOpenConnection(client);
case X_XF86DRICloseConnection:
- return ProcXF86DRICloseConnection(client);
+ return ProcXF86DRICloseConnection(client);
case X_XF86DRIGetClientDriverName:
- return ProcXF86DRIGetClientDriverName(client);
+ return ProcXF86DRIGetClientDriverName(client);
case X_XF86DRICreateContext:
- return ProcXF86DRICreateContext(client);
+ return ProcXF86DRICreateContext(client);
case X_XF86DRIDestroyContext:
- return ProcXF86DRIDestroyContext(client);
+ return ProcXF86DRIDestroyContext(client);
case X_XF86DRICreateDrawable:
- return ProcXF86DRICreateDrawable(client);
+ return ProcXF86DRICreateDrawable(client);
case X_XF86DRIDestroyDrawable:
- return ProcXF86DRIDestroyDrawable(client);
+ return ProcXF86DRIDestroyDrawable(client);
case X_XF86DRIGetDrawableInfo:
- return ProcXF86DRIGetDrawableInfo(client);
+ return ProcXF86DRIGetDrawableInfo(client);
case X_XF86DRIGetDeviceInfo:
- return ProcXF86DRIGetDeviceInfo(client);
+ return ProcXF86DRIGetDeviceInfo(client);
case X_XF86DRIAuthConnection:
- return ProcXF86DRIAuthConnection(client);
- /* {Open,Close}FullScreen are deprecated now */
+ return ProcXF86DRIAuthConnection(client);
+ /* {Open,Close}FullScreen are deprecated now */
default:
- return BadRequest;
+ return BadRequest;
}
}
static int
-SProcXF86DRIQueryVersion(
- register ClientPtr client
-)
+SProcXF86DRIQueryVersion(register ClientPtr client)
{
REQUEST(xXF86DRIQueryVersionReq);
swaps(&stuff->length);
@@ -599,9 +561,7 @@ SProcXF86DRIQueryVersion(
}
static int
-SProcXF86DRIQueryDirectRenderingCapable(
- register ClientPtr client
-)
+SProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client)
{
REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
swaps(&stuff->length);
@@ -610,9 +570,7 @@ SProcXF86DRIQueryDirectRenderingCapable(
}
static int
-SProcXF86DRIDispatch (
- register ClientPtr client
-)
+SProcXF86DRIDispatch(register ClientPtr client)
{
REQUEST(xReq);
@@ -620,39 +578,36 @@ SProcXF86DRIDispatch (
* Only local clients are allowed DRI access, but remote clients still need
* these requests to find out cleanly.
*/
- switch (stuff->data)
- {
+ switch (stuff->data) {
case X_XF86DRIQueryVersion:
- return SProcXF86DRIQueryVersion(client);
+ return SProcXF86DRIQueryVersion(client);
case X_XF86DRIQueryDirectRenderingCapable:
- return SProcXF86DRIQueryDirectRenderingCapable(client);
+ return SProcXF86DRIQueryDirectRenderingCapable(client);
default:
- return DRIErrorBase + XF86DRIClientNotLocal;
+ return DRIErrorBase + XF86DRIClientNotLocal;
}
}
void
XFree86DRIExtensionInit(void)
{
- ExtensionEntry* extEntry;
+ ExtensionEntry *extEntry;
#ifdef XF86DRI_EVENTS
EventType = CreateNewResourceType(XF86DRIFreeEvents, "DRIEvent");
#endif
- if (
- DRIExtensionInit() &&
+ if (DRIExtensionInit() &&
#ifdef XF86DRI_EVENTS
EventType && ScreenPrivateIndex != -1 &&
#endif
- (extEntry = AddExtension(XF86DRINAME,
- XF86DRINumberEvents,
- XF86DRINumberErrors,
- ProcXF86DRIDispatch,
- SProcXF86DRIDispatch,
- XF86DRIResetProc,
- StandardMinorOpcode))) {
- DRIReqCode = (unsigned char)extEntry->base;
- DRIErrorBase = extEntry->errorBase;
+ (extEntry = AddExtension(XF86DRINAME,
+ XF86DRINumberEvents,
+ XF86DRINumberErrors,
+ ProcXF86DRIDispatch,
+ SProcXF86DRIDispatch,
+ XF86DRIResetProc, StandardMinorOpcode))) {
+ DRIReqCode = (unsigned char) extEntry->base;
+ DRIErrorBase = extEntry->errorBase;
}
}
diff --git a/xorg-server/hw/xfree86/dri2/dri2.c b/xorg-server/hw/xfree86/dri2/dri2.c
index 5cc9068af..591ff3ace 100644
--- a/xorg-server/hw/xfree86/dri2/dri2.c
+++ b/xorg-server/hw/xfree86/dri2/dri2.c
@@ -48,66 +48,69 @@
#include "xf86.h"
-CARD8 dri2_major; /* version of DRI2 supported by DDX */
+CARD8 dri2_major; /* version of DRI2 supported by DDX */
CARD8 dri2_minor;
static DevPrivateKeyRec dri2ScreenPrivateKeyRec;
+
#define dri2ScreenPrivateKey (&dri2ScreenPrivateKeyRec)
static DevPrivateKeyRec dri2WindowPrivateKeyRec;
+
#define dri2WindowPrivateKey (&dri2WindowPrivateKeyRec)
static DevPrivateKeyRec dri2PixmapPrivateKeyRec;
+
#define dri2PixmapPrivateKey (&dri2PixmapPrivateKeyRec)
-static RESTYPE dri2DrawableRes;
+static RESTYPE dri2DrawableRes;
typedef struct _DRI2Screen *DRI2ScreenPtr;
typedef struct _DRI2Drawable {
- DRI2ScreenPtr dri2_screen;
- DrawablePtr drawable;
- struct xorg_list reference_list;
- int width;
- int height;
- DRI2BufferPtr *buffers;
- int bufferCount;
- unsigned int swapsPending;
- ClientPtr blockedClient;
- Bool blockedOnMsc;
- int swap_interval;
- CARD64 swap_count;
- int64_t target_sbc; /* -1 means no SBC wait outstanding */
- CARD64 last_swap_target; /* most recently queued swap target */
- CARD64 last_swap_msc; /* msc at completion of most recent swap */
- CARD64 last_swap_ust; /* ust at completion of most recent swap */
- int swap_limit; /* for N-buffering */
- unsigned long serialNumber;
- Bool needInvalidate;
+ DRI2ScreenPtr dri2_screen;
+ DrawablePtr drawable;
+ struct xorg_list reference_list;
+ int width;
+ int height;
+ DRI2BufferPtr *buffers;
+ int bufferCount;
+ unsigned int swapsPending;
+ ClientPtr blockedClient;
+ Bool blockedOnMsc;
+ int swap_interval;
+ CARD64 swap_count;
+ int64_t target_sbc; /* -1 means no SBC wait outstanding */
+ CARD64 last_swap_target; /* most recently queued swap target */
+ CARD64 last_swap_msc; /* msc at completion of most recent swap */
+ CARD64 last_swap_ust; /* ust at completion of most recent swap */
+ int swap_limit; /* for N-buffering */
+ unsigned long serialNumber;
+ Bool needInvalidate;
} DRI2DrawableRec, *DRI2DrawablePtr;
typedef struct _DRI2Screen {
- ScreenPtr screen;
- int refcnt;
- unsigned int numDrivers;
- const char **driverNames;
- const char *deviceName;
- int fd;
- unsigned int lastSequence;
-
- DRI2CreateBufferProcPtr CreateBuffer;
- DRI2DestroyBufferProcPtr DestroyBuffer;
- DRI2CopyRegionProcPtr CopyRegion;
- DRI2ScheduleSwapProcPtr ScheduleSwap;
- DRI2GetMSCProcPtr GetMSC;
- DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
- DRI2AuthMagicProcPtr AuthMagic;
+ ScreenPtr screen;
+ int refcnt;
+ unsigned int numDrivers;
+ const char **driverNames;
+ const char *deviceName;
+ int fd;
+ unsigned int lastSequence;
+
+ DRI2CreateBufferProcPtr CreateBuffer;
+ DRI2DestroyBufferProcPtr DestroyBuffer;
+ DRI2CopyRegionProcPtr CopyRegion;
+ DRI2ScheduleSwapProcPtr ScheduleSwap;
+ DRI2GetMSCProcPtr GetMSC;
+ DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
+ DRI2AuthMagicProcPtr AuthMagic;
DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
DRI2SwapLimitValidateProcPtr SwapLimitValidate;
- HandleExposuresProcPtr HandleExposures;
+ HandleExposuresProcPtr HandleExposures;
- ConfigNotifyProcPtr ConfigNotify;
+ ConfigNotifyProcPtr ConfigNotify;
} DRI2ScreenRec;
static DRI2ScreenPtr
@@ -124,13 +127,13 @@ DRI2GetDrawable(DrawablePtr pDraw)
switch (pDraw->type) {
case DRAWABLE_WINDOW:
- pWin = (WindowPtr) pDraw;
- return dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey);
+ pWin = (WindowPtr) pDraw;
+ return dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey);
case DRAWABLE_PIXMAP:
- pPixmap = (PixmapPtr) pDraw;
- return dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey);
+ pPixmap = (PixmapPtr) pDraw;
+ return dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey);
default:
- return NULL;
+ return NULL;
}
}
@@ -141,24 +144,24 @@ DRI2DrawableSerial(DrawablePtr pDraw)
PixmapPtr pPix;
if (pDraw->type != DRAWABLE_WINDOW)
- return pDraw->serialNumber;
+ return pDraw->serialNumber;
- pPix = pScreen->GetWindowPixmap((WindowPtr)pDraw);
+ pPix = pScreen->GetWindowPixmap((WindowPtr) pDraw);
return pPix->drawable.serialNumber;
}
static DRI2DrawablePtr
DRI2AllocateDrawable(DrawablePtr pDraw)
{
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
DRI2DrawablePtr pPriv;
- CARD64 ust;
+ CARD64 ust;
WindowPtr pWin;
PixmapPtr pPixmap;
pPriv = malloc(sizeof *pPriv);
if (pPriv == NULL)
- return NULL;
+ return NULL;
pPriv->dri2_screen = ds;
pPriv->drawable = pDraw;
@@ -173,10 +176,10 @@ DRI2AllocateDrawable(DrawablePtr pDraw)
pPriv->target_sbc = -1;
pPriv->swap_interval = 1;
/* Initialize last swap target from DDX if possible */
- if (!ds->GetMSC || !(*ds->GetMSC)(pDraw, &ust, &pPriv->last_swap_target))
- pPriv->last_swap_target = 0;
+ if (!ds->GetMSC || !(*ds->GetMSC) (pDraw, &ust, &pPriv->last_swap_target))
+ pPriv->last_swap_target = 0;
- pPriv->swap_limit = 1; /* default to double buffering */
+ pPriv->swap_limit = 1; /* default to double buffering */
pPriv->last_swap_msc = 0;
pPriv->last_swap_ust = 0;
xorg_list_init(&pPriv->reference_list);
@@ -184,11 +187,12 @@ DRI2AllocateDrawable(DrawablePtr pDraw)
pPriv->needInvalidate = FALSE;
if (pDraw->type == DRAWABLE_WINDOW) {
- pWin = (WindowPtr) pDraw;
- dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, pPriv);
- } else {
- pPixmap = (PixmapPtr) pDraw;
- dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, pPriv);
+ pWin = (WindowPtr) pDraw;
+ dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, pPriv);
+ }
+ else {
+ pPixmap = (PixmapPtr) pDraw;
+ dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, pPriv);
}
return pPriv;
@@ -199,37 +203,37 @@ DRI2SwapLimit(DrawablePtr pDraw, int swap_limit)
{
DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
DRI2ScreenPtr ds;
+
if (!pPriv)
- return FALSE;
+ return FALSE;
ds = pPriv->dri2_screen;
- if (!ds->SwapLimitValidate
- || !ds->SwapLimitValidate(pDraw, swap_limit))
- return FALSE;
+ if (!ds->SwapLimitValidate || !ds->SwapLimitValidate(pDraw, swap_limit))
+ return FALSE;
pPriv->swap_limit = swap_limit;
/* Check throttling */
if (pPriv->swapsPending >= pPriv->swap_limit)
- return TRUE;
+ return TRUE;
if (pPriv->target_sbc == -1 && !pPriv->blockedOnMsc) {
- if (pPriv->blockedClient) {
- AttendClient(pPriv->blockedClient);
- pPriv->blockedClient = NULL;
- }
+ if (pPriv->blockedClient) {
+ AttendClient(pPriv->blockedClient);
+ pPriv->blockedClient = NULL;
+ }
}
return TRUE;
}
typedef struct DRI2DrawableRefRec {
- XID id;
- XID dri2_id;
- DRI2InvalidateProcPtr invalidate;
- void *priv;
- struct xorg_list link;
+ XID id;
+ XID dri2_id;
+ DRI2InvalidateProcPtr invalidate;
+ void *priv;
+ struct xorg_list link;
} DRI2DrawableRefRec, *DRI2DrawableRefPtr;
static DRI2DrawableRefPtr
@@ -238,36 +242,36 @@ DRI2LookupDrawableRef(DRI2DrawablePtr pPriv, XID id)
DRI2DrawableRefPtr ref;
xorg_list_for_each_entry(ref, &pPriv->reference_list, link) {
- if (ref->id == id)
- return ref;
+ if (ref->id == id)
+ return ref;
}
-
+
return NULL;
}
static int
DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id,
- DRI2InvalidateProcPtr invalidate, void *priv)
+ DRI2InvalidateProcPtr invalidate, void *priv)
{
DRI2DrawableRefPtr ref;
ref = malloc(sizeof *ref);
if (ref == NULL)
- return BadAlloc;
-
+ return BadAlloc;
+
if (!AddResource(dri2_id, dri2DrawableRes, pPriv)) {
- free(ref);
- return BadAlloc;
+ free(ref);
+ return BadAlloc;
}
if (!DRI2LookupDrawableRef(pPriv, id))
- if (!AddResource(id, dri2DrawableRes, pPriv)) {
- FreeResourceByType(dri2_id, dri2DrawableRes, TRUE);
- free(ref);
- return BadAlloc;
+ if (!AddResource(id, dri2DrawableRes, pPriv)) {
+ FreeResourceByType(dri2_id, dri2DrawableRes, TRUE);
+ free(ref);
+ return BadAlloc;
}
ref->id = id;
- ref->dri2_id = dri2_id;
+ ref->dri2_id = dri2_id;
ref->invalidate = invalidate;
ref->priv = priv;
xorg_list_add(&ref->link, &pPriv->reference_list);
@@ -277,7 +281,7 @@ DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id,
int
DRI2CreateDrawable(ClientPtr client, DrawablePtr pDraw, XID id,
- DRI2InvalidateProcPtr invalidate, void *priv)
+ DRI2InvalidateProcPtr invalidate, void *priv)
{
DRI2DrawablePtr pPriv;
XID dri2_id;
@@ -285,22 +289,23 @@ DRI2CreateDrawable(ClientPtr client, DrawablePtr pDraw, XID id,
pPriv = DRI2GetDrawable(pDraw);
if (pPriv == NULL)
- pPriv = DRI2AllocateDrawable(pDraw);
+ pPriv = DRI2AllocateDrawable(pDraw);
if (pPriv == NULL)
- return BadAlloc;
-
+ return BadAlloc;
+
dri2_id = FakeClientID(client->index);
rc = DRI2AddDrawableRef(pPriv, id, dri2_id, invalidate, priv);
if (rc != Success)
- return rc;
+ return rc;
return Success;
}
-static int DRI2DrawableGone(pointer p, XID id)
+static int
+DRI2DrawableGone(pointer p, XID id)
{
DRI2DrawablePtr pPriv = p;
- DRI2ScreenPtr ds = pPriv->dri2_screen;
+ DRI2ScreenPtr ds = pPriv->dri2_screen;
DRI2DrawableRefPtr ref, next;
WindowPtr pWin;
PixmapPtr pPixmap;
@@ -308,40 +313,41 @@ static int DRI2DrawableGone(pointer p, XID id)
int i;
xorg_list_for_each_entry_safe(ref, next, &pPriv->reference_list, link) {
- if (ref->dri2_id == id) {
- xorg_list_del(&ref->link);
- /* If this was the last ref under this X drawable XID,
- * unregister the X drawable resource. */
- if (!DRI2LookupDrawableRef(pPriv, ref->id))
- FreeResourceByType(ref->id, dri2DrawableRes, TRUE);
- free(ref);
- break;
- }
-
- if (ref->id == id) {
- xorg_list_del(&ref->link);
- FreeResourceByType(ref->dri2_id, dri2DrawableRes, TRUE);
- free(ref);
- }
+ if (ref->dri2_id == id) {
+ xorg_list_del(&ref->link);
+ /* If this was the last ref under this X drawable XID,
+ * unregister the X drawable resource. */
+ if (!DRI2LookupDrawableRef(pPriv, ref->id))
+ FreeResourceByType(ref->id, dri2DrawableRes, TRUE);
+ free(ref);
+ break;
+ }
+
+ if (ref->id == id) {
+ xorg_list_del(&ref->link);
+ FreeResourceByType(ref->dri2_id, dri2DrawableRes, TRUE);
+ free(ref);
+ }
}
if (!xorg_list_is_empty(&pPriv->reference_list))
- return Success;
+ return Success;
pDraw = pPriv->drawable;
if (pDraw->type == DRAWABLE_WINDOW) {
- pWin = (WindowPtr) pDraw;
- dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, NULL);
- } else {
- pPixmap = (PixmapPtr) pDraw;
- dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, NULL);
+ pWin = (WindowPtr) pDraw;
+ dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, NULL);
+ }
+ else {
+ pPixmap = (PixmapPtr) pDraw;
+ dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, NULL);
}
if (pPriv->buffers != NULL) {
- for (i = 0; i < pPriv->bufferCount; i++)
- (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]);
+ for (i = 0; i < pPriv->bufferCount; i++)
+ (*ds->DestroyBuffer) (pDraw, pPriv->buffers[i]);
- free(pPriv->buffers);
+ free(pPriv->buffers);
}
free(pPriv);
@@ -355,14 +361,14 @@ find_attachment(DRI2DrawablePtr pPriv, unsigned attachment)
int i;
if (pPriv->buffers == NULL) {
- return -1;
+ return -1;
}
for (i = 0; i < pPriv->bufferCount; i++) {
- if ((pPriv->buffers[i] != NULL)
- && (pPriv->buffers[i]->attachment == attachment)) {
- return i;
- }
+ if ((pPriv->buffers[i] != NULL)
+ && (pPriv->buffers[i]->attachment == attachment)) {
+ return i;
+ }
}
return -1;
@@ -370,46 +376,47 @@ find_attachment(DRI2DrawablePtr pPriv, unsigned attachment)
static Bool
allocate_or_reuse_buffer(DrawablePtr pDraw, DRI2ScreenPtr ds,
- DRI2DrawablePtr pPriv,
- unsigned int attachment, unsigned int format,
- int dimensions_match, DRI2BufferPtr *buffer)
+ DRI2DrawablePtr pPriv,
+ unsigned int attachment, unsigned int format,
+ int dimensions_match, DRI2BufferPtr * buffer)
{
int old_buf = find_attachment(pPriv, attachment);
if ((old_buf < 0)
- || attachment == DRI2BufferFrontLeft
- || !dimensions_match
- || (pPriv->buffers[old_buf]->format != format)) {
- *buffer = (*ds->CreateBuffer)(pDraw, attachment, format);
- pPriv->serialNumber = DRI2DrawableSerial(pDraw);
- return TRUE;
+ || attachment == DRI2BufferFrontLeft
+ || !dimensions_match || (pPriv->buffers[old_buf]->format != format)) {
+ *buffer = (*ds->CreateBuffer) (pDraw, attachment, format);
+ pPriv->serialNumber = DRI2DrawableSerial(pDraw);
+ return TRUE;
- } else {
- *buffer = pPriv->buffers[old_buf];
+ }
+ else {
+ *buffer = pPriv->buffers[old_buf];
- if (ds->ReuseBufferNotify)
- (*ds->ReuseBufferNotify)(pDraw, *buffer);
+ if (ds->ReuseBufferNotify)
+ (*ds->ReuseBufferNotify) (pDraw, *buffer);
- pPriv->buffers[old_buf] = NULL;
- return FALSE;
+ pPriv->buffers[old_buf] = NULL;
+ return FALSE;
}
}
static void
update_dri2_drawable_buffers(DRI2DrawablePtr pPriv, DrawablePtr pDraw,
- DRI2BufferPtr *buffers, int out_count, int *width, int *height)
+ DRI2BufferPtr * buffers, int out_count, int *width,
+ int *height)
{
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
int i;
if (pPriv->buffers != NULL) {
- for (i = 0; i < pPriv->bufferCount; i++) {
- if (pPriv->buffers[i] != NULL) {
- (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]);
- }
- }
+ for (i = 0; i < pPriv->bufferCount; i++) {
+ if (pPriv->buffers[i] != NULL) {
+ (*ds->DestroyBuffer) (pDraw, pPriv->buffers[i]);
+ }
+ }
- free(pPriv->buffers);
+ free(pPriv->buffers);
}
pPriv->buffers = buffers;
@@ -422,12 +429,12 @@ update_dri2_drawable_buffers(DRI2DrawablePtr pPriv, DrawablePtr pDraw,
static DRI2BufferPtr *
do_get_buffers(DrawablePtr pDraw, int *width, int *height,
- unsigned int *attachments, int count, int *out_count,
- int has_format)
+ unsigned int *attachments, int count, int *out_count,
+ int has_format)
{
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
- DRI2BufferPtr *buffers;
+ DRI2BufferPtr *buffers;
int need_real_front = 0;
int need_fake_front = 0;
int have_fake_front = 0;
@@ -437,142 +444,143 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height,
int i;
if (!pPriv) {
- *width = pDraw->width;
- *height = pDraw->height;
- *out_count = 0;
- return NULL;
+ *width = pDraw->width;
+ *height = pDraw->height;
+ *out_count = 0;
+ return NULL;
}
dimensions_match = (pDraw->width == pPriv->width)
- && (pDraw->height == pPriv->height)
- && (pPriv->serialNumber == DRI2DrawableSerial(pDraw));
+ && (pDraw->height == pPriv->height)
+ && (pPriv->serialNumber == DRI2DrawableSerial(pDraw));
buffers = calloc((count + 1), sizeof(buffers[0]));
if (!buffers)
- goto err_out;
+ goto err_out;
for (i = 0; i < count; i++) {
- const unsigned attachment = *(attachments++);
- const unsigned format = (has_format) ? *(attachments++) : 0;
-
- if (allocate_or_reuse_buffer(pDraw, ds, pPriv, attachment,
- format, dimensions_match,
- &buffers[i]))
- buffers_changed = 1;
-
- if (buffers[i] == NULL)
- goto err_out;
-
- /* If the drawable is a window and the front-buffer is requested,
- * silently add the fake front-buffer to the list of requested
- * attachments. The counting logic in the loop accounts for the case
- * where the client requests both the fake and real front-buffer.
- */
- if (attachment == DRI2BufferBackLeft) {
- need_real_front++;
- front_format = format;
- }
-
- if (attachment == DRI2BufferFrontLeft) {
- need_real_front--;
- front_format = format;
-
- if (pDraw->type == DRAWABLE_WINDOW) {
- need_fake_front++;
- }
- }
-
- if (pDraw->type == DRAWABLE_WINDOW) {
- if (attachment == DRI2BufferFakeFrontLeft) {
- need_fake_front--;
- have_fake_front = 1;
- }
- }
+ const unsigned attachment = *(attachments++);
+ const unsigned format = (has_format) ? *(attachments++) : 0;
+
+ if (allocate_or_reuse_buffer(pDraw, ds, pPriv, attachment,
+ format, dimensions_match, &buffers[i]))
+ buffers_changed = 1;
+
+ if (buffers[i] == NULL)
+ goto err_out;
+
+ /* If the drawable is a window and the front-buffer is requested,
+ * silently add the fake front-buffer to the list of requested
+ * attachments. The counting logic in the loop accounts for the case
+ * where the client requests both the fake and real front-buffer.
+ */
+ if (attachment == DRI2BufferBackLeft) {
+ need_real_front++;
+ front_format = format;
+ }
+
+ if (attachment == DRI2BufferFrontLeft) {
+ need_real_front--;
+ front_format = format;
+
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ need_fake_front++;
+ }
+ }
+
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ if (attachment == DRI2BufferFakeFrontLeft) {
+ need_fake_front--;
+ have_fake_front = 1;
+ }
+ }
}
if (need_real_front > 0) {
- if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFrontLeft,
- front_format, dimensions_match,
- &buffers[i]))
- buffers_changed = 1;
-
- if (buffers[i] == NULL)
- goto err_out;
- i++;
+ if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFrontLeft,
+ front_format, dimensions_match,
+ &buffers[i]))
+ buffers_changed = 1;
+
+ if (buffers[i] == NULL)
+ goto err_out;
+ i++;
}
if (need_fake_front > 0) {
- if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFakeFrontLeft,
- front_format, dimensions_match,
- &buffers[i]))
- buffers_changed = 1;
+ if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFakeFrontLeft,
+ front_format, dimensions_match,
+ &buffers[i]))
+ buffers_changed = 1;
- if (buffers[i] == NULL)
- goto err_out;
+ if (buffers[i] == NULL)
+ goto err_out;
- i++;
- have_fake_front = 1;
+ i++;
+ have_fake_front = 1;
}
*out_count = i;
- update_dri2_drawable_buffers(pPriv, pDraw, buffers, *out_count, width, height);
+ update_dri2_drawable_buffers(pPriv, pDraw, buffers, *out_count, width,
+ height);
/* If the client is getting a fake front-buffer, pre-fill it with the
* contents of the real front-buffer. This ensures correct operation of
* applications that call glXWaitX before calling glDrawBuffer.
*/
if (have_fake_front && buffers_changed) {
- BoxRec box;
- RegionRec region;
+ BoxRec box;
+ RegionRec region;
- box.x1 = 0;
- box.y1 = 0;
- box.x2 = pPriv->width;
- box.y2 = pPriv->height;
- RegionInit(&region, &box, 0);
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pPriv->width;
+ box.y2 = pPriv->height;
+ RegionInit(&region, &box, 0);
- DRI2CopyRegion(pDraw, &region, DRI2BufferFakeFrontLeft,
- DRI2BufferFrontLeft);
+ DRI2CopyRegion(pDraw, &region, DRI2BufferFakeFrontLeft,
+ DRI2BufferFrontLeft);
}
pPriv->needInvalidate = TRUE;
return pPriv->buffers;
-err_out:
+ err_out:
*out_count = 0;
if (buffers) {
- for (i = 0; i < count; i++) {
- if (buffers[i] != NULL)
- (*ds->DestroyBuffer)(pDraw, buffers[i]);
- }
+ for (i = 0; i < count; i++) {
+ if (buffers[i] != NULL)
+ (*ds->DestroyBuffer) (pDraw, buffers[i]);
+ }
- free(buffers);
- buffers = NULL;
+ free(buffers);
+ buffers = NULL;
}
- update_dri2_drawable_buffers(pPriv, pDraw, buffers, *out_count, width, height);
+ update_dri2_drawable_buffers(pPriv, pDraw, buffers, *out_count, width,
+ height);
return buffers;
}
DRI2BufferPtr *
DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height,
- unsigned int *attachments, int count, int *out_count)
+ unsigned int *attachments, int count, int *out_count)
{
return do_get_buffers(pDraw, width, height, attachments, count,
- out_count, FALSE);
+ out_count, FALSE);
}
DRI2BufferPtr *
DRI2GetBuffersWithFormat(DrawablePtr pDraw, int *width, int *height,
- unsigned int *attachments, int count, int *out_count)
+ unsigned int *attachments, int count, int *out_count)
{
return do_get_buffers(pDraw, width, height, attachments, count,
- out_count, TRUE);
+ out_count, TRUE);
}
static void
@@ -587,7 +595,7 @@ DRI2InvalidateDrawable(DrawablePtr pDraw)
pPriv->needInvalidate = FALSE;
xorg_list_for_each_entry(ref, &pPriv->reference_list, link)
- ref->invalidate(pDraw, ref->priv, ref->id);
+ ref->invalidate(pDraw, ref->priv, ref->id);
}
/*
@@ -604,16 +612,15 @@ DRI2ThrottleClient(ClientPtr client, DrawablePtr pDraw)
pPriv = DRI2GetDrawable(pDraw);
if (pPriv == NULL)
- return FALSE;
+ return FALSE;
/* Throttle to swap limit */
- if ((pPriv->swapsPending >= pPriv->swap_limit) &&
- !pPriv->blockedClient) {
- ResetCurrentRequest(client);
- client->sequence--;
- IgnoreClient(client);
- pPriv->blockedClient = client;
- return TRUE;
+ if ((pPriv->swapsPending >= pPriv->swap_limit) && !pPriv->blockedClient) {
+ ResetCurrentRequest(client);
+ client->sequence--;
+ IgnoreClient(client);
+ pPriv->blockedClient = client;
+ return TRUE;
}
return FALSE;
@@ -623,8 +630,8 @@ static void
__DRI2BlockClient(ClientPtr client, DRI2DrawablePtr pPriv)
{
if (pPriv->blockedClient == NULL) {
- IgnoreClient(client);
- pPriv->blockedClient = client;
+ IgnoreClient(client);
+ pPriv->blockedClient = client;
}
}
@@ -635,7 +642,7 @@ DRI2BlockClient(ClientPtr client, DrawablePtr pDraw)
pPriv = DRI2GetDrawable(pDraw);
if (pPriv == NULL)
- return;
+ return;
__DRI2BlockClient(client, pPriv);
pPriv->blockedOnMsc = TRUE;
@@ -643,30 +650,29 @@ DRI2BlockClient(ClientPtr client, DrawablePtr pDraw)
int
DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
- unsigned int dest, unsigned int src)
+ unsigned int dest, unsigned int src)
{
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
DRI2DrawablePtr pPriv;
- DRI2BufferPtr pDestBuffer, pSrcBuffer;
- int i;
+ DRI2BufferPtr pDestBuffer, pSrcBuffer;
+ int i;
pPriv = DRI2GetDrawable(pDraw);
if (pPriv == NULL)
- return BadDrawable;
+ return BadDrawable;
pDestBuffer = NULL;
pSrcBuffer = NULL;
- for (i = 0; i < pPriv->bufferCount; i++)
- {
- if (pPriv->buffers[i]->attachment == dest)
- pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
- if (pPriv->buffers[i]->attachment == src)
- pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
+ for (i = 0; i < pPriv->bufferCount; i++) {
+ if (pPriv->buffers[i]->attachment == dest)
+ pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
+ if (pPriv->buffers[i]->attachment == src)
+ pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
}
if (pSrcBuffer == NULL || pDestBuffer == NULL)
- return BadValue;
+ return BadValue;
- (*ds->CopyRegion)(pDraw, pRegion, pDestBuffer, pSrcBuffer);
+ (*ds->CopyRegion) (pDraw, pRegion, pDestBuffer, pSrcBuffer);
return Success;
}
@@ -680,7 +686,7 @@ DRI2CanFlip(DrawablePtr pDraw)
PixmapPtr pWinPixmap, pRootPixmap;
if (pDraw->type == DRAWABLE_PIXMAP)
- return TRUE;
+ return TRUE;
pRoot = pScreen->root;
pRootPixmap = pScreen->GetWindowPixmap(pRoot);
@@ -688,20 +694,18 @@ DRI2CanFlip(DrawablePtr pDraw)
pWin = (WindowPtr) pDraw;
pWinPixmap = pScreen->GetWindowPixmap(pWin);
if (pRootPixmap != pWinPixmap)
- return FALSE;
+ return FALSE;
if (!RegionEqual(&pWin->clipList, &pRoot->winSize))
- return FALSE;
+ return FALSE;
/* Does the window match the pixmap exactly? */
- if (pDraw->x != 0 ||
- pDraw->y != 0 ||
+ if (pDraw->x != 0 || pDraw->y != 0 ||
#ifdef COMPOSITE
- pDraw->x != pWinPixmap->screen_x ||
- pDraw->y != pWinPixmap->screen_y ||
+ pDraw->x != pWinPixmap->screen_x || pDraw->y != pWinPixmap->screen_y ||
#endif
- pDraw->width != pWinPixmap->drawable.width ||
- pDraw->height != pWinPixmap->drawable.height)
- return FALSE;
+ pDraw->width != pWinPixmap->drawable.width ||
+ pDraw->height != pWinPixmap->drawable.height)
+ return FALSE;
return TRUE;
}
@@ -715,19 +719,19 @@ DRI2CanExchange(DrawablePtr pDraw)
void
DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw, int frame,
- unsigned int tv_sec, unsigned int tv_usec)
+ unsigned int tv_sec, unsigned int tv_usec)
{
DRI2DrawablePtr pPriv;
pPriv = DRI2GetDrawable(pDraw);
if (pPriv == NULL)
- return;
+ return;
- ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec,
- frame, pPriv->swap_count);
+ ProcDRI2WaitMSCReply(client, ((CARD64) tv_sec * 1000000) + tv_usec,
+ frame, pPriv->swap_count);
if (pPriv->blockedClient)
- AttendClient(pPriv->blockedClient);
+ AttendClient(pPriv->blockedClient);
pPriv->blockedClient = NULL;
pPriv->blockedOnMsc = FALSE;
@@ -735,16 +739,16 @@ DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw, int frame,
static void
DRI2WakeClient(ClientPtr client, DrawablePtr pDraw, int frame,
- unsigned int tv_sec, unsigned int tv_usec)
+ unsigned int tv_sec, unsigned int tv_usec)
{
- ScreenPtr pScreen = pDraw->pScreen;
+ ScreenPtr pScreen = pDraw->pScreen;
DRI2DrawablePtr pPriv;
pPriv = DRI2GetDrawable(pDraw);
if (pPriv == NULL) {
xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: bad drawable\n", __func__);
- return;
+ "[DRI2] %s: bad drawable\n", __func__);
+ return;
}
/*
@@ -755,38 +759,38 @@ DRI2WakeClient(ClientPtr client, DrawablePtr pDraw, int frame,
* - was blocked due to swap throttling
* - is not blocked due to an MSC wait
*/
- if (pPriv->target_sbc != -1 &&
- pPriv->target_sbc <= pPriv->swap_count) {
- ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec,
- frame, pPriv->swap_count);
- pPriv->target_sbc = -1;
-
- AttendClient(pPriv->blockedClient);
- pPriv->blockedClient = NULL;
- } else if (pPriv->target_sbc == -1 && !pPriv->blockedOnMsc) {
- if (pPriv->blockedClient) {
- AttendClient(pPriv->blockedClient);
- pPriv->blockedClient = NULL;
- }
+ if (pPriv->target_sbc != -1 && pPriv->target_sbc <= pPriv->swap_count) {
+ ProcDRI2WaitMSCReply(client, ((CARD64) tv_sec * 1000000) + tv_usec,
+ frame, pPriv->swap_count);
+ pPriv->target_sbc = -1;
+
+ AttendClient(pPriv->blockedClient);
+ pPriv->blockedClient = NULL;
+ }
+ else if (pPriv->target_sbc == -1 && !pPriv->blockedOnMsc) {
+ if (pPriv->blockedClient) {
+ AttendClient(pPriv->blockedClient);
+ pPriv->blockedClient = NULL;
+ }
}
}
void
DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame,
- unsigned int tv_sec, unsigned int tv_usec, int type,
- DRI2SwapEventPtr swap_complete, void *swap_data)
+ unsigned int tv_sec, unsigned int tv_usec, int type,
+ DRI2SwapEventPtr swap_complete, void *swap_data)
{
- ScreenPtr pScreen = pDraw->pScreen;
+ ScreenPtr pScreen = pDraw->pScreen;
DRI2DrawablePtr pPriv;
- CARD64 ust = 0;
- BoxRec box;
- RegionRec region;
+ CARD64 ust = 0;
+ BoxRec box;
+ RegionRec region;
pPriv = DRI2GetDrawable(pDraw);
if (pPriv == NULL) {
xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: bad drawable\n", __func__);
- return;
+ "[DRI2] %s: bad drawable\n", __func__);
+ return;
}
pPriv->swapsPending--;
@@ -798,11 +802,11 @@ DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame,
box.y2 = pDraw->height;
RegionInit(&region, &box, 0);
DRI2CopyRegion(pDraw, &region, DRI2BufferFakeFrontLeft,
- DRI2BufferFrontLeft);
+ DRI2BufferFrontLeft);
- ust = ((CARD64)tv_sec * 1000000) + tv_usec;
+ ust = ((CARD64) tv_sec * 1000000) + tv_usec;
if (swap_complete)
- swap_complete(client, swap_data, type, ust, frame, pPriv->swap_count);
+ swap_complete(client, swap_data, type, ust, frame, pPriv->swap_count);
pPriv->last_swap_msc = frame;
pPriv->last_swap_ust = ust;
@@ -818,13 +822,11 @@ DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable)
/* If we're currently waiting for a swap on this drawable, reset
* the request and suspend the client. We only support one
* blocked client per drawable. */
- if (pPriv &&
- pPriv->swapsPending &&
- pPriv->blockedClient == NULL) {
- ResetCurrentRequest(client);
- client->sequence--;
- __DRI2BlockClient(client, pPriv);
- return TRUE;
+ if (pPriv && pPriv->swapsPending && pPriv->blockedClient == NULL) {
+ ResetCurrentRequest(client);
+ client->sequence--;
+ __DRI2BlockClient(client, pPriv);
+ return TRUE;
}
return FALSE;
@@ -838,59 +840,59 @@ static int
DRI2InvalidateWalk(WindowPtr pWin, pointer data)
{
if (pWin->drawable.pScreen->GetWindowPixmap(pWin) != data)
- return WT_DONTWALKCHILDREN;
+ return WT_DONTWALKCHILDREN;
DRI2InvalidateDrawable(&pWin->drawable);
return WT_WALKCHILDREN;
}
int
DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
- CARD64 divisor, CARD64 remainder, CARD64 *swap_target,
- DRI2SwapEventPtr func, void *data)
+ CARD64 divisor, CARD64 remainder, CARD64 * swap_target,
+ DRI2SwapEventPtr func, void *data)
{
- ScreenPtr pScreen = pDraw->pScreen;
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
DRI2DrawablePtr pPriv;
- DRI2BufferPtr pDestBuffer = NULL, pSrcBuffer = NULL;
- int ret, i;
- CARD64 ust, current_msc;
+ DRI2BufferPtr pDestBuffer = NULL, pSrcBuffer = NULL;
+ int ret, i;
+ CARD64 ust, current_msc;
pPriv = DRI2GetDrawable(pDraw);
if (pPriv == NULL) {
xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: bad drawable\n", __func__);
- return BadDrawable;
+ "[DRI2] %s: bad drawable\n", __func__);
+ return BadDrawable;
}
for (i = 0; i < pPriv->bufferCount; i++) {
- if (pPriv->buffers[i]->attachment == DRI2BufferFrontLeft)
- pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
- if (pPriv->buffers[i]->attachment == DRI2BufferBackLeft)
- pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
+ if (pPriv->buffers[i]->attachment == DRI2BufferFrontLeft)
+ pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
+ if (pPriv->buffers[i]->attachment == DRI2BufferBackLeft)
+ pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
}
if (pSrcBuffer == NULL || pDestBuffer == NULL) {
xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: drawable has no back or front?\n", __func__);
- return BadDrawable;
+ "[DRI2] %s: drawable has no back or front?\n", __func__);
+ return BadDrawable;
}
/* Old DDX or no swap interval, just blit */
if (!ds->ScheduleSwap || !pPriv->swap_interval) {
- BoxRec box;
- RegionRec region;
+ BoxRec box;
+ RegionRec region;
- box.x1 = 0;
- box.y1 = 0;
- box.x2 = pDraw->width;
- box.y2 = pDraw->height;
- RegionInit(&region, &box, 0);
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pDraw->width;
+ box.y2 = pDraw->height;
+ RegionInit(&region, &box, 0);
- pPriv->swapsPending++;
+ pPriv->swapsPending++;
- (*ds->CopyRegion)(pDraw, &region, pDestBuffer, pSrcBuffer);
- DRI2SwapComplete(client, pDraw, target_msc, 0, 0, DRI2_BLIT_COMPLETE,
- func, data);
- return Success;
+ (*ds->CopyRegion) (pDraw, &region, pDestBuffer, pSrcBuffer);
+ DRI2SwapComplete(client, pDraw, target_msc, 0, 0, DRI2_BLIT_COMPLETE,
+ func, data);
+ return Success;
}
/*
@@ -898,42 +900,43 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
* need to schedule a swap for the last swap target + the swap interval.
*/
if (target_msc == 0 && divisor == 0 && remainder == 0) {
- /* If the current vblank count of the drawable's crtc is lower
- * than the count stored in last_swap_target from a previous swap
- * then reinitialize last_swap_target to the current crtc's msc,
- * otherwise the swap will hang. This will happen if the drawable
- * is moved to a crtc with a lower refresh rate, or a crtc that just
- * got enabled.
- */
- if (ds->GetMSC) {
- if (!(*ds->GetMSC)(pDraw, &ust, &current_msc))
- pPriv->last_swap_target = 0;
-
- if (current_msc < pPriv->last_swap_target)
- pPriv->last_swap_target = current_msc;
-
- }
-
- /*
- * Swap target for this swap is last swap target + swap interval since
- * we have to account for the current swap count, interval, and the
- * number of pending swaps.
- */
- *swap_target = pPriv->last_swap_target + pPriv->swap_interval;
-
- } else {
- /* glXSwapBuffersMscOML could have a 0 target_msc, honor it */
- *swap_target = target_msc;
+ /* If the current vblank count of the drawable's crtc is lower
+ * than the count stored in last_swap_target from a previous swap
+ * then reinitialize last_swap_target to the current crtc's msc,
+ * otherwise the swap will hang. This will happen if the drawable
+ * is moved to a crtc with a lower refresh rate, or a crtc that just
+ * got enabled.
+ */
+ if (ds->GetMSC) {
+ if (!(*ds->GetMSC) (pDraw, &ust, &current_msc))
+ pPriv->last_swap_target = 0;
+
+ if (current_msc < pPriv->last_swap_target)
+ pPriv->last_swap_target = current_msc;
+
+ }
+
+ /*
+ * Swap target for this swap is last swap target + swap interval since
+ * we have to account for the current swap count, interval, and the
+ * number of pending swaps.
+ */
+ *swap_target = pPriv->last_swap_target + pPriv->swap_interval;
+
+ }
+ else {
+ /* glXSwapBuffersMscOML could have a 0 target_msc, honor it */
+ *swap_target = target_msc;
}
pPriv->swapsPending++;
- ret = (*ds->ScheduleSwap)(client, pDraw, pDestBuffer, pSrcBuffer,
- swap_target, divisor, remainder, func, data);
+ ret = (*ds->ScheduleSwap) (client, pDraw, pDestBuffer, pSrcBuffer,
+ swap_target, divisor, remainder, func, data);
if (!ret) {
- pPriv->swapsPending--; /* didn't schedule */
+ pPriv->swapsPending--; /* didn't schedule */
xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: driver failed to schedule swap\n", __func__);
- return BadDrawable;
+ "[DRI2] %s: driver failed to schedule swap\n", __func__);
+ return BadDrawable;
}
pPriv->last_swap_target = *swap_target;
@@ -944,23 +947,25 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
*swap_target = pPriv->swap_count + pPriv->swapsPending;
if (pDraw->type == DRAWABLE_WINDOW) {
- WindowPtr pWin = (WindowPtr) pDraw;
- PixmapPtr pPixmap = pScreen->GetWindowPixmap(pWin);
-
- /*
- * Find the top-most window using this pixmap
- */
- while (pWin->parent && pScreen->GetWindowPixmap(pWin->parent) == pPixmap)
- pWin = pWin->parent;
-
- /*
- * Walk the sub-tree to invalidate all of the
- * windows using the same pixmap
- */
- TraverseTree(pWin, DRI2InvalidateWalk, pPixmap);
- DRI2InvalidateDrawable(&pPixmap->drawable);
- } else
- DRI2InvalidateDrawable(pDraw);
+ WindowPtr pWin = (WindowPtr) pDraw;
+ PixmapPtr pPixmap = pScreen->GetWindowPixmap(pWin);
+
+ /*
+ * Find the top-most window using this pixmap
+ */
+ while (pWin->parent &&
+ pScreen->GetWindowPixmap(pWin->parent) == pPixmap)
+ pWin = pWin->parent;
+
+ /*
+ * Walk the sub-tree to invalidate all of the
+ * windows using the same pixmap
+ */
+ TraverseTree(pWin, DRI2InvalidateWalk, pPixmap);
+ DRI2InvalidateDrawable(&pPixmap->drawable);
+ }
+ else
+ DRI2InvalidateDrawable(pDraw);
return Success;
}
@@ -968,13 +973,13 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
void
DRI2SwapInterval(DrawablePtr pDrawable, int interval)
{
- ScreenPtr pScreen = pDrawable->pScreen;
+ ScreenPtr pScreen = pDrawable->pScreen;
DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable);
if (pPriv == NULL) {
xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: bad drawable\n", __func__);
- return;
+ "[DRI2] %s: bad drawable\n", __func__);
+ return;
}
/* fixme: check against arbitrary max? */
@@ -982,7 +987,7 @@ DRI2SwapInterval(DrawablePtr pDrawable, int interval)
}
int
-DRI2GetMSC(DrawablePtr pDraw, CARD64 *ust, CARD64 *msc, CARD64 *sbc)
+DRI2GetMSC(DrawablePtr pDraw, CARD64 * ust, CARD64 * msc, CARD64 * sbc)
{
ScreenPtr pScreen = pDraw->pScreen;
DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
@@ -992,15 +997,15 @@ DRI2GetMSC(DrawablePtr pDraw, CARD64 *ust, CARD64 *msc, CARD64 *sbc)
pPriv = DRI2GetDrawable(pDraw);
if (pPriv == NULL) {
xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: bad drawable\n", __func__);
- return BadDrawable;
+ "[DRI2] %s: bad drawable\n", __func__);
+ return BadDrawable;
}
if (!ds->GetMSC) {
- *ust = 0;
- *msc = 0;
- *sbc = pPriv->swap_count;
- return Success;
+ *ust = 0;
+ *msc = 0;
+ *sbc = pPriv->swap_count;
+ return Success;
}
/*
@@ -1008,9 +1013,9 @@ DRI2GetMSC(DrawablePtr pDraw, CARD64 *ust, CARD64 *msc, CARD64 *sbc)
* drawables
*/
- ret = (*ds->GetMSC)(pDraw, ust, msc);
+ ret = (*ds->GetMSC) (pDraw, ust, msc);
if (!ret)
- return BadDrawable;
+ return BadDrawable;
*sbc = pPriv->swap_count;
@@ -1019,7 +1024,7 @@ DRI2GetMSC(DrawablePtr pDraw, CARD64 *ust, CARD64 *msc, CARD64 *sbc)
int
DRI2WaitMSC(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
- CARD64 divisor, CARD64 remainder)
+ CARD64 divisor, CARD64 remainder)
{
DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
DRI2DrawablePtr pPriv;
@@ -1027,18 +1032,19 @@ DRI2WaitMSC(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
pPriv = DRI2GetDrawable(pDraw);
if (pPriv == NULL)
- return BadDrawable;
+ return BadDrawable;
/* Old DDX just completes immediately */
if (!ds->ScheduleWaitMSC) {
- DRI2WaitMSCComplete(client, pDraw, target_msc, 0, 0);
+ DRI2WaitMSCComplete(client, pDraw, target_msc, 0, 0);
- return Success;
+ return Success;
}
- ret = (*ds->ScheduleWaitMSC)(client, pDraw, target_msc, divisor, remainder);
+ ret =
+ (*ds->ScheduleWaitMSC) (client, pDraw, target_msc, divisor, remainder);
if (!ret)
- return BadDrawable;
+ return BadDrawable;
return Success;
}
@@ -1050,7 +1056,7 @@ DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, CARD64 target_sbc)
pPriv = DRI2GetDrawable(pDraw);
if (pPriv == NULL)
- return BadDrawable;
+ return BadDrawable;
/* target_sbc == 0 means to block until all pending swaps are
* finished. Recalculate target_sbc to get that behaviour.
@@ -1084,17 +1090,17 @@ DRI2HasSwapControl(ScreenPtr pScreen)
Bool
DRI2Connect(ScreenPtr pScreen, unsigned int driverType, int *fd,
- const char **driverName, const char **deviceName)
+ const char **driverName, const char **deviceName)
{
DRI2ScreenPtr ds;
if (!dixPrivateKeyRegistered(dri2ScreenPrivateKey))
- return FALSE;
+ return FALSE;
ds = DRI2GetScreen(pScreen);
if (ds == NULL || driverType >= ds->numDrivers ||
- !ds->driverNames[driverType])
- return FALSE;
+ !ds->driverNames[driverType])
+ return FALSE;
*fd = ds->fd;
*driverName = ds->driverNames[driverType];
@@ -1108,7 +1114,7 @@ DRI2Authenticate(ScreenPtr pScreen, uint32_t magic)
{
DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
- if (ds == NULL || (*ds->AuthMagic)(ds->fd, magic))
+ if (ds == NULL || (*ds->AuthMagic) (ds->fd, magic))
return FALSE;
return TRUE;
@@ -1116,27 +1122,27 @@ DRI2Authenticate(ScreenPtr pScreen, uint32_t magic)
static int
DRI2ConfigNotify(WindowPtr pWin, int x, int y, int w, int h, int bw,
- WindowPtr pSib)
+ WindowPtr pSib)
{
- DrawablePtr pDraw = (DrawablePtr)pWin;
+ DrawablePtr pDraw = (DrawablePtr) pWin;
ScreenPtr pScreen = pDraw->pScreen;
DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
DRI2DrawablePtr dd = DRI2GetDrawable(pDraw);
int ret;
if (ds->ConfigNotify) {
- pScreen->ConfigNotify = ds->ConfigNotify;
+ pScreen->ConfigNotify = ds->ConfigNotify;
- ret = (*pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib);
+ ret = (*pScreen->ConfigNotify) (pWin, x, y, w, h, bw, pSib);
- ds->ConfigNotify = pScreen->ConfigNotify;
- pScreen->ConfigNotify = DRI2ConfigNotify;
- if (ret)
- return ret;
+ ds->ConfigNotify = pScreen->ConfigNotify;
+ pScreen->ConfigNotify = DRI2ConfigNotify;
+ if (ret)
+ return ret;
}
if (!dd || (dd->width == w && dd->height == h))
- return Success;
+ return Success;
DRI2InvalidateDrawable(pDraw);
return Success;
@@ -1146,51 +1152,53 @@ Bool
DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
{
DRI2ScreenPtr ds;
- const char* driverTypeNames[] = {
- "DRI", /* DRI2DriverDRI */
- "VDPAU", /* DRI2DriverVDPAU */
+
+ const char *driverTypeNames[] = {
+ "DRI", /* DRI2DriverDRI */
+ "VDPAU", /* DRI2DriverVDPAU */
};
unsigned int i;
CARD8 cur_minor;
if (info->version < 3)
- return FALSE;
+ return FALSE;
if (!xf86VGAarbiterAllowDRI(pScreen)) {
xf86DrvMsg(pScreen->myNum, X_WARNING,
- "[DRI2] Direct rendering is not supported when VGA arb is necessary for the device\n");
+ "[DRI2] Direct rendering is not supported when VGA arb is necessary for the device\n");
return FALSE;
}
if (!dixRegisterPrivateKey(&dri2ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
+ return FALSE;
if (!dixRegisterPrivateKey(&dri2WindowPrivateKeyRec, PRIVATE_WINDOW, 0))
- return FALSE;
+ return FALSE;
if (!dixRegisterPrivateKey(&dri2PixmapPrivateKeyRec, PRIVATE_PIXMAP, 0))
- return FALSE;
+ return FALSE;
ds = calloc(1, sizeof *ds);
if (!ds)
- return FALSE;
+ return FALSE;
- ds->screen = pScreen;
- ds->fd = info->fd;
- ds->deviceName = info->deviceName;
- dri2_major = 1;
+ ds->screen = pScreen;
+ ds->fd = info->fd;
+ ds->deviceName = info->deviceName;
+ dri2_major = 1;
- ds->CreateBuffer = info->CreateBuffer;
- ds->DestroyBuffer = info->DestroyBuffer;
- ds->CopyRegion = info->CopyRegion;
+ ds->CreateBuffer = info->CreateBuffer;
+ ds->DestroyBuffer = info->DestroyBuffer;
+ ds->CopyRegion = info->CopyRegion;
if (info->version >= 4) {
- ds->ScheduleSwap = info->ScheduleSwap;
- ds->ScheduleWaitMSC = info->ScheduleWaitMSC;
- ds->GetMSC = info->GetMSC;
- cur_minor = 3;
- } else {
- cur_minor = 1;
+ ds->ScheduleSwap = info->ScheduleSwap;
+ ds->ScheduleWaitMSC = info->ScheduleWaitMSC;
+ ds->GetMSC = info->GetMSC;
+ cur_minor = 3;
+ }
+ else {
+ cur_minor = 1;
}
if (info->version >= 5) {
@@ -1198,8 +1206,8 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
}
if (info->version >= 6) {
- ds->ReuseBufferNotify = info->ReuseBufferNotify;
- ds->SwapLimitValidate = info->SwapLimitValidate;
+ ds->ReuseBufferNotify = info->ReuseBufferNotify;
+ ds->SwapLimitValidate = info->SwapLimitValidate;
}
/*
@@ -1215,22 +1223,23 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
/* Initialize minor if needed and set to minimum provied by DDX */
if (!dri2_minor || dri2_minor > cur_minor)
- dri2_minor = cur_minor;
+ dri2_minor = cur_minor;
if (info->version == 3 || info->numDrivers == 0) {
- /* Driver too old: use the old-style driverName field */
- ds->numDrivers = 1;
- ds->driverNames = malloc(sizeof(*ds->driverNames));
- if (!ds->driverNames)
- goto err_out;
- ds->driverNames[0] = info->driverName;
- } else {
- ds->numDrivers = info->numDrivers;
- ds->driverNames = malloc(info->numDrivers * sizeof(*ds->driverNames));
- if (!ds->driverNames)
- goto err_out;
- memcpy(ds->driverNames, info->driverNames,
- info->numDrivers * sizeof(*ds->driverNames));
+ /* Driver too old: use the old-style driverName field */
+ ds->numDrivers = 1;
+ ds->driverNames = malloc(sizeof(*ds->driverNames));
+ if (!ds->driverNames)
+ goto err_out;
+ ds->driverNames[0] = info->driverName;
+ }
+ else {
+ ds->numDrivers = info->numDrivers;
+ ds->driverNames = malloc(info->numDrivers * sizeof(*ds->driverNames));
+ if (!ds->driverNames)
+ goto err_out;
+ memcpy(ds->driverNames, info->driverNames,
+ info->numDrivers * sizeof(*ds->driverNames));
}
dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, ds);
@@ -1240,17 +1249,18 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] Setup complete\n");
for (i = 0; i < sizeof(driverTypeNames) / sizeof(driverTypeNames[0]); i++) {
- if (i < ds->numDrivers && ds->driverNames[i]) {
- xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] %s driver: %s\n",
- driverTypeNames[i], ds->driverNames[i]);
- }
+ if (i < ds->numDrivers && ds->driverNames[i]) {
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] %s driver: %s\n",
+ driverTypeNames[i], ds->driverNames[i]);
+ }
}
return TRUE;
-err_out:
+ err_out:
xf86DrvMsg(pScreen->myNum, X_WARNING,
- "[DRI2] Initialization failed for info version %d.\n", info->version);
+ "[DRI2] Initialization failed for info version %d.\n",
+ info->version);
free(ds);
return FALSE;
}
@@ -1259,6 +1269,7 @@ void
DRI2CloseScreen(ScreenPtr pScreen)
{
DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+
pScreen->ConfigNotify = ds->ConfigNotify;
free(ds->driverNames);
@@ -1275,7 +1286,7 @@ DRI2ModuleSetup(void)
{
dri2DrawableRes = CreateNewResourceType(DRI2DrawableGone, "DRI2Drawable");
if (!dri2DrawableRes)
- return FALSE;
+ return FALSE;
return TRUE;
}
@@ -1285,22 +1296,19 @@ DRI2Setup(pointer module, pointer opts, int *errmaj, int *errmin)
{
static Bool setupDone = FALSE;
- if (!setupDone)
- {
- setupDone = TRUE;
- LoadExtension(&dri2ExtensionModule, FALSE);
+ if (!setupDone) {
+ setupDone = TRUE;
+ LoadExtension(&dri2ExtensionModule, FALSE);
}
- else
- {
- if (errmaj)
- *errmaj = LDR_ONCEONLY;
+ else {
+ if (errmaj)
+ *errmaj = LDR_ONCEONLY;
}
return (pointer) 1;
}
-static XF86ModuleVersionInfo DRI2VersRec =
-{
+static XF86ModuleVersionInfo DRI2VersRec = {
"dri2",
MODULEVENDORSTRING,
MODINFOSTRING1,
@@ -1310,7 +1318,7 @@ static XF86ModuleVersionInfo DRI2VersRec =
ABI_CLASS_EXTENSION,
ABI_EXTENSION_VERSION,
MOD_CLASS_NONE,
- { 0, 0, 0, 0 }
+ {0, 0, 0, 0}
};
_X_EXPORT XF86ModuleData dri2ModuleData = { &DRI2VersRec, DRI2Setup, NULL };
@@ -1319,8 +1327,8 @@ void
DRI2Version(int *major, int *minor)
{
if (major != NULL)
- *major = DRI2VersRec.majorversion;
+ *major = DRI2VersRec.majorversion;
if (minor != NULL)
- *minor = DRI2VersRec.minorversion;
+ *minor = DRI2VersRec.minorversion;
}
diff --git a/xorg-server/hw/xfree86/dri2/dri2.h b/xorg-server/hw/xfree86/dri2/dri2.h
index a67e35f73..00b3668cc 100644
--- a/xorg-server/hw/xfree86/dri2/dri2.h
+++ b/xorg-server/hw/xfree86/dri2/dri2.h
@@ -46,27 +46,24 @@ typedef struct {
void *driverPrivate;
} DRI2BufferRec, *DRI2BufferPtr;
-extern CARD8 dri2_major; /* version of DRI2 supported by DDX */
+extern CARD8 dri2_major; /* version of DRI2 supported by DDX */
extern CARD8 dri2_minor;
typedef DRI2BufferRec DRI2Buffer2Rec, *DRI2Buffer2Ptr;
-typedef void (*DRI2SwapEventPtr)(ClientPtr client, void *data, int type,
- CARD64 ust, CARD64 msc, CARD32 sbc);
-
-
-typedef DRI2BufferPtr (*DRI2CreateBuffersProcPtr)(DrawablePtr pDraw,
- unsigned int *attachments,
- int count);
-typedef void (*DRI2DestroyBuffersProcPtr)(DrawablePtr pDraw,
- DRI2BufferPtr buffers,
- int count);
-typedef void (*DRI2CopyRegionProcPtr)(DrawablePtr pDraw,
- RegionPtr pRegion,
- DRI2BufferPtr pDestBuffer,
- DRI2BufferPtr pSrcBuffer);
-typedef void (*DRI2WaitProcPtr)(WindowPtr pWin,
- unsigned int sequence);
-typedef int (*DRI2AuthMagicProcPtr)(int fd, uint32_t magic);
+typedef void (*DRI2SwapEventPtr) (ClientPtr client, void *data, int type,
+ CARD64 ust, CARD64 msc, CARD32 sbc);
+
+typedef DRI2BufferPtr(*DRI2CreateBuffersProcPtr) (DrawablePtr pDraw,
+ unsigned int *attachments,
+ int count);
+typedef void (*DRI2DestroyBuffersProcPtr) (DrawablePtr pDraw,
+ DRI2BufferPtr buffers, int count);
+typedef void (*DRI2CopyRegionProcPtr) (DrawablePtr pDraw,
+ RegionPtr pRegion,
+ DRI2BufferPtr pDestBuffer,
+ DRI2BufferPtr pSrcBuffer);
+typedef void (*DRI2WaitProcPtr) (WindowPtr pWin, unsigned int sequence);
+typedef int (*DRI2AuthMagicProcPtr) (int fd, uint32_t magic);
/**
* Schedule a buffer swap
@@ -95,20 +92,19 @@ typedef int (*DRI2AuthMagicProcPtr)(int fd, uint32_t magic);
* \param func function to call when the swap completes
* \param data data for the callback \p func.
*/
-typedef int (*DRI2ScheduleSwapProcPtr)(ClientPtr client,
- DrawablePtr pDraw,
- DRI2BufferPtr pDestBuffer,
- DRI2BufferPtr pSrcBuffer,
- CARD64 *target_msc,
- CARD64 divisor,
- CARD64 remainder,
- DRI2SwapEventPtr func,
- void *data);
-typedef DRI2BufferPtr (*DRI2CreateBufferProcPtr)(DrawablePtr pDraw,
- unsigned int attachment,
- unsigned int format);
-typedef void (*DRI2DestroyBufferProcPtr)(DrawablePtr pDraw,
- DRI2BufferPtr buffer);
+typedef int (*DRI2ScheduleSwapProcPtr) (ClientPtr client,
+ DrawablePtr pDraw,
+ DRI2BufferPtr pDestBuffer,
+ DRI2BufferPtr pSrcBuffer,
+ CARD64 * target_msc,
+ CARD64 divisor,
+ CARD64 remainder,
+ DRI2SwapEventPtr func, void *data);
+typedef DRI2BufferPtr(*DRI2CreateBufferProcPtr) (DrawablePtr pDraw,
+ unsigned int attachment,
+ unsigned int format);
+typedef void (*DRI2DestroyBufferProcPtr) (DrawablePtr pDraw,
+ DRI2BufferPtr buffer);
/**
* Notifies driver when DRI2GetBuffers reuses a dri2 buffer.
*
@@ -117,8 +113,8 @@ typedef void (*DRI2DestroyBufferProcPtr)(DrawablePtr pDraw,
* \param pDraw drawable whose count we want
* \param buffer buffer that will be returned to client
*/
-typedef void (*DRI2ReuseBufferNotifyProcPtr)(DrawablePtr pDraw,
- DRI2BufferPtr buffer);
+typedef void (*DRI2ReuseBufferNotifyProcPtr) (DrawablePtr pDraw,
+ DRI2BufferPtr buffer);
/**
* Get current media stamp counter values
*
@@ -137,8 +133,8 @@ typedef void (*DRI2ReuseBufferNotifyProcPtr)(DrawablePtr pDraw,
* \param ust timestamp from when the count was last incremented.
* \param mst current frame count
*/
-typedef int (*DRI2GetMSCProcPtr)(DrawablePtr pDraw, CARD64 *ust,
- CARD64 *msc);
+typedef int (*DRI2GetMSCProcPtr) (DrawablePtr pDraw, CARD64 * ust,
+ CARD64 * msc);
/**
* Schedule a frame count related wait
*
@@ -159,15 +155,12 @@ typedef int (*DRI2GetMSCProcPtr)(DrawablePtr pDraw, CARD64 *ust,
* \param divisor divisor for condition equation
* \param remainder remainder for division equation
*/
-typedef int (*DRI2ScheduleWaitMSCProcPtr)(ClientPtr client,
- DrawablePtr pDraw,
- CARD64 target_msc,
- CARD64 divisor,
- CARD64 remainder);
+typedef int (*DRI2ScheduleWaitMSCProcPtr) (ClientPtr client,
+ DrawablePtr pDraw,
+ CARD64 target_msc,
+ CARD64 divisor, CARD64 remainder);
-typedef void (*DRI2InvalidateProcPtr)(DrawablePtr pDraw,
- void *data,
- XID id);
+typedef void (*DRI2InvalidateProcPtr) (DrawablePtr pDraw, void *data, XID id);
/**
* DRI2 calls this hook when ever swap_limit is going to be changed. Default
@@ -179,8 +172,8 @@ typedef void (*DRI2InvalidateProcPtr)(DrawablePtr pDraw,
* \param swap_limit new swap_limit that going to be set
* \return TRUE if limit is support, FALSE if not.
*/
-typedef Bool (*DRI2SwapLimitValidateProcPtr)(DrawablePtr pDraw,
- int swap_limit);
+typedef Bool (*DRI2SwapLimitValidateProcPtr) (DrawablePtr pDraw,
+ int swap_limit);
/**
* Version of the DRI2InfoRec structure defined in this header
@@ -188,74 +181,71 @@ typedef Bool (*DRI2SwapLimitValidateProcPtr)(DrawablePtr pDraw,
#define DRI2INFOREC_VERSION 6
typedef struct {
- unsigned int version; /**< Version of this struct */
+ unsigned int version; /**< Version of this struct */
int fd;
const char *driverName;
const char *deviceName;
- DRI2CreateBufferProcPtr CreateBuffer;
- DRI2DestroyBufferProcPtr DestroyBuffer;
- DRI2CopyRegionProcPtr CopyRegion;
- DRI2WaitProcPtr Wait;
+ DRI2CreateBufferProcPtr CreateBuffer;
+ DRI2DestroyBufferProcPtr DestroyBuffer;
+ DRI2CopyRegionProcPtr CopyRegion;
+ DRI2WaitProcPtr Wait;
/* added in version 4 */
- DRI2ScheduleSwapProcPtr ScheduleSwap;
- DRI2GetMSCProcPtr GetMSC;
- DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
+ DRI2ScheduleSwapProcPtr ScheduleSwap;
+ DRI2GetMSCProcPtr GetMSC;
+ DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
/* number of drivers in the driverNames array */
unsigned int numDrivers;
/* array of driver names, indexed by DRI2Driver* driver types */
/* a name of NULL means that driver is not supported */
- const char * const *driverNames;
+ const char *const *driverNames;
/* added in version 5 */
- DRI2AuthMagicProcPtr AuthMagic;
+ DRI2AuthMagicProcPtr AuthMagic;
/* added in version 6 */
DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
DRI2SwapLimitValidateProcPtr SwapLimitValidate;
-} DRI2InfoRec, *DRI2InfoPtr;
+} DRI2InfoRec, *DRI2InfoPtr;
extern _X_EXPORT int DRI2EventBase;
-extern _X_EXPORT Bool DRI2ScreenInit(ScreenPtr pScreen,
- DRI2InfoPtr info);
+extern _X_EXPORT Bool DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info);
extern _X_EXPORT void DRI2CloseScreen(ScreenPtr pScreen);
extern _X_EXPORT Bool DRI2HasSwapControl(ScreenPtr pScreen);
extern _X_EXPORT Bool DRI2Connect(ScreenPtr pScreen,
- unsigned int driverType,
- int *fd,
- const char **driverName,
- const char **deviceName);
+ unsigned int driverType,
+ int *fd,
+ const char **driverName,
+ const char **deviceName);
extern _X_EXPORT Bool DRI2Authenticate(ScreenPtr pScreen, uint32_t magic);
extern _X_EXPORT int DRI2CreateDrawable(ClientPtr client,
- DrawablePtr pDraw,
- XID id,
- DRI2InvalidateProcPtr invalidate,
- void *priv);
+ DrawablePtr pDraw,
+ XID id,
+ DRI2InvalidateProcPtr invalidate,
+ void *priv);
extern _X_EXPORT void DRI2DestroyDrawable(DrawablePtr pDraw);
extern _X_EXPORT DRI2BufferPtr *DRI2GetBuffers(DrawablePtr pDraw,
- int *width,
- int *height,
- unsigned int *attachments,
- int count,
- int *out_count);
+ int *width,
+ int *height,
+ unsigned int *attachments,
+ int count, int *out_count);
extern _X_EXPORT int DRI2CopyRegion(DrawablePtr pDraw,
- RegionPtr pRegion,
- unsigned int dest,
- unsigned int src);
+ RegionPtr pRegion,
+ unsigned int dest, unsigned int src);
/**
* Determine the major and minor version of the DRI2 extension.
@@ -276,26 +266,30 @@ extern _X_EXPORT int DRI2CopyRegion(DrawablePtr pDraw,
extern _X_EXPORT void DRI2Version(int *major, int *minor);
extern _X_EXPORT DRI2BufferPtr *DRI2GetBuffersWithFormat(DrawablePtr pDraw,
- int *width, int *height, unsigned int *attachments, int count,
- int *out_count);
+ int *width,
+ int *height,
+ unsigned int
+ *attachments,
+ int count,
+ int *out_count);
extern _X_EXPORT void DRI2SwapInterval(DrawablePtr pDrawable, int interval);
extern _X_EXPORT Bool DRI2SwapLimit(DrawablePtr pDraw, int swap_limit);
extern _X_EXPORT int DRI2SwapBuffers(ClientPtr client, DrawablePtr pDrawable,
- CARD64 target_msc, CARD64 divisor,
- CARD64 remainder, CARD64 *swap_target,
- DRI2SwapEventPtr func, void *data);
+ CARD64 target_msc, CARD64 divisor,
+ CARD64 remainder, CARD64 * swap_target,
+ DRI2SwapEventPtr func, void *data);
extern _X_EXPORT Bool DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable);
-extern _X_EXPORT int DRI2GetMSC(DrawablePtr pDrawable, CARD64 *ust,
- CARD64 *msc, CARD64 *sbc);
+extern _X_EXPORT int DRI2GetMSC(DrawablePtr pDrawable, CARD64 * ust,
+ CARD64 * msc, CARD64 * sbc);
extern _X_EXPORT int DRI2WaitMSC(ClientPtr client, DrawablePtr pDrawable,
- CARD64 target_msc, CARD64 divisor,
- CARD64 remainder);
+ CARD64 target_msc, CARD64 divisor,
+ CARD64 remainder);
extern _X_EXPORT int ProcDRI2WaitMSCReply(ClientPtr client, CARD64 ust,
- CARD64 msc, CARD64 sbc);
+ CARD64 msc, CARD64 sbc);
extern _X_EXPORT int DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw,
- CARD64 target_sbc);
+ CARD64 target_sbc);
extern _X_EXPORT Bool DRI2ThrottleClient(ClientPtr client, DrawablePtr pDraw);
extern _X_EXPORT Bool DRI2CanFlip(DrawablePtr pDraw);
@@ -306,12 +300,12 @@ extern _X_EXPORT Bool DRI2CanExchange(DrawablePtr pDraw);
extern _X_EXPORT void DRI2BlockClient(ClientPtr client, DrawablePtr pDraw);
extern _X_EXPORT void DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw,
- int frame, unsigned int tv_sec,
- unsigned int tv_usec, int type,
- DRI2SwapEventPtr swap_complete,
- void *swap_data);
+ int frame, unsigned int tv_sec,
+ unsigned int tv_usec, int type,
+ DRI2SwapEventPtr swap_complete,
+ void *swap_data);
extern _X_EXPORT void DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw,
- int frame, unsigned int tv_sec,
- unsigned int tv_usec);
+ int frame, unsigned int tv_sec,
+ unsigned int tv_usec);
#endif
diff --git a/xorg-server/hw/xfree86/dri2/dri2ext.c b/xorg-server/hw/xfree86/dri2/dri2ext.c
index 73ef7f25e..2579a5c86 100644
--- a/xorg-server/hw/xfree86/dri2/dri2ext.c
+++ b/xorg-server/hw/xfree86/dri2/dri2ext.c
@@ -49,19 +49,19 @@
/* The only xf86 include */
#include "xf86Module.h"
-static ExtensionEntry *dri2Extension;
+static ExtensionEntry *dri2Extension;
extern Bool DRI2ModuleSetup(void);
static Bool
validDrawable(ClientPtr client, XID drawable, Mask access_mode,
- DrawablePtr *pDrawable, int *status)
+ DrawablePtr *pDrawable, int *status)
{
*status = dixLookupDrawable(pDrawable, drawable, client,
- M_DRAWABLE_WINDOW | M_DRAWABLE_PIXMAP,
- access_mode);
+ M_DRAWABLE_WINDOW | M_DRAWABLE_PIXMAP,
+ access_mode);
if (*status != Success) {
- client->errorValue = drawable;
- return FALSE;
+ client->errorValue = drawable;
+ return FALSE;
}
return TRUE;
@@ -74,7 +74,7 @@ ProcDRI2QueryVersion(ClientPtr client)
xDRI2QueryVersionReply rep;
if (client->swapped)
- swaps(&stuff->length);
+ swaps(&stuff->length);
REQUEST_SIZE_MATCH(xDRI2QueryVersionReq);
rep.type = X_Reply;
@@ -84,10 +84,10 @@ ProcDRI2QueryVersion(ClientPtr client)
rep.minorVersion = dri2_minor;
if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swapl(&rep.majorVersion);
- swapl(&rep.minorVersion);
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
+ swapl(&rep.majorVersion);
+ swapl(&rep.minorVersion);
}
WriteToClient(client, sizeof(xDRI2QueryVersionReply), &rep);
@@ -107,9 +107,9 @@ ProcDRI2Connect(ClientPtr client)
REQUEST_SIZE_MATCH(xDRI2ConnectReq);
if (!validDrawable(client, stuff->window, DixGetAttrAccess,
- &pDraw, &status))
- return status;
-
+ &pDraw, &status))
+ return status;
+
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
@@ -117,13 +117,13 @@ ProcDRI2Connect(ClientPtr client)
rep.deviceNameLength = 0;
if (!DRI2Connect(pDraw->pScreen,
- stuff->driverType, &fd, &driverName, &deviceName))
- goto fail;
+ stuff->driverType, &fd, &driverName, &deviceName))
+ goto fail;
rep.driverNameLength = strlen(driverName);
rep.deviceNameLength = strlen(deviceName);
rep.length = (rep.driverNameLength + 3) / 4 +
- (rep.deviceNameLength + 3) / 4;
+ (rep.deviceNameLength + 3) / 4;
fail:
WriteToClient(client, sizeof(xDRI2ConnectReply), &rep);
@@ -143,8 +143,8 @@ ProcDRI2Authenticate(ClientPtr client)
REQUEST_SIZE_MATCH(xDRI2AuthenticateReq);
if (!validDrawable(client, stuff->window, DixGetAttrAccess,
- &pDraw, &status))
- return status;
+ &pDraw, &status))
+ return status;
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
@@ -164,7 +164,7 @@ DRI2InvalidateBuffersEvent(DrawablePtr pDraw, void *priv, XID id)
event.type = DRI2EventBase + DRI2_InvalidateBuffers;
event.drawable = id;
- WriteEventsToClient(client, 1, (xEvent *)&event);
+ WriteEventsToClient(client, 1, (xEvent *) &event);
}
static int
@@ -177,13 +177,13 @@ ProcDRI2CreateDrawable(ClientPtr client)
REQUEST_SIZE_MATCH(xDRI2CreateDrawableReq);
if (!validDrawable(client, stuff->drawable, DixAddAccess,
- &pDrawable, &status))
- return status;
+ &pDrawable, &status))
+ return status;
status = DRI2CreateDrawable(client, pDrawable, stuff->drawable,
- DRI2InvalidateBuffersEvent, client);
+ DRI2InvalidateBuffersEvent, client);
if (status != Success)
- return status;
+ return status;
return Success;
}
@@ -197,33 +197,32 @@ ProcDRI2DestroyDrawable(ClientPtr client)
REQUEST_SIZE_MATCH(xDRI2DestroyDrawableReq);
if (!validDrawable(client, stuff->drawable, DixRemoveAccess,
- &pDrawable, &status))
- return status;
+ &pDrawable, &status))
+ return status;
return Success;
}
-
static int
send_buffers_reply(ClientPtr client, DrawablePtr pDrawable,
- DRI2BufferPtr *buffers, int count, int width, int height)
+ DRI2BufferPtr * buffers, int count, int width, int height)
{
xDRI2GetBuffersReply rep;
int skip = 0;
int i;
if (buffers == NULL)
- return BadAlloc;
+ return BadAlloc;
if (pDrawable->type == DRAWABLE_WINDOW) {
- for (i = 0; i < count; i++) {
- /* Do not send the real front buffer of a window to the client.
- */
- if (buffers[i]->attachment == DRI2BufferFrontLeft) {
- skip++;
- continue;
- }
- }
+ for (i = 0; i < count; i++) {
+ /* Do not send the real front buffer of a window to the client.
+ */
+ if (buffers[i]->attachment == DRI2BufferFrontLeft) {
+ skip++;
+ continue;
+ }
+ }
}
rep.type = X_Reply;
@@ -235,26 +234,25 @@ send_buffers_reply(ClientPtr client, DrawablePtr pDrawable,
WriteToClient(client, sizeof(xDRI2GetBuffersReply), &rep);
for (i = 0; i < count; i++) {
- xDRI2Buffer buffer;
-
- /* Do not send the real front buffer of a window to the client.
- */
- if ((pDrawable->type == DRAWABLE_WINDOW)
- && (buffers[i]->attachment == DRI2BufferFrontLeft)) {
- continue;
- }
-
- buffer.attachment = buffers[i]->attachment;
- buffer.name = buffers[i]->name;
- buffer.pitch = buffers[i]->pitch;
- buffer.cpp = buffers[i]->cpp;
- buffer.flags = buffers[i]->flags;
- WriteToClient(client, sizeof(xDRI2Buffer), &buffer);
+ xDRI2Buffer buffer;
+
+ /* Do not send the real front buffer of a window to the client.
+ */
+ if ((pDrawable->type == DRAWABLE_WINDOW)
+ && (buffers[i]->attachment == DRI2BufferFrontLeft)) {
+ continue;
+ }
+
+ buffer.attachment = buffers[i]->attachment;
+ buffer.name = buffers[i]->name;
+ buffer.pitch = buffers[i]->pitch;
+ buffer.cpp = buffers[i]->cpp;
+ buffer.flags = buffers[i]->flags;
+ WriteToClient(client, sizeof(xDRI2Buffer), &buffer);
}
return Success;
}
-
static int
ProcDRI2GetBuffers(ClientPtr client)
{
@@ -266,16 +264,15 @@ ProcDRI2GetBuffers(ClientPtr client)
REQUEST_FIXED_SIZE(xDRI2GetBuffersReq, stuff->count * 4);
if (!validDrawable(client, stuff->drawable, DixReadAccess | DixWriteAccess,
- &pDrawable, &status))
- return status;
+ &pDrawable, &status))
+ return status;
if (DRI2ThrottleClient(client, pDrawable))
- return Success;
+ return Success;
attachments = (unsigned int *) &stuff[1];
buffers = DRI2GetBuffers(pDrawable, &width, &height,
- attachments, stuff->count, &count);
-
+ attachments, stuff->count, &count);
return send_buffers_reply(client, pDrawable, buffers, count, width, height);
@@ -292,15 +289,15 @@ ProcDRI2GetBuffersWithFormat(ClientPtr client)
REQUEST_FIXED_SIZE(xDRI2GetBuffersReq, stuff->count * (2 * 4));
if (!validDrawable(client, stuff->drawable, DixReadAccess | DixWriteAccess,
- &pDrawable, &status))
- return status;
+ &pDrawable, &status))
+ return status;
if (DRI2ThrottleClient(client, pDrawable))
- return Success;
+ return Success;
attachments = (unsigned int *) &stuff[1];
buffers = DRI2GetBuffersWithFormat(pDrawable, &width, &height,
- attachments, stuff->count, &count);
+ attachments, stuff->count, &count);
return send_buffers_reply(client, pDrawable, buffers, count, width, height);
}
@@ -317,14 +314,14 @@ ProcDRI2CopyRegion(ClientPtr client)
REQUEST_SIZE_MATCH(xDRI2CopyRegionReq);
if (!validDrawable(client, stuff->drawable, DixWriteAccess,
- &pDrawable, &status))
- return status;
+ &pDrawable, &status))
+ return status;
VERIFY_REGION(pRegion, stuff->region, client, DixReadAccess);
status = DRI2CopyRegion(pDrawable, pRegion, stuff->dest, stuff->src);
if (status != Success)
- return status;
+ return status;
/* CopyRegion needs to be a round trip to make sure the X server
* queues the swap buffer rendering commands before the DRI client
@@ -343,7 +340,7 @@ ProcDRI2CopyRegion(ClientPtr client)
}
static void
-load_swap_reply(xDRI2SwapBuffersReply *rep, CARD64 sbc)
+load_swap_reply(xDRI2SwapBuffersReply * rep, CARD64 sbc)
{
rep->swap_hi = sbc >> 32;
rep->swap_lo = sbc & 0xffffffff;
@@ -352,12 +349,12 @@ load_swap_reply(xDRI2SwapBuffersReply *rep, CARD64 sbc)
static CARD64
vals_to_card64(CARD32 lo, CARD32 hi)
{
- return (CARD64)hi << 32 | lo;
+ return (CARD64) hi << 32 | lo;
}
static void
DRI2SwapEvent(ClientPtr client, void *data, int type, CARD64 ust, CARD64 msc,
- CARD32 sbc)
+ CARD32 sbc)
{
xDRI2BufferSwapComplete2 event;
DrawablePtr pDrawable = data;
@@ -365,13 +362,13 @@ DRI2SwapEvent(ClientPtr client, void *data, int type, CARD64 ust, CARD64 msc,
event.type = DRI2EventBase + DRI2_BufferSwapComplete;
event.event_type = type;
event.drawable = pDrawable->id;
- event.ust_hi = (CARD64)ust >> 32;
+ event.ust_hi = (CARD64) ust >> 32;
event.ust_lo = ust & 0xffffffff;
- event.msc_hi = (CARD64)msc >> 32;
+ event.msc_hi = (CARD64) msc >> 32;
event.msc_lo = msc & 0xffffffff;
event.sbc = sbc;
- WriteEventsToClient(client, 1, (xEvent *)&event);
+ WriteEventsToClient(client, 1, (xEvent *) &event);
}
static int
@@ -386,24 +383,24 @@ ProcDRI2SwapBuffers(ClientPtr client)
REQUEST_SIZE_MATCH(xDRI2SwapBuffersReq);
if (!validDrawable(client, stuff->drawable,
- DixReadAccess | DixWriteAccess, &pDrawable, &status))
- return status;
+ DixReadAccess | DixWriteAccess, &pDrawable, &status))
+ return status;
/*
* Ensures an out of control client can't exhaust our swap queue, and
* also orders swaps.
*/
if (DRI2ThrottleClient(client, pDrawable))
- return Success;
+ return Success;
target_msc = vals_to_card64(stuff->target_msc_lo, stuff->target_msc_hi);
divisor = vals_to_card64(stuff->divisor_lo, stuff->divisor_hi);
remainder = vals_to_card64(stuff->remainder_lo, stuff->remainder_hi);
status = DRI2SwapBuffers(client, pDrawable, target_msc, divisor, remainder,
- &swap_target, DRI2SwapEvent, pDrawable);
+ &swap_target, DRI2SwapEvent, pDrawable);
if (status != Success)
- return BadDrawable;
+ return BadDrawable;
rep.type = X_Reply;
rep.length = 0;
@@ -416,7 +413,7 @@ ProcDRI2SwapBuffers(ClientPtr client)
}
static void
-load_msc_reply(xDRI2MSCReply *rep, CARD64 ust, CARD64 msc, CARD64 sbc)
+load_msc_reply(xDRI2MSCReply * rep, CARD64 ust, CARD64 msc, CARD64 sbc)
{
rep->ust_hi = ust >> 32;
rep->ust_lo = ust & 0xffffffff;
@@ -438,12 +435,12 @@ ProcDRI2GetMSC(ClientPtr client)
REQUEST_SIZE_MATCH(xDRI2GetMSCReq);
if (!validDrawable(client, stuff->drawable, DixReadAccess, &pDrawable,
- &status))
- return status;
+ &status))
+ return status;
status = DRI2GetMSC(pDrawable, &ust, &msc, &sbc);
if (status != Success)
- return status;
+ return status;
rep.type = X_Reply;
rep.length = 0;
@@ -468,8 +465,8 @@ ProcDRI2WaitMSC(ClientPtr client)
REQUEST_SIZE_MATCH(xDRI2WaitMSCReq);
if (!validDrawable(client, stuff->drawable, DixReadAccess, &pDrawable,
- &status))
- return status;
+ &status))
+ return status;
target = vals_to_card64(stuff->target_msc_lo, stuff->target_msc_hi);
divisor = vals_to_card64(stuff->divisor_lo, stuff->divisor_hi);
@@ -477,7 +474,7 @@ ProcDRI2WaitMSC(ClientPtr client)
status = DRI2WaitMSC(client, pDrawable, target, divisor, remainder);
if (status != Success)
- return status;
+ return status;
return Success;
}
@@ -509,8 +506,8 @@ ProcDRI2SwapInterval(ClientPtr client)
REQUEST_SIZE_MATCH(xDRI2SwapIntervalReq);
if (!validDrawable(client, stuff->drawable, DixReadAccess | DixWriteAccess,
- &pDrawable, &status))
- return status;
+ &pDrawable, &status))
+ return status;
DRI2SwapInterval(pDrawable, stuff->interval);
@@ -528,8 +525,8 @@ ProcDRI2WaitSBC(ClientPtr client)
REQUEST_SIZE_MATCH(xDRI2WaitSBCReq);
if (!validDrawable(client, stuff->drawable, DixReadAccess, &pDrawable,
- &status))
- return status;
+ &status))
+ return status;
target = vals_to_card64(stuff->target_sbc_lo, stuff->target_sbc_hi);
status = DRI2WaitSBC(client, pDrawable, target);
@@ -538,45 +535,45 @@ ProcDRI2WaitSBC(ClientPtr client)
}
static int
-ProcDRI2Dispatch (ClientPtr client)
+ProcDRI2Dispatch(ClientPtr client)
{
REQUEST(xReq);
-
+
switch (stuff->data) {
case X_DRI2QueryVersion:
- return ProcDRI2QueryVersion(client);
+ return ProcDRI2QueryVersion(client);
}
if (!LocalClient(client))
- return BadRequest;
+ return BadRequest;
switch (stuff->data) {
case X_DRI2Connect:
- return ProcDRI2Connect(client);
+ return ProcDRI2Connect(client);
case X_DRI2Authenticate:
- return ProcDRI2Authenticate(client);
+ return ProcDRI2Authenticate(client);
case X_DRI2CreateDrawable:
- return ProcDRI2CreateDrawable(client);
+ return ProcDRI2CreateDrawable(client);
case X_DRI2DestroyDrawable:
- return ProcDRI2DestroyDrawable(client);
+ return ProcDRI2DestroyDrawable(client);
case X_DRI2GetBuffers:
- return ProcDRI2GetBuffers(client);
+ return ProcDRI2GetBuffers(client);
case X_DRI2CopyRegion:
- return ProcDRI2CopyRegion(client);
+ return ProcDRI2CopyRegion(client);
case X_DRI2GetBuffersWithFormat:
- return ProcDRI2GetBuffersWithFormat(client);
+ return ProcDRI2GetBuffersWithFormat(client);
case X_DRI2SwapBuffers:
- return ProcDRI2SwapBuffers(client);
+ return ProcDRI2SwapBuffers(client);
case X_DRI2GetMSC:
- return ProcDRI2GetMSC(client);
+ return ProcDRI2GetMSC(client);
case X_DRI2WaitMSC:
- return ProcDRI2WaitMSC(client);
+ return ProcDRI2WaitMSC(client);
case X_DRI2WaitSBC:
- return ProcDRI2WaitSBC(client);
+ return ProcDRI2WaitSBC(client);
case X_DRI2SwapInterval:
- return ProcDRI2SwapInterval(client);
+ return ProcDRI2SwapInterval(client);
default:
- return BadRequest;
+ return BadRequest;
}
}
@@ -590,7 +587,7 @@ SProcDRI2Connect(ClientPtr client)
swaps(&stuff->length);
if (sizeof(*stuff) / 4 != client->req_len)
- return BadLength;
+ return BadLength;
rep.sequenceNumber = client->sequence;
swaps(&rep.sequenceNumber);
@@ -602,7 +599,7 @@ SProcDRI2Connect(ClientPtr client)
}
static int
-SProcDRI2Dispatch (ClientPtr client)
+SProcDRI2Dispatch(ClientPtr client)
{
REQUEST(xReq);
@@ -610,14 +607,13 @@ SProcDRI2Dispatch (ClientPtr client)
* Only local clients are allowed DRI access, but remote clients
* still need these requests to find out cleanly.
*/
- switch (stuff->data)
- {
+ switch (stuff->data) {
case X_DRI2QueryVersion:
- return ProcDRI2QueryVersion(client);
+ return ProcDRI2QueryVersion(client);
case X_DRI2Connect:
- return SProcDRI2Connect(client);
+ return SProcDRI2Connect(client);
default:
- return BadRequest;
+ return BadRequest;
}
}
@@ -627,12 +623,10 @@ static void
DRI2ExtensionInit(void)
{
dri2Extension = AddExtension(DRI2_NAME,
- DRI2NumberEvents,
- DRI2NumberErrors,
- ProcDRI2Dispatch,
- SProcDRI2Dispatch,
- NULL,
- StandardMinorOpcode);
+ DRI2NumberEvents,
+ DRI2NumberErrors,
+ ProcDRI2Dispatch,
+ SProcDRI2Dispatch, NULL, StandardMinorOpcode);
DRI2EventBase = dri2Extension->eventBase;
diff --git a/xorg-server/hw/xfree86/exa/examodule.c b/xorg-server/hw/xfree86/exa/examodule.c
index 15560513d..72cf7988d 100644
--- a/xorg-server/hw/xfree86/exa/examodule.c
+++ b/xorg-server/hw/xfree86/exa/examodule.c
@@ -37,12 +37,13 @@
#include "xf86.h"
typedef struct _ExaXorgScreenPrivRec {
- CloseScreenProcPtr SavedCloseScreen;
+ CloseScreenProcPtr SavedCloseScreen;
EnableDisableFBAccessProcPtr SavedEnableDisableFBAccess;
- OptionInfoPtr options;
+ OptionInfoPtr options;
} ExaXorgScreenPrivRec, *ExaXorgScreenPrivPtr;
static DevPrivateKeyRec exaXorgScreenPrivateKeyRec;
+
#define exaXorgScreenPrivateKey (&exaXorgScreenPrivateKeyRec)
typedef enum {
@@ -54,26 +55,26 @@ typedef enum {
} EXAOpts;
static const OptionInfoRec EXAOptions[] = {
- { EXAOPT_MIGRATION_HEURISTIC, "MigrationHeuristic",
- OPTV_ANYSTR, {0}, FALSE },
- { EXAOPT_NO_COMPOSITE, "EXANoComposite",
- OPTV_BOOLEAN, {0}, FALSE },
- { EXAOPT_NO_UTS, "EXANoUploadToScreen",
- OPTV_BOOLEAN, {0}, FALSE },
- { EXAOPT_NO_DFS, "EXANoDownloadFromScreen",
- OPTV_BOOLEAN, {0}, FALSE },
- { EXAOPT_OPTIMIZE_MIGRATION, "EXAOptimizeMigration",
- OPTV_BOOLEAN, {0}, FALSE },
- { -1, NULL,
- OPTV_NONE, {0}, FALSE }
+ {EXAOPT_MIGRATION_HEURISTIC, "MigrationHeuristic",
+ OPTV_ANYSTR, {0}, FALSE},
+ {EXAOPT_NO_COMPOSITE, "EXANoComposite",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {EXAOPT_NO_UTS, "EXANoUploadToScreen",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {EXAOPT_NO_DFS, "EXANoDownloadFromScreen",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {EXAOPT_OPTIMIZE_MIGRATION, "EXAOptimizeMigration",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {-1, NULL,
+ OPTV_NONE, {0}, FALSE}
};
static Bool
-exaXorgCloseScreen (int i, ScreenPtr pScreen)
+exaXorgCloseScreen(int i, ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
ExaXorgScreenPrivPtr pScreenPriv = (ExaXorgScreenPrivPtr)
- dixLookupPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey);
+ dixLookupPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey);
pScreen->CloseScreen = pScreenPriv->SavedCloseScreen;
@@ -82,24 +83,24 @@ exaXorgCloseScreen (int i, ScreenPtr pScreen)
free(pScreenPriv->options);
free(pScreenPriv);
- return pScreen->CloseScreen (i, pScreen);
+ return pScreen->CloseScreen(i, pScreen);
}
static void
-exaXorgEnableDisableFBAccess (int index, Bool enable)
+exaXorgEnableDisableFBAccess(int index, Bool enable)
{
ScreenPtr pScreen = screenInfo.screens[index];
ExaXorgScreenPrivPtr pScreenPriv = (ExaXorgScreenPrivPtr)
- dixLookupPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey);
+ dixLookupPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey);
if (!enable)
- exaEnableDisableFBAccess (index, enable);
+ exaEnableDisableFBAccess(index, enable);
if (pScreenPriv->SavedEnableDisableFBAccess)
- pScreenPriv->SavedEnableDisableFBAccess (index, enable);
+ pScreenPriv->SavedEnableDisableFBAccess(index, enable);
if (enable)
- exaEnableDisableFBAccess (index, enable);
+ exaEnableDisableFBAccess(index, enable);
}
/**
@@ -115,87 +116,83 @@ exaDDXDriverInit(ScreenPtr pScreen)
ExaXorgScreenPrivPtr pScreenPriv;
if (!dixRegisterPrivateKey(&exaXorgScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
- return;
+ return;
pScreenPriv = calloc(1, sizeof(ExaXorgScreenPrivRec));
if (pScreenPriv == NULL)
- return;
+ return;
- pScreenPriv->options = xnfalloc (sizeof(EXAOptions));
+ pScreenPriv->options = xnfalloc(sizeof(EXAOptions));
memcpy(pScreenPriv->options, EXAOptions, sizeof(EXAOptions));
- xf86ProcessOptions (pScrn->scrnIndex, pScrn->options, pScreenPriv->options);
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pScreenPriv->options);
if (pExaScr->info->flags & EXA_OFFSCREEN_PIXMAPS) {
- if (!(pExaScr->info->flags & EXA_HANDLES_PIXMAPS) &&
- pExaScr->info->offScreenBase < pExaScr->info->memorySize) {
- char *heuristicName;
-
- heuristicName = xf86GetOptValString (pScreenPriv->options,
- EXAOPT_MIGRATION_HEURISTIC);
- if (heuristicName != NULL) {
- if (strcmp(heuristicName, "greedy") == 0)
- pExaScr->migration = ExaMigrationGreedy;
- else if (strcmp(heuristicName, "always") == 0)
- pExaScr->migration = ExaMigrationAlways;
- else if (strcmp(heuristicName, "smart") == 0)
- pExaScr->migration = ExaMigrationSmart;
- else {
- xf86DrvMsg (pScreen->myNum, X_WARNING,
- "EXA: unknown migration heuristic %s\n",
- heuristicName);
- }
- }
- }
-
- pExaScr->optimize_migration =
- xf86ReturnOptValBool(pScreenPriv->options,
- EXAOPT_OPTIMIZE_MIGRATION,
- TRUE);
+ if (!(pExaScr->info->flags & EXA_HANDLES_PIXMAPS) &&
+ pExaScr->info->offScreenBase < pExaScr->info->memorySize) {
+ char *heuristicName;
+
+ heuristicName = xf86GetOptValString(pScreenPriv->options,
+ EXAOPT_MIGRATION_HEURISTIC);
+ if (heuristicName != NULL) {
+ if (strcmp(heuristicName, "greedy") == 0)
+ pExaScr->migration = ExaMigrationGreedy;
+ else if (strcmp(heuristicName, "always") == 0)
+ pExaScr->migration = ExaMigrationAlways;
+ else if (strcmp(heuristicName, "smart") == 0)
+ pExaScr->migration = ExaMigrationSmart;
+ else {
+ xf86DrvMsg(pScreen->myNum, X_WARNING,
+ "EXA: unknown migration heuristic %s\n",
+ heuristicName);
+ }
+ }
+ }
+
+ pExaScr->optimize_migration =
+ xf86ReturnOptValBool(pScreenPriv->options,
+ EXAOPT_OPTIMIZE_MIGRATION, TRUE);
}
- if (xf86ReturnOptValBool(pScreenPriv->options,
- EXAOPT_NO_COMPOSITE, FALSE)) {
- xf86DrvMsg(pScreen->myNum, X_CONFIG,
- "EXA: Disabling Composite operation "
- "(RENDER acceleration)\n");
- pExaScr->info->CheckComposite = NULL;
- pExaScr->info->PrepareComposite = NULL;
+ if (xf86ReturnOptValBool(pScreenPriv->options, EXAOPT_NO_COMPOSITE, FALSE)) {
+ xf86DrvMsg(pScreen->myNum, X_CONFIG,
+ "EXA: Disabling Composite operation "
+ "(RENDER acceleration)\n");
+ pExaScr->info->CheckComposite = NULL;
+ pExaScr->info->PrepareComposite = NULL;
}
if (xf86ReturnOptValBool(pScreenPriv->options, EXAOPT_NO_UTS, FALSE)) {
- xf86DrvMsg(pScreen->myNum, X_CONFIG,
- "EXA: Disabling UploadToScreen\n");
- pExaScr->info->UploadToScreen = NULL;
+ xf86DrvMsg(pScreen->myNum, X_CONFIG, "EXA: Disabling UploadToScreen\n");
+ pExaScr->info->UploadToScreen = NULL;
}
if (xf86ReturnOptValBool(pScreenPriv->options, EXAOPT_NO_DFS, FALSE)) {
- xf86DrvMsg(pScreen->myNum, X_CONFIG,
- "EXA: Disabling DownloadFromScreen\n");
- pExaScr->info->DownloadFromScreen = NULL;
+ xf86DrvMsg(pScreen->myNum, X_CONFIG,
+ "EXA: Disabling DownloadFromScreen\n");
+ pExaScr->info->DownloadFromScreen = NULL;
}
dixSetPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey, pScreenPriv);
pScreenPriv->SavedEnableDisableFBAccess = pScrn->EnableDisableFBAccess;
pScrn->EnableDisableFBAccess = exaXorgEnableDisableFBAccess;
-
+
pScreenPriv->SavedCloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = exaXorgCloseScreen;
-
+
}
-static XF86ModuleVersionInfo exaVersRec =
-{
- "exa",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- EXA_VERSION_MAJOR, EXA_VERSION_MINOR, EXA_VERSION_RELEASE,
- ABI_CLASS_VIDEODRV, /* requires the video driver ABI */
- ABI_VIDEODRV_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0}
+static XF86ModuleVersionInfo exaVersRec = {
+ "exa",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ EXA_VERSION_MAJOR, EXA_VERSION_MINOR, EXA_VERSION_RELEASE,
+ ABI_CLASS_VIDEODRV, /* requires the video driver ABI */
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_NONE,
+ {0, 0, 0, 0}
};
_X_EXPORT XF86ModuleData exaModuleData = { &exaVersRec, NULL, NULL };
diff --git a/xorg-server/hw/xfree86/fbdevhw/fbdevhw.c b/xorg-server/hw/xfree86/fbdevhw/fbdevhw.c
index 309fa654a..2881d7ec2 100644
--- a/xorg-server/hw/xfree86/fbdevhw/fbdevhw.c
+++ b/xorg-server/hw/xfree86/fbdevhw/fbdevhw.c
@@ -20,18 +20,17 @@
#define PAGE_MASK (~(getpagesize() - 1))
-static XF86ModuleVersionInfo fbdevHWVersRec =
-{
- "fbdevhw",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 0, 0, 2,
- ABI_CLASS_VIDEODRV,
- ABI_VIDEODRV_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0}
+static XF86ModuleVersionInfo fbdevHWVersRec = {
+ "fbdevhw",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 0, 0, 2,
+ ABI_CLASS_VIDEODRV,
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_NONE,
+ {0, 0, 0, 0}
};
_X_EXPORT XF86ModuleData fbdevhwModuleData = {
@@ -57,49 +56,49 @@ _X_EXPORT XF86ModuleData fbdevhwModuleData = {
static int fbdevHWPrivateIndex = -1;
typedef struct {
- /* framebuffer device: filename (/dev/fb*), handle, more */
- char* device;
- int fd;
- void* fbmem;
- unsigned int fbmem_len;
- unsigned int fboff;
- char* mmio;
- unsigned int mmio_len;
+ /* framebuffer device: filename (/dev/fb*), handle, more */
+ char *device;
+ int fd;
+ void *fbmem;
+ unsigned int fbmem_len;
+ unsigned int fboff;
+ char *mmio;
+ unsigned int mmio_len;
- /* current hardware state */
- struct fb_fix_screeninfo fix;
- struct fb_var_screeninfo var;
+ /* current hardware state */
+ struct fb_fix_screeninfo fix;
+ struct fb_var_screeninfo var;
- /* saved video mode */
- struct fb_var_screeninfo saved_var;
+ /* saved video mode */
+ struct fb_var_screeninfo saved_var;
- /* buildin video mode */
- DisplayModeRec buildin;
+ /* buildin video mode */
+ DisplayModeRec buildin;
} fbdevHWRec, *fbdevHWPtr;
Bool
fbdevHWGetRec(ScrnInfoPtr pScrn)
{
- fbdevHWPtr fPtr;
-
- if (fbdevHWPrivateIndex < 0)
- fbdevHWPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
+ fbdevHWPtr fPtr;
+
+ if (fbdevHWPrivateIndex < 0)
+ fbdevHWPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
+
+ if (FBDEVHWPTR(pScrn) != NULL)
+ return TRUE;
- if (FBDEVHWPTR(pScrn) != NULL)
- return TRUE;
-
- fPtr = FBDEVHWPTRLVAL(pScrn) = xnfcalloc(sizeof(fbdevHWRec), 1);
- return TRUE;
+ fPtr = FBDEVHWPTRLVAL(pScrn) = xnfcalloc(sizeof(fbdevHWRec), 1);
+ return TRUE;
}
void
fbdevHWFreeRec(ScrnInfoPtr pScrn)
{
- if (fbdevHWPrivateIndex < 0)
- return;
- free(FBDEVHWPTR(pScrn));
- FBDEVHWPTRLVAL(pScrn) = NULL;
+ if (fbdevHWPrivateIndex < 0)
+ return;
+ free(FBDEVHWPTR(pScrn));
+ FBDEVHWPTRLVAL(pScrn) = NULL;
}
int
@@ -120,21 +119,21 @@ fbdevHWGetFD(ScrnInfoPtr pScrn)
static void
print_fbdev_mode(char *txt, struct fb_var_screeninfo *var)
{
- ErrorF( "fbdev %s mode:\t%d %d %d %d %d %d %d %d %d %d %d:%d:%d\n",
- txt,var->pixclock,
- var->xres, var->right_margin, var->hsync_len, var->left_margin,
- var->yres, var->lower_margin, var->vsync_len, var->upper_margin,
- var->bits_per_pixel,
- var->red.length, var->green.length, var->blue.length);
+ ErrorF("fbdev %s mode:\t%d %d %d %d %d %d %d %d %d %d %d:%d:%d\n",
+ txt, var->pixclock,
+ var->xres, var->right_margin, var->hsync_len, var->left_margin,
+ var->yres, var->lower_margin, var->vsync_len, var->upper_margin,
+ var->bits_per_pixel,
+ var->red.length, var->green.length, var->blue.length);
}
static void
print_xfree_mode(char *txt, DisplayModePtr mode)
{
- ErrorF( "xfree %s mode:\t%d %d %d %d %d %d %d %d %d\n",
- txt,mode->Clock,
- mode->HDisplay, mode->HSyncStart, mode->HSyncEnd, mode->HTotal,
- mode->VDisplay, mode->VSyncStart, mode->VSyncEnd, mode->VTotal);
+ ErrorF("xfree %s mode:\t%d %d %d %d %d %d %d %d %d\n",
+ txt, mode->Clock,
+ mode->HDisplay, mode->HSyncStart, mode->HSyncEnd, mode->HTotal,
+ mode->VDisplay, mode->VSyncStart, mode->VSyncEnd, mode->VTotal);
}
#endif
@@ -144,111 +143,111 @@ print_xfree_mode(char *txt, DisplayModePtr mode)
static void
xfree2fbdev_fblayout(ScrnInfoPtr pScrn, struct fb_var_screeninfo *var)
{
- var->xres_virtual = pScrn->displayWidth ? pScrn->displayWidth :
- pScrn->virtualX;
- var->yres_virtual = pScrn->virtualY;
- var->bits_per_pixel = pScrn->bitsPerPixel;
- if (pScrn->defaultVisual == TrueColor ||
- pScrn->defaultVisual == DirectColor) {
- var->red.length = pScrn->weight.red;
- var->green.length = pScrn->weight.green;
- var->blue.length = pScrn->weight.blue;
- } else {
- var->red.length = 8;
- var->green.length = 8;
- var->blue.length = 8;
- }
+ var->xres_virtual = pScrn->displayWidth ? pScrn->displayWidth :
+ pScrn->virtualX;
+ var->yres_virtual = pScrn->virtualY;
+ var->bits_per_pixel = pScrn->bitsPerPixel;
+ if (pScrn->defaultVisual == TrueColor ||
+ pScrn->defaultVisual == DirectColor) {
+ var->red.length = pScrn->weight.red;
+ var->green.length = pScrn->weight.green;
+ var->blue.length = pScrn->weight.blue;
+ }
+ else {
+ var->red.length = 8;
+ var->green.length = 8;
+ var->blue.length = 8;
+ }
}
static void
xfree2fbdev_timing(DisplayModePtr mode, struct fb_var_screeninfo *var)
{
- var->xres = mode->HDisplay;
- var->yres = mode->VDisplay;
- if (var->xres_virtual < var->xres)
- var->xres_virtual = var->xres;
- if (var->yres_virtual < var->yres)
- var->yres_virtual = var->yres;
- var->xoffset = var->yoffset = 0;
- var->pixclock = mode->Clock ? 1000000000/mode->Clock : 0;
- var->right_margin = mode->HSyncStart-mode->HDisplay;
- var->hsync_len = mode->HSyncEnd-mode->HSyncStart;
- var->left_margin = mode->HTotal-mode->HSyncEnd;
- var->lower_margin = mode->VSyncStart-mode->VDisplay;
- var->vsync_len = mode->VSyncEnd-mode->VSyncStart;
- var->upper_margin = mode->VTotal-mode->VSyncEnd;
- var->sync = 0;
- if (mode->Flags & V_PHSYNC)
- var->sync |= FB_SYNC_HOR_HIGH_ACT;
- if (mode->Flags & V_PVSYNC)
- var->sync |= FB_SYNC_VERT_HIGH_ACT;
- if (mode->Flags & V_PCSYNC)
- var->sync |= FB_SYNC_COMP_HIGH_ACT;
- if (mode->Flags & V_BCAST)
- var->sync |= FB_SYNC_BROADCAST;
- if (mode->Flags & V_INTERLACE)
- var->vmode = FB_VMODE_INTERLACED;
- else if (mode->Flags & V_DBLSCAN)
- var->vmode = FB_VMODE_DOUBLE;
- else
- var->vmode = FB_VMODE_NONINTERLACED;
+ var->xres = mode->HDisplay;
+ var->yres = mode->VDisplay;
+ if (var->xres_virtual < var->xres)
+ var->xres_virtual = var->xres;
+ if (var->yres_virtual < var->yres)
+ var->yres_virtual = var->yres;
+ var->xoffset = var->yoffset = 0;
+ var->pixclock = mode->Clock ? 1000000000 / mode->Clock : 0;
+ var->right_margin = mode->HSyncStart - mode->HDisplay;
+ var->hsync_len = mode->HSyncEnd - mode->HSyncStart;
+ var->left_margin = mode->HTotal - mode->HSyncEnd;
+ var->lower_margin = mode->VSyncStart - mode->VDisplay;
+ var->vsync_len = mode->VSyncEnd - mode->VSyncStart;
+ var->upper_margin = mode->VTotal - mode->VSyncEnd;
+ var->sync = 0;
+ if (mode->Flags & V_PHSYNC)
+ var->sync |= FB_SYNC_HOR_HIGH_ACT;
+ if (mode->Flags & V_PVSYNC)
+ var->sync |= FB_SYNC_VERT_HIGH_ACT;
+ if (mode->Flags & V_PCSYNC)
+ var->sync |= FB_SYNC_COMP_HIGH_ACT;
+ if (mode->Flags & V_BCAST)
+ var->sync |= FB_SYNC_BROADCAST;
+ if (mode->Flags & V_INTERLACE)
+ var->vmode = FB_VMODE_INTERLACED;
+ else if (mode->Flags & V_DBLSCAN)
+ var->vmode = FB_VMODE_DOUBLE;
+ else
+ var->vmode = FB_VMODE_NONINTERLACED;
}
static Bool
fbdev_modes_equal(struct fb_var_screeninfo *set, struct fb_var_screeninfo *req)
{
- return (set->xres_virtual >= req->xres_virtual &&
- set->yres_virtual >= req->yres_virtual &&
- set->bits_per_pixel == req->bits_per_pixel &&
- set->red.length == req->red.length &&
- set->green.length == req->green.length &&
- set->blue.length == req->blue.length &&
- set->xres == req->xres && set->yres == req->yres &&
- set->right_margin == req->right_margin &&
- set->hsync_len == req->hsync_len &&
- set->left_margin == req->left_margin &&
- set->lower_margin == req->lower_margin &&
- set->vsync_len == req->vsync_len &&
- set->upper_margin == req->upper_margin &&
- set->sync == req->sync && set->vmode == req->vmode);
+ return (set->xres_virtual >= req->xres_virtual &&
+ set->yres_virtual >= req->yres_virtual &&
+ set->bits_per_pixel == req->bits_per_pixel &&
+ set->red.length == req->red.length &&
+ set->green.length == req->green.length &&
+ set->blue.length == req->blue.length &&
+ set->xres == req->xres && set->yres == req->yres &&
+ set->right_margin == req->right_margin &&
+ set->hsync_len == req->hsync_len &&
+ set->left_margin == req->left_margin &&
+ set->lower_margin == req->lower_margin &&
+ set->vsync_len == req->vsync_len &&
+ set->upper_margin == req->upper_margin &&
+ set->sync == req->sync && set->vmode == req->vmode);
}
static void
fbdev2xfree_timing(struct fb_var_screeninfo *var, DisplayModePtr mode)
{
- mode->Clock = var->pixclock ? 1000000000/var->pixclock : 0;
- mode->HDisplay = var->xres;
- mode->HSyncStart = mode->HDisplay+var->right_margin;
- mode->HSyncEnd = mode->HSyncStart+var->hsync_len;
- mode->HTotal = mode->HSyncEnd+var->left_margin;
- mode->VDisplay = var->yres;
- mode->VSyncStart = mode->VDisplay+var->lower_margin;
- mode->VSyncEnd = mode->VSyncStart+var->vsync_len;
- mode->VTotal = mode->VSyncEnd+var->upper_margin;
- mode->Flags = 0;
- mode->Flags |= var->sync & FB_SYNC_HOR_HIGH_ACT ? V_PHSYNC : V_NHSYNC;
- mode->Flags |= var->sync & FB_SYNC_VERT_HIGH_ACT ? V_PVSYNC : V_NVSYNC;
- mode->Flags |= var->sync & FB_SYNC_COMP_HIGH_ACT ? V_PCSYNC : V_NCSYNC;
- if (var->sync & FB_SYNC_BROADCAST)
- mode->Flags |= V_BCAST;
- if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED)
- mode->Flags |= V_INTERLACE;
- else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE)
- mode->Flags |= V_DBLSCAN;
- mode->SynthClock = mode->Clock;
- mode->CrtcHDisplay = mode->HDisplay;
- mode->CrtcHSyncStart = mode->HSyncStart;
- mode->CrtcHSyncEnd = mode->HSyncEnd;
- mode->CrtcHTotal = mode->HTotal;
- mode->CrtcVDisplay = mode->VDisplay;
- mode->CrtcVSyncStart = mode->VSyncStart;
- mode->CrtcVSyncEnd = mode->VSyncEnd;
- mode->CrtcVTotal = mode->VTotal;
- mode->CrtcHAdjusted = FALSE;
- mode->CrtcVAdjusted = FALSE;
+ mode->Clock = var->pixclock ? 1000000000 / var->pixclock : 0;
+ mode->HDisplay = var->xres;
+ mode->HSyncStart = mode->HDisplay + var->right_margin;
+ mode->HSyncEnd = mode->HSyncStart + var->hsync_len;
+ mode->HTotal = mode->HSyncEnd + var->left_margin;
+ mode->VDisplay = var->yres;
+ mode->VSyncStart = mode->VDisplay + var->lower_margin;
+ mode->VSyncEnd = mode->VSyncStart + var->vsync_len;
+ mode->VTotal = mode->VSyncEnd + var->upper_margin;
+ mode->Flags = 0;
+ mode->Flags |= var->sync & FB_SYNC_HOR_HIGH_ACT ? V_PHSYNC : V_NHSYNC;
+ mode->Flags |= var->sync & FB_SYNC_VERT_HIGH_ACT ? V_PVSYNC : V_NVSYNC;
+ mode->Flags |= var->sync & FB_SYNC_COMP_HIGH_ACT ? V_PCSYNC : V_NCSYNC;
+ if (var->sync & FB_SYNC_BROADCAST)
+ mode->Flags |= V_BCAST;
+ if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED)
+ mode->Flags |= V_INTERLACE;
+ else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE)
+ mode->Flags |= V_DBLSCAN;
+ mode->SynthClock = mode->Clock;
+ mode->CrtcHDisplay = mode->HDisplay;
+ mode->CrtcHSyncStart = mode->HSyncStart;
+ mode->CrtcHSyncEnd = mode->HSyncEnd;
+ mode->CrtcHTotal = mode->HTotal;
+ mode->CrtcVDisplay = mode->VDisplay;
+ mode->CrtcVSyncStart = mode->VSyncStart;
+ mode->CrtcVSyncEnd = mode->VSyncEnd;
+ mode->CrtcVTotal = mode->VTotal;
+ mode->CrtcHAdjusted = FALSE;
+ mode->CrtcVAdjusted = FALSE;
}
-
/* -------------------------------------------------------------------- */
/* open correct framebuffer device */
@@ -256,314 +255,316 @@ fbdev2xfree_timing(struct fb_var_screeninfo *var, DisplayModePtr mode)
* Try to find the framebuffer device for a given PCI device
*/
static int
-fbdev_open_pci(struct pci_device * pPci, char **namep)
+fbdev_open_pci(struct pci_device *pPci, char **namep)
{
- struct fb_fix_screeninfo fix;
- char filename[256];
- int fd, i;
+ struct fb_fix_screeninfo fix;
+ char filename[256];
+ int fd, i;
for (i = 0; i < 8; i++) {
- snprintf(filename, sizeof(filename),
- "/sys/bus/pci/devices/%04x:%02x:%02x.%d/graphics/fb%d",
- pPci->domain, pPci->bus, pPci->dev, pPci->func, i);
+ snprintf(filename, sizeof(filename),
+ "/sys/bus/pci/devices/%04x:%02x:%02x.%d/graphics/fb%d",
+ pPci->domain, pPci->bus, pPci->dev, pPci->func, i);
- fd = open(filename, O_RDONLY, 0);
+ fd = open(filename, O_RDONLY, 0);
if (fd < 0) {
snprintf(filename, sizeof(filename),
- "/sys/bus/pci/devices/%04x:%02x:%02x.%d/graphics:fb%d",
- pPci->domain, pPci->bus, pPci->dev, pPci->func, i);
+ "/sys/bus/pci/devices/%04x:%02x:%02x.%d/graphics:fb%d",
+ pPci->domain, pPci->bus, pPci->dev, pPci->func, i);
fd = open(filename, O_RDONLY, 0);
}
- if (fd >= 0) {
- close(fd);
- snprintf(filename, sizeof(filename), "/dev/fb%d", i);
-
- fd = open(filename, O_RDWR, 0);
- if (fd != -1) {
- if (ioctl(fd, FBIOGET_FSCREENINFO, (void*) & fix) != -1) {
- if (namep) {
- *namep = xnfalloc(16);
- strncpy(*namep,fix.id,16);
- }
-
- return fd;
- }
- close(fd);
- }
- }
+ if (fd >= 0) {
+ close(fd);
+ snprintf(filename, sizeof(filename), "/dev/fb%d", i);
+
+ fd = open(filename, O_RDWR, 0);
+ if (fd != -1) {
+ if (ioctl(fd, FBIOGET_FSCREENINFO, (void *) &fix) != -1) {
+ if (namep) {
+ *namep = xnfalloc(16);
+ strncpy(*namep, fix.id, 16);
+ }
+
+ return fd;
+ }
+ close(fd);
+ }
+ }
}
if (namep)
- *namep = NULL;
+ *namep = NULL;
xf86DrvMsg(-1, X_ERROR, "Unable to find a valid framebuffer device\n");
return -1;
}
static int
-fbdev_open(int scrnIndex, char *dev, char** namep)
-{
- struct fb_fix_screeninfo fix;
- int fd;
-
- /* try argument (from XF86Config) first */
- if (dev) {
- fd = open(dev,O_RDWR,0);
- } else {
- /* second: environment variable */
- dev = getenv("FRAMEBUFFER");
- if ((NULL == dev) || ((fd = open(dev,O_RDWR,0)) == -1)) {
- /* last try: default device */
- dev = "/dev/fb0";
- fd = open(dev,O_RDWR,0);
- }
- }
-
- if (fd == -1) {
- xf86DrvMsg(scrnIndex, X_ERROR,
- "open %s: %s\n", dev, strerror(errno));
- return -1;
- }
-
- if (namep) {
- if (-1 == ioctl(fd,FBIOGET_FSCREENINFO,(void*)(&fix))) {
- *namep = NULL;
- xf86DrvMsg(scrnIndex, X_ERROR,
- "FBIOGET_FSCREENINFO: %s\n", strerror(errno));
- return -1;
- } else {
- *namep = xnfalloc(16);
- strncpy(*namep,fix.id,16);
- }
- }
- return fd;
+fbdev_open(int scrnIndex, char *dev, char **namep)
+{
+ struct fb_fix_screeninfo fix;
+ int fd;
+
+ /* try argument (from XF86Config) first */
+ if (dev) {
+ fd = open(dev, O_RDWR, 0);
+ }
+ else {
+ /* second: environment variable */
+ dev = getenv("FRAMEBUFFER");
+ if ((NULL == dev) || ((fd = open(dev, O_RDWR, 0)) == -1)) {
+ /* last try: default device */
+ dev = "/dev/fb0";
+ fd = open(dev, O_RDWR, 0);
+ }
+ }
+
+ if (fd == -1) {
+ xf86DrvMsg(scrnIndex, X_ERROR, "open %s: %s\n", dev, strerror(errno));
+ return -1;
+ }
+
+ if (namep) {
+ if (-1 == ioctl(fd, FBIOGET_FSCREENINFO, (void *) (&fix))) {
+ *namep = NULL;
+ xf86DrvMsg(scrnIndex, X_ERROR,
+ "FBIOGET_FSCREENINFO: %s\n", strerror(errno));
+ return -1;
+ }
+ else {
+ *namep = xnfalloc(16);
+ strncpy(*namep, fix.id, 16);
+ }
+ }
+ return fd;
}
/* -------------------------------------------------------------------- */
Bool
-fbdevHWProbe(struct pci_device * pPci, char *device,char **namep)
+fbdevHWProbe(struct pci_device *pPci, char *device, char **namep)
{
- int fd;
+ int fd;
- if (pPci)
- fd = fbdev_open_pci(pPci,namep);
- else
- fd = fbdev_open(-1,device,namep);
+ if (pPci)
+ fd = fbdev_open_pci(pPci, namep);
+ else
+ fd = fbdev_open(-1, device, namep);
- if (-1 == fd)
- return FALSE;
- close(fd);
- return TRUE;
+ if (-1 == fd)
+ return FALSE;
+ close(fd);
+ return TRUE;
}
Bool
-fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device * pPci, char *device)
-{
- fbdevHWPtr fPtr;
-
- fbdevHWGetRec(pScrn);
- fPtr = FBDEVHWPTR(pScrn);
-
- /* open device */
- if (pPci)
- fPtr->fd = fbdev_open_pci(pPci,NULL);
- else
- fPtr->fd = fbdev_open(pScrn->scrnIndex,device,NULL);
- if (-1 == fPtr->fd) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Failed to open framebuffer device, consult warnings"
- " and/or errors above for possible reasons\n"
- "\t(you may have to look at the server log to see"
- " warnings)\n");
- return FALSE;
- }
-
- /* get current fb device settings */
- if (-1 == ioctl(fPtr->fd,FBIOGET_FSCREENINFO,(void*)(&fPtr->fix))) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "ioctl FBIOGET_FSCREENINFO: %s\n",
- strerror(errno));
- return FALSE;
- }
- if (-1 == ioctl(fPtr->fd,FBIOGET_VSCREENINFO,(void*)(&fPtr->var))) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "ioctl FBIOGET_VSCREENINFO: %s\n",
- strerror(errno));
- return FALSE;
- }
-
- /* we can use the current settings as "buildin mode" */
- fbdev2xfree_timing(&fPtr->var, &fPtr->buildin);
- fPtr->buildin.name = "current";
- fPtr->buildin.next = &fPtr->buildin;
- fPtr->buildin.prev = &fPtr->buildin;
- fPtr->buildin.type |= M_T_BUILTIN;
-
- return TRUE;
-}
-
-char*
+fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device *pPci, char *device)
+{
+ fbdevHWPtr fPtr;
+
+ fbdevHWGetRec(pScrn);
+ fPtr = FBDEVHWPTR(pScrn);
+
+ /* open device */
+ if (pPci)
+ fPtr->fd = fbdev_open_pci(pPci, NULL);
+ else
+ fPtr->fd = fbdev_open(pScrn->scrnIndex, device, NULL);
+ if (-1 == fPtr->fd) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Failed to open framebuffer device, consult warnings"
+ " and/or errors above for possible reasons\n"
+ "\t(you may have to look at the server log to see"
+ " warnings)\n");
+ return FALSE;
+ }
+
+ /* get current fb device settings */
+ if (-1 == ioctl(fPtr->fd, FBIOGET_FSCREENINFO, (void *) (&fPtr->fix))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "ioctl FBIOGET_FSCREENINFO: %s\n", strerror(errno));
+ return FALSE;
+ }
+ if (-1 == ioctl(fPtr->fd, FBIOGET_VSCREENINFO, (void *) (&fPtr->var))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "ioctl FBIOGET_VSCREENINFO: %s\n", strerror(errno));
+ return FALSE;
+ }
+
+ /* we can use the current settings as "buildin mode" */
+ fbdev2xfree_timing(&fPtr->var, &fPtr->buildin);
+ fPtr->buildin.name = "current";
+ fPtr->buildin.next = &fPtr->buildin;
+ fPtr->buildin.prev = &fPtr->buildin;
+ fPtr->buildin.type |= M_T_BUILTIN;
+
+ return TRUE;
+}
+
+char *
fbdevHWGetName(ScrnInfoPtr pScrn)
{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- return fPtr->fix.id;
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+
+ return fPtr->fix.id;
}
int
fbdevHWGetDepth(ScrnInfoPtr pScrn, int *fbbpp)
{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- if (fbbpp)
- *fbbpp = fPtr->var.bits_per_pixel;
+ if (fbbpp)
+ *fbbpp = fPtr->var.bits_per_pixel;
- if (fPtr->fix.visual == FB_VISUAL_TRUECOLOR ||
- fPtr->fix.visual == FB_VISUAL_DIRECTCOLOR)
- return fPtr->var.red.length+fPtr->var.green.length+
- fPtr->var.blue.length;
- else
- return fPtr->var.bits_per_pixel;
+ if (fPtr->fix.visual == FB_VISUAL_TRUECOLOR ||
+ fPtr->fix.visual == FB_VISUAL_DIRECTCOLOR)
+ return fPtr->var.red.length + fPtr->var.green.length +
+ fPtr->var.blue.length;
+ else
+ return fPtr->var.bits_per_pixel;
}
int
fbdevHWGetLineLength(ScrnInfoPtr pScrn)
{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- if (fPtr->fix.line_length)
- return fPtr->fix.line_length;
- else
- return fPtr->var.xres_virtual*fPtr->var.bits_per_pixel/8;
+ if (fPtr->fix.line_length)
+ return fPtr->fix.line_length;
+ else
+ return fPtr->var.xres_virtual * fPtr->var.bits_per_pixel / 8;
}
int
fbdevHWGetType(ScrnInfoPtr pScrn)
{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- return fPtr->fix.type;
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+
+ return fPtr->fix.type;
}
int
fbdevHWGetVidmem(ScrnInfoPtr pScrn)
{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- return fPtr->fix.smem_len;
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+
+ return fPtr->fix.smem_len;
}
static Bool
fbdevHWSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode, Bool check)
{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- struct fb_var_screeninfo req_var = fPtr->var, set_var;
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ struct fb_var_screeninfo req_var = fPtr->var, set_var;
- xfree2fbdev_fblayout(pScrn, &req_var);
- xfree2fbdev_timing(mode, &req_var);
+ xfree2fbdev_fblayout(pScrn, &req_var);
+ xfree2fbdev_timing(mode, &req_var);
#if DEBUG
- print_xfree_mode("init", mode);
- print_fbdev_mode("init", &req_var);
+ print_xfree_mode("init", mode);
+ print_fbdev_mode("init", &req_var);
#endif
- set_var = req_var;
+ set_var = req_var;
- if (check)
- set_var.activate = FB_ACTIVATE_TEST;
+ if (check)
+ set_var.activate = FB_ACTIVATE_TEST;
- if (0 != ioctl(fPtr->fd, FBIOPUT_VSCREENINFO, (void*)(&set_var))) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "FBIOPUT_VSCREENINFO: %s\n", strerror(errno));
- return FALSE;
- }
+ if (0 != ioctl(fPtr->fd, FBIOPUT_VSCREENINFO, (void *) (&set_var))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "FBIOPUT_VSCREENINFO: %s\n", strerror(errno));
+ return FALSE;
+ }
- if (!fbdev_modes_equal(&set_var, &req_var)) {
- if (!check)
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "FBIOPUT_VSCREENINFO succeeded but modified "
- "mode\n");
+ if (!fbdev_modes_equal(&set_var, &req_var)) {
+ if (!check)
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "FBIOPUT_VSCREENINFO succeeded but modified " "mode\n");
#if DEBUG
- print_fbdev_mode("returned", &set_var);
+ print_fbdev_mode("returned", &set_var);
#endif
- return FALSE;
- }
+ return FALSE;
+ }
- if (!check)
- fPtr->var = set_var;
+ if (!check)
+ fPtr->var = set_var;
- return TRUE;
+ return TRUE;
}
void
fbdevHWSetVideoModes(ScrnInfoPtr pScrn)
{
- char **modename;
- DisplayModePtr mode,this,last = pScrn->modes;
-
- if (NULL == pScrn->display->modes)
- return;
-
- pScrn->virtualX = pScrn->display->virtualX;
- pScrn->virtualY = pScrn->display->virtualY;
-
- for (modename = pScrn->display->modes; *modename != NULL; modename++) {
- for (mode = pScrn->monitor->Modes; mode != NULL; mode = mode->next) {
- if (0 == strcmp(mode->name,*modename)) {
- if (fbdevHWSetMode(pScrn, mode, TRUE))
- break;
-
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "\tmode \"%s\" test failed\n", *modename);
- }
- }
-
- if (NULL == mode) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "\tmode \"%s\" not found\n", *modename);
- continue;
- }
-
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "\tmode \"%s\" ok\n", *modename);
-
- if (pScrn->virtualX < mode->HDisplay)
- pScrn->virtualX = mode->HDisplay;
- if (pScrn->virtualY < mode->VDisplay)
- pScrn->virtualY = mode->VDisplay;
-
- if (NULL == pScrn->modes) {
- this = pScrn->modes = xf86DuplicateMode(mode);
- this->next = this;
- this->prev = this;
- } else {
- this = xf86DuplicateMode(mode);
- this->next = pScrn->modes;
- this->prev = last;
- last->next = this;
- pScrn->modes->prev = this;
- }
- last = this;
- }
+ char **modename;
+ DisplayModePtr mode, this, last = pScrn->modes;
+
+ if (NULL == pScrn->display->modes)
+ return;
+
+ pScrn->virtualX = pScrn->display->virtualX;
+ pScrn->virtualY = pScrn->display->virtualY;
+
+ for (modename = pScrn->display->modes; *modename != NULL; modename++) {
+ for (mode = pScrn->monitor->Modes; mode != NULL; mode = mode->next) {
+ if (0 == strcmp(mode->name, *modename)) {
+ if (fbdevHWSetMode(pScrn, mode, TRUE))
+ break;
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "\tmode \"%s\" test failed\n", *modename);
+ }
+ }
+
+ if (NULL == mode) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "\tmode \"%s\" not found\n", *modename);
+ continue;
+ }
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "\tmode \"%s\" ok\n", *modename);
+
+ if (pScrn->virtualX < mode->HDisplay)
+ pScrn->virtualX = mode->HDisplay;
+ if (pScrn->virtualY < mode->VDisplay)
+ pScrn->virtualY = mode->VDisplay;
+
+ if (NULL == pScrn->modes) {
+ this = pScrn->modes = xf86DuplicateMode(mode);
+ this->next = this;
+ this->prev = this;
+ }
+ else {
+ this = xf86DuplicateMode(mode);
+ this->next = pScrn->modes;
+ this->prev = last;
+ last->next = this;
+ pScrn->modes->prev = this;
+ }
+ last = this;
+ }
}
DisplayModePtr
fbdevHWGetBuildinMode(ScrnInfoPtr pScrn)
{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- return &fPtr->buildin;
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+
+ return &fPtr->buildin;
}
void
fbdevHWUseBuildinMode(ScrnInfoPtr pScrn)
{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- pScrn->modes = &fPtr->buildin;
- pScrn->virtualX = pScrn->display->virtualX;
- pScrn->virtualY = pScrn->display->virtualY;
- if (pScrn->virtualX < fPtr->buildin.HDisplay)
- pScrn->virtualX = fPtr->buildin.HDisplay;
- if (pScrn->virtualY < fPtr->buildin.VDisplay)
- pScrn->virtualY = fPtr->buildin.VDisplay;
+ pScrn->modes = &fPtr->buildin;
+ pScrn->virtualX = pScrn->display->virtualX;
+ pScrn->virtualY = pScrn->display->virtualY;
+ if (pScrn->virtualX < fPtr->buildin.HDisplay)
+ pScrn->virtualX = fPtr->buildin.HDisplay;
+ if (pScrn->virtualY < fPtr->buildin.VDisplay)
+ pScrn->virtualY = fPtr->buildin.VDisplay;
}
/* -------------------------------------------------------------------- */
@@ -571,145 +572,153 @@ fbdevHWUseBuildinMode(ScrnInfoPtr pScrn)
static void
calculateFbmem_len(fbdevHWPtr fPtr)
{
- fPtr->fboff = (unsigned long) fPtr->fix.smem_start & ~PAGE_MASK;
- fPtr->fbmem_len = (fPtr->fboff+fPtr->fix.smem_len+~PAGE_MASK) &
- PAGE_MASK;
+ fPtr->fboff = (unsigned long) fPtr->fix.smem_start & ~PAGE_MASK;
+ fPtr->fbmem_len = (fPtr->fboff + fPtr->fix.smem_len + ~PAGE_MASK) &
+ PAGE_MASK;
}
-
-void*
+void *
fbdevHWMapVidmem(ScrnInfoPtr pScrn)
{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
-
- if (NULL == fPtr->fbmem) {
- calculateFbmem_len(fPtr);
- fPtr->fbmem = mmap(NULL, fPtr->fbmem_len, PROT_READ | PROT_WRITE,
- MAP_SHARED, fPtr->fd, 0);
- if (-1 == (long)fPtr->fbmem) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "mmap fbmem: %s\n", strerror(errno));
- fPtr->fbmem = NULL;
- } else {
- /* Perhaps we'd better add fboff to fbmem and return 0 in
- fbdevHWLinearOffset()? Of course we then need to mask
- fPtr->fbmem with PAGE_MASK in fbdevHWUnmapVidmem() as
- well. [geert] */
- }
- }
- pScrn->memPhysBase = (unsigned long)fPtr->fix.smem_start & (unsigned long)(PAGE_MASK);
- pScrn->fbOffset = (unsigned long)fPtr->fix.smem_start & (unsigned long)(~PAGE_MASK);
- return fPtr->fbmem;
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+
+ if (NULL == fPtr->fbmem) {
+ calculateFbmem_len(fPtr);
+ fPtr->fbmem = mmap(NULL, fPtr->fbmem_len, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fPtr->fd, 0);
+ if (-1 == (long) fPtr->fbmem) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "mmap fbmem: %s\n", strerror(errno));
+ fPtr->fbmem = NULL;
+ }
+ else {
+ /* Perhaps we'd better add fboff to fbmem and return 0 in
+ fbdevHWLinearOffset()? Of course we then need to mask
+ fPtr->fbmem with PAGE_MASK in fbdevHWUnmapVidmem() as
+ well. [geert] */
+ }
+ }
+ pScrn->memPhysBase =
+ (unsigned long) fPtr->fix.smem_start & (unsigned long) (PAGE_MASK);
+ pScrn->fbOffset =
+ (unsigned long) fPtr->fix.smem_start & (unsigned long) (~PAGE_MASK);
+ return fPtr->fbmem;
}
int
fbdevHWLinearOffset(ScrnInfoPtr pScrn)
{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- return fPtr->fboff;
+ return fPtr->fboff;
}
Bool
fbdevHWUnmapVidmem(ScrnInfoPtr pScrn)
{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- if (NULL != fPtr->fbmem) {
- if (-1 == munmap(fPtr->fbmem, fPtr->fbmem_len))
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "munmap fbmem: %s\n", strerror(errno));
- fPtr->fbmem = NULL;
- }
- return TRUE;
+ if (NULL != fPtr->fbmem) {
+ if (-1 == munmap(fPtr->fbmem, fPtr->fbmem_len))
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "munmap fbmem: %s\n", strerror(errno));
+ fPtr->fbmem = NULL;
+ }
+ return TRUE;
}
-void*
+void *
fbdevHWMapMMIO(ScrnInfoPtr pScrn)
{
- unsigned int mmio_off;
-
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
-
- if (NULL == fPtr->mmio) {
- /* tell the kernel not to use accels to speed up console scrolling */
- fPtr->var.accel_flags = 0;
- if (0 != ioctl(fPtr->fd,FBIOPUT_VSCREENINFO,(void*)(&fPtr->var))) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "FBIOPUT_VSCREENINFO: %s\n", strerror(errno));
- return FALSE;
- }
- mmio_off = (unsigned long) fPtr->fix.mmio_start & ~PAGE_MASK;
- fPtr->mmio_len = (mmio_off+fPtr->fix.mmio_len+~PAGE_MASK) &
- PAGE_MASK;
- if (NULL == fPtr->fbmem)
- calculateFbmem_len(fPtr);
- fPtr->mmio = mmap(NULL, fPtr->mmio_len, PROT_READ | PROT_WRITE,
- MAP_SHARED, fPtr->fd, fPtr->fbmem_len);
- if (-1 == (long)fPtr->mmio) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "mmap mmio: %s\n", strerror(errno));
- fPtr->mmio = NULL;
- } else
- fPtr->mmio += mmio_off;
- }
- return fPtr->mmio;
+ unsigned int mmio_off;
+
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+
+ if (NULL == fPtr->mmio) {
+ /* tell the kernel not to use accels to speed up console scrolling */
+ fPtr->var.accel_flags = 0;
+ if (0 != ioctl(fPtr->fd, FBIOPUT_VSCREENINFO, (void *) (&fPtr->var))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "FBIOPUT_VSCREENINFO: %s\n", strerror(errno));
+ return FALSE;
+ }
+ mmio_off = (unsigned long) fPtr->fix.mmio_start & ~PAGE_MASK;
+ fPtr->mmio_len = (mmio_off + fPtr->fix.mmio_len + ~PAGE_MASK) &
+ PAGE_MASK;
+ if (NULL == fPtr->fbmem)
+ calculateFbmem_len(fPtr);
+ fPtr->mmio = mmap(NULL, fPtr->mmio_len, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fPtr->fd, fPtr->fbmem_len);
+ if (-1 == (long) fPtr->mmio) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "mmap mmio: %s\n", strerror(errno));
+ fPtr->mmio = NULL;
+ }
+ else
+ fPtr->mmio += mmio_off;
+ }
+ return fPtr->mmio;
}
Bool
fbdevHWUnmapMMIO(ScrnInfoPtr pScrn)
{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- if (NULL != fPtr->mmio) {
- if (-1 == munmap((void *)((unsigned long)fPtr->mmio & PAGE_MASK), fPtr->mmio_len))
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "munmap mmio: %s\n", strerror(errno));
- fPtr->mmio = NULL;
- /* FIXME: restore var.accel_flags [geert] */
- }
- return TRUE;
+ if (NULL != fPtr->mmio) {
+ if (-1 ==
+ munmap((void *) ((unsigned long) fPtr->mmio & PAGE_MASK),
+ fPtr->mmio_len))
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "munmap mmio: %s\n",
+ strerror(errno));
+ fPtr->mmio = NULL;
+ /* FIXME: restore var.accel_flags [geert] */
+ }
+ return TRUE;
}
/* -------------------------------------------------------------------- */
Bool
fbdevHWModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
-{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
-
- pScrn->vtSema = TRUE;
-
- /* set */
- if (!fbdevHWSetMode(pScrn, mode, FALSE))
- return FALSE;
-
- /* read back */
- if (0 != ioctl(fPtr->fd,FBIOGET_FSCREENINFO,(void*)(&fPtr->fix))) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "FBIOGET_FSCREENINFO: %s\n", strerror(errno));
- return FALSE;
- }
- if (0 != ioctl(fPtr->fd,FBIOGET_VSCREENINFO,(void*)(&fPtr->var))) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "FBIOGET_VSCREENINFO: %s\n", strerror(errno));
- return FALSE;
- }
-
- if (pScrn->defaultVisual == TrueColor ||
- pScrn->defaultVisual == DirectColor) {
- /* XXX: This is a hack, but it should be a NOP for all the setups that
- * worked before and actually seems to fix some others...
- */
- pScrn->offset.red = fPtr->var.red.offset;
- pScrn->offset.green = fPtr->var.green.offset;
- pScrn->offset.blue = fPtr->var.blue.offset;
- pScrn->mask.red = ((1 << fPtr->var.red.length) - 1) << fPtr->var.red.offset;
- pScrn->mask.green = ((1 << fPtr->var.green.length) - 1) << fPtr->var.green.offset;
- pScrn->mask.blue = ((1 << fPtr->var.blue.length) - 1) << fPtr->var.blue.offset;
- }
-
- return TRUE;
+{
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+
+ pScrn->vtSema = TRUE;
+
+ /* set */
+ if (!fbdevHWSetMode(pScrn, mode, FALSE))
+ return FALSE;
+
+ /* read back */
+ if (0 != ioctl(fPtr->fd, FBIOGET_FSCREENINFO, (void *) (&fPtr->fix))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "FBIOGET_FSCREENINFO: %s\n", strerror(errno));
+ return FALSE;
+ }
+ if (0 != ioctl(fPtr->fd, FBIOGET_VSCREENINFO, (void *) (&fPtr->var))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "FBIOGET_VSCREENINFO: %s\n", strerror(errno));
+ return FALSE;
+ }
+
+ if (pScrn->defaultVisual == TrueColor ||
+ pScrn->defaultVisual == DirectColor) {
+ /* XXX: This is a hack, but it should be a NOP for all the setups that
+ * worked before and actually seems to fix some others...
+ */
+ pScrn->offset.red = fPtr->var.red.offset;
+ pScrn->offset.green = fPtr->var.green.offset;
+ pScrn->offset.blue = fPtr->var.blue.offset;
+ pScrn->mask.red =
+ ((1 << fPtr->var.red.length) - 1) << fPtr->var.red.offset;
+ pScrn->mask.green =
+ ((1 << fPtr->var.green.length) - 1) << fPtr->var.green.offset;
+ pScrn->mask.blue =
+ ((1 << fPtr->var.blue.length) - 1) << fPtr->var.blue.offset;
+ }
+
+ return TRUE;
}
/* -------------------------------------------------------------------- */
@@ -717,21 +726,21 @@ fbdevHWModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
void
fbdevHWSave(ScrnInfoPtr pScrn)
{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- if (0 != ioctl(fPtr->fd,FBIOGET_VSCREENINFO,(void*)(&fPtr->saved_var)))
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "FBIOGET_VSCREENINFO: %s\n", strerror(errno));
+ if (0 != ioctl(fPtr->fd, FBIOGET_VSCREENINFO, (void *) (&fPtr->saved_var)))
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "FBIOGET_VSCREENINFO: %s\n", strerror(errno));
}
void
fbdevHWRestore(ScrnInfoPtr pScrn)
{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- if (0 != ioctl(fPtr->fd,FBIOPUT_VSCREENINFO,(void*)(&fPtr->saved_var)))
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "FBIOPUT_VSCREENINFO: %s\n", strerror(errno));
+ if (0 != ioctl(fPtr->fd, FBIOPUT_VSCREENINFO, (void *) (&fPtr->saved_var)))
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "FBIOPUT_VSCREENINFO: %s\n", strerror(errno));
}
/* -------------------------------------------------------------------- */
@@ -739,30 +748,27 @@ fbdevHWRestore(ScrnInfoPtr pScrn)
void
fbdevHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
- LOCO *colors, VisualPtr pVisual)
-{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- struct fb_cmap cmap;
- unsigned short red,green,blue;
- int i;
-
- cmap.len = 1;
- cmap.red = &red;
- cmap.green = &green;
- cmap.blue = &blue;
- cmap.transp = NULL;
- for (i = 0; i < numColors; i++) {
- cmap.start = indices[i];
- red = (colors[indices[i]].red << 8) |
- colors[indices[i]].red;
- green = (colors[indices[i]].green << 8) |
- colors[indices[i]].green;
- blue = (colors[indices[i]].blue << 8) |
- colors[indices[i]].blue;
- if (-1 == ioctl(fPtr->fd,FBIOPUTCMAP,(void*)&cmap))
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "FBIOPUTCMAP: %s\n", strerror(errno));
- }
+ LOCO * colors, VisualPtr pVisual)
+{
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ struct fb_cmap cmap;
+ unsigned short red, green, blue;
+ int i;
+
+ cmap.len = 1;
+ cmap.red = &red;
+ cmap.green = &green;
+ cmap.blue = &blue;
+ cmap.transp = NULL;
+ for (i = 0; i < numColors; i++) {
+ cmap.start = indices[i];
+ red = (colors[indices[i]].red << 8) | colors[indices[i]].red;
+ green = (colors[indices[i]].green << 8) | colors[indices[i]].green;
+ blue = (colors[indices[i]].blue << 8) | colors[indices[i]].blue;
+ if (-1 == ioctl(fPtr->fd, FBIOPUTCMAP, (void *) &cmap))
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "FBIOPUTCMAP: %s\n", strerror(errno));
+ }
}
/* -------------------------------------------------------------------- */
@@ -771,134 +777,157 @@ fbdevHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
ModeStatus
fbdevHWValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- if (!fbdevHWSetMode(pScrn, mode, TRUE))
- return MODE_BAD;
+ if (!fbdevHWSetMode(pScrn, mode, TRUE))
+ return MODE_BAD;
- return MODE_OK;
+ return MODE_OK;
}
Bool
fbdevHWSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- if (!fbdevHWSetMode(pScrn, mode, FALSE))
- return FALSE;
+ if (!fbdevHWSetMode(pScrn, mode, FALSE))
+ return FALSE;
- return TRUE;
+ return TRUE;
}
void
fbdevHWAdjustFrame(int scrnIndex, int x, int y, int flags)
{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- if ( x < 0 || x + fPtr->var.xres > fPtr->var.xres_virtual ||
- y < 0 || y + fPtr->var.yres > fPtr->var.yres_virtual )
- return;
+ if (x < 0 || x + fPtr->var.xres > fPtr->var.xres_virtual ||
+ y < 0 || y + fPtr->var.yres > fPtr->var.yres_virtual)
+ return;
- fPtr->var.xoffset = x;
- fPtr->var.yoffset = y;
- if (-1 == ioctl(fPtr->fd,FBIOPAN_DISPLAY,(void*)&fPtr->var))
- xf86DrvMsgVerb(scrnIndex, X_WARNING, 5,
- "FBIOPAN_DISPLAY: %s\n", strerror(errno));
+ fPtr->var.xoffset = x;
+ fPtr->var.yoffset = y;
+ if (-1 == ioctl(fPtr->fd, FBIOPAN_DISPLAY, (void *) &fPtr->var))
+ xf86DrvMsgVerb(scrnIndex, X_WARNING, 5,
+ "FBIOPAN_DISPLAY: %s\n", strerror(errno));
}
Bool
fbdevHWEnterVT(int scrnIndex, int flags)
{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-
- if (!fbdevHWModeInit(pScrn, pScrn->currentMode))
- return FALSE;
- fbdevHWAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
- return TRUE;
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+
+ if (!fbdevHWModeInit(pScrn, pScrn->currentMode))
+ return FALSE;
+ fbdevHWAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+ return TRUE;
}
void
fbdevHWLeaveVT(int scrnIndex, int flags)
{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- fbdevHWRestore(pScrn);
+ fbdevHWRestore(pScrn);
}
void
fbdevHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags)
{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- unsigned long fbmode;
-
- if (!pScrn->vtSema)
- return;
-
- switch (mode) {
- case DPMSModeOn:
- fbmode = 0;
- break;
- case DPMSModeStandby:
- fbmode = 2;
- break;
- case DPMSModeSuspend:
- fbmode = 3;
- break;
- case DPMSModeOff:
- fbmode = 4;
- break;
- default:
- return;
- }
-
- if (-1 == ioctl(fPtr->fd, FBIOBLANK, (void *)fbmode))
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "FBIOBLANK: %s\n", strerror(errno));
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ unsigned long fbmode;
+
+ if (!pScrn->vtSema)
+ return;
+
+ switch (mode) {
+ case DPMSModeOn:
+ fbmode = 0;
+ break;
+ case DPMSModeStandby:
+ fbmode = 2;
+ break;
+ case DPMSModeSuspend:
+ fbmode = 3;
+ break;
+ case DPMSModeOff:
+ fbmode = 4;
+ break;
+ default:
+ return;
+ }
+
+ if (-1 == ioctl(fPtr->fd, FBIOBLANK, (void *) fbmode))
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "FBIOBLANK: %s\n", strerror(errno));
}
Bool
fbdevHWSaveScreen(ScreenPtr pScreen, int mode)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- unsigned long unblank;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ unsigned long unblank;
- if (!pScrn->vtSema)
- return TRUE;
+ if (!pScrn->vtSema)
+ return TRUE;
- unblank = xf86IsUnblank(mode);
+ unblank = xf86IsUnblank(mode);
- if (-1 == ioctl(fPtr->fd, FBIOBLANK, (void *)(1-unblank))) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "FBIOBLANK: %s\n", strerror(errno));
- return FALSE;
- }
+ if (-1 == ioctl(fPtr->fd, FBIOBLANK, (void *) (1 - unblank))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "FBIOBLANK: %s\n", strerror(errno));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
xf86SwitchModeProc *
-fbdevHWSwitchModeWeak(void) { return fbdevHWSwitchMode; }
+fbdevHWSwitchModeWeak(void)
+{
+ return fbdevHWSwitchMode;
+}
xf86AdjustFrameProc *
-fbdevHWAdjustFrameWeak(void) { return fbdevHWAdjustFrame; }
+fbdevHWAdjustFrameWeak(void)
+{
+ return fbdevHWAdjustFrame;
+}
xf86EnterVTProc *
-fbdevHWEnterVTWeak(void) { return fbdevHWEnterVT; }
+fbdevHWEnterVTWeak(void)
+{
+ return fbdevHWEnterVT;
+}
xf86LeaveVTProc *
-fbdevHWLeaveVTWeak(void) { return fbdevHWLeaveVT; }
+fbdevHWLeaveVTWeak(void)
+{
+ return fbdevHWLeaveVT;
+}
xf86ValidModeProc *
-fbdevHWValidModeWeak(void) { return fbdevHWValidMode; }
+fbdevHWValidModeWeak(void)
+{
+ return fbdevHWValidMode;
+}
xf86DPMSSetProc *
-fbdevHWDPMSSetWeak(void) { return fbdevHWDPMSSet; }
+fbdevHWDPMSSetWeak(void)
+{
+ return fbdevHWDPMSSet;
+}
xf86LoadPaletteProc *
-fbdevHWLoadPaletteWeak(void) { return fbdevHWLoadPalette; }
+fbdevHWLoadPaletteWeak(void)
+{
+ return fbdevHWLoadPalette;
+}
SaveScreenProcPtr
-fbdevHWSaveScreenWeak(void) { return fbdevHWSaveScreen; }
+fbdevHWSaveScreenWeak(void)
+{
+ return fbdevHWSaveScreen;
+}
diff --git a/xorg-server/hw/xfree86/fbdevhw/fbdevhw.h b/xorg-server/hw/xfree86/fbdevhw/fbdevhw.h
index 34870c27d..536987101 100644
--- a/xorg-server/hw/xfree86/fbdevhw/fbdevhw.h
+++ b/xorg-server/hw/xfree86/fbdevhw/fbdevhw.h
@@ -5,58 +5,64 @@
#include "xf86str.h"
#include "colormapst.h"
-#define FBDEVHW_PACKED_PIXELS 0 /* Packed Pixels */
-#define FBDEVHW_PLANES 1 /* Non interleaved planes */
-#define FBDEVHW_INTERLEAVED_PLANES 2 /* Interleaved planes */
-#define FBDEVHW_TEXT 3 /* Text/attributes */
-#define FBDEVHW_VGA_PLANES 4 /* EGA/VGA planes */
+#define FBDEVHW_PACKED_PIXELS 0 /* Packed Pixels */
+#define FBDEVHW_PLANES 1 /* Non interleaved planes */
+#define FBDEVHW_INTERLEAVED_PLANES 2 /* Interleaved planes */
+#define FBDEVHW_TEXT 3 /* Text/attributes */
+#define FBDEVHW_VGA_PLANES 4 /* EGA/VGA planes */
-extern _X_EXPORT Bool fbdevHWGetRec(ScrnInfoPtr pScrn);
-extern _X_EXPORT void fbdevHWFreeRec(ScrnInfoPtr pScrn);
+extern _X_EXPORT Bool fbdevHWGetRec(ScrnInfoPtr pScrn);
+extern _X_EXPORT void fbdevHWFreeRec(ScrnInfoPtr pScrn);
-extern _X_EXPORT int fbdevHWGetFD(ScrnInfoPtr pScrn);
+extern _X_EXPORT int fbdevHWGetFD(ScrnInfoPtr pScrn);
-extern _X_EXPORT Bool fbdevHWProbe(struct pci_device * pPci, char *device, char **namep);
-extern _X_EXPORT Bool fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device * pPci, char *device);
+extern _X_EXPORT Bool fbdevHWProbe(struct pci_device *pPci, char *device,
+ char **namep);
+extern _X_EXPORT Bool fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device *pPci,
+ char *device);
-extern _X_EXPORT char* fbdevHWGetName(ScrnInfoPtr pScrn);
-extern _X_EXPORT int fbdevHWGetDepth(ScrnInfoPtr pScrn, int *fbbpp);
-extern _X_EXPORT int fbdevHWGetLineLength(ScrnInfoPtr pScrn);
-extern _X_EXPORT int fbdevHWGetType(ScrnInfoPtr pScrn);
-extern _X_EXPORT int fbdevHWGetVidmem(ScrnInfoPtr pScrn);
+extern _X_EXPORT char *fbdevHWGetName(ScrnInfoPtr pScrn);
+extern _X_EXPORT int fbdevHWGetDepth(ScrnInfoPtr pScrn, int *fbbpp);
+extern _X_EXPORT int fbdevHWGetLineLength(ScrnInfoPtr pScrn);
+extern _X_EXPORT int fbdevHWGetType(ScrnInfoPtr pScrn);
+extern _X_EXPORT int fbdevHWGetVidmem(ScrnInfoPtr pScrn);
-extern _X_EXPORT void* fbdevHWMapVidmem(ScrnInfoPtr pScrn);
-extern _X_EXPORT int fbdevHWLinearOffset(ScrnInfoPtr pScrn);
-extern _X_EXPORT Bool fbdevHWUnmapVidmem(ScrnInfoPtr pScrn);
-extern _X_EXPORT void* fbdevHWMapMMIO(ScrnInfoPtr pScrn);
-extern _X_EXPORT Bool fbdevHWUnmapMMIO(ScrnInfoPtr pScrn);
+extern _X_EXPORT void *fbdevHWMapVidmem(ScrnInfoPtr pScrn);
+extern _X_EXPORT int fbdevHWLinearOffset(ScrnInfoPtr pScrn);
+extern _X_EXPORT Bool fbdevHWUnmapVidmem(ScrnInfoPtr pScrn);
+extern _X_EXPORT void *fbdevHWMapMMIO(ScrnInfoPtr pScrn);
+extern _X_EXPORT Bool fbdevHWUnmapMMIO(ScrnInfoPtr pScrn);
-extern _X_EXPORT void fbdevHWSetVideoModes(ScrnInfoPtr pScrn);
+extern _X_EXPORT void fbdevHWSetVideoModes(ScrnInfoPtr pScrn);
extern _X_EXPORT DisplayModePtr fbdevHWGetBuildinMode(ScrnInfoPtr pScrn);
-extern _X_EXPORT void fbdevHWUseBuildinMode(ScrnInfoPtr pScrn);
-extern _X_EXPORT Bool fbdevHWModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
-extern _X_EXPORT void fbdevHWSave(ScrnInfoPtr pScrn);
-extern _X_EXPORT void fbdevHWRestore(ScrnInfoPtr pScrn);
-
-extern _X_EXPORT void fbdevHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
- LOCO *colors, VisualPtr pVisual);
-
-extern _X_EXPORT ModeStatus fbdevHWValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags);
-extern _X_EXPORT Bool fbdevHWSwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
-extern _X_EXPORT void fbdevHWAdjustFrame(int scrnIndex, int x, int y, int flags);
-extern _X_EXPORT Bool fbdevHWEnterVT(int scrnIndex, int flags);
-extern _X_EXPORT void fbdevHWLeaveVT(int scrnIndex, int flags);
-extern _X_EXPORT void fbdevHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags);
-
-extern _X_EXPORT Bool fbdevHWSaveScreen(ScreenPtr pScreen, int mode);
-
-extern _X_EXPORT xf86SwitchModeProc *fbdevHWSwitchModeWeak(void);
-extern _X_EXPORT xf86AdjustFrameProc *fbdevHWAdjustFrameWeak(void);
-extern _X_EXPORT xf86EnterVTProc *fbdevHWEnterVTWeak(void);
-extern _X_EXPORT xf86LeaveVTProc *fbdevHWLeaveVTWeak(void);
-extern _X_EXPORT xf86ValidModeProc *fbdevHWValidModeWeak(void);
-extern _X_EXPORT xf86DPMSSetProc *fbdevHWDPMSSetWeak(void);
-extern _X_EXPORT xf86LoadPaletteProc *fbdevHWLoadPaletteWeak(void);
-extern _X_EXPORT SaveScreenProcPtr fbdevHWSaveScreenWeak(void);
+extern _X_EXPORT void fbdevHWUseBuildinMode(ScrnInfoPtr pScrn);
+extern _X_EXPORT Bool fbdevHWModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
+extern _X_EXPORT void fbdevHWSave(ScrnInfoPtr pScrn);
+extern _X_EXPORT void fbdevHWRestore(ScrnInfoPtr pScrn);
+
+extern _X_EXPORT void fbdevHWLoadPalette(ScrnInfoPtr pScrn, int numColors,
+ int *indices, LOCO * colors,
+ VisualPtr pVisual);
+
+extern _X_EXPORT ModeStatus fbdevHWValidMode(int scrnIndex, DisplayModePtr mode,
+ Bool verbose, int flags);
+extern _X_EXPORT Bool fbdevHWSwitchMode(int scrnIndex, DisplayModePtr mode,
+ int flags);
+extern _X_EXPORT void fbdevHWAdjustFrame(int scrnIndex, int x, int y,
+ int flags);
+extern _X_EXPORT Bool fbdevHWEnterVT(int scrnIndex, int flags);
+extern _X_EXPORT void fbdevHWLeaveVT(int scrnIndex, int flags);
+extern _X_EXPORT void fbdevHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags);
+
+extern _X_EXPORT Bool fbdevHWSaveScreen(ScreenPtr pScreen, int mode);
+
+extern _X_EXPORT xf86SwitchModeProc *fbdevHWSwitchModeWeak(void);
+extern _X_EXPORT xf86AdjustFrameProc *fbdevHWAdjustFrameWeak(void);
+extern _X_EXPORT xf86EnterVTProc *fbdevHWEnterVTWeak(void);
+extern _X_EXPORT xf86LeaveVTProc *fbdevHWLeaveVTWeak(void);
+extern _X_EXPORT xf86ValidModeProc *fbdevHWValidModeWeak(void);
+extern _X_EXPORT xf86DPMSSetProc *fbdevHWDPMSSetWeak(void);
+extern _X_EXPORT xf86LoadPaletteProc *fbdevHWLoadPaletteWeak(void);
+extern _X_EXPORT SaveScreenProcPtr fbdevHWSaveScreenWeak(void);
#endif
diff --git a/xorg-server/hw/xfree86/fbdevhw/fbdevhwstub.c b/xorg-server/hw/xfree86/fbdevhw/fbdevhwstub.c
index 191a6d33d..6e0a470b8 100644
--- a/xorg-server/hw/xfree86/fbdevhw/fbdevhwstub.c
+++ b/xorg-server/hw/xfree86/fbdevhw/fbdevhwstub.c
@@ -8,11 +8,10 @@
/* Stubs for the static server on platforms that don't support fbdev */
-
Bool
fbdevHWGetRec(ScrnInfoPtr pScrn)
{
- return FALSE;
+ return FALSE;
}
void
@@ -20,48 +19,47 @@ fbdevHWFreeRec(ScrnInfoPtr pScrn)
{
}
-
Bool
fbdevHWProbe(struct pci_device *pPci, char *device, char **namep)
{
- return FALSE;
+ return FALSE;
}
Bool
fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device *pPci, char *device)
{
- xf86Msg(X_ERROR, "fbdevhw is not available on this platform\n");
- return FALSE;
+ xf86Msg(X_ERROR, "fbdevhw is not available on this platform\n");
+ return FALSE;
}
-char*
+char *
fbdevHWGetName(ScrnInfoPtr pScrn)
{
- return NULL;
+ return NULL;
}
int
fbdevHWGetDepth(ScrnInfoPtr pScrn, int *fbbpp)
{
- return -1;
+ return -1;
}
int
fbdevHWGetLineLength(ScrnInfoPtr pScrn)
{
- return -1; /* Should cause something spectacular... */
+ return -1; /* Should cause something spectacular... */
}
int
fbdevHWGetType(ScrnInfoPtr pScrn)
{
- return -1;
+ return -1;
}
int
fbdevHWGetVidmem(ScrnInfoPtr pScrn)
{
- return -1;
+ return -1;
}
void
@@ -72,7 +70,7 @@ fbdevHWSetVideoModes(ScrnInfoPtr pScrn)
DisplayModePtr
fbdevHWGetBuildinMode(ScrnInfoPtr pScrn)
{
- return NULL;
+ return NULL;
}
void
@@ -80,40 +78,40 @@ fbdevHWUseBuildinMode(ScrnInfoPtr pScrn)
{
}
-void*
+void *
fbdevHWMapVidmem(ScrnInfoPtr pScrn)
{
- return NULL;
+ return NULL;
}
int
fbdevHWLinearOffset(ScrnInfoPtr pScrn)
{
- return 0;
+ return 0;
}
Bool
fbdevHWUnmapVidmem(ScrnInfoPtr pScrn)
{
- return FALSE;
+ return FALSE;
}
-void*
+void *
fbdevHWMapMMIO(ScrnInfoPtr pScrn)
{
- return NULL;
+ return NULL;
}
Bool
fbdevHWUnmapMMIO(ScrnInfoPtr pScrn)
{
- return FALSE;
+ return FALSE;
}
Bool
fbdevHWModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
-{
- return FALSE;
+{
+ return FALSE;
}
void
@@ -128,20 +126,20 @@ fbdevHWRestore(ScrnInfoPtr pScrn)
void
fbdevHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
- LOCO *colors, VisualPtr pVisual)
+ LOCO * colors, VisualPtr pVisual)
{
}
ModeStatus
fbdevHWValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
{
- return MODE_ERROR;
+ return MODE_ERROR;
}
Bool
fbdevHWSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
{
- return FALSE;
+ return FALSE;
}
void
@@ -152,7 +150,7 @@ fbdevHWAdjustFrame(int scrnIndex, int x, int y, int flags)
Bool
fbdevHWEnterVT(int scrnIndex, int flags)
{
- return FALSE;
+ return FALSE;
}
void
@@ -168,29 +166,53 @@ fbdevHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags)
Bool
fbdevHWSaveScreen(ScreenPtr pScreen, int mode)
{
- return FALSE;
+ return FALSE;
}
xf86SwitchModeProc *
-fbdevHWSwitchModeWeak(void) { return fbdevHWSwitchMode; }
+fbdevHWSwitchModeWeak(void)
+{
+ return fbdevHWSwitchMode;
+}
xf86AdjustFrameProc *
-fbdevHWAdjustFrameWeak(void) { return fbdevHWAdjustFrame; }
+fbdevHWAdjustFrameWeak(void)
+{
+ return fbdevHWAdjustFrame;
+}
xf86EnterVTProc *
-fbdevHWEnterVTWeak(void) { return fbdevHWEnterVT; }
+fbdevHWEnterVTWeak(void)
+{
+ return fbdevHWEnterVT;
+}
xf86LeaveVTProc *
-fbdevHWLeaveVTWeak(void) { return fbdevHWLeaveVT; }
+fbdevHWLeaveVTWeak(void)
+{
+ return fbdevHWLeaveVT;
+}
xf86ValidModeProc *
-fbdevHWValidModeWeak(void) { return fbdevHWValidMode; }
+fbdevHWValidModeWeak(void)
+{
+ return fbdevHWValidMode;
+}
xf86DPMSSetProc *
-fbdevHWDPMSSetWeak(void) { return fbdevHWDPMSSet; }
+fbdevHWDPMSSetWeak(void)
+{
+ return fbdevHWDPMSSet;
+}
xf86LoadPaletteProc *
-fbdevHWLoadPaletteWeak(void) { return fbdevHWLoadPalette; }
+fbdevHWLoadPaletteWeak(void)
+{
+ return fbdevHWLoadPalette;
+}
SaveScreenProcPtr
-fbdevHWSaveScreenWeak(void) { return fbdevHWSaveScreen; }
+fbdevHWSaveScreenWeak(void)
+{
+ return fbdevHWSaveScreen;
+}
diff --git a/xorg-server/hw/xfree86/i2c/bt829.c b/xorg-server/hw/xfree86/i2c/bt829.c
index 64c711681..070cb2044 100644
--- a/xorg-server/hw/xfree86/i2c/bt829.c
+++ b/xorg-server/hw/xfree86/i2c/bt829.c
@@ -1,745 +1,821 @@
-/* TODO: clean up/fix CC code */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-#include "xf86.h"
-#include "xf86i2c.h"
-#include "bt829.h"
-#include "i2c_def.h"
-
-/* Changing the following settings (especially VCROP) may */
-/* require modifying code that calls this driver. */
-#define HCROP 0 /* amount to crop from the left and right edges */
-#define VCROP 0 /* amount to crop from the top and bottom edges */
-
-#define BTVERSION (bt->id>>4)
-
-#define H(X) ( ((X)>>8) & 0xFF )
-#define L(X) ( (X) & 0xFF )
-
-#define LIMIT(X,A,B) (((X)<(A)) ? (A) : ((X)>(B)) ? (B) : (X) )
-
-/* Bt829 family chip ID's */
-#define BT815 0x02
-#define BT817 0x06
-#define BT819 0x07
-#define BT827 0x0C
-#define BT829 0x0E
-
-/* Bt829 registers */
-#define STATUS 0x00 /* Device Status */
-#define IFORM 0x01 /* Input Format */
-#define TDEC 0x02 /* Temporal Decimation */
-#define CROP 0x03 /* MSB Cropping */
-#define VDELAY_LO 0x04 /* Vertical Delay */
-#define VACTIVE_LO 0x05 /* Vertical Active */
-#define HDELAY_LO 0x06 /* Horizontal Delay */
-#define HACTIVE_LO 0x07 /* Horizontal Active */
-#define HSCALE_HI 0x08 /* Horizontal Scaling */
-#define HSCALE_LO 0x09 /* Horizontal Scaling */
-#define BRIGHT 0x0A /* Brightness Control */
-#define CONTROL 0x0B /* Miscellaneous Control */
-#define CONTRAST_LO 0x0C /* Luma Gain (Contrast) */
-#define SAT_U_LO 0x0D /* Chroma (U) Gain (Saturation) */
-#define SAT_V_LO 0x0E /* Chroma (V) Gain (Saturation) */
-#define HUE 0x0F /* Hue Control */
-#define SCLOOP 0x10 /* SC Loop Control */
-#define WC_UP 0x11 /* White Crush Up Count */
-#define OFORM 0x12 /* Output Format */
-#define VSCALE_HI 0x13 /* Vertical Scaling */
-#define VSCALE_LO 0x14 /* Vertical Scaling */
-#define TEST 0x15 /* Test Control */
-#define VPOLE 0x16 /* Video Timing Polarity */
-#define IDCODE 0x17 /* ID Code */
-#define ADELAY 0x18 /* AGC Delay */
-#define BDELAY 0x19 /* Burst Gate Delay */
-#define ADC 0x1A /* ADC Interface */
-#define VTC 0x1B /* Video Timing Control */
-#define CC_STATUS 0x1C /* Extended Data Services/Closed Capt Status */
-#define CC_DATA 0x1D /* Extended Data Services/Closed Capt Data */
-#define WC_DN 0x1E /* White Crush Down Count */
-#define SRESET 0x1F /* Software Reset */
-#define P_IO 0x3F /* Programmable I/O */
-
-static CARD8 btread(BT829Ptr bt, CARD8 reg)
-{
- CARD8 v;
-
- I2C_WriteRead(&(bt->d), &reg, 1, &v, 1);
-
- return v;
-}
-
-static void btwrite(BT829Ptr bt, CARD8 reg, CARD8 val)
-{
- CARD8 data[2];
-
- data[0] = reg;
- data[1] = val;
- I2C_WriteRead(&(bt->d), data, 2, NULL, 0);
-}
-
-/*
- * Register access
- */
-static void btwrite_status(BT829Ptr bt) /* STATUS */
-{
- btwrite(bt, STATUS, 0x00); /* clear */
-}
-
-static void btwrite_iform(BT829Ptr bt) /* IFORM */
-{
- int xtsel;
-
- switch (bt->format) {
- case BT829_NTSC:
- case BT829_NTSC_JAPAN:
- case BT829_PAL_M:
- case BT829_PAL_N_COMB: /* gatos says xtsel = 2 */
- xtsel = 1;
- break;
- case BT829_PAL:
- case BT829_PAL_N:
- case BT829_SECAM:
- xtsel = 2;
- break;
- default: /* shouldn't get here */
- xtsel = 3; /* hardware default */
- break;
- }
-
- btwrite(bt, IFORM, (bt->mux<<5) | (xtsel<<3) | bt->format);
-}
-
-static void btwrite_tdec(BT829Ptr bt) /* TDEC */
-{
- /* use default */
-}
-
-static void btwrite_crop(BT829Ptr bt) /* CROP */
-{
- btwrite(bt, CROP, (H(bt->vdelay)<<6) | (H(bt->vactive)<<4) |
- (H(bt->hdelay)<<2) | H(bt->width));
-}
-
-static void btwrite_vdelay_lo(BT829Ptr bt) /* VDELAY_LO */
-{
- btwrite(bt, VDELAY_LO, L(bt->vdelay));
-}
-
-static void btwrite_vactive_lo(BT829Ptr bt) /* VACTIVE_LO */
-{
- btwrite(bt, VACTIVE_LO, L(bt->vactive));
-}
-
-static void btwrite_hdelay_lo(BT829Ptr bt) /* HDELAY_LO */
-{
- btwrite(bt, HDELAY_LO, L(bt->hdelay));
-}
-
-static void btwrite_hactive_lo(BT829Ptr bt) /* HACTIVE_LO */
-{
- btwrite(bt, HACTIVE_LO, L(bt->width));
-}
-
-static void btwrite_hscale_hi(BT829Ptr bt) /* HSCALE_HI */
-{
- btwrite(bt, HSCALE_HI, H(bt->hscale));
-}
-
-static void btwrite_hscale_lo(BT829Ptr bt) /* HSCALE_LO */
-{
- btwrite(bt, HSCALE_LO, L(bt->hscale));
-}
-
-static void btwrite_bright(BT829Ptr bt) /* BRIGHT */
-{
- btwrite(bt, BRIGHT, bt->brightness);
-}
-
-static void btwrite_control(BT829Ptr bt) /* CONTROL */
-{
- int ldec;
-
- /* The data sheet says ldec should always be 0 for SECAM */
- /* but the picture quality is better with ldec = 1 */
- ldec = (bt->width > 360); /* gatos says 384 */
-
- btwrite(bt, CONTROL,
- ((bt->mux==bt->svideo_mux) ? 0xC0:0x00) | /* LNOTCH and COMP */
- (ldec<<5) | (H(bt->contrast)<<2) | (H(bt->sat_u)<<1) | H(bt->sat_v));
-}
-
-static void btwrite_contrast_lo(BT829Ptr bt) /* CONTRAST_LO */
-{
- btwrite(bt, CONTRAST_LO, L(bt->contrast));
-}
-
-static void btwrite_sat_u_lo(BT829Ptr bt) /* SAT_U_LO */
-{
- btwrite(bt, SAT_U_LO, L(bt->sat_u));
-}
-
-static void btwrite_sat_v_lo(BT829Ptr bt) /* SAT_V_LO */
-{
- btwrite(bt, SAT_V_LO, L(bt->sat_v));
-}
-
-static void btwrite_hue(BT829Ptr bt) /* HUE */
-{
- btwrite(bt, HUE, bt->hue);
-}
-
-static void btwrite_scloop(BT829Ptr bt) /* SCLOOP */
-{
- if (BTVERSION >= BT827) {
- btwrite(bt, SCLOOP,
- (bt->format==BT829_SECAM) ? 0x10:0x00 /* QCIF or AUTO */
- );
- }
-}
-
-static void btwrite_wc_up(BT829Ptr bt) /* WC_UP */
-{
- if (BTVERSION >= BT827) {
- /* use default */
- }
-}
-
-static void btwrite_oform(BT829Ptr bt) /* OFORM */
-{
- btwrite(bt, OFORM, (bt->code<<3) | (bt->len<<2) |
- 0x02 /* RANGE = 0, CORE = 0, VBI_FRAME = 0, OES = 2 (default) */
- );
-}
-
-static void btwrite_vscale_hi(BT829Ptr bt) /* VSCALE_HI */
-{
- btwrite(bt, VSCALE_HI, H(bt->vscale) |
- 0x60 /* YCOMB = 0, COMB = 1, INT = 1 (default) */
- );
-}
-
-static void btwrite_vscale_lo(BT829Ptr bt) /* VSCALE_LO */
-{
- btwrite(bt, VSCALE_LO, L(bt->vscale));
-}
-
-/* TEST should not be written to */
-
-static void btwrite_vpole(BT829Ptr bt) /* VPOLE */
-{
- btwrite(bt, VPOLE, (bt->out_en<<7));
-}
-
-/* IDCODE is read only */
-
-static void btwrite_adelay(BT829Ptr bt) /* ADELAY */
-{
- switch (bt->format) {
- case BT829_NTSC:
- case BT829_NTSC_JAPAN:
- case BT829_PAL_M:
- btwrite(bt, ADELAY, 104);
- break;
- case BT829_PAL:
- case BT829_PAL_N:
- case BT829_SECAM:
- case BT829_PAL_N_COMB:
- btwrite(bt, ADELAY, 127);
- break;
- default: /* shouldn't get here */
- btwrite(bt, ADELAY, 104); /* hardware default */
- break;
- }
-}
-
-static void btwrite_bdelay(BT829Ptr bt) /* BDELAY */
-{
- switch (bt->format) {
- case BT829_NTSC:
- case BT829_NTSC_JAPAN:
- case BT829_PAL_M:
- btwrite(bt, BDELAY, 93);
- break;
- case BT829_PAL:
- case BT829_PAL_N:
- case BT829_PAL_N_COMB:
- btwrite(bt, BDELAY, 114);
- break;
- case BT829_SECAM:
- btwrite(bt, BDELAY, 160);
- break;
- default: /* shouldn't get here */
- btwrite(bt, BDELAY, 93); /* hardware default */
- break;
- }
-}
-
-static void btwrite_adc(BT829Ptr bt) /* ADC */
-{
- btwrite(bt, ADC, bt->mux==bt->svideo_mux ? 0x80:0x82); /* CSLEEP = 0 or 1 */
-}
-
-static void btwrite_vtc(BT829Ptr bt) /* VTC */
-{
- int vfilt = 0; /* hardware default */
-
- if (BTVERSION > BT827) { /* gatos says >= BT827 */
- switch (bt->format) {
- case BT829_NTSC:
- case BT829_NTSC_JAPAN:
- case BT829_PAL_M:
- case BT829_PAL_N_COMB: /* gatos groups with BT829_PAL */
- if (bt->width <= 360) vfilt = 1; /* gatos says <= 240 */
- if (bt->width <= 180) vfilt = 2; /* gatos says <= 120 */
- if (bt->width <= 90) vfilt = 3; /* gatos says <= 60 */
- break;
- case BT829_PAL:
- case BT829_PAL_N:
- case BT829_SECAM:
- if (bt->width <= 384) vfilt = 1;
- if (bt->width <= 192) vfilt = 2;
- if (bt->width<= 96) vfilt = 3;
- break;
- default: /* shouldn't get here */
- break; /* use hardware default */
- }
- btwrite(bt, VTC, (bt->vbien<<4) | (bt->vbifmt<<3) | vfilt);
- }
-}
-
-static void btwrite_cc_status(BT829Ptr bt) /* CC_STATUS */
-{ /* FIXME: ATI specific */
- if (BTVERSION >= BT827) {
- if (bt->ccmode == 0) btwrite(bt, CC_STATUS, 0x00);
- /* 0x40 is activate to set the CCVALID line. Not required yet */
- else btwrite(bt, CC_STATUS, (bt->ccmode<<4) | 0x40);
- }
-}
-
-/* CC_DATA is read only */
-
-static void btwrite_wc_dn(BT829Ptr bt) /* WC_DN */
-{
- if (BTVERSION >= BT827) {
- /* use default */
- }
-}
-
-static void bt_reset(BT829Ptr bt) { /* SRESET */
- btwrite(bt, SRESET, 0x0); /* Reset all registers */
-}
-
-static void btwrite_p_io(BT829Ptr bt) /* P_IO */
-{
- if (BTVERSION >= BT827) {
- btwrite(bt, P_IO, bt->p_io);
- }
-}
-
-/*
- * Deal with dependencies
- */
-static void propagate_changes(BT829Ptr bt)
-{
- CARD16 hdelay, unscaled_hdelay, vdelay, hscale, vscale;
- int htotal, vactive;
-
- switch (bt->format) {
- case BT829_NTSC:
- case BT829_NTSC_JAPAN:
- case BT829_PAL_M:
- vdelay = 22;
- htotal = 754;
- vactive = 480;
- unscaled_hdelay = 135;
- break;
- case BT829_PAL:
- case BT829_PAL_N:
- vdelay = (bt->tunertype==5) ? 34 : 22;
- htotal = 922;
- vactive = 576;
- unscaled_hdelay = 186;
- break;
- case BT829_SECAM:
- vdelay = 34;
- htotal = 922;
- vactive = 576;
- unscaled_hdelay = 186;
- break;
- case BT829_PAL_N_COMB:
- vdelay = (bt->tunertype==5) ? 34 : 22; /* windows says 22 */
- htotal = 754; /* gatos and windows say 922 */
- vactive = 576;
- unscaled_hdelay = 135; /* gatos and windows say 186 */
- break;
- default: /* shouldn't get here */
- vdelay = 22; /* hardware default */
- htotal = 754;
- vactive = 480; /* hardware default */
- unscaled_hdelay = 135;
- break;
- }
-
- bt->htotal = htotal; /* Used for error checking in bt829_SetCaptSize */
-
- hscale = 4096 * htotal / (bt->width + 2 * HCROP)-4096;
- hdelay = (
- HCROP + (bt->width + 2 * HCROP) * unscaled_hdelay / htotal
- ) & 0x3FE;
-
- vactive = vactive - 2 * VCROP;
- vdelay = vdelay + VCROP;
- vscale = (0x10000 - (512*vactive/bt->height-512)) & 0x1FFF;
-
- if ((hdelay != bt->hdelay) || (vdelay != bt->vdelay) ||
- (vactive != bt->vactive) || (hscale != bt->hscale) ||
- (vscale != bt->vscale)) {
- bt->hdelay = hdelay;
- bt->vdelay = vdelay;
- bt->vactive = vactive;
- bt->hscale = hscale;
- bt->vscale = vscale;
- btwrite_crop(bt);
- btwrite_vdelay_lo(bt);
- btwrite_vactive_lo(bt);
- btwrite_hdelay_lo(bt);
- btwrite_hscale_hi(bt);
- btwrite_hscale_lo(bt);
- btwrite_control(bt);
- btwrite_vscale_hi(bt);
- btwrite_vscale_lo(bt);
- }
-}
-
-static void write_all(BT829Ptr bt)
-{
- bt_reset(bt);
- propagate_changes(bt); /* ensure consistency */
- btwrite_iform(bt);
- btwrite_tdec(bt);
- btwrite_crop(bt);
- btwrite_vdelay_lo(bt);
- btwrite_vactive_lo(bt);
- btwrite_hdelay_lo(bt);
- btwrite_hactive_lo(bt);
- btwrite_hscale_hi(bt);
- btwrite_hscale_lo(bt);
- btwrite_bright(bt);
- btwrite_control(bt);
- btwrite_contrast_lo(bt);
- btwrite_sat_u_lo(bt);
- btwrite_sat_v_lo(bt);
- btwrite_hue(bt);
- btwrite_scloop(bt);
- btwrite_wc_up(bt);
- btwrite_oform(bt);
- btwrite_vscale_hi(bt);
- btwrite_vscale_lo(bt);
- btwrite_vpole(bt);
- btwrite_adelay(bt);
- btwrite_bdelay(bt);
- btwrite_adc(bt);
- btwrite_vtc(bt);
-/* btwrite_cc_status(bt); */ /* FIXME: CC code needs cleaning */
- btwrite_wc_dn(bt);
- btwrite_p_io(bt);
-}
-
-/*
- * Public functions
- */
-BT829Ptr bt829_Detect(I2CBusPtr b, I2CSlaveAddr addr)
-{
- BT829Ptr bt;
- I2CByte a;
-
- bt = calloc(1, sizeof(BT829Rec));
- if(bt == NULL) return NULL;
- bt->d.DevName = strdup("BT829 video decoder");
- bt->d.SlaveAddr = addr;
- bt->d.pI2CBus = b;
- bt->d.NextDev = NULL;
- bt->d.StartTimeout = b->StartTimeout;
- bt->d.BitTimeout = b->BitTimeout;
- bt->d.AcknTimeout = b->AcknTimeout;
- bt->d.ByteTimeout = b->ByteTimeout;
-
-
- if(!I2C_WriteRead(&(bt->d), NULL, 0, &a, 1))
- {
- free(bt);
- return NULL;
- }
-
- bt->id = btread(bt,IDCODE);
-
- free(bt->d.DevName);
- bt->d.DevName = calloc(200, sizeof(char));
- switch(BTVERSION){
- case BT815:
- sprintf(bt->d.DevName, "bt815a video decoder, revision %d",bt->id & 0xf);
- break;
- case BT817:
- sprintf(bt->d.DevName, "bt817a video decoder, revision %d",bt->id & 0xf);
- break;
- case BT819:
- sprintf(bt->d.DevName, "bt819a video decoder, revision %d",bt->id & 0xf);
- break;
- case BT827:
- sprintf(bt->d.DevName, "bt827a/b video decoder, revision %d",bt->id & 0xf);
- break;
- case BT829:
- sprintf(bt->d.DevName, "bt829a/b video decoder, revision %d",bt->id & 0xf);
- break;
- default:
- sprintf(bt->d.DevName, "bt8xx/unknown video decoder version %d, revision %d",bt->id >> 4,bt->id & 0xf);
- break;
- }
-
- /* set default parameters */
- if(!I2CDevInit(&(bt->d)))
- {
- free(bt);
- return NULL;
- }
-
- bt->tunertype = 1;
-
- bt->brightness = 0; /* hardware default */
- bt->ccmode = 0;
- bt->code = 0; /* hardware default */
- bt->contrast = 216; /* hardware default */
- bt->format = BT829_NTSC;
- bt->height = 480; /* hardware default for vactive */
- bt->hue = 0; /* hardware default */
- bt->len = 1; /* hardware default */
- bt->mux = BT829_MUX0; /* hardware default */
- bt->out_en = 0; /* hardware default */
- bt->p_io = 0; /* hardware default */
- bt->sat_u = 254; /* hardware default */
- bt->sat_v = 180; /* hardware default */
- bt->vbien = 0; /* hardware default */
- bt->vbifmt = 0; /* hardware default */
- bt->width = 640; /* hardware default for hactive */
-
- bt->hdelay = 120; /* hardware default */
- bt->hscale = 684; /* hardware default */
- bt->vactive = 480; /* hardware default */
- bt->vdelay = 22; /* hardware default */
- bt->vscale = 0; /* hardware default */
-
- bt->htotal = 754; /* NTSC */
- bt->svideo_mux = 0; /* no s-video */
-
- return bt;
-}
-
-int bt829_ATIInit(BT829Ptr bt)
-{
- bt->code = 1;
- bt->len = 0;
- bt->vbien = 1;
- bt->vbifmt = 1;
- bt->svideo_mux = BT829_MUX1;
-
- write_all (bt);
-
- return 0;
-}
-
-int bt829_SetFormat(BT829Ptr bt, CARD8 format)
-{
- if ((format < 1) || (format > 7)) return -1;
- if ((BTVERSION <= BT819) &&
- (format != BT829_NTSC) && (format != BT829_PAL)) return -1;
- if (format == bt->format) return 0;
- bt->format = format;
- propagate_changes(bt);
- btwrite_iform(bt);
- btwrite_scloop(bt);
- btwrite_adelay(bt);
- btwrite_bdelay(bt);
- btwrite_vtc(bt);
- return 0;
-}
-
-int bt829_SetMux(BT829Ptr bt, CARD8 mux)
-{
- if ((mux < 1) || (mux > 3)) return -1;
- if (mux == bt->mux) return 0;
- bt->mux = mux;
- /* propagate_changes(bt); */ /* no dependencies */
- btwrite_iform(bt);
- btwrite_control(bt);
- btwrite_adc(bt);
- return 0;
-}
-
-void bt829_SetBrightness(BT829Ptr bt, int brightness)
-{
- brightness = LIMIT(brightness,-1000,999); /* ensure -128 <= brightness <= 127 below */
- brightness = (128*brightness)/1000;
- if (brightness == bt->brightness) return;
- bt->brightness = brightness;
- /* propagate_changes(bt); */ /* no dependencies */
- btwrite_bright(bt);
-}
-
-void bt829_SetContrast(BT829Ptr bt, int contrast)
-{
- contrast = LIMIT(contrast,-1000,1000);
- contrast = (216*(contrast+1000))/1000;
- if (contrast == bt->contrast) return;
- bt->contrast = contrast;
- /* propagate_changes(bt); */ /* no dependencies */
- btwrite_control(bt);
- btwrite_contrast_lo(bt);
-}
-
-void bt829_SetSaturation(BT829Ptr bt, int saturation)
-{
- CARD16 sat_u, sat_v;
-
- saturation = LIMIT(saturation,-1000,1000);
- sat_u = (254*(saturation+1000))/1000;
- sat_v = (180*(saturation+1000))/1000;
- if ((sat_u == bt->sat_u) && (sat_v == bt->sat_v)) return;
- bt->sat_u = sat_u;
- bt->sat_v = sat_v;
- /* propagate_changes(bt); */ /* no dependencies */
- btwrite_control(bt);
- btwrite_sat_u_lo(bt);
- btwrite_sat_v_lo(bt);
-}
-
-void bt829_SetTint(BT829Ptr bt, int hue)
-{
- hue = LIMIT(hue,-1000,999); /* ensure -128 <= hue <= 127 below */
- hue = (128*hue)/1000;
- if (hue == bt->hue) return;
- bt->hue = hue;
- /* propagate_changes(bt); */ /* no dependencies */
- btwrite_hue(bt);
-}
-
-int bt829_SetCaptSize(BT829Ptr bt, int width, int height)
-{
- if ((width > bt->htotal - 2 * HCROP) ||
- (16 * width < bt->htotal - 32 * HCROP)) return -1;
- if ((height > bt->vactive) || (16 * height < bt->vactive)) return -1;
- if ((width == bt->width) && (height == bt->height)) return 0;
- bt->width = width;
- bt->height = height;
- propagate_changes(bt);
- btwrite_crop(bt);
- btwrite_hactive_lo(bt);
- btwrite_control(bt);
- btwrite_vtc(bt);
- return 0;
-}
-
-int bt829_SetCC(BT829Ptr bt) /* FIXME: should take ccmode as a parameter */
-{
- if (BTVERSION < BT827) return -1; /* can't do it */
- /* propagate_changes(bt); */ /* no dependencies */
- btwrite_cc_status(bt);
- /* we write to STATUS to reset the CCVALID flag */
- if (bt->ccmode != 0) btwrite_status(bt);
- return 0;
-}
-
-void bt829_SetOUT_EN(BT829Ptr bt, BOOL out_en)
-{
- out_en = (out_en != 0);
- if (out_en == bt->out_en) return;
- bt->out_en = out_en;
- /* propagate_changes(bt); */ /* no dependencies */
- btwrite_vpole(bt);
-}
-
-void bt829_SetP_IO(BT829Ptr bt, CARD8 p_io)
-{
- if (p_io == bt->p_io) return;
- bt->p_io = p_io;
- /* propagate_changes(bt); */ /* no dependencies */
- btwrite_p_io(bt);
-}
-
-#define BTREAD(R) btread(bt,(R))
-
-#if 0
-
-void bt829_getCCdata(BT829Ptr bt,struct CCdata *data)
-{
- CARD8 status;
- data->num_valid=0;
- /* wait for buffer to be half full (means 8/16 bytes)
- * either 4 (one of CC/EDS) or 2 (both CC/EDS) frames */
- if(!(BTREAD(STATUS)&0x04)) return; /* could comment this line */
- for(;data->num_valid<CC_FIFO_SIZE;data->num_valid++) {
- status=BTREAD(CC_STATUS);
- if(!(status&0x04)) break;
- data->data[data->num_valid]= BTREAD(CC_DATA)&0x7f;
- /* stripped high bit (parity) */
- data->status[data->num_valid]= (CCS_EDS*((status&0x02)>>1)) |
- (CCS_HIGH*(status&0x01)) |
- (CCS_OVER*((status&0x08)>>3)) |
- (CCS_PAR*((status&0x80)>>7)) ; }
- btwrite(bt,STATUS,0x00); /* Reset CCVALID status bit */
- return;
-}
-
-#endif
-
-/* ------------------------------------------------------------------------ */
-/* Debug and report routines */
-
-#define DUMPREG(REG) \
- xf86DrvMsg(bt->d.pI2CBus->scrnIndex,X_INFO," %-12s (0x%02X) = 0x%02X\n", \
- #REG,REG,BTREAD(REG))
-
-/*static void bt829_dumpregs(BT829Ptr bt)
-{
- DUMPREG(STATUS);
- DUMPREG(IFORM);
- DUMPREG(TDEC);
- DUMPREG(CROP);
- DUMPREG(VDELAY_LO);
- DUMPREG(VACTIVE_LO);
- DUMPREG(HDELAY_LO);
- DUMPREG(HACTIVE_LO);
- DUMPREG(HSCALE_HI);
- DUMPREG(HSCALE_LO);
- DUMPREG(BRIGHT);
- DUMPREG(CONTROL);
- DUMPREG(CONTRAST_LO);
- DUMPREG(SAT_U_LO);
- DUMPREG(SAT_V_LO);
- DUMPREG(HUE);
- if (BTVERSION >= BT827) {
- DUMPREG(SCLOOP);
- DUMPREG(WC_UP) ; }
- DUMPREG(OFORM);
- DUMPREG(VSCALE_HI);
- DUMPREG(VSCALE_LO);
- DUMPREG(TEST);
- DUMPREG(VPOLE);
- DUMPREG(IDCODE);
- DUMPREG(ADELAY);
- DUMPREG(BDELAY);
- DUMPREG(ADC);
- if (BTVERSION >= BT827) {
- DUMPREG(VTC);
- DUMPREG(CC_STATUS);
- DUMPREG(CC_DATA);
- DUMPREG(WC_DN);
- DUMPREG(P_IO) ; }
-}*/
+/* TODO: clean up/fix CC code */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "xf86.h"
+#include "xf86i2c.h"
+#include "bt829.h"
+#include "i2c_def.h"
+
+/* Changing the following settings (especially VCROP) may */
+/* require modifying code that calls this driver. */
+#define HCROP 0 /* amount to crop from the left and right edges */
+#define VCROP 0 /* amount to crop from the top and bottom edges */
+
+#define BTVERSION (bt->id>>4)
+
+#define H(X) ( ((X)>>8) & 0xFF )
+#define L(X) ( (X) & 0xFF )
+
+#define LIMIT(X,A,B) (((X)<(A)) ? (A) : ((X)>(B)) ? (B) : (X) )
+
+/* Bt829 family chip ID's */
+#define BT815 0x02
+#define BT817 0x06
+#define BT819 0x07
+#define BT827 0x0C
+#define BT829 0x0E
+
+/* Bt829 registers */
+#define STATUS 0x00 /* Device Status */
+#define IFORM 0x01 /* Input Format */
+#define TDEC 0x02 /* Temporal Decimation */
+#define CROP 0x03 /* MSB Cropping */
+#define VDELAY_LO 0x04 /* Vertical Delay */
+#define VACTIVE_LO 0x05 /* Vertical Active */
+#define HDELAY_LO 0x06 /* Horizontal Delay */
+#define HACTIVE_LO 0x07 /* Horizontal Active */
+#define HSCALE_HI 0x08 /* Horizontal Scaling */
+#define HSCALE_LO 0x09 /* Horizontal Scaling */
+#define BRIGHT 0x0A /* Brightness Control */
+#define CONTROL 0x0B /* Miscellaneous Control */
+#define CONTRAST_LO 0x0C /* Luma Gain (Contrast) */
+#define SAT_U_LO 0x0D /* Chroma (U) Gain (Saturation) */
+#define SAT_V_LO 0x0E /* Chroma (V) Gain (Saturation) */
+#define HUE 0x0F /* Hue Control */
+#define SCLOOP 0x10 /* SC Loop Control */
+#define WC_UP 0x11 /* White Crush Up Count */
+#define OFORM 0x12 /* Output Format */
+#define VSCALE_HI 0x13 /* Vertical Scaling */
+#define VSCALE_LO 0x14 /* Vertical Scaling */
+#define TEST 0x15 /* Test Control */
+#define VPOLE 0x16 /* Video Timing Polarity */
+#define IDCODE 0x17 /* ID Code */
+#define ADELAY 0x18 /* AGC Delay */
+#define BDELAY 0x19 /* Burst Gate Delay */
+#define ADC 0x1A /* ADC Interface */
+#define VTC 0x1B /* Video Timing Control */
+#define CC_STATUS 0x1C /* Extended Data Services/Closed Capt Status */
+#define CC_DATA 0x1D /* Extended Data Services/Closed Capt Data */
+#define WC_DN 0x1E /* White Crush Down Count */
+#define SRESET 0x1F /* Software Reset */
+#define P_IO 0x3F /* Programmable I/O */
+
+static CARD8
+btread(BT829Ptr bt, CARD8 reg)
+{
+ CARD8 v;
+
+ I2C_WriteRead(&(bt->d), &reg, 1, &v, 1);
+
+ return v;
+}
+
+static void
+btwrite(BT829Ptr bt, CARD8 reg, CARD8 val)
+{
+ CARD8 data[2];
+
+ data[0] = reg;
+ data[1] = val;
+ I2C_WriteRead(&(bt->d), data, 2, NULL, 0);
+}
+
+/*
+ * Register access
+ */
+static void
+btwrite_status(BT829Ptr bt)
+{ /* STATUS */
+ btwrite(bt, STATUS, 0x00); /* clear */
+}
+
+static void
+btwrite_iform(BT829Ptr bt)
+{ /* IFORM */
+ int xtsel;
+
+ switch (bt->format) {
+ case BT829_NTSC:
+ case BT829_NTSC_JAPAN:
+ case BT829_PAL_M:
+ case BT829_PAL_N_COMB: /* gatos says xtsel = 2 */
+ xtsel = 1;
+ break;
+ case BT829_PAL:
+ case BT829_PAL_N:
+ case BT829_SECAM:
+ xtsel = 2;
+ break;
+ default: /* shouldn't get here */
+ xtsel = 3; /* hardware default */
+ break;
+ }
+
+ btwrite(bt, IFORM, (bt->mux << 5) | (xtsel << 3) | bt->format);
+}
+
+static void
+btwrite_tdec(BT829Ptr bt)
+{ /* TDEC */
+ /* use default */
+}
+
+static void
+btwrite_crop(BT829Ptr bt)
+{ /* CROP */
+ btwrite(bt, CROP, (H(bt->vdelay) << 6) | (H(bt->vactive) << 4) |
+ (H(bt->hdelay) << 2) | H(bt->width));
+}
+
+static void
+btwrite_vdelay_lo(BT829Ptr bt)
+{ /* VDELAY_LO */
+ btwrite(bt, VDELAY_LO, L(bt->vdelay));
+}
+
+static void
+btwrite_vactive_lo(BT829Ptr bt)
+{ /* VACTIVE_LO */
+ btwrite(bt, VACTIVE_LO, L(bt->vactive));
+}
+
+static void
+btwrite_hdelay_lo(BT829Ptr bt)
+{ /* HDELAY_LO */
+ btwrite(bt, HDELAY_LO, L(bt->hdelay));
+}
+
+static void
+btwrite_hactive_lo(BT829Ptr bt)
+{ /* HACTIVE_LO */
+ btwrite(bt, HACTIVE_LO, L(bt->width));
+}
+
+static void
+btwrite_hscale_hi(BT829Ptr bt)
+{ /* HSCALE_HI */
+ btwrite(bt, HSCALE_HI, H(bt->hscale));
+}
+
+static void
+btwrite_hscale_lo(BT829Ptr bt)
+{ /* HSCALE_LO */
+ btwrite(bt, HSCALE_LO, L(bt->hscale));
+}
+
+static void
+btwrite_bright(BT829Ptr bt)
+{ /* BRIGHT */
+ btwrite(bt, BRIGHT, bt->brightness);
+}
+
+static void
+btwrite_control(BT829Ptr bt)
+{ /* CONTROL */
+ int ldec;
+
+ /* The data sheet says ldec should always be 0 for SECAM */
+ /* but the picture quality is better with ldec = 1 */
+ ldec = (bt->width > 360); /* gatos says 384 */
+
+ btwrite(bt, CONTROL, ((bt->mux == bt->svideo_mux) ? 0xC0 : 0x00) | /* LNOTCH and COMP */
+ (ldec << 5) | (H(bt->contrast) << 2) | (H(bt->sat_u) << 1) | H(bt->
+ sat_v));
+}
+
+static void
+btwrite_contrast_lo(BT829Ptr bt)
+{ /* CONTRAST_LO */
+ btwrite(bt, CONTRAST_LO, L(bt->contrast));
+}
+
+static void
+btwrite_sat_u_lo(BT829Ptr bt)
+{ /* SAT_U_LO */
+ btwrite(bt, SAT_U_LO, L(bt->sat_u));
+}
+
+static void
+btwrite_sat_v_lo(BT829Ptr bt)
+{ /* SAT_V_LO */
+ btwrite(bt, SAT_V_LO, L(bt->sat_v));
+}
+
+static void
+btwrite_hue(BT829Ptr bt)
+{ /* HUE */
+ btwrite(bt, HUE, bt->hue);
+}
+
+static void
+btwrite_scloop(BT829Ptr bt)
+{ /* SCLOOP */
+ if (BTVERSION >= BT827) {
+ btwrite(bt, SCLOOP, (bt->format == BT829_SECAM) ? 0x10 : 0x00 /* QCIF or AUTO */
+ );
+ }
+}
+
+static void
+btwrite_wc_up(BT829Ptr bt)
+{ /* WC_UP */
+ if (BTVERSION >= BT827) {
+ /* use default */
+ }
+}
+
+static void
+btwrite_oform(BT829Ptr bt)
+{ /* OFORM */
+ btwrite(bt, OFORM, (bt->code << 3) | (bt->len << 2) | 0x02 /* RANGE = 0, CORE = 0, VBI_FRAME = 0, OES = 2 (default) */
+ );
+}
+
+static void
+btwrite_vscale_hi(BT829Ptr bt)
+{ /* VSCALE_HI */
+ btwrite(bt, VSCALE_HI, H(bt->vscale) | 0x60 /* YCOMB = 0, COMB = 1, INT = 1 (default) */
+ );
+}
+
+static void
+btwrite_vscale_lo(BT829Ptr bt)
+{ /* VSCALE_LO */
+ btwrite(bt, VSCALE_LO, L(bt->vscale));
+}
+
+/* TEST should not be written to */
+
+static void
+btwrite_vpole(BT829Ptr bt)
+{ /* VPOLE */
+ btwrite(bt, VPOLE, (bt->out_en << 7));
+}
+
+/* IDCODE is read only */
+
+static void
+btwrite_adelay(BT829Ptr bt)
+{ /* ADELAY */
+ switch (bt->format) {
+ case BT829_NTSC:
+ case BT829_NTSC_JAPAN:
+ case BT829_PAL_M:
+ btwrite(bt, ADELAY, 104);
+ break;
+ case BT829_PAL:
+ case BT829_PAL_N:
+ case BT829_SECAM:
+ case BT829_PAL_N_COMB:
+ btwrite(bt, ADELAY, 127);
+ break;
+ default: /* shouldn't get here */
+ btwrite(bt, ADELAY, 104); /* hardware default */
+ break;
+ }
+}
+
+static void
+btwrite_bdelay(BT829Ptr bt)
+{ /* BDELAY */
+ switch (bt->format) {
+ case BT829_NTSC:
+ case BT829_NTSC_JAPAN:
+ case BT829_PAL_M:
+ btwrite(bt, BDELAY, 93);
+ break;
+ case BT829_PAL:
+ case BT829_PAL_N:
+ case BT829_PAL_N_COMB:
+ btwrite(bt, BDELAY, 114);
+ break;
+ case BT829_SECAM:
+ btwrite(bt, BDELAY, 160);
+ break;
+ default: /* shouldn't get here */
+ btwrite(bt, BDELAY, 93); /* hardware default */
+ break;
+ }
+}
+
+static void
+btwrite_adc(BT829Ptr bt)
+{ /* ADC */
+ btwrite(bt, ADC, bt->mux == bt->svideo_mux ? 0x80 : 0x82); /* CSLEEP = 0 or 1 */
+}
+
+static void
+btwrite_vtc(BT829Ptr bt)
+{ /* VTC */
+ int vfilt = 0; /* hardware default */
+
+ if (BTVERSION > BT827) { /* gatos says >= BT827 */
+ switch (bt->format) {
+ case BT829_NTSC:
+ case BT829_NTSC_JAPAN:
+ case BT829_PAL_M:
+ case BT829_PAL_N_COMB: /* gatos groups with BT829_PAL */
+ if (bt->width <= 360)
+ vfilt = 1; /* gatos says <= 240 */
+ if (bt->width <= 180)
+ vfilt = 2; /* gatos says <= 120 */
+ if (bt->width <= 90)
+ vfilt = 3; /* gatos says <= 60 */
+ break;
+ case BT829_PAL:
+ case BT829_PAL_N:
+ case BT829_SECAM:
+ if (bt->width <= 384)
+ vfilt = 1;
+ if (bt->width <= 192)
+ vfilt = 2;
+ if (bt->width <= 96)
+ vfilt = 3;
+ break;
+ default: /* shouldn't get here */
+ break; /* use hardware default */
+ }
+ btwrite(bt, VTC, (bt->vbien << 4) | (bt->vbifmt << 3) | vfilt);
+ }
+}
+
+static void
+btwrite_cc_status(BT829Ptr bt)
+{ /* CC_STATUS *//* FIXME: ATI specific */
+ if (BTVERSION >= BT827) {
+ if (bt->ccmode == 0)
+ btwrite(bt, CC_STATUS, 0x00);
+ /* 0x40 is activate to set the CCVALID line. Not required yet */
+ else
+ btwrite(bt, CC_STATUS, (bt->ccmode << 4) | 0x40);
+ }
+}
+
+/* CC_DATA is read only */
+
+static void
+btwrite_wc_dn(BT829Ptr bt)
+{ /* WC_DN */
+ if (BTVERSION >= BT827) {
+ /* use default */
+ }
+}
+
+static void
+bt_reset(BT829Ptr bt)
+{ /* SRESET */
+ btwrite(bt, SRESET, 0x0); /* Reset all registers */
+}
+
+static void
+btwrite_p_io(BT829Ptr bt)
+{ /* P_IO */
+ if (BTVERSION >= BT827) {
+ btwrite(bt, P_IO, bt->p_io);
+ }
+}
+
+/*
+ * Deal with dependencies
+ */
+static void
+propagate_changes(BT829Ptr bt)
+{
+ CARD16 hdelay, unscaled_hdelay, vdelay, hscale, vscale;
+ int htotal, vactive;
+
+ switch (bt->format) {
+ case BT829_NTSC:
+ case BT829_NTSC_JAPAN:
+ case BT829_PAL_M:
+ vdelay = 22;
+ htotal = 754;
+ vactive = 480;
+ unscaled_hdelay = 135;
+ break;
+ case BT829_PAL:
+ case BT829_PAL_N:
+ vdelay = (bt->tunertype == 5) ? 34 : 22;
+ htotal = 922;
+ vactive = 576;
+ unscaled_hdelay = 186;
+ break;
+ case BT829_SECAM:
+ vdelay = 34;
+ htotal = 922;
+ vactive = 576;
+ unscaled_hdelay = 186;
+ break;
+ case BT829_PAL_N_COMB:
+ vdelay = (bt->tunertype == 5) ? 34 : 22; /* windows says 22 */
+ htotal = 754; /* gatos and windows say 922 */
+ vactive = 576;
+ unscaled_hdelay = 135; /* gatos and windows say 186 */
+ break;
+ default: /* shouldn't get here */
+ vdelay = 22; /* hardware default */
+ htotal = 754;
+ vactive = 480; /* hardware default */
+ unscaled_hdelay = 135;
+ break;
+ }
+
+ bt->htotal = htotal; /* Used for error checking in bt829_SetCaptSize */
+
+ hscale = 4096 * htotal / (bt->width + 2 * HCROP) - 4096;
+ hdelay =
+ (HCROP + (bt->width + 2 * HCROP) * unscaled_hdelay / htotal) & 0x3FE;
+
+ vactive = vactive - 2 * VCROP;
+ vdelay = vdelay + VCROP;
+ vscale = (0x10000 - (512 * vactive / bt->height - 512)) & 0x1FFF;
+
+ if ((hdelay != bt->hdelay) || (vdelay != bt->vdelay) ||
+ (vactive != bt->vactive) || (hscale != bt->hscale) ||
+ (vscale != bt->vscale)) {
+ bt->hdelay = hdelay;
+ bt->vdelay = vdelay;
+ bt->vactive = vactive;
+ bt->hscale = hscale;
+ bt->vscale = vscale;
+ btwrite_crop(bt);
+ btwrite_vdelay_lo(bt);
+ btwrite_vactive_lo(bt);
+ btwrite_hdelay_lo(bt);
+ btwrite_hscale_hi(bt);
+ btwrite_hscale_lo(bt);
+ btwrite_control(bt);
+ btwrite_vscale_hi(bt);
+ btwrite_vscale_lo(bt);
+ }
+}
+
+static void
+write_all(BT829Ptr bt)
+{
+ bt_reset(bt);
+ propagate_changes(bt); /* ensure consistency */
+ btwrite_iform(bt);
+ btwrite_tdec(bt);
+ btwrite_crop(bt);
+ btwrite_vdelay_lo(bt);
+ btwrite_vactive_lo(bt);
+ btwrite_hdelay_lo(bt);
+ btwrite_hactive_lo(bt);
+ btwrite_hscale_hi(bt);
+ btwrite_hscale_lo(bt);
+ btwrite_bright(bt);
+ btwrite_control(bt);
+ btwrite_contrast_lo(bt);
+ btwrite_sat_u_lo(bt);
+ btwrite_sat_v_lo(bt);
+ btwrite_hue(bt);
+ btwrite_scloop(bt);
+ btwrite_wc_up(bt);
+ btwrite_oform(bt);
+ btwrite_vscale_hi(bt);
+ btwrite_vscale_lo(bt);
+ btwrite_vpole(bt);
+ btwrite_adelay(bt);
+ btwrite_bdelay(bt);
+ btwrite_adc(bt);
+ btwrite_vtc(bt);
+ /* btwrite_cc_status(bt); *//* FIXME: CC code needs cleaning */
+ btwrite_wc_dn(bt);
+ btwrite_p_io(bt);
+}
+
+/*
+ * Public functions
+ */
+BT829Ptr
+bt829_Detect(I2CBusPtr b, I2CSlaveAddr addr)
+{
+ BT829Ptr bt;
+ I2CByte a;
+
+ bt = calloc(1, sizeof(BT829Rec));
+ if (bt == NULL)
+ return NULL;
+ bt->d.DevName = strdup("BT829 video decoder");
+ bt->d.SlaveAddr = addr;
+ bt->d.pI2CBus = b;
+ bt->d.NextDev = NULL;
+ bt->d.StartTimeout = b->StartTimeout;
+ bt->d.BitTimeout = b->BitTimeout;
+ bt->d.AcknTimeout = b->AcknTimeout;
+ bt->d.ByteTimeout = b->ByteTimeout;
+
+ if (!I2C_WriteRead(&(bt->d), NULL, 0, &a, 1)) {
+ free(bt);
+ return NULL;
+ }
+
+ bt->id = btread(bt, IDCODE);
+
+ free(bt->d.DevName);
+ bt->d.DevName = calloc(200, sizeof(char));
+ switch (BTVERSION) {
+ case BT815:
+ sprintf(bt->d.DevName, "bt815a video decoder, revision %d",
+ bt->id & 0xf);
+ break;
+ case BT817:
+ sprintf(bt->d.DevName, "bt817a video decoder, revision %d",
+ bt->id & 0xf);
+ break;
+ case BT819:
+ sprintf(bt->d.DevName, "bt819a video decoder, revision %d",
+ bt->id & 0xf);
+ break;
+ case BT827:
+ sprintf(bt->d.DevName, "bt827a/b video decoder, revision %d",
+ bt->id & 0xf);
+ break;
+ case BT829:
+ sprintf(bt->d.DevName, "bt829a/b video decoder, revision %d",
+ bt->id & 0xf);
+ break;
+ default:
+ sprintf(bt->d.DevName,
+ "bt8xx/unknown video decoder version %d, revision %d",
+ bt->id >> 4, bt->id & 0xf);
+ break;
+ }
+
+ /* set default parameters */
+ if (!I2CDevInit(&(bt->d))) {
+ free(bt);
+ return NULL;
+ }
+
+ bt->tunertype = 1;
+
+ bt->brightness = 0; /* hardware default */
+ bt->ccmode = 0;
+ bt->code = 0; /* hardware default */
+ bt->contrast = 216; /* hardware default */
+ bt->format = BT829_NTSC;
+ bt->height = 480; /* hardware default for vactive */
+ bt->hue = 0; /* hardware default */
+ bt->len = 1; /* hardware default */
+ bt->mux = BT829_MUX0; /* hardware default */
+ bt->out_en = 0; /* hardware default */
+ bt->p_io = 0; /* hardware default */
+ bt->sat_u = 254; /* hardware default */
+ bt->sat_v = 180; /* hardware default */
+ bt->vbien = 0; /* hardware default */
+ bt->vbifmt = 0; /* hardware default */
+ bt->width = 640; /* hardware default for hactive */
+
+ bt->hdelay = 120; /* hardware default */
+ bt->hscale = 684; /* hardware default */
+ bt->vactive = 480; /* hardware default */
+ bt->vdelay = 22; /* hardware default */
+ bt->vscale = 0; /* hardware default */
+
+ bt->htotal = 754; /* NTSC */
+ bt->svideo_mux = 0; /* no s-video */
+
+ return bt;
+}
+
+int
+bt829_ATIInit(BT829Ptr bt)
+{
+ bt->code = 1;
+ bt->len = 0;
+ bt->vbien = 1;
+ bt->vbifmt = 1;
+ bt->svideo_mux = BT829_MUX1;
+
+ write_all(bt);
+
+ return 0;
+}
+
+int
+bt829_SetFormat(BT829Ptr bt, CARD8 format)
+{
+ if ((format < 1) || (format > 7))
+ return -1;
+ if ((BTVERSION <= BT819) && (format != BT829_NTSC) && (format != BT829_PAL))
+ return -1;
+ if (format == bt->format)
+ return 0;
+ bt->format = format;
+ propagate_changes(bt);
+ btwrite_iform(bt);
+ btwrite_scloop(bt);
+ btwrite_adelay(bt);
+ btwrite_bdelay(bt);
+ btwrite_vtc(bt);
+ return 0;
+}
+
+int
+bt829_SetMux(BT829Ptr bt, CARD8 mux)
+{
+ if ((mux < 1) || (mux > 3))
+ return -1;
+ if (mux == bt->mux)
+ return 0;
+ bt->mux = mux;
+ /* propagate_changes(bt); *//* no dependencies */
+ btwrite_iform(bt);
+ btwrite_control(bt);
+ btwrite_adc(bt);
+ return 0;
+}
+
+void
+bt829_SetBrightness(BT829Ptr bt, int brightness)
+{
+ brightness = LIMIT(brightness, -1000, 999); /* ensure -128 <= brightness <= 127 below */
+ brightness = (128 * brightness) / 1000;
+ if (brightness == bt->brightness)
+ return;
+ bt->brightness = brightness;
+ /* propagate_changes(bt); *//* no dependencies */
+ btwrite_bright(bt);
+}
+
+void
+bt829_SetContrast(BT829Ptr bt, int contrast)
+{
+ contrast = LIMIT(contrast, -1000, 1000);
+ contrast = (216 * (contrast + 1000)) / 1000;
+ if (contrast == bt->contrast)
+ return;
+ bt->contrast = contrast;
+ /* propagate_changes(bt); *//* no dependencies */
+ btwrite_control(bt);
+ btwrite_contrast_lo(bt);
+}
+
+void
+bt829_SetSaturation(BT829Ptr bt, int saturation)
+{
+ CARD16 sat_u, sat_v;
+
+ saturation = LIMIT(saturation, -1000, 1000);
+ sat_u = (254 * (saturation + 1000)) / 1000;
+ sat_v = (180 * (saturation + 1000)) / 1000;
+ if ((sat_u == bt->sat_u) && (sat_v == bt->sat_v))
+ return;
+ bt->sat_u = sat_u;
+ bt->sat_v = sat_v;
+ /* propagate_changes(bt); *//* no dependencies */
+ btwrite_control(bt);
+ btwrite_sat_u_lo(bt);
+ btwrite_sat_v_lo(bt);
+}
+
+void
+bt829_SetTint(BT829Ptr bt, int hue)
+{
+ hue = LIMIT(hue, -1000, 999); /* ensure -128 <= hue <= 127 below */
+ hue = (128 * hue) / 1000;
+ if (hue == bt->hue)
+ return;
+ bt->hue = hue;
+ /* propagate_changes(bt); *//* no dependencies */
+ btwrite_hue(bt);
+}
+
+int
+bt829_SetCaptSize(BT829Ptr bt, int width, int height)
+{
+ if ((width > bt->htotal - 2 * HCROP) ||
+ (16 * width < bt->htotal - 32 * HCROP))
+ return -1;
+ if ((height > bt->vactive) || (16 * height < bt->vactive))
+ return -1;
+ if ((width == bt->width) && (height == bt->height))
+ return 0;
+ bt->width = width;
+ bt->height = height;
+ propagate_changes(bt);
+ btwrite_crop(bt);
+ btwrite_hactive_lo(bt);
+ btwrite_control(bt);
+ btwrite_vtc(bt);
+ return 0;
+}
+
+int
+bt829_SetCC(BT829Ptr bt)
+{ /* FIXME: should take ccmode as a parameter */
+ if (BTVERSION < BT827)
+ return -1; /* can't do it */
+ /* propagate_changes(bt); *//* no dependencies */
+ btwrite_cc_status(bt);
+ /* we write to STATUS to reset the CCVALID flag */
+ if (bt->ccmode != 0)
+ btwrite_status(bt);
+ return 0;
+}
+
+void
+bt829_SetOUT_EN(BT829Ptr bt, BOOL out_en)
+{
+ out_en = (out_en != 0);
+ if (out_en == bt->out_en)
+ return;
+ bt->out_en = out_en;
+ /* propagate_changes(bt); *//* no dependencies */
+ btwrite_vpole(bt);
+}
+
+void
+bt829_SetP_IO(BT829Ptr bt, CARD8 p_io)
+{
+ if (p_io == bt->p_io)
+ return;
+ bt->p_io = p_io;
+ /* propagate_changes(bt); *//* no dependencies */
+ btwrite_p_io(bt);
+}
+
+#define BTREAD(R) btread(bt,(R))
+
+#if 0
+
+void
+bt829_getCCdata(BT829Ptr bt, struct CCdata *data)
+{
+ CARD8 status;
+
+ data->num_valid = 0;
+ /* wait for buffer to be half full (means 8/16 bytes)
+ * either 4 (one of CC/EDS) or 2 (both CC/EDS) frames */
+ if (!(BTREAD(STATUS) & 0x04))
+ return; /* could comment this line */
+ for (; data->num_valid < CC_FIFO_SIZE; data->num_valid++) {
+ status = BTREAD(CC_STATUS);
+ if (!(status & 0x04))
+ break;
+ data->data[data->num_valid] = BTREAD(CC_DATA) & 0x7f;
+ /* stripped high bit (parity) */
+ data->status[data->num_valid] = (CCS_EDS * ((status & 0x02) >> 1)) |
+ (CCS_HIGH * (status & 0x01)) |
+ (CCS_OVER * ((status & 0x08) >> 3)) |
+ (CCS_PAR * ((status & 0x80) >> 7));
+ }
+ btwrite(bt, STATUS, 0x00); /* Reset CCVALID status bit */
+ return;
+}
+
+#endif
+
+/* ------------------------------------------------------------------------ */
+/* Debug and report routines */
+
+#define DUMPREG(REG) \
+ xf86DrvMsg(bt->d.pI2CBus->scrnIndex,X_INFO," %-12s (0x%02X) = 0x%02X\n", \
+ #REG,REG,BTREAD(REG))
+
+/*static void bt829_dumpregs(BT829Ptr bt)
+{
+ DUMPREG(STATUS);
+ DUMPREG(IFORM);
+ DUMPREG(TDEC);
+ DUMPREG(CROP);
+ DUMPREG(VDELAY_LO);
+ DUMPREG(VACTIVE_LO);
+ DUMPREG(HDELAY_LO);
+ DUMPREG(HACTIVE_LO);
+ DUMPREG(HSCALE_HI);
+ DUMPREG(HSCALE_LO);
+ DUMPREG(BRIGHT);
+ DUMPREG(CONTROL);
+ DUMPREG(CONTRAST_LO);
+ DUMPREG(SAT_U_LO);
+ DUMPREG(SAT_V_LO);
+ DUMPREG(HUE);
+ if (BTVERSION >= BT827) {
+ DUMPREG(SCLOOP);
+ DUMPREG(WC_UP) ; }
+ DUMPREG(OFORM);
+ DUMPREG(VSCALE_HI);
+ DUMPREG(VSCALE_LO);
+ DUMPREG(TEST);
+ DUMPREG(VPOLE);
+ DUMPREG(IDCODE);
+ DUMPREG(ADELAY);
+ DUMPREG(BDELAY);
+ DUMPREG(ADC);
+ if (BTVERSION >= BT827) {
+ DUMPREG(VTC);
+ DUMPREG(CC_STATUS);
+ DUMPREG(CC_DATA);
+ DUMPREG(WC_DN);
+ DUMPREG(P_IO) ; }
+}*/
diff --git a/xorg-server/hw/xfree86/i2c/bt829_module.c b/xorg-server/hw/xfree86/i2c/bt829_module.c
index 12801fbf3..c8a6ac6d1 100644
--- a/xorg-server/hw/xfree86/i2c/bt829_module.c
+++ b/xorg-server/hw/xfree86/i2c/bt829_module.c
@@ -1,21 +1,20 @@
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Module.h"
-
-static XF86ModuleVersionInfo bt829VersRec =
-{
- "bt829",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 0, 0,
- ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */
- ABI_VIDEODRV_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0}
-};
-
-_X_EXPORT XF86ModuleData bt829ModuleData = { &bt829VersRec, NULL, NULL };
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Module.h"
+
+static XF86ModuleVersionInfo bt829VersRec = {
+ "bt829",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_NONE,
+ {0, 0, 0, 0}
+};
+
+_X_EXPORT XF86ModuleData bt829ModuleData = { &bt829VersRec, NULL, NULL };
diff --git a/xorg-server/hw/xfree86/i2c/fi1236.c b/xorg-server/hw/xfree86/i2c/fi1236.c
index 0bc50e566..282fe7e34 100644
--- a/xorg-server/hw/xfree86/i2c/fi1236.c
+++ b/xorg-server/hw/xfree86/i2c/fi1236.c
@@ -15,38 +15,36 @@
#define NUM_TUNERS 8
-const FI1236_parameters tuner_parms[NUM_TUNERS] =
-{
+const FI1236_parameters tuner_parms[NUM_TUNERS] = {
/* 0 - FI1236 */
- { 733, 884, 12820, 2516, 7220, 0xA2, 0x94, 0x34, 0x8e },
+ {733, 884, 12820, 2516, 7220, 0xA2, 0x94, 0x34, 0x8e},
/* !!!based on documentation - it should be:
- {733, 16*55.25, 16*801.25, 16*160, 16*454, 0xA0, 0x90, 0x30, 0x8e},*/
+ {733, 16*55.25, 16*801.25, 16*160, 16*454, 0xA0, 0x90, 0x30, 0x8e}, */
/* 1 - FI1216 */
- { 623, 16*48.75, 16*855.25, 16*170, 16*450, 0xA0, 0x90, 0x30, 0x8e },
+ {623, 16 * 48.75, 16 * 855.25, 16 * 170, 16 * 450, 0xA0, 0x90, 0x30, 0x8e},
/* 2 - TEMIC FN5AL */
- { 623, 16*45.75, 16*855.25, 16*169, 16*454, 0xA0, 0x90, 0x30, 0x8e },
+ {623, 16 * 45.75, 16 * 855.25, 16 * 169, 16 * 454, 0xA0, 0x90, 0x30, 0x8e},
/* 3 - MT2032.. */
- { 733, 768, 13760, 0, 0, 0, 0, 0, 0 },
+ {733, 768, 13760, 0, 0, 0, 0, 0, 0},
/* 4 - FI1246 */
- { 623, 16*45.75, 16*855.25, 16*170, 16*450, 0xA0, 0x90, 0x30, 0x8e },
+ {623, 16 * 45.75, 16 * 855.25, 16 * 170, 16 * 450, 0xA0, 0x90, 0x30, 0x8e},
/* 5 - FI1256 */
- { 623, 16*49.75, 16*863.25, 16*170, 16*450, 0xA0, 0x90, 0x30, 0x8e },
+ {623, 16 * 49.75, 16 * 863.25, 16 * 170, 16 * 450, 0xA0, 0x90, 0x30, 0x8e},
/* 6 - FI1236W */
- /*{ 733, 884, 12820, 2516, 7220, 0x1, 0x2, 0x4, 0x8e },*/
- { 732, 16*55.25, 16*801.25, 16*160, 16*442, 0x1, 0x2, 0x4, 0x8e },
+ /*{ 733, 884, 12820, 2516, 7220, 0x1, 0x2, 0x4, 0x8e }, */
+ {732, 16 * 55.25, 16 * 801.25, 16 * 160, 16 * 442, 0x1, 0x2, 0x4, 0x8e},
/* 7 - FM1216ME */
- { 623, 16*48.25, 16*863.25, 16*158.00, 16*442.00, 0x1, 0x2, 0x4, 0x8e }
+ {623, 16 * 48.25, 16 * 863.25, 16 * 158.00, 16 * 442.00, 0x1, 0x2, 0x4, 0x8e}
};
-
FI1236Ptr
-Detect_FI1236 (I2CBusPtr b, I2CSlaveAddr addr)
+Detect_FI1236(I2CBusPtr b, I2CSlaveAddr addr)
{
FI1236Ptr f;
I2CByte a;
- f = calloc(1,sizeof(FI1236Rec));
+ f = calloc(1, sizeof(FI1236Rec));
if (f == NULL)
return NULL;
f->d.DevName = strdup("FI12xx Tuner");
@@ -57,10 +55,10 @@ Detect_FI1236 (I2CBusPtr b, I2CSlaveAddr addr)
f->d.BitTimeout = b->BitTimeout;
f->d.AcknTimeout = b->AcknTimeout;
f->d.ByteTimeout = b->ByteTimeout;
- f->type=TUNER_TYPE_FI1236;
- f->afc_timer_installed=FALSE;
- f->last_afc_hint=TUNER_OFF;
- f->video_if=45.7812;
+ f->type = TUNER_TYPE_FI1236;
+ f->afc_timer_installed = FALSE;
+ f->last_afc_hint = TUNER_OFF;
+ f->video_if = 45.7812;
if (!I2C_WriteRead(&(f->d), NULL, 0, &a, 1)) {
free(f);
@@ -75,7 +73,7 @@ Detect_FI1236 (I2CBusPtr b, I2CSlaveAddr addr)
}
static void
-MT2032_dump_parameters (FI1236Ptr f, MT2032_parameters *m)
+MT2032_dump_parameters(FI1236Ptr f, MT2032_parameters * m)
{
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"MT2032: input f_rf=%g f_if1=%g f_if2=%g f_ref=%g f_ifbw=%g f_step=%g\n",
@@ -86,15 +84,14 @@ MT2032_dump_parameters (FI1236Ptr f, MT2032_parameters *m)
m->f_lo1, m->f_lo2, m->LO1I, m->LO2I, m->SEL, m->STEP, m->NUM);
}
-
static void
-MT2032_getid (FI1236Ptr f)
+MT2032_getid(FI1236Ptr f)
{
CARD8 out[4];
CARD8 in;
in = 0x11;
- I2C_WriteRead(&(f->d), (I2CByte *)&in, 1, out, 4);
+ I2C_WriteRead(&(f->d), (I2CByte *) & in, 1, out, 4);
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"MT2032: Company code 0x%02x%02x, part code 0x%02x, revision code 0x%02x\n",
out[0], out[1], out[2], out[3]);
@@ -104,37 +101,37 @@ MT2032_getid (FI1236Ptr f)
/* might be buggy */
#if 0
static void
-MT2032_shutdown (FI1236Ptr f)
+MT2032_shutdown(FI1236Ptr f)
{
CARD8 data[10];
- data[0] = 0x00; /* start with register 0x00 */
+ data[0] = 0x00; /* start with register 0x00 */
data[1] = 0x1A;
data[2] = 0x44;
data[3] = 0x20;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 4, NULL, 0);
- data[0] = 0x05; /* now start with register 0x05 */
+ data[0] = 0x05; /* now start with register 0x05 */
data[1] = 0xD7;
data[2] = 0x14;
data[3] = 0x05;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 4, NULL, 0);
- data[0] = 0x0B; /* now start with register 0x05 */
+ data[0] = 0x0B; /* now start with register 0x05 */
data[1] = 0x8F;
data[2] = 0x07;
data[3] = 0x43;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 4, NULL, 0);
usleep(15000);
}
#endif
-static void MT2032_dump_status (FI1236Ptr f);
+static void MT2032_dump_status(FI1236Ptr f);
static void
-MT2032_init (FI1236Ptr f)
+MT2032_init(FI1236Ptr f)
{
CARD8 data[10];
CARD8 value;
@@ -142,31 +139,31 @@ MT2032_init (FI1236Ptr f)
MT2032_getid(f);
- data[0] = 0x02; /* start with register 0x02 */
+ data[0] = 0x02; /* start with register 0x02 */
data[1] = 0xFF;
data[2] = 0x0F;
data[3] = 0x1F;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 4, NULL, 0);
- data[0] = 0x06; /* now start with register 0x06 */
+ data[0] = 0x06; /* now start with register 0x06 */
data[1] = 0xE4;
data[2] = 0x8F;
data[3] = 0xC3;
data[4] = 0x4E;
data[5] = 0xEC;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 6, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 6, NULL, 0);
- data[0] = 0x0d; /* now start with register 0x0d */
+ data[0] = 0x0d; /* now start with register 0x0d */
data[1] = 0x32;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 2, NULL, 0);
while (1) {
- usleep(15000); /* wait 15 milliseconds */
+ usleep(15000); /* wait 15 milliseconds */
- data[0] = 0x0e; /* register number 7, status */
+ data[0] = 0x0e; /* register number 7, status */
value = 0xFF;
- if (!I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1))
+ if (!I2C_WriteRead(&(f->d), (I2CByte *) data, 1, &value, 1))
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"MT2032: failed to read XOK\n");
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
@@ -175,32 +172,33 @@ MT2032_init (FI1236Ptr f)
break;
data[0] = 0x07;
- if (!I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1))
+ if (!I2C_WriteRead(&(f->d), (I2CByte *) data, 1, &value, 1))
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"MT2032: failed to read XOGC\n");
- xogc=value & 0x7;
+ xogc = value & 0x7;
if (xogc == 4)
- break; /* XOGC has reached 4.. stop */
+ break; /* XOGC has reached 4.. stop */
xogc--;
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"MT2032: try XOGC=%d\n", xogc);
usleep(15000);
- data[0] = 0x07; /* register number 7, control byte 2 */
+ data[0] = 0x07; /* register number 7, control byte 2 */
data[1] = 0x08 | xogc;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 2, NULL, 0);
}
f->xogc = xogc;
/* wait before continuing */
- usleep(15000); /* wait 50 milliseconds */
+ usleep(15000); /* wait 50 milliseconds */
MT2032_dump_status(f);
}
static int
-MT2032_no_spur_in_band (MT2032_parameters *m)
+MT2032_no_spur_in_band(MT2032_parameters * m)
{
int n_max, n1, n2;
double f_test;
+
n_max = 5;
n1 = 1;
while (1) {
@@ -233,10 +231,12 @@ MT2032_no_spur_in_band (MT2032_parameters *m)
}
static void
-MT2032_calculate_register_settings (MT2032_parameters *m, double f_rf,
- double f_if1, double f_if2, double f_ref, double f_ifbw, double f_step)
+MT2032_calculate_register_settings(MT2032_parameters * m, double f_rf,
+ double f_if1, double f_if2, double f_ref,
+ double f_ifbw, double f_step)
{
int n;
+
m->f_rf = f_rf;
m->f_if1 = f_if1;
m->f_if2 = f_if2;
@@ -244,7 +244,7 @@ MT2032_calculate_register_settings (MT2032_parameters *m, double f_rf,
m->f_ifbw = f_ifbw;
m->f_step = f_step;
- m->f_lo1 = f_rf+f_if1;
+ m->f_lo1 = f_rf + f_if1;
m->LO1I = lrint(m->f_lo1 / f_ref);
m->f_lo1 = f_ref * m->LO1I;
@@ -277,33 +277,33 @@ MT2032_calculate_register_settings (MT2032_parameters *m, double f_rf,
m->SEL = 2;
else if (m->f_lo1 < 1890.0)
m->SEL = 1;
- else /* m->f_lo1 < 1958.0 */
+ else /* m->f_lo1 < 1958.0 */
m->SEL = 0;
/* calculate the rest of the registers */
m->LO2I = floor(m->f_lo2 / f_ref);
m->STEP = floor(3780.0 * f_step / f_ref);
- m->NUM = floor(3780.0 * (m->f_lo2 / f_ref - m->LO2I));
- m->NUM = m->STEP * lrint((1.0 * m->NUM) / (1.0 * m->STEP));
+ m->NUM = floor(3780.0 * (m->f_lo2 / f_ref - m->LO2I));
+ m->NUM = m->STEP * lrint((1.0 * m->NUM) / (1.0 * m->STEP));
}
static int
-MT2032_wait_for_lock (FI1236Ptr f)
+MT2032_wait_for_lock(FI1236Ptr f)
{
int n;
CARD8 data[10];
CARD8 value;
- n=12;
- while(1) {
- data[0] = 0x0e; /* register number 7, status */
- I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1);
- /* xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
- "MT2032: LO1LK=%d LO2LK=%d\n",
- (value & 0x04)>>2, (value & 0x02)>>1); */
- if ((value & 6)==6)
+ n = 12;
+ while (1) {
+ data[0] = 0x0e; /* register number 7, status */
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 1, &value, 1);
+ /* xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+ "MT2032: LO1LK=%d LO2LK=%d\n",
+ (value & 0x04)>>2, (value & 0x02)>>1); */
+ if ((value & 6) == 6)
break;
- usleep (1500);
+ usleep(1500);
n--;
if (n < 0)
break;
@@ -317,50 +317,50 @@ MT2032_wait_for_lock (FI1236Ptr f)
}
static void
-MT2032_implement_settings (FI1236Ptr f, MT2032_parameters *m)
+MT2032_implement_settings(FI1236Ptr f, MT2032_parameters * m)
{
CARD8 data[10];
CARD8 value;
- data[0] = 0x00; /* start with register 0x00 */
+ data[0] = 0x00; /* start with register 0x00 */
data[1] = (m->LO1I >> 3) - 1;
data[2] = (m->SEL << 4) | (m->LO1I & 0x7);
data[3] = 0x86;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 4, NULL, 0);
- data[0] = 0x05; /* start with register 0x05 */
+ data[0] = 0x05; /* start with register 0x05 */
data[1] = ((m->LO2I & 0x7) << 5) | ((m->LO2I >> 3) - 1);
if (m->f_rf < 400.0)
data[2] = 0xe4;
else
data[2] = 0xf4;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 3, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 3, NULL, 0);
- data[0] = 0x07; /* register number 7, control byte 2 */
- I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1);
+ data[0] = 0x07; /* register number 7, control byte 2 */
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 1, &value, 1);
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"MT2032: using XOGC=%d\n", (value & 0x07));
data[1] = 8 | (value & 0x7);
- I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 2, NULL, 0);
- data[0] = 0x0b; /* start with register 0x0b */
+ data[0] = 0x0b; /* start with register 0x0b */
data[1] = m->NUM & 0xff;
- data[2] = (1<<7) | ((m->NUM >> 8) & 0x0f);
- I2C_WriteRead(&(f->d), (I2CByte *)data, 3, NULL, 0);
+ data[2] = (1 << 7) | ((m->NUM >> 8) & 0x0f);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 3, NULL, 0);
MT2032_wait_for_lock(f);
}
static void
-MT2032_optimize_VCO (FI1236Ptr f, MT2032_parameters *m)
+MT2032_optimize_VCO(FI1236Ptr f, MT2032_parameters * m)
{
CARD8 data[10];
CARD8 value;
CARD8 TAD1;
- data[0] = 0x0f; /* register number 7, status */
- I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1);
- TAD1=value & 0x07;
+ data[0] = 0x0f; /* register number 7, status */
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 1, &value, 1);
+ TAD1 = value & 0x07;
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"MT2032: TAD1=%d SEL=%d\n", TAD1, m->SEL);
if (TAD1 < 2)
@@ -369,25 +369,27 @@ MT2032_optimize_VCO (FI1236Ptr f, MT2032_parameters *m)
if (m->SEL == 0)
return;
m->SEL--;
- } else {
+ }
+ else {
if (m->SEL >= 4)
return;
m->SEL++;
}
- data[0] = 0x01; /* start with register 1 */
+ data[0] = 0x01; /* start with register 1 */
data[1] = (m->SEL << 4) | (m->LO1I & 0x7);
- I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 2, NULL, 0);
}
static int
-FI1236_get_afc_hint (FI1236Ptr f)
+FI1236_get_afc_hint(FI1236Ptr f)
{
CARD8 out;
CARD8 AFC;
if ((f->type == TUNER_TYPE_FM1216ME) || (f->type == TUNER_TYPE_FI1236W)) {
- TDA9885Ptr t = (TDA9885Ptr)f->afc_source;
+ TDA9885Ptr t = (TDA9885Ptr) f->afc_source;
+
if (t == NULL)
return TUNER_OFF;
@@ -405,7 +407,8 @@ FI1236_get_afc_hint (FI1236Ptr f)
return TUNER_JUST_ABOVE;
else if (AFC == 0x0f)
return TUNER_TUNED;
- } else {
+ }
+ else {
I2C_WriteRead(&(f->d), NULL, 0, &out, 1);
AFC = out & 0x7;
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
@@ -422,17 +425,18 @@ FI1236_get_afc_hint (FI1236Ptr f)
}
static int
-MT2032_get_afc_hint (FI1236Ptr f)
+MT2032_get_afc_hint(FI1236Ptr f)
{
CARD8 in;
CARD8 out[2];
CARD8 AFC;
+
in = 0x0e;
- I2C_WriteRead(&(f->d), (I2CByte *)&in, 1, out, 2);
+ I2C_WriteRead(&(f->d), (I2CByte *) & in, 1, out, 2);
AFC = (out[0] >> 4) & 0x7;
#if 0
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC=%d TAD1=%d TAD2=%d\n",
- AFC, out[1] & 0x7, (out[1]>>4)& 0x07);
+ AFC, out[1] & 0x7, (out[1] >> 4) & 0x07);
#endif
if (AFC == 2)
return TUNER_TUNED;
@@ -445,7 +449,7 @@ MT2032_get_afc_hint (FI1236Ptr f)
/* this function is for external use only */
int
-TUNER_get_afc_hint (FI1236Ptr f)
+TUNER_get_afc_hint(FI1236Ptr f)
{
if (f->afc_timer_installed)
return TUNER_STILL_TUNING;
@@ -453,7 +457,7 @@ TUNER_get_afc_hint (FI1236Ptr f)
}
static void
-MT2032_dump_status (FI1236Ptr f)
+MT2032_dump_status(FI1236Ptr f)
{
CARD8 in;
CARD8 out[2];
@@ -463,16 +467,16 @@ MT2032_dump_status (FI1236Ptr f)
CARD8 TAD2, TAD1;
in = 0x0e;
- I2C_WriteRead(&(f->d), (I2CByte *)&in, 1, out, 2);
+ I2C_WriteRead(&(f->d), (I2CByte *) & in, 1, out, 2);
XOK = out[0] & 1;
- LO1LK = (out[0] >> 2) & 1;
- LO2LK = (out[0] >> 1) & 1;
+ LO1LK = (out[0] >> 2) & 1;
+ LO2LK = (out[0] >> 1) & 1;
LDONrb = (out[0] >> 3) & 1;
- AFC = (out[0] >> 4) & 0x7;
+ AFC = (out[0] >> 4) & 0x7;
- TAD1 = (out[1] & 0x7);
- TAD2 = (out[1] >> 4) & 0x7;
+ TAD1 = (out[1] & 0x7);
+ TAD2 = (out[1] >> 4) & 0x7;
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"MT2032: status: XOK=%d LO1LK=%d LO2LK=%d LDONrb=%d AFC=%d TAD1=%d TAD2=%d\n",
@@ -480,12 +484,12 @@ MT2032_dump_status (FI1236Ptr f)
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"MT2032: status: OSCILLATOR:%s PLL1:%s PLL2:%s\n",
XOK ? "ok" : "off",
- LO1LK ? "locked" : "off",
- LO2LK ? "locked" : "off");
+ LO1LK ? "locked" : "off", LO2LK ? "locked" : "off");
}
-static void MT2032_tune(FI1236Ptr f, double freq, double step)
+static void
+MT2032_tune(FI1236Ptr f, double freq, double step)
{
MT2032_parameters m;
CARD8 data[10];
@@ -494,38 +498,41 @@ static void MT2032_tune(FI1236Ptr f, double freq, double step)
/* NTSC IF is 44mhz.. but 733/16=45.8125 and all TDAXXXX docs mention
45.75, 39, 58.75 and 30. */
#if 0
- MT2032_calculate_register_settings(&m, freq, 1090.0, 45.125, 5.25, 6.0, step);
- MT2032_calculate_register_settings(&m, freq, 1090.0, 45.74, 5.25, 6.0, step);
+ MT2032_calculate_register_settings(&m, freq, 1090.0, 45.125, 5.25, 6.0,
+ step);
+ MT2032_calculate_register_settings(&m, freq, 1090.0, 45.74, 5.25, 6.0,
+ step);
#endif
- MT2032_calculate_register_settings(&m, freq, 1090.0, f->video_if, 5.25, 3.0, step);
+ MT2032_calculate_register_settings(&m, freq, 1090.0, f->video_if, 5.25, 3.0,
+ step);
MT2032_dump_parameters(f, &m);
MT2032_implement_settings(f, &m);
- /* MT2032_dump_parameters(f, &m); */
+ /* MT2032_dump_parameters(f, &m); */
for (i = 0; i < 3; i++) {
MT2032_optimize_VCO(f, &m);
if (MT2032_wait_for_lock(f)) {
- data[0] = 0x02; /* LO Gain control register 0x02 */
+ data[0] = 0x02; /* LO Gain control register 0x02 */
data[1] = 0x20;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 2, NULL, 0);
return;
}
data[0] = 0x07;
data[1] = 0x88 | f->xogc;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 2, NULL, 0);
usleep(15000);
data[1] = 0x08 | f->xogc;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 2, NULL, 0);
}
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"MT2032: failed to set frequency\n");
}
void
-FI1236_set_tuner_type (FI1236Ptr f, int type)
+FI1236_set_tuner_type(FI1236Ptr f, int type)
{
f->type = type;
if (type >= NUM_TUNERS)
- type = NUM_TUNERS-1;
+ type = NUM_TUNERS - 1;
if (type < 0)
type = 0;
memcpy(&(f->parm), &(tuner_parms[type]), sizeof(FI1236_parameters));
@@ -537,11 +544,11 @@ FI1236_set_tuner_type (FI1236Ptr f, int type)
}
}
-
static CARD32
AFC_TimerCallback(OsTimerPtr timer, CARD32 time, pointer data)
{
- FI1236Ptr f = (FI1236Ptr)data;
+ FI1236Ptr f = (FI1236Ptr) data;
+
if (FI1236_AFC(f))
return 150;
else {
@@ -557,12 +564,14 @@ FI1236_tune(FI1236Ptr f, CARD32 frequency)
CARD16 divider;
CARD8 data;
- if (frequency < f->parm.min_freq) frequency = f->parm.min_freq;
- if (frequency > f->parm.max_freq) frequency = f->parm.max_freq;
+ if (frequency < f->parm.min_freq)
+ frequency = f->parm.min_freq;
+ if (frequency > f->parm.max_freq)
+ frequency = f->parm.max_freq;
- divider = (f->parm.fcar + (CARD16)frequency) & 0x7fff;
- f->tuner_data.div1 = (CARD8)((divider >> 8)&0x7f);
- f->tuner_data.div2 = (CARD8)(divider & 0xff);
+ divider = (f->parm.fcar + (CARD16) frequency) & 0x7fff;
+ f->tuner_data.div1 = (CARD8) ((divider >> 8) & 0x7f);
+ f->tuner_data.div2 = (CARD8) (divider & 0xff);
f->tuner_data.control = f->parm.control;
if (frequency < f->parm.threshold1)
@@ -576,41 +585,42 @@ FI1236_tune(FI1236Ptr f, CARD32 frequency)
"Setting tuner band to %d\n", f->tuner_data.band);
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
- "Setting tuner frequency to %d\n", (int)frequency);
+ "Setting tuner frequency to %d\n", (int) frequency);
if ((f->type == TUNER_TYPE_FM1216ME) || (f->type == TUNER_TYPE_FI1236W)) {
f->tuner_data.aux = 0x20;
- I2C_WriteRead(&(f->d), (I2CByte *)&(f->tuner_data), 5, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) & (f->tuner_data), 5, NULL, 0);
I2C_WriteRead(&(f->d), NULL, 0, &data, 1);
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "Tuner status %x\n", data);
}
else
- I2C_WriteRead(&(f->d), (I2CByte *)&(f->tuner_data), 4, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) & (f->tuner_data), 4, NULL, 0);
}
void
TUNER_set_frequency(FI1236Ptr f, CARD32 frequency)
{
- if (frequency < f->parm.min_freq) frequency = f->parm.min_freq;
- if (frequency > f->parm.max_freq) frequency = f->parm.max_freq;
+ if (frequency < f->parm.min_freq)
+ frequency = f->parm.min_freq;
+ if (frequency > f->parm.max_freq)
+ frequency = f->parm.max_freq;
- f->afc_delta=0;
- f->original_frequency=frequency;
+ f->afc_delta = 0;
+ f->original_frequency = frequency;
if (f->type == TUNER_TYPE_MT2032)
- MT2032_tune(f, (1.0*frequency)/16.0, 0.0625);
+ MT2032_tune(f, (1.0 * frequency) / 16.0, 0.0625);
else
FI1236_tune(f, frequency);
if (!f->afc_timer_installed) {
- f->afc_timer_installed=TRUE;
+ f->afc_timer_installed = TRUE;
/* RegisterBlockAndWakeupHandlers(FI1236_BlockHandler, AFCWakeup, f); */
TimerSet(NULL, 0, 300, AFC_TimerCallback, f);
}
}
-
int
FI1236_AFC(FI1236Ptr f)
{
@@ -637,12 +647,13 @@ FI1236_AFC(FI1236Ptr f)
"AFC: Setting tuner frequency to %g\n",
(0.5 * (2 * f->original_frequency + f->afc_delta)) / 16.0);
MT2032_tune(f,
- (1.0 * f->original_frequency+ 0.5 * f->afc_delta) / 16.0,
+ (1.0 * f->original_frequency + 0.5 * f->afc_delta) / 16.0,
0.03125);
if (f->last_afc_hint == TUNER_OFF)
return 0;
- return 1; /* call me again */
- } else {
+ return 1; /* call me again */
+ }
+ else {
f->last_afc_hint = FI1236_get_afc_hint(f);
if (f->last_afc_hint == TUNER_TUNED) {
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC: TUNER_TUNNED\n");
@@ -652,9 +663,9 @@ FI1236_AFC(FI1236Ptr f)
f->last_afc_hint = TUNER_OFF;
if (f->last_afc_hint == TUNER_OFF)
- f->afc_delta=0;
+ f->afc_delta = 0;
else
- f->afc_delta+=f->last_afc_hint;
+ f->afc_delta += f->last_afc_hint;
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"AFC: Setting tuner frequency to %g\n",
@@ -662,9 +673,9 @@ FI1236_AFC(FI1236Ptr f)
FI1236_tune(f, f->original_frequency + f->afc_delta);
if (f->last_afc_hint == TUNER_OFF)
return 0;
- return 1; /* call me again */
+ return 1; /* call me again */
}
- return 0; /* done */
+ return 0; /* done */
}
void
diff --git a/xorg-server/hw/xfree86/i2c/fi1236_module.c b/xorg-server/hw/xfree86/i2c/fi1236_module.c
index 7375e0fb9..2f453d964 100644
--- a/xorg-server/hw/xfree86/i2c/fi1236_module.c
+++ b/xorg-server/hw/xfree86/i2c/fi1236_module.c
@@ -1,25 +1,24 @@
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Module.h"
-
-static XF86ModuleVersionInfo fi1236VersRec =
-{
- "fi1236",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 0, 0,
- ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */
- ABI_VIDEODRV_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0}
-};
-
-_X_EXPORT XF86ModuleData fi1236ModuleData = {
- &fi1236VersRec,
- NULL,
- NULL
-};
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Module.h"
+
+static XF86ModuleVersionInfo fi1236VersRec = {
+ "fi1236",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_NONE,
+ {0, 0, 0, 0}
+};
+
+_X_EXPORT XF86ModuleData fi1236ModuleData = {
+ &fi1236VersRec,
+ NULL,
+ NULL
+};
diff --git a/xorg-server/hw/xfree86/i2c/msp3430.c b/xorg-server/hw/xfree86/i2c/msp3430.c
index df8adc435..312a2d1d1 100644
--- a/xorg-server/hw/xfree86/i2c/msp3430.c
+++ b/xorg-server/hw/xfree86/i2c/msp3430.c
@@ -16,11 +16,10 @@
#define WR_DSP 0x12
#define RD_DSP 0x13
-
void InitMSP34xxG(MSP3430Ptr m);
void InitMSP34x5D(MSP3430Ptr m);
void CheckModeMSP34x5D(MSP3430Ptr m);
-static const char *MSP_getProductName (CARD16 product_id);
+static const char *MSP_getProductName(CARD16 product_id);
void mpause(int milliseconds);
#define __MSPDEBUG__ 0
@@ -28,275 +27,296 @@ void mpause(int milliseconds);
#if __MSPDEBUG__ > 3
void MSPBeep(MSP3430Ptr m, CARD8 freq);
+
#define __MSPBEEP MSPBeep(m,0x14);
#else
-#define __MSPBEEP
+#define __MSPBEEP
#endif
-static void SetMSP3430Control(MSP3430Ptr m, CARD8 RegAddress, CARD8 RegValueHigh, CARD8 RegValueLow)
+static void
+SetMSP3430Control(MSP3430Ptr m, CARD8 RegAddress, CARD8 RegValueHigh,
+ CARD8 RegValueLow)
{
- I2CByte data[3];
-
- data[0]=RegAddress;
- data[1]=RegValueHigh;
- data[2]=RegValueLow;
-
- I2C_WriteRead(&(m->d),data,3,NULL,0);
+ I2CByte data[3];
+
+ data[0] = RegAddress;
+ data[1] = RegValueHigh;
+ data[2] = RegValueLow;
+
+ I2C_WriteRead(&(m->d), data, 3, NULL, 0);
}
-static void SetMSP3430Data(MSP3430Ptr m, CARD8 RegAddress, CARD8 RegSubAddressHigh, CARD8 RegSubAddressLow,
- CARD8 RegValueHigh, CARD8 RegValueLow)
+static void
+SetMSP3430Data(MSP3430Ptr m, CARD8 RegAddress, CARD8 RegSubAddressHigh,
+ CARD8 RegSubAddressLow, CARD8 RegValueHigh, CARD8 RegValueLow)
{
- I2CByte data[5];
+ I2CByte data[5];
+
#ifdef MSP_DEBUG
- if(!m->registers_present[RegSubAddressLow]){
- xf86DrvMsg(m->d.pI2CBus->scrnIndex,X_ERROR, "Attempt to access non-existent register in MSP34xxX: 0x%02x 0x%02x 0x%02x <- 0x%02x 0x%02x\n",
- RegAddress, RegSubAddressHigh, RegSubAddressLow, RegValueHigh, RegValueLow);
- }
+ if (!m->registers_present[RegSubAddressLow]) {
+ xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_ERROR,
+ "Attempt to access non-existent register in MSP34xxX: 0x%02x 0x%02x 0x%02x <- 0x%02x 0x%02x\n",
+ RegAddress, RegSubAddressHigh, RegSubAddressLow,
+ RegValueHigh, RegValueLow);
+ }
#endif
-
- data[0] = RegAddress;
- data[1] = RegSubAddressHigh;
- data[2] = RegSubAddressLow;
- data[3] = RegValueHigh;
- data[4] = RegValueLow;
-
- I2C_WriteRead(&(m->d),data,5,NULL,0);
+
+ data[0] = RegAddress;
+ data[1] = RegSubAddressHigh;
+ data[2] = RegSubAddressLow;
+ data[3] = RegValueHigh;
+ data[4] = RegValueLow;
+
+ I2C_WriteRead(&(m->d), data, 5, NULL, 0);
}
-static void GetMSP3430Data(MSP3430Ptr m, CARD8 RegAddress, CARD8 RegSubAddressHigh, CARD8 RegSubAddressLow,
- CARD8 *RegValueHigh, CARD8 *RegValueLow)
+static void
+GetMSP3430Data(MSP3430Ptr m, CARD8 RegAddress, CARD8 RegSubAddressHigh,
+ CARD8 RegSubAddressLow, CARD8 *RegValueHigh, CARD8 *RegValueLow)
{
- I2CByte send[3];
- I2CByte receive[2];
-
- send[0] = RegAddress;
- send[1] = RegSubAddressHigh;
- send[2] = RegSubAddressLow;
-
- I2C_WriteRead(&(m->d), send, 3, receive, 2);
-
- *RegValueHigh = receive[0];
- *RegValueLow = receive[1];
+ I2CByte send[3];
+ I2CByte receive[2];
+
+ send[0] = RegAddress;
+ send[1] = RegSubAddressHigh;
+ send[2] = RegSubAddressLow;
+
+ I2C_WriteRead(&(m->d), send, 3, receive, 2);
+
+ *RegValueHigh = receive[0];
+ *RegValueLow = receive[1];
}
#if __MSPDEBUG__ > 2
-static void MSP3430DumpStatus(MSP3430Ptr m)
+static void
+MSP3430DumpStatus(MSP3430Ptr m)
{
-CARD8 status_hi, status_lo;
-CARD8 subaddr, data[2];
-
-GetMSP3430Data(m, RD_DEM, 0x02, 0x00, &status_hi, &status_lo);
-xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO, "MSP34xx: SAP(8)=%d mono/NICAM(7)=%d stereo=%d %s O_1=%d O_0=%d 2nd car=%d 1st car=%d\n",
- status_hi & 1, (status_lo>>7) & 1, (status_lo>>6)&1,
- (status_lo>>5)? ( (status_hi>>1)&1? "bad NICAM reception" : "NICAM" ) :
- ((status_hi>>1)&1 ? "bogus" : "ANALOG FM/AM") ,
- (status_lo>>4)&1, (status_lo>>3)&1,!( (status_lo>>2)&1), !((status_lo>>1)&1));
-
-GetMSP3430Data(m, RD_DEM, 0x00, 0x7E, &status_hi, &status_lo);
-xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO, "MSP34xx: standard result=0x%02x%02x\n",
- status_hi, status_lo);
-subaddr=0x0;
-I2C_WriteRead(&(m->d), &subaddr, 1, data, 2);
-xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO, "MSP34xx: control=0x%02x%02x\n",
- data[1], data[0]);
+ CARD8 status_hi, status_lo;
+ CARD8 subaddr, data[2];
+
+ GetMSP3430Data(m, RD_DEM, 0x02, 0x00, &status_hi, &status_lo);
+ xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO,
+ "MSP34xx: SAP(8)=%d mono/NICAM(7)=%d stereo=%d %s O_1=%d O_0=%d 2nd car=%d 1st car=%d\n",
+ status_hi & 1, (status_lo >> 7) & 1, (status_lo >> 6) & 1,
+ (status_lo >> 5) ? ((status_hi >> 1) & 1 ? "bad NICAM reception"
+ : "NICAM") : ((status_hi >> 1) & 1 ? "bogus"
+ : "ANALOG FM/AM"),
+ (status_lo >> 4) & 1, (status_lo >> 3) & 1,
+ !((status_lo >> 2) & 1), !((status_lo >> 1) & 1));
+
+ GetMSP3430Data(m, RD_DEM, 0x00, 0x7E, &status_hi, &status_lo);
+ xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO,
+ "MSP34xx: standard result=0x%02x%02x\n", status_hi, status_lo);
+ subaddr = 0x0;
+ I2C_WriteRead(&(m->d), &subaddr, 1, data, 2);
+ xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO, "MSP34xx: control=0x%02x%02x\n",
+ data[1], data[0]);
}
#endif
/* wrapper */
-void InitMSP3430(MSP3430Ptr m)
+void
+InitMSP3430(MSP3430Ptr m)
{
- #if __MSPDEBUG__ > 1
- xf86DrvMsg(m->d.pI2CBus->scrnIndex,X_INFO,"InitMSP3430(m->connector=%d, m->standard=%d, m->chip_family=%d)\n",
- m->connector, m->standard, m->chip_family);
- #endif
- switch (m->chip_family) {
- case MSPFAMILY_34x0G:
- InitMSP34xxG(m);
- break;
- case MSPFAMILY_34x5G:
- InitMSP34xxG(m);
- break;
- case MSPFAMILY_34x5D:
- InitMSP34x5D(m);
- break;
- }
+#if __MSPDEBUG__ > 1
+ xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO,
+ "InitMSP3430(m->connector=%d, m->standard=%d, m->chip_family=%d)\n",
+ m->connector, m->standard, m->chip_family);
+#endif
+ switch (m->chip_family) {
+ case MSPFAMILY_34x0G:
+ InitMSP34xxG(m);
+ break;
+ case MSPFAMILY_34x5G:
+ InitMSP34xxG(m);
+ break;
+ case MSPFAMILY_34x5D:
+ InitMSP34x5D(m);
+ break;
+ }
}
/*-----------------------------------------------------------------
| common functions for all MSP34xx chips
|----------------------------------------------------------------*/
-MSP3430Ptr DetectMSP3430(I2CBusPtr b, I2CSlaveAddr addr)
+MSP3430Ptr
+DetectMSP3430(I2CBusPtr b, I2CSlaveAddr addr)
{
- MSP3430Ptr m;
- I2CByte a;
- CARD8 hardware_version, major_revision, product_code, rom_version;
- Bool supported;
-
- m = calloc(1,sizeof(MSP3430Rec));
- if(m == NULL)return NULL;
- m->d.DevName = strdup("MSP34xx");
- m->d.SlaveAddr = addr;
- m->d.pI2CBus = b;
- m->d.NextDev = NULL;
- m->d.StartTimeout = b->StartTimeout;
- m->d.BitTimeout = b->BitTimeout;
- m->d.AcknTimeout = b->AcknTimeout;
- m->d.ByteTimeout = b->ByteTimeout;
-
- if(!I2C_WriteRead(&(m->d), NULL, 0, &a, 1))
- {
- free(m->d.DevName);
- free(m);
- return NULL;
+ MSP3430Ptr m;
+ I2CByte a;
+ CARD8 hardware_version, major_revision, product_code, rom_version;
+ Bool supported;
+
+ m = calloc(1, sizeof(MSP3430Rec));
+ if (m == NULL)
+ return NULL;
+ m->d.DevName = strdup("MSP34xx");
+ m->d.SlaveAddr = addr;
+ m->d.pI2CBus = b;
+ m->d.NextDev = NULL;
+ m->d.StartTimeout = b->StartTimeout;
+ m->d.BitTimeout = b->BitTimeout;
+ m->d.AcknTimeout = b->AcknTimeout;
+ m->d.ByteTimeout = b->ByteTimeout;
+
+ if (!I2C_WriteRead(&(m->d), NULL, 0, &a, 1)) {
+ free(m->d.DevName);
+ free(m);
+ return NULL;
+ }
+
+ m->standard = MSP3430_NTSC;
+ m->connector = MSP3430_CONNECTOR_1;
+ m->mode = MSPMODE_STEREO_A; /*stereo or chanel A if avail. */
+ m->c_format = MSPFORMAT_UNKNOWN;
+ m->c_standard = MSPSTANDARD_UNKNOWN;
+ m->c_matrix = m->c_fmmatrix = m->c_source = 0;
+ m->volume = 0;
+ m->recheck = FALSE;
+
+ GetMSP3430Data(m, RD_DSP, 0x00, 0x1E, &hardware_version, &major_revision);
+ GetMSP3430Data(m, RD_DSP, 0x00, 0x1F, &product_code, &rom_version);
+ m->hardware_version = hardware_version;
+ m->major_revision = major_revision;
+ m->product_code = product_code;
+ m->rom_version = rom_version;
+
+ m->chip_id = ((major_revision << 8) | product_code);
+
+ supported = FALSE;
+ switch (major_revision) {
+ case 4: /* 34xxD */
+ switch (product_code) {
+ case 0x05: /* 3405D */
+ case 0x0A: /* 3410D */
+ case 0x0F: /* 3415D */
+ m->chip_family = MSPFAMILY_34x5D;
+ m->recheck = TRUE;
+ supported = TRUE;
+ break;
+ default:
+ m->chip_family = MSPFAMILY_34x0D;
+ }
+ break;
+ case 7: /* 34xxG */
+ switch (product_code) {
+ case 0x00:
+ case 0x0A:
+ case 0x1E:
+ case 0x28:
+ case 0x32:
+ m->chip_family = MSPFAMILY_34x0G;
+ supported = TRUE;
+ break;
+ case 0x0f:
+ case 0x19:
+ case 0x2d:
+ case 0x37:
+ case 0x41:
+ m->chip_family = MSPFAMILY_34x5G;
+ supported = TRUE;
+#ifdef MSP_DEBUG
+ memset(m->registers_present, 0, 256);
+#define A(num) m->registers_present[(num)]=1;
+#define B(num1, num2) memset(&(m->registers_present[num1]), 1, num2-num1);
+ A(0x20)
+ A(0x30)
+ A(0x40)
+ A(0x00)
+ B(0x01, 0x08)
+ B(0x0B, 0x0E)
+ A(0x10)
+ B(0x12, 0x14)
+ A(0x16)
+ A(0x29)
+#undef B
+#undef A
+#endif
+ break;
+ default:
+ m->chip_family = MSPFAMILY_UNKNOWN;
+ }
+ break;
+ default:
+ m->chip_family = MSPFAMILY_UNKNOWN;
}
+ xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO,
+ "Found %s%s, rom version 0x%02x, chip_id=0x%04x\n",
+ MSP_getProductName(m->chip_id),
+ supported ? "" : " (unsupported)", rom_version, m->chip_id);
- m->standard=MSP3430_NTSC;
- m->connector=MSP3430_CONNECTOR_1;
- m->mode=MSPMODE_STEREO_A; /*stereo or chanel A if avail. */
- m->c_format=MSPFORMAT_UNKNOWN;
- m->c_standard=MSPSTANDARD_UNKNOWN;
- m->c_matrix=m->c_fmmatrix=m->c_source=0;
- m->volume=0;
- m->recheck=FALSE;
-
- GetMSP3430Data(m, RD_DSP, 0x00, 0x1E, &hardware_version, &major_revision);
- GetMSP3430Data(m, RD_DSP, 0x00, 0x1F, &product_code, &rom_version);
- m->hardware_version=hardware_version;
- m->major_revision=major_revision;
- m->product_code=product_code;
- m->rom_version=rom_version;
-
- m->chip_id=((major_revision << 8) | product_code);
-
- supported=FALSE;
- switch (major_revision) {
- case 4: /* 34xxD */
- switch (product_code) {
- case 0x05: /* 3405D */
- case 0x0A: /* 3410D */
- case 0x0F: /* 3415D */
- m->chip_family=MSPFAMILY_34x5D;
- m->recheck=TRUE;
- supported=TRUE;
- break;
- default:
- m->chip_family=MSPFAMILY_34x0D;
- }
- break;
- case 7: /* 34xxG */
- switch(product_code){
- case 0x00:
- case 0x0A:
- case 0x1E:
- case 0x28:
- case 0x32:
- m->chip_family=MSPFAMILY_34x0G;
- supported=TRUE;
- break;
- case 0x0f:
- case 0x19:
- case 0x2d:
- case 0x37:
- case 0x41:
- m->chip_family=MSPFAMILY_34x5G;
- supported=TRUE;
- #ifdef MSP_DEBUG
- memset(m->registers_present, 0, 256);
- #define A(num) m->registers_present[(num)]=1;
- #define B(num1, num2) memset(&(m->registers_present[num1]), 1, num2-num1);
- A(0x20)
- A(0x30)
- A(0x40)
- A(0x00)
- B(0x01, 0x08)
- B(0x0B, 0x0E)
- A(0x10)
- B(0x12,0x14)
- A(0x16)
- A(0x29)
- #undef B
- #undef A
- #endif
- break;
- default:
- m->chip_family=MSPFAMILY_UNKNOWN;
- }
- break;
- default:
- m->chip_family=MSPFAMILY_UNKNOWN;
- }
-
- xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO, "Found %s%s, rom version 0x%02x, chip_id=0x%04x\n",
- MSP_getProductName(m->chip_id), supported?"":" (unsupported)", rom_version, m->chip_id);
-
- if (!supported) {
- free(m->d.DevName);
- free(m);
- return NULL;
- }
- if(!I2CDevInit(&(m->d)))
- {
- free(m->d.DevName);
- free(m);
- return NULL;
- }
-
- return m;
+ if (!supported) {
+ free(m->d.DevName);
+ free(m);
+ return NULL;
+ }
+ if (!I2CDevInit(&(m->d))) {
+ free(m->d.DevName);
+ free(m);
+ return NULL;
+ }
+
+ return m;
}
-void ResetMSP3430(MSP3430Ptr m)
+void
+ResetMSP3430(MSP3430Ptr m)
{
/* Reset the MSP3430 */
SetMSP3430Control(m, 0x00, 0x80, 0x00);
/* Set it back to normal operation */
SetMSP3430Control(m, 0x00, 0x00, 0x00);
- m->c_format=MSPFORMAT_UNKNOWN;
- m->c_standard=MSPSTANDARD_UNKNOWN;
- m->c_matrix=m->c_fmmatrix=m->c_source=0;
- m->volume=0;
-}
+ m->c_format = MSPFORMAT_UNKNOWN;
+ m->c_standard = MSPSTANDARD_UNKNOWN;
+ m->c_matrix = m->c_fmmatrix = m->c_source = 0;
+ m->volume = 0;
+}
-void MSP3430SetVolume (MSP3430Ptr m, CARD8 value)
+void
+MSP3430SetVolume(MSP3430Ptr m, CARD8 value)
{
CARD8 result;
+
#if 0
CARD8 old_volume;
- GetMSP3430Data(m, RD_DSP, 0x00, 0x00, &old_volume, &result);
- xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO, "MSP3430 result 0x%02x\n", result);
+
+ GetMSP3430Data(m, RD_DSP, 0x00, 0x00, &old_volume, &result);
+ xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO, "MSP3430 result 0x%02x\n",
+ result);
#endif
/* save an extra Get call */
- result=0;
+ result = 0;
SetMSP3430Data(m, WR_DSP, 0x00, 0x00, value, result);
SetMSP3430Data(m, WR_DSP, 0x00, 0x07, value, 0);
- m->volume=value;
+ m->volume = value;
#if __MSPDEBUG__ > 2
- MSP3430DumpStatus(m);
- __MSPBEEP
- GetMSP3430Data(m, RD_DSP, 0x00, 0x00, &old_volume, &result);
- xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO, "MSP3430 volume 0x%02x\n",value);
+ MSP3430DumpStatus(m);
+ __MSPBEEP GetMSP3430Data(m, RD_DSP, 0x00, 0x00, &old_volume, &result);
+ xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO, "MSP3430 volume 0x%02x\n",
+ value);
#endif
}
-
-void MSP3430SetSAP (MSP3430Ptr m, int mode)
+void
+MSP3430SetSAP(MSP3430Ptr m, int mode)
{
- xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO, "Put actual code to change SAP here\n");
+ xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO,
+ "Put actual code to change SAP here\n");
- SetMSP3430Data(m, WR_DSP, 0x00, 0x08, mode & 0xff, 0x20);
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x08, mode & 0xff, 0x20);
}
-
#if 0
-void MSP3430SetSource(MSP3430Ptr m, CARD8 value)
+void
+MSP3430SetSource(MSP3430Ptr m, CARD8 value)
{
/* Write to DSP, register 0x0008, (loudspeaker channel source/matrix) */
/* This sets the source to the TV tuner, for stereo operation */
@@ -304,121 +324,142 @@ void MSP3430SetSource(MSP3430Ptr m, CARD8 value)
}
#endif
-
static const char *
-MSP_getProductName (CARD16 product_id)
+MSP_getProductName(CARD16 product_id)
{
- switch (product_id) {
- case 0x0400: return "MSP3400D";
- case 0x040a: return "MSP3410D";
- case 0x0405: return "MSP3405D";
- case 0x040f: return "MSP3415D";
- case 0x0700: return "MSP3400G";
- case 0x070a: return "MSP3410G";
- case 0x071e: return "MSP3430G";
- case 0x0728: return "MSP3440G";
- case 0x0732: return "MSP3450G";
- case 0x070f: return "MSP3415G";
- case 0x0719: return "MSP3425G";
- case 0x072d: return "MSP3445G";
- case 0x0737: return "MSP3455G";
- case 0x0741: return "MSP3465G";
- }
- return "MSP - unknown type";
+ switch (product_id) {
+ case 0x0400:
+ return "MSP3400D";
+ case 0x040a:
+ return "MSP3410D";
+ case 0x0405:
+ return "MSP3405D";
+ case 0x040f:
+ return "MSP3415D";
+ case 0x0700:
+ return "MSP3400G";
+ case 0x070a:
+ return "MSP3410G";
+ case 0x071e:
+ return "MSP3430G";
+ case 0x0728:
+ return "MSP3440G";
+ case 0x0732:
+ return "MSP3450G";
+ case 0x070f:
+ return "MSP3415G";
+ case 0x0719:
+ return "MSP3425G";
+ case 0x072d:
+ return "MSP3445G";
+ case 0x0737:
+ return "MSP3455G";
+ case 0x0741:
+ return "MSP3465G";
+ }
+ return "MSP - unknown type";
}
#if __MSPDEBUG__ > 2
/*puts beep in MSP output
freq = 0x01 - 16Hz ... 0x40 - 1kHz ... 0xff - 4kHz
*/
-void MSPBeep(MSP3430Ptr m, CARD8 freq) {
- SetMSP3430Data (m, WR_DSP, 0x00, freq, 0x7f, 0x40);
+void
+MSPBeep(MSP3430Ptr m, CARD8 freq)
+{
+ SetMSP3430Data(m, WR_DSP, 0x00, freq, 0x7f, 0x40);
mpause(100);
- SetMSP3430Data (m, WR_DSP, 0x00, 0x14, 0x00, 0x00);
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x14, 0x00, 0x00);
}
#endif
-void mpause(int milliseconds) {
- int i,m;
- m=milliseconds/20;
- for (i=0;i<m;i++) usleep(20000);
+void
+mpause(int milliseconds)
+{
+ int i, m;
+
+ m = milliseconds / 20;
+ for (i = 0; i < m; i++)
+ usleep(20000);
}
/*-----------------------------------------------------------------
| specific functions for all MSP34xxG chips
|----------------------------------------------------------------*/
-void InitMSP34xxG(MSP3430Ptr m)
+void
+InitMSP34xxG(MSP3430Ptr m)
{
- #if __MSPDEBUG__ > 1
- xf86DrvMsg(m->d.pI2CBus->scrnIndex,X_INFO,"InitMSP34xxG(m->connector=%d, m->standard=%d, m->chip_family=%d)\n",
- m->connector, m->standard, m->chip_family);
- #endif
- /* Reset MSP3430 */
- SetMSP3430Control(m, 0x00, 0x80, 0x00);
- /* Set it back to normal operation */
- SetMSP3430Control(m, 0x00, 0x00, 0x00);
-
- /*set MODUS register */
- /* bits: 0 - automatic sound detection */
- /* 1 - enable STATUS change */
- /* 12 - detect 6.5 Mhz carrier as D/K1, D/K2 or D/K NICAM (does not seem to work ) */
- /* 13 - detect 4.5 Mhz carrier as BTSC */
- if ( (m->standard & 0xff) == MSP3430_PAL )
- {
- SetMSP3430Data(m, WR_DEM, 0x00, 0x30, 0x30, 0x03|0x08); /* make O_ pins tristate */
- /* PAL standard */
- SetMSP3430Data(m, WR_DEM, 0x00, 0x20, 0x00, 0x01); /* possibly wrong */
- } else {
- SetMSP3430Data(m, WR_DEM, 0x00, 0x30, 0x20, 0x03|0x08);
- /* standard selection is M-BTSC-Stereo */
- SetMSP3430Data(m, WR_DEM, 0x00, 0x20, 0x00, 0x20);
- }
-
- switch(m->connector){
- case MSP3430_CONNECTOR_1:
- SetMSP3430Data(m, WR_DSP, 0x00, 0x08, 0x03, 0x20);
- break;
- case MSP3430_CONNECTOR_2:
- /* this has not been checked yet.. could be bogus */
- /* SCART Input Prescale: 0 dB gain */
- SetMSP3430Data(m, WR_DSP, 0x00, 0x0d, 0x19, 0x00);
- SetMSP3430Data(m, WR_DSP, 0x00, 0x08, 0x02, 0x20);
- break;
- case MSP3430_CONNECTOR_3:
- default:
- /* SCART Input Prescale: 0 dB gain */
- SetMSP3430Data(m, WR_DSP, 0x00, 0x0d, 0x19, 0x00);
-
- SetMSP3430Data(m, WR_DSP, 0x00, 0x08, 0x02, 0x20);
- break;
- }
-
- switch(m->standard){
- case MSP3430_PAL:
- SetMSP3430Data(m, WR_DSP, 0x00, 0x0e, 0x24, 0x03);
- SetMSP3430Data(m, WR_DSP, 0x00, 0x10, 0x00, 0x5a);
- SetMSP3430Data(m, WR_DEM, 0x00, 0x20, 0x00, 0x03);
- /* Set volume to FAST_MUTE. */
- SetMSP3430Data(m, WR_DSP, 0x00, 0x00, 0xFF, 0x00);
- break;
- case MSP3430_PAL_DK1:
- SetMSP3430Data(m, WR_DSP, 0x00, 0x0e, 0x24, 0x03);
- SetMSP3430Data(m, WR_DSP, 0x00, 0x10, 0x00, 0x5a);
- SetMSP3430Data(m, WR_DEM, 0x00, 0x20, 0x00, 0x04);
- /* Set volume to FAST_MUTE. */
- SetMSP3430Data(m, WR_DSP, 0x00, 0x00, 0xFF, 0x00);
- break;
- case MSP3430_SECAM: /* is this right ? */
- case MSP3430_NTSC:
- /* Write to DSP, register 0x000E, (prescale FM/FM matrix) */
- SetMSP3430Data(m, WR_DSP, 0x00, 0x0e, 0x24, 0x03);
-
- /* Set volume to FAST_MUTE. */
- SetMSP3430Data(m, WR_DSP, 0x00, 0x00, 0xFF, 0x00);
- break;
- }
+#if __MSPDEBUG__ > 1
+ xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO,
+ "InitMSP34xxG(m->connector=%d, m->standard=%d, m->chip_family=%d)\n",
+ m->connector, m->standard, m->chip_family);
+#endif
+ /* Reset MSP3430 */
+ SetMSP3430Control(m, 0x00, 0x80, 0x00);
+ /* Set it back to normal operation */
+ SetMSP3430Control(m, 0x00, 0x00, 0x00);
+
+ /*set MODUS register */
+ /* bits: 0 - automatic sound detection */
+ /* 1 - enable STATUS change */
+ /* 12 - detect 6.5 Mhz carrier as D/K1, D/K2 or D/K NICAM (does not seem to work ) */
+ /* 13 - detect 4.5 Mhz carrier as BTSC */
+ if ((m->standard & 0xff) == MSP3430_PAL) {
+ SetMSP3430Data(m, WR_DEM, 0x00, 0x30, 0x30, 0x03 | 0x08); /* make O_ pins tristate */
+ /* PAL standard */
+ SetMSP3430Data(m, WR_DEM, 0x00, 0x20, 0x00, 0x01); /* possibly wrong */
+ }
+ else {
+ SetMSP3430Data(m, WR_DEM, 0x00, 0x30, 0x20, 0x03 | 0x08);
+ /* standard selection is M-BTSC-Stereo */
+ SetMSP3430Data(m, WR_DEM, 0x00, 0x20, 0x00, 0x20);
+ }
+
+ switch (m->connector) {
+ case MSP3430_CONNECTOR_1:
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x08, 0x03, 0x20);
+ break;
+ case MSP3430_CONNECTOR_2:
+ /* this has not been checked yet.. could be bogus */
+ /* SCART Input Prescale: 0 dB gain */
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x0d, 0x19, 0x00);
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x08, 0x02, 0x20);
+ break;
+ case MSP3430_CONNECTOR_3:
+ default:
+ /* SCART Input Prescale: 0 dB gain */
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x0d, 0x19, 0x00);
+
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x08, 0x02, 0x20);
+ break;
+ }
+
+ switch (m->standard) {
+ case MSP3430_PAL:
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x0e, 0x24, 0x03);
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x10, 0x00, 0x5a);
+ SetMSP3430Data(m, WR_DEM, 0x00, 0x20, 0x00, 0x03);
+ /* Set volume to FAST_MUTE. */
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x00, 0xFF, 0x00);
+ break;
+ case MSP3430_PAL_DK1:
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x0e, 0x24, 0x03);
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x10, 0x00, 0x5a);
+ SetMSP3430Data(m, WR_DEM, 0x00, 0x20, 0x00, 0x04);
+ /* Set volume to FAST_MUTE. */
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x00, 0xFF, 0x00);
+ break;
+ case MSP3430_SECAM: /* is this right ? */
+ case MSP3430_NTSC:
+ /* Write to DSP, register 0x000E, (prescale FM/FM matrix) */
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x0e, 0x24, 0x03);
+
+ /* Set volume to FAST_MUTE. */
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x00, 0xFF, 0x00);
+ break;
+ }
}
@@ -426,41 +467,40 @@ void InitMSP34xxG(MSP3430Ptr m)
| specific functions for all MSP34x5D chips
|----------------------------------------------------------------*/
-void InitMSP34x5D(MSP3430Ptr m)
+void
+InitMSP34x5D(MSP3430Ptr m)
{
-int count;
-CARD8 high,low;
-CARD16 result,standard;
-CARD16 peak;
-
-
-if (m->c_format==MSPFORMAT_UNKNOWN) ResetMSP3430(m);
-else {
- /*mute volume*/
- SetMSP3430Data (m, WR_DSP, 0x00, 0x00, 0x00, 0x00);
-}
-
-
+ int count;
+ CARD8 high, low;
+ CARD16 result, standard;
+ CARD16 peak;
+
+ if (m->c_format == MSPFORMAT_UNKNOWN)
+ ResetMSP3430(m);
+ else {
+ /*mute volume */
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x00, 0x00, 0x00);
+ }
- switch(m->connector){
- case MSP3430_CONNECTOR_2:
- case MSP3430_CONNECTOR_3:
- if (m->c_format!=MSPFORMAT_SCART) {
- /* SCART Input Prescale: 0 dB gain */
- SetMSP3430Data (m, WR_DSP, 0x00, 0x0d, 0x19, 0x00);
- /* this has not been checked yet.. could be bogus */
- m->c_format=MSPFORMAT_SCART; /*stereo*/
- }
- break;
- case MSP3430_CONNECTOR_1:
- default:
-
- switch ( m->standard & 0x00ff ) {
- case MSP3430_PAL:
- switch( m->standard ) {
- case MSP3430_PAL_DK1:
- standard=MSPSTANDARD_FM_DK1;
- break;
+ switch (m->connector) {
+ case MSP3430_CONNECTOR_2:
+ case MSP3430_CONNECTOR_3:
+ if (m->c_format != MSPFORMAT_SCART) {
+ /* SCART Input Prescale: 0 dB gain */
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x0d, 0x19, 0x00);
+ /* this has not been checked yet.. could be bogus */
+ m->c_format = MSPFORMAT_SCART; /*stereo */
+ }
+ break;
+ case MSP3430_CONNECTOR_1:
+ default:
+
+ switch (m->standard & 0x00ff) {
+ case MSP3430_PAL:
+ switch (m->standard) {
+ case MSP3430_PAL_DK1:
+ standard = MSPSTANDARD_FM_DK1;
+ break;
/* case MSP3430_PAL_DK2:
standard=MSPSTANDARD_FM_DK2;
break;
@@ -469,259 +509,271 @@ else {
standard=MSPSTANDARD_AUTO;
break;
*/
- default:
- standard=MSPSTANDARD_AUTO;
- }
- break;
- case MSP3430_SECAM:
- standard=MSPSTANDARD_AUTO;
- case MSP3430_NTSC:
- /* Only MSP34x5 supported format - Korean NTSC-M*/
- standard=MSPSTANDARD_FM_M;
- default:
- standard=MSPSTANDARD_AUTO;
- }
-
- /*no NICAM support in MSP3410D - force to autodetect*/
- if ((m->chip_id==0x405) && (standard>=MSPSTANDARD_NICAM_BG))
- standard=MSPSTANDARD_AUTO;
-
- if (m->c_standard != standard) {
-
- SetMSP3430Data (m, WR_DEM, 0x00, 0x20, standard>>8, standard & 0xFF);
- if (standard==MSPSTANDARD_AUTO) {
- count = 50; /* time shouldn't exceed 1s, just in case */
- do {
- usleep(20000);
- GetMSP3430Data (m, RD_DEM, 0x00, 0x7e, &high, &low);
- result = ( high << 8 ) | low;
- --count;
- } while( result > 0x07ff && count > 0 );
-
- if ((result > MSPSTANDARD_AUTO))
- standard=result;
- else standard=MSPSTANDARD_UNKNOWN;
+ default:
+ standard = MSPSTANDARD_AUTO;
+ }
+ break;
+ case MSP3430_SECAM:
+ standard = MSPSTANDARD_AUTO;
+ case MSP3430_NTSC:
+ /* Only MSP34x5 supported format - Korean NTSC-M */
+ standard = MSPSTANDARD_FM_M;
+ default:
+ standard = MSPSTANDARD_AUTO;
+ }
+
+ /*no NICAM support in MSP3410D - force to autodetect */
+ if ((m->chip_id == 0x405) && (standard >= MSPSTANDARD_NICAM_BG))
+ standard = MSPSTANDARD_AUTO;
+
+ if (m->c_standard != standard) {
+
+ SetMSP3430Data(m, WR_DEM, 0x00, 0x20, standard >> 8,
+ standard & 0xFF);
+ if (standard == MSPSTANDARD_AUTO) {
+ count = 50; /* time shouldn't exceed 1s, just in case */
+ do {
+ usleep(20000);
+ GetMSP3430Data(m, RD_DEM, 0x00, 0x7e, &high, &low);
+ result = (high << 8) | low;
+ --count;
+ } while (result > 0x07ff && count > 0);
+
+ if ((result > MSPSTANDARD_AUTO))
+ standard = result;
+ else
+ standard = MSPSTANDARD_UNKNOWN;
#if __MSPDEBUG__ > 1
- xf86DrvMsg(m->d.pI2CBus->scrnIndex,X_INFO,"Detected audio standard: %d\n",result);
-#endif
- /* result = MSPSTANDARD_NICAM_L can be one of:
- SECAM_L - MSPSTANDARD_NICAM_L
- D/K1 - MSPSTANDARD_FM_DK1
- D/K2 - MSPSTANDARD_FM_DK2
- D/K-NICAM - MSPSTANDARD_NICAM_DK*/
- if( standard == MSPSTANDARD_NICAM_L ) {
- if ((m->standard & 0x00ff)==MSP3430_PAL) {
- /* force PAL D/K */
- standard=MSPSTANDARD_FM_DK1;
- SetMSP3430Data (m, WR_DEM, 0x00, 0x20, standard>>8, standard & 0xFF);
+ xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO,
+ "Detected audio standard: %d\n", result);
+#endif
+ /* result = MSPSTANDARD_NICAM_L can be one of:
+ SECAM_L - MSPSTANDARD_NICAM_L
+ D/K1 - MSPSTANDARD_FM_DK1
+ D/K2 - MSPSTANDARD_FM_DK2
+ D/K-NICAM - MSPSTANDARD_NICAM_DK */
+ if (standard == MSPSTANDARD_NICAM_L) {
+ if ((m->standard & 0x00ff) == MSP3430_PAL) {
+ /* force PAL D/K */
+ standard = MSPSTANDARD_FM_DK1;
+ SetMSP3430Data(m, WR_DEM, 0x00, 0x20, standard >> 8,
+ standard & 0xFF);
#if __MSPDEBUG__ > 1
- xf86DrvMsg(m->d.pI2CBus->scrnIndex,X_INFO, "Detected 6.5MHz carrier - forced to D/K1 !!!\n" );
+ xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO,
+ "Detected 6.5MHz carrier - forced to D/K1 !!!\n");
#endif
- }
- }
- }
- m->c_standard=standard;
- } /*end - standard changed*/
- else {
- if (standard<MSPSTANDARD_NICAM_BG) {
- /* get old value of ident. mode register*/
- GetMSP3430Data (m, RD_DSP, 0x00, 0x15, &high, &low);
- /* reset Ident-Filter */
- SetMSP3430Data (m, WR_DSP, 0x00, 0x14, 0x00, 0x3F);
- /* put back old value to ident. mode register*/
- SetMSP3430Data (m, WR_DSP, 0x00, 0x14, 0x00, low);
- }
- }
-
- if (standard<=MSPSTANDARD_AUTO) {
- m->c_format=MSPFORMAT_1xFM;
- }
- else if (standard<MSPSTANDARD_NICAM_BG) {
- /* set FM prescale */
- SetMSP3430Data (m, WR_DSP, 0x00, 0x0e, 0x30, 0);
- /* set FM deemphasis*/
- SetMSP3430Data (m, WR_DSP, 0x00, 0x0f, ((standard==MSPSTANDARD_FM_M)?0:1), 0);
-
- /* check if FM2 carrier is present */
- /*turn off FM DC Notch*/
- SetMSP3430Data (m, WR_DSP, 0x00, 0x17, 0x00, 0x3f);
- /*matrix source for Quasi-Peak Detector - stereo: ch2->L ch1->R*/
- SetMSP3430Data (m, WR_DSP, 0x00, 0x0c, 0x00, 0x20);
-
- mpause(250);
- GetMSP3430Data (m, RD_DSP, 0x00, 0x1A, &high, &low);
- peak = (high << 8) | low;
+ }
+ }
+ }
+ m->c_standard = standard;
+ } /*end - standard changed */
+ else {
+ if (standard < MSPSTANDARD_NICAM_BG) {
+ /* get old value of ident. mode register */
+ GetMSP3430Data(m, RD_DSP, 0x00, 0x15, &high, &low);
+ /* reset Ident-Filter */
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x14, 0x00, 0x3F);
+ /* put back old value to ident. mode register */
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x14, 0x00, low);
+ }
+ }
+
+ if (standard <= MSPSTANDARD_AUTO) {
+ m->c_format = MSPFORMAT_1xFM;
+ }
+ else if (standard < MSPSTANDARD_NICAM_BG) {
+ /* set FM prescale */
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x0e, 0x30, 0);
+ /* set FM deemphasis */
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x0f,
+ ((standard == MSPSTANDARD_FM_M) ? 0 : 1), 0);
+
+ /* check if FM2 carrier is present */
+ /*turn off FM DC Notch */
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x17, 0x00, 0x3f);
+ /*matrix source for Quasi-Peak Detector - stereo: ch2->L ch1->R */
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x0c, 0x00, 0x20);
+
+ mpause(250);
+ GetMSP3430Data(m, RD_DSP, 0x00, 0x1A, &high, &low);
+ peak = (high << 8) | low;
#if __MSPDEBUG__ > 1
- xf86DrvMsg(m->d.pI2CBus->scrnIndex,X_INFO,"Second carrier Quasi-Peak detection: %d\n",peak);
-#endif
- /*turn on FM DC Notch*/
- SetMSP3430Data (m, WR_DSP, 0x00, 0x17, 0x00, 0x00);
-
- if (peak<5) {
- /* if second carrier not detected - only mono from first carrier*/
- m->c_format=MSPFORMAT_1xFM;
- }
- else {
- m->c_format=MSPFORMAT_2xFM;
- /*start of FM identification process - FM_WAIT
- wait at least 0.5s - used 1s - gives beter resolution*/
- mpause(1000);
- }
- }
- else {
- if (standard==MSPSTANDARD_NICAM_L) {
- m->c_format=MSPFORMAT_NICAM_AM;
- /* set AM prescale */
- SetMSP3430Data (m, WR_DSP, 0x00, 0x0e, 0x7C, 0);
- }
- else {
- m->c_format=MSPFORMAT_NICAM_FM;
- /* set FM prescale */
- SetMSP3430Data (m, WR_DSP, 0x00, 0x0e, 0x30, 0);
- }
- /* set FM deemphasis*/
- SetMSP3430Data (m, WR_DSP, 0x00, 0x0f, 0x00, 0);
- /* set NICAM prescale to 0dB */
- SetMSP3430Data (m, WR_DSP, 0x00, 0x10, 0x20, 0);
- }
-
- break;
- } /*end - case conector*/
+ xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO,
+ "Second carrier Quasi-Peak detection: %d\n", peak);
+#endif
+ /*turn on FM DC Notch */
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x17, 0x00, 0x00);
+
+ if (peak < 5) {
+ /* if second carrier not detected - only mono from first carrier */
+ m->c_format = MSPFORMAT_1xFM;
+ }
+ else {
+ m->c_format = MSPFORMAT_2xFM;
+ /*start of FM identification process - FM_WAIT
+ wait at least 0.5s - used 1s - gives beter resolution */
+ mpause(1000);
+ }
+ }
+ else {
+ if (standard == MSPSTANDARD_NICAM_L) {
+ m->c_format = MSPFORMAT_NICAM_AM;
+ /* set AM prescale */
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x0e, 0x7C, 0);
+ }
+ else {
+ m->c_format = MSPFORMAT_NICAM_FM;
+ /* set FM prescale */
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x0e, 0x30, 0);
+ }
+ /* set FM deemphasis */
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x0f, 0x00, 0);
+ /* set NICAM prescale to 0dB */
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x10, 0x20, 0);
+ }
+
+ break;
+ } /*end - case conector */
CheckModeMSP34x5D(m);
-
- /* Set volume to FAST_MUTE. */
- /*SetMSP3430Data(m, WR_DSP, 0x00, 0x00, 0xFF, 0x00);*/
- /*set volume*/
- MSP3430SetVolume(m,m->volume);
-
- __MSPBEEP
-
-
-} /* EnableMSP34x5D ()... */
-
+ /* Set volume to FAST_MUTE. */
+ /*SetMSP3430Data(m, WR_DSP, 0x00, 0x00, 0xFF, 0x00); */
+ /*set volume */
+ MSP3430SetVolume(m, m->volume);
+__MSPBEEP} /* EnableMSP34x5D ()... */
-void CheckModeMSP34x5D(MSP3430Ptr m) {
- const char stereo_on=25;
- const char stereo_off=20;
- const char dual_on=-stereo_on;
- const char dual_off=-stereo_off;
+void
+CheckModeMSP34x5D(MSP3430Ptr m)
+{
+ const char stereo_on = 25;
+ const char stereo_off = 20;
+ const char dual_on = -stereo_on;
+ const char dual_off = -stereo_off;
char detect;
CARD8 matrix, fmmatrix, source, high, low;
- fmmatrix=0; /*no matrix*/
- source=0; /*FM*/
- switch (m->c_format) {
- case MSPFORMAT_NICAM_FM:
- case MSPFORMAT_NICAM_AM:
- case MSPFORMAT_SCART:
- source=( (m->c_format == MSPFORMAT_SCART)?2:1 );
- switch (m->mode) {
- case MSPMODE_MONO:
- matrix=0x30; /*MONO*/
- break;
- case MSPMODE_A:
- matrix=0x00; /*A*/
- break;
- case MSPMODE_B:
- matrix=0x10; /*B*/
- break;
- default:
- matrix=0x20; /*STEREO*/
- break;
- }
- break;
- default:
- case MSPFORMAT_1xFM:
- matrix=0x00; /*A*/
- break;
- case MSPFORMAT_2xFM:
- switch (m->mode) {
- case MSPMODE_MONO:
- matrix=0x30; /*MONO*/
- break;
- case MSPMODE_STEREO:
- matrix=0x20; /*STEREO*/
- fmmatrix=((m->c_standard==MSPSTANDARD_FM_M)?2:1);
- break;
- case MSPMODE_AB:
- matrix=0x20; /*STEREO*/
- break;
- case MSPMODE_A:
- matrix=0x00; /*A*/
- break;
- case MSPMODE_B:
- matrix=0x10; /*B*/
- break;
- default:
- /*FM_IDENT_CHECK*/
- GetMSP3430Data (m, RD_DSP, 0x00, 0x18, &high, &low);
- detect=(char)high;
+ fmmatrix = 0; /*no matrix */
+ source = 0;
+ /*FM*/ switch (m->c_format) {
+ case MSPFORMAT_NICAM_FM:
+ case MSPFORMAT_NICAM_AM:
+ case MSPFORMAT_SCART:
+ source = ((m->c_format == MSPFORMAT_SCART) ? 2 : 1);
+ switch (m->mode) {
+ case MSPMODE_MONO:
+ matrix = 0x30;
+ /*MONO*/ break;
+ case MSPMODE_A:
+ matrix = 0x00;
+ /*A*/ break;
+ case MSPMODE_B:
+ matrix = 0x10;
+ /*B*/ break;
+ default:
+ matrix = 0x20;
+ /*STEREO*/ break;
+ }
+ break;
+ default:
+ case MSPFORMAT_1xFM:
+ matrix = 0x00;
+ /*A*/ break;
+ case MSPFORMAT_2xFM:
+ switch (m->mode) {
+ case MSPMODE_MONO:
+ matrix = 0x30;
+ /*MONO*/ break;
+ case MSPMODE_STEREO:
+ matrix = 0x20;
+ /*STEREO*/ fmmatrix = ((m->c_standard == MSPSTANDARD_FM_M) ? 2 : 1);
+ break;
+ case MSPMODE_AB:
+ matrix = 0x20;
+ /*STEREO*/ break;
+ case MSPMODE_A:
+ matrix = 0x00;
+ /*A*/ break;
+ case MSPMODE_B:
+ matrix = 0x10;
+ /*B*/ break;
+ default:
+ /*FM_IDENT_CHECK */
+ GetMSP3430Data(m, RD_DSP, 0x00, 0x18, &high, &low);
+ detect = (char) high;
#if __MSPDEBUG__ > 1
- xf86DrvMsg(m->d.pI2CBus->scrnIndex,X_INFO,"Stereo Detection Register: %d\n",detect);
+ xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO,
+ "Stereo Detection Register: %d\n", detect);
#endif
- if (detect>=((m->c_mode==MSPMODE_STEREO)?stereo_off:stereo_on)) {
- m->c_mode=MSPMODE_STEREO;
- matrix=0x20; /*STEREO*/
- fmmatrix=((m->c_standard==MSPSTANDARD_FM_M)?2:1);
- }
- else if (detect<=((m->c_mode==MSPMODE_AB)?dual_off:dual_on)) {
- m->c_mode=MSPMODE_AB;
- switch (m->mode) {
- case MSPMODE_STEREO_AB: matrix=0x20; break;
- case MSPMODE_STEREO_B: matrix=0x10; break;
- default:
- case MSPMODE_A: matrix=0x00; break;
- }
- }
- else {
- m->c_mode=MSPMODE_MONO;
- matrix=0x30; /*MONO*/
- }
- break;
- } /* end - case mode*/
- break;
+ if (detect >=
+ ((m->c_mode == MSPMODE_STEREO) ? stereo_off : stereo_on)) {
+ m->c_mode = MSPMODE_STEREO;
+ matrix = 0x20;
+ /*STEREO*/
+ fmmatrix = ((m->c_standard == MSPSTANDARD_FM_M) ? 2 : 1);
+ }
+ else if (detect <= ((m->c_mode == MSPMODE_AB) ? dual_off : dual_on)) {
+ m->c_mode = MSPMODE_AB;
+ switch (m->mode) {
+ case MSPMODE_STEREO_AB:
+ matrix = 0x20;
+ break;
+ case MSPMODE_STEREO_B:
+ matrix = 0x10;
+ break;
+ default:
+ case MSPMODE_A:
+ matrix = 0x00;
+ break;
+ }
+ }
+ else {
+ m->c_mode = MSPMODE_MONO;
+ matrix = 0x30;
+ /*MONO*/}
+ break;
+ } /* end - case mode */
+ break;
}
if (m->c_fmmatrix != fmmatrix) {
- GetMSP3430Data (m, RD_DSP, 0x00, 0x0e, &high, &low);
- SetMSP3430Data (m, WR_DSP, 0x00, 0x0e, high, fmmatrix);
- m->c_fmmatrix = fmmatrix;
+ GetMSP3430Data(m, RD_DSP, 0x00, 0x0e, &high, &low);
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x0e, high, fmmatrix);
+ m->c_fmmatrix = fmmatrix;
}
if ((m->c_matrix != matrix) || (m->c_source != source)) {
- /*set chanel source and matrix for loudspeaker*/
- SetMSP3430Data (m, WR_DSP, 0x00, 0x08, source, matrix);
-
- m->c_matrix = matrix;
- m->c_source = source;
+ /*set chanel source and matrix for loudspeaker */
+ SetMSP3430Data(m, WR_DSP, 0x00, 0x08, source, matrix);
+
+ m->c_matrix = matrix;
+ m->c_source = source;
}
- if ( ((m->c_format) & 0xF0) == MSPFORMAT_NICAM)
- SetMSP3430Data (m, WR_DEM, 0x00, 0x21, 0, 1);
+ if (((m->c_format) & 0xF0) == MSPFORMAT_NICAM)
+ SetMSP3430Data(m, WR_DEM, 0x00, 0x21, 0, 1);
#if __MSPDEBUG__ > 0
- char *msg;
- switch (matrix) {
- case 0x30: /*MONO*/
- msg="MONO";
- break;
- case 0x00: /*LEFT*/
- msg="MONO/CHANNEL_1";
- break;
- case 0x10: /*RIGHT*/
- msg="MONO/CHANNEL_2";
- break;
- case 0x20: /*LEFT*/
- msg="STEREO";
- break;
- default:
- msg="unknown";
- break;
- }
- xf86DrvMsg(m->d.pI2CBus->scrnIndex,X_INFO,"Audio mode set to: %s\n",msg);
+ char *msg;
+
+ switch (matrix) {
+ case 0x30:
+ /*MONO*/ msg = "MONO";
+ break;
+ case 0x00:
+ /*LEFT*/ msg = "MONO/CHANNEL_1";
+ break;
+ case 0x10:
+ /*RIGHT*/ msg = "MONO/CHANNEL_2";
+ break;
+ case 0x20:
+ /*LEFT*/ msg = "STEREO";
+ break;
+ default:
+ msg = "unknown";
+ break;
+ }
+ xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO, "Audio mode set to: %s\n", msg);
#endif
}
-
diff --git a/xorg-server/hw/xfree86/i2c/msp3430_module.c b/xorg-server/hw/xfree86/i2c/msp3430_module.c
index c5c24635f..e177efe7f 100644
--- a/xorg-server/hw/xfree86/i2c/msp3430_module.c
+++ b/xorg-server/hw/xfree86/i2c/msp3430_module.c
@@ -1,25 +1,24 @@
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Module.h"
-
-static XF86ModuleVersionInfo msp3430VersRec =
-{
- "msp3430",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 0, 0,
- ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */
- ABI_VIDEODRV_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0}
-};
-
-_X_EXPORT XF86ModuleData msp3430ModuleData = {
- &msp3430VersRec,
- NULL,
- NULL
-};
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Module.h"
+
+static XF86ModuleVersionInfo msp3430VersRec = {
+ "msp3430",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_NONE,
+ {0, 0, 0, 0}
+};
+
+_X_EXPORT XF86ModuleData msp3430ModuleData = {
+ &msp3430VersRec,
+ NULL,
+ NULL
+};
diff --git a/xorg-server/hw/xfree86/i2c/tda8425.c b/xorg-server/hw/xfree86/i2c/tda8425.c
index abbbb2a03..051249b8a 100644
--- a/xorg-server/hw/xfree86/i2c/tda8425.c
+++ b/xorg-server/hw/xfree86/i2c/tda8425.c
@@ -1,78 +1,83 @@
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86i2c.h"
-#include "tda8425.h"
-#include "i2c_def.h"
-
-#define TDA8425(a,b) { \
- data[0]=a; \
- data[1]=b; \
- I2C_WriteRead(&(t->d), data, 2, NULL, 0); \
- }
-
-TDA8425Ptr Detect_tda8425(I2CBusPtr b, I2CSlaveAddr addr, Bool force)
-{
- TDA8425Ptr t;
-
- t = calloc(1, sizeof(TDA8425Rec));
- if(t == NULL) return NULL;
- t->d.DevName = "TDA8425 BTSC Stereo Audio Processor";
- t->d.SlaveAddr = addr;
- t->d.pI2CBus = b;
- t->d.NextDev = NULL;
- t->d.StartTimeout = b->StartTimeout;
- t->d.BitTimeout = b->BitTimeout;
- t->d.AcknTimeout = b->AcknTimeout;
- t->d.ByteTimeout = b->ByteTimeout;
-
- if(!force && !I2CProbeAddress(b, addr))
- {
- free(t);
- return NULL;
- }
-
- /* set default parameters */
- if(!I2CDevInit(&(t->d)))
- {
- free(t);
- return NULL;
- }
-
- return t;
-}
-
-Bool tda8425_init(TDA8425Ptr t)
-{
- t->stereo = 3; /* 3 = Spacial 2 = Linear 1 = Pseudo 0 = Forced mono */
- t->v_left = 0xFF; /* FF - C0 */
- t->v_right = 0xFF; /* FF - C0 */
- t->bass = 0xF6; /* 0xFF - 0xF0 */
- t->treble = 0xF6; /* 0xFF - 0xF0 */
- t->src_sel = 3; /* 3 - stereo */
- t->mute = TRUE;
- t->mux = 0; /* 0 - source one, 1 -source 2 */
-
- tda8425_setaudio(t);
- return TRUE;
-}
-
-void tda8425_setaudio(TDA8425Ptr t)
-{
- I2CByte data[2];
-
- TDA8425(0x00, t->v_left );
- TDA8425(0x01, t->v_right );
- TDA8425(0x02, t->bass );
- TDA8425(0x03, t->treble );
- TDA8425(0x08, 0xC0 | (t->mute ? 0x20 : 0x0) | (t->stereo << 3) | (t->src_sel << 1) |
- t->mux);
-}
-
-void tda8425_mute(TDA8425Ptr t, Bool mute)
-{
- t->mute = mute;
- tda8425_setaudio(t);
-}
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86i2c.h"
+#include "tda8425.h"
+#include "i2c_def.h"
+
+#define TDA8425(a,b) { \
+ data[0]=a; \
+ data[1]=b; \
+ I2C_WriteRead(&(t->d), data, 2, NULL, 0); \
+ }
+
+TDA8425Ptr
+Detect_tda8425(I2CBusPtr b, I2CSlaveAddr addr, Bool force)
+{
+ TDA8425Ptr t;
+
+ t = calloc(1, sizeof(TDA8425Rec));
+ if (t == NULL)
+ return NULL;
+ t->d.DevName = "TDA8425 BTSC Stereo Audio Processor";
+ t->d.SlaveAddr = addr;
+ t->d.pI2CBus = b;
+ t->d.NextDev = NULL;
+ t->d.StartTimeout = b->StartTimeout;
+ t->d.BitTimeout = b->BitTimeout;
+ t->d.AcknTimeout = b->AcknTimeout;
+ t->d.ByteTimeout = b->ByteTimeout;
+
+ if (!force && !I2CProbeAddress(b, addr)) {
+ free(t);
+ return NULL;
+ }
+
+ /* set default parameters */
+ if (!I2CDevInit(&(t->d))) {
+ free(t);
+ return NULL;
+ }
+
+ return t;
+}
+
+Bool
+tda8425_init(TDA8425Ptr t)
+{
+ t->stereo = 3; /* 3 = Spacial 2 = Linear 1 = Pseudo 0 = Forced mono */
+ t->v_left = 0xFF; /* FF - C0 */
+ t->v_right = 0xFF; /* FF - C0 */
+ t->bass = 0xF6; /* 0xFF - 0xF0 */
+ t->treble = 0xF6; /* 0xFF - 0xF0 */
+ t->src_sel = 3; /* 3 - stereo */
+ t->mute = TRUE;
+ t->mux = 0; /* 0 - source one, 1 -source 2 */
+
+ tda8425_setaudio(t);
+ return TRUE;
+}
+
+void
+tda8425_setaudio(TDA8425Ptr t)
+{
+ I2CByte data[2];
+
+ TDA8425(0x00, t->v_left);
+ TDA8425(0x01, t->v_right);
+ TDA8425(0x02, t->bass);
+ TDA8425(0x03, t->treble);
+ TDA8425(0x08,
+ 0xC0 | (t->mute ? 0x20 : 0x0) | (t->stereo << 3) | (t->
+ src_sel << 1) |
+ t->mux);
+}
+
+void
+tda8425_mute(TDA8425Ptr t, Bool mute)
+{
+ t->mute = mute;
+ tda8425_setaudio(t);
+}
diff --git a/xorg-server/hw/xfree86/i2c/tda8425.h b/xorg-server/hw/xfree86/i2c/tda8425.h
index 9c33e7f60..e3dfb1384 100644
--- a/xorg-server/hw/xfree86/i2c/tda8425.h
+++ b/xorg-server/hw/xfree86/i2c/tda8425.h
@@ -4,17 +4,17 @@
#include "xf86i2c.h"
typedef struct {
- I2CDevRec d;
-
- int mux;
- int stereo;
- int v_left;
- int v_right;
- int bass;
- int treble;
- int src_sel;
- Bool mute;
- } TDA8425Rec, *TDA8425Ptr;
+ I2CDevRec d;
+
+ int mux;
+ int stereo;
+ int v_left;
+ int v_right;
+ int bass;
+ int treble;
+ int src_sel;
+ Bool mute;
+} TDA8425Rec, *TDA8425Ptr;
#define TDA8425_ADDR_1 0x82
@@ -22,13 +22,16 @@ typedef struct {
This is because tda8425 is write-only and complete implementation
of I2C protocol is not always available. Besides address there is no good
way to autodetect it so we have to _know_ it is there anyway */
-
+
#define xf86_Detect_tda8425 Detect_tda8425
-extern _X_EXPORT TDA8425Ptr Detect_tda8425(I2CBusPtr b, I2CSlaveAddr addr,Bool force);
+extern _X_EXPORT TDA8425Ptr Detect_tda8425(I2CBusPtr b, I2CSlaveAddr addr,
+ Bool force);
#define xf86_tda8425_init tda8425_init
extern _X_EXPORT Bool tda8425_init(TDA8425Ptr t);
+
#define xf86_tda8425_setaudio tda8425_setaudio
extern _X_EXPORT void tda8425_setaudio(TDA8425Ptr t);
+
#define xf86_tda8425_mute tda8425_mute
extern _X_EXPORT void tda8425_mute(TDA8425Ptr t, Bool mute);
diff --git a/xorg-server/hw/xfree86/i2c/tda8425_module.c b/xorg-server/hw/xfree86/i2c/tda8425_module.c
index 936281460..74c820f73 100644
--- a/xorg-server/hw/xfree86/i2c/tda8425_module.c
+++ b/xorg-server/hw/xfree86/i2c/tda8425_module.c
@@ -1,25 +1,24 @@
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Module.h"
-
-static XF86ModuleVersionInfo tda8425VersRec =
-{
- "tda8425",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 0, 0,
- ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */
- ABI_VIDEODRV_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0}
-};
-
-_X_EXPORT XF86ModuleData tda8425ModuleData = {
- &tda8425VersRec,
- NULL,
- NULL
-};
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Module.h"
+
+static XF86ModuleVersionInfo tda8425VersRec = {
+ "tda8425",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_NONE,
+ {0, 0, 0, 0}
+};
+
+_X_EXPORT XF86ModuleData tda8425ModuleData = {
+ &tda8425VersRec,
+ NULL,
+ NULL
+};
diff --git a/xorg-server/hw/xfree86/i2c/tda9850.c b/xorg-server/hw/xfree86/i2c/tda9850.c
index 5d794dfe5..c2ce6971f 100644
--- a/xorg-server/hw/xfree86/i2c/tda9850.c
+++ b/xorg-server/hw/xfree86/i2c/tda9850.c
@@ -1,112 +1,136 @@
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86i2c.h"
-#include "tda9850.h"
-#include "i2c_def.h"
-
-#define TDA9850(a,b) { \
- data[0]=a; \
- data[1]=b; \
- I2C_WriteRead(&(t->d), data, 2, NULL, 0); \
- }
-
-TDA9850Ptr Detect_tda9850(I2CBusPtr b, I2CSlaveAddr addr)
-{
- TDA9850Ptr t;
- I2CByte a;
-
- t = calloc(1, sizeof(TDA9850Rec));
- if(t == NULL) return NULL;
- switch(addr)
- {
- case TDA9850_ADDR_1:
- t->d.DevName = "TDA9850 BTSC Stereo+SAP Audio Processor";
- break;
- default:
- t->d.DevName = "Generic TDAxxxx";
- break;
- }
- t->d.SlaveAddr = addr;
- t->d.pI2CBus = b;
- t->d.NextDev = NULL;
- t->d.StartTimeout = b->StartTimeout;
- t->d.BitTimeout = b->BitTimeout;
- t->d.AcknTimeout = b->AcknTimeout;
- t->d.ByteTimeout = b->ByteTimeout;
-
- if(!I2C_WriteRead(&(t->d), NULL, 0, &a, 1))
- {
- free(t);
- return NULL;
- }
-
- /* set default parameters */
- if(!I2CDevInit(&(t->d)))
- {
- free(t);
- return NULL;
- }
-
- return t;
-}
-
-Bool tda9850_init(TDA9850Ptr t)
-{
- t->stereo = 1;
- t->sap = 0;
- t->mute = TRUE;
- t->sap_mute = TRUE;
- tda9850_setaudio(t);
- return TRUE;
-}
-
-void tda9850_setaudio(TDA9850Ptr t)
-{
-CARD8 data[2];
-
-if(t->mux==2)
-{
- TDA9850(0x04,0x0F); TDA9850(0x05,0x0F); TDA9850(0x06, 0x58);
- TDA9850(0x07,0x07); TDA9850(0x08,0x00);
- TDA9850(0x09,0x00); TDA9850(0x0A,0x03);
-} else
-{
- TDA9850(0x04,0x07); TDA9850(0x05,0x07);
- TDA9850(0x06,0x58); TDA9850(0x07,0x07);
- TDA9850(0x08,0x10); TDA9850(0x09,0x10);
- TDA9850(0x0A,0x03);
-}
-
-TDA9850(0x06,(t->stereo<<6)|(t->sap<<7)|(t->mute?0x8:0)|(t->sap_mute?0x10:0x0));
-}
-
-void tda9850_mute(TDA9850Ptr t, Bool mute)
-{
-CARD8 data[2];
-
-xf86DrvMsg(t->d.pI2CBus->scrnIndex, X_INFO, "tda9850_mute %s\n", mute ? "on" : "off");
-t->mute = mute;
-
-TDA9850(0x06,(t->stereo<<6)|(t->sap<<7)|(t->mute?0x8:0x0)|(t->sap_mute?0x10:0x0));
-}
-
-void tda9850_sap_mute(TDA9850Ptr t, Bool sap_mute)
-{
-CARD8 data[2];
-
-xf86DrvMsg(t->d.pI2CBus->scrnIndex, X_INFO, "tda9850_sap_mute %s\n", sap_mute ? "on" : "off");
-t->sap_mute = sap_mute;
-
-TDA9850(0x06,(t->stereo<<6)|(t->sap<<7)|(t->mute?0x8:0x0)|(t->sap_mute?0x10:0x0));
-}
-
-CARD16 tda9850_getstatus(TDA9850Ptr t)
-{
-CARD16 status;
-
-I2C_WriteRead(&(t->d), NULL, 0, (I2CByte *)&status, 2);
-return status;
-}
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86i2c.h"
+#include "tda9850.h"
+#include "i2c_def.h"
+
+#define TDA9850(a,b) { \
+ data[0]=a; \
+ data[1]=b; \
+ I2C_WriteRead(&(t->d), data, 2, NULL, 0); \
+ }
+
+TDA9850Ptr
+Detect_tda9850(I2CBusPtr b, I2CSlaveAddr addr)
+{
+ TDA9850Ptr t;
+ I2CByte a;
+
+ t = calloc(1, sizeof(TDA9850Rec));
+ if (t == NULL)
+ return NULL;
+ switch (addr) {
+ case TDA9850_ADDR_1:
+ t->d.DevName = "TDA9850 BTSC Stereo+SAP Audio Processor";
+ break;
+ default:
+ t->d.DevName = "Generic TDAxxxx";
+ break;
+ }
+ t->d.SlaveAddr = addr;
+ t->d.pI2CBus = b;
+ t->d.NextDev = NULL;
+ t->d.StartTimeout = b->StartTimeout;
+ t->d.BitTimeout = b->BitTimeout;
+ t->d.AcknTimeout = b->AcknTimeout;
+ t->d.ByteTimeout = b->ByteTimeout;
+
+ if (!I2C_WriteRead(&(t->d), NULL, 0, &a, 1)) {
+ free(t);
+ return NULL;
+ }
+
+ /* set default parameters */
+ if (!I2CDevInit(&(t->d))) {
+ free(t);
+ return NULL;
+ }
+
+ return t;
+}
+
+Bool
+tda9850_init(TDA9850Ptr t)
+{
+ t->stereo = 1;
+ t->sap = 0;
+ t->mute = TRUE;
+ t->sap_mute = TRUE;
+ tda9850_setaudio(t);
+ return TRUE;
+}
+
+void
+tda9850_setaudio(TDA9850Ptr t)
+{
+ CARD8 data[2];
+
+ if (t->mux == 2) {
+ TDA9850(0x04, 0x0F);
+ TDA9850(0x05, 0x0F);
+ TDA9850(0x06, 0x58);
+ TDA9850(0x07, 0x07);
+ TDA9850(0x08, 0x00);
+ TDA9850(0x09, 0x00);
+ TDA9850(0x0A, 0x03);
+ }
+ else {
+ TDA9850(0x04, 0x07);
+ TDA9850(0x05, 0x07);
+ TDA9850(0x06, 0x58);
+ TDA9850(0x07, 0x07);
+ TDA9850(0x08, 0x10);
+ TDA9850(0x09, 0x10);
+ TDA9850(0x0A, 0x03);
+ }
+
+ TDA9850(0x06,
+ (t->stereo << 6) | (t->sap << 7) | (t->mute ? 0x8 : 0) | (t->
+ sap_mute ?
+ 0x10 :
+ 0x0));
+}
+
+void
+tda9850_mute(TDA9850Ptr t, Bool mute)
+{
+ CARD8 data[2];
+
+ xf86DrvMsg(t->d.pI2CBus->scrnIndex, X_INFO, "tda9850_mute %s\n",
+ mute ? "on" : "off");
+ t->mute = mute;
+
+ TDA9850(0x06,
+ (t->stereo << 6) | (t->sap << 7) | (t->mute ? 0x8 : 0x0) | (t->
+ sap_mute
+ ? 0x10 :
+ 0x0));
+}
+
+void
+tda9850_sap_mute(TDA9850Ptr t, Bool sap_mute)
+{
+ CARD8 data[2];
+
+ xf86DrvMsg(t->d.pI2CBus->scrnIndex, X_INFO, "tda9850_sap_mute %s\n",
+ sap_mute ? "on" : "off");
+ t->sap_mute = sap_mute;
+
+ TDA9850(0x06,
+ (t->stereo << 6) | (t->sap << 7) | (t->mute ? 0x8 : 0x0) | (t->
+ sap_mute
+ ? 0x10 :
+ 0x0));
+}
+
+CARD16
+tda9850_getstatus(TDA9850Ptr t)
+{
+ CARD16 status;
+
+ I2C_WriteRead(&(t->d), NULL, 0, (I2CByte *) & status, 2);
+ return status;
+}
diff --git a/xorg-server/hw/xfree86/i2c/tda9850_module.c b/xorg-server/hw/xfree86/i2c/tda9850_module.c
index 239cff4fd..197d65a71 100644
--- a/xorg-server/hw/xfree86/i2c/tda9850_module.c
+++ b/xorg-server/hw/xfree86/i2c/tda9850_module.c
@@ -1,25 +1,24 @@
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Module.h"
-
-static XF86ModuleVersionInfo tda9850VersRec =
-{
- "tda9850",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 0, 0,
- ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */
- ABI_VIDEODRV_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0}
-};
-
-_X_EXPORT XF86ModuleData tda9850ModuleData = {
- &tda9850VersRec,
- NULL,
- NULL
-};
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Module.h"
+
+static XF86ModuleVersionInfo tda9850VersRec = {
+ "tda9850",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_NONE,
+ {0, 0, 0, 0}
+};
+
+_X_EXPORT XF86ModuleData tda9850ModuleData = {
+ &tda9850VersRec,
+ NULL,
+ NULL
+};
diff --git a/xorg-server/hw/xfree86/i2c/tda9885.c b/xorg-server/hw/xfree86/i2c/tda9885.c
index f22233995..fd859bde0 100644
--- a/xorg-server/hw/xfree86/i2c/tda9885.c
+++ b/xorg-server/hw/xfree86/i2c/tda9885.c
@@ -1,104 +1,100 @@
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86i2c.h"
-#include "tda9885.h"
-#include "i2c_def.h"
-
-
-TDA9885Ptr Detect_tda9885(I2CBusPtr b, I2CSlaveAddr addr)
-{
- TDA9885Ptr t;
- I2CByte a;
-
- t = calloc(1, sizeof(TDA9885Rec));
- if(t == NULL) return NULL;
- switch(addr)
- {
- case TDA9885_ADDR_1:
- case TDA9885_ADDR_2:
- case TDA9885_ADDR_3:
- case TDA9885_ADDR_4:
- t->d.DevName = "TDA9885 Alignment-free IF-PLL";
- break;
- default:
- t->d.DevName = "Generic TDAxxxx";
- break;
- }
- t->d.SlaveAddr = addr;
- t->d.pI2CBus = b;
- t->d.NextDev = NULL;
- t->d.StartTimeout = b->StartTimeout;
- t->d.BitTimeout = b->BitTimeout;
- t->d.AcknTimeout = b->AcknTimeout;
- t->d.ByteTimeout = b->ByteTimeout;
-
- if(!I2C_WriteRead(&(t->d), NULL, 0, &a, 1))
- {
- free(t);
- return NULL;
- }
-
- /* set default parameters */
- if(!I2CDevInit(&(t->d)))
- {
- free(t);
- return NULL;
- }
-
- return t;
-}
-
-Bool tda9885_init(TDA9885Ptr t)
-{
- t->forced_mute_audio=1;
- return TRUE;
-}
-
-void tda9885_getstatus(TDA9885Ptr t)
-{
-CARD8 value;
-
-I2C_WriteRead(&(t->d), NULL, 0, &value, 1);
-t->after_reset=value & 1;
-t->afc_status=(value >> 1) & 0xf;
-t->fm_carrier=(value>>5)& 1;
-t->vif_level=(value >>6) & 1;
-t->afc_win=(value >> 7)&1;
-}
-
-void tda9885_setparameters(TDA9885Ptr t)
-{
-CARD8 data[4];
-
-data[0]=0; /* start with subaddress 0 */
-data[1]=(t->sound_trap & 1) |
- ((t->auto_mute_fm &1)<<1) |
- ((t->carrier_mode &1)<<2) |
- ((t->modulation &3)<<3) |
- ((t->forced_mute_audio &1)<<5) |
- ((t->port1 & 1)<<6) |
- ((t->port2 &1)<<7); /* B data */
-data[2]=(t->top_adjustment & 0x1f) |
- ((t->deemphasis & 0x3)<<5) |
- ((t->audio_gain & 1) << 7); /* C data */
-data[3]=(t->standard_sound_carrier & 0x3) |
- ((t->standard_video_if & 0x07)<<2) |
- ((t->minimum_gain & 0x01)<<5) |
- ((t->gating & 0x01)<<6) |
- ((t->vif_agc & 0x01)<<7); /* E data */
-
-I2C_WriteRead(&(t->d), data, 4, NULL, 0);
-
-xf86DrvMsg(t->d.pI2CBus->scrnIndex,X_INFO,"TDA9885 setparam: B data: %x, C data: %x, E data: %x\n", data[1], data[2], data[3]);
-}
-
-void tda9885_dumpstatus(TDA9885Ptr t)
-{
-xf86DrvMsg(t->d.pI2CBus->scrnIndex,X_INFO,"TDA9885 status: after_reset=%d afc_status=%d (%3.1f kHz off) fm_carrier=%d vif_level=%d afc_win=%d %s\n",
- t->after_reset, t->afc_status,
- (t->afc_status<8)?-12.5-t->afc_status*25.0:-12.5+(16-t->afc_status)*25.0,
- t->fm_carrier, t->vif_level, t->afc_win, t->afc_win?"VCO in": "VCO out");
-}
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86i2c.h"
+#include "tda9885.h"
+#include "i2c_def.h"
+
+TDA9885Ptr
+Detect_tda9885(I2CBusPtr b, I2CSlaveAddr addr)
+{
+ TDA9885Ptr t;
+ I2CByte a;
+
+ t = calloc(1, sizeof(TDA9885Rec));
+ if (t == NULL)
+ return NULL;
+ switch (addr) {
+ case TDA9885_ADDR_1:
+ case TDA9885_ADDR_2:
+ case TDA9885_ADDR_3:
+ case TDA9885_ADDR_4:
+ t->d.DevName = "TDA9885 Alignment-free IF-PLL";
+ break;
+ default:
+ t->d.DevName = "Generic TDAxxxx";
+ break;
+ }
+ t->d.SlaveAddr = addr;
+ t->d.pI2CBus = b;
+ t->d.NextDev = NULL;
+ t->d.StartTimeout = b->StartTimeout;
+ t->d.BitTimeout = b->BitTimeout;
+ t->d.AcknTimeout = b->AcknTimeout;
+ t->d.ByteTimeout = b->ByteTimeout;
+
+ if (!I2C_WriteRead(&(t->d), NULL, 0, &a, 1)) {
+ free(t);
+ return NULL;
+ }
+
+ /* set default parameters */
+ if (!I2CDevInit(&(t->d))) {
+ free(t);
+ return NULL;
+ }
+
+ return t;
+}
+
+Bool
+tda9885_init(TDA9885Ptr t)
+{
+ t->forced_mute_audio = 1;
+ return TRUE;
+}
+
+void
+tda9885_getstatus(TDA9885Ptr t)
+{
+ CARD8 value;
+
+ I2C_WriteRead(&(t->d), NULL, 0, &value, 1);
+ t->after_reset = value & 1;
+ t->afc_status = (value >> 1) & 0xf;
+ t->fm_carrier = (value >> 5) & 1;
+ t->vif_level = (value >> 6) & 1;
+ t->afc_win = (value >> 7) & 1;
+}
+
+void
+tda9885_setparameters(TDA9885Ptr t)
+{
+ CARD8 data[4];
+
+ data[0] = 0; /* start with subaddress 0 */
+ data[1] = (t->sound_trap & 1) | ((t->auto_mute_fm & 1) << 1) | ((t->carrier_mode & 1) << 2) | ((t->modulation & 3) << 3) | ((t->forced_mute_audio & 1) << 5) | ((t->port1 & 1) << 6) | ((t->port2 & 1) << 7); /* B data */
+ data[2] = (t->top_adjustment & 0x1f) | ((t->deemphasis & 0x3) << 5) | ((t->audio_gain & 1) << 7); /* C data */
+ data[3] = (t->standard_sound_carrier & 0x3) | ((t->standard_video_if & 0x07) << 2) | ((t->minimum_gain & 0x01) << 5) | ((t->gating & 0x01) << 6) | ((t->vif_agc & 0x01) << 7); /* E data */
+
+ I2C_WriteRead(&(t->d), data, 4, NULL, 0);
+
+ xf86DrvMsg(t->d.pI2CBus->scrnIndex, X_INFO,
+ "TDA9885 setparam: B data: %x, C data: %x, E data: %x\n",
+ data[1], data[2], data[3]);
+}
+
+void
+tda9885_dumpstatus(TDA9885Ptr t)
+{
+ xf86DrvMsg(t->d.pI2CBus->scrnIndex, X_INFO,
+ "TDA9885 status: after_reset=%d afc_status=%d (%3.1f kHz off) fm_carrier=%d vif_level=%d afc_win=%d %s\n",
+ t->after_reset, t->afc_status,
+ (t->afc_status <
+ 8) ? -12.5 - t->afc_status * 25.0 : -12.5 + (16 -
+ t->afc_status) *
+ 25.0, t->fm_carrier, t->vif_level, t->afc_win,
+ t->afc_win ? "VCO in" : "VCO out");
+}
diff --git a/xorg-server/hw/xfree86/i2c/tda9885_module.c b/xorg-server/hw/xfree86/i2c/tda9885_module.c
index 51eaca7e8..e71bd6061 100644
--- a/xorg-server/hw/xfree86/i2c/tda9885_module.c
+++ b/xorg-server/hw/xfree86/i2c/tda9885_module.c
@@ -1,25 +1,24 @@
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Module.h"
-
-static XF86ModuleVersionInfo tda9885VersRec =
-{
- "tda9885",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 0, 0,
- ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */
- ABI_VIDEODRV_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0}
-};
-
-_X_EXPORT XF86ModuleData tda9885ModuleData = {
- &tda9885VersRec,
- NULL,
- NULL
-};
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Module.h"
+
+static XF86ModuleVersionInfo tda9885VersRec = {
+ "tda9885",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_NONE,
+ {0, 0, 0, 0}
+};
+
+_X_EXPORT XF86ModuleData tda9885ModuleData = {
+ &tda9885VersRec,
+ NULL,
+ NULL
+};
diff --git a/xorg-server/hw/xfree86/i2c/uda1380.c b/xorg-server/hw/xfree86/i2c/uda1380.c
index eebe127ed..87226877b 100644
--- a/xorg-server/hw/xfree86/i2c/uda1380.c
+++ b/xorg-server/hw/xfree86/i2c/uda1380.c
@@ -1,183 +1,196 @@
-/*************************************************************************************
- * Copyright (C) 2005 Bogdan D. bogdand@users.sourceforge.net
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this
- * software and associated documentation files (the "Software"), to deal in the Software
- * without restriction, including without limitation the rights to use, copy, modify,
- * merge, publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the author shall not be used in advertising or
- * otherwise to promote the sale, use or other dealings in this Software without prior written
- * authorization from the author.
- *
- ************************************************************************************/
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86i2c.h"
-#include "uda1380.h"
-#include "i2c_def.h"
-
-UDA1380Ptr Detect_uda1380(I2CBusPtr b, I2CSlaveAddr addr)
-{
- UDA1380Ptr t;
- I2CByte a;
-
- t = calloc(1, sizeof(UDA1380Rec));
- if(t == NULL) return NULL;
- switch(addr)
- {
- case UDA1380_ADDR_1:
- case UDA1380_ADDR_2:
- t->d.DevName = "UDA1380 Stereo audion coder-decoder";
- break;
- default:
- t->d.DevName = "Generic UDAxxxx";
- break;
- }
- t->d.SlaveAddr = addr;
- t->d.pI2CBus = b;
- t->d.NextDev = NULL;
- t->d.StartTimeout = b->StartTimeout;
- t->d.BitTimeout = b->BitTimeout;
- t->d.AcknTimeout = b->AcknTimeout;
- t->d.ByteTimeout = b->ByteTimeout;
-
- if(!I2C_WriteRead(&(t->d), NULL, 0, &a, 1))
- {
- free(t);
- return NULL;
- }
-
- /* set default parameters */
- if(!I2CDevInit(&(t->d)))
- {
- free(t);
- return NULL;
- }
-
- xf86DrvMsg(t->d.pI2CBus->scrnIndex,X_INFO,"UDA1380 stereo coder-decoder detected\n");
-
- return t;
-}
-
-Bool uda1380_init(UDA1380Ptr t)
-{
- CARD8 data[3];
- CARD16 tmp;
- Bool ret;
-
- /* Power control */
- data[0] = 0x02;
- tmp = (1 << 13) | (1 << 10) | ( 1 << 8) | (1 << 7) | (1 << 6) | (1 << 3) | (1 << 1);
- data[1] = (CARD8)((tmp >> 8) & 0xff);
- data[2] = (CARD8)(tmp & 0xff);
- ret = I2C_WriteRead(&(t->d), data, 3, NULL, 0);
- if (ret == FALSE)
- {
- xf86DrvMsg(t->d.pI2CBus->scrnIndex,X_INFO,"UDA1380 failed to initialize\n");
- return FALSE;
- }
-
- /* Analog mixer (AVC) */
- data[0] = 0x03;
- /* the analog mixer is muted initially */
- data[1] = 0x3f;
- data[2] = 0x3f;
- ret = I2C_WriteRead(&(t->d), data, 3, NULL, 0);
- if (ret == FALSE)
- {
- xf86DrvMsg(t->d.pI2CBus->scrnIndex,X_INFO,"UDA1380 failed to initialize\n");
- return FALSE;
- }
-
- xf86DrvMsg(t->d.pI2CBus->scrnIndex,X_INFO,"UDA1380 initialized\n");
-
- return TRUE;
-}
-
-void uda1380_shutdown(UDA1380Ptr t)
-{
- CARD8 data[3];
- Bool ret;
-
- /* Power control */
- data[0] = 0x02;
- data[1] = 0;
- data[2] = 0;
- ret = I2C_WriteRead(&(t->d), data, 3, NULL, 0);
- if (ret == FALSE)
- xf86DrvMsg(t->d.pI2CBus->scrnIndex,X_INFO,"UDA1380 failed to shutdown\n");
-}
-
-void uda1380_setvolume(UDA1380Ptr t, INT32 value)
-{
- CARD8 data[3];
- /*
- * We have to scale the value ranging from -1000 to 1000 to 0x2c to 0
- */
- CARD8 volume = 47 - (CARD8)((value + 1000) * 47 / 2000);
- Bool ret;
-
- t->analog_mixer_settings = ((volume << 8) & 0x3f00) | (volume & 0x3f);
-
- /* Analog mixer (AVC) */
- data[0] = 0x03;
- data[1] = volume & 0x3f;
- data[2] = volume & 0x3f;
- ret = I2C_WriteRead(&(t->d), data, 3, NULL, 0);
- if (ret == FALSE)
- xf86DrvMsg(t->d.pI2CBus->scrnIndex,X_INFO,"UDA1380 failed to set volume\n");
-}
-
-void uda1380_mute(UDA1380Ptr t, Bool mute)
-{
- CARD8 data[3];
- Bool ret;
-
- if (mute == TRUE)
- {
- /* Analog mixer (AVC) */
- data[0] = 0x03;
- data[1] = 0xff;
- data[2] = 0xff;
- ret = I2C_WriteRead(&(t->d), data, 3, NULL, 0);
- if (ret == FALSE)
- xf86DrvMsg(t->d.pI2CBus->scrnIndex,X_INFO,"UDA1380 failed to mute\n");
- }
- else
- {
- /* Analog mixer (AVC) */
- data[0] = 0x03;
- data[1] = (CARD8)((t->analog_mixer_settings >> 8) & 0x3f);
- data[2] = (CARD8)(t->analog_mixer_settings & 0x3f);
- ret = I2C_WriteRead(&(t->d), data, 3, NULL, 0);
- if (ret == FALSE)
- xf86DrvMsg(t->d.pI2CBus->scrnIndex,X_INFO,"UDA1380 failed to unmute\n");
- }
-}
-
-void uda1380_getstatus(UDA1380Ptr t)
-{
-}
-
-void uda1380_setparameters(UDA1380Ptr t)
-{
-}
-
-void uda1380_dumpstatus(UDA1380Ptr t)
-{
-}
+/*************************************************************************************
+ * Copyright (C) 2005 Bogdan D. bogdand@users.sourceforge.net
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this
+ * software and associated documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+ * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the author shall not be used in advertising or
+ * otherwise to promote the sale, use or other dealings in this Software without prior written
+ * authorization from the author.
+ *
+ ************************************************************************************/
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86i2c.h"
+#include "uda1380.h"
+#include "i2c_def.h"
+
+UDA1380Ptr
+Detect_uda1380(I2CBusPtr b, I2CSlaveAddr addr)
+{
+ UDA1380Ptr t;
+ I2CByte a;
+
+ t = calloc(1, sizeof(UDA1380Rec));
+ if (t == NULL)
+ return NULL;
+ switch (addr) {
+ case UDA1380_ADDR_1:
+ case UDA1380_ADDR_2:
+ t->d.DevName = "UDA1380 Stereo audion coder-decoder";
+ break;
+ default:
+ t->d.DevName = "Generic UDAxxxx";
+ break;
+ }
+ t->d.SlaveAddr = addr;
+ t->d.pI2CBus = b;
+ t->d.NextDev = NULL;
+ t->d.StartTimeout = b->StartTimeout;
+ t->d.BitTimeout = b->BitTimeout;
+ t->d.AcknTimeout = b->AcknTimeout;
+ t->d.ByteTimeout = b->ByteTimeout;
+
+ if (!I2C_WriteRead(&(t->d), NULL, 0, &a, 1)) {
+ free(t);
+ return NULL;
+ }
+
+ /* set default parameters */
+ if (!I2CDevInit(&(t->d))) {
+ free(t);
+ return NULL;
+ }
+
+ xf86DrvMsg(t->d.pI2CBus->scrnIndex, X_INFO,
+ "UDA1380 stereo coder-decoder detected\n");
+
+ return t;
+}
+
+Bool
+uda1380_init(UDA1380Ptr t)
+{
+ CARD8 data[3];
+ CARD16 tmp;
+ Bool ret;
+
+ /* Power control */
+ data[0] = 0x02;
+ tmp =
+ (1 << 13) | (1 << 10) | (1 << 8) | (1 << 7) | (1 << 6) | (1 << 3) | (1
+ <<
+ 1);
+ data[1] = (CARD8) ((tmp >> 8) & 0xff);
+ data[2] = (CARD8) (tmp & 0xff);
+ ret = I2C_WriteRead(&(t->d), data, 3, NULL, 0);
+ if (ret == FALSE) {
+ xf86DrvMsg(t->d.pI2CBus->scrnIndex, X_INFO,
+ "UDA1380 failed to initialize\n");
+ return FALSE;
+ }
+
+ /* Analog mixer (AVC) */
+ data[0] = 0x03;
+ /* the analog mixer is muted initially */
+ data[1] = 0x3f;
+ data[2] = 0x3f;
+ ret = I2C_WriteRead(&(t->d), data, 3, NULL, 0);
+ if (ret == FALSE) {
+ xf86DrvMsg(t->d.pI2CBus->scrnIndex, X_INFO,
+ "UDA1380 failed to initialize\n");
+ return FALSE;
+ }
+
+ xf86DrvMsg(t->d.pI2CBus->scrnIndex, X_INFO, "UDA1380 initialized\n");
+
+ return TRUE;
+}
+
+void
+uda1380_shutdown(UDA1380Ptr t)
+{
+ CARD8 data[3];
+ Bool ret;
+
+ /* Power control */
+ data[0] = 0x02;
+ data[1] = 0;
+ data[2] = 0;
+ ret = I2C_WriteRead(&(t->d), data, 3, NULL, 0);
+ if (ret == FALSE)
+ xf86DrvMsg(t->d.pI2CBus->scrnIndex, X_INFO,
+ "UDA1380 failed to shutdown\n");
+}
+
+void
+uda1380_setvolume(UDA1380Ptr t, INT32 value)
+{
+ CARD8 data[3];
+
+ /*
+ * We have to scale the value ranging from -1000 to 1000 to 0x2c to 0
+ */
+ CARD8 volume = 47 - (CARD8) ((value + 1000) * 47 / 2000);
+ Bool ret;
+
+ t->analog_mixer_settings = ((volume << 8) & 0x3f00) | (volume & 0x3f);
+
+ /* Analog mixer (AVC) */
+ data[0] = 0x03;
+ data[1] = volume & 0x3f;
+ data[2] = volume & 0x3f;
+ ret = I2C_WriteRead(&(t->d), data, 3, NULL, 0);
+ if (ret == FALSE)
+ xf86DrvMsg(t->d.pI2CBus->scrnIndex, X_INFO,
+ "UDA1380 failed to set volume\n");
+}
+
+void
+uda1380_mute(UDA1380Ptr t, Bool mute)
+{
+ CARD8 data[3];
+ Bool ret;
+
+ if (mute == TRUE) {
+ /* Analog mixer (AVC) */
+ data[0] = 0x03;
+ data[1] = 0xff;
+ data[2] = 0xff;
+ ret = I2C_WriteRead(&(t->d), data, 3, NULL, 0);
+ if (ret == FALSE)
+ xf86DrvMsg(t->d.pI2CBus->scrnIndex, X_INFO,
+ "UDA1380 failed to mute\n");
+ }
+ else {
+ /* Analog mixer (AVC) */
+ data[0] = 0x03;
+ data[1] = (CARD8) ((t->analog_mixer_settings >> 8) & 0x3f);
+ data[2] = (CARD8) (t->analog_mixer_settings & 0x3f);
+ ret = I2C_WriteRead(&(t->d), data, 3, NULL, 0);
+ if (ret == FALSE)
+ xf86DrvMsg(t->d.pI2CBus->scrnIndex, X_INFO,
+ "UDA1380 failed to unmute\n");
+ }
+}
+
+void
+uda1380_getstatus(UDA1380Ptr t)
+{
+}
+
+void
+uda1380_setparameters(UDA1380Ptr t)
+{
+}
+
+void
+uda1380_dumpstatus(UDA1380Ptr t)
+{
+}
diff --git a/xorg-server/hw/xfree86/i2c/uda1380_module.c b/xorg-server/hw/xfree86/i2c/uda1380_module.c
index 203055d46..dca834b12 100644
--- a/xorg-server/hw/xfree86/i2c/uda1380_module.c
+++ b/xorg-server/hw/xfree86/i2c/uda1380_module.c
@@ -1,25 +1,24 @@
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Module.h"
-
-static XF86ModuleVersionInfo uda1380VersRec =
-{
- "uda1380",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 0, 0,
- ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */
- ABI_VIDEODRV_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0}
-};
-
-_X_EXPORT XF86ModuleData uda1380ModuleData = {
- &uda1380VersRec,
- NULL,
- NULL
-};
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Module.h"
+
+static XF86ModuleVersionInfo uda1380VersRec = {
+ "uda1380",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_NONE,
+ {0, 0, 0, 0}
+};
+
+_X_EXPORT XF86ModuleData uda1380ModuleData = {
+ &uda1380VersRec,
+ NULL,
+ NULL
+};
diff --git a/xorg-server/hw/xfree86/i2c/xf86i2c.c b/xorg-server/hw/xfree86/i2c/xf86i2c.c
index 488b6815f..1273f4bab 100644
--- a/xorg-server/hw/xfree86/i2c/xf86i2c.c
+++ b/xorg-server/hw/xfree86/i2c/xf86i2c.c
@@ -1,866 +1,879 @@
-/*
- * Copyright (C) 1998 Itai Nahshon, Michael Schimek
- *
- * The original code was derived from and inspired by
- * the I2C driver from the Linux kernel.
- * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de>
- */
-
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <sys/time.h>
-#include <string.h>
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include <X11/Xos.h>
-#include <X11/Xproto.h>
-#include "scrnintstr.h"
-#include "regionstr.h"
-#include "windowstr.h"
-#include "pixmapstr.h"
-#include "validate.h"
-#include "resource.h"
-#include "gcstruct.h"
-#include "dixstruct.h"
-
-#include "xf86i2c.h"
-
-#define I2C_TIMEOUT(x) /*(x)*/ /* Report timeouts */
-#define I2C_TRACE(x) /*(x)*/ /* Report progress */
-
-/* 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.
- */
-
-static void
-I2CUDelay(I2CBusPtr b, int usec)
-{
- struct timeval begin, cur;
- long d_secs, d_usecs;
- long diff;
-
- if (usec > 0) {
- X_GETTIMEOFDAY(&begin);
- do {
- /* It would be nice to use {xf86}usleep,
- * but usleep (1) takes >10000 usec !
- */
- X_GETTIMEOFDAY(&cur);
- d_secs = (cur.tv_sec - begin.tv_sec);
- d_usecs = (cur.tv_usec - begin.tv_usec);
- diff = d_secs*1000000 + d_usecs;
- } while (diff>=0 && diff< (usec + 1));
- }
-}
-
-/* Most drivers will register just with GetBits/PutBits functions.
- * The following functions implement a software I2C protocol
- * by using the promitive functions given by the driver.
- * ================================================================
- *
- * It is assumed that there is just one master on the I2C bus, therefore
- * there is no explicit test for conflits.
- */
-
-#define RISEFALLTIME 2 /* usec, actually 300 to 1000 ns according to the i2c specs */
-
-/* Some devices will hold SCL low to slow down the bus or until
- * ready for transmission.
- *
- * This condition will be noticed when the master tries to raise
- * the SCL line. You can set the timeout to zero if the slave device
- * does not support this clock synchronization.
- */
-
-static Bool
-I2CRaiseSCL(I2CBusPtr b, int sda, int timeout)
-{
- int i, scl;
-
- b->I2CPutBits(b, 1, sda);
- b->I2CUDelay(b, b->RiseFallTime);
-
- for (i = timeout; i > 0; i -= b->RiseFallTime) {
- b->I2CGetBits(b, &scl, &sda);
- if (scl) break;
- b->I2CUDelay(b, b->RiseFallTime);
- }
-
- if (i <= 0) {
- I2C_TIMEOUT(ErrorF("[I2CRaiseSCL(<%s>, %d, %d) timeout]", b->BusName, sda, timeout));
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* Send a start signal on the I2C bus. The start signal notifies
- * devices that a new transaction is initiated by the bus master.
- *
- * The start signal is always followed by a slave address.
- * Slave addresses are 8+ bits. The first 7 bits identify the
- * device and the last bit signals if this is a read (1) or
- * write (0) operation.
- *
- * There may be more than one start signal on one transaction.
- * This happens for example on some devices that allow reading
- * of registers. First send a start bit followed by the device
- * address (with the last bit 0) and the register number. Then send
- * a new start bit with the device address (with the last bit 1)
- * and then read the value from the device.
- *
- * Note this is function does not implement a multiple master
- * arbitration procedure.
- */
-
-static Bool
-I2CStart(I2CBusPtr b, int timeout)
-{
- if (!I2CRaiseSCL(b, 1, timeout))
- return FALSE;
-
- b->I2CPutBits(b, 1, 0);
- b->I2CUDelay(b, b->HoldTime);
- b->I2CPutBits(b, 0, 0);
- b->I2CUDelay(b, b->HoldTime);
-
- I2C_TRACE(ErrorF("\ni2c: <"));
-
- return TRUE;
-}
-
-/* This is the default I2CStop function if not supplied by the driver.
- *
- * Signal devices on the I2C bus that a transaction on the
- * bus has finished. There may be more than one start signal
- * on a transaction but only one stop signal.
- */
-
-static void
-I2CStop(I2CDevPtr d)
-{
- I2CBusPtr b = d->pI2CBus;
-
- b->I2CPutBits(b, 0, 0);
- b->I2CUDelay(b, b->RiseFallTime);
-
- b->I2CPutBits(b, 1, 0);
- b->I2CUDelay(b, b->HoldTime);
- b->I2CPutBits(b, 1, 1);
- b->I2CUDelay(b, b->HoldTime);
-
- I2C_TRACE(ErrorF(">\n"));
-}
-
-/* Write/Read a single bit to/from a device.
- * Return FALSE if a timeout occurs.
- */
-
-static Bool
-I2CWriteBit(I2CBusPtr b, int sda, int timeout)
-{
- Bool r;
-
- b->I2CPutBits(b, 0, sda);
- b->I2CUDelay(b, b->RiseFallTime);
-
- r = I2CRaiseSCL(b, sda, timeout);
- b->I2CUDelay(b, b->HoldTime);
-
- b->I2CPutBits(b, 0, sda);
- b->I2CUDelay(b, b->HoldTime);
-
- return r;
-}
-
-static Bool
-I2CReadBit(I2CBusPtr b, int *psda, int timeout)
-{
- Bool r;
- int scl;
-
- r = I2CRaiseSCL(b, 1, timeout);
- b->I2CUDelay(b, b->HoldTime);
-
- b->I2CGetBits(b, &scl, psda);
-
- b->I2CPutBits(b, 0, 1);
- b->I2CUDelay(b, b->HoldTime);
-
- return r;
-}
-
-/* This is the default I2CPutByte function if not supplied by the driver.
- *
- * A single byte is sent to the device.
- * The function returns FALSE if a timeout occurs, you should send
- * a stop condition afterwards to reset the bus.
- *
- * A timeout occurs,
- * if the slave pulls SCL to slow down the bus more than ByteTimeout usecs,
- * or slows down the bus for more than BitTimeout usecs for each bit,
- * or does not send an ACK bit (0) to acknowledge the transmission within
- * AcknTimeout usecs, but a NACK (1) bit.
- *
- * AcknTimeout must be at least b->HoldTime, the other timeouts can be
- * zero according to the comment on I2CRaiseSCL.
- */
-
-static Bool
-I2CPutByte(I2CDevPtr d, I2CByte data)
-{
- Bool r;
- int i, scl, sda;
- I2CBusPtr b = d->pI2CBus;
-
- if (!I2CWriteBit(b, (data >> 7) & 1, d->ByteTimeout))
- return FALSE;
-
- for (i = 6; i >= 0; i--)
- if (!I2CWriteBit(b, (data >> i) & 1, d->BitTimeout))
- return FALSE;
-
- b->I2CPutBits(b, 0, 1);
- b->I2CUDelay(b, b->RiseFallTime);
-
- r = I2CRaiseSCL(b, 1, b->HoldTime);
-
- if (r) {
- for (i = d->AcknTimeout; i > 0; i -= b->HoldTime) {
- b->I2CUDelay(b, b->HoldTime);
- b->I2CGetBits(b, &scl, &sda);
- if (sda == 0) break;
- }
-
- if (i <= 0) {
- I2C_TIMEOUT(ErrorF("[I2CPutByte(<%s>, 0x%02x, %d, %d, %d) timeout]",
- b->BusName, data, d->BitTimeout,
- d->ByteTimeout, d->AcknTimeout));
- r = FALSE;
- }
-
- I2C_TRACE(ErrorF("W%02x%c ", (int) data, sda ? '-' : '+'));
- }
-
- b->I2CPutBits(b, 0, 1);
- b->I2CUDelay(b, b->HoldTime);
-
- return r;
-}
-
-/* This is the default I2CGetByte function if not supplied by the driver.
- *
- * A single byte is read from the device.
- * The function returns FALSE if a timeout occurs, you should send
- * a stop condition afterwards to reset the bus.
- *
- * A timeout occurs,
- * if the slave pulls SCL to slow down the bus more than ByteTimeout usecs,
- * or slows down the bus for more than b->BitTimeout usecs for each bit.
- *
- * ByteTimeout must be at least b->HoldTime, the other timeouts can be
- * zero according to the comment on I2CRaiseSCL.
- *
- * For the <last> byte in a sequence the acknowledge bit NACK (1),
- * otherwise ACK (0) will be sent.
- */
-
-static Bool
-I2CGetByte(I2CDevPtr d, I2CByte *data, Bool last)
-{
- int i, sda;
- I2CBusPtr b = d->pI2CBus;
-
- b->I2CPutBits(b, 0, 1);
- b->I2CUDelay(b, b->RiseFallTime);
-
- if (!I2CReadBit(b, &sda, d->ByteTimeout))
- return FALSE;
-
- *data = (sda > 0) << 7;
-
- for (i = 6; i >= 0; i--)
- if (!I2CReadBit(b, &sda, d->BitTimeout))
- return FALSE;
- else
- *data |= (sda > 0) << i;
-
- if (!I2CWriteBit(b, last ? 1 : 0, d->BitTimeout))
- return FALSE;
-
- I2C_TRACE(ErrorF("R%02x%c ", (int) *data, last ? '+' : '-'));
-
- return TRUE;
-}
-
-/* This is the default I2CAddress function if not supplied by the driver.
- *
- * It creates the start condition, followed by the d->SlaveAddr.
- * Higher level functions must call this routine rather than
- * I2CStart/PutByte because a hardware I2C master may not be able
- * to send a slave address without a start condition.
- *
- * The same timeouts apply as with I2CPutByte and additional a
- * StartTimeout, similar to the ByteTimeout but for the start
- * condition.
- *
- * In case of a timeout, the bus is left in a clean idle condition.
- * I. e. you *must not* send a Stop. If this function succeeds, you *must*.
- *
- * The slave address format is 16 bit, with the legacy _8_bit_ slave address
- * in the least significant byte. This is, the slave address must include the
- * R/_W flag as least significant bit.
- *
- * The most significant byte of the address will be sent _after_ the LSB,
- * but only if the LSB indicates:
- * a) an 11 bit address, this is LSB = 1111 0xxx.
- * b) a 'general call address', this is LSB = 0000 000x - see the I2C specs
- * for more.
- */
-
-static Bool
-I2CAddress(I2CDevPtr d, I2CSlaveAddr addr)
-{
- if (I2CStart(d->pI2CBus, d->StartTimeout)) {
- if (I2CPutByte(d, addr & 0xFF)) {
- if ((addr & 0xF8) != 0xF0 &&
- (addr & 0xFE) != 0x00)
- return TRUE;
-
- if (I2CPutByte(d, (addr >> 8) & 0xFF))
- return TRUE;
- }
-
- I2CStop(d);
- }
-
- return FALSE;
-}
-
-/* These are the hardware independent I2C helper functions.
- * ========================================================
- */
-
-/* Function for probing. Just send the slave address
- * and return true if the device responds. The slave address
- * must have the lsb set to reflect a read (1) or write (0) access.
- * Don't expect a read- or write-only device will respond otherwise.
- */
-
-Bool
-xf86I2CProbeAddress(I2CBusPtr b, I2CSlaveAddr addr)
-{
- int r;
- I2CDevRec d;
-
- d.DevName = "Probing";
- d.BitTimeout = b->BitTimeout;
- d.ByteTimeout = b->ByteTimeout;
- d.AcknTimeout = b->AcknTimeout;
- d.StartTimeout = b->StartTimeout;
- d.SlaveAddr = addr;
- d.pI2CBus = b;
- d.NextDev = NULL;
-
- r = b->I2CAddress(&d, addr);
-
- if (r) b->I2CStop(&d);
-
- return r;
-}
-
-/* All functions below are related to devices and take the
- * slave address and timeout values from an I2CDevRec. They
- * return FALSE in case of an error (presumably a timeout).
- */
-
-/* General purpose read and write function.
- *
- * 1st, if nWrite > 0
- * Send a start condition
- * Send the slave address (1 or 2 bytes) with write flag
- * Write n bytes from WriteBuffer
- * 2nd, if nRead > 0
- * Send a start condition [again]
- * Send the slave address (1 or 2 bytes) with read flag
- * Read n bytes to ReadBuffer
- * 3rd, if a Start condition has been successfully sent,
- * Send a Stop condition.
- *
- * The functions exits immediately when an error occures,
- * not proceeding any data left. However, step 3 will
- * be executed anyway to leave the bus in clean idle state.
- */
-
-static Bool
-I2CWriteRead(I2CDevPtr d,
- I2CByte *WriteBuffer, int nWrite,
- I2CByte *ReadBuffer, int nRead)
-{
- Bool r = TRUE;
- I2CBusPtr b = d->pI2CBus;
- int s = 0;
-
- if (r && nWrite > 0) {
- r = b->I2CAddress(d, d->SlaveAddr & ~1);
- if (r) {
- for (; nWrite > 0; WriteBuffer++, nWrite--)
- if (!(r = b->I2CPutByte(d, *WriteBuffer)))
- break;
- s++;
- }
- }
-
- if (r && nRead > 0) {
- r = b->I2CAddress(d, d->SlaveAddr | 1);
- if (r) {
- for (; nRead > 0; ReadBuffer++, nRead--)
- if (!(r = b->I2CGetByte(d, ReadBuffer, nRead == 1)))
- break;
- s++;
- }
- }
-
- if (s) b->I2CStop(d);
-
- return r;
-}
-
-/* wrapper - for compatibility and convinience */
-
-Bool
-xf86I2CWriteRead(I2CDevPtr d,
- I2CByte *WriteBuffer, int nWrite,
- I2CByte *ReadBuffer, int nRead)
-{
- I2CBusPtr b = d->pI2CBus;
- return b->I2CWriteRead(d,WriteBuffer,nWrite,ReadBuffer,nRead);
-}
-
-/* Read a byte, the only readable register of a device.
- */
-
-Bool
-xf86I2CReadStatus(I2CDevPtr d, I2CByte *pbyte)
-{
- return xf86I2CWriteRead(d, NULL, 0, pbyte, 1);
-}
-
-/* Read a byte from one of the registers determined by its sub-address.
- */
-
-Bool
-xf86I2CReadByte(I2CDevPtr d, I2CByte subaddr, I2CByte *pbyte)
-{
- return xf86I2CWriteRead(d, &subaddr, 1, pbyte, 1);
-}
-
-/* Read bytes from subsequent registers determined by the
- * sub-address of the first register.
- */
-
-Bool
-xf86I2CReadBytes(I2CDevPtr d, I2CByte subaddr, I2CByte *pbyte, int n)
-{
- return xf86I2CWriteRead(d, &subaddr, 1, pbyte, n);
-}
-
-/* Read a word (high byte, then low byte) from one of the registers
- * determined by its sub-address.
- */
-
-Bool
-xf86I2CReadWord(I2CDevPtr d, I2CByte subaddr, unsigned short *pword)
-{
- I2CByte rb[2];
-
- if (!xf86I2CWriteRead(d, &subaddr, 1, rb, 2)) return FALSE;
-
- *pword = (rb[0] << 8) | rb[1];
-
- return TRUE;
-}
-
-/* Write a byte to one of the registers determined by its sub-address.
- */
-
-Bool
-xf86I2CWriteByte(I2CDevPtr d, I2CByte subaddr, I2CByte byte)
-{
- I2CByte wb[2];
-
- wb[0] = subaddr;
- wb[1] = byte;
-
- return xf86I2CWriteRead(d, wb, 2, NULL, 0);
-}
-
-/* Write bytes to subsequent registers determined by the
- * sub-address of the first register.
- */
-
-Bool
-xf86I2CWriteBytes(I2CDevPtr d, I2CByte subaddr,
- I2CByte *WriteBuffer, int nWrite)
-{
- I2CBusPtr b = d->pI2CBus;
- Bool r = TRUE;
-
- if (nWrite > 0) {
- r = b->I2CAddress(d, d->SlaveAddr & ~1);
- if (r){
- if ((r = b->I2CPutByte(d, subaddr)))
- for (; nWrite > 0; WriteBuffer++, nWrite--)
- if (!(r = b->I2CPutByte(d, *WriteBuffer)))
- break;
-
- b->I2CStop(d);
- }
- }
-
- return r;
-}
-
-/* Write a word (high byte, then low byte) to one of the registers
- * determined by its sub-address.
- */
-
-Bool
-xf86I2CWriteWord(I2CDevPtr d, I2CByte subaddr, unsigned short word)
-{
- I2CByte wb[3];
-
- wb[0] = subaddr;
- wb[1] = word >> 8;
- wb[2] = word & 0xFF;
-
- return xf86I2CWriteRead(d, wb, 3, NULL, 0);
-}
-
-/* Write a vector of bytes to not adjacent registers. This vector is,
- * 1st byte sub-address, 2nd byte value, 3rd byte sub-address asf.
- * This function is intended to initialize devices. Note this function
- * exits immediately when an error occurs, some registers may
- * remain uninitialized.
- */
-
-Bool
-xf86I2CWriteVec(I2CDevPtr d, I2CByte *vec, int nValues)
-{
- I2CBusPtr b = d->pI2CBus;
- Bool r = TRUE;
- int s = 0;
-
- if (nValues > 0) {
- for (; nValues > 0; nValues--, vec += 2) {
- if (!(r = b->I2CAddress(d, d->SlaveAddr & ~1)))
- break;
-
- s++;
-
- if (!(r = b->I2CPutByte(d, vec[0])))
- break;
-
- if (!(r = b->I2CPutByte(d, vec[1])))
- break;
- }
-
- if (s > 0) b->I2CStop(d);
- }
-
- return r;
-}
-
-/* Administrative functions.
- * =========================
- */
-
-/* Allocates an I2CDevRec for you and initializes with propper defaults
- * you may modify before calling xf86I2CDevInit. Your I2CDevRec must
- * contain at least a SlaveAddr, and a pI2CBus pointer to the bus this
- * device shall be linked to.
- *
- * See function I2CAddress for the slave address format. Always set
- * the least significant bit, indicating a read or write access, to zero.
- */
-
-I2CDevPtr
-xf86CreateI2CDevRec(void)
-{
- return calloc(1, sizeof(I2CDevRec));
-}
-
-/* Unlink an I2C device. If you got the I2CDevRec from xf86CreateI2CDevRec
- * you should set <unalloc> to free it.
- */
-
-void
-xf86DestroyI2CDevRec(I2CDevPtr d, Bool unalloc)
-{
- if (d) {
- I2CDevPtr *p;
-
- /* Remove this from the list of active I2C devices. */
-
- for (p = &d->pI2CBus->FirstDev; *p != NULL; p = &(*p)->NextDev)
- if (*p == d) {
- *p = (*p)->NextDev;
- break;
- }
-
- xf86DrvMsg(d->pI2CBus->scrnIndex, X_INFO,
- "I2C device \"%s:%s\" removed.\n",
- d->pI2CBus->BusName, d->DevName);
-
- if (unalloc) free(d);
- }
-}
-
-/* I2C transmissions are related to an I2CDevRec you must link to a
- * previously registered bus (see xf86I2CBusInit) before attempting
- * to read and write data. You may call xf86I2CProbeAddress first to
- * see if the device in question is present on this bus.
- *
- * xf86I2CDevInit will not allocate an I2CBusRec for you, instead you
- * may enter a pointer to a statically allocated I2CDevRec or the (modified)
- * result of xf86CreateI2CDevRec.
- *
- * If you don't specify timeouts for the device (n <= 0), it will inherit
- * the bus-wide defaults. The function returns TRUE on success.
- */
-
-Bool
-xf86I2CDevInit(I2CDevPtr d)
-{
- I2CBusPtr b;
-
- if (d == NULL ||
- (b = d->pI2CBus) == NULL ||
- (d->SlaveAddr & 1) ||
- xf86I2CFindDev(b, d->SlaveAddr) != NULL)
- return FALSE;
-
- if (d->BitTimeout <= 0) d->BitTimeout = b->BitTimeout;
- if (d->ByteTimeout <= 0) d->ByteTimeout = b->ByteTimeout;
- if (d->AcknTimeout <= 0) d->AcknTimeout = b->AcknTimeout;
- if (d->StartTimeout <= 0) d->StartTimeout = b->StartTimeout;
-
- d->NextDev = b->FirstDev;
- b->FirstDev = d;
-
- xf86DrvMsg(b->scrnIndex, X_INFO,
- "I2C device \"%s:%s\" registered at address 0x%02X.\n",
- b->BusName, d->DevName, d->SlaveAddr);
-
- return TRUE;
-}
-
-I2CDevPtr
-xf86I2CFindDev(I2CBusPtr b, I2CSlaveAddr addr)
-{
- I2CDevPtr d;
-
- if (b) {
- for (d = b->FirstDev; d != NULL; d = d->NextDev)
- if (d->SlaveAddr == addr)
- return d;
- }
-
- return NULL;
-}
-
-static I2CBusPtr I2CBusList;
-
-/* Allocates an I2CBusRec for you and initializes with propper defaults
- * you may modify before calling xf86I2CBusInit. Your I2CBusRec must
- * contain at least a BusName, a scrnIndex (or -1), and a complete set
- * of either high or low level I2C function pointers. You may pass
- * bus-wide timeouts, otherwise inplausible values will be replaced
- * with safe defaults.
- */
-
-I2CBusPtr
-xf86CreateI2CBusRec(void)
-{
- I2CBusPtr b;
-
- b = (I2CBusPtr) calloc(1, sizeof(I2CBusRec));
-
- if (b != NULL) {
- b->scrnIndex = -1;
- b->HoldTime = 5; /* 100 kHz bus */
- b->BitTimeout = 5;
- b->ByteTimeout = 5;
- b->AcknTimeout = 5;
- b->StartTimeout = 5;
- b->RiseFallTime = RISEFALLTIME;
- }
-
- return b;
-}
-
-/* Unregister an I2C bus. If you got the I2CBusRec from xf86CreateI2CBusRec
- * you should set <unalloc> to free it. If you set <devs_too>, the function
- * xf86DestroyI2CDevRec will be called for all devices linked to the bus
- * first, passing down the <unalloc> option.
- */
-
-void
-xf86DestroyI2CBusRec(I2CBusPtr b, Bool unalloc, Bool devs_too)
-{
- if (b) {
- I2CBusPtr *p;
-
- /* Remove this from the list of active I2C buses */
-
- for (p = &I2CBusList; *p != NULL; p = &(*p)->NextBus)
- if (*p == b) {
- *p = (*p)->NextBus;
- break;
- }
-
- if (b->FirstDev != NULL) {
- if (devs_too) {
- I2CDevPtr d;
-
- while ((d = b->FirstDev) != NULL) {
- b->FirstDev = d->NextDev;
- xf86DestroyI2CDevRec(d, unalloc);
- }
- } else {
- if (unalloc) {
- xf86Msg(X_ERROR, "i2c bug: Attempt to remove I2C bus \"%s\", "
- "but device list is not empty.\n",
- b->BusName);
- return;
- }
- }
- }
-
- xf86DrvMsg(b->scrnIndex, X_INFO, "I2C bus \"%s\" removed.\n",
- b->BusName);
-
- if (unalloc) free(b);
- }
-}
-
-/* I2C masters have to register themselves using this function.
- * It will not allocate an I2CBusRec for you, instead you may enter
- * a pointer to a statically allocated I2CBusRec or the (modified)
- * result of xf86CreateI2CBusRec. Returns TRUE on success.
- *
- * At this point there won't be any traffic on the I2C bus.
- */
-
-Bool
-xf86I2CBusInit(I2CBusPtr b)
-{
- /* I2C buses must be identified by a unique scrnIndex
- * and name. If scrnIndex is unspecified (a negative value),
- * then the name must be unique throughout the server.
- */
-
- if (b->BusName == NULL ||
- xf86I2CFindBus(b->scrnIndex, b->BusName) != NULL)
- return FALSE;
-
- /* If the high level functions are not
- * supplied, use the generic functions.
- * In this case we need the low-level
- * function.
- */
- if (b->I2CWriteRead == NULL)
- {
- b->I2CWriteRead=I2CWriteRead;
-
- if (b->I2CPutBits == NULL ||
- b->I2CGetBits == NULL)
- {
- if (b->I2CPutByte == NULL ||
- b->I2CGetByte == NULL ||
- b->I2CAddress == NULL ||
- b->I2CStart == NULL ||
- b->I2CStop == NULL)
- return FALSE;
- } else {
- b->I2CPutByte = I2CPutByte;
- b->I2CGetByte = I2CGetByte;
- b->I2CAddress = I2CAddress;
- b->I2CStop = I2CStop;
- b->I2CStart = I2CStart;
- }
- }
-
- if (b->I2CUDelay == NULL)
- b->I2CUDelay = I2CUDelay;
-
- if (b->HoldTime < 2) b->HoldTime = 5;
- if (b->BitTimeout <= 0) b->BitTimeout = b->HoldTime;
- if (b->ByteTimeout <= 0) b->ByteTimeout = b->HoldTime;
- if (b->AcknTimeout <= 0) b->AcknTimeout = b->HoldTime;
- if (b->StartTimeout <= 0) b->StartTimeout = b->HoldTime;
-
- /* Put new bus on list. */
-
- b->NextBus = I2CBusList;
- I2CBusList = b;
-
- xf86DrvMsg(b->scrnIndex, X_INFO, "I2C bus \"%s\" initialized.\n",
- b->BusName);
-
- return TRUE;
-}
-
-I2CBusPtr
-xf86I2CFindBus(int scrnIndex, char *name)
-{
- I2CBusPtr p;
-
- if (name != NULL)
- for (p = I2CBusList; p != NULL; p = p->NextBus)
- if (scrnIndex < 0 || p->scrnIndex == scrnIndex)
- if (!strcmp(p->BusName, name))
- return p;
-
- return NULL;
-}
-
-/*
- * Return an array of I2CBusPtr's related to a screen. The caller is
- * responsible for freeing the array.
- */
-int
-xf86I2CGetScreenBuses(int scrnIndex, I2CBusPtr **pppI2CBus)
-{
- I2CBusPtr pI2CBus;
- int n = 0;
-
- if (pppI2CBus)
- *pppI2CBus = NULL;
-
- for (pI2CBus = I2CBusList; pI2CBus; pI2CBus = pI2CBus->NextBus) {
- if ((pI2CBus->scrnIndex >= 0) && (pI2CBus->scrnIndex != scrnIndex))
- continue;
-
- n++;
-
- if (!pppI2CBus)
- continue;
-
- *pppI2CBus = xnfrealloc(*pppI2CBus, n * sizeof(I2CBusPtr));
- (*pppI2CBus)[n - 1] = pI2CBus;
- }
-
- return n;
-}
+/*
+ * Copyright (C) 1998 Itai Nahshon, Michael Schimek
+ *
+ * The original code was derived from and inspired by
+ * the I2C driver from the Linux kernel.
+ * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de>
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/time.h>
+#include <string.h>
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include <X11/Xos.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "regionstr.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "validate.h"
+#include "resource.h"
+#include "gcstruct.h"
+#include "dixstruct.h"
+
+#include "xf86i2c.h"
+
+#define I2C_TIMEOUT(x) /*(x)*/ /* Report timeouts */
+#define I2C_TRACE(x) /*(x)*/ /* Report progress */
+
+/* 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.
+ */
+
+static void
+I2CUDelay(I2CBusPtr b, int usec)
+{
+ struct timeval begin, cur;
+ long d_secs, d_usecs;
+ long diff;
+
+ if (usec > 0) {
+ X_GETTIMEOFDAY(&begin);
+ do {
+ /* It would be nice to use {xf86}usleep,
+ * but usleep (1) takes >10000 usec !
+ */
+ X_GETTIMEOFDAY(&cur);
+ d_secs = (cur.tv_sec - begin.tv_sec);
+ d_usecs = (cur.tv_usec - begin.tv_usec);
+ diff = d_secs * 1000000 + d_usecs;
+ } while (diff >= 0 && diff < (usec + 1));
+ }
+}
+
+/* Most drivers will register just with GetBits/PutBits functions.
+ * The following functions implement a software I2C protocol
+ * by using the promitive functions given by the driver.
+ * ================================================================
+ *
+ * It is assumed that there is just one master on the I2C bus, therefore
+ * there is no explicit test for conflits.
+ */
+
+#define RISEFALLTIME 2 /* usec, actually 300 to 1000 ns according to the i2c specs */
+
+/* Some devices will hold SCL low to slow down the bus or until
+ * ready for transmission.
+ *
+ * This condition will be noticed when the master tries to raise
+ * the SCL line. You can set the timeout to zero if the slave device
+ * does not support this clock synchronization.
+ */
+
+static Bool
+I2CRaiseSCL(I2CBusPtr b, int sda, int timeout)
+{
+ int i, scl;
+
+ b->I2CPutBits(b, 1, sda);
+ b->I2CUDelay(b, b->RiseFallTime);
+
+ for (i = timeout; i > 0; i -= b->RiseFallTime) {
+ b->I2CGetBits(b, &scl, &sda);
+ if (scl)
+ break;
+ b->I2CUDelay(b, b->RiseFallTime);
+ }
+
+ if (i <= 0) {
+ I2C_TIMEOUT(ErrorF
+ ("[I2CRaiseSCL(<%s>, %d, %d) timeout]", b->BusName, sda,
+ timeout));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* Send a start signal on the I2C bus. The start signal notifies
+ * devices that a new transaction is initiated by the bus master.
+ *
+ * The start signal is always followed by a slave address.
+ * Slave addresses are 8+ bits. The first 7 bits identify the
+ * device and the last bit signals if this is a read (1) or
+ * write (0) operation.
+ *
+ * There may be more than one start signal on one transaction.
+ * This happens for example on some devices that allow reading
+ * of registers. First send a start bit followed by the device
+ * address (with the last bit 0) and the register number. Then send
+ * a new start bit with the device address (with the last bit 1)
+ * and then read the value from the device.
+ *
+ * Note this is function does not implement a multiple master
+ * arbitration procedure.
+ */
+
+static Bool
+I2CStart(I2CBusPtr b, int timeout)
+{
+ if (!I2CRaiseSCL(b, 1, timeout))
+ return FALSE;
+
+ b->I2CPutBits(b, 1, 0);
+ b->I2CUDelay(b, b->HoldTime);
+ b->I2CPutBits(b, 0, 0);
+ b->I2CUDelay(b, b->HoldTime);
+
+ I2C_TRACE(ErrorF("\ni2c: <"));
+
+ return TRUE;
+}
+
+/* This is the default I2CStop function if not supplied by the driver.
+ *
+ * Signal devices on the I2C bus that a transaction on the
+ * bus has finished. There may be more than one start signal
+ * on a transaction but only one stop signal.
+ */
+
+static void
+I2CStop(I2CDevPtr d)
+{
+ I2CBusPtr b = d->pI2CBus;
+
+ b->I2CPutBits(b, 0, 0);
+ b->I2CUDelay(b, b->RiseFallTime);
+
+ b->I2CPutBits(b, 1, 0);
+ b->I2CUDelay(b, b->HoldTime);
+ b->I2CPutBits(b, 1, 1);
+ b->I2CUDelay(b, b->HoldTime);
+
+ I2C_TRACE(ErrorF(">\n"));
+}
+
+/* Write/Read a single bit to/from a device.
+ * Return FALSE if a timeout occurs.
+ */
+
+static Bool
+I2CWriteBit(I2CBusPtr b, int sda, int timeout)
+{
+ Bool r;
+
+ b->I2CPutBits(b, 0, sda);
+ b->I2CUDelay(b, b->RiseFallTime);
+
+ r = I2CRaiseSCL(b, sda, timeout);
+ b->I2CUDelay(b, b->HoldTime);
+
+ b->I2CPutBits(b, 0, sda);
+ b->I2CUDelay(b, b->HoldTime);
+
+ return r;
+}
+
+static Bool
+I2CReadBit(I2CBusPtr b, int *psda, int timeout)
+{
+ Bool r;
+ int scl;
+
+ r = I2CRaiseSCL(b, 1, timeout);
+ b->I2CUDelay(b, b->HoldTime);
+
+ b->I2CGetBits(b, &scl, psda);
+
+ b->I2CPutBits(b, 0, 1);
+ b->I2CUDelay(b, b->HoldTime);
+
+ return r;
+}
+
+/* This is the default I2CPutByte function if not supplied by the driver.
+ *
+ * A single byte is sent to the device.
+ * The function returns FALSE if a timeout occurs, you should send
+ * a stop condition afterwards to reset the bus.
+ *
+ * A timeout occurs,
+ * if the slave pulls SCL to slow down the bus more than ByteTimeout usecs,
+ * or slows down the bus for more than BitTimeout usecs for each bit,
+ * or does not send an ACK bit (0) to acknowledge the transmission within
+ * AcknTimeout usecs, but a NACK (1) bit.
+ *
+ * AcknTimeout must be at least b->HoldTime, the other timeouts can be
+ * zero according to the comment on I2CRaiseSCL.
+ */
+
+static Bool
+I2CPutByte(I2CDevPtr d, I2CByte data)
+{
+ Bool r;
+ int i, scl, sda;
+ I2CBusPtr b = d->pI2CBus;
+
+ if (!I2CWriteBit(b, (data >> 7) & 1, d->ByteTimeout))
+ return FALSE;
+
+ for (i = 6; i >= 0; i--)
+ if (!I2CWriteBit(b, (data >> i) & 1, d->BitTimeout))
+ return FALSE;
+
+ b->I2CPutBits(b, 0, 1);
+ b->I2CUDelay(b, b->RiseFallTime);
+
+ r = I2CRaiseSCL(b, 1, b->HoldTime);
+
+ if (r) {
+ for (i = d->AcknTimeout; i > 0; i -= b->HoldTime) {
+ b->I2CUDelay(b, b->HoldTime);
+ b->I2CGetBits(b, &scl, &sda);
+ if (sda == 0)
+ break;
+ }
+
+ if (i <= 0) {
+ I2C_TIMEOUT(ErrorF("[I2CPutByte(<%s>, 0x%02x, %d, %d, %d) timeout]",
+ b->BusName, data, d->BitTimeout,
+ d->ByteTimeout, d->AcknTimeout));
+ r = FALSE;
+ }
+
+ I2C_TRACE(ErrorF("W%02x%c ", (int) data, sda ? '-' : '+'));
+ }
+
+ b->I2CPutBits(b, 0, 1);
+ b->I2CUDelay(b, b->HoldTime);
+
+ return r;
+}
+
+/* This is the default I2CGetByte function if not supplied by the driver.
+ *
+ * A single byte is read from the device.
+ * The function returns FALSE if a timeout occurs, you should send
+ * a stop condition afterwards to reset the bus.
+ *
+ * A timeout occurs,
+ * if the slave pulls SCL to slow down the bus more than ByteTimeout usecs,
+ * or slows down the bus for more than b->BitTimeout usecs for each bit.
+ *
+ * ByteTimeout must be at least b->HoldTime, the other timeouts can be
+ * zero according to the comment on I2CRaiseSCL.
+ *
+ * For the <last> byte in a sequence the acknowledge bit NACK (1),
+ * otherwise ACK (0) will be sent.
+ */
+
+static Bool
+I2CGetByte(I2CDevPtr d, I2CByte * data, Bool last)
+{
+ int i, sda;
+ I2CBusPtr b = d->pI2CBus;
+
+ b->I2CPutBits(b, 0, 1);
+ b->I2CUDelay(b, b->RiseFallTime);
+
+ if (!I2CReadBit(b, &sda, d->ByteTimeout))
+ return FALSE;
+
+ *data = (sda > 0) << 7;
+
+ for (i = 6; i >= 0; i--)
+ if (!I2CReadBit(b, &sda, d->BitTimeout))
+ return FALSE;
+ else
+ *data |= (sda > 0) << i;
+
+ if (!I2CWriteBit(b, last ? 1 : 0, d->BitTimeout))
+ return FALSE;
+
+ I2C_TRACE(ErrorF("R%02x%c ", (int) *data, last ? '+' : '-'));
+
+ return TRUE;
+}
+
+/* This is the default I2CAddress function if not supplied by the driver.
+ *
+ * It creates the start condition, followed by the d->SlaveAddr.
+ * Higher level functions must call this routine rather than
+ * I2CStart/PutByte because a hardware I2C master may not be able
+ * to send a slave address without a start condition.
+ *
+ * The same timeouts apply as with I2CPutByte and additional a
+ * StartTimeout, similar to the ByteTimeout but for the start
+ * condition.
+ *
+ * In case of a timeout, the bus is left in a clean idle condition.
+ * I. e. you *must not* send a Stop. If this function succeeds, you *must*.
+ *
+ * The slave address format is 16 bit, with the legacy _8_bit_ slave address
+ * in the least significant byte. This is, the slave address must include the
+ * R/_W flag as least significant bit.
+ *
+ * The most significant byte of the address will be sent _after_ the LSB,
+ * but only if the LSB indicates:
+ * a) an 11 bit address, this is LSB = 1111 0xxx.
+ * b) a 'general call address', this is LSB = 0000 000x - see the I2C specs
+ * for more.
+ */
+
+static Bool
+I2CAddress(I2CDevPtr d, I2CSlaveAddr addr)
+{
+ if (I2CStart(d->pI2CBus, d->StartTimeout)) {
+ if (I2CPutByte(d, addr & 0xFF)) {
+ if ((addr & 0xF8) != 0xF0 && (addr & 0xFE) != 0x00)
+ return TRUE;
+
+ if (I2CPutByte(d, (addr >> 8) & 0xFF))
+ return TRUE;
+ }
+
+ I2CStop(d);
+ }
+
+ return FALSE;
+}
+
+/* These are the hardware independent I2C helper functions.
+ * ========================================================
+ */
+
+/* Function for probing. Just send the slave address
+ * and return true if the device responds. The slave address
+ * must have the lsb set to reflect a read (1) or write (0) access.
+ * Don't expect a read- or write-only device will respond otherwise.
+ */
+
+Bool
+xf86I2CProbeAddress(I2CBusPtr b, I2CSlaveAddr addr)
+{
+ int r;
+ I2CDevRec d;
+
+ d.DevName = "Probing";
+ d.BitTimeout = b->BitTimeout;
+ d.ByteTimeout = b->ByteTimeout;
+ d.AcknTimeout = b->AcknTimeout;
+ d.StartTimeout = b->StartTimeout;
+ d.SlaveAddr = addr;
+ d.pI2CBus = b;
+ d.NextDev = NULL;
+
+ r = b->I2CAddress(&d, addr);
+
+ if (r)
+ b->I2CStop(&d);
+
+ return r;
+}
+
+/* All functions below are related to devices and take the
+ * slave address and timeout values from an I2CDevRec. They
+ * return FALSE in case of an error (presumably a timeout).
+ */
+
+/* General purpose read and write function.
+ *
+ * 1st, if nWrite > 0
+ * Send a start condition
+ * Send the slave address (1 or 2 bytes) with write flag
+ * Write n bytes from WriteBuffer
+ * 2nd, if nRead > 0
+ * Send a start condition [again]
+ * Send the slave address (1 or 2 bytes) with read flag
+ * Read n bytes to ReadBuffer
+ * 3rd, if a Start condition has been successfully sent,
+ * Send a Stop condition.
+ *
+ * The functions exits immediately when an error occures,
+ * not proceeding any data left. However, step 3 will
+ * be executed anyway to leave the bus in clean idle state.
+ */
+
+static Bool
+I2CWriteRead(I2CDevPtr d,
+ I2CByte * WriteBuffer, int nWrite, I2CByte * ReadBuffer, int nRead)
+{
+ Bool r = TRUE;
+ I2CBusPtr b = d->pI2CBus;
+ int s = 0;
+
+ if (r && nWrite > 0) {
+ r = b->I2CAddress(d, d->SlaveAddr & ~1);
+ if (r) {
+ for (; nWrite > 0; WriteBuffer++, nWrite--)
+ if (!(r = b->I2CPutByte(d, *WriteBuffer)))
+ break;
+ s++;
+ }
+ }
+
+ if (r && nRead > 0) {
+ r = b->I2CAddress(d, d->SlaveAddr | 1);
+ if (r) {
+ for (; nRead > 0; ReadBuffer++, nRead--)
+ if (!(r = b->I2CGetByte(d, ReadBuffer, nRead == 1)))
+ break;
+ s++;
+ }
+ }
+
+ if (s)
+ b->I2CStop(d);
+
+ return r;
+}
+
+/* wrapper - for compatibility and convinience */
+
+Bool
+xf86I2CWriteRead(I2CDevPtr d,
+ I2CByte * WriteBuffer, int nWrite,
+ I2CByte * ReadBuffer, int nRead)
+{
+ I2CBusPtr b = d->pI2CBus;
+
+ return b->I2CWriteRead(d, WriteBuffer, nWrite, ReadBuffer, nRead);
+}
+
+/* Read a byte, the only readable register of a device.
+ */
+
+Bool
+xf86I2CReadStatus(I2CDevPtr d, I2CByte * pbyte)
+{
+ return xf86I2CWriteRead(d, NULL, 0, pbyte, 1);
+}
+
+/* Read a byte from one of the registers determined by its sub-address.
+ */
+
+Bool
+xf86I2CReadByte(I2CDevPtr d, I2CByte subaddr, I2CByte * pbyte)
+{
+ return xf86I2CWriteRead(d, &subaddr, 1, pbyte, 1);
+}
+
+/* Read bytes from subsequent registers determined by the
+ * sub-address of the first register.
+ */
+
+Bool
+xf86I2CReadBytes(I2CDevPtr d, I2CByte subaddr, I2CByte * pbyte, int n)
+{
+ return xf86I2CWriteRead(d, &subaddr, 1, pbyte, n);
+}
+
+/* Read a word (high byte, then low byte) from one of the registers
+ * determined by its sub-address.
+ */
+
+Bool
+xf86I2CReadWord(I2CDevPtr d, I2CByte subaddr, unsigned short *pword)
+{
+ I2CByte rb[2];
+
+ if (!xf86I2CWriteRead(d, &subaddr, 1, rb, 2))
+ return FALSE;
+
+ *pword = (rb[0] << 8) | rb[1];
+
+ return TRUE;
+}
+
+/* Write a byte to one of the registers determined by its sub-address.
+ */
+
+Bool
+xf86I2CWriteByte(I2CDevPtr d, I2CByte subaddr, I2CByte byte)
+{
+ I2CByte wb[2];
+
+ wb[0] = subaddr;
+ wb[1] = byte;
+
+ return xf86I2CWriteRead(d, wb, 2, NULL, 0);
+}
+
+/* Write bytes to subsequent registers determined by the
+ * sub-address of the first register.
+ */
+
+Bool
+xf86I2CWriteBytes(I2CDevPtr d, I2CByte subaddr,
+ I2CByte * WriteBuffer, int nWrite)
+{
+ I2CBusPtr b = d->pI2CBus;
+ Bool r = TRUE;
+
+ if (nWrite > 0) {
+ r = b->I2CAddress(d, d->SlaveAddr & ~1);
+ if (r) {
+ if ((r = b->I2CPutByte(d, subaddr)))
+ for (; nWrite > 0; WriteBuffer++, nWrite--)
+ if (!(r = b->I2CPutByte(d, *WriteBuffer)))
+ break;
+
+ b->I2CStop(d);
+ }
+ }
+
+ return r;
+}
+
+/* Write a word (high byte, then low byte) to one of the registers
+ * determined by its sub-address.
+ */
+
+Bool
+xf86I2CWriteWord(I2CDevPtr d, I2CByte subaddr, unsigned short word)
+{
+ I2CByte wb[3];
+
+ wb[0] = subaddr;
+ wb[1] = word >> 8;
+ wb[2] = word & 0xFF;
+
+ return xf86I2CWriteRead(d, wb, 3, NULL, 0);
+}
+
+/* Write a vector of bytes to not adjacent registers. This vector is,
+ * 1st byte sub-address, 2nd byte value, 3rd byte sub-address asf.
+ * This function is intended to initialize devices. Note this function
+ * exits immediately when an error occurs, some registers may
+ * remain uninitialized.
+ */
+
+Bool
+xf86I2CWriteVec(I2CDevPtr d, I2CByte * vec, int nValues)
+{
+ I2CBusPtr b = d->pI2CBus;
+ Bool r = TRUE;
+ int s = 0;
+
+ if (nValues > 0) {
+ for (; nValues > 0; nValues--, vec += 2) {
+ if (!(r = b->I2CAddress(d, d->SlaveAddr & ~1)))
+ break;
+
+ s++;
+
+ if (!(r = b->I2CPutByte(d, vec[0])))
+ break;
+
+ if (!(r = b->I2CPutByte(d, vec[1])))
+ break;
+ }
+
+ if (s > 0)
+ b->I2CStop(d);
+ }
+
+ return r;
+}
+
+/* Administrative functions.
+ * =========================
+ */
+
+/* Allocates an I2CDevRec for you and initializes with propper defaults
+ * you may modify before calling xf86I2CDevInit. Your I2CDevRec must
+ * contain at least a SlaveAddr, and a pI2CBus pointer to the bus this
+ * device shall be linked to.
+ *
+ * See function I2CAddress for the slave address format. Always set
+ * the least significant bit, indicating a read or write access, to zero.
+ */
+
+I2CDevPtr
+xf86CreateI2CDevRec(void)
+{
+ return calloc(1, sizeof(I2CDevRec));
+}
+
+/* Unlink an I2C device. If you got the I2CDevRec from xf86CreateI2CDevRec
+ * you should set <unalloc> to free it.
+ */
+
+void
+xf86DestroyI2CDevRec(I2CDevPtr d, Bool unalloc)
+{
+ if (d) {
+ I2CDevPtr *p;
+
+ /* Remove this from the list of active I2C devices. */
+
+ for (p = &d->pI2CBus->FirstDev; *p != NULL; p = &(*p)->NextDev)
+ if (*p == d) {
+ *p = (*p)->NextDev;
+ break;
+ }
+
+ xf86DrvMsg(d->pI2CBus->scrnIndex, X_INFO,
+ "I2C device \"%s:%s\" removed.\n",
+ d->pI2CBus->BusName, d->DevName);
+
+ if (unalloc)
+ free(d);
+ }
+}
+
+/* I2C transmissions are related to an I2CDevRec you must link to a
+ * previously registered bus (see xf86I2CBusInit) before attempting
+ * to read and write data. You may call xf86I2CProbeAddress first to
+ * see if the device in question is present on this bus.
+ *
+ * xf86I2CDevInit will not allocate an I2CBusRec for you, instead you
+ * may enter a pointer to a statically allocated I2CDevRec or the (modified)
+ * result of xf86CreateI2CDevRec.
+ *
+ * If you don't specify timeouts for the device (n <= 0), it will inherit
+ * the bus-wide defaults. The function returns TRUE on success.
+ */
+
+Bool
+xf86I2CDevInit(I2CDevPtr d)
+{
+ I2CBusPtr b;
+
+ if (d == NULL ||
+ (b = d->pI2CBus) == NULL ||
+ (d->SlaveAddr & 1) || xf86I2CFindDev(b, d->SlaveAddr) != NULL)
+ return FALSE;
+
+ if (d->BitTimeout <= 0)
+ d->BitTimeout = b->BitTimeout;
+ if (d->ByteTimeout <= 0)
+ d->ByteTimeout = b->ByteTimeout;
+ if (d->AcknTimeout <= 0)
+ d->AcknTimeout = b->AcknTimeout;
+ if (d->StartTimeout <= 0)
+ d->StartTimeout = b->StartTimeout;
+
+ d->NextDev = b->FirstDev;
+ b->FirstDev = d;
+
+ xf86DrvMsg(b->scrnIndex, X_INFO,
+ "I2C device \"%s:%s\" registered at address 0x%02X.\n",
+ b->BusName, d->DevName, d->SlaveAddr);
+
+ return TRUE;
+}
+
+I2CDevPtr
+xf86I2CFindDev(I2CBusPtr b, I2CSlaveAddr addr)
+{
+ I2CDevPtr d;
+
+ if (b) {
+ for (d = b->FirstDev; d != NULL; d = d->NextDev)
+ if (d->SlaveAddr == addr)
+ return d;
+ }
+
+ return NULL;
+}
+
+static I2CBusPtr I2CBusList;
+
+/* Allocates an I2CBusRec for you and initializes with propper defaults
+ * you may modify before calling xf86I2CBusInit. Your I2CBusRec must
+ * contain at least a BusName, a scrnIndex (or -1), and a complete set
+ * of either high or low level I2C function pointers. You may pass
+ * bus-wide timeouts, otherwise inplausible values will be replaced
+ * with safe defaults.
+ */
+
+I2CBusPtr
+xf86CreateI2CBusRec(void)
+{
+ I2CBusPtr b;
+
+ b = (I2CBusPtr) calloc(1, sizeof(I2CBusRec));
+
+ if (b != NULL) {
+ b->scrnIndex = -1;
+ b->HoldTime = 5; /* 100 kHz bus */
+ b->BitTimeout = 5;
+ b->ByteTimeout = 5;
+ b->AcknTimeout = 5;
+ b->StartTimeout = 5;
+ b->RiseFallTime = RISEFALLTIME;
+ }
+
+ return b;
+}
+
+/* Unregister an I2C bus. If you got the I2CBusRec from xf86CreateI2CBusRec
+ * you should set <unalloc> to free it. If you set <devs_too>, the function
+ * xf86DestroyI2CDevRec will be called for all devices linked to the bus
+ * first, passing down the <unalloc> option.
+ */
+
+void
+xf86DestroyI2CBusRec(I2CBusPtr b, Bool unalloc, Bool devs_too)
+{
+ if (b) {
+ I2CBusPtr *p;
+
+ /* Remove this from the list of active I2C buses */
+
+ for (p = &I2CBusList; *p != NULL; p = &(*p)->NextBus)
+ if (*p == b) {
+ *p = (*p)->NextBus;
+ break;
+ }
+
+ if (b->FirstDev != NULL) {
+ if (devs_too) {
+ I2CDevPtr d;
+
+ while ((d = b->FirstDev) != NULL) {
+ b->FirstDev = d->NextDev;
+ xf86DestroyI2CDevRec(d, unalloc);
+ }
+ }
+ else {
+ if (unalloc) {
+ xf86Msg(X_ERROR,
+ "i2c bug: Attempt to remove I2C bus \"%s\", "
+ "but device list is not empty.\n", b->BusName);
+ return;
+ }
+ }
+ }
+
+ xf86DrvMsg(b->scrnIndex, X_INFO, "I2C bus \"%s\" removed.\n",
+ b->BusName);
+
+ if (unalloc)
+ free(b);
+ }
+}
+
+/* I2C masters have to register themselves using this function.
+ * It will not allocate an I2CBusRec for you, instead you may enter
+ * a pointer to a statically allocated I2CBusRec or the (modified)
+ * result of xf86CreateI2CBusRec. Returns TRUE on success.
+ *
+ * At this point there won't be any traffic on the I2C bus.
+ */
+
+Bool
+xf86I2CBusInit(I2CBusPtr b)
+{
+ /* I2C buses must be identified by a unique scrnIndex
+ * and name. If scrnIndex is unspecified (a negative value),
+ * then the name must be unique throughout the server.
+ */
+
+ if (b->BusName == NULL || xf86I2CFindBus(b->scrnIndex, b->BusName) != NULL)
+ return FALSE;
+
+ /* If the high level functions are not
+ * supplied, use the generic functions.
+ * In this case we need the low-level
+ * function.
+ */
+ if (b->I2CWriteRead == NULL) {
+ b->I2CWriteRead = I2CWriteRead;
+
+ if (b->I2CPutBits == NULL || b->I2CGetBits == NULL) {
+ if (b->I2CPutByte == NULL ||
+ b->I2CGetByte == NULL ||
+ b->I2CAddress == NULL ||
+ b->I2CStart == NULL || b->I2CStop == NULL)
+ return FALSE;
+ }
+ else {
+ b->I2CPutByte = I2CPutByte;
+ b->I2CGetByte = I2CGetByte;
+ b->I2CAddress = I2CAddress;
+ b->I2CStop = I2CStop;
+ b->I2CStart = I2CStart;
+ }
+ }
+
+ if (b->I2CUDelay == NULL)
+ b->I2CUDelay = I2CUDelay;
+
+ if (b->HoldTime < 2)
+ b->HoldTime = 5;
+ if (b->BitTimeout <= 0)
+ b->BitTimeout = b->HoldTime;
+ if (b->ByteTimeout <= 0)
+ b->ByteTimeout = b->HoldTime;
+ if (b->AcknTimeout <= 0)
+ b->AcknTimeout = b->HoldTime;
+ if (b->StartTimeout <= 0)
+ b->StartTimeout = b->HoldTime;
+
+ /* Put new bus on list. */
+
+ b->NextBus = I2CBusList;
+ I2CBusList = b;
+
+ xf86DrvMsg(b->scrnIndex, X_INFO, "I2C bus \"%s\" initialized.\n",
+ b->BusName);
+
+ return TRUE;
+}
+
+I2CBusPtr
+xf86I2CFindBus(int scrnIndex, char *name)
+{
+ I2CBusPtr p;
+
+ if (name != NULL)
+ for (p = I2CBusList; p != NULL; p = p->NextBus)
+ if (scrnIndex < 0 || p->scrnIndex == scrnIndex)
+ if (!strcmp(p->BusName, name))
+ return p;
+
+ return NULL;
+}
+
+/*
+ * Return an array of I2CBusPtr's related to a screen. The caller is
+ * responsible for freeing the array.
+ */
+int
+xf86I2CGetScreenBuses(int scrnIndex, I2CBusPtr ** pppI2CBus)
+{
+ I2CBusPtr pI2CBus;
+ int n = 0;
+
+ if (pppI2CBus)
+ *pppI2CBus = NULL;
+
+ for (pI2CBus = I2CBusList; pI2CBus; pI2CBus = pI2CBus->NextBus) {
+ if ((pI2CBus->scrnIndex >= 0) && (pI2CBus->scrnIndex != scrnIndex))
+ continue;
+
+ n++;
+
+ if (!pppI2CBus)
+ continue;
+
+ *pppI2CBus = xnfrealloc(*pppI2CBus, n * sizeof(I2CBusPtr));
+ (*pppI2CBus)[n - 1] = pI2CBus;
+ }
+
+ return n;
+}
diff --git a/xorg-server/hw/xfree86/i2c/xf86i2c.h b/xorg-server/hw/xfree86/i2c/xf86i2c.h
index f2ded09db..9a8fb21a3 100644
--- a/xorg-server/hw/xfree86/i2c/xf86i2c.h
+++ b/xorg-server/hw/xfree86/i2c/xf86i2c.h
@@ -2,13 +2,12 @@
* Copyright (C) 1998 Itai Nahshon, Michael Schimek
*/
-
#ifndef _XF86I2C_H
#define _XF86I2C_H
#include "regionstr.h"
-typedef unsigned char I2CByte;
+typedef unsigned char I2CByte;
typedef unsigned short I2CSlaveAddr;
typedef struct _I2CBusRec *I2CBusPtr;
@@ -17,68 +16,71 @@ typedef struct _I2CDevRec *I2CDevPtr;
/* I2C masters have to register themselves */
typedef struct _I2CBusRec {
- char * BusName;
- int scrnIndex;
-
- void (*I2CUDelay) (I2CBusPtr b, int usec);
-
- void (*I2CPutBits)(I2CBusPtr b, int scl, int sda);
- void (*I2CGetBits)(I2CBusPtr b, int *scl, int *sda);
+ char *BusName;
+ int scrnIndex;
+
+ void (*I2CUDelay) (I2CBusPtr b, int usec);
+
+ void (*I2CPutBits) (I2CBusPtr b, int scl, int sda);
+ void (*I2CGetBits) (I2CBusPtr b, int *scl, int *sda);
/* Look at the generic routines to see how these functions should behave. */
- Bool (*I2CStart) (I2CBusPtr b, int timeout);
- Bool (*I2CAddress)(I2CDevPtr d, I2CSlaveAddr);
- void (*I2CStop) (I2CDevPtr d);
- Bool (*I2CPutByte)(I2CDevPtr d, I2CByte data);
- Bool (*I2CGetByte)(I2CDevPtr d, I2CByte *data, Bool);
+ Bool (*I2CStart) (I2CBusPtr b, int timeout);
+ Bool (*I2CAddress) (I2CDevPtr d, I2CSlaveAddr);
+ void (*I2CStop) (I2CDevPtr d);
+ Bool (*I2CPutByte) (I2CDevPtr d, I2CByte data);
+ Bool (*I2CGetByte) (I2CDevPtr d, I2CByte * data, Bool);
- DevUnion DriverPrivate;
+ DevUnion DriverPrivate;
- int HoldTime; /* 1 / bus clock frequency, 5 or 2 usec */
+ int HoldTime; /* 1 / bus clock frequency, 5 or 2 usec */
- int BitTimeout; /* usec */
- int ByteTimeout; /* usec */
- int AcknTimeout; /* usec */
- int StartTimeout; /* usec */
- int RiseFallTime; /* usec */
+ int BitTimeout; /* usec */
+ int ByteTimeout; /* usec */
+ int AcknTimeout; /* usec */
+ int StartTimeout; /* usec */
+ int RiseFallTime; /* usec */
- I2CDevPtr FirstDev;
- I2CBusPtr NextBus;
- Bool (*I2CWriteRead)(I2CDevPtr d, I2CByte *WriteBuffer, int nWrite,
- I2CByte *ReadBuffer, int nRead);
+ I2CDevPtr FirstDev;
+ I2CBusPtr NextBus;
+ Bool (*I2CWriteRead) (I2CDevPtr d, I2CByte * WriteBuffer, int nWrite,
+ I2CByte * ReadBuffer, int nRead);
} I2CBusRec;
#define CreateI2CBusRec xf86CreateI2CBusRec
extern _X_EXPORT I2CBusPtr xf86CreateI2CBusRec(void);
+
#define DestroyI2CBusRec xf86DestroyI2CBusRec
-extern _X_EXPORT void xf86DestroyI2CBusRec(I2CBusPtr pI2CBus, Bool unalloc, Bool devs_too);
+extern _X_EXPORT void xf86DestroyI2CBusRec(I2CBusPtr pI2CBus, Bool unalloc,
+ Bool devs_too);
#define I2CBusInit xf86I2CBusInit
extern _X_EXPORT Bool xf86I2CBusInit(I2CBusPtr pI2CBus);
extern _X_EXPORT I2CBusPtr xf86I2CFindBus(int scrnIndex, char *name);
-extern _X_EXPORT int xf86I2CGetScreenBuses(int scrnIndex, I2CBusPtr **pppI2CBus);
-
+extern _X_EXPORT int xf86I2CGetScreenBuses(int scrnIndex,
+ I2CBusPtr ** pppI2CBus);
/* I2C slave devices */
typedef struct _I2CDevRec {
- char * DevName;
+ char *DevName;
- int BitTimeout; /* usec */
- int ByteTimeout; /* usec */
- int AcknTimeout; /* usec */
- int StartTimeout; /* usec */
+ int BitTimeout; /* usec */
+ int ByteTimeout; /* usec */
+ int AcknTimeout; /* usec */
+ int StartTimeout; /* usec */
- I2CSlaveAddr SlaveAddr;
- I2CBusPtr pI2CBus;
- I2CDevPtr NextDev;
- DevUnion DriverPrivate;
+ I2CSlaveAddr SlaveAddr;
+ I2CBusPtr pI2CBus;
+ I2CDevPtr NextDev;
+ DevUnion DriverPrivate;
} I2CDevRec;
#define CreateI2CDevRec xf86CreateI2CDevRec
extern _X_EXPORT I2CDevPtr xf86CreateI2CDevRec(void);
extern _X_EXPORT void xf86DestroyI2CDevRec(I2CDevPtr pI2CDev, Bool unalloc);
+
#define I2CDevInit xf86I2CDevInit
extern _X_EXPORT Bool xf86I2CDevInit(I2CDevPtr pI2CDev);
extern _X_EXPORT I2CDevPtr xf86I2CFindDev(I2CBusPtr, I2CSlaveAddr);
@@ -89,18 +91,25 @@ extern _X_EXPORT I2CDevPtr xf86I2CFindDev(I2CBusPtr, I2CSlaveAddr);
extern _X_EXPORT Bool xf86I2CProbeAddress(I2CBusPtr pI2CBus, I2CSlaveAddr);
#define I2C_WriteRead xf86I2CWriteRead
-extern _X_EXPORT Bool xf86I2CWriteRead(I2CDevPtr d, I2CByte *WriteBuffer, int nWrite,
- I2CByte *ReadBuffer, int nRead);
+extern _X_EXPORT Bool xf86I2CWriteRead(I2CDevPtr d, I2CByte * WriteBuffer,
+ int nWrite, I2CByte * ReadBuffer,
+ int nRead);
#define xf86I2CRead(d, rb, nr) xf86I2CWriteRead(d, NULL, 0, rb, nr)
-extern _X_EXPORT Bool xf86I2CReadStatus(I2CDevPtr d, I2CByte *pbyte);
-extern _X_EXPORT Bool xf86I2CReadByte(I2CDevPtr d, I2CByte subaddr, I2CByte *pbyte);
-extern _X_EXPORT Bool xf86I2CReadBytes(I2CDevPtr d, I2CByte subaddr, I2CByte *pbyte, int n);
-extern _X_EXPORT Bool xf86I2CReadWord(I2CDevPtr d, I2CByte subaddr, unsigned short *pword);
+extern _X_EXPORT Bool xf86I2CReadStatus(I2CDevPtr d, I2CByte * pbyte);
+extern _X_EXPORT Bool xf86I2CReadByte(I2CDevPtr d, I2CByte subaddr,
+ I2CByte * pbyte);
+extern _X_EXPORT Bool xf86I2CReadBytes(I2CDevPtr d, I2CByte subaddr,
+ I2CByte * pbyte, int n);
+extern _X_EXPORT Bool xf86I2CReadWord(I2CDevPtr d, I2CByte subaddr,
+ unsigned short *pword);
#define xf86I2CWrite(d, wb, nw) xf86I2CWriteRead(d, wb, nw, NULL, 0)
-extern _X_EXPORT Bool xf86I2CWriteByte(I2CDevPtr d, I2CByte subaddr, I2CByte byte);
-extern _X_EXPORT Bool xf86I2CWriteBytes(I2CDevPtr d, I2CByte subaddr, I2CByte *WriteBuffer, int nWrite);
-extern _X_EXPORT Bool xf86I2CWriteWord(I2CDevPtr d, I2CByte subaddr, unsigned short word);
-extern _X_EXPORT Bool xf86I2CWriteVec(I2CDevPtr d, I2CByte *vec, int nValues);
+extern _X_EXPORT Bool xf86I2CWriteByte(I2CDevPtr d, I2CByte subaddr,
+ I2CByte byte);
+extern _X_EXPORT Bool xf86I2CWriteBytes(I2CDevPtr d, I2CByte subaddr,
+ I2CByte * WriteBuffer, int nWrite);
+extern _X_EXPORT Bool xf86I2CWriteWord(I2CDevPtr d, I2CByte subaddr,
+ unsigned short word);
+extern _X_EXPORT Bool xf86I2CWriteVec(I2CDevPtr d, I2CByte * vec, int nValues);
#endif /*_XF86I2C_H */
diff --git a/xorg-server/hw/xfree86/int10/generic.c b/xorg-server/hw/xfree86/int10/generic.c
index fbc9b8507..8614e0b9b 100644
--- a/xorg-server/hw/xfree86/int10/generic.c
+++ b/xorg-server/hw/xfree86/int10/generic.c
@@ -20,12 +20,12 @@
#define ALLOC_ENTRIES(x) ((V_RAM / x) - 1)
-static CARD8 read_b(xf86Int10InfoPtr pInt,int addr);
-static CARD16 read_w(xf86Int10InfoPtr pInt,int addr);
-static CARD32 read_l(xf86Int10InfoPtr pInt,int addr);
-static void write_b(xf86Int10InfoPtr pInt,int addr, CARD8 val);
-static void write_w(xf86Int10InfoPtr pInt,int addr, CARD16 val);
-static void write_l(xf86Int10InfoPtr pInt,int addr, CARD32 val);
+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
@@ -35,11 +35,11 @@ static void write_l(xf86Int10InfoPtr pInt,int addr, CARD32 val);
typedef struct {
int shift;
int entries;
- void* base;
- void* vRam;
+ void *base;
+ void *vRam;
int highMemory;
- void* sysMem;
- char* alloc;
+ void *sysMem;
+ char *alloc;
} genericInt10Priv;
#define INTPriv(x) ((genericInt10Priv*)x->private)
@@ -55,6 +55,7 @@ int10MemRec genericMem = {
static void MapVRam(xf86Int10InfoPtr pInt);
static void UnmapVRam(xf86Int10InfoPtr pInt);
+
#ifdef _PC
#define GET_HIGH_BASE(x) (((V_BIOS + (x) + getpagesize() - 1)/getpagesize()) \
* getpagesize())
@@ -66,28 +67,28 @@ xf86Int10InfoPtr
xf86ExtendedInitInt10(int entityIndex, int Flags)
{
xf86Int10InfoPtr pInt;
- void* base = 0;
- void* vbiosMem = 0;
- void* options = NULL;
+ void *base = 0;
+ void *vbiosMem = 0;
+ void *options = NULL;
int screen;
legacyVGARec vga;
-
+
screen = (xf86FindScreenForEntity(entityIndex))->scrnIndex;
- options = xf86HandleInt10Options(xf86Screens[screen],entityIndex);
-
+ options = xf86HandleInt10Options(xf86Screens[screen], entityIndex);
+
if (int10skip(options)) {
- free(options);
- return NULL;
+ free(options);
+ return NULL;
}
-
- pInt = (xf86Int10InfoPtr)xnfcalloc(1, sizeof(xf86Int10InfoRec));
+
+ pInt = (xf86Int10InfoPtr) xnfcalloc(1, sizeof(xf86Int10InfoRec));
pInt->entityIndex = entityIndex;
if (!xf86Int10ExecSetup(pInt))
- goto error0;
+ goto error0;
pInt->mem = &genericMem;
- pInt->private = (pointer)xnfcalloc(1, sizeof(genericInt10Priv));
- INTPriv(pInt)->alloc = (pointer)xnfcalloc(1, ALLOC_ENTRIES(getpagesize()));
+ pInt->private = (pointer) xnfcalloc(1, sizeof(genericInt10Priv));
+ INTPriv(pInt)->alloc = (pointer) xnfcalloc(1, ALLOC_ENTRIES(getpagesize()));
pInt->scrnIndex = screen;
base = INTPriv(pInt)->base = xnfalloc(SYS_BIOS);
@@ -103,69 +104,70 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
MapVRam(pInt);
#ifdef _PC
if (!sysMem)
- pci_device_map_legacy(pInt->dev, V_BIOS, BIOS_SIZE + SYS_BIOS - V_BIOS,
- PCI_DEV_MAP_FLAG_WRITABLE, &sysMem);
+ pci_device_map_legacy(pInt->dev, V_BIOS, BIOS_SIZE + SYS_BIOS - V_BIOS,
+ PCI_DEV_MAP_FLAG_WRITABLE, &sysMem);
INTPriv(pInt)->sysMem = sysMem;
if (xf86ReadBIOS(0, 0, base, LOW_PAGE_SIZE) < 0) {
- xf86DrvMsg(screen, X_ERROR, "Cannot read int vect\n");
- goto error1;
+ xf86DrvMsg(screen, X_ERROR, "Cannot read int vect\n");
+ goto error1;
}
/*
* Retrieve everything between V_BIOS and SYS_BIOS as some system BIOSes
* have executable code there.
*/
- memset((char *)base + V_BIOS, 0, SYS_BIOS - V_BIOS);
+ memset((char *) base + V_BIOS, 0, SYS_BIOS - V_BIOS);
INTPriv(pInt)->highMemory = V_BIOS;
-
+
if (xf86IsEntityPrimary(entityIndex) && !(initPrimary(options))) {
- if (!xf86int10GetBiosSegment(pInt, (unsigned char *)sysMem - V_BIOS))
- goto error1;
+ if (!xf86int10GetBiosSegment(pInt, (unsigned char *) sysMem - V_BIOS))
+ goto error1;
+
+ set_return_trap(pInt);
- set_return_trap(pInt);
+ pInt->Flags = Flags & (SET_BIOS_SCRATCH | RESTORE_BIOS_SCRATCH);
+ if (!(pInt->Flags & SET_BIOS_SCRATCH))
+ pInt->Flags &= ~RESTORE_BIOS_SCRATCH;
+ xf86Int10SaveRestoreBIOSVars(pInt, TRUE);
- pInt->Flags = Flags & (SET_BIOS_SCRATCH | RESTORE_BIOS_SCRATCH);
- if (! (pInt->Flags & SET_BIOS_SCRATCH))
- pInt->Flags &= ~RESTORE_BIOS_SCRATCH;
- xf86Int10SaveRestoreBIOSVars(pInt, TRUE);
-
- } else {
- const BusType location_type = xf86int10GetBiosLocationType(pInt);
- int bios_location = V_BIOS;
+ }
+ else {
+ const BusType location_type = xf86int10GetBiosLocationType(pInt);
+ int bios_location = V_BIOS;
reset_int_vect(pInt);
- set_return_trap(pInt);
-
- switch (location_type) {
- case BUS_PCI: {
- int err;
- struct pci_device *rom_device =
- xf86GetPciInfoForEntity(pInt->entityIndex);
-
- vbiosMem = (unsigned char *)base + bios_location;
- err = pci_device_read_rom(rom_device, vbiosMem);
- if (err) {
- xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (3) %s\n",
- strerror(err));
- goto error1;
- }
- INTPriv(pInt)->highMemory = GET_HIGH_BASE(rom_device->rom_size);
- break;
- }
- default:
- goto error1;
- }
- pInt->BIOSseg = V_BIOS >> 4;
- pInt->num = 0xe6;
- LockLegacyVGA(pInt, &vga);
- xf86ExecX86int10(pInt);
- UnlockLegacyVGA(pInt, &vga);
+ set_return_trap(pInt);
+
+ switch (location_type) {
+ case BUS_PCI:{
+ int err;
+ struct pci_device *rom_device =
+ xf86GetPciInfoForEntity(pInt->entityIndex);
+
+ vbiosMem = (unsigned char *) base + bios_location;
+ err = pci_device_read_rom(rom_device, vbiosMem);
+ if (err) {
+ xf86DrvMsg(screen, X_ERROR, "Cannot read V_BIOS (3) %s\n",
+ strerror(err));
+ goto error1;
+ }
+ INTPriv(pInt)->highMemory = GET_HIGH_BASE(rom_device->rom_size);
+ break;
+ }
+ default:
+ goto error1;
+ }
+ pInt->BIOSseg = V_BIOS >> 4;
+ pInt->num = 0xe6;
+ LockLegacyVGA(pInt, &vga);
+ xf86ExecX86int10(pInt);
+ UnlockLegacyVGA(pInt, &vga);
}
#else
if (!sysMem) {
- sysMem = xnfalloc(BIOS_SIZE);
- setup_system_bios(sysMem);
+ sysMem = xnfalloc(BIOS_SIZE);
+ setup_system_bios(sysMem);
}
INTPriv(pInt)->sysMem = sysMem;
setup_int_vect(pInt);
@@ -174,11 +176,11 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
/* Retrieve the entire legacy video BIOS segment. This can be upto
* 128KiB.
*/
- vbiosMem = (char *)base + V_BIOS;
+ vbiosMem = (char *) base + V_BIOS;
memset(vbiosMem, 0, 2 * V_BIOS_SIZE);
if (pci_device_read_rom(pInt->dev, vbiosMem) < V_BIOS_SIZE) {
- xf86DrvMsg(screen, X_WARNING,
- "Unable to retrieve all of segment 0x0C0000.\n");
+ xf86DrvMsg(screen, X_WARNING,
+ "Unable to retrieve all of segment 0x0C0000.\n");
}
/*
@@ -186,29 +188,30 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
* it).
*/
{
- int bios_location = V_BIOS;
- Bool done = FALSE;
- vbiosMem = (unsigned char *)base + bios_location;
-
- if (xf86IsEntityPrimary(entityIndex)) {
- if (int10_check_bios(screen, bios_location >> 4, vbiosMem))
- done = TRUE;
- else
- xf86DrvMsg(screen,X_INFO,
- "No legacy BIOS found -- trying PCI\n");
- }
- if (!done) {
- int err;
- struct pci_device *rom_device =
- xf86GetPciInfoForEntity(pInt->entityIndex);
-
- err = pci_device_read_rom(rom_device, vbiosMem);
- if (err) {
- xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (5) %s\n",
- strerror(err));
- goto error1;
- }
- }
+ int bios_location = V_BIOS;
+ Bool done = FALSE;
+
+ vbiosMem = (unsigned char *) base + bios_location;
+
+ if (xf86IsEntityPrimary(entityIndex)) {
+ if (int10_check_bios(screen, bios_location >> 4, vbiosMem))
+ done = TRUE;
+ else
+ xf86DrvMsg(screen, X_INFO,
+ "No legacy BIOS found -- trying PCI\n");
+ }
+ if (!done) {
+ int err;
+ struct pci_device *rom_device =
+ xf86GetPciInfoForEntity(pInt->entityIndex);
+
+ err = pci_device_read_rom(rom_device, vbiosMem);
+ if (err) {
+ xf86DrvMsg(screen, X_ERROR, "Cannot read V_BIOS (5) %s\n",
+ strerror(err));
+ goto error1;
+ }
+ }
}
pInt->BIOSseg = V_BIOS >> 4;
@@ -228,7 +231,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
error0:
free(pInt);
free(options);
-
+
return NULL;
}
@@ -238,7 +241,8 @@ MapVRam(xf86Int10InfoPtr pInt)
int pagesize = getpagesize();
int size = ((VRAM_SIZE + pagesize - 1) / pagesize) * pagesize;
- pci_device_map_legacy(pInt->dev, V_RAM, size, PCI_DEV_MAP_FLAG_WRITABLE, &(INTPriv(pInt)->vRam));
+ pci_device_map_legacy(pInt->dev, V_RAM, size, PCI_DEV_MAP_FLAG_WRITABLE,
+ &(INTPriv(pInt)->vRam));
pInt->io = pci_legacy_open_io(pInt->dev, 0, 64 * 1024);
}
@@ -247,7 +251,7 @@ UnmapVRam(xf86Int10InfoPtr pInt)
{
int screen = pInt->scrnIndex;
int pagesize = getpagesize();
- int size = ((VRAM_SIZE + pagesize - 1)/pagesize) * pagesize;
+ int size = ((VRAM_SIZE + pagesize - 1) / pagesize) * pagesize;
pci_device_unmap_legacy(pInt->dev, INTPriv(pInt)->vRam, size);
pci_device_close_io(pInt->dev, pInt->io);
@@ -265,12 +269,12 @@ void
xf86FreeInt10(xf86Int10InfoPtr pInt)
{
if (!pInt)
- return;
+ return;
#if defined (_PC)
xf86Int10SaveRestoreBIOSVars(pInt, FALSE);
#endif
if (Int10Current == pInt)
- Int10Current = NULL;
+ Int10Current = NULL;
free(INTPriv(pInt)->base);
UnmapVRam(pInt);
free(INTPriv(pInt)->alloc);
@@ -283,49 +287,50 @@ xf86Int10AllocPages(xf86Int10InfoPtr pInt, int num, int *off)
{
int pagesize = getpagesize();
int num_pages = ALLOC_ENTRIES(pagesize);
- int i,j;
+ int i, j;
for (i = 0; i < (num_pages - num); i++) {
- if (INTPriv(pInt)->alloc[i] == 0) {
- for (j = i; j < (num + i); j++)
- if (INTPriv(pInt)->alloc[j] != 0)
- break;
- if (j == (num + i))
- break;
- i += num;
- }
+ if (INTPriv(pInt)->alloc[i] == 0) {
+ for (j = i; j < (num + i); j++)
+ if (INTPriv(pInt)->alloc[j] != 0)
+ break;
+ if (j == (num + i))
+ break;
+ i += num;
+ }
}
if (i == (num_pages - num))
- return NULL;
+ return NULL;
for (j = i; j < (i + num); j++)
- INTPriv(pInt)->alloc[j] = 1;
+ INTPriv(pInt)->alloc[j] = 1;
*off = (i + 1) * pagesize;
- return (char *)INTPriv(pInt)->base + *off;
+ return (char *) INTPriv(pInt)->base + *off;
}
void
xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase, int num)
{
int pagesize = getpagesize();
- int first = (((char *)pbase - (char *)INTPriv(pInt)->base) / pagesize) - 1;
+ int first =
+ (((char *) pbase - (char *) INTPriv(pInt)->base) / pagesize) - 1;
int i;
for (i = first; i < (first + num); i++)
- INTPriv(pInt)->alloc[i] = 0;
+ INTPriv(pInt)->alloc[i] = 0;
}
#define OFF(addr) ((addr) & 0xffff)
#if defined _PC
-# define HIGH_OFFSET (INTPriv(pInt)->highMemory)
-# define HIGH_BASE V_BIOS
+#define HIGH_OFFSET (INTPriv(pInt)->highMemory)
+#define HIGH_BASE V_BIOS
#else
-# define HIGH_OFFSET SYS_BIOS
-# define HIGH_BASE SYS_BIOS
+#define HIGH_OFFSET SYS_BIOS
+#define HIGH_BASE SYS_BIOS
#endif
-# define SYS(addr) ((addr) >= HIGH_OFFSET)
+#define SYS(addr) ((addr) >= HIGH_OFFSET)
#define V_ADDR(addr) \
(SYS(addr) ? ((char*)INTPriv(pInt)->sysMem) + (addr - HIGH_BASE) \
: (((char*)(INTPriv(pInt)->base) + addr)))
@@ -371,7 +376,7 @@ read_w(xf86Int10InfoPtr pInt, int addr)
{
#if X_BYTE_ORDER == X_LITTLE_ENDIAN
if (OFF(addr + 1) > 0)
- return V_ADDR_RW(addr);
+ return V_ADDR_RW(addr);
#endif
return V_ADDR_RB(addr) | (V_ADDR_RB(addr + 1) << 8);
}
@@ -381,26 +386,26 @@ read_l(xf86Int10InfoPtr pInt, int addr)
{
#if X_BYTE_ORDER == X_LITTLE_ENDIAN
if (OFF(addr + 3) > 2)
- return V_ADDR_RL(addr);
+ return V_ADDR_RL(addr);
#endif
return V_ADDR_RB(addr) |
- (V_ADDR_RB(addr + 1) << 8) |
- (V_ADDR_RB(addr + 2) << 16) |
- (V_ADDR_RB(addr + 3) << 24);
+ (V_ADDR_RB(addr + 1) << 8) |
+ (V_ADDR_RB(addr + 2) << 16) | (V_ADDR_RB(addr + 3) << 24);
}
static void
write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val)
{
- V_ADDR_WB(addr,val);
+ V_ADDR_WB(addr, val);
}
static void
write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val)
{
#if X_BYTE_ORDER == X_LITTLE_ENDIAN
- if (OFF(addr + 1) > 0)
- { V_ADDR_WW(addr, val); }
+ if (OFF(addr + 1) > 0) {
+ V_ADDR_WW(addr, val);
+ }
#endif
V_ADDR_WB(addr, val);
V_ADDR_WB(addr + 1, val >> 8);
@@ -410,8 +415,9 @@ static void
write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val)
{
#if X_BYTE_ORDER == X_LITTLE_ENDIAN
- if (OFF(addr + 3) > 2)
- { V_ADDR_WL(addr, val); }
+ if (OFF(addr + 3) > 2) {
+ V_ADDR_WL(addr, val);
+ }
#endif
V_ADDR_WB(addr, val);
V_ADDR_WB(addr + 1, val >> 8);
diff --git a/xorg-server/hw/xfree86/int10/helper_exec.c b/xorg-server/hw/xfree86/int10/helper_exec.c
index 03f9f7da6..1e908778f 100644
--- a/xorg-server/hw/xfree86/int10/helper_exec.c
+++ b/xorg-server/hw/xfree86/int10/helper_exec.c
@@ -43,6 +43,7 @@ static int pciCfg1inw(CARD16 addr, CARD16 *val);
static int pciCfg1outw(CARD16 addr, CARD16 val);
static int pciCfg1inb(CARD16 addr, CARD8 *val);
static int pciCfg1outb(CARD16 addr, CARD8 val);
+
#if defined (_PC)
static void SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set);
#endif
@@ -53,9 +54,9 @@ int
setup_int(xf86Int10InfoPtr pInt)
{
if (pInt != Int10Current) {
- if (!MapCurrentInt10(pInt))
- return -1;
- Int10Current = pInt;
+ if (!MapCurrentInt10(pInt))
+ return -1;
+ Int10Current = pInt;
}
X86_EAX = (CARD32) pInt->ax;
X86_EBX = (CARD32) pInt->bx;
@@ -64,16 +65,18 @@ setup_int(xf86Int10InfoPtr pInt)
X86_ESI = (CARD32) pInt->si;
X86_EDI = (CARD32) pInt->di;
X86_EBP = (CARD32) pInt->bp;
- X86_ESP = 0x1000; X86_SS = pInt->stackseg >> 4;
- X86_EIP = 0x0600; X86_CS = 0x0; /* address of 'hlt' */
- X86_DS = 0x40; /* standard pc ds */
+ X86_ESP = 0x1000;
+ X86_SS = pInt->stackseg >> 4;
+ X86_EIP = 0x0600;
+ X86_CS = 0x0; /* address of 'hlt' */
+ X86_DS = 0x40; /* standard pc ds */
X86_ES = pInt->es;
X86_FS = 0;
X86_GS = 0;
X86_EFLAGS = X86_IF_MASK | X86_IOPL_MASK;
#if defined (_PC)
if (pInt->Flags & SET_BIOS_SCRATCH)
- SetResetBIOSVars(pInt, TRUE);
+ SetResetBIOSVars(pInt, TRUE);
#endif
OsBlockSignals();
return 0;
@@ -94,13 +97,13 @@ finish_int(xf86Int10InfoPtr pInt, int sig)
pInt->flags = (CARD32) X86_FLAGS;
#if defined (_PC)
if (pInt->Flags & RESTORE_BIOS_SCRATCH)
- SetResetBIOSVars(pInt, FALSE);
+ SetResetBIOSVars(pInt, FALSE);
#endif
}
/* general software interrupt handler */
CARD32
-getIntVect(xf86Int10InfoPtr pInt,int num)
+getIntVect(xf86Int10InfoPtr pInt, int num)
{
return MEM_RW(pInt, num << 2) + (MEM_RW(pInt, (num << 2) + 2) << 4);
}
@@ -116,26 +119,28 @@ int
run_bios_int(int num, xf86Int10InfoPtr pInt)
{
CARD32 eflags;
+
#ifndef _PC
/* check if bios vector is initialized */
- if (MEM_RW(pInt, (num << 2) + 2) == (SYS_BIOS >> 4)) { /* SYS_BIOS_SEG ?*/
-
- if (num == 21 && X86_AH == 0x4e) {
- xf86DrvMsg(pInt->scrnIndex, X_NOTICE,
- "Failing Find-Matching-File on non-PC"
- " (int 21, func 4e)\n");
- X86_AX = 2;
- SET_FLAG(F_CF);
- return 1;
- } else {
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
- "Ignoring int 0x%02x call\n", num);
- if (xf86GetVerbosity() > 3) {
- dump_registers(pInt);
- stack_trace(pInt);
- }
- return 1;
- }
+ if (MEM_RW(pInt, (num << 2) + 2) == (SYS_BIOS >> 4)) { /* SYS_BIOS_SEG ? */
+
+ if (num == 21 && X86_AH == 0x4e) {
+ xf86DrvMsg(pInt->scrnIndex, X_NOTICE,
+ "Failing Find-Matching-File on non-PC"
+ " (int 21, func 4e)\n");
+ X86_AX = 2;
+ SET_FLAG(F_CF);
+ return 1;
+ }
+ else {
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
+ "Ignoring int 0x%02x call\n", num);
+ if (xf86GetVerbosity() > 3) {
+ dump_registers(pInt);
+ stack_trace(pInt);
+ }
+ return 1;
+ }
}
#endif
#ifdef PRINT_INT
@@ -144,13 +149,13 @@ run_bios_int(int num, xf86Int10InfoPtr pInt)
eflags = X86_EFLAGS;
#if 0
eflags = eflags | IF_MASK;
- X86_EFLAGS = X86_EFLAGS & ~(VIF_MASK | TF_MASK | IF_MASK | NT_MASK);
+ X86_EFLAGS = X86_EFLAGS & ~(VIF_MASK | TF_MASK | IF_MASK | NT_MASK);
#endif
pushw(pInt, eflags);
pushw(pInt, X86_CS);
pushw(pInt, X86_IP);
X86_CS = MEM_RW(pInt, (num << 2) + 2);
- X86_IP = MEM_RW(pInt, num << 2);
+ X86_IP = MEM_RW(pInt, num << 2);
#ifdef PRINT_INT
ErrorF("0x%x:%lx\n", X86_CS, X86_EIP);
#endif
@@ -164,12 +169,13 @@ dump_code(xf86Int10InfoPtr pInt)
int i;
CARD32 lina = SEG_ADR((CARD32), X86_CS, IP);
- xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3, "code at 0x%8.8" PRIx32 ":\n", lina);
- for (i=0; i<0x10; i++)
- xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, lina + i));
+ xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3, "code at 0x%8.8" PRIx32 ":\n",
+ lina);
+ for (i = 0; i < 0x10; i++)
+ xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, lina + i));
xf86ErrorFVerb(3, "\n");
- for (; i<0x20; i++)
- xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, lina + i));
+ for (; i < 0x20; i++)
+ xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, lina + i));
xf86ErrorFVerb(3, "\n");
}
@@ -177,20 +183,20 @@ void
dump_registers(xf86Int10InfoPtr pInt)
{
xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3,
- "EAX=0x%8.8lx, EBX=0x%8.8lx, ECX=0x%8.8lx, EDX=0x%8.8lx\n",
- (unsigned long)X86_EAX, (unsigned long)X86_EBX,
- (unsigned long)X86_ECX, (unsigned long)X86_EDX);
+ "EAX=0x%8.8lx, EBX=0x%8.8lx, ECX=0x%8.8lx, EDX=0x%8.8lx\n",
+ (unsigned long) X86_EAX, (unsigned long) X86_EBX,
+ (unsigned long) X86_ECX, (unsigned long) X86_EDX);
xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3,
- "ESP=0x%8.8lx, EBP=0x%8.8lx, ESI=0x%8.8lx, EDI=0x%8.8lx\n",
- (unsigned long)X86_ESP, (unsigned long)X86_EBP,
- (unsigned long)X86_ESI, (unsigned long)X86_EDI);
+ "ESP=0x%8.8lx, EBP=0x%8.8lx, ESI=0x%8.8lx, EDI=0x%8.8lx\n",
+ (unsigned long) X86_ESP, (unsigned long) X86_EBP,
+ (unsigned long) X86_ESI, (unsigned long) X86_EDI);
xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3,
- "CS=0x%4.4x, SS=0x%4.4x,"
- " DS=0x%4.4x, ES=0x%4.4x, FS=0x%4.4x, GS=0x%4.4x\n",
- X86_CS, X86_SS, X86_DS, X86_ES, X86_FS, X86_GS);
+ "CS=0x%4.4x, SS=0x%4.4x,"
+ " DS=0x%4.4x, ES=0x%4.4x, FS=0x%4.4x, GS=0x%4.4x\n",
+ X86_CS, X86_SS, X86_DS, X86_ES, X86_FS, X86_GS);
xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3,
- "EIP=0x%8.8lx, EFLAGS=0x%8.8lx\n",
- (unsigned long)X86_EIP, (unsigned long)X86_EFLAGS);
+ "EIP=0x%8.8lx, EFLAGS=0x%8.8lx\n",
+ (unsigned long) X86_EIP, (unsigned long) X86_EFLAGS);
}
void
@@ -198,113 +204,120 @@ stack_trace(xf86Int10InfoPtr pInt)
{
int i = 0;
unsigned long stack = SEG_ADR((CARD32), X86_SS, SP);
- unsigned long tail = (CARD32)((X86_SS << 4) + 0x1000);
+ unsigned long tail = (CARD32) ((X86_SS << 4) + 0x1000);
- if (stack >= tail) return;
+ if (stack >= tail)
+ return;
xf86MsgVerb(X_INFO, 3, "stack at 0x%8.8lx:\n", stack);
for (; stack < tail; stack++) {
- xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, stack));
- i = (i + 1) % 0x10;
- if (!i)
- xf86ErrorFVerb(3, "\n");
+ xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, stack));
+ i = (i + 1) % 0x10;
+ if (!i)
+ xf86ErrorFVerb(3, "\n");
}
if (i)
- xf86ErrorFVerb(3, "\n");
+ xf86ErrorFVerb(3, "\n");
}
int
port_rep_inb(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count)
+ CARD16 port, CARD32 base, int d_f, CARD32 count)
{
register int inc = d_f ? -1 : 1;
CARD32 dst = base;
+
if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" rep_insb(%#x) %" PRIu32 " bytes at %8.8" PRIx32 " %s\n",
- port, count, base, d_f ? "up" : "down");
+ ErrorF(" rep_insb(%#x) %" PRIu32 " bytes at %8.8" PRIx32 " %s\n",
+ port, count, base, d_f ? "up" : "down");
while (count--) {
- MEM_WB(pInt, dst, x_inb(port));
- dst += inc;
+ MEM_WB(pInt, dst, x_inb(port));
+ dst += inc;
}
return dst - base;
}
int
port_rep_inw(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count)
+ CARD16 port, CARD32 base, int d_f, CARD32 count)
{
register int inc = d_f ? -2 : 2;
CARD32 dst = base;
+
if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" rep_insw(%#x) %" PRIu32 " bytes at %8.8" PRIx32 " %s\n",
- port, count, base, d_f ? "up" : "down");
+ ErrorF(" rep_insw(%#x) %" PRIu32 " bytes at %8.8" PRIx32 " %s\n",
+ port, count, base, d_f ? "up" : "down");
while (count--) {
- MEM_WW(pInt, dst, x_inw(port));
- dst += inc;
+ MEM_WW(pInt, dst, x_inw(port));
+ dst += inc;
}
return dst - base;
}
int
port_rep_inl(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count)
+ CARD16 port, CARD32 base, int d_f, CARD32 count)
{
register int inc = d_f ? -4 : 4;
CARD32 dst = base;
+
if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" rep_insl(%#x) %" PRIu32 " bytes at %8.8" PRIx32 " %s\n",
- port, count, base, d_f ? "up" : "down");
+ ErrorF(" rep_insl(%#x) %" PRIu32 " bytes at %8.8" PRIx32 " %s\n",
+ port, count, base, d_f ? "up" : "down");
while (count--) {
- MEM_WL(pInt, dst, x_inl(port));
- dst += inc;
+ MEM_WL(pInt, dst, x_inl(port));
+ dst += inc;
}
return dst - base;
}
int
port_rep_outb(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count)
+ CARD16 port, CARD32 base, int d_f, CARD32 count)
{
register int inc = d_f ? -1 : 1;
CARD32 dst = base;
+
if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" rep_outb(%#x) %" PRIu32 " bytes at %8.8" PRIx32 " %s\n",
- port, count, base, d_f ? "up" : "down");
+ ErrorF(" rep_outb(%#x) %" PRIu32 " bytes at %8.8" PRIx32 " %s\n",
+ port, count, base, d_f ? "up" : "down");
while (count--) {
- x_outb(port, MEM_RB(pInt, dst));
- dst += inc;
+ x_outb(port, MEM_RB(pInt, dst));
+ dst += inc;
}
return dst - base;
}
int
port_rep_outw(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count)
+ CARD16 port, CARD32 base, int d_f, CARD32 count)
{
register int inc = d_f ? -2 : 2;
CARD32 dst = base;
+
if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" rep_outw(%#x) %" PRIu32 " bytes at %8.8" PRIx32 " %s\n",
- port, count, base, d_f ? "up" : "down");
+ ErrorF(" rep_outw(%#x) %" PRIu32 " bytes at %8.8" PRIx32 " %s\n",
+ port, count, base, d_f ? "up" : "down");
while (count--) {
- x_outw(port, MEM_RW(pInt, dst));
- dst += inc;
+ x_outw(port, MEM_RW(pInt, dst));
+ dst += inc;
}
return dst - base;
}
int
port_rep_outl(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count)
+ CARD16 port, CARD32 base, int d_f, CARD32 count)
{
register int inc = d_f ? -4 : 4;
CARD32 dst = base;
+
if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" rep_outl(%#x) %" PRIu32 " bytes at %8.8" PRIx32 " %s\n",
- port, count, base, d_f ? "up" : "down");
+ ErrorF(" rep_outl(%#x) %" PRIu32 " bytes at %8.8" PRIx32 " %s\n",
+ port, count, base, d_f ? "up" : "down");
while (count--) {
- x_outl(port, MEM_RL(pInt, dst));
- dst += inc;
+ x_outl(port, MEM_RL(pInt, dst));
+ dst += inc;
}
return dst - base;
}
@@ -315,25 +328,27 @@ x_inb(CARD16 port)
CARD8 val;
if (port == 0x40) {
- Int10Current->inb40time++;
- val = (CARD8)(Int10Current->inb40time >>
- ((Int10Current->inb40time & 1) << 3));
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" inb(%#x) = %2.2x\n", port, val);
+ Int10Current->inb40time++;
+ val = (CARD8) (Int10Current->inb40time >>
+ ((Int10Current->inb40time & 1) << 3));
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" inb(%#x) = %2.2x\n", port, val);
#ifdef __NOT_YET__
- } else if (port < 0x0100) { /* Don't interfere with mainboard */
- val = 0;
- xf86DrvMsgVerb(Int10Current->scrnIndex, X_NOT_IMPLEMENTED, 2,
- "inb 0x%4.4x\n", port);
- if (xf86GetVerbosity() > 3) {
- dump_registers(Int10Current);
- stack_trace(Int10Current);
- }
-#endif /* __NOT_YET__ */
- } else if (!pciCfg1inb(port, &val)) {
- val = pci_io_read8(Int10Current->io, port);
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" inb(%#x) = %2.2x\n", port, val);
+ }
+ else if (port < 0x0100) { /* Don't interfere with mainboard */
+ val = 0;
+ xf86DrvMsgVerb(Int10Current->scrnIndex, X_NOT_IMPLEMENTED, 2,
+ "inb 0x%4.4x\n", port);
+ if (xf86GetVerbosity() > 3) {
+ dump_registers(Int10Current);
+ stack_trace(Int10Current);
+ }
+#endif /* __NOT_YET__ */
+ }
+ else if (!pciCfg1inb(port, &val)) {
+ val = pci_io_read8(Int10Current->io, port);
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" inb(%#x) = %2.2x\n", port, val);
}
return val;
}
@@ -344,18 +359,19 @@ x_inw(CARD16 port)
CARD16 val;
if (port == 0x5c) {
- struct timeval tv;
-
- /*
- * Emulate a PC's timer. Typical resolution is 3.26 usec.
- * Approximate this by dividing by 3.
- */
- X_GETTIMEOFDAY(&tv);
- val = (CARD16)(tv.tv_usec / 3);
- } else if (!pciCfg1inw(port, &val)) {
- val = pci_io_read16(Int10Current->io, port);
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" inw(%#x) = %4.4x\n", port, val);
+ struct timeval tv;
+
+ /*
+ * Emulate a PC's timer. Typical resolution is 3.26 usec.
+ * Approximate this by dividing by 3.
+ */
+ X_GETTIMEOFDAY(&tv);
+ val = (CARD16) (tv.tv_usec / 3);
+ }
+ else if (!pciCfg1inw(port, &val)) {
+ val = pci_io_read16(Int10Current->io, port);
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" inw(%#x) = %4.4x\n", port, val);
}
return val;
}
@@ -364,30 +380,33 @@ void
x_outb(CARD16 port, CARD8 val)
{
if ((port == 0x43) && (val == 0)) {
- struct timeval tv;
- /*
- * Emulate a PC's timer 0. Such timers typically have a resolution of
- * some .838 usec per tick, but this can only provide 1 usec per tick.
- * (Not that this matters much, given inherent emulation delays.) Use
- * the bottom bit as a byte select. See inb(0x40) above.
- */
- X_GETTIMEOFDAY(&tv);
- Int10Current->inb40time = (CARD16)(tv.tv_usec | 1);
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" outb(%#x, %2.2x)\n", port, val);
+ struct timeval tv;
+
+ /*
+ * Emulate a PC's timer 0. Such timers typically have a resolution of
+ * some .838 usec per tick, but this can only provide 1 usec per tick.
+ * (Not that this matters much, given inherent emulation delays.) Use
+ * the bottom bit as a byte select. See inb(0x40) above.
+ */
+ X_GETTIMEOFDAY(&tv);
+ Int10Current->inb40time = (CARD16) (tv.tv_usec | 1);
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" outb(%#x, %2.2x)\n", port, val);
#ifdef __NOT_YET__
- } else if (port < 0x0100) { /* Don't interfere with mainboard */
- xf86DrvMsgVerb(Int10Current->scrnIndex, X_NOT_IMPLEMENTED, 2,
- "outb 0x%4.4x,0x%2.2x\n", port, val);
- if (xf86GetVerbosity() > 3) {
- dump_registers(Int10Current);
- stack_trace(Int10Current);
- }
-#endif /* __NOT_YET__ */
- } else if (!pciCfg1outb(port, val)) {
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" outb(%#x, %2.2x)\n", port, val);
- pci_io_write8(Int10Current->io, port, val);
+ }
+ else if (port < 0x0100) { /* Don't interfere with mainboard */
+ xf86DrvMsgVerb(Int10Current->scrnIndex, X_NOT_IMPLEMENTED, 2,
+ "outb 0x%4.4x,0x%2.2x\n", port, val);
+ if (xf86GetVerbosity() > 3) {
+ dump_registers(Int10Current);
+ stack_trace(Int10Current);
+ }
+#endif /* __NOT_YET__ */
+ }
+ else if (!pciCfg1outb(port, val)) {
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" outb(%#x, %2.2x)\n", port, val);
+ pci_io_write8(Int10Current->io, port, val);
}
}
@@ -396,9 +415,9 @@ x_outw(CARD16 port, CARD16 val)
{
if (!pciCfg1outw(port, val)) {
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" outw(%#x, %4.4x)\n", port, val);
- pci_io_write16(Int10Current->io, port, val);
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" outw(%#x, %4.4x)\n", port, val);
+ pci_io_write16(Int10Current->io, port, val);
}
}
@@ -408,9 +427,9 @@ x_inl(CARD16 port)
CARD32 val;
if (!pciCfg1in(port, &val)) {
- val = pci_io_read32(Int10Current->io, port);
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" inl(%#x) = %8.8" PRIx32 "\n", port, val);
+ val = pci_io_read32(Int10Current->io, port);
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" inl(%#x) = %8.8" PRIx32 "\n", port, val);
}
return val;
}
@@ -419,46 +438,46 @@ void
x_outl(CARD16 port, CARD32 val)
{
if (!pciCfg1out(port, val)) {
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" outl(%#x, %8.8" PRIx32 ")\n", port, val);
- pci_io_write32(Int10Current->io, port, val);
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" outl(%#x, %8.8" PRIx32 ")\n", port, val);
+ pci_io_write32(Int10Current->io, port, val);
}
}
CARD8
Mem_rb(CARD32 addr)
{
- return (*Int10Current->mem->rb)(Int10Current, addr);
+ return (*Int10Current->mem->rb) (Int10Current, addr);
}
CARD16
Mem_rw(CARD32 addr)
{
- return (*Int10Current->mem->rw)(Int10Current, addr);
+ return (*Int10Current->mem->rw) (Int10Current, addr);
}
CARD32
Mem_rl(CARD32 addr)
{
- return (*Int10Current->mem->rl)(Int10Current, addr);
+ return (*Int10Current->mem->rl) (Int10Current, addr);
}
void
Mem_wb(CARD32 addr, CARD8 val)
{
- (*Int10Current->mem->wb)(Int10Current, addr, val);
+ (*Int10Current->mem->wb) (Int10Current, addr, val);
}
void
Mem_ww(CARD32 addr, CARD16 val)
{
- (*Int10Current->mem->ww)(Int10Current, addr, val);
+ (*Int10Current->mem->ww) (Int10Current, addr, val);
}
void
Mem_wl(CARD32 addr, CARD32 val)
{
- (*Int10Current->mem->wl)(Int10Current, addr, val);
+ (*Int10Current->mem->wl) (Int10Current, addr, val);
}
static CARD32 PciCfg1Addr = 0;
@@ -471,43 +490,45 @@ static CARD32 PciCfg1Addr = 0;
#define PCI_OFFSET(x) ((x) & 0x000000ff)
#define PCI_TAG(x) ((x) & 0x7fffff00)
-static struct pci_device*
-pci_device_for_cfg_address (CARD32 addr)
+static struct pci_device *
+pci_device_for_cfg_address(CARD32 addr)
{
- struct pci_device *dev = NULL;
- CARD32 tag = PCI_TAG(addr);
- struct pci_slot_match slot_match = {
- .domain = PCI_DOM_FROM_TAG(tag),
- .bus = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(tag)),
- .dev = PCI_DEV_FROM_TAG(tag),
- .func = PCI_FUNC_FROM_TAG(tag),
- .match_data = 0
- };
+ struct pci_device *dev = NULL;
+ CARD32 tag = PCI_TAG(addr);
+
+ struct pci_slot_match slot_match = {
+ .domain = PCI_DOM_FROM_TAG(tag),
+ .bus = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(tag)),
+ .dev = PCI_DEV_FROM_TAG(tag),
+ .func = PCI_FUNC_FROM_TAG(tag),
+ .match_data = 0
+ };
- struct pci_device_iterator *iter =
- pci_slot_match_iterator_create (&slot_match);
+ struct pci_device_iterator *iter =
+ pci_slot_match_iterator_create(&slot_match);
- if (iter)
- dev = pci_device_next(iter);
+ if (iter)
+ dev = pci_device_next(iter);
- pci_iterator_destroy(iter);
+ pci_iterator_destroy(iter);
- return dev;
+ return dev;
}
static int
pciCfg1in(CARD16 addr, CARD32 *val)
{
if (addr == 0xCF8) {
- *val = PciCfg1Addr;
- return 1;
+ *val = PciCfg1Addr;
+ return 1;
}
if (addr == 0xCFC) {
- pci_device_cfg_read_u32(pci_device_for_cfg_address(PciCfg1Addr),
- (uint32_t *)val, PCI_OFFSET(PciCfg1Addr));
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" cfg_inl(%#" PRIx32 ") = %8.8" PRIx32 "\n", PciCfg1Addr, *val);
- return 1;
+ pci_device_cfg_read_u32(pci_device_for_cfg_address(PciCfg1Addr),
+ (uint32_t *) val, PCI_OFFSET(PciCfg1Addr));
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" cfg_inl(%#" PRIx32 ") = %8.8" PRIx32 "\n", PciCfg1Addr,
+ *val);
+ return 1;
}
return 0;
}
@@ -516,15 +537,16 @@ static int
pciCfg1out(CARD16 addr, CARD32 val)
{
if (addr == 0xCF8) {
- PciCfg1Addr = val;
- return 1;
+ PciCfg1Addr = val;
+ return 1;
}
if (addr == 0xCFC) {
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" cfg_outl(%#" PRIx32 ", %8.8" PRIx32 ")\n", PciCfg1Addr, val);
- pci_device_cfg_write_u32(pci_device_for_cfg_address(PciCfg1Addr),
- val, PCI_OFFSET(PciCfg1Addr));
- return 1;
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" cfg_outl(%#" PRIx32 ", %8.8" PRIx32 ")\n", PciCfg1Addr,
+ val);
+ pci_device_cfg_write_u32(pci_device_for_cfg_address(PciCfg1Addr), val,
+ PCI_OFFSET(PciCfg1Addr));
+ return 1;
}
return 0;
}
@@ -535,18 +557,19 @@ pciCfg1inw(CARD16 addr, CARD16 *val)
int shift;
if ((addr >= 0xCF8) && (addr <= 0xCFB)) {
- shift = (addr - 0xCF8) * 8;
- *val = (PciCfg1Addr >> shift) & 0xffff;
- return 1;
+ shift = (addr - 0xCF8) * 8;
+ *val = (PciCfg1Addr >> shift) & 0xffff;
+ return 1;
}
if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
- const unsigned offset = addr - 0xCFC;
-
- pci_device_cfg_read_u16(pci_device_for_cfg_address(PciCfg1Addr),
- val, PCI_OFFSET(PciCfg1Addr) + offset);
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" cfg_inw(%#" PRIx32 ") = %4.4x\n", PciCfg1Addr + offset, *val);
- return 1;
+ const unsigned offset = addr - 0xCFC;
+
+ pci_device_cfg_read_u16(pci_device_for_cfg_address(PciCfg1Addr),
+ val, PCI_OFFSET(PciCfg1Addr) + offset);
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" cfg_inw(%#" PRIx32 ") = %4.4x\n", PciCfg1Addr + offset,
+ *val);
+ return 1;
}
return 0;
}
@@ -557,19 +580,20 @@ pciCfg1outw(CARD16 addr, CARD16 val)
int shift;
if ((addr >= 0xCF8) && (addr <= 0xCFB)) {
- shift = (addr - 0xCF8) * 8;
- PciCfg1Addr &= ~(0xffff << shift);
- PciCfg1Addr |= ((CARD32) val) << shift;
- return 1;
+ shift = (addr - 0xCF8) * 8;
+ PciCfg1Addr &= ~(0xffff << shift);
+ PciCfg1Addr |= ((CARD32) val) << shift;
+ return 1;
}
if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
- const unsigned offset = addr - 0xCFC;
-
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" cfg_outw(%#" PRIx32 ", %4.4x)\n", PciCfg1Addr + offset, val);
- pci_device_cfg_write_u16(pci_device_for_cfg_address(PciCfg1Addr),
- val, PCI_OFFSET(PciCfg1Addr) + offset);
- return 1;
+ const unsigned offset = addr - 0xCFC;
+
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" cfg_outw(%#" PRIx32 ", %4.4x)\n", PciCfg1Addr + offset,
+ val);
+ pci_device_cfg_write_u16(pci_device_for_cfg_address(PciCfg1Addr), val,
+ PCI_OFFSET(PciCfg1Addr) + offset);
+ return 1;
}
return 0;
}
@@ -580,18 +604,19 @@ pciCfg1inb(CARD16 addr, CARD8 *val)
int shift;
if ((addr >= 0xCF8) && (addr <= 0xCFB)) {
- shift = (addr - 0xCF8) * 8;
- *val = (PciCfg1Addr >> shift) & 0xff;
- return 1;
+ shift = (addr - 0xCF8) * 8;
+ *val = (PciCfg1Addr >> shift) & 0xff;
+ return 1;
}
if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
- const unsigned offset = addr - 0xCFC;
-
- pci_device_cfg_read_u8(pci_device_for_cfg_address(PciCfg1Addr),
- val, PCI_OFFSET(PciCfg1Addr) + offset);
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" cfg_inb(%#" PRIx32 ") = %2.2x\n", PciCfg1Addr + offset, *val);
- return 1;
+ const unsigned offset = addr - 0xCFC;
+
+ pci_device_cfg_read_u8(pci_device_for_cfg_address(PciCfg1Addr),
+ val, PCI_OFFSET(PciCfg1Addr) + offset);
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" cfg_inb(%#" PRIx32 ") = %2.2x\n", PciCfg1Addr + offset,
+ *val);
+ return 1;
}
return 0;
}
@@ -602,19 +627,20 @@ pciCfg1outb(CARD16 addr, CARD8 val)
int shift;
if ((addr >= 0xCF8) && (addr <= 0xCFB)) {
- shift = (addr - 0xCF8) * 8;
- PciCfg1Addr &= ~(0xff << shift);
- PciCfg1Addr |= ((CARD32) val) << shift;
- return 1;
+ shift = (addr - 0xCF8) * 8;
+ PciCfg1Addr &= ~(0xff << shift);
+ PciCfg1Addr |= ((CARD32) val) << shift;
+ return 1;
}
if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
- const unsigned offset = addr - 0xCFC;
-
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" cfg_outb(%#" PRIx32 ", %2.2x)\n", PciCfg1Addr + offset, val);
- pci_device_cfg_write_u8(pci_device_for_cfg_address(PciCfg1Addr),
- val, PCI_OFFSET(PciCfg1Addr) + offset);
- return 1;
+ const unsigned offset = addr - 0xCFC;
+
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" cfg_outb(%#" PRIx32 ", %2.2x)\n", PciCfg1Addr + offset,
+ val);
+ pci_device_cfg_write_u8(pci_device_for_cfg_address(PciCfg1Addr), val,
+ PCI_OFFSET(PciCfg1Addr) + offset);
+ return 1;
}
return 0;
}
@@ -625,7 +651,7 @@ bios_checksum(const CARD8 *start, int size)
CARD8 sum = 0;
while (size-- > 0)
- sum += *start++;
+ sum += *start++;
return sum;
}
@@ -650,18 +676,18 @@ bios_checksum(const CARD8 *start, int size)
void
LockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga)
{
- vga->save_msr = pci_io_read8(pInt->io, 0x03CC);
- vga->save_vse = pci_io_read8(pInt->io, 0x03C3);
+ vga->save_msr = pci_io_read8(pInt->io, 0x03CC);
+ vga->save_vse = pci_io_read8(pInt->io, 0x03C3);
#ifndef __ia64__
- vga->save_46e8 = pci_io_read8(pInt->io, 0x46E8);
+ vga->save_46e8 = pci_io_read8(pInt->io, 0x46E8);
#endif
vga->save_pos102 = pci_io_read8(pInt->io, 0x0102);
- pci_io_write8(pInt->io, 0x03C2, ~(CARD8)0x03 & vga->save_msr);
- pci_io_write8(pInt->io, 0x03C3, ~(CARD8)0x01 & vga->save_vse);
+ pci_io_write8(pInt->io, 0x03C2, ~(CARD8) 0x03 & vga->save_msr);
+ pci_io_write8(pInt->io, 0x03C3, ~(CARD8) 0x01 & vga->save_vse);
#ifndef __ia64__
- pci_io_write8(pInt->io, 0x46E8, ~(CARD8)0x08 & vga->save_46e8);
+ pci_io_write8(pInt->io, 0x46E8, ~(CARD8) 0x08 & vga->save_46e8);
#endif
- pci_io_write8(pInt->io, 0x0102, ~(CARD8)0x01 & vga->save_pos102);
+ pci_io_write8(pInt->io, 0x0102, ~(CARD8) 0x01 & vga->save_pos102);
}
void
@@ -680,20 +706,22 @@ static void
SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set)
{
int pagesize = getpagesize();
- unsigned char* base;
+ unsigned char *base;
int i;
- if (pci_device_map_legacy(pInt->dev, 0, pagesize, PCI_DEV_MAP_FLAG_WRITABLE, (void **)&base))
- return; /* eek */
+ if (pci_device_map_legacy
+ (pInt->dev, 0, pagesize, PCI_DEV_MAP_FLAG_WRITABLE, (void **) &base))
+ return; /* eek */
if (set) {
- for (i = BIOS_SCRATCH_OFF; i < BIOS_SCRATCH_END; i++)
- MEM_WW(pInt, i, *(base + i));
- } else {
- for (i = BIOS_SCRATCH_OFF; i < BIOS_SCRATCH_END; i++)
- *(base + i) = MEM_RW(pInt, i);
+ for (i = BIOS_SCRATCH_OFF; i < BIOS_SCRATCH_END; i++)
+ MEM_WW(pInt, i, *(base + i));
}
-
+ else {
+ for (i = BIOS_SCRATCH_OFF; i < BIOS_SCRATCH_END; i++)
+ *(base + i) = MEM_RW(pInt, i);
+ }
+
pci_device_unmap_legacy(pInt->dev, base, pagesize);
}
@@ -701,31 +729,32 @@ void
xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save)
{
int pagesize = getpagesize();
- unsigned char* base;
+ unsigned char *base;
int i;
if (!xf86IsEntityPrimary(pInt->entityIndex)
- || (!save && !pInt->BIOSScratch))
- return;
-
- if (pci_device_map_legacy(pInt->dev, 0, pagesize, PCI_DEV_MAP_FLAG_WRITABLE, (void **)&base))
- return; /* eek */
+ || (!save && !pInt->BIOSScratch))
+ return;
+
+ if (pci_device_map_legacy
+ (pInt->dev, 0, pagesize, PCI_DEV_MAP_FLAG_WRITABLE, (void **) &base))
+ return; /* eek */
base += BIOS_SCRATCH_OFF;
if (save) {
- if ((pInt->BIOSScratch
- = xnfalloc(BIOS_SCRATCH_LEN)))
- for (i = 0; i < BIOS_SCRATCH_LEN; i++)
- *(((char*)pInt->BIOSScratch + i)) = *(base + i);
- } else {
- if (pInt->BIOSScratch) {
- for (i = 0; i < BIOS_SCRATCH_LEN; i++)
- *(base + i) = *(pInt->BIOSScratch + i);
- free(pInt->BIOSScratch);
- pInt->BIOSScratch = NULL;
- }
- }
-
+ if ((pInt->BIOSScratch = xnfalloc(BIOS_SCRATCH_LEN)))
+ for (i = 0; i < BIOS_SCRATCH_LEN; i++)
+ *(((char *) pInt->BIOSScratch + i)) = *(base + i);
+ }
+ else {
+ if (pInt->BIOSScratch) {
+ for (i = 0; i < BIOS_SCRATCH_LEN; i++)
+ *(base + i) = *(pInt->BIOSScratch + i);
+ free(pInt->BIOSScratch);
+ pInt->BIOSScratch = NULL;
+ }
+ }
+
pci_device_unmap_legacy(pInt->dev, base - BIOS_SCRATCH_OFF, pagesize);
}
#endif
diff --git a/xorg-server/hw/xfree86/int10/helper_mem.c b/xorg-server/hw/xfree86/int10/helper_mem.c
index 9088298a9..96c598a53 100644
--- a/xorg-server/hw/xfree86/int10/helper_mem.c
+++ b/xorg-server/hw/xfree86/int10/helper_mem.c
@@ -28,29 +28,30 @@ typedef enum {
} INT10Opts;
static const OptionInfoRec INT10Options[] = {
- {OPT_NOINT10, "NoINT10", OPTV_BOOLEAN, {0}, FALSE },
- {OPT_INIT_PRIMARY, "InitPrimary", OPTV_BOOLEAN, {0}, FALSE },
- { -1, NULL, OPTV_NONE, {0}, FALSE },
+ {OPT_NOINT10, "NoINT10", OPTV_BOOLEAN, {0}, FALSE},
+ {OPT_INIT_PRIMARY, "InitPrimary", OPTV_BOOLEAN, {0}, FALSE},
+ {-1, NULL, OPTV_NONE, {0}, FALSE},
};
#ifdef DEBUG
void
dprint(unsigned long start, unsigned long size)
{
- int i,j;
- char *c = (char *)start;
+ int i, j;
+ char *c = (char *) start;
for (j = 0; j < (size >> 4); j++) {
- char *d = c;
- ErrorF("\n0x%lx: ",(unsigned long)c);
- for (i = 0; i<16; i++)
- ErrorF("%2.2x ",(unsigned char) (*(c++)));
- c = d;
- for (i = 0; i<16; i++) {
- ErrorF("%c",((((CARD8)(*c)) > 32) && (((CARD8)(*c)) < 128)) ?
- (unsigned char) (*(c)): '.');
- c++;
- }
+ char *d = c;
+
+ ErrorF("\n0x%lx: ", (unsigned long) c);
+ for (i = 0; i < 16; i++)
+ ErrorF("%2.2x ", (unsigned char) (*(c++)));
+ c = d;
+ for (i = 0; i < 16; i++) {
+ ErrorF("%c", ((((CARD8) (*c)) > 32) && (((CARD8) (*c)) < 128)) ?
+ (unsigned char) (*(c)) : '.');
+ c++;
+ }
}
ErrorF("\n");
}
@@ -69,13 +70,13 @@ setup_int_vect(xf86Int10InfoPtr pInt)
/* let the int vects point to the SYS_BIOS seg */
for (i = 0; i < 0x80; i++) {
- MEM_WW(pInt, i << 2, 0);
- MEM_WW(pInt, (i << 2) + 2, SYS_BIOS >> 4);
+ MEM_WW(pInt, i << 2, 0);
+ MEM_WW(pInt, (i << 2) + 2, SYS_BIOS >> 4);
}
reset_int_vect(pInt);
/* font tables default location (int 1F) */
- MEM_WW(pInt,0x1f<<2,0xfa6e);
+ MEM_WW(pInt, 0x1f << 2, 0xfa6e);
/* int 11 default location (Get Equipment Configuration) */
MEM_WW(pInt, 0x11 << 2, 0xf84d);
@@ -122,7 +123,7 @@ setup_system_bios(void *base_addr)
/* set up eisa ident string */
strcpy(base + 0x0FFD9, "PCI_ISA");
/* write system model id for IBM-AT */
- *((unsigned char *)(base + 0x0FFFE)) = 0xfc;
+ *((unsigned char *) (base + 0x0FFFE)) = 0xfc;
return 1;
}
@@ -137,42 +138,42 @@ reset_int_vect(xf86Int10InfoPtr pInt)
* only be used during EGA/VGA BIOS initialisation.
*/
static const CARD8 VideoParms[] = {
- /* Timing for modes 0x00 & 0x01 */
- 0x38, 0x28, 0x2d, 0x0a, 0x1f, 0x06, 0x19, 0x1c,
- 0x02, 0x07, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
- /* Timing for modes 0x02 & 0x03 */
- 0x71, 0x50, 0x5a, 0x0a, 0x1f, 0x06, 0x19, 0x1c,
- 0x02, 0x07, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
- /* Timing for modes 0x04, 0x05 & 0x06 */
- 0x38, 0x28, 0x2d, 0x0a, 0x7f, 0x06, 0x64, 0x70,
- 0x02, 0x01, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
- /* Timing for mode 0x07 */
- 0x61, 0x50, 0x52, 0x0f, 0x19, 0x06, 0x19, 0x19,
- 0x02, 0x0d, 0x0b, 0x0c, 0x00, 0x00, 0x00, 0x00,
- /* Display page lengths in little endian order */
- 0x00, 0x08, /* Modes 0x00 and 0x01 */
- 0x00, 0x10, /* Modes 0x02 and 0x03 */
- 0x00, 0x40, /* Modes 0x04 and 0x05 */
- 0x00, 0x40, /* Modes 0x06 and 0x07 */
- /* Number of columns for each mode */
- 40, 40, 80, 80, 40, 40, 80, 80,
- /* CGA Mode register value for each mode */
- 0x2c, 0x28, 0x2d, 0x29, 0x2a, 0x2e, 0x1e, 0x29,
- /* Padding */
- 0x00, 0x00, 0x00, 0x00
- };
+ /* Timing for modes 0x00 & 0x01 */
+ 0x38, 0x28, 0x2d, 0x0a, 0x1f, 0x06, 0x19, 0x1c,
+ 0x02, 0x07, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
+ /* Timing for modes 0x02 & 0x03 */
+ 0x71, 0x50, 0x5a, 0x0a, 0x1f, 0x06, 0x19, 0x1c,
+ 0x02, 0x07, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
+ /* Timing for modes 0x04, 0x05 & 0x06 */
+ 0x38, 0x28, 0x2d, 0x0a, 0x7f, 0x06, 0x64, 0x70,
+ 0x02, 0x01, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
+ /* Timing for mode 0x07 */
+ 0x61, 0x50, 0x52, 0x0f, 0x19, 0x06, 0x19, 0x19,
+ 0x02, 0x0d, 0x0b, 0x0c, 0x00, 0x00, 0x00, 0x00,
+ /* Display page lengths in little endian order */
+ 0x00, 0x08, /* Modes 0x00 and 0x01 */
+ 0x00, 0x10, /* Modes 0x02 and 0x03 */
+ 0x00, 0x40, /* Modes 0x04 and 0x05 */
+ 0x00, 0x40, /* Modes 0x06 and 0x07 */
+ /* Number of columns for each mode */
+ 40, 40, 80, 80, 40, 40, 80, 80,
+ /* CGA Mode register value for each mode */
+ 0x2c, 0x28, 0x2d, 0x29, 0x2a, 0x2e, 0x1e, 0x29,
+ /* Padding */
+ 0x00, 0x00, 0x00, 0x00
+ };
int i;
for (i = 0; i < sizeof(VideoParms); i++)
- MEM_WB(pInt, i + (0x1000 - sizeof(VideoParms)), VideoParms[i]);
- MEM_WW(pInt, 0x1d << 2, 0x1000 - sizeof(VideoParms));
+ MEM_WB(pInt, i + (0x1000 - sizeof(VideoParms)), VideoParms[i]);
+ MEM_WW(pInt, 0x1d << 2, 0x1000 - sizeof(VideoParms));
MEM_WW(pInt, (0x1d << 2) + 2, 0);
- MEM_WW(pInt, 0x10 << 2, 0xf065);
+ MEM_WW(pInt, 0x10 << 2, 0xf065);
MEM_WW(pInt, (0x10 << 2) + 2, SYS_BIOS >> 4);
- MEM_WW(pInt, 0x42 << 2, 0xf065);
+ MEM_WW(pInt, 0x42 << 2, 0xf065);
MEM_WW(pInt, (0x42 << 2) + 2, SYS_BIOS >> 4);
- MEM_WW(pInt, 0x6D << 2, 0xf065);
+ MEM_WW(pInt, 0x6D << 2, 0xf065);
MEM_WW(pInt, (0x6D << 2) + 2, SYS_BIOS >> 4);
}
@@ -196,24 +197,22 @@ xf86HandleInt10Options(ScrnInfoPtr pScrn, int entityIndex)
{
EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
OptionInfoPtr options = NULL;
-
+
if (pEnt->device) {
- pointer configOptions = NULL;
-
- /* Check if xf86CollectOptions() has already been called */
- if (((pEnt->index < 0) ||
- !pScrn ||
- !(configOptions = pScrn->options)) &&
- pEnt->device)
- configOptions = pEnt->device->options;
-
- if (configOptions) {
- if (!(options = (OptionInfoPtr) malloc(sizeof(INT10Options))))
- return NULL;
-
- (void)memcpy(options, INT10Options, sizeof(INT10Options));
- xf86ProcessOptions(pScrn->scrnIndex, configOptions, options);
- }
+ pointer configOptions = NULL;
+
+ /* Check if xf86CollectOptions() has already been called */
+ if (((pEnt->index < 0) ||
+ !pScrn || !(configOptions = pScrn->options)) && pEnt->device)
+ configOptions = pEnt->device->options;
+
+ if (configOptions) {
+ if (!(options = (OptionInfoPtr) malloc(sizeof(INT10Options))))
+ return NULL;
+
+ (void) memcpy(options, INT10Options, sizeof(INT10Options));
+ xf86ProcessOptions(pScrn->scrnIndex, configOptions, options);
+ }
}
free(pEnt);
@@ -221,47 +220,48 @@ xf86HandleInt10Options(ScrnInfoPtr pScrn, int entityIndex)
}
Bool
-int10skip(const void* options)
+int10skip(const void *options)
{
Bool noint10 = FALSE;
- if (!options) return FALSE;
-
+ if (!options)
+ return FALSE;
+
xf86GetOptValBool(options, OPT_NOINT10, &noint10);
return noint10;
}
Bool
-int10_check_bios(int scrnIndex, int codeSeg, const unsigned char* vbiosMem)
+int10_check_bios(int scrnIndex, int codeSeg, const unsigned char *vbiosMem)
{
int size;
- if ((codeSeg & 0x1f) || /* Not 512-byte aligned otherwise */
- ((codeSeg << 4) < V_BIOS) ||
- ((codeSeg << 4) >= SYS_SIZE))
- return FALSE;
+ if ((codeSeg & 0x1f) || /* Not 512-byte aligned otherwise */
+ ((codeSeg << 4) < V_BIOS) || ((codeSeg << 4) >= SYS_SIZE))
+ return FALSE;
- if ((*vbiosMem != 0x55) || (*(vbiosMem+1) != 0xAA) || !*(vbiosMem+2))
- return FALSE;
+ if ((*vbiosMem != 0x55) || (*(vbiosMem + 1) != 0xAA) || !*(vbiosMem + 2))
+ return FALSE;
size = *(vbiosMem + 2) * 512;
if ((size + (codeSeg << 4)) > SYS_SIZE)
- return FALSE;
+ return FALSE;
if (bios_checksum(vbiosMem, size))
- xf86DrvMsg(scrnIndex, X_INFO, "Bad V_BIOS checksum\n");
+ xf86DrvMsg(scrnIndex, X_INFO, "Bad V_BIOS checksum\n");
return TRUE;
}
Bool
-initPrimary(const void* options)
+initPrimary(const void *options)
{
Bool initPrimary = FALSE;
- if (!options) return FALSE;
-
+ if (!options)
+ return FALSE;
+
xf86GetOptValBool(options, OPT_INIT_PRIMARY, &initPrimary);
return initPrimary;
}
@@ -272,13 +272,13 @@ xf86int10GetBiosLocationType(const xf86Int10InfoPtr pInt)
BusType location_type;
EntityInfoPtr pEnt = xf86GetEntityInfo(pInt->entityIndex);
+
location_type = pEnt->location.type;
free(pEnt);
return location_type;
}
-
#define CHECK_V_SEGMENT_RANGE(x) \
if (((x) << 4) < V_BIOS) { \
xf86DrvMsg(pInt->scrnIndex, X_ERROR, \
@@ -300,24 +300,24 @@ xf86int10GetBiosSegment(xf86Int10InfoPtr pInt, void *base)
segments[3] = ~0;
for (i = 0; segments[i] != ~0; i++) {
- unsigned char * vbiosMem;
+ unsigned char *vbiosMem;
- cs = segments[i];
+ cs = segments[i];
- CHECK_V_SEGMENT_RANGE(cs);
- vbiosMem = (unsigned char *)base + (cs << 4);
- if (int10_check_bios(pInt->scrnIndex, cs, vbiosMem)) {
- break;
- }
+ CHECK_V_SEGMENT_RANGE(cs);
+ vbiosMem = (unsigned char *) base + (cs << 4);
+ if (int10_check_bios(pInt->scrnIndex, cs, vbiosMem)) {
+ break;
+ }
}
if (segments[i] == ~0) {
- xf86DrvMsg(pInt->scrnIndex, X_ERROR, "No V_BIOS found\n");
- return FALSE;
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR, "No V_BIOS found\n");
+ return FALSE;
}
xf86DrvMsg(pInt->scrnIndex, X_INFO, "Primary V_BIOS segment is: 0x%lx\n",
- (unsigned long)cs);
+ (unsigned long) cs);
pInt->BIOSseg = cs;
return TRUE;
diff --git a/xorg-server/hw/xfree86/int10/xf86int10.c b/xorg-server/hw/xfree86/int10/xf86int10.c
index dd00e5465..df347d4dd 100644
--- a/xorg-server/hw/xfree86/int10/xf86int10.c
+++ b/xorg-server/hw/xfree86/int10/xf86int10.c
@@ -20,12 +20,13 @@
xf86Int10InfoPtr Int10Current = NULL;
static int int1A_handler(xf86Int10InfoPtr pInt);
+
#ifndef _PC
static int int42_handler(xf86Int10InfoPtr pInt);
#endif
static int intE6_handler(xf86Int10InfoPtr pInt);
static struct pci_device *findPci(xf86Int10InfoPtr pInt, unsigned short bx);
-static CARD32 pciSlotBX( const struct pci_device * pvp );
+static CARD32 pciSlotBX(const struct pci_device *pvp);
int
int_handler(xf86Int10InfoPtr pInt)
@@ -38,28 +39,27 @@ int_handler(xf86Int10InfoPtr pInt)
case 0x10:
case 0x42:
case 0x6D:
- if (getIntVect(pInt, num) == I_S_DEFAULT_INT_VECT)
- ret = int42_handler(pInt);
- break;
+ if (getIntVect(pInt, num) == I_S_DEFAULT_INT_VECT)
+ ret = int42_handler(pInt);
+ break;
#endif
case 0x1A:
- ret = int1A_handler(pInt);
- break;
+ ret = int1A_handler(pInt);
+ break;
case 0xe6:
- ret = intE6_handler(pInt);
- break;
+ ret = intE6_handler(pInt);
+ break;
default:
- break;
+ break;
}
if (!ret)
- ret = run_bios_int(num, pInt);
+ ret = run_bios_int(num, pInt);
if (!ret) {
- xf86DrvMsg(pInt->scrnIndex, X_ERROR,
- "Halting on int 0x%2.2x!\n", num);
- dump_registers(pInt);
- stack_trace(pInt);
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Halting on int 0x%2.2x!\n", num);
+ dump_registers(pInt);
+ stack_trace(pInt);
}
return ret;
@@ -79,507 +79,511 @@ int42_handler(xf86Int10InfoPtr pInt)
{
switch (X86_AH) {
case 0x00:
- /* Set Video Mode */
- /* Enter: AL = video mode number */
- /* Leave: Nothing */
- /* Implemented (except for clearing the screen) */
- { /* Localise */
- unsigned int ioport;
- int i;
- CARD16 int1d, regvals, tmp;
- CARD8 mode, cgamode, cgacolour;
-
- /*
- * Ignore all mode numbers but 0x00-0x13. Some systems also ignore
- * 0x0B and 0x0C, but don't do that here.
- */
- if (X86_AL > 0x13)
- break;
-
- /*
- * You didn't think that was really the mode set, did you? There
- * are only so many slots in the video parameter table...
- */
- mode = X86_AL;
- ioport = 0x03D4;
- switch (MEM_RB(pInt, 0x0410) & 0x30) {
- case 0x30: /* MDA */
- mode = 0x07; /* Force mode to 0x07 */
- ioport = 0x03B4;
- break;
- case 0x10: /* CGA 40x25 */
- if (mode >= 0x07)
- mode = 0x01;
- break;
- case 0x20: /* CGA 80x25 (MCGA?) */
- if (mode >= 0x07)
- mode = 0x03;
- break;
- case 0x00: /* EGA/VGA */
- if (mode >= 0x07) /* Don't try MDA timings */
- mode = 0x01; /* !?!?! */
- break;
- }
-
- /* Locate data in video parameter table */
- int1d = MEM_RW(pInt, 0x1d << 2);
- regvals = ((mode >> 1) << 4) + int1d;
- cgacolour = 0x30;
- if (mode == 0x06) {
- regvals -= 0x10;
- cgacolour = 0x3F;
- }
-
- /** Update BIOS Data Area **/
-
- /* Video mode */
- MEM_WB(pInt, 0x0449, mode);
-
- /* Columns */
- tmp = MEM_RB(pInt, mode + int1d + 0x48);
- MEM_WW(pInt, 0x044A, tmp);
-
- /* Page length */
- tmp = MEM_RW(pInt, (mode & 0x06) + int1d + 0x40);
- MEM_WW(pInt, 0x044C, tmp);
-
- /* Start Address */
- MEM_WW(pInt, 0x044E, 0);
-
- /* Cursor positions, one for each display page */
- for (i = 0x0450; i < 0x0460; i += 2)
- MEM_WW(pInt, i, 0);
-
- /* Cursor start & end scanlines */
- tmp = MEM_RB(pInt, regvals + 0x0B);
- MEM_WB(pInt, 0x0460, tmp);
- tmp = MEM_RB(pInt, regvals + 0x0A);
- MEM_WB(pInt, 0x0461, tmp);
-
- /* Current display page number */
- MEM_WB(pInt, 0x0462, 0);
-
- /* CRTC I/O address */
- MEM_WW(pInt, 0x0463, ioport);
-
- /* CGA Mode register value */
- cgamode = MEM_RB(pInt, mode + int1d + 0x50);
- MEM_WB(pInt, 0x0465, cgamode);
-
- /* CGA Colour register value */
- MEM_WB(pInt, 0x0466, cgacolour);
-
- /* Rows */
- MEM_WB(pInt, 0x0484, (25 - 1));
-
- /* Program the mode */
- pci_io_write8(pInt->io, ioport + 4, cgamode & 0x37); /* Turn off screen */
- for (i = 0; i < 0x10; i++) {
- tmp = MEM_RB(pInt, regvals + i);
- pci_io_write8(pInt->io, ioport, i);
- pci_io_write8(pInt->io, ioport + 1, tmp);
- }
- pci_io_write8(pInt->io, ioport + 5, cgacolour); /* Select colour mode */
- pci_io_write8(pInt->io, ioport + 4, cgamode); /* Turn on screen */
- }
- break;
+ /* Set Video Mode */
+ /* Enter: AL = video mode number */
+ /* Leave: Nothing */
+ /* Implemented (except for clearing the screen) */
+ { /* Localise */
+ unsigned int ioport;
+ int i;
+ CARD16 int1d, regvals, tmp;
+ CARD8 mode, cgamode, cgacolour;
+
+ /*
+ * Ignore all mode numbers but 0x00-0x13. Some systems also ignore
+ * 0x0B and 0x0C, but don't do that here.
+ */
+ if (X86_AL > 0x13)
+ break;
+
+ /*
+ * You didn't think that was really the mode set, did you? There
+ * are only so many slots in the video parameter table...
+ */
+ mode = X86_AL;
+ ioport = 0x03D4;
+ switch (MEM_RB(pInt, 0x0410) & 0x30) {
+ case 0x30: /* MDA */
+ mode = 0x07; /* Force mode to 0x07 */
+ ioport = 0x03B4;
+ break;
+ case 0x10: /* CGA 40x25 */
+ if (mode >= 0x07)
+ mode = 0x01;
+ break;
+ case 0x20: /* CGA 80x25 (MCGA?) */
+ if (mode >= 0x07)
+ mode = 0x03;
+ break;
+ case 0x00: /* EGA/VGA */
+ if (mode >= 0x07) /* Don't try MDA timings */
+ mode = 0x01; /* !?!?! */
+ break;
+ }
+
+ /* Locate data in video parameter table */
+ int1d = MEM_RW(pInt, 0x1d << 2);
+ regvals = ((mode >> 1) << 4) + int1d;
+ cgacolour = 0x30;
+ if (mode == 0x06) {
+ regvals -= 0x10;
+ cgacolour = 0x3F;
+ }
+
+ /** Update BIOS Data Area **/
+
+ /* Video mode */
+ MEM_WB(pInt, 0x0449, mode);
+
+ /* Columns */
+ tmp = MEM_RB(pInt, mode + int1d + 0x48);
+ MEM_WW(pInt, 0x044A, tmp);
+
+ /* Page length */
+ tmp = MEM_RW(pInt, (mode & 0x06) + int1d + 0x40);
+ MEM_WW(pInt, 0x044C, tmp);
+
+ /* Start Address */
+ MEM_WW(pInt, 0x044E, 0);
+
+ /* Cursor positions, one for each display page */
+ for (i = 0x0450; i < 0x0460; i += 2)
+ MEM_WW(pInt, i, 0);
+
+ /* Cursor start & end scanlines */
+ tmp = MEM_RB(pInt, regvals + 0x0B);
+ MEM_WB(pInt, 0x0460, tmp);
+ tmp = MEM_RB(pInt, regvals + 0x0A);
+ MEM_WB(pInt, 0x0461, tmp);
+
+ /* Current display page number */
+ MEM_WB(pInt, 0x0462, 0);
+
+ /* CRTC I/O address */
+ MEM_WW(pInt, 0x0463, ioport);
+
+ /* CGA Mode register value */
+ cgamode = MEM_RB(pInt, mode + int1d + 0x50);
+ MEM_WB(pInt, 0x0465, cgamode);
+
+ /* CGA Colour register value */
+ MEM_WB(pInt, 0x0466, cgacolour);
+
+ /* Rows */
+ MEM_WB(pInt, 0x0484, (25 - 1));
+
+ /* Program the mode */
+ pci_io_write8(pInt->io, ioport + 4, cgamode & 0x37); /* Turn off screen */
+ for (i = 0; i < 0x10; i++) {
+ tmp = MEM_RB(pInt, regvals + i);
+ pci_io_write8(pInt->io, ioport, i);
+ pci_io_write8(pInt->io, ioport + 1, tmp);
+ }
+ pci_io_write8(pInt->io, ioport + 5, cgacolour); /* Select colour mode */
+ pci_io_write8(pInt->io, ioport + 4, cgamode); /* Turn on screen */
+ }
+ break;
case 0x01:
- /* Set Cursor Type */
- /* Enter: CH = starting line for cursor */
- /* CL = ending line for cursor */
- /* Leave: Nothing */
- /* Implemented */
- { /* Localise */
- unsigned int ioport = MEM_RW(pInt, 0x0463);
-
- MEM_WB(pInt, 0x0460, X86_CL);
- MEM_WB(pInt, 0x0461, X86_CH);
-
- pci_io_write8(pInt->io, ioport, 0x0A);
- pci_io_write8(pInt->io, ioport + 1, X86_CH);
- pci_io_write8(pInt->io, ioport, 0x0B);
- pci_io_write8(pInt->io, ioport + 1, X86_CL);
- }
- break;
+ /* Set Cursor Type */
+ /* Enter: CH = starting line for cursor */
+ /* CL = ending line for cursor */
+ /* Leave: Nothing */
+ /* Implemented */
+ { /* Localise */
+ unsigned int ioport = MEM_RW(pInt, 0x0463);
+
+ MEM_WB(pInt, 0x0460, X86_CL);
+ MEM_WB(pInt, 0x0461, X86_CH);
+
+ pci_io_write8(pInt->io, ioport, 0x0A);
+ pci_io_write8(pInt->io, ioport + 1, X86_CH);
+ pci_io_write8(pInt->io, ioport, 0x0B);
+ pci_io_write8(pInt->io, ioport + 1, X86_CL);
+ }
+ break;
case 0x02:
- /* Set Cursor Position */
- /* Enter: BH = display page number */
- /* DH = row */
- /* DL = column */
- /* Leave: Nothing */
- /* Implemented */
- { /* Localise */
- unsigned int ioport;
- CARD16 offset;
-
- MEM_WB(pInt, (X86_BH << 1) + 0x0450, X86_DL);
- MEM_WB(pInt, (X86_BH << 1) + 0x0451, X86_DH);
-
- if (X86_BH != MEM_RB(pInt, 0x0462))
- break;
-
- offset = (X86_DH * MEM_RW(pInt, 0x044A)) + X86_DL;
- offset += MEM_RW(pInt, 0x044E) << 1;
-
- ioport = MEM_RW(pInt, 0x0463);
- pci_io_write8(pInt->io, ioport, 0x0E);
- pci_io_write8(pInt->io, ioport + 1, offset >> 8);
- pci_io_write8(pInt->io, ioport, 0x0F);
- pci_io_write8(pInt->io, ioport + 1, offset & 0xFF);
- }
- break;
+ /* Set Cursor Position */
+ /* Enter: BH = display page number */
+ /* DH = row */
+ /* DL = column */
+ /* Leave: Nothing */
+ /* Implemented */
+ { /* Localise */
+ unsigned int ioport;
+ CARD16 offset;
+
+ MEM_WB(pInt, (X86_BH << 1) + 0x0450, X86_DL);
+ MEM_WB(pInt, (X86_BH << 1) + 0x0451, X86_DH);
+
+ if (X86_BH != MEM_RB(pInt, 0x0462))
+ break;
+
+ offset = (X86_DH * MEM_RW(pInt, 0x044A)) + X86_DL;
+ offset += MEM_RW(pInt, 0x044E) << 1;
+
+ ioport = MEM_RW(pInt, 0x0463);
+ pci_io_write8(pInt->io, ioport, 0x0E);
+ pci_io_write8(pInt->io, ioport + 1, offset >> 8);
+ pci_io_write8(pInt->io, ioport, 0x0F);
+ pci_io_write8(pInt->io, ioport + 1, offset & 0xFF);
+ }
+ break;
case 0x03:
- /* Get Cursor Position */
- /* Enter: BH = display page number */
- /* Leave: CH = starting line for cursor */
- /* CL = ending line for cursor */
- /* DH = row */
- /* DL = column */
- /* Implemented */
- { /* Localise */
- X86_CL = MEM_RB(pInt, 0x0460);
- X86_CH = MEM_RB(pInt, 0x0461);
- X86_DL = MEM_RB(pInt, (X86_BH << 1) + 0x0450);
- X86_DH = MEM_RB(pInt, (X86_BH << 1) + 0x0451);
- }
- break;
+ /* Get Cursor Position */
+ /* Enter: BH = display page number */
+ /* Leave: CH = starting line for cursor */
+ /* CL = ending line for cursor */
+ /* DH = row */
+ /* DL = column */
+ /* Implemented */
+ { /* Localise */
+ X86_CL = MEM_RB(pInt, 0x0460);
+ X86_CH = MEM_RB(pInt, 0x0461);
+ X86_DL = MEM_RB(pInt, (X86_BH << 1) + 0x0450);
+ X86_DH = MEM_RB(pInt, (X86_BH << 1) + 0x0451);
+ }
+ break;
case 0x04:
- /* Get Light Pen Position */
- /* Enter: Nothing */
- /* Leave: AH = 0x01 (down/triggered) or 0x00 (not) */
- /* BX = pixel column */
- /* CX = pixel row */
- /* DH = character row */
- /* DL = character column */
- /* Not Implemented */
- { /* Localise */
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
- "int 0x%2.2x(AH=0x04) -- Get Light Pen Position\n", pInt->num);
- if (xf86GetVerbosity() > 3) {
- dump_registers(pInt);
- stack_trace(pInt);
- }
- X86_AH = X86_BX = X86_CX = X86_DX = 0;
- }
- break;
+ /* Get Light Pen Position */
+ /* Enter: Nothing */
+ /* Leave: AH = 0x01 (down/triggered) or 0x00 (not) */
+ /* BX = pixel column */
+ /* CX = pixel row */
+ /* DH = character row */
+ /* DL = character column */
+ /* Not Implemented */
+ { /* Localise */
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
+ "int 0x%2.2x(AH=0x04) -- Get Light Pen Position\n",
+ pInt->num);
+ if (xf86GetVerbosity() > 3) {
+ dump_registers(pInt);
+ stack_trace(pInt);
+ }
+ X86_AH = X86_BX = X86_CX = X86_DX = 0;
+ }
+ break;
case 0x05:
- /* Set Display Page */
- /* Enter: AL = display page number */
- /* Leave: Nothing */
- /* Implemented */
- { /* Localise */
- unsigned int ioport = MEM_RW(pInt, 0x0463);
- CARD16 start;
- CARD8 x, y;
-
- /* Calculate new start address */
- MEM_WB(pInt, 0x0462, X86_AL);
- start = X86_AL * MEM_RW(pInt, 0x044C);
- MEM_WW(pInt, 0x044E, start);
- start <<= 1;
-
- /* Update start address */
- pci_io_write8(pInt->io, ioport, 0x0C);
- pci_io_write8(pInt->io, ioport + 1, start >> 8);
- pci_io_write8(pInt->io, ioport, 0x0D);
- pci_io_write8(pInt->io, ioport + 1, start & 0xFF);
-
- /* Switch cursor position */
- y = MEM_RB(pInt, (X86_AL << 1) + 0x0450);
- x = MEM_RB(pInt, (X86_AL << 1) + 0x0451);
- start += (y * MEM_RW(pInt, 0x044A)) + x;
-
- /* Update cursor position */
- pci_io_write8(pInt->io, ioport, 0x0E);
- pci_io_write8(pInt->io, ioport + 1, start >> 8);
- pci_io_write8(pInt->io, ioport, 0x0F);
- pci_io_write8(pInt->io, ioport + 1, start & 0xFF);
- }
- break;
+ /* Set Display Page */
+ /* Enter: AL = display page number */
+ /* Leave: Nothing */
+ /* Implemented */
+ { /* Localise */
+ unsigned int ioport = MEM_RW(pInt, 0x0463);
+ CARD16 start;
+ CARD8 x, y;
+
+ /* Calculate new start address */
+ MEM_WB(pInt, 0x0462, X86_AL);
+ start = X86_AL * MEM_RW(pInt, 0x044C);
+ MEM_WW(pInt, 0x044E, start);
+ start <<= 1;
+
+ /* Update start address */
+ pci_io_write8(pInt->io, ioport, 0x0C);
+ pci_io_write8(pInt->io, ioport + 1, start >> 8);
+ pci_io_write8(pInt->io, ioport, 0x0D);
+ pci_io_write8(pInt->io, ioport + 1, start & 0xFF);
+
+ /* Switch cursor position */
+ y = MEM_RB(pInt, (X86_AL << 1) + 0x0450);
+ x = MEM_RB(pInt, (X86_AL << 1) + 0x0451);
+ start += (y * MEM_RW(pInt, 0x044A)) + x;
+
+ /* Update cursor position */
+ pci_io_write8(pInt->io, ioport, 0x0E);
+ pci_io_write8(pInt->io, ioport + 1, start >> 8);
+ pci_io_write8(pInt->io, ioport, 0x0F);
+ pci_io_write8(pInt->io, ioport + 1, start & 0xFF);
+ }
+ break;
case 0x06:
- /* Initialise or Scroll Window Up */
- /* Enter: AL = lines to scroll up */
- /* BH = attribute for blank */
- /* CH = upper y of window */
- /* CL = left x of window */
- /* DH = lower y of window */
- /* DL = right x of window */
- /* Leave: Nothing */
- /* Not Implemented */
- { /* Localise */
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
- "int 0x%2.2x(AH=0x06) -- Initialise or Scroll Window Up\n",
- pInt->num);
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3,
- " AL=0x%2.2x, BH=0x%2.2x,"
- " CH=0x%2.2x, CL=0x%2.2x, DH=0x%2.2x, DL=0x%2.2x\n",
- X86_AL, X86_BH, X86_CH, X86_CL, X86_DH, X86_DL);
- if (xf86GetVerbosity() > 3) {
- dump_registers(pInt);
- stack_trace(pInt);
- }
- }
- break;
+ /* Initialise or Scroll Window Up */
+ /* Enter: AL = lines to scroll up */
+ /* BH = attribute for blank */
+ /* CH = upper y of window */
+ /* CL = left x of window */
+ /* DH = lower y of window */
+ /* DL = right x of window */
+ /* Leave: Nothing */
+ /* Not Implemented */
+ { /* Localise */
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
+ "int 0x%2.2x(AH=0x06) -- Initialise or Scroll Window Up\n",
+ pInt->num);
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3,
+ " AL=0x%2.2x, BH=0x%2.2x,"
+ " CH=0x%2.2x, CL=0x%2.2x, DH=0x%2.2x, DL=0x%2.2x\n",
+ X86_AL, X86_BH, X86_CH, X86_CL, X86_DH, X86_DL);
+ if (xf86GetVerbosity() > 3) {
+ dump_registers(pInt);
+ stack_trace(pInt);
+ }
+ }
+ break;
case 0x07:
- /* Initialise or Scroll Window Down */
- /* Enter: AL = lines to scroll down */
- /* BH = attribute for blank */
- /* CH = upper y of window */
- /* CL = left x of window */
- /* DH = lower y of window */
- /* DL = right x of window */
- /* Leave: Nothing */
- /* Not Implemented */
- { /* Localise */
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
- "int 0x%2.2x(AH=0x07) -- Initialise or Scroll Window Down\n",
- pInt->num);
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3,
- " AL=0x%2.2x, BH=0x%2.2x,"
- " CH=0x%2.2x, CL=0x%2.2x, DH=0x%2.2x, DL=0x%2.2x\n",
- X86_AL, X86_BH, X86_CH, X86_CL, X86_DH, X86_DL);
- if (xf86GetVerbosity() > 3) {
- dump_registers(pInt);
- stack_trace(pInt);
- }
- }
- break;
+ /* Initialise or Scroll Window Down */
+ /* Enter: AL = lines to scroll down */
+ /* BH = attribute for blank */
+ /* CH = upper y of window */
+ /* CL = left x of window */
+ /* DH = lower y of window */
+ /* DL = right x of window */
+ /* Leave: Nothing */
+ /* Not Implemented */
+ { /* Localise */
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
+ "int 0x%2.2x(AH=0x07) -- Initialise or Scroll Window Down\n",
+ pInt->num);
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3,
+ " AL=0x%2.2x, BH=0x%2.2x,"
+ " CH=0x%2.2x, CL=0x%2.2x, DH=0x%2.2x, DL=0x%2.2x\n",
+ X86_AL, X86_BH, X86_CH, X86_CL, X86_DH, X86_DL);
+ if (xf86GetVerbosity() > 3) {
+ dump_registers(pInt);
+ stack_trace(pInt);
+ }
+ }
+ break;
case 0x08:
- /* Read Character and Attribute at Cursor */
- /* Enter: BH = display page number */
- /* Leave: AH = attribute */
- /* AL = character */
- /* Not Implemented */
- { /* Localise */
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
- "int 0x%2.2x(AH=0x08) -- Read Character and Attribute at"
- " Cursor\n", pInt->num);
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3,
- "BH=0x%2.2x\n", X86_BH);
- if (xf86GetVerbosity() > 3) {
- dump_registers(pInt);
- stack_trace(pInt);
- }
- X86_AX = 0;
- }
- break;
+ /* Read Character and Attribute at Cursor */
+ /* Enter: BH = display page number */
+ /* Leave: AH = attribute */
+ /* AL = character */
+ /* Not Implemented */
+ { /* Localise */
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
+ "int 0x%2.2x(AH=0x08) -- Read Character and Attribute at"
+ " Cursor\n", pInt->num);
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3,
+ "BH=0x%2.2x\n", X86_BH);
+ if (xf86GetVerbosity() > 3) {
+ dump_registers(pInt);
+ stack_trace(pInt);
+ }
+ X86_AX = 0;
+ }
+ break;
case 0x09:
- /* Write Character and Attribute at Cursor */
- /* Enter: AL = character */
- /* BH = display page number */
- /* BL = attribute (text) or colour (graphics) */
- /* CX = replication count */
- /* Leave: Nothing */
- /* Not Implemented */
- { /* Localise */
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
- "int 0x%2.2x(AH=0x09) -- Write Character and Attribute at"
- " Cursor\n", pInt->num);
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3,
- "AL=0x%2.2x, BH=0x%2.2x, BL=0x%2.2x, CX=0x%4.4x\n",
- X86_AL, X86_BH, X86_BL, X86_CX);
- if (xf86GetVerbosity() > 3) {
- dump_registers(pInt);
- stack_trace(pInt);
- }
- }
- break;
+ /* Write Character and Attribute at Cursor */
+ /* Enter: AL = character */
+ /* BH = display page number */
+ /* BL = attribute (text) or colour (graphics) */
+ /* CX = replication count */
+ /* Leave: Nothing */
+ /* Not Implemented */
+ { /* Localise */
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
+ "int 0x%2.2x(AH=0x09) -- Write Character and Attribute at"
+ " Cursor\n", pInt->num);
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3,
+ "AL=0x%2.2x, BH=0x%2.2x, BL=0x%2.2x, CX=0x%4.4x\n",
+ X86_AL, X86_BH, X86_BL, X86_CX);
+ if (xf86GetVerbosity() > 3) {
+ dump_registers(pInt);
+ stack_trace(pInt);
+ }
+ }
+ break;
case 0x0a:
- /* Write Character at Cursor */
- /* Enter: AL = character */
- /* BH = display page number */
- /* BL = colour */
- /* CX = replication count */
- /* Leave: Nothing */
- /* Not Implemented */
- { /* Localise */
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
- "int 0x%2.2x(AH=0x0A) -- Write Character at Cursor\n",
- pInt->num);
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3,
- "AL=0x%2.2x, BH=0x%2.2x, BL=0x%2.2x, CX=0x%4.4x\n",
- X86_AL, X86_BH, X86_BL, X86_CX);
- if (xf86GetVerbosity() > 3) {
- dump_registers(pInt);
- stack_trace(pInt);
- }
- }
- break;
+ /* Write Character at Cursor */
+ /* Enter: AL = character */
+ /* BH = display page number */
+ /* BL = colour */
+ /* CX = replication count */
+ /* Leave: Nothing */
+ /* Not Implemented */
+ { /* Localise */
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
+ "int 0x%2.2x(AH=0x0A) -- Write Character at Cursor\n",
+ pInt->num);
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3,
+ "AL=0x%2.2x, BH=0x%2.2x, BL=0x%2.2x, CX=0x%4.4x\n",
+ X86_AL, X86_BH, X86_BL, X86_CX);
+ if (xf86GetVerbosity() > 3) {
+ dump_registers(pInt);
+ stack_trace(pInt);
+ }
+ }
+ break;
case 0x0b:
- /* Set Palette, Background or Border */
- /* Enter: BH = 0x00 or 0x01 */
- /* BL = colour or palette (respectively) */
- /* Leave: Nothing */
- /* Implemented */
- { /* Localise */
- unsigned int ioport = MEM_RW(pInt, 0x0463) + 5;
- CARD8 cgacolour = MEM_RB(pInt, 0x0466);
-
- if (X86_BH) {
- cgacolour &= 0xDF;
- cgacolour |= (X86_BL & 0x01) << 5;
- } else {
- cgacolour &= 0xE0;
- cgacolour |= X86_BL & 0x1F;
- }
-
- MEM_WB(pInt, 0x0466, cgacolour);
- pci_io_write8(pInt->io, ioport, cgacolour);
- }
- break;
+ /* Set Palette, Background or Border */
+ /* Enter: BH = 0x00 or 0x01 */
+ /* BL = colour or palette (respectively) */
+ /* Leave: Nothing */
+ /* Implemented */
+ { /* Localise */
+ unsigned int ioport = MEM_RW(pInt, 0x0463) + 5;
+ CARD8 cgacolour = MEM_RB(pInt, 0x0466);
+
+ if (X86_BH) {
+ cgacolour &= 0xDF;
+ cgacolour |= (X86_BL & 0x01) << 5;
+ }
+ else {
+ cgacolour &= 0xE0;
+ cgacolour |= X86_BL & 0x1F;
+ }
+
+ MEM_WB(pInt, 0x0466, cgacolour);
+ pci_io_write8(pInt->io, ioport, cgacolour);
+ }
+ break;
case 0x0c:
- /* Write Graphics Pixel */
- /* Enter: AL = pixel value */
- /* BH = display page number */
- /* CX = column */
- /* DX = row */
- /* Leave: Nothing */
- /* Not Implemented */
- { /* Localise */
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
- "int 0x%2.2x(AH=0x0C) -- Write Graphics Pixel\n", pInt->num);
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3,
- "AL=0x%2.2x, BH=0x%2.2x, CX=0x%4.4x, DX=0x%4.4x\n",
- X86_AL, X86_BH, X86_CX, X86_DX);
- if (xf86GetVerbosity() > 3) {
- dump_registers(pInt);
- stack_trace(pInt);
- }
- }
- break;
+ /* Write Graphics Pixel */
+ /* Enter: AL = pixel value */
+ /* BH = display page number */
+ /* CX = column */
+ /* DX = row */
+ /* Leave: Nothing */
+ /* Not Implemented */
+ { /* Localise */
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
+ "int 0x%2.2x(AH=0x0C) -- Write Graphics Pixel\n",
+ pInt->num);
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3,
+ "AL=0x%2.2x, BH=0x%2.2x, CX=0x%4.4x, DX=0x%4.4x\n",
+ X86_AL, X86_BH, X86_CX, X86_DX);
+ if (xf86GetVerbosity() > 3) {
+ dump_registers(pInt);
+ stack_trace(pInt);
+ }
+ }
+ break;
case 0x0d:
- /* Read Graphics Pixel */
- /* Enter: BH = display page number */
- /* CX = column */
- /* DX = row */
- /* Leave: AL = pixel value */
- /* Not Implemented */
- { /* Localise */
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
- "int 0x%2.2x(AH=0x0D) -- Read Graphics Pixel\n", pInt->num);
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3,
- "BH=0x%2.2x, CX=0x%4.4x, DX=0x%4.4x\n",
- X86_BH, X86_CX, X86_DX);
- if (xf86GetVerbosity() > 3) {
- dump_registers(pInt);
- stack_trace(pInt);
- }
- X86_AL = 0;
- }
- break;
+ /* Read Graphics Pixel */
+ /* Enter: BH = display page number */
+ /* CX = column */
+ /* DX = row */
+ /* Leave: AL = pixel value */
+ /* Not Implemented */
+ { /* Localise */
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
+ "int 0x%2.2x(AH=0x0D) -- Read Graphics Pixel\n",
+ pInt->num);
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3,
+ "BH=0x%2.2x, CX=0x%4.4x, DX=0x%4.4x\n", X86_BH, X86_CX,
+ X86_DX);
+ if (xf86GetVerbosity() > 3) {
+ dump_registers(pInt);
+ stack_trace(pInt);
+ }
+ X86_AL = 0;
+ }
+ break;
case 0x0e:
- /* Write Character in Teletype Mode */
- /* Enter: AL = character */
- /* BH = display page number */
- /* BL = foreground colour */
- /* Leave: Nothing */
- /* Not Implemented */
- /* WARNING: Emulation of BEL characters will require */
- /* emulation of RTC and PC speaker I/O. */
- /* Also, this recurses through int 0x10 */
- /* which might or might not have been */
- /* installed yet. */
- { /* Localise */
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
- "int 0x%2.2x(AH=0x0E) -- Write Character in Teletype Mode\n",
- pInt->num);
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3,
- "AL=0x%2.2x, BH=0x%2.2x, BL=0x%2.2x\n",
- X86_AL, X86_BH, X86_BL);
- if (xf86GetVerbosity() > 3) {
- dump_registers(pInt);
- stack_trace(pInt);
- }
- }
- break;
+ /* Write Character in Teletype Mode */
+ /* Enter: AL = character */
+ /* BH = display page number */
+ /* BL = foreground colour */
+ /* Leave: Nothing */
+ /* Not Implemented */
+ /* WARNING: Emulation of BEL characters will require */
+ /* emulation of RTC and PC speaker I/O. */
+ /* Also, this recurses through int 0x10 */
+ /* which might or might not have been */
+ /* installed yet. */
+ { /* Localise */
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
+ "int 0x%2.2x(AH=0x0E) -- Write Character in Teletype Mode\n",
+ pInt->num);
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3,
+ "AL=0x%2.2x, BH=0x%2.2x, BL=0x%2.2x\n",
+ X86_AL, X86_BH, X86_BL);
+ if (xf86GetVerbosity() > 3) {
+ dump_registers(pInt);
+ stack_trace(pInt);
+ }
+ }
+ break;
case 0x0f:
- /* Get Video Mode */
- /* Enter: Nothing */
- /* Leave: AH = number of columns */
- /* AL = video mode number */
- /* BH = display page number */
- /* Implemented */
- { /* Localise */
- X86_AH = MEM_RW(pInt, 0x044A);
- X86_AL = MEM_RB(pInt, 0x0449);
- X86_BH = MEM_RB(pInt, 0x0462);
- }
- break;
+ /* Get Video Mode */
+ /* Enter: Nothing */
+ /* Leave: AH = number of columns */
+ /* AL = video mode number */
+ /* BH = display page number */
+ /* Implemented */
+ { /* Localise */
+ X86_AH = MEM_RW(pInt, 0x044A);
+ X86_AL = MEM_RB(pInt, 0x0449);
+ X86_BH = MEM_RB(pInt, 0x0462);
+ }
+ break;
case 0x10:
- /* Colour Control (subfunction in AL) */
- /* Enter: Various */
- /* Leave: Various */
- /* Ignored */
- break;
+ /* Colour Control (subfunction in AL) */
+ /* Enter: Various */
+ /* Leave: Various */
+ /* Ignored */
+ break;
case 0x11:
- /* Font Control (subfunction in AL) */
- /* Enter: Various */
- /* Leave: Various */
- /* Ignored */
- break;
+ /* Font Control (subfunction in AL) */
+ /* Enter: Various */
+ /* Leave: Various */
+ /* Ignored */
+ break;
case 0x12:
- /* Miscellaneous (subfunction in BL) */
- /* Enter: Various */
- /* Leave: Various */
- /* Ignored. Previous code here optionally allowed */
- /* the enabling and disabling of VGA, but no system */
- /* BIOS I've come across actually implements it. */
- break;
+ /* Miscellaneous (subfunction in BL) */
+ /* Enter: Various */
+ /* Leave: Various */
+ /* Ignored. Previous code here optionally allowed */
+ /* the enabling and disabling of VGA, but no system */
+ /* BIOS I've come across actually implements it. */
+ break;
case 0x13:
- /* Write String in Teletype Mode */
- /* Enter: AL = write mode */
- /* BL = attribute (if (AL & 0x02) == 0) */
- /* CX = string length */
- /* DH = row */
- /* DL = column */
- /* ES:BP = string segment:offset */
- /* Leave: Nothing */
- /* Not Implemented */
- /* WARNING: Emulation of BEL characters will require */
- /* emulation of RTC and PC speaker I/O. */
- /* Also, this recurses through int 0x10 */
- /* which might or might not have been */
- /* installed yet. */
- { /* Localise */
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
- "int 0x%2.2x(AH=0x13) -- Write String in Teletype Mode\n",
- pInt->num);
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3,
- "AL=0x%2.2x, BL=0x%2.2x, CX=0x%4.4x,"
- " DH=0x%2.2x, DL=0x%2.2x, ES:BP=0x%4.4x:0x%4.4x\n",
- X86_AL, X86_BL, X86_CX, X86_DH, X86_DL, X86_ES, X86_BP);
- if (xf86GetVerbosity() > 3) {
- dump_registers(pInt);
- stack_trace(pInt);
- }
- }
- break;
+ /* Write String in Teletype Mode */
+ /* Enter: AL = write mode */
+ /* BL = attribute (if (AL & 0x02) == 0) */
+ /* CX = string length */
+ /* DH = row */
+ /* DL = column */
+ /* ES:BP = string segment:offset */
+ /* Leave: Nothing */
+ /* Not Implemented */
+ /* WARNING: Emulation of BEL characters will require */
+ /* emulation of RTC and PC speaker I/O. */
+ /* Also, this recurses through int 0x10 */
+ /* which might or might not have been */
+ /* installed yet. */
+ { /* Localise */
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
+ "int 0x%2.2x(AH=0x13) -- Write String in Teletype Mode\n",
+ pInt->num);
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3,
+ "AL=0x%2.2x, BL=0x%2.2x, CX=0x%4.4x,"
+ " DH=0x%2.2x, DL=0x%2.2x, ES:BP=0x%4.4x:0x%4.4x\n",
+ X86_AL, X86_BL, X86_CX, X86_DH, X86_DL, X86_ES, X86_BP);
+ if (xf86GetVerbosity() > 3) {
+ dump_registers(pInt);
+ stack_trace(pInt);
+ }
+ }
+ break;
default:
- /* Various extensions */
- /* Enter: Various */
- /* Leave: Various */
- /* Ignored */
- break;
+ /* Various extensions */
+ /* Enter: Various */
+ /* Leave: Various */
+ /* Ignored */
+ break;
}
return 1;
@@ -598,7 +602,7 @@ int42_handler(xf86Int10InfoPtr pInt)
* required.
*/
static struct pci_device *
-do_find(const struct pci_id_match *m, char n, const struct pci_device * exclude)
+do_find(const struct pci_id_match *m, char n, const struct pci_device *exclude)
{
struct pci_device *dev;
struct pci_device_iterator *iter;
@@ -607,9 +611,9 @@ do_find(const struct pci_id_match *m, char n, const struct pci_device * exclude)
iter = pci_id_match_iterator_create(m);
while ((dev = pci_device_next(iter)) != NULL) {
- if ((dev != exclude) && !(--n)) {
- break;
- }
+ if ((dev != exclude) && !(--n)) {
+ break;
+ }
}
pci_iterator_destroy(iter);
@@ -617,10 +621,9 @@ do_find(const struct pci_id_match *m, char n, const struct pci_device * exclude)
return dev;
}
-
static struct pci_device *
find_pci_device_vendor(CARD16 vendorID, CARD16 deviceID,
- char n, const struct pci_device * exclude)
+ char n, const struct pci_device *exclude)
{
struct pci_id_match m;
@@ -631,12 +634,12 @@ find_pci_device_vendor(CARD16 vendorID, CARD16 deviceID,
m.device_class = 0;
m.device_class_mask = 0;
- return do_find(& m, n, exclude);
+ return do_find(&m, n, exclude);
}
static struct pci_device *
find_pci_class(CARD8 intf, CARD8 subClass, CARD16 _class,
- char n, const struct pci_device * exclude)
+ char n, const struct pci_device *exclude)
{
struct pci_id_match m;
@@ -644,11 +647,11 @@ find_pci_class(CARD8 intf, CARD8 subClass, CARD16 _class,
m.device_id = PCI_MATCH_ANY;
m.subvendor_id = PCI_MATCH_ANY;
m.subdevice_id = PCI_MATCH_ANY;
- m.device_class = (((uint32_t)_class) << 16)
- | (((uint32_t)subClass) << 8) | intf;
+ m.device_class = (((uint32_t) _class) << 16)
+ | (((uint32_t) subClass) << 8) | intf;
m.device_class_mask = 0x00ffffff;
- return do_find(& m, n, exclude);
+ return do_find(&m, n, exclude);
}
#endif
@@ -660,18 +663,20 @@ static int
int1A_last_bus_number(struct pci_device *dev)
{
struct pci_device *d;
+
struct pci_slot_match m = { dev->domain,
- PCI_MATCH_ANY,
- PCI_MATCH_ANY,
- PCI_MATCH_ANY };
+ PCI_MATCH_ANY,
+ PCI_MATCH_ANY,
+ PCI_MATCH_ANY
+ };
struct pci_device_iterator *iter;
int i = 0;
iter = pci_slot_match_iterator_create(&m);
while ((d = pci_device_next(iter)))
- if (d->bus > i)
- i = d->bus;
+ if (d->bus > i)
+ i = d->bus;
pci_iterator_destroy(iter);
@@ -681,176 +686,181 @@ int1A_last_bus_number(struct pci_device *dev)
static int
int1A_handler(xf86Int10InfoPtr pInt)
{
- struct pci_device * const pvp = xf86GetPciInfoForEntity(pInt->entityIndex);
- struct pci_device * dev;
+ struct pci_device *const pvp = xf86GetPciInfoForEntity(pInt->entityIndex);
+ struct pci_device *dev;
if (pvp == NULL)
- return 0; /* oops */
+ return 0; /* oops */
#ifdef PRINT_INT
ErrorF("int 0x1a: ax=0x%x bx=0x%x cx=0x%x dx=0x%x di=0x%x es=0x%x\n",
- X86_EAX, X86_EBX, X86_ECX, X86_EDX, X86_EDI, X86_ESI);
+ X86_EAX, X86_EBX, X86_ECX, X86_EDX, X86_EDI, X86_ESI);
#endif
switch (X86_AX) {
case 0xb101:
- X86_EAX &= 0xFF00; /* no config space/special cycle support */
- X86_EDX = 0x20494350; /* " ICP" */
- X86_EBX = 0x0210; /* Version 2.10 */
- X86_ECX &= 0xFF00;
- X86_ECX |= int1A_last_bus_number(pvp);
- X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */
+ X86_EAX &= 0xFF00; /* no config space/special cycle support */
+ X86_EDX = 0x20494350; /* " ICP" */
+ X86_EBX = 0x0210; /* Version 2.10 */
+ X86_ECX &= 0xFF00;
+ X86_ECX |= int1A_last_bus_number(pvp);
+ X86_EFLAGS &= ~((unsigned long) 0x01); /* clear carry flag */
#ifdef PRINT_INT
- ErrorF("ax=0x%x dx=0x%x bx=0x%x cx=0x%x flags=0x%x\n",
- X86_EAX, X86_EDX, X86_EBX, X86_ECX, X86_EFLAGS);
+ ErrorF("ax=0x%x dx=0x%x bx=0x%x cx=0x%x flags=0x%x\n",
+ X86_EAX, X86_EDX, X86_EBX, X86_ECX, X86_EFLAGS);
#endif
- return 1;
+ return 1;
case 0xb102:
- if ( (X86_DX == pvp->vendor_id)
- && (X86_CX == pvp->device_id)
- && (X86_ESI == 0) ) {
- X86_EAX = X86_AL | (SUCCESSFUL << 8);
- X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */
- X86_EBX = pciSlotBX(pvp);
- }
+ if ((X86_DX == pvp->vendor_id)
+ && (X86_CX == pvp->device_id)
+ && (X86_ESI == 0)) {
+ X86_EAX = X86_AL | (SUCCESSFUL << 8);
+ X86_EFLAGS &= ~((unsigned long) 0x01); /* clear carry flag */
+ X86_EBX = pciSlotBX(pvp);
+ }
#ifdef SHOW_ALL_DEVICES
- else
- if ((dev = find_pci_device_vendor(X86_EDX, X86_ECX, X86_ESI, pvp))) {
- X86_EAX = X86_AL | (SUCCESSFUL << 8);
- X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */
- X86_EBX = pciSlotBX(dev);
- }
+ else if ((dev = find_pci_device_vendor(X86_EDX, X86_ECX, X86_ESI, pvp))) {
+ X86_EAX = X86_AL | (SUCCESSFUL << 8);
+ X86_EFLAGS &= ~((unsigned long) 0x01); /* clear carry flag */
+ X86_EBX = pciSlotBX(dev);
+ }
#endif
- else {
- X86_EAX = X86_AL | (DEVICE_NOT_FOUND << 8);
- X86_EFLAGS |= ((unsigned long)0x01); /* set carry flag */
- }
+ else {
+ X86_EAX = X86_AL | (DEVICE_NOT_FOUND << 8);
+ X86_EFLAGS |= ((unsigned long) 0x01); /* set carry flag */
+ }
#ifdef PRINT_INT
- ErrorF("ax=0x%x bx=0x%x flags=0x%x\n", X86_EAX, X86_EBX, X86_EFLAGS);
+ ErrorF("ax=0x%x bx=0x%x flags=0x%x\n", X86_EAX, X86_EBX, X86_EFLAGS);
#endif
- return 1;
+ return 1;
case 0xb103:
- if ( (X86_ECX & 0x00FFFFFF) == pvp->device_class ) {
- X86_EAX = X86_AL | (SUCCESSFUL << 8);
- X86_EBX = pciSlotBX(pvp);
- X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */
- }
+ if ((X86_ECX & 0x00FFFFFF) == pvp->device_class) {
+ X86_EAX = X86_AL | (SUCCESSFUL << 8);
+ X86_EBX = pciSlotBX(pvp);
+ X86_EFLAGS &= ~((unsigned long) 0x01); /* clear carry flag */
+ }
#ifdef SHOW_ALL_DEVICES
- else if ((dev = find_pci_class(X86_CL, X86_CH,
- (X86_ECX & 0xffff0000) >> 16,
- X86_ESI, pvp))) {
- X86_EAX = X86_AL | (SUCCESSFUL << 8);
- X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */
- X86_EBX = pciSlotBX(dev);
- }
+ else if ((dev = find_pci_class(X86_CL, X86_CH,
+ (X86_ECX & 0xffff0000) >> 16,
+ X86_ESI, pvp))) {
+ X86_EAX = X86_AL | (SUCCESSFUL << 8);
+ X86_EFLAGS &= ~((unsigned long) 0x01); /* clear carry flag */
+ X86_EBX = pciSlotBX(dev);
+ }
#endif
- else {
- X86_EAX = X86_AL | (DEVICE_NOT_FOUND << 8);
- X86_EFLAGS |= ((unsigned long)0x01); /* set carry flag */
- }
+ else {
+ X86_EAX = X86_AL | (DEVICE_NOT_FOUND << 8);
+ X86_EFLAGS |= ((unsigned long) 0x01); /* set carry flag */
+ }
#ifdef PRINT_INT
- ErrorF("ax=0x%x flags=0x%x\n", X86_EAX, X86_EFLAGS);
+ ErrorF("ax=0x%x flags=0x%x\n", X86_EAX, X86_EFLAGS);
#endif
- return 1;
+ return 1;
case 0xb108:
- if ((dev = findPci(pInt, X86_EBX)) != NULL) {
- pci_device_cfg_read_u8(dev, & X86_CL, X86_DI);
- X86_EAX = X86_AL | (SUCCESSFUL << 8);
- X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */
- } else {
- X86_EAX = X86_AL | (BAD_REGISTER_NUMBER << 8);
- X86_EFLAGS |= ((unsigned long)0x01); /* set carry flag */
- }
+ if ((dev = findPci(pInt, X86_EBX)) != NULL) {
+ pci_device_cfg_read_u8(dev, &X86_CL, X86_DI);
+ X86_EAX = X86_AL | (SUCCESSFUL << 8);
+ X86_EFLAGS &= ~((unsigned long) 0x01); /* clear carry flag */
+ }
+ else {
+ X86_EAX = X86_AL | (BAD_REGISTER_NUMBER << 8);
+ X86_EFLAGS |= ((unsigned long) 0x01); /* set carry flag */
+ }
#ifdef PRINT_INT
- ErrorF("ax=0x%x cx=0x%x flags=0x%x\n", X86_EAX, X86_ECX, X86_EFLAGS);
+ ErrorF("ax=0x%x cx=0x%x flags=0x%x\n", X86_EAX, X86_ECX, X86_EFLAGS);
#endif
- return 1;
+ return 1;
case 0xb109:
- if ((dev = findPci(pInt, X86_EBX)) != NULL) {
- pci_device_cfg_read_u16(dev, & X86_CX, X86_DI);
- X86_EAX = X86_AL | (SUCCESSFUL << 8);
- X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */
- } else {
- X86_EAX = X86_AL | (BAD_REGISTER_NUMBER << 8);
- X86_EFLAGS |= ((unsigned long)0x01); /* set carry flag */
- }
+ if ((dev = findPci(pInt, X86_EBX)) != NULL) {
+ pci_device_cfg_read_u16(dev, &X86_CX, X86_DI);
+ X86_EAX = X86_AL | (SUCCESSFUL << 8);
+ X86_EFLAGS &= ~((unsigned long) 0x01); /* clear carry flag */
+ }
+ else {
+ X86_EAX = X86_AL | (BAD_REGISTER_NUMBER << 8);
+ X86_EFLAGS |= ((unsigned long) 0x01); /* set carry flag */
+ }
#ifdef PRINT_INT
- ErrorF("ax=0x%x cx=0x%x flags=0x%x\n", X86_EAX, X86_ECX, X86_EFLAGS);
+ ErrorF("ax=0x%x cx=0x%x flags=0x%x\n", X86_EAX, X86_ECX, X86_EFLAGS);
#endif
- return 1;
+ return 1;
case 0xb10a:
- if ((dev = findPci(pInt, X86_EBX)) != NULL) {
- pci_device_cfg_read_u32(dev, & X86_ECX, X86_DI);
- X86_EAX = X86_AL | (SUCCESSFUL << 8);
- X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */
- } else {
- X86_EAX = X86_AL | (BAD_REGISTER_NUMBER << 8);
- X86_EFLAGS |= ((unsigned long)0x01); /* set carry flag */
- }
+ if ((dev = findPci(pInt, X86_EBX)) != NULL) {
+ pci_device_cfg_read_u32(dev, &X86_ECX, X86_DI);
+ X86_EAX = X86_AL | (SUCCESSFUL << 8);
+ X86_EFLAGS &= ~((unsigned long) 0x01); /* clear carry flag */
+ }
+ else {
+ X86_EAX = X86_AL | (BAD_REGISTER_NUMBER << 8);
+ X86_EFLAGS |= ((unsigned long) 0x01); /* set carry flag */
+ }
#ifdef PRINT_INT
- ErrorF("ax=0x%x cx=0x%x flags=0x%x\n", X86_EAX, X86_ECX, X86_EFLAGS);
+ ErrorF("ax=0x%x cx=0x%x flags=0x%x\n", X86_EAX, X86_ECX, X86_EFLAGS);
#endif
- return 1;
+ return 1;
case 0xb10b:
- if ((dev = findPci(pInt, X86_EBX)) != NULL) {
- pci_device_cfg_write_u8(dev, X86_CL, X86_DI);
- X86_EAX = X86_AL | (SUCCESSFUL << 8);
- X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */
- } else {
- X86_EAX = X86_AL | (BAD_REGISTER_NUMBER << 8);
- X86_EFLAGS |= ((unsigned long)0x01); /* set carry flag */
- }
+ if ((dev = findPci(pInt, X86_EBX)) != NULL) {
+ pci_device_cfg_write_u8(dev, X86_CL, X86_DI);
+ X86_EAX = X86_AL | (SUCCESSFUL << 8);
+ X86_EFLAGS &= ~((unsigned long) 0x01); /* clear carry flag */
+ }
+ else {
+ X86_EAX = X86_AL | (BAD_REGISTER_NUMBER << 8);
+ X86_EFLAGS |= ((unsigned long) 0x01); /* set carry flag */
+ }
#ifdef PRINT_INT
- ErrorF("ax=0x%x flags=0x%x\n", X86_EAX, X86_EFLAGS);
+ ErrorF("ax=0x%x flags=0x%x\n", X86_EAX, X86_EFLAGS);
#endif
- return 1;
+ return 1;
case 0xb10c:
- if ((dev = findPci(pInt, X86_EBX)) != NULL) {
- pci_device_cfg_write_u16(dev, X86_CX, X86_DI);
- X86_EAX = X86_AL | (SUCCESSFUL << 8);
- X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */
- } else {
- X86_EAX = X86_AL | (BAD_REGISTER_NUMBER << 8);
- X86_EFLAGS |= ((unsigned long)0x01); /* set carry flag */
- }
+ if ((dev = findPci(pInt, X86_EBX)) != NULL) {
+ pci_device_cfg_write_u16(dev, X86_CX, X86_DI);
+ X86_EAX = X86_AL | (SUCCESSFUL << 8);
+ X86_EFLAGS &= ~((unsigned long) 0x01); /* clear carry flag */
+ }
+ else {
+ X86_EAX = X86_AL | (BAD_REGISTER_NUMBER << 8);
+ X86_EFLAGS |= ((unsigned long) 0x01); /* set carry flag */
+ }
#ifdef PRINT_INT
- ErrorF("ax=0x%x flags=0x%x\n", X86_EAX, X86_EFLAGS);
+ ErrorF("ax=0x%x flags=0x%x\n", X86_EAX, X86_EFLAGS);
#endif
- return 1;
+ return 1;
case 0xb10d:
- if ((dev = findPci(pInt, X86_EBX)) != NULL) {
- pci_device_cfg_write_u32(dev, X86_ECX, X86_DI);
- X86_EAX = X86_AL | (SUCCESSFUL << 8);
- X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */
- } else {
- X86_EAX = X86_AL | (BAD_REGISTER_NUMBER << 8);
- X86_EFLAGS |= ((unsigned long)0x01); /* set carry flag */
- }
+ if ((dev = findPci(pInt, X86_EBX)) != NULL) {
+ pci_device_cfg_write_u32(dev, X86_ECX, X86_DI);
+ X86_EAX = X86_AL | (SUCCESSFUL << 8);
+ X86_EFLAGS &= ~((unsigned long) 0x01); /* clear carry flag */
+ }
+ else {
+ X86_EAX = X86_AL | (BAD_REGISTER_NUMBER << 8);
+ X86_EFLAGS |= ((unsigned long) 0x01); /* set carry flag */
+ }
#ifdef PRINT_INT
- ErrorF("ax=0x%x flags=0x%x\n", X86_EAX, X86_EFLAGS);
+ ErrorF("ax=0x%x flags=0x%x\n", X86_EAX, X86_EFLAGS);
#endif
- return 1;
+ return 1;
default:
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
- "int 0x1a subfunction\n");
- dump_registers(pInt);
- if (xf86GetVerbosity() > 3)
- stack_trace(pInt);
- return 0;
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
+ "int 0x1a subfunction\n");
+ dump_registers(pInt);
+ if (xf86GetVerbosity() > 3)
+ stack_trace(pInt);
+ return 0;
}
}
static struct pci_device *
findPci(xf86Int10InfoPtr pInt, unsigned short bx)
{
- const unsigned bus = (bx >> 8) & 0x00FF;
- const unsigned dev = (bx >> 3) & 0x001F;
- const unsigned func = (bx ) & 0x0007;
+ const unsigned bus = (bx >> 8) & 0x00FF;
+ const unsigned dev = (bx >> 3) & 0x001F;
+ const unsigned func = (bx) & 0x0007;
return pci_device_find_by_slot(pInt->dev->domain, bus, dev, func);
}
static CARD32
-pciSlotBX(const struct pci_device * pvp)
+pciSlotBX(const struct pci_device *pvp)
{
return ((pvp->bus << 8) & 0x00FF00) | (pvp->dev << 3) | (pvp->func);
}
@@ -861,14 +871,14 @@ pciSlotBX(const struct pci_device * pvp)
static int
intE6_handler(xf86Int10InfoPtr pInt)
{
- struct pci_device * pvp;
+ struct pci_device *pvp;
if ((pvp = xf86GetPciInfoForEntity(pInt->entityIndex)))
- X86_AX = (pvp->bus << 8) | (pvp->dev << 3) | (pvp->func & 0x7);
+ X86_AX = (pvp->bus << 8) | (pvp->dev << 3) | (pvp->func & 0x7);
pushw(pInt, X86_CS);
pushw(pInt, X86_IP);
X86_CS = pInt->BIOSseg;
X86_EIP = 0x0003;
- X86_ES = 0; /* standard pc es */
+ X86_ES = 0; /* standard pc es */
return 1;
}
diff --git a/xorg-server/hw/xfree86/int10/xf86int10.h b/xorg-server/hw/xfree86/int10/xf86int10.h
index 5bf326e78..36b659fd7 100644
--- a/xorg-server/hw/xfree86/int10/xf86int10.h
+++ b/xorg-server/hw/xfree86/int10/xf86int10.h
@@ -23,12 +23,12 @@ typedef struct {
int entityIndex;
int scrnIndex;
pointer cpuRegs;
- CARD16 BIOSseg;
- CARD16 inb40time;
- char * BIOSScratch;
+ CARD16 BIOSseg;
+ CARD16 inb40time;
+ char *BIOSScratch;
int Flags;
pointer private;
- struct _int10Mem* mem;
+ struct _int10Mem *mem;
int num;
int ax;
int bx;
@@ -45,12 +45,12 @@ typedef struct {
} xf86Int10InfoRec, *xf86Int10InfoPtr;
typedef struct _int10Mem {
- CARD8(*rb)(xf86Int10InfoPtr, int);
- CARD16(*rw)(xf86Int10InfoPtr, int);
- CARD32(*rl)(xf86Int10InfoPtr, int);
- void(*wb)(xf86Int10InfoPtr, int, CARD8);
- void(*ww)(xf86Int10InfoPtr, int, CARD16);
- void(*wl)(xf86Int10InfoPtr, int, CARD32);
+ CARD8 (*rb) (xf86Int10InfoPtr, int);
+ CARD16 (*rw) (xf86Int10InfoPtr, int);
+ CARD32 (*rl) (xf86Int10InfoPtr, int);
+ void (*wb) (xf86Int10InfoPtr, int, CARD8);
+ void (*ww) (xf86Int10InfoPtr, int, CARD16);
+ void (*wl) (xf86Int10InfoPtr, int, CARD32);
} int10MemRec, *int10MemPtr;
typedef struct {
@@ -59,16 +59,16 @@ typedef struct {
CARD8 save_vse;
CARD8 save_46e8;
} legacyVGARec, *legacyVGAPtr;
-
+
/* OS dependent functions */
extern _X_EXPORT xf86Int10InfoPtr xf86InitInt10(int entityIndex);
extern _X_EXPORT xf86Int10InfoPtr xf86ExtendedInitInt10(int entityIndex,
- int Flags);
+ int Flags);
extern _X_EXPORT void xf86FreeInt10(xf86Int10InfoPtr pInt);
extern _X_EXPORT void *xf86Int10AllocPages(xf86Int10InfoPtr pInt, int num,
- int *off);
+ int *off);
extern _X_EXPORT void xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase,
- int num);
+ int num);
extern _X_EXPORT pointer xf86int10Addr(xf86Int10InfoPtr pInt, CARD32 addr);
/* x86 executor related functions */
@@ -81,7 +81,7 @@ extern _X_EXPORT void xf86ExecX86int10(xf86Int10InfoPtr pInt);
#define SYS_BIOS 0xF0000
#if 1
#define BIOS_SIZE 0x10000
-#else /* a bug in DGUX requires this - let's try it */
+#else /* a bug in DGUX requires this - let's try it */
#define BIOS_SIZE (0x10000 - 1)
#endif
#define LOW_PAGE_SIZE 0x600
@@ -103,8 +103,8 @@ extern _X_EXPORT void xf86ExecX86int10(xf86Int10InfoPtr pInt);
#define X86_NT_MASK 0x00004000
#define X86_VM_MASK 0x00020000
#define X86_AC_MASK 0x00040000
-#define X86_VIF_MASK 0x00080000 /* virtual interrupt flag */
-#define X86_VIP_MASK 0x00100000 /* virtual interrupt pending */
+#define X86_VIF_MASK 0x00080000 /* virtual interrupt flag */
+#define X86_VIP_MASK 0x00100000 /* virtual interrupt pending */
#define X86_ID_MASK 0x00200000
#define MEM_RB(name, addr) (*name->mem->rb)(name, addr)
@@ -116,6 +116,7 @@ extern _X_EXPORT void xf86ExecX86int10(xf86Int10InfoPtr pInt);
/* OS dependent functions */
extern _X_EXPORT Bool MapCurrentInt10(xf86Int10InfoPtr pInt);
+
/* x86 executor related functions */
extern _X_EXPORT Bool xf86Int10ExecSetup(xf86Int10InfoPtr pInt);
@@ -135,21 +136,23 @@ void stack_trace(xf86Int10InfoPtr pInt);
CARD8 bios_checksum(const CARD8 *start, int size);
void LockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga);
void UnlockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga);
+
#if defined (_PC)
-extern _X_EXPORT void xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save);
+extern _X_EXPORT void xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt,
+ Bool save);
#endif
int port_rep_inb(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count);
+ CARD16 port, CARD32 base, int d_f, CARD32 count);
int port_rep_inw(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count);
+ CARD16 port, CARD32 base, int d_f, CARD32 count);
int port_rep_inl(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count);
+ CARD16 port, CARD32 base, int d_f, CARD32 count);
int port_rep_outb(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count);
+ CARD16 port, CARD32 base, int d_f, CARD32 count);
int port_rep_outw(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count);
+ CARD16 port, CARD32 base, int d_f, CARD32 count);
int port_rep_outl(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count);
+ CARD16 port, CARD32 base, int d_f, CARD32 count);
CARD8 x_inb(CARD16 port);
CARD16 x_inw(CARD16 port);
@@ -170,16 +173,19 @@ void setup_int_vect(xf86Int10InfoPtr pInt);
int setup_system_bios(void *base_addr);
void reset_int_vect(xf86Int10InfoPtr pInt);
void set_return_trap(xf86Int10InfoPtr pInt);
-extern _X_EXPORT void * xf86HandleInt10Options(ScrnInfoPtr pScrn, int entityIndex);
-Bool int10skip(const void* options);
+extern _X_EXPORT void *xf86HandleInt10Options(ScrnInfoPtr pScrn,
+ int entityIndex);
+Bool int10skip(const void *options);
Bool int10_check_bios(int scrnIndex, int codeSeg,
- const unsigned char* vbiosMem);
-Bool initPrimary(const void* options);
-extern _X_EXPORT BusType xf86int10GetBiosLocationType(const xf86Int10InfoPtr pInt);
-extern _X_EXPORT Bool xf86int10GetBiosSegment(xf86Int10InfoPtr pInt, void *base);
+ const unsigned char *vbiosMem);
+Bool initPrimary(const void *options);
+extern _X_EXPORT BusType xf86int10GetBiosLocationType(const xf86Int10InfoPtr
+ pInt);
+extern _X_EXPORT Bool xf86int10GetBiosSegment(xf86Int10InfoPtr pInt,
+ void *base);
#ifdef DEBUG
void dprint(unsigned long start, unsigned long size);
#endif
-#endif /* _INT10_PRIVATE */
-#endif /* _XF86INT10_H */
+#endif /* _INT10_PRIVATE */
+#endif /* _XF86INT10_H */
diff --git a/xorg-server/hw/xfree86/int10/xf86int10module.c b/xorg-server/hw/xfree86/int10/xf86int10module.c
index 52bf0eeb1..1eb5a0783 100644
--- a/xorg-server/hw/xfree86/int10/xf86int10module.c
+++ b/xorg-server/hw/xfree86/int10/xf86int10module.c
@@ -1,43 +1,32 @@
-/*
- * XFree86 int10 module
- * execute BIOS int 10h calls in x86 real mode environment
- * Copyright 1999 Egbert Eich
- */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86str.h"
-#include "xf86Pci.h"
-#include "xf86int10.h"
-
-#ifndef MOD_NAME
-# define MOD_NAME int10
-#endif
-
-#define stringify(x) #x
-#define STRING(x) stringify(x)
-#define concat(x,y) x ## y
-#define combine(a,b) concat(a,b)
-#define NAME(x) combine(MOD_NAME,x)
-
-static XF86ModuleVersionInfo NAME(VersRec) =
-{
- STRING(NAME( )),
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 0, 0,
- ABI_CLASS_VIDEODRV, /* needs the video driver ABI */
- ABI_VIDEODRV_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0}
-};
-
-_X_EXPORT XF86ModuleData NAME(ModuleData) = {
- &NAME(VersRec),
- NULL,
- NULL
-};
+/*
+ * XFree86 int10 module
+ * execute BIOS int 10h calls in x86 real mode environment
+ * Copyright 1999 Egbert Eich
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86str.h"
+#include "xf86Pci.h"
+#include "xf86int10.h"
+
+#ifndef MOD_NAME
+#define MOD_NAME int10
+#endif
+
+#define stringify(x) #x
+#define STRING(x) stringify(x)
+#define concat(x,y) x ## y
+#define combine(a,b) concat(a,b)
+#define NAME(x) combine(MOD_NAME,x)
+
+static XF86ModuleVersionInfo NAME(VersRec) = {
+ STRING(NAME()), MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_VIDEODRV, /* needs the video driver ABI */
+ ABI_VIDEODRV_VERSION, MOD_CLASS_NONE, {
+ 0, 0, 0, 0}
+};
+
+_X_EXPORT XF86ModuleData NAME(ModuleData) = {
+&NAME(VersRec), NULL, NULL};
diff --git a/xorg-server/hw/xfree86/loader/loader.c b/xorg-server/hw/xfree86/loader/loader.c
index 159b61198..b72b8b89d 100644
--- a/xorg-server/hw/xfree86/loader/loader.c
+++ b/xorg-server/hw/xfree86/loader/loader.c
@@ -99,20 +99,20 @@ extern void *xorg_symbols[];
void
LoaderInit(void)
{
- xf86MsgVerb(X_INFO, 2, "Loader magic: %p\n", (void *)xorg_symbols);
+ xf86MsgVerb(X_INFO, 2, "Loader magic: %p\n", (void *) xorg_symbols);
xf86MsgVerb(X_INFO, 2, "Module ABI versions:\n");
xf86ErrorFVerb(2, "\t%s: %d.%d\n", ABI_CLASS_ANSIC,
- GET_ABI_MAJOR(LoaderVersionInfo.ansicVersion),
- GET_ABI_MINOR(LoaderVersionInfo.ansicVersion));
+ GET_ABI_MAJOR(LoaderVersionInfo.ansicVersion),
+ GET_ABI_MINOR(LoaderVersionInfo.ansicVersion));
xf86ErrorFVerb(2, "\t%s: %d.%d\n", ABI_CLASS_VIDEODRV,
- GET_ABI_MAJOR(LoaderVersionInfo.videodrvVersion),
- GET_ABI_MINOR(LoaderVersionInfo.videodrvVersion));
+ GET_ABI_MAJOR(LoaderVersionInfo.videodrvVersion),
+ GET_ABI_MINOR(LoaderVersionInfo.videodrvVersion));
xf86ErrorFVerb(2, "\t%s : %d.%d\n", ABI_CLASS_XINPUT,
- GET_ABI_MAJOR(LoaderVersionInfo.xinputVersion),
- GET_ABI_MINOR(LoaderVersionInfo.xinputVersion));
+ GET_ABI_MAJOR(LoaderVersionInfo.xinputVersion),
+ GET_ABI_MINOR(LoaderVersionInfo.xinputVersion));
xf86ErrorFVerb(2, "\t%s : %d.%d\n", ABI_CLASS_EXTENSION,
- GET_ABI_MAJOR(LoaderVersionInfo.extensionVersion),
- GET_ABI_MINOR(LoaderVersionInfo.extensionVersion));
+ GET_ABI_MAJOR(LoaderVersionInfo.extensionVersion),
+ GET_ABI_MINOR(LoaderVersionInfo.extensionVersion));
}
@@ -130,12 +130,12 @@ LoaderOpen(const char *module, int *errmaj, int *errmin)
xf86Msg(X_INFO, "Loading %s\n", module);
if (!(ret = dlopen(module, DLOPEN_LAZY | DLOPEN_GLOBAL))) {
- xf86Msg(X_ERROR, "Failed to load %s: %s\n", module, dlerror());
- if (errmaj)
- *errmaj = LDR_NOLOAD;
- if (errmin)
- *errmin = LDR_NOLOAD;
- return NULL;
+ xf86Msg(X_ERROR, "Failed to load %s: %s\n", module, dlerror());
+ if (errmaj)
+ *errmaj = LDR_NOLOAD;
+ if (errmin)
+ *errmin = LDR_NOLOAD;
+ return NULL;
}
return ret;
@@ -149,13 +149,13 @@ LoaderSymbol(const char *name)
p = dlsym(RTLD_DEFAULT, name);
if (p != NULL)
- return p;
+ return p;
if (!global_scope)
- global_scope = dlopen(NULL, DLOPEN_LAZY | DLOPEN_GLOBAL);
+ global_scope = dlopen(NULL, DLOPEN_LAZY | DLOPEN_GLOBAL);
if (global_scope)
- return dlsym(global_scope, name);
+ return dlsym(global_scope, name);
return NULL;
}
@@ -165,7 +165,7 @@ LoaderUnload(const char *name, void *handle)
{
xf86Msg(X_INFO, "Unloading %s\n", name);
if (handle)
- dlclose(handle);
+ dlclose(handle);
}
unsigned long LoaderOptions = 0;
@@ -189,17 +189,18 @@ LoaderGetABIVersion(const char *abiclass)
const char *name;
int version;
} classes[] = {
- { ABI_CLASS_ANSIC, LoaderVersionInfo.ansicVersion },
- { ABI_CLASS_VIDEODRV, LoaderVersionInfo.videodrvVersion },
- { ABI_CLASS_XINPUT, LoaderVersionInfo.xinputVersion },
- { ABI_CLASS_EXTENSION, LoaderVersionInfo.extensionVersion },
- { ABI_CLASS_FONT, LoaderVersionInfo.fontVersion },
- { NULL, 0 }
+ {
+ ABI_CLASS_ANSIC, LoaderVersionInfo.ansicVersion}, {
+ ABI_CLASS_VIDEODRV, LoaderVersionInfo.videodrvVersion}, {
+ ABI_CLASS_XINPUT, LoaderVersionInfo.xinputVersion}, {
+ ABI_CLASS_EXTENSION, LoaderVersionInfo.extensionVersion}, {
+ ABI_CLASS_FONT, LoaderVersionInfo.fontVersion}, {
+ NULL, 0}
};
int i;
- for(i = 0; classes[i].name; i++) {
- if(!strcmp(classes[i].name, abiclass)) {
+ for (i = 0; classes[i].name; i++) {
+ if (!strcmp(classes[i].name, abiclass)) {
return classes[i].version;
}
}
diff --git a/xorg-server/hw/xfree86/loader/loadext.c b/xorg-server/hw/xfree86/loader/loadext.c
index 8380c300b..daa1abf8d 100644
--- a/xorg-server/hw/xfree86/loader/loadext.c
+++ b/xorg-server/hw/xfree86/loader/loadext.c
@@ -1,440 +1,440 @@
-/*
- * Copyright (c) 2000 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/* Maybe this file belongs elsewhere? */
-
-#define LOADERDECLARATIONS
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "loaderProcs.h"
-#include "misc.h"
-#include "xf86.h"
-
-/*
- * This should be static, but miinitext wants it. FIXME: make extension
- * initialization not completely terrible.
- */
-ExtensionModule *ExtensionModuleList = NULL;
-static int numExtensionModules = 0;
-
-static ExtensionModule *
-NewExtensionModule(void)
-{
- ExtensionModule *save = ExtensionModuleList;
- int n;
-
- /* Sanity check */
- if (!ExtensionModuleList)
- numExtensionModules = 0;
-
- n = numExtensionModules + 1;
- ExtensionModuleList = realloc(ExtensionModuleList,
- (n + 1) * sizeof(ExtensionModule));
- if (ExtensionModuleList == NULL) {
- ExtensionModuleList = save;
- return NULL;
- } else {
- numExtensionModules++;
- ExtensionModuleList[numExtensionModules].name = NULL;
- return ExtensionModuleList + (numExtensionModules - 1);
- }
-}
-
-void
-LoadExtension(ExtensionModule * e, Bool builtin)
-{
- ExtensionModule *newext;
-
- if (e == NULL || e->name == NULL)
- return;
-
- if (!(newext = NewExtensionModule()))
- return;
-
- if (builtin)
- xf86MsgVerb(X_INFO, 2, "Initializing built-in extension %s\n",
- e->name);
- else
- xf86MsgVerb(X_INFO, 2, "Loading extension %s\n", e->name);
-
- newext->name = e->name;
- newext->initFunc = e->initFunc;
- newext->disablePtr = e->disablePtr;
- newext->setupFunc = e->setupFunc;
- newext->initDependencies = e->initDependencies;
-
- if (e->setupFunc != NULL)
- e->setupFunc();
-}
-
-/*
- * Sort ExtensionModuleList according to the initialisation order
- * dependencies. The code for this is taken from BSD's tsort,
- * and carries the following copyright/license:
- *
- *
- * Copyright (c) 1989, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Michael Rendell of Memorial University of Newfoundland.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#define NF_MARK 0x1 /* marker for cycle detection */
-#define NF_ACYCLIC 0x2 /* this node is cycle free */
-#define NF_NODEST 0x4 /* Unreachable */
-
-typedef struct node_str NODE;
-struct node_str {
- NODE **n_prevp; /* pointer to previous node's n_next */
- NODE *n_next; /* next node in graph */
- NODE **n_arcs; /* array of arcs to other nodes */
- int n_narcs; /* number of arcs in n_arcs[] */
- int n_arcsize; /* size of n_arcs[] array */
- int n_refcnt; /* # of arcs pointing to this node */
- int n_flags; /* NF_* */
- const char *n_name; /* name of this node */
-};
-
-static NODE *graph = NULL, **cycle_buf = NULL, **longest_cycle = NULL;
-static int longest = 0;
-static NODE *sorted = NULL, *last = NULL;
-
-/* Find a node in the graph (insert if not found) and return a pointer to it. */
-static NODE *
-get_node(const char *name)
-{
- NODE *n;
-
- for (n = graph; n && n->n_name && strcmp(n->n_name, name);
- n = n->n_next) ;
- if (n)
- return n;
-
- n = xnfalloc(sizeof(NODE));
-
- n->n_narcs = 0;
- n->n_arcsize = 0;
- n->n_arcs = NULL;
- n->n_refcnt = 0;
- n->n_flags = 0;
- n->n_name = name;
-
- /* Add to linked list. */
- if ((n->n_next = graph) != NULL)
- graph->n_prevp = &n->n_next;
- n->n_prevp = &graph;
- graph = n;
-
- return n;
-}
-
-/*
- * add an arc from node s1 to node s2 in the graph. If s1 or s2 are not in
- * the graph, then add them.
- */
-static void
-add_arc(const char *s1, const char *s2)
-{
- NODE *n1;
- NODE *n2;
- int bsize, i;
-
- n1 = get_node(s1);
-
- if (!strcmp(s1, s2))
- return;
-
- n2 = get_node(s2);
-
- /*
- * Check if this arc is already here.
- */
- for (i = 0; i < n1->n_narcs; i++)
- if (n1->n_arcs[i] == n2)
- return;
- /*
- * Add it.
- */
- if (n1->n_narcs == n1->n_arcsize) {
- if (!n1->n_arcsize)
- n1->n_arcsize = 10;
- bsize = n1->n_arcsize * sizeof(*n1->n_arcs) * 2;
- n1->n_arcs = xnfrealloc(n1->n_arcs, bsize);
- n1->n_arcsize = bsize / sizeof(*n1->n_arcs);
- }
- n1->n_arcs[n1->n_narcs++] = n2;
- ++n2->n_refcnt;
-}
-
-/*
- * Clear the NODEST flag from all nodes.
- */
-static void
-clear_cycle(void)
-{
- NODE *n;
-
- for (n = graph; n != NULL; n = n->n_next)
- n->n_flags &= ~NF_NODEST;
-}
-
-/* print node and remove from graph (does not actually free node) */
-static void
-remove_node(NODE * n)
-{
- NODE **np;
- NODE *newnode;
- int i;
-
-#ifdef DEBUG
- ErrorF("%s\n", n->n_name);
-#endif
- newnode = xnfalloc(sizeof(NODE));
- memcpy(newnode, n, sizeof(NODE));
- if (last)
- last->n_next = newnode;
- else
- sorted = newnode;
- last = newnode;
- newnode->n_next = NULL;
-
- for (np = n->n_arcs, i = n->n_narcs; --i >= 0; np++)
- --(*np)->n_refcnt;
- n->n_narcs = 0;
- *n->n_prevp = n->n_next;
- if (n->n_next)
- n->n_next->n_prevp = n->n_prevp;
-}
-
-static void
-free_nodes(NODE * nodelist)
-{
- NODE *n, *nextnode;
-
- for (n = nodelist; n;) {
- nextnode = n->n_next;
- free(n);
- n = nextnode;
- }
-}
-
-/* look for the longest? cycle from node from to node to. */
-static int
-find_cycle(NODE * from, NODE * to, int longest_len, int depth)
-{
- NODE **np;
- int i, len;
-
- /*
- * avoid infinite loops and ignore portions of the graph known
- * to be acyclic
- */
- if (from->n_flags & (NF_NODEST | NF_MARK | NF_ACYCLIC))
- return 0;
- from->n_flags |= NF_MARK;
-
- for (np = from->n_arcs, i = from->n_narcs; --i >= 0; np++) {
- cycle_buf[depth] = *np;
- if (*np == to) {
- if (depth + 1 > longest_len) {
- longest_len = depth + 1;
- memcpy((char *)longest_cycle,
- (char *)cycle_buf, longest_len * sizeof(NODE *));
- }
- } else {
- if ((*np)->n_flags & (NF_MARK | NF_ACYCLIC | NF_NODEST))
- continue;
- len = find_cycle(*np, to, longest_len, depth + 1);
-
-#ifdef DEBUG
- ErrorF("%*s %s->%s %d\n", depth, "",
- from->n_name, to->n_name, len);
-#endif
-
- if (len == 0)
- (*np)->n_flags |= NF_NODEST;
-
- if (len > longest_len)
- longest_len = len;
-
- if (len > 0 && !longest)
- break;
- }
- }
- from->n_flags &= ~NF_MARK;
- return longest_len;
-}
-
-/* do topological sort on graph */
-static void
-tsort(void)
-{
- NODE *n, *next;
- int cnt, i;
-
- while (graph != NULL) {
- /*
- * Keep getting rid of simple cases until there are none left,
- * if there are any nodes still in the graph, then there is
- * a cycle in it.
- */
- do {
- for (cnt = 0, n = graph; n != NULL; n = next) {
- next = n->n_next;
- if (n->n_refcnt == 0) {
- remove_node(n);
- ++cnt;
- }
- }
- } while (graph != NULL && cnt);
-
- if (graph == NULL)
- break;
-
- if (!cycle_buf) {
- /*
- * Allocate space for two cycle logs - one to be used
- * as scratch space, the other to save the longest
- * cycle.
- */
- for (cnt = 0, n = graph; n != NULL; n = n->n_next)
- ++cnt;
- cycle_buf = xnfalloc(sizeof(NODE *) * cnt);
- longest_cycle = xnfalloc(sizeof(NODE *) * cnt);
- if (cycle_buf == NULL || longest_cycle == NULL)
- return;
- }
- for (n = graph; n != NULL; n = n->n_next)
- if (!(n->n_flags & NF_ACYCLIC)) {
- if ((cnt = find_cycle(n, n, 0, 0))) {
- ErrorF("tsort: cycle in data");
- for (i = 0; i < cnt; i++)
- ErrorF("%s", longest_cycle[i]->n_name);
- remove_node(n);
- clear_cycle();
- break;
- } else {
- /* to avoid further checks */
- n->n_flags |= NF_ACYCLIC;
- clear_cycle();
- }
- }
-
- if (n == NULL)
- ErrorF("tsort: internal error -- could not find cycle");
- }
- free(cycle_buf);
- free(longest_cycle);
- if (graph)
- free_nodes(graph);
-}
-
-void
-LoaderSortExtensions(void)
-{
- int i, j;
- ExtensionModule *ext, *newList;
- NODE *node;
-
- graph = NULL;
- longest = 0;
- sorted = NULL;
- last = NULL;
- cycle_buf = NULL;
- longest_cycle = NULL;
-
- /*
- * Parse list and build the graph. Enter them in reverse order
- * because tsort() will reverse those that have no depedencies.
- */
- for (i = numExtensionModules - 1; i >= 0; i--) {
- ext = &ExtensionModuleList[i];
- add_arc(ext->name, ext->name);
-#ifdef DEBUG
- ErrorF("Extension %s:\n", ext->name);
-#endif
- if (ext->initDependencies)
- for (j = 0; ext->initDependencies[j]; j++) {
- add_arc(ext->initDependencies[j], ext->name);
-#ifdef DEBUG
- ErrorF("\t%s\n", ext->initDependencies[j]);
-#endif
- }
- }
- tsort();
- newList = xnfalloc((numExtensionModules + 1) * sizeof(ExtensionModule));
- i = 0;
- for (node = sorted; node; node = node->n_next) {
- for (j = 0; j < numExtensionModules; j++)
- if (!strcmp(node->n_name, ExtensionModuleList[j].name))
- break;
- if (j != numExtensionModules)
- newList[i++] = ExtensionModuleList[j];
- }
- if (sorted)
- free_nodes(sorted);
- if (graph)
- free_nodes(graph);
- newList[i].name = NULL;
- free(ExtensionModuleList);
- ExtensionModuleList = newList;
-#ifdef DEBUG
- for (i = 0; ExtensionModuleList[i].name; i++)
- ErrorF("Extension %s\n", ExtensionModuleList[i].name);
-#endif
-}
+/*
+ * Copyright (c) 2000 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* Maybe this file belongs elsewhere? */
+
+#define LOADERDECLARATIONS
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "loaderProcs.h"
+#include "misc.h"
+#include "xf86.h"
+
+/*
+ * This should be static, but miinitext wants it. FIXME: make extension
+ * initialization not completely terrible.
+ */
+ExtensionModule *ExtensionModuleList = NULL;
+static int numExtensionModules = 0;
+
+static ExtensionModule *
+NewExtensionModule(void)
+{
+ ExtensionModule *save = ExtensionModuleList;
+ int n;
+
+ /* Sanity check */
+ if (!ExtensionModuleList)
+ numExtensionModules = 0;
+
+ n = numExtensionModules + 1;
+ ExtensionModuleList = realloc(ExtensionModuleList,
+ (n + 1) * sizeof(ExtensionModule));
+ if (ExtensionModuleList == NULL) {
+ ExtensionModuleList = save;
+ return NULL;
+ }
+ else {
+ numExtensionModules++;
+ ExtensionModuleList[numExtensionModules].name = NULL;
+ return ExtensionModuleList + (numExtensionModules - 1);
+ }
+}
+
+void
+LoadExtension(ExtensionModule * e, Bool builtin)
+{
+ ExtensionModule *newext;
+
+ if (e == NULL || e->name == NULL)
+ return;
+
+ if (!(newext = NewExtensionModule()))
+ return;
+
+ if (builtin)
+ xf86MsgVerb(X_INFO, 2, "Initializing built-in extension %s\n", e->name);
+ else
+ xf86MsgVerb(X_INFO, 2, "Loading extension %s\n", e->name);
+
+ newext->name = e->name;
+ newext->initFunc = e->initFunc;
+ newext->disablePtr = e->disablePtr;
+ newext->setupFunc = e->setupFunc;
+ newext->initDependencies = e->initDependencies;
+
+ if (e->setupFunc != NULL)
+ e->setupFunc();
+}
+
+/*
+ * Sort ExtensionModuleList according to the initialisation order
+ * dependencies. The code for this is taken from BSD's tsort,
+ * and carries the following copyright/license:
+ *
+ *
+ * Copyright (c) 1989, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Michael Rendell of Memorial University of Newfoundland.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#define NF_MARK 0x1 /* marker for cycle detection */
+#define NF_ACYCLIC 0x2 /* this node is cycle free */
+#define NF_NODEST 0x4 /* Unreachable */
+
+typedef struct node_str NODE;
+struct node_str {
+ NODE **n_prevp; /* pointer to previous node's n_next */
+ NODE *n_next; /* next node in graph */
+ NODE **n_arcs; /* array of arcs to other nodes */
+ int n_narcs; /* number of arcs in n_arcs[] */
+ int n_arcsize; /* size of n_arcs[] array */
+ int n_refcnt; /* # of arcs pointing to this node */
+ int n_flags; /* NF_* */
+ const char *n_name; /* name of this node */
+};
+
+static NODE *graph = NULL, **cycle_buf = NULL, **longest_cycle = NULL;
+static int longest = 0;
+static NODE *sorted = NULL, *last = NULL;
+
+/* Find a node in the graph (insert if not found) and return a pointer to it. */
+static NODE *
+get_node(const char *name)
+{
+ NODE *n;
+
+ for (n = graph; n && n->n_name && strcmp(n->n_name, name); n = n->n_next);
+ if (n)
+ return n;
+
+ n = xnfalloc(sizeof(NODE));
+
+ n->n_narcs = 0;
+ n->n_arcsize = 0;
+ n->n_arcs = NULL;
+ n->n_refcnt = 0;
+ n->n_flags = 0;
+ n->n_name = name;
+
+ /* Add to linked list. */
+ if ((n->n_next = graph) != NULL)
+ graph->n_prevp = &n->n_next;
+ n->n_prevp = &graph;
+ graph = n;
+
+ return n;
+}
+
+/*
+ * add an arc from node s1 to node s2 in the graph. If s1 or s2 are not in
+ * the graph, then add them.
+ */
+static void
+add_arc(const char *s1, const char *s2)
+{
+ NODE *n1;
+ NODE *n2;
+ int bsize, i;
+
+ n1 = get_node(s1);
+
+ if (!strcmp(s1, s2))
+ return;
+
+ n2 = get_node(s2);
+
+ /*
+ * Check if this arc is already here.
+ */
+ for (i = 0; i < n1->n_narcs; i++)
+ if (n1->n_arcs[i] == n2)
+ return;
+ /*
+ * Add it.
+ */
+ if (n1->n_narcs == n1->n_arcsize) {
+ if (!n1->n_arcsize)
+ n1->n_arcsize = 10;
+ bsize = n1->n_arcsize * sizeof(*n1->n_arcs) * 2;
+ n1->n_arcs = xnfrealloc(n1->n_arcs, bsize);
+ n1->n_arcsize = bsize / sizeof(*n1->n_arcs);
+ }
+ n1->n_arcs[n1->n_narcs++] = n2;
+ ++n2->n_refcnt;
+}
+
+/*
+ * Clear the NODEST flag from all nodes.
+ */
+static void
+clear_cycle(void)
+{
+ NODE *n;
+
+ for (n = graph; n != NULL; n = n->n_next)
+ n->n_flags &= ~NF_NODEST;
+}
+
+/* print node and remove from graph (does not actually free node) */
+static void
+remove_node(NODE * n)
+{
+ NODE **np;
+ NODE *newnode;
+ int i;
+
+#ifdef DEBUG
+ ErrorF("%s\n", n->n_name);
+#endif
+ newnode = xnfalloc(sizeof(NODE));
+ memcpy(newnode, n, sizeof(NODE));
+ if (last)
+ last->n_next = newnode;
+ else
+ sorted = newnode;
+ last = newnode;
+ newnode->n_next = NULL;
+
+ for (np = n->n_arcs, i = n->n_narcs; --i >= 0; np++)
+ --(*np)->n_refcnt;
+ n->n_narcs = 0;
+ *n->n_prevp = n->n_next;
+ if (n->n_next)
+ n->n_next->n_prevp = n->n_prevp;
+}
+
+static void
+free_nodes(NODE * nodelist)
+{
+ NODE *n, *nextnode;
+
+ for (n = nodelist; n;) {
+ nextnode = n->n_next;
+ free(n);
+ n = nextnode;
+ }
+}
+
+/* look for the longest? cycle from node from to node to. */
+static int
+find_cycle(NODE * from, NODE * to, int longest_len, int depth)
+{
+ NODE **np;
+ int i, len;
+
+ /*
+ * avoid infinite loops and ignore portions of the graph known
+ * to be acyclic
+ */
+ if (from->n_flags & (NF_NODEST | NF_MARK | NF_ACYCLIC))
+ return 0;
+ from->n_flags |= NF_MARK;
+
+ for (np = from->n_arcs, i = from->n_narcs; --i >= 0; np++) {
+ cycle_buf[depth] = *np;
+ if (*np == to) {
+ if (depth + 1 > longest_len) {
+ longest_len = depth + 1;
+ memcpy((char *) longest_cycle,
+ (char *) cycle_buf, longest_len * sizeof(NODE *));
+ }
+ }
+ else {
+ if ((*np)->n_flags & (NF_MARK | NF_ACYCLIC | NF_NODEST))
+ continue;
+ len = find_cycle(*np, to, longest_len, depth + 1);
+
+#ifdef DEBUG
+ ErrorF("%*s %s->%s %d\n", depth, "", from->n_name, to->n_name, len);
+#endif
+
+ if (len == 0)
+ (*np)->n_flags |= NF_NODEST;
+
+ if (len > longest_len)
+ longest_len = len;
+
+ if (len > 0 && !longest)
+ break;
+ }
+ }
+ from->n_flags &= ~NF_MARK;
+ return longest_len;
+}
+
+/* do topological sort on graph */
+static void
+tsort(void)
+{
+ NODE *n, *next;
+ int cnt, i;
+
+ while (graph != NULL) {
+ /*
+ * Keep getting rid of simple cases until there are none left,
+ * if there are any nodes still in the graph, then there is
+ * a cycle in it.
+ */
+ do {
+ for (cnt = 0, n = graph; n != NULL; n = next) {
+ next = n->n_next;
+ if (n->n_refcnt == 0) {
+ remove_node(n);
+ ++cnt;
+ }
+ }
+ } while (graph != NULL && cnt);
+
+ if (graph == NULL)
+ break;
+
+ if (!cycle_buf) {
+ /*
+ * Allocate space for two cycle logs - one to be used
+ * as scratch space, the other to save the longest
+ * cycle.
+ */
+ for (cnt = 0, n = graph; n != NULL; n = n->n_next)
+ ++cnt;
+ cycle_buf = xnfalloc(sizeof(NODE *) * cnt);
+ longest_cycle = xnfalloc(sizeof(NODE *) * cnt);
+ if (cycle_buf == NULL || longest_cycle == NULL)
+ return;
+ }
+ for (n = graph; n != NULL; n = n->n_next)
+ if (!(n->n_flags & NF_ACYCLIC)) {
+ if ((cnt = find_cycle(n, n, 0, 0))) {
+ ErrorF("tsort: cycle in data");
+ for (i = 0; i < cnt; i++)
+ ErrorF("%s", longest_cycle[i]->n_name);
+ remove_node(n);
+ clear_cycle();
+ break;
+ }
+ else {
+ /* to avoid further checks */
+ n->n_flags |= NF_ACYCLIC;
+ clear_cycle();
+ }
+ }
+
+ if (n == NULL)
+ ErrorF("tsort: internal error -- could not find cycle");
+ }
+ free(cycle_buf);
+ free(longest_cycle);
+ if (graph)
+ free_nodes(graph);
+}
+
+void
+LoaderSortExtensions(void)
+{
+ int i, j;
+ ExtensionModule *ext, *newList;
+ NODE *node;
+
+ graph = NULL;
+ longest = 0;
+ sorted = NULL;
+ last = NULL;
+ cycle_buf = NULL;
+ longest_cycle = NULL;
+
+ /*
+ * Parse list and build the graph. Enter them in reverse order
+ * because tsort() will reverse those that have no depedencies.
+ */
+ for (i = numExtensionModules - 1; i >= 0; i--) {
+ ext = &ExtensionModuleList[i];
+ add_arc(ext->name, ext->name);
+#ifdef DEBUG
+ ErrorF("Extension %s:\n", ext->name);
+#endif
+ if (ext->initDependencies)
+ for (j = 0; ext->initDependencies[j]; j++) {
+ add_arc(ext->initDependencies[j], ext->name);
+#ifdef DEBUG
+ ErrorF("\t%s\n", ext->initDependencies[j]);
+#endif
+ }
+ }
+ tsort();
+ newList = xnfalloc((numExtensionModules + 1) * sizeof(ExtensionModule));
+ i = 0;
+ for (node = sorted; node; node = node->n_next) {
+ for (j = 0; j < numExtensionModules; j++)
+ if (!strcmp(node->n_name, ExtensionModuleList[j].name))
+ break;
+ if (j != numExtensionModules)
+ newList[i++] = ExtensionModuleList[j];
+ }
+ if (sorted)
+ free_nodes(sorted);
+ if (graph)
+ free_nodes(graph);
+ newList[i].name = NULL;
+ free(ExtensionModuleList);
+ ExtensionModuleList = newList;
+#ifdef DEBUG
+ for (i = 0; ExtensionModuleList[i].name; i++)
+ ErrorF("Extension %s\n", ExtensionModuleList[i].name);
+#endif
+}
diff --git a/xorg-server/hw/xfree86/loader/loadmod.c b/xorg-server/hw/xfree86/loader/loadmod.c
index 5b9c11950..c6b559072 100644
--- a/xorg-server/hw/xfree86/loader/loadmod.c
+++ b/xorg-server/hw/xfree86/loader/loadmod.c
@@ -74,16 +74,15 @@ typedef struct _pattern {
} PatternRec, *PatternPtr;
/* Prototypes for static functions */
-static char *FindModule(const char *, const char *, const char **,
- PatternPtr);
+static char *FindModule(const char *, const char *, const char **, PatternPtr);
static Bool CheckVersion(const char *, XF86ModuleVersionInfo *,
- const XF86ModReqInfo *);
+ const XF86ModReqInfo *);
static void UnloadModuleOrDriver(ModuleDescPtr mod);
static char *LoaderGetCanonicalName(const char *, PatternPtr);
static void RemoveChild(ModuleDescPtr);
static ModuleDescPtr doLoadModule(const char *, const char *, const char **,
- const char **, pointer,
- const XF86ModReqInfo *, int *, int *);
+ const char **, pointer,
+ const XF86ModReqInfo *, int *, int *);
const ModuleVersions LoaderVersionInfo = {
XORG_VERSION_CURRENT,
@@ -94,7 +93,7 @@ const ModuleVersions LoaderVersionInfo = {
ABI_FONT_VERSION
};
-static int ModuleDuplicated[] = {};
+static int ModuleDuplicated[] = { };
static void
FreeStringList(char **paths)
@@ -102,10 +101,10 @@ FreeStringList(char **paths)
char **p;
if (!paths)
- return;
+ return;
for (p = paths; *p; p++)
- free(*p);
+ free(*p);
free(paths);
}
@@ -116,7 +115,7 @@ static Bool
PathIsAbsolute(const char *path)
{
return *path == '/';
-}
+}
/*
* Convert a comma-separated path into a NULL-terminated array of path
@@ -134,46 +133,45 @@ InitPathList(const char *path)
int n = 0;
if (!path)
- return defaultPathList;
+ return defaultPathList;
fullpath = strdup(path);
if (!fullpath)
- return NULL;
+ return NULL;
elem = strtok(fullpath, ",");
while (elem) {
- if (PathIsAbsolute(elem))
- {
- len = strlen(elem);
- addslash = (elem[len - 1] != '/');
- if (addslash)
- len++;
- save = list;
- list = realloc(list, (n + 2) * sizeof(char *));
- if (!list) {
- if (save) {
- save[n] = NULL;
- FreeStringList(save);
- }
- free(fullpath);
- return NULL;
- }
- list[n] = malloc(len + 1);
- if (!list[n]) {
- FreeStringList(list);
- free(fullpath);
- return NULL;
- }
- strcpy(list[n], elem);
- if (addslash) {
- list[n][len - 1] = '/';
- list[n][len] = '\0';
- }
- n++;
- }
- elem = strtok(NULL, ",");
+ if (PathIsAbsolute(elem)) {
+ len = strlen(elem);
+ addslash = (elem[len - 1] != '/');
+ if (addslash)
+ len++;
+ save = list;
+ list = realloc(list, (n + 2) * sizeof(char *));
+ if (!list) {
+ if (save) {
+ save[n] = NULL;
+ FreeStringList(save);
+ }
+ free(fullpath);
+ return NULL;
+ }
+ list[n] = malloc(len + 1);
+ if (!list[n]) {
+ FreeStringList(list);
+ free(fullpath);
+ return NULL;
+ }
+ strcpy(list[n], elem);
+ if (addslash) {
+ list[n][len - 1] = '/';
+ list[n][len] = '\0';
+ }
+ n++;
+ }
+ elem = strtok(NULL, ",");
}
if (list)
- list[n] = NULL;
+ list[n] = NULL;
free(fullpath);
return list;
}
@@ -182,14 +180,14 @@ static void
FreePathList(char **pathlist)
{
if (pathlist && pathlist != defaultPathList)
- FreeStringList(pathlist);
+ FreeStringList(pathlist);
}
void
LoaderSetPath(const char *path)
{
if (!path)
- return;
+ return;
defaultPathList = InitPathList(path);
}
@@ -231,43 +229,45 @@ InitPatterns(const char **patternlist)
const char **s;
if (firstTime) {
- /* precompile stdPatterns */
- firstTime = 0;
- for (p = stdPatterns; p->pattern; p++)
- if ((e = regcomp(&p->rex, p->pattern, REG_EXTENDED)) != 0) {
- regerror(e, &p->rex, errmsg, sizeof(errmsg));
- FatalError("InitPatterns: regcomp error for `%s': %s\n",
- p->pattern, errmsg);
- }
+ /* precompile stdPatterns */
+ firstTime = 0;
+ for (p = stdPatterns; p->pattern; p++)
+ if ((e = regcomp(&p->rex, p->pattern, REG_EXTENDED)) != 0) {
+ regerror(e, &p->rex, errmsg, sizeof(errmsg));
+ FatalError("InitPatterns: regcomp error for `%s': %s\n",
+ p->pattern, errmsg);
+ }
}
if (patternlist) {
- for (i = 0, s = patternlist; *s; i++, s++)
- if (*s == DEFAULT_LIST)
- i += sizeof(stdPatterns) / sizeof(stdPatterns[0]) - 1 - 1;
- patterns = malloc((i + 1) * sizeof(PatternRec));
- if (!patterns) {
- return NULL;
- }
- for (i = 0, s = patternlist; *s; i++, s++)
- if (*s != DEFAULT_LIST) {
- p = patterns + i;
- p->pattern = *s;
- if ((e = regcomp(&p->rex, p->pattern, REG_EXTENDED)) != 0) {
- regerror(e, &p->rex, errmsg, sizeof(errmsg));
- ErrorF("InitPatterns: regcomp error for `%s': %s\n",
- p->pattern, errmsg);
- i--;
- }
- } else {
- for (p = stdPatterns; p->pattern; p++, i++)
- patterns[i] = *p;
- if (p != stdPatterns)
- i--;
- }
- patterns[i].pattern = NULL;
- } else
- patterns = stdPatterns;
+ for (i = 0, s = patternlist; *s; i++, s++)
+ if (*s == DEFAULT_LIST)
+ i += sizeof(stdPatterns) / sizeof(stdPatterns[0]) - 1 - 1;
+ patterns = malloc((i + 1) * sizeof(PatternRec));
+ if (!patterns) {
+ return NULL;
+ }
+ for (i = 0, s = patternlist; *s; i++, s++)
+ if (*s != DEFAULT_LIST) {
+ p = patterns + i;
+ p->pattern = *s;
+ if ((e = regcomp(&p->rex, p->pattern, REG_EXTENDED)) != 0) {
+ regerror(e, &p->rex, errmsg, sizeof(errmsg));
+ ErrorF("InitPatterns: regcomp error for `%s': %s\n",
+ p->pattern, errmsg);
+ i--;
+ }
+ }
+ else {
+ for (p = stdPatterns; p->pattern; p++, i++)
+ patterns[i] = *p;
+ if (p != stdPatterns)
+ i--;
+ }
+ patterns[i].pattern = NULL;
+ }
+ else
+ patterns = stdPatterns;
return patterns;
}
@@ -275,7 +275,7 @@ static void
FreePatterns(PatternPtr patterns)
{
if (patterns && patterns != stdPatterns)
- free(patterns);
+ free(patterns);
}
static const char **
@@ -291,82 +291,84 @@ InitSubdirs(const char **subdirlist)
Bool indefault;
if (subdirlist == NULL) {
- subdirlist = tmp_subdirlist = malloc(2 * sizeof(char *));
- if (subdirlist == NULL)
- return NULL;
- subdirlist[0] = DEFAULT_LIST;
- subdirlist[1] = NULL;
+ subdirlist = tmp_subdirlist = malloc(2 * sizeof(char *));
+ if (subdirlist == NULL)
+ return NULL;
+ subdirlist[0] = DEFAULT_LIST;
+ subdirlist[1] = NULL;
}
LoaderGetOS(&osname, NULL, NULL, NULL);
oslen = strlen(osname);
{
- /* Count number of entries and check for invalid paths */
- for (i = 0, s = subdirlist; *s; i++, s++) {
- if (*s == DEFAULT_LIST) {
- i += sizeof(stdSubdirs) / sizeof(stdSubdirs[0]) - 1 - 1;
- } else {
- /*
- * Path validity check. Don't allow absolute paths, or
- * paths containing "..". To catch absolute paths on
- * platforms that use driver letters, don't allow the ':'
- * character to appear at all.
- */
- if (**s == '/' || **s == '\\' || strchr(*s, ':') ||
- strstr(*s, "..")) {
- xf86Msg(X_ERROR, "InitSubdirs: Bad subdir: \"%s\"\n", *s);
- free(tmp_subdirlist);
- return NULL;
- }
- }
- }
- subdirs = malloc((i * 2 + 1) * sizeof(char *));
- if (!subdirs) {
- free(tmp_subdirlist);
- return NULL;
- }
- i = 0;
- s = subdirlist;
- indefault = FALSE;
- while (*s) {
- if (*s == DEFAULT_LIST) {
- /* Divert to the default list */
- indefault = TRUE;
- stmp = ++s;
- s = stdSubdirs;
- }
- len = strlen(*s);
- if (**s && (*s)[len - 1] != '/') {
- slash = "/";
- len++;
- } else
- slash = "";
- len += oslen + 2;
- if (!(subdirs[i] = malloc(len))) {
- while (--i >= 0)
- free(subdirs[i]);
- free(subdirs);
- free(tmp_subdirlist);
- return NULL;
- }
- /* tack on the OS name */
- sprintf(subdirs[i], "%s%s%s/", *s, slash, osname);
- i++;
- /* path as given */
- subdirs[i] = strdup(*s);
- i++;
- s++;
- if (indefault && !s) {
- /* revert back to the main list */
- indefault = FALSE;
- s = stmp;
- }
- }
- subdirs[i] = NULL;
+ /* Count number of entries and check for invalid paths */
+ for (i = 0, s = subdirlist; *s; i++, s++) {
+ if (*s == DEFAULT_LIST) {
+ i += sizeof(stdSubdirs) / sizeof(stdSubdirs[0]) - 1 - 1;
+ }
+ else {
+ /*
+ * Path validity check. Don't allow absolute paths, or
+ * paths containing "..". To catch absolute paths on
+ * platforms that use driver letters, don't allow the ':'
+ * character to appear at all.
+ */
+ if (**s == '/' || **s == '\\' || strchr(*s, ':') ||
+ strstr(*s, "..")) {
+ xf86Msg(X_ERROR, "InitSubdirs: Bad subdir: \"%s\"\n", *s);
+ free(tmp_subdirlist);
+ return NULL;
+ }
+ }
+ }
+ subdirs = malloc((i * 2 + 1) * sizeof(char *));
+ if (!subdirs) {
+ free(tmp_subdirlist);
+ return NULL;
+ }
+ i = 0;
+ s = subdirlist;
+ indefault = FALSE;
+ while (*s) {
+ if (*s == DEFAULT_LIST) {
+ /* Divert to the default list */
+ indefault = TRUE;
+ stmp = ++s;
+ s = stdSubdirs;
+ }
+ len = strlen(*s);
+ if (**s && (*s)[len - 1] != '/') {
+ slash = "/";
+ len++;
+ }
+ else
+ slash = "";
+ len += oslen + 2;
+ if (!(subdirs[i] = malloc(len))) {
+ while (--i >= 0)
+ free(subdirs[i]);
+ free(subdirs);
+ free(tmp_subdirlist);
+ return NULL;
+ }
+ /* tack on the OS name */
+ sprintf(subdirs[i], "%s%s%s/", *s, slash, osname);
+ i++;
+ /* path as given */
+ subdirs[i] = strdup(*s);
+ i++;
+ s++;
+ if (indefault && !s) {
+ /* revert back to the main list */
+ indefault = FALSE;
+ s = stmp;
+ }
+ }
+ subdirs[i] = NULL;
}
free(tmp_subdirlist);
- return (const char **)subdirs;
+ return (const char **) subdirs;
}
static void
@@ -375,9 +377,9 @@ FreeSubdirs(const char **subdirs)
const char **s;
if (subdirs) {
- for (s = subdirs; *s; s++)
- free((char *)*s);
- free(subdirs);
+ for (s = subdirs; *s; s++)
+ free((char *) *s);
+ free(subdirs);
}
}
@@ -397,44 +399,44 @@ FindModuleInSubdir(const char *dirpath, const char *module)
if (direntry->d_name[0] == '.')
continue;
snprintf(tmpBuf, PATH_MAX, "%s%s/", dirpath, direntry->d_name);
- /* the stat with the appended / fails for normal files,
- and works for sub dirs fine, looks a bit strange in strace
- but does seem to work */
+ /* the stat with the appended / fails for normal files,
+ and works for sub dirs fine, looks a bit strange in strace
+ but does seem to work */
if ((stat(tmpBuf, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode)) {
if ((ret = FindModuleInSubdir(tmpBuf, module)))
break;
continue;
}
-
+
snprintf(tmpBuf, PATH_MAX, "lib%s.so", module);
if (strcmp(direntry->d_name, tmpBuf) == 0) {
if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1)
- ret = NULL;
+ ret = NULL;
break;
}
snprintf(tmpBuf, PATH_MAX, "%s_drv.so", module);
if (strcmp(direntry->d_name, tmpBuf) == 0) {
if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1)
- ret = NULL;
+ ret = NULL;
break;
}
snprintf(tmpBuf, PATH_MAX, "%s.so", module);
if (strcmp(direntry->d_name, tmpBuf) == 0) {
if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1)
- ret = NULL;
+ ret = NULL;
break;
}
}
-
+
closedir(dir);
return ret;
}
static char *
FindModule(const char *module, const char *dirname, const char **subdirlist,
- PatternPtr patterns)
+ PatternPtr patterns)
{
char buf[PATH_MAX + 1];
char *name = NULL;
@@ -442,17 +444,17 @@ FindModule(const char *module, const char *dirname, const char **subdirlist,
const char **s;
if (strlen(dirname) > PATH_MAX)
- return NULL;
-
+ return NULL;
+
subdirs = InitSubdirs(subdirlist);
if (!subdirs)
- return NULL;
+ return NULL;
for (s = subdirs; *s; s++) {
- if ((strlen(dirname) + strlen(*s)) > PATH_MAX)
- continue;
- strcpy(buf, dirname);
- strcat(buf, *s);
+ if ((strlen(dirname) + strlen(*s)) > PATH_MAX)
+ continue;
+ strcpy(buf, dirname);
+ strcat(buf, *s);
if ((name = FindModuleInSubdir(buf, module)))
break;
}
@@ -484,70 +486,70 @@ LoaderListDirs(const char **subdirlist, const char **patternlist)
int n = 0;
if (!(pathlist = InitPathList(NULL)))
- return NULL;
+ return NULL;
if (!(subdirs = InitSubdirs(subdirlist)))
- goto bail;
+ goto bail;
if (!(patterns = InitPatterns(patternlist)))
- goto bail;
+ goto bail;
for (elem = pathlist; *elem; elem++) {
- for (s = subdirs; *s; s++) {
- if ((dirlen = strlen(*elem) + strlen(*s)) > PATH_MAX)
- continue;
- strcpy(buf, *elem);
- strcat(buf, *s);
- fp = buf + dirlen;
- if (stat(buf, &stat_buf) == 0 && S_ISDIR(stat_buf.st_mode) &&
- (d = opendir(buf))) {
- if (buf[dirlen - 1] != '/') {
- buf[dirlen++] = '/';
- fp++;
- }
- while ((dp = readdir(d))) {
- if (dirlen + strlen(dp->d_name) > PATH_MAX)
- continue;
- strcpy(fp, dp->d_name);
- if (!(stat(buf, &stat_buf) == 0 &&
- S_ISREG(stat_buf.st_mode)))
- continue;
- for (p = patterns; p->pattern; p++) {
- if (regexec(&p->rex, dp->d_name, 2, match, 0) == 0 &&
- match[1].rm_so != -1) {
- len = match[1].rm_eo - match[1].rm_so;
- save = listing;
- listing = realloc(listing,
- (n + 2) * sizeof(char *));
- if (!listing) {
- if (save) {
- save[n] = NULL;
- FreeStringList(save);
- }
- closedir(d);
- goto bail;
- }
- listing[n] = malloc(len + 1);
- if (!listing[n]) {
- FreeStringList(listing);
- closedir(d);
- goto bail;
- }
- strncpy(listing[n], dp->d_name + match[1].rm_so,
- len);
- listing[n][len] = '\0';
- n++;
- break;
- }
- }
- }
- closedir(d);
- }
- }
+ for (s = subdirs; *s; s++) {
+ if ((dirlen = strlen(*elem) + strlen(*s)) > PATH_MAX)
+ continue;
+ strcpy(buf, *elem);
+ strcat(buf, *s);
+ fp = buf + dirlen;
+ if (stat(buf, &stat_buf) == 0 && S_ISDIR(stat_buf.st_mode) &&
+ (d = opendir(buf))) {
+ if (buf[dirlen - 1] != '/') {
+ buf[dirlen++] = '/';
+ fp++;
+ }
+ while ((dp = readdir(d))) {
+ if (dirlen + strlen(dp->d_name) > PATH_MAX)
+ continue;
+ strcpy(fp, dp->d_name);
+ if (!(stat(buf, &stat_buf) == 0 &&
+ S_ISREG(stat_buf.st_mode)))
+ continue;
+ for (p = patterns; p->pattern; p++) {
+ if (regexec(&p->rex, dp->d_name, 2, match, 0) == 0 &&
+ match[1].rm_so != -1) {
+ len = match[1].rm_eo - match[1].rm_so;
+ save = listing;
+ listing = realloc(listing,
+ (n + 2) * sizeof(char *));
+ if (!listing) {
+ if (save) {
+ save[n] = NULL;
+ FreeStringList(save);
+ }
+ closedir(d);
+ goto bail;
+ }
+ listing[n] = malloc(len + 1);
+ if (!listing[n]) {
+ FreeStringList(listing);
+ closedir(d);
+ goto bail;
+ }
+ strncpy(listing[n], dp->d_name + match[1].rm_so,
+ len);
+ listing[n][len] = '\0';
+ n++;
+ break;
+ }
+ }
+ }
+ closedir(d);
+ }
+ }
}
if (listing)
- listing[n] = NULL;
+ listing[n] = NULL;
ret = listing;
-bail:
+ bail:
FreePatterns(patterns);
FreeSubdirs(subdirs);
FreePathList(pathlist);
@@ -562,7 +564,7 @@ LoaderFreeDirList(char **list)
static Bool
CheckVersion(const char *module, XF86ModuleVersionInfo * data,
- const XF86ModReqInfo * req)
+ const XF86ModReqInfo * req)
{
int vercode[4];
char verstr[4];
@@ -570,8 +572,8 @@ CheckVersion(const char *module, XF86ModuleVersionInfo * data,
MessageType errtype;
xf86Msg(X_INFO, "Module %s: vendor=\"%s\"\n",
- data->modname ? data->modname : "UNKNOWN!",
- data->vendor ? data->vendor : "UNKNOWN!");
+ data->modname ? data->modname : "UNKNOWN!",
+ data->vendor ? data->vendor : "UNKNOWN!");
/* Check for the different scheme used in XFree86 4.0.x releases:
* ((((((((major << 7) | minor) << 7) | subminor) << 5) | beta) << 5) | alpha)
@@ -579,152 +581,157 @@ CheckVersion(const char *module, XF86ModuleVersionInfo * data,
* range, which limits the overlap with the new version scheme to conflicts
* with 6.71.8.764 through 6.72.39.934.
*/
- if ((ver > (4 << 24)) && (ver < ( (4 << 24) + (1 << 17)))) {
- /* 4.0.x and earlier */
- verstr[1] = verstr[3] = 0;
- verstr[2] = (ver & 0x1f) ? (ver & 0x1f) + 'a' - 1 : 0;
- ver >>= 5;
- verstr[0] = (ver & 0x1f) ? (ver & 0x1f) + 'A' - 1 : 0;
- ver >>= 5;
- vercode[2] = ver & 0x7f;
- ver >>= 7;
- vercode[1] = ver & 0x7f;
- ver >>= 7;
- vercode[0] = ver;
- xf86ErrorF("\tcompiled for %d.%d", vercode[0], vercode[1]);
- if (vercode[2] != 0)
- xf86ErrorF(".%d", vercode[2]);
- xf86ErrorF("%s%s, module version = %d.%d.%d\n", verstr, verstr + 2,
- data->majorversion, data->minorversion, data->patchlevel);
- } else {
- vercode[0] = ver / 10000000;
- vercode[1] = (ver / 100000) % 100;
- vercode[2] = (ver / 1000) % 100;
- vercode[3] = ver % 1000;
- xf86ErrorF("\tcompiled for %d.%d.%d", vercode[0], vercode[1],
- vercode[2]);
- if (vercode[3] != 0)
- xf86ErrorF(".%d", vercode[3]);
- xf86ErrorF(", module version = %d.%d.%d\n", data->majorversion,
- data->minorversion, data->patchlevel);
+ if ((ver > (4 << 24)) && (ver < ((4 << 24) + (1 << 17)))) {
+ /* 4.0.x and earlier */
+ verstr[1] = verstr[3] = 0;
+ verstr[2] = (ver & 0x1f) ? (ver & 0x1f) + 'a' - 1 : 0;
+ ver >>= 5;
+ verstr[0] = (ver & 0x1f) ? (ver & 0x1f) + 'A' - 1 : 0;
+ ver >>= 5;
+ vercode[2] = ver & 0x7f;
+ ver >>= 7;
+ vercode[1] = ver & 0x7f;
+ ver >>= 7;
+ vercode[0] = ver;
+ xf86ErrorF("\tcompiled for %d.%d", vercode[0], vercode[1]);
+ if (vercode[2] != 0)
+ xf86ErrorF(".%d", vercode[2]);
+ xf86ErrorF("%s%s, module version = %d.%d.%d\n", verstr, verstr + 2,
+ data->majorversion, data->minorversion, data->patchlevel);
+ }
+ else {
+ vercode[0] = ver / 10000000;
+ vercode[1] = (ver / 100000) % 100;
+ vercode[2] = (ver / 1000) % 100;
+ vercode[3] = ver % 1000;
+ xf86ErrorF("\tcompiled for %d.%d.%d", vercode[0], vercode[1],
+ vercode[2]);
+ if (vercode[3] != 0)
+ xf86ErrorF(".%d", vercode[3]);
+ xf86ErrorF(", module version = %d.%d.%d\n", data->majorversion,
+ data->minorversion, data->patchlevel);
}
if (data->moduleclass)
- xf86ErrorFVerb(2, "\tModule class: %s\n", data->moduleclass);
+ xf86ErrorFVerb(2, "\tModule class: %s\n", data->moduleclass);
ver = -1;
if (data->abiclass) {
- int abimaj, abimin;
- int vermaj, vermin;
-
- if (!strcmp(data->abiclass, ABI_CLASS_ANSIC))
- ver = LoaderVersionInfo.ansicVersion;
- else if (!strcmp(data->abiclass, ABI_CLASS_VIDEODRV))
- ver = LoaderVersionInfo.videodrvVersion;
- else if (!strcmp(data->abiclass, ABI_CLASS_XINPUT))
- ver = LoaderVersionInfo.xinputVersion;
- else if (!strcmp(data->abiclass, ABI_CLASS_EXTENSION))
- ver = LoaderVersionInfo.extensionVersion;
- else if (!strcmp(data->abiclass, ABI_CLASS_FONT))
- ver = LoaderVersionInfo.fontVersion;
-
- abimaj = GET_ABI_MAJOR(data->abiversion);
- abimin = GET_ABI_MINOR(data->abiversion);
- xf86ErrorFVerb(2, "\tABI class: %s, version %d.%d\n",
- data->abiclass, abimaj, abimin);
- if (ver != -1) {
- vermaj = GET_ABI_MAJOR(ver);
- vermin = GET_ABI_MINOR(ver);
- if (abimaj != vermaj) {
- if (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL)
- errtype = X_WARNING;
- else
- errtype = X_ERROR;
- xf86MsgVerb(errtype, 0,
- "module ABI major version (%d) doesn't"
- " match the server's version (%d)\n",
- abimaj, vermaj);
- if (!(LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL))
- return FALSE;
- } else if (abimin > vermin) {
- if (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL)
- errtype = X_WARNING;
- else
- errtype = X_ERROR;
- xf86MsgVerb(errtype, 0,
- "module ABI minor version (%d) is "
- "newer than the server's version "
- "(%d)\n", abimin, vermin);
- if (!(LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL))
- return FALSE;
- }
- }
+ int abimaj, abimin;
+ int vermaj, vermin;
+
+ if (!strcmp(data->abiclass, ABI_CLASS_ANSIC))
+ ver = LoaderVersionInfo.ansicVersion;
+ else if (!strcmp(data->abiclass, ABI_CLASS_VIDEODRV))
+ ver = LoaderVersionInfo.videodrvVersion;
+ else if (!strcmp(data->abiclass, ABI_CLASS_XINPUT))
+ ver = LoaderVersionInfo.xinputVersion;
+ else if (!strcmp(data->abiclass, ABI_CLASS_EXTENSION))
+ ver = LoaderVersionInfo.extensionVersion;
+ else if (!strcmp(data->abiclass, ABI_CLASS_FONT))
+ ver = LoaderVersionInfo.fontVersion;
+
+ abimaj = GET_ABI_MAJOR(data->abiversion);
+ abimin = GET_ABI_MINOR(data->abiversion);
+ xf86ErrorFVerb(2, "\tABI class: %s, version %d.%d\n",
+ data->abiclass, abimaj, abimin);
+ if (ver != -1) {
+ vermaj = GET_ABI_MAJOR(ver);
+ vermin = GET_ABI_MINOR(ver);
+ if (abimaj != vermaj) {
+ if (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL)
+ errtype = X_WARNING;
+ else
+ errtype = X_ERROR;
+ xf86MsgVerb(errtype, 0,
+ "module ABI major version (%d) doesn't"
+ " match the server's version (%d)\n",
+ abimaj, vermaj);
+ if (!(LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL))
+ return FALSE;
+ }
+ else if (abimin > vermin) {
+ if (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL)
+ errtype = X_WARNING;
+ else
+ errtype = X_ERROR;
+ xf86MsgVerb(errtype, 0,
+ "module ABI minor version (%d) is "
+ "newer than the server's version "
+ "(%d)\n", abimin, vermin);
+ if (!(LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL))
+ return FALSE;
+ }
+ }
}
/* Check against requirements that the caller has specified */
if (req) {
- if (req->majorversion != MAJOR_UNSPEC) {
- if (data->majorversion != req->majorversion) {
- xf86MsgVerb(X_WARNING, 2, "module major version (%d) "
- "doesn't match required major version (%d)\n",
- data->majorversion, req->majorversion);
- return FALSE;
- } else if (req->minorversion != MINOR_UNSPEC) {
- if (data->minorversion < req->minorversion) {
- xf86MsgVerb(X_WARNING, 2, "module minor version (%d) "
- "is less than the required minor version (%d)\n",
- data->minorversion, req->minorversion);
- return FALSE;
- } else if (data->minorversion == req->minorversion &&
- req->patchlevel != PATCH_UNSPEC) {
- if (data->patchlevel < req->patchlevel) {
- xf86MsgVerb(X_WARNING, 2, "module patch level (%d) "
- "is less than the required patch level (%d)\n",
- data->patchlevel, req->patchlevel);
- return FALSE;
- }
- }
- }
- }
- if (req->moduleclass) {
- if (!data->moduleclass ||
- strcmp(req->moduleclass, data->moduleclass)) {
- xf86MsgVerb(X_WARNING, 2, "Module class (%s) doesn't match "
- "the required class (%s)\n",
- data->moduleclass ? data->moduleclass : "<NONE>",
- req->moduleclass);
- return FALSE;
- }
- } else if (req->abiclass != ABI_CLASS_NONE) {
- if (!data->abiclass || strcmp(req->abiclass, data->abiclass)) {
- xf86MsgVerb(X_WARNING, 2, "ABI class (%s) doesn't match the "
- "required ABI class (%s)\n",
- data->abiclass ? data->abiclass : "<NONE>",
- req->abiclass);
- return FALSE;
- }
- }
- if ((req->abiclass != ABI_CLASS_NONE) &&
- req->abiversion != ABI_VERS_UNSPEC) {
- int reqmaj, reqmin, maj, min;
-
- reqmaj = GET_ABI_MAJOR(req->abiversion);
- reqmin = GET_ABI_MINOR(req->abiversion);
- maj = GET_ABI_MAJOR(data->abiversion);
- min = GET_ABI_MINOR(data->abiversion);
- if (maj != reqmaj) {
- xf86MsgVerb(X_WARNING, 2, "ABI major version (%d) doesn't "
- "match the required ABI major version (%d)\n",
- maj, reqmaj);
- return FALSE;
- }
- /* XXX Maybe this should be the other way around? */
- if (min > reqmin) {
- xf86MsgVerb(X_WARNING, 2, "module ABI minor version (%d) "
- "is newer than that available (%d)\n", min, reqmin);
- return FALSE;
- }
- }
+ if (req->majorversion != MAJOR_UNSPEC) {
+ if (data->majorversion != req->majorversion) {
+ xf86MsgVerb(X_WARNING, 2, "module major version (%d) "
+ "doesn't match required major version (%d)\n",
+ data->majorversion, req->majorversion);
+ return FALSE;
+ }
+ else if (req->minorversion != MINOR_UNSPEC) {
+ if (data->minorversion < req->minorversion) {
+ xf86MsgVerb(X_WARNING, 2, "module minor version (%d) "
+ "is less than the required minor version (%d)\n",
+ data->minorversion, req->minorversion);
+ return FALSE;
+ }
+ else if (data->minorversion == req->minorversion &&
+ req->patchlevel != PATCH_UNSPEC) {
+ if (data->patchlevel < req->patchlevel) {
+ xf86MsgVerb(X_WARNING, 2, "module patch level (%d) "
+ "is less than the required patch level (%d)\n",
+ data->patchlevel, req->patchlevel);
+ return FALSE;
+ }
+ }
+ }
+ }
+ if (req->moduleclass) {
+ if (!data->moduleclass ||
+ strcmp(req->moduleclass, data->moduleclass)) {
+ xf86MsgVerb(X_WARNING, 2, "Module class (%s) doesn't match "
+ "the required class (%s)\n",
+ data->moduleclass ? data->moduleclass : "<NONE>",
+ req->moduleclass);
+ return FALSE;
+ }
+ }
+ else if (req->abiclass != ABI_CLASS_NONE) {
+ if (!data->abiclass || strcmp(req->abiclass, data->abiclass)) {
+ xf86MsgVerb(X_WARNING, 2, "ABI class (%s) doesn't match the "
+ "required ABI class (%s)\n",
+ data->abiclass ? data->abiclass : "<NONE>",
+ req->abiclass);
+ return FALSE;
+ }
+ }
+ if ((req->abiclass != ABI_CLASS_NONE) &&
+ req->abiversion != ABI_VERS_UNSPEC) {
+ int reqmaj, reqmin, maj, min;
+
+ reqmaj = GET_ABI_MAJOR(req->abiversion);
+ reqmin = GET_ABI_MINOR(req->abiversion);
+ maj = GET_ABI_MAJOR(data->abiversion);
+ min = GET_ABI_MINOR(data->abiversion);
+ if (maj != reqmaj) {
+ xf86MsgVerb(X_WARNING, 2, "ABI major version (%d) doesn't "
+ "match the required ABI major version (%d)\n",
+ maj, reqmaj);
+ return FALSE;
+ }
+ /* XXX Maybe this should be the other way around? */
+ if (min > reqmin) {
+ xf86MsgVerb(X_WARNING, 2, "module ABI minor version (%d) "
+ "is newer than that available (%d)\n", min, reqmin);
+ return FALSE;
+ }
+ }
}
return TRUE;
}
@@ -738,31 +745,31 @@ AddSibling(ModuleDescPtr head, ModuleDescPtr new)
pointer
LoadSubModule(pointer _parent, const char *module,
- const char **subdirlist, const char **patternlist,
- pointer options, const XF86ModReqInfo * modreq,
- int *errmaj, int *errmin)
+ const char **subdirlist, const char **patternlist,
+ pointer options, const XF86ModReqInfo * modreq,
+ int *errmaj, int *errmin)
{
ModuleDescPtr submod;
- ModuleDescPtr parent = (ModuleDescPtr)_parent;
+ ModuleDescPtr parent = (ModuleDescPtr) _parent;
xf86MsgVerb(X_INFO, 3, "Loading sub module \"%s\"\n", module);
if (PathIsAbsolute(module)) {
- xf86Msg(X_ERROR,
- "LoadSubModule: Absolute module path not permitted: \"%s\"\n",
- module);
- if (errmaj)
- *errmaj = LDR_BADUSAGE;
- if (errmin)
- *errmin = 0;
- return NULL;
+ xf86Msg(X_ERROR,
+ "LoadSubModule: Absolute module path not permitted: \"%s\"\n",
+ module);
+ if (errmaj)
+ *errmaj = LDR_BADUSAGE;
+ if (errmin)
+ *errmin = 0;
+ return NULL;
}
submod = doLoadModule(module, NULL, subdirlist, patternlist, options,
- modreq, errmaj, errmin);
+ modreq, errmaj, errmin);
if (submod && submod != (ModuleDescPtr) 1) {
- parent->child = AddSibling(parent->child, submod);
- submod->parent = parent;
+ parent->child = AddSibling(parent->child, submod);
+ submod->parent = parent;
}
return submod;
}
@@ -773,7 +780,7 @@ NewModuleDesc(const char *name)
ModuleDescPtr mdp = calloc(1, sizeof(ModuleDesc));
if (mdp)
- mdp->name = xstrdup(name);
+ mdp->name = xstrdup(name);
return mdp;
}
@@ -784,11 +791,11 @@ DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent)
ModuleDescPtr ret;
if (!mod)
- return NULL;
+ return NULL;
ret = NewModuleDesc(mod->name);
if (ret == NULL)
- return NULL;
+ return NULL;
ret->handle = mod->handle;
@@ -813,9 +820,8 @@ static const char *compiled_in_modules[] = {
static ModuleDescPtr
doLoadModule(const char *module, const char *path, const char **subdirlist,
- const char **patternlist, pointer options,
- const XF86ModReqInfo * modreq,
- int *errmaj, int *errmin)
+ const char **patternlist, pointer options,
+ const XF86ModReqInfo * modreq, int *errmaj, int *errmin)
{
XF86ModuleData *initdata = NULL;
char **pathlist = NULL;
@@ -835,48 +841,48 @@ doLoadModule(const char *module, const char *path, const char **subdirlist,
name = LoaderGetCanonicalName(module, patterns);
noncanonical = (name && strcmp(module, name) != 0);
if (noncanonical) {
- xf86ErrorFVerb(3, " (%s)\n", name);
- xf86MsgVerb(X_WARNING, 1,
- "LoadModule: given non-canonical module name \"%s\"\n",
- module);
- m = name;
- } else {
- xf86ErrorFVerb(3, "\n");
- m = (char *)module;
+ xf86ErrorFVerb(3, " (%s)\n", name);
+ xf86MsgVerb(X_WARNING, 1,
+ "LoadModule: given non-canonical module name \"%s\"\n",
+ module);
+ m = name;
+ }
+ else {
+ xf86ErrorFVerb(3, "\n");
+ m = (char *) module;
}
for (cim = compiled_in_modules; *cim; cim++)
- if (!strcmp (m, *cim))
- {
- xf86MsgVerb(X_INFO, 3, "Module \"%s\" already built-in\n", m);
- ret = (ModuleDescPtr) 1;
- goto LoadModule_exit;
- }
+ if (!strcmp(m, *cim)) {
+ xf86MsgVerb(X_INFO, 3, "Module \"%s\" already built-in\n", m);
+ ret = (ModuleDescPtr) 1;
+ goto LoadModule_exit;
+ }
if (!name) {
- if (errmaj)
- *errmaj = LDR_BADUSAGE;
- if (errmin)
- *errmin = 0;
- goto LoadModule_fail;
+ if (errmaj)
+ *errmaj = LDR_BADUSAGE;
+ if (errmin)
+ *errmin = 0;
+ goto LoadModule_fail;
}
ret = NewModuleDesc(name);
if (!ret) {
- if (errmaj)
- *errmaj = LDR_NOMEM;
- if (errmin)
- *errmin = 0;
- goto LoadModule_fail;
+ if (errmaj)
+ *errmaj = LDR_NOMEM;
+ if (errmin)
+ *errmin = 0;
+ goto LoadModule_fail;
}
pathlist = InitPathList(path);
if (!pathlist) {
- /* This could be a malloc failure too */
- if (errmaj)
- *errmaj = LDR_BADUSAGE;
- if (errmin)
- *errmin = 1;
- goto LoadModule_fail;
+ /* This could be a malloc failure too */
+ if (errmaj)
+ *errmaj = LDR_BADUSAGE;
+ if (errmin)
+ *errmin = 1;
+ goto LoadModule_fail;
}
/*
@@ -884,35 +890,35 @@ doLoadModule(const char *module, const char *path, const char **subdirlist,
* check the elements in the path
*/
if (PathIsAbsolute(module))
- found = xstrdup(module);
+ found = xstrdup(module);
path_elem = pathlist;
while (!found && *path_elem != NULL) {
- found = FindModule(m, *path_elem, subdirlist, patterns);
- path_elem++;
- /*
- * When the module name isn't the canonical name, search for the
- * former if no match was found for the latter.
- */
- if (!*path_elem && m == name) {
- path_elem = pathlist;
- m = (char *)module;
- }
+ found = FindModule(m, *path_elem, subdirlist, patterns);
+ path_elem++;
+ /*
+ * When the module name isn't the canonical name, search for the
+ * former if no match was found for the latter.
+ */
+ if (!*path_elem && m == name) {
+ path_elem = pathlist;
+ m = (char *) module;
+ }
}
/*
* did we find the module?
*/
if (!found) {
- xf86Msg(X_WARNING, "Warning, couldn't open module %s\n", module);
- if (errmaj)
- *errmaj = LDR_NOENT;
- if (errmin)
- *errmin = 0;
- goto LoadModule_fail;
+ xf86Msg(X_WARNING, "Warning, couldn't open module %s\n", module);
+ if (errmaj)
+ *errmaj = LDR_NOENT;
+ if (errmin)
+ *errmin = 0;
+ goto LoadModule_fail;
}
ret->handle = LoaderOpen(found, errmaj, errmin);
if (ret->handle == NULL)
- goto LoadModule_fail;
+ goto LoadModule_fail;
ret->path = strdup(found);
/* drop any explicit suffix from the module name */
@@ -925,22 +931,22 @@ doLoadModule(const char *module, const char *path, const char **subdirlist,
* present.
*/
if (asprintf(&p, "%sModuleData", name) == -1) {
- p = NULL;
- if (errmaj)
- *errmaj = LDR_NOMEM;
- if (errmin)
- *errmin = 0;
- goto LoadModule_fail;
+ p = NULL;
+ if (errmaj)
+ *errmaj = LDR_NOMEM;
+ if (errmin)
+ *errmin = 0;
+ goto LoadModule_fail;
}
initdata = LoaderSymbol(p);
if (initdata) {
- ModuleSetupProc setup;
- ModuleTearDownProc teardown;
- XF86ModuleVersionInfo *vers;
+ ModuleSetupProc setup;
+ ModuleTearDownProc teardown;
+ XF86ModuleVersionInfo *vers;
- vers = initdata->vers;
- setup = initdata->setup;
- teardown = initdata->teardown;
+ vers = initdata->vers;
+ setup = initdata->setup;
+ teardown = initdata->teardown;
if (vers) {
if (!CheckVersion(module, vers, modreq)) {
@@ -950,7 +956,8 @@ doLoadModule(const char *module, const char *path, const char **subdirlist,
*errmin = 0;
goto LoadModule_fail;
}
- } else {
+ }
+ else {
xf86Msg(X_ERROR,
"LoadModule: Module %s does not supply"
" version information\n", module);
@@ -960,41 +967,43 @@ doLoadModule(const char *module, const char *path, const char **subdirlist,
*errmin = 0;
goto LoadModule_fail;
}
- if (setup)
- ret->SetupProc = setup;
- if (teardown)
- ret->TearDownProc = teardown;
- ret->VersionInfo = vers;
- } else {
- /* No initdata is OK for external modules */
- if (options == EXTERN_MODULE)
- goto LoadModule_exit;
-
- /* no initdata, fail the load */
- xf86Msg(X_ERROR, "LoadModule: Module %s does not have a %s "
- "data object.\n", module, p);
- if (errmaj)
- *errmaj = LDR_INVALID;
- if (errmin)
- *errmin = 0;
- goto LoadModule_fail;
+ if (setup)
+ ret->SetupProc = setup;
+ if (teardown)
+ ret->TearDownProc = teardown;
+ ret->VersionInfo = vers;
+ }
+ else {
+ /* No initdata is OK for external modules */
+ if (options == EXTERN_MODULE)
+ goto LoadModule_exit;
+
+ /* no initdata, fail the load */
+ xf86Msg(X_ERROR, "LoadModule: Module %s does not have a %s "
+ "data object.\n", module, p);
+ if (errmaj)
+ *errmaj = LDR_INVALID;
+ if (errmin)
+ *errmin = 0;
+ goto LoadModule_fail;
}
if (ret->SetupProc) {
- ret->TearDownData = ret->SetupProc(ret, options, errmaj, errmin);
- if (!ret->TearDownData) {
- goto LoadModule_fail;
- }
- } else if (options) {
- xf86Msg(X_WARNING, "Module Options present, but no SetupProc "
- "available for %s\n", module);
+ ret->TearDownData = ret->SetupProc(ret, options, errmaj, errmin);
+ if (!ret->TearDownData) {
+ goto LoadModule_fail;
+ }
+ }
+ else if (options) {
+ xf86Msg(X_WARNING, "Module Options present, but no SetupProc "
+ "available for %s\n", module);
}
goto LoadModule_exit;
- LoadModule_fail:
+ LoadModule_fail:
UnloadModule(ret);
ret = NULL;
- LoadModule_exit:
+ LoadModule_exit:
FreePathList(pathlist);
FreePatterns(patterns);
free(found);
@@ -1043,43 +1052,43 @@ doLoadModule(const char *module, const char *path, const char **subdirlist,
*/
ModuleDescPtr
LoadModule(const char *module, const char *path, const char **subdirlist,
- const char **patternlist, pointer options,
- const XF86ModReqInfo * modreq, int *errmaj, int *errmin)
+ const char **patternlist, pointer options,
+ const XF86ModReqInfo * modreq, int *errmaj, int *errmin)
{
- return doLoadModule(module, path, subdirlist, patternlist, options,
- modreq, errmaj, errmin);
+ return doLoadModule(module, path, subdirlist, patternlist, options,
+ modreq, errmaj, errmin);
}
void
UnloadModule(pointer mod)
{
- UnloadModuleOrDriver((ModuleDescPtr)mod);
+ UnloadModuleOrDriver((ModuleDescPtr) mod);
}
static void
UnloadModuleOrDriver(ModuleDescPtr mod)
{
if (mod == (ModuleDescPtr) 1)
- return;
+ return;
if (mod == NULL || mod->name == NULL)
- return;
+ return;
if (mod->parent)
- xf86MsgVerb(X_INFO, 3, "UnloadSubModule: \"%s\"\n", mod->name);
+ xf86MsgVerb(X_INFO, 3, "UnloadSubModule: \"%s\"\n", mod->name);
else
- xf86MsgVerb(X_INFO, 3, "UnloadModule: \"%s\"\n", mod->name);
+ xf86MsgVerb(X_INFO, 3, "UnloadModule: \"%s\"\n", mod->name);
if (mod->TearDownData != ModuleDuplicated) {
- if ((mod->TearDownProc) && (mod->TearDownData))
- mod->TearDownProc(mod->TearDownData);
- LoaderUnload(mod->name, mod->handle);
+ if ((mod->TearDownProc) && (mod->TearDownData))
+ mod->TearDownProc(mod->TearDownData);
+ LoaderUnload(mod->name, mod->handle);
}
if (mod->child)
- UnloadModuleOrDriver(mod->child);
+ UnloadModuleOrDriver(mod->child);
if (mod->sib)
- UnloadModuleOrDriver(mod->sib);
+ UnloadModuleOrDriver(mod->sib);
free(mod->path);
free(mod->name);
free(mod);
@@ -1088,11 +1097,11 @@ UnloadModuleOrDriver(ModuleDescPtr mod)
void
UnloadSubModule(pointer _mod)
{
- ModuleDescPtr mod = (ModuleDescPtr)_mod;
+ ModuleDescPtr mod = (ModuleDescPtr) _mod;
/* Some drivers are calling us on built-in submodules, ignore them */
- if (mod == (ModuleDescPtr)1)
- return;
+ if (mod == (ModuleDescPtr) 1)
+ return;
RemoveChild(mod);
UnloadModuleOrDriver(mod);
}
@@ -1105,22 +1114,22 @@ RemoveChild(ModuleDescPtr child)
ModuleDescPtr parent;
if (!child->parent)
- return;
+ return;
parent = child->parent;
if (parent->child == child) {
- parent->child = child->sib;
- return;
+ parent->child = child->sib;
+ return;
}
prevsib = parent->child;
mdp = prevsib->sib;
while (mdp && mdp != child) {
- prevsib = mdp;
- mdp = mdp->sib;
+ prevsib = mdp;
+ mdp = mdp->sib;
}
if (mdp == child)
- prevsib->sib = child->sib;
+ prevsib->sib = child->sib;
child->sib = NULL;
return;
}
@@ -1133,63 +1142,63 @@ LoaderErrorMsg(const char *name, const char *modname, int errmaj, int errmin)
switch (errmaj) {
case LDR_NOERROR:
- msg = "no error";
- break;
+ msg = "no error";
+ break;
case LDR_NOMEM:
- msg = "out of memory";
- break;
+ msg = "out of memory";
+ break;
case LDR_NOENT:
- msg = "module does not exist";
- break;
+ msg = "module does not exist";
+ break;
case LDR_NOSUBENT:
- msg = "a required submodule could not be loaded";
- break;
+ msg = "a required submodule could not be loaded";
+ break;
case LDR_NOSPACE:
- msg = "too many modules";
- break;
+ msg = "too many modules";
+ break;
case LDR_NOMODOPEN:
- msg = "open failed";
- break;
+ msg = "open failed";
+ break;
case LDR_UNKTYPE:
- msg = "unknown module type";
- break;
+ msg = "unknown module type";
+ break;
case LDR_NOLOAD:
- msg = "loader failed";
- break;
+ msg = "loader failed";
+ break;
case LDR_ONCEONLY:
- msg = "already loaded";
+ msg = "already loaded";
type = X_INFO;
- break;
+ break;
case LDR_NOPORTOPEN:
- msg = "port open failed";
- break;
+ msg = "port open failed";
+ break;
case LDR_NOHARDWARE:
- msg = "no hardware found";
- break;
+ msg = "no hardware found";
+ break;
case LDR_MISMATCH:
- msg = "module requirement mismatch";
- break;
+ msg = "module requirement mismatch";
+ break;
case LDR_BADUSAGE:
- msg = "invalid argument(s) to LoadModule()";
- break;
+ msg = "invalid argument(s) to LoadModule()";
+ break;
case LDR_INVALID:
- msg = "invalid module";
- break;
+ msg = "invalid module";
+ break;
case LDR_BADOS:
- msg = "module doesn't support this OS";
- break;
+ msg = "module doesn't support this OS";
+ break;
case LDR_MODSPECIFIC:
- msg = "module-specific error";
- break;
+ msg = "module-specific error";
+ break;
default:
- msg = "unknown error";
+ msg = "unknown error";
}
if (name)
- xf86Msg(type, "%s: Failed to load module \"%s\" (%s, %d)\n",
- name, modname, msg, errmin);
+ xf86Msg(type, "%s: Failed to load module \"%s\" (%s, %d)\n",
+ name, modname, msg, errmin);
else
- xf86Msg(type, "Failed to load module \"%s\" (%s, %d)\n",
- modname, msg, errmin);
+ xf86Msg(type, "Failed to load module \"%s\" (%s, %d)\n",
+ modname, msg, errmin);
}
/* Given a module path or file name, return the module's canonical name */
@@ -1205,21 +1214,21 @@ LoaderGetCanonicalName(const char *modname, PatternPtr patterns)
/* Strip off any leading path */
s = strrchr(modname, '/');
if (s == NULL)
- s = modname;
+ s = modname;
else
- s++;
+ s++;
/* Find the first regex that is matched */
for (p = patterns; p->pattern; p++)
- if (regexec(&p->rex, s, 2, match, 0) == 0 && match[1].rm_so != -1) {
- len = match[1].rm_eo - match[1].rm_so;
- str = malloc(len + 1);
- if (!str)
- return NULL;
- strncpy(str, s + match[1].rm_so, len);
- str[len] = '\0';
- return str;
- }
+ if (regexec(&p->rex, s, 2, match, 0) == 0 && match[1].rm_so != -1) {
+ len = match[1].rm_eo - match[1].rm_so;
+ str = malloc(len + 1);
+ if (!str)
+ return NULL;
+ strncpy(str, s + match[1].rm_so, len);
+ str[len] = '\0';
+ return str;
+ }
/* If there is no match, return the whole name minus the leading path */
return strdup(s);
@@ -1232,9 +1241,9 @@ unsigned long
LoaderGetModuleVersion(ModuleDescPtr mod)
{
if (!mod || mod == (ModuleDescPtr) 1 || !mod->VersionInfo)
- return 0;
+ return 0;
return MODULE_VERSION_NUMERIC(mod->VersionInfo->majorversion,
- mod->VersionInfo->minorversion,
- mod->VersionInfo->patchlevel);
+ mod->VersionInfo->minorversion,
+ mod->VersionInfo->patchlevel);
}
diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.c b/xorg-server/hw/xfree86/modes/xf86Crtc.c
index da9db3460..6d5e92f12 100644
--- a/xorg-server/hw/xfree86/modes/xf86Crtc.c
+++ b/xorg-server/hw/xfree86/modes/xf86Crtc.c
@@ -55,26 +55,24 @@
int xf86CrtcConfigPrivateIndex = -1;
void
-xf86CrtcConfigInit (ScrnInfoPtr scrn,
- const xf86CrtcConfigFuncsRec *funcs)
+xf86CrtcConfigInit(ScrnInfoPtr scrn, const xf86CrtcConfigFuncsRec * funcs)
{
- xf86CrtcConfigPtr config;
-
+ xf86CrtcConfigPtr config;
+
if (xf86CrtcConfigPrivateIndex == -1)
- xf86CrtcConfigPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
- config = xnfcalloc (1, sizeof (xf86CrtcConfigRec));
+ xf86CrtcConfigPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
+ config = xnfcalloc(1, sizeof(xf86CrtcConfigRec));
config->funcs = funcs;
scrn->privates[xf86CrtcConfigPrivateIndex].ptr = config;
}
-
+
void
-xf86CrtcSetSizeRange (ScrnInfoPtr scrn,
- int minWidth, int minHeight,
- int maxWidth, int maxHeight)
+xf86CrtcSetSizeRange(ScrnInfoPtr scrn,
+ int minWidth, int minHeight, int maxWidth, int maxHeight)
{
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
config->minWidth = minWidth;
config->minHeight = minHeight;
@@ -86,15 +84,14 @@ xf86CrtcSetSizeRange (ScrnInfoPtr scrn,
* Crtc functions
*/
xf86CrtcPtr
-xf86CrtcCreate (ScrnInfoPtr scrn,
- const xf86CrtcFuncsRec *funcs)
+xf86CrtcCreate(ScrnInfoPtr scrn, const xf86CrtcFuncsRec * funcs)
{
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- xf86CrtcPtr crtc, *crtcs;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86CrtcPtr crtc, *crtcs;
- crtc = calloc(sizeof (xf86CrtcRec), 1);
+ crtc = calloc(sizeof(xf86CrtcRec), 1);
if (!crtc)
- return NULL;
+ return NULL;
crtc->version = XF86_CRTC_VERSION;
crtc->scrn = scrn;
crtc->funcs = funcs;
@@ -103,9 +100,9 @@ xf86CrtcCreate (ScrnInfoPtr scrn,
#endif
crtc->rotation = RR_Rotate_0;
crtc->desiredRotation = RR_Rotate_0;
- pixman_transform_init_identity (&crtc->crtc_to_framebuffer);
- pixman_f_transform_init_identity (&crtc->f_crtc_to_framebuffer);
- pixman_f_transform_init_identity (&crtc->f_framebuffer_to_crtc);
+ pixman_transform_init_identity(&crtc->crtc_to_framebuffer);
+ pixman_f_transform_init_identity(&crtc->f_crtc_to_framebuffer);
+ pixman_f_transform_init_identity(&crtc->f_framebuffer_to_crtc);
crtc->filter = NULL;
crtc->params = NULL;
crtc->nparams = 0;
@@ -114,28 +111,27 @@ xf86CrtcCreate (ScrnInfoPtr scrn,
crtc->transform_in_use = FALSE;
crtc->transformPresent = FALSE;
crtc->desiredTransformPresent = FALSE;
- memset (&crtc->bounds, '\0', sizeof (crtc->bounds));
+ memset(&crtc->bounds, '\0', sizeof(crtc->bounds));
/* Preallocate gamma at a sensible size. */
crtc->gamma_size = 256;
- crtc->gamma_red = malloc(3 * crtc->gamma_size * sizeof (CARD16));
+ crtc->gamma_red = malloc(3 * crtc->gamma_size * sizeof(CARD16));
if (!crtc->gamma_red) {
- free(crtc);
- return NULL;
+ free(crtc);
+ return NULL;
}
crtc->gamma_green = crtc->gamma_red + crtc->gamma_size;
crtc->gamma_blue = crtc->gamma_green + crtc->gamma_size;
if (xf86_config->crtc)
- crtcs = realloc(xf86_config->crtc,
- (xf86_config->num_crtc + 1) * sizeof (xf86CrtcPtr));
+ crtcs = realloc(xf86_config->crtc,
+ (xf86_config->num_crtc + 1) * sizeof(xf86CrtcPtr));
else
- crtcs = malloc((xf86_config->num_crtc + 1) * sizeof (xf86CrtcPtr));
- if (!crtcs)
- {
- free(crtc->gamma_red);
- free(crtc);
- return NULL;
+ crtcs = malloc((xf86_config->num_crtc + 1) * sizeof(xf86CrtcPtr));
+ if (!crtcs) {
+ free(crtc->gamma_red);
+ free(crtc);
+ return NULL;
}
xf86_config->crtc = crtcs;
xf86_config->crtc[xf86_config->num_crtc++] = crtc;
@@ -143,146 +139,140 @@ xf86CrtcCreate (ScrnInfoPtr scrn,
}
void
-xf86CrtcDestroy (xf86CrtcPtr crtc)
+xf86CrtcDestroy(xf86CrtcPtr crtc)
{
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
- int c;
-
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
+ int c;
+
(*crtc->funcs->destroy) (crtc);
for (c = 0; c < xf86_config->num_crtc; c++)
- if (xf86_config->crtc[c] == crtc)
- {
- memmove (&xf86_config->crtc[c],
- &xf86_config->crtc[c+1],
- ((xf86_config->num_crtc - (c + 1)) * sizeof(void*)));
- xf86_config->num_crtc--;
- break;
- }
+ if (xf86_config->crtc[c] == crtc) {
+ memmove(&xf86_config->crtc[c],
+ &xf86_config->crtc[c + 1],
+ ((xf86_config->num_crtc - (c + 1)) * sizeof(void *)));
+ xf86_config->num_crtc--;
+ break;
+ }
free(crtc->params);
free(crtc->gamma_red);
free(crtc);
}
-
/**
* Return whether any outputs are connected to the specified pipe
*/
Bool
-xf86CrtcInUse (xf86CrtcPtr crtc)
+xf86CrtcInUse(xf86CrtcPtr crtc)
{
- ScrnInfoPtr pScrn = crtc->scrn;
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
- int o;
-
+ ScrnInfoPtr pScrn = crtc->scrn;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int o;
+
for (o = 0; o < xf86_config->num_output; o++)
- if (xf86_config->output[o]->crtc == crtc)
- return TRUE;
+ if (xf86_config->output[o]->crtc == crtc)
+ return TRUE;
return FALSE;
}
void
-xf86CrtcSetScreenSubpixelOrder (ScreenPtr pScreen)
+xf86CrtcSetScreenSubpixelOrder(ScreenPtr pScreen)
{
- int subpixel_order = SubPixelUnknown;
- Bool has_none = FALSE;
- ScrnInfoPtr scrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- int c, o;
+ int subpixel_order = SubPixelUnknown;
+ Bool has_none = FALSE;
+ ScrnInfoPtr scrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ int c, o;
- for (c = 0; c < xf86_config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = xf86_config->crtc[c];
-
- for (o = 0; o < xf86_config->num_output; o++)
- {
- xf86OutputPtr output = xf86_config->output[o];
-
- if (output->crtc == crtc)
- {
- switch (output->subpixel_order) {
- case SubPixelNone:
- has_none = TRUE;
- break;
- case SubPixelUnknown:
- break;
- default:
- subpixel_order = output->subpixel_order;
- break;
- }
- }
- if (subpixel_order != SubPixelUnknown)
- break;
- }
- if (subpixel_order != SubPixelUnknown)
- {
- static const int circle[4] = {
- SubPixelHorizontalRGB,
- SubPixelVerticalRGB,
- SubPixelHorizontalBGR,
- SubPixelVerticalBGR,
- };
- int rotate;
- int c;
- for (rotate = 0; rotate < 4; rotate++)
- if (crtc->rotation & (1 << rotate))
- break;
- for (c = 0; c < 4; c++)
- if (circle[c] == subpixel_order)
- break;
- c = (c + rotate) & 0x3;
- if ((crtc->rotation & RR_Reflect_X) && !(c & 1))
- c ^= 2;
- if ((crtc->rotation & RR_Reflect_Y) && (c & 1))
- c ^= 2;
- subpixel_order = circle[c];
- break;
- }
+ for (c = 0; c < xf86_config->num_crtc; c++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+ for (o = 0; o < xf86_config->num_output; o++) {
+ xf86OutputPtr output = xf86_config->output[o];
+
+ if (output->crtc == crtc) {
+ switch (output->subpixel_order) {
+ case SubPixelNone:
+ has_none = TRUE;
+ break;
+ case SubPixelUnknown:
+ break;
+ default:
+ subpixel_order = output->subpixel_order;
+ break;
+ }
+ }
+ if (subpixel_order != SubPixelUnknown)
+ break;
+ }
+ if (subpixel_order != SubPixelUnknown) {
+ static const int circle[4] = {
+ SubPixelHorizontalRGB,
+ SubPixelVerticalRGB,
+ SubPixelHorizontalBGR,
+ SubPixelVerticalBGR,
+ };
+ int rotate;
+ int c;
+
+ for (rotate = 0; rotate < 4; rotate++)
+ if (crtc->rotation & (1 << rotate))
+ break;
+ for (c = 0; c < 4; c++)
+ if (circle[c] == subpixel_order)
+ break;
+ c = (c + rotate) & 0x3;
+ if ((crtc->rotation & RR_Reflect_X) && !(c & 1))
+ c ^= 2;
+ if ((crtc->rotation & RR_Reflect_Y) && (c & 1))
+ c ^= 2;
+ subpixel_order = circle[c];
+ break;
+ }
}
if (subpixel_order == SubPixelUnknown && has_none)
- subpixel_order = SubPixelNone;
- PictureSetSubpixelOrder (pScreen, subpixel_order);
+ subpixel_order = SubPixelNone;
+ PictureSetSubpixelOrder(pScreen, subpixel_order);
}
/**
* Sets the given video mode on the given crtc
*/
Bool
-xf86CrtcSetModeTransform (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
- RRTransformPtr transform, int x, int y)
-{
- ScrnInfoPtr scrn = crtc->scrn;
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- int i;
- Bool ret = FALSE;
- Bool didLock = FALSE;
- DisplayModePtr adjusted_mode;
- DisplayModeRec saved_mode;
- int saved_x, saved_y;
- Rotation saved_rotation;
- RRTransformRec saved_transform;
- Bool saved_transform_present;
-
- crtc->enabled = xf86CrtcInUse (crtc);
+xf86CrtcSetModeTransform(xf86CrtcPtr crtc, DisplayModePtr mode,
+ Rotation rotation, RRTransformPtr transform, int x,
+ int y)
+{
+ ScrnInfoPtr scrn = crtc->scrn;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ int i;
+ Bool ret = FALSE;
+ Bool didLock = FALSE;
+ DisplayModePtr adjusted_mode;
+ DisplayModeRec saved_mode;
+ int saved_x, saved_y;
+ Rotation saved_rotation;
+ RRTransformRec saved_transform;
+ Bool saved_transform_present;
+
+ crtc->enabled = xf86CrtcInUse(crtc);
/* We only hit this if someone explicitly sends a "disabled" modeset. */
- if (!crtc->enabled)
- {
- /* Check everything for stuff that should be off. */
- xf86DisableUnusedFunctions(scrn);
- return TRUE;
+ if (!crtc->enabled) {
+ /* Check everything for stuff that should be off. */
+ xf86DisableUnusedFunctions(scrn);
+ return TRUE;
}
adjusted_mode = xf86DuplicateMode(mode);
-
saved_mode = crtc->mode;
saved_x = crtc->x;
saved_y = crtc->y;
saved_rotation = crtc->rotation;
if (crtc->transformPresent) {
- RRTransformInit (&saved_transform);
- RRTransformCopy (&saved_transform, &crtc->transform);
+ RRTransformInit(&saved_transform);
+ RRTransformCopy(&saved_transform, &crtc->transform);
}
saved_transform_present = crtc->transformPresent;
@@ -294,48 +284,49 @@ xf86CrtcSetModeTransform (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotati
crtc->y = y;
crtc->rotation = rotation;
if (transform) {
- RRTransformCopy (&crtc->transform, transform);
- crtc->transformPresent = TRUE;
- } else
- crtc->transformPresent = FALSE;
+ RRTransformCopy(&crtc->transform, transform);
+ crtc->transformPresent = TRUE;
+ }
+ else
+ crtc->transformPresent = FALSE;
if (crtc->funcs->set_mode_major) {
- ret = crtc->funcs->set_mode_major(crtc, mode, rotation, x, y);
- goto done;
+ ret = crtc->funcs->set_mode_major(crtc, mode, rotation, x, y);
+ goto done;
}
- didLock = crtc->funcs->lock (crtc);
+ didLock = crtc->funcs->lock(crtc);
/* Pass our mode to the outputs and the CRTC to give them a chance to
* adjust it according to limitations or output properties, and also
* a chance to reject the mode entirely.
*/
for (i = 0; i < xf86_config->num_output; i++) {
- xf86OutputPtr output = xf86_config->output[i];
+ xf86OutputPtr output = xf86_config->output[i];
- if (output->crtc != crtc)
- continue;
+ if (output->crtc != crtc)
+ continue;
- if (!output->funcs->mode_fixup(output, mode, adjusted_mode)) {
- goto done;
- }
+ if (!output->funcs->mode_fixup(output, mode, adjusted_mode)) {
+ goto done;
+ }
}
if (!crtc->funcs->mode_fixup(crtc, mode, adjusted_mode)) {
- goto done;
+ goto done;
}
- if (!xf86CrtcRotate (crtc))
- goto done;
+ if (!xf86CrtcRotate(crtc))
+ goto done;
/* Prepare the outputs and CRTCs before setting the mode. */
for (i = 0; i < xf86_config->num_output; i++) {
- xf86OutputPtr output = xf86_config->output[i];
+ xf86OutputPtr output = xf86_config->output[i];
- if (output->crtc != crtc)
- continue;
+ if (output->crtc != crtc)
+ continue;
- /* Disable the output as the first thing we do. */
- output->funcs->prepare(output);
+ /* Disable the output as the first thing we do. */
+ output->funcs->prepare(output);
}
crtc->funcs->prepare(crtc);
@@ -344,51 +335,52 @@ xf86CrtcSetModeTransform (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotati
* on the DPLL.
*/
crtc->funcs->mode_set(crtc, mode, adjusted_mode, crtc->x, crtc->y);
- for (i = 0; i < xf86_config->num_output; i++)
- {
- xf86OutputPtr output = xf86_config->output[i];
- if (output->crtc == crtc)
- output->funcs->mode_set(output, mode, adjusted_mode);
+ for (i = 0; i < xf86_config->num_output; i++) {
+ xf86OutputPtr output = xf86_config->output[i];
+
+ if (output->crtc == crtc)
+ output->funcs->mode_set(output, mode, adjusted_mode);
}
/* Only upload when needed, to avoid unneeded delays. */
if (!crtc->active && crtc->funcs->gamma_set)
- crtc->funcs->gamma_set(crtc, crtc->gamma_red, crtc->gamma_green,
- crtc->gamma_blue, crtc->gamma_size);
+ crtc->funcs->gamma_set(crtc, crtc->gamma_red, crtc->gamma_green,
+ crtc->gamma_blue, crtc->gamma_size);
/* Now, enable the clocks, plane, pipe, and outputs that we set up. */
crtc->funcs->commit(crtc);
- for (i = 0; i < xf86_config->num_output; i++)
- {
- xf86OutputPtr output = xf86_config->output[i];
- if (output->crtc == crtc)
- output->funcs->commit(output);
+ for (i = 0; i < xf86_config->num_output; i++) {
+ xf86OutputPtr output = xf86_config->output[i];
+
+ if (output->crtc == crtc)
+ output->funcs->commit(output);
}
ret = TRUE;
-done:
+ done:
if (ret) {
- crtc->active = TRUE;
- if (scrn->pScreen)
- xf86CrtcSetScreenSubpixelOrder (scrn->pScreen);
- if (scrn->ModeSet)
- scrn->ModeSet(scrn);
- } else {
- crtc->x = saved_x;
- crtc->y = saved_y;
- crtc->rotation = saved_rotation;
- crtc->mode = saved_mode;
- if (saved_transform_present)
- RRTransformCopy (&crtc->transform, &saved_transform);
- crtc->transformPresent = saved_transform_present;
+ crtc->active = TRUE;
+ if (scrn->pScreen)
+ xf86CrtcSetScreenSubpixelOrder(scrn->pScreen);
+ if (scrn->ModeSet)
+ scrn->ModeSet(scrn);
+ }
+ else {
+ crtc->x = saved_x;
+ crtc->y = saved_y;
+ crtc->rotation = saved_rotation;
+ crtc->mode = saved_mode;
+ if (saved_transform_present)
+ RRTransformCopy(&crtc->transform, &saved_transform);
+ crtc->transformPresent = saved_transform_present;
}
free(adjusted_mode->name);
free(adjusted_mode);
if (didLock)
- crtc->funcs->unlock (crtc);
+ crtc->funcs->unlock(crtc);
return ret;
}
@@ -398,31 +390,31 @@ done:
* a transform
*/
Bool
-xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
- int x, int y)
+xf86CrtcSetMode(xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
+ int x, int y)
{
- return xf86CrtcSetModeTransform (crtc, mode, rotation, NULL, x, y);
+ return xf86CrtcSetModeTransform(crtc, mode, rotation, NULL, x, y);
}
/**
* Pans the screen, does not change the mode
*/
void
-xf86CrtcSetOrigin (xf86CrtcPtr crtc, int x, int y)
+xf86CrtcSetOrigin(xf86CrtcPtr crtc, int x, int y)
{
ScrnInfoPtr scrn = crtc->scrn;
crtc->x = x;
crtc->y = y;
if (crtc->funcs->set_origin) {
- if (!xf86CrtcRotate (crtc))
- return;
- crtc->funcs->set_origin (crtc, x, y);
- if (scrn->ModeSet)
- scrn->ModeSet(scrn);
+ if (!xf86CrtcRotate(crtc))
+ return;
+ crtc->funcs->set_origin(crtc, x, y);
+ if (scrn->ModeSet)
+ scrn->ModeSet(scrn);
}
else
- xf86CrtcSetMode (crtc, &crtc->mode, crtc->rotation, x, y);
+ xf86CrtcSetMode(crtc, &crtc->mode, crtc->rotation, x, y);
}
/*
@@ -450,22 +442,22 @@ typedef enum {
} OutputOpts;
static OptionInfoRec xf86OutputOptions[] = {
- {OPTION_PREFERRED_MODE, "PreferredMode", OPTV_STRING, {0}, FALSE },
- {OPTION_POSITION, "Position", OPTV_STRING, {0}, FALSE },
- {OPTION_BELOW, "Below", OPTV_STRING, {0}, FALSE },
- {OPTION_RIGHT_OF, "RightOf", OPTV_STRING, {0}, FALSE },
- {OPTION_ABOVE, "Above", OPTV_STRING, {0}, FALSE },
- {OPTION_LEFT_OF, "LeftOf", OPTV_STRING, {0}, FALSE },
- {OPTION_ENABLE, "Enable", OPTV_BOOLEAN, {0}, FALSE },
- {OPTION_DISABLE, "Disable", OPTV_BOOLEAN, {0}, FALSE },
- {OPTION_MIN_CLOCK, "MinClock", OPTV_FREQ, {0}, FALSE },
- {OPTION_MAX_CLOCK, "MaxClock", OPTV_FREQ, {0}, FALSE },
- {OPTION_IGNORE, "Ignore", OPTV_BOOLEAN, {0}, FALSE },
- {OPTION_ROTATE, "Rotate", OPTV_STRING, {0}, FALSE },
- {OPTION_PANNING, "Panning", OPTV_STRING, {0}, FALSE },
- {OPTION_PRIMARY, "Primary", OPTV_BOOLEAN, {0}, FALSE },
- {OPTION_DEFAULT_MODES, "DefaultModes", OPTV_BOOLEAN, {0}, FALSE },
- {-1, NULL, OPTV_NONE, {0}, FALSE },
+ {OPTION_PREFERRED_MODE, "PreferredMode", OPTV_STRING, {0}, FALSE},
+ {OPTION_POSITION, "Position", OPTV_STRING, {0}, FALSE},
+ {OPTION_BELOW, "Below", OPTV_STRING, {0}, FALSE},
+ {OPTION_RIGHT_OF, "RightOf", OPTV_STRING, {0}, FALSE},
+ {OPTION_ABOVE, "Above", OPTV_STRING, {0}, FALSE},
+ {OPTION_LEFT_OF, "LeftOf", OPTV_STRING, {0}, FALSE},
+ {OPTION_ENABLE, "Enable", OPTV_BOOLEAN, {0}, FALSE},
+ {OPTION_DISABLE, "Disable", OPTV_BOOLEAN, {0}, FALSE},
+ {OPTION_MIN_CLOCK, "MinClock", OPTV_FREQ, {0}, FALSE},
+ {OPTION_MAX_CLOCK, "MaxClock", OPTV_FREQ, {0}, FALSE},
+ {OPTION_IGNORE, "Ignore", OPTV_BOOLEAN, {0}, FALSE},
+ {OPTION_ROTATE, "Rotate", OPTV_STRING, {0}, FALSE},
+ {OPTION_PANNING, "Panning", OPTV_STRING, {0}, FALSE},
+ {OPTION_PRIMARY, "Primary", OPTV_BOOLEAN, {0}, FALSE},
+ {OPTION_DEFAULT_MODES, "DefaultModes", OPTV_BOOLEAN, {0}, FALSE},
+ {-1, NULL, OPTV_NONE, {0}, FALSE},
};
enum {
@@ -473,144 +465,138 @@ enum {
};
static OptionInfoRec xf86DeviceOptions[] = {
- {OPTION_MODEDEBUG, "ModeDebug", OPTV_BOOLEAN, {0}, FALSE },
- {-1, NULL, OPTV_NONE, {0}, FALSE },
+ {OPTION_MODEDEBUG, "ModeDebug", OPTV_BOOLEAN, {0}, FALSE},
+ {-1, NULL, OPTV_NONE, {0}, FALSE},
};
static void
-xf86OutputSetMonitor (xf86OutputPtr output)
+xf86OutputSetMonitor(xf86OutputPtr output)
{
- char *option_name;
- const char *monitor;
+ char *option_name;
+ const char *monitor;
if (!output->name)
- return;
+ return;
free(output->options);
- output->options = xnfalloc (sizeof (xf86OutputOptions));
- memcpy (output->options, xf86OutputOptions, sizeof (xf86OutputOptions));
+ output->options = xnfalloc(sizeof(xf86OutputOptions));
+ memcpy(output->options, xf86OutputOptions, sizeof(xf86OutputOptions));
XNFasprintf(&option_name, "monitor-%s", output->name);
- monitor = xf86findOptionValue (output->scrn->options, option_name);
+ monitor = xf86findOptionValue(output->scrn->options, option_name);
if (!monitor)
- monitor = output->name;
+ monitor = output->name;
else
- xf86MarkOptionUsedByName (output->scrn->options, option_name);
+ xf86MarkOptionUsedByName(output->scrn->options, option_name);
free(option_name);
- output->conf_monitor = xf86findMonitor (monitor,
- xf86configptr->conf_monitor_lst);
+ output->conf_monitor = xf86findMonitor(monitor,
+ xf86configptr->conf_monitor_lst);
/*
* Find the monitor section of the screen and use that
*/
if (!output->conf_monitor && output->use_screen_monitor)
- output->conf_monitor = xf86findMonitor (output->scrn->monitor->id,
- xf86configptr->conf_monitor_lst);
- if (output->conf_monitor)
- {
- xf86DrvMsg (output->scrn->scrnIndex, X_INFO,
- "Output %s using monitor section %s\n",
- output->name, output->conf_monitor->mon_identifier);
- xf86ProcessOptions (output->scrn->scrnIndex,
- output->conf_monitor->mon_option_lst,
- output->options);
+ output->conf_monitor = xf86findMonitor(output->scrn->monitor->id,
+ xf86configptr->conf_monitor_lst);
+ if (output->conf_monitor) {
+ xf86DrvMsg(output->scrn->scrnIndex, X_INFO,
+ "Output %s using monitor section %s\n",
+ output->name, output->conf_monitor->mon_identifier);
+ xf86ProcessOptions(output->scrn->scrnIndex,
+ output->conf_monitor->mon_option_lst,
+ output->options);
}
else
- xf86DrvMsg (output->scrn->scrnIndex, X_INFO,
- "Output %s has no monitor section\n",
- output->name);
+ xf86DrvMsg(output->scrn->scrnIndex, X_INFO,
+ "Output %s has no monitor section\n", output->name);
}
static Bool
-xf86OutputEnabled (xf86OutputPtr output, Bool strict)
+xf86OutputEnabled(xf86OutputPtr output, Bool strict)
{
- Bool enable, disable;
+ Bool enable, disable;
/* check to see if this output was enabled in the config file */
- if (xf86GetOptValBool (output->options, OPTION_ENABLE, &enable) && enable)
- {
- xf86DrvMsg (output->scrn->scrnIndex, X_INFO,
- "Output %s enabled by config file\n", output->name);
- return TRUE;
+ if (xf86GetOptValBool(output->options, OPTION_ENABLE, &enable) && enable) {
+ xf86DrvMsg(output->scrn->scrnIndex, X_INFO,
+ "Output %s enabled by config file\n", output->name);
+ return TRUE;
}
/* or if this output was disabled in the config file */
- if (xf86GetOptValBool (output->options, OPTION_DISABLE, &disable) && disable)
- {
- xf86DrvMsg (output->scrn->scrnIndex, X_INFO,
- "Output %s disabled by config file\n", output->name);
- return FALSE;
+ if (xf86GetOptValBool(output->options, OPTION_DISABLE, &disable) && disable) {
+ xf86DrvMsg(output->scrn->scrnIndex, X_INFO,
+ "Output %s disabled by config file\n", output->name);
+ return FALSE;
}
/* If not, try to only light up the ones we know are connected */
if (strict) {
- enable = output->status == XF86OutputStatusConnected;
+ enable = output->status == XF86OutputStatusConnected;
}
/* But if that fails, try to light up even outputs we're unsure of */
else {
- enable = output->status != XF86OutputStatusDisconnected;
+ enable = output->status != XF86OutputStatusDisconnected;
}
- xf86DrvMsg (output->scrn->scrnIndex, X_INFO,
- "Output %s %sconnected\n", output->name, enable ? "" : "dis");
+ xf86DrvMsg(output->scrn->scrnIndex, X_INFO,
+ "Output %s %sconnected\n", output->name, enable ? "" : "dis");
return enable;
}
static Bool
-xf86OutputIgnored (xf86OutputPtr output)
+xf86OutputIgnored(xf86OutputPtr output)
{
- return xf86ReturnOptValBool (output->options, OPTION_IGNORE, FALSE);
+ return xf86ReturnOptValBool(output->options, OPTION_IGNORE, FALSE);
}
static const char *direction[4] = {
- "normal",
- "left",
- "inverted",
+ "normal",
+ "left",
+ "inverted",
"right"
};
static Rotation
-xf86OutputInitialRotation (xf86OutputPtr output)
+xf86OutputInitialRotation(xf86OutputPtr output)
{
- char *rotate_name = xf86GetOptValString (output->options,
- OPTION_ROTATE);
- int i;
+ char *rotate_name = xf86GetOptValString(output->options,
+ OPTION_ROTATE);
+ int i;
if (!rotate_name) {
- if (output->initial_rotation)
- return output->initial_rotation;
- return RR_Rotate_0;
+ if (output->initial_rotation)
+ return output->initial_rotation;
+ return RR_Rotate_0;
}
-
+
for (i = 0; i < 4; i++)
- if (xf86nameCompare (direction[i], rotate_name) == 0)
- return 1 << i;
+ if (xf86nameCompare(direction[i], rotate_name) == 0)
+ return 1 << i;
return RR_Rotate_0;
}
xf86OutputPtr
-xf86OutputCreate (ScrnInfoPtr scrn,
- const xf86OutputFuncsRec *funcs,
- const char *name)
+xf86OutputCreate(ScrnInfoPtr scrn,
+ const xf86OutputFuncsRec * funcs, const char *name)
{
- xf86OutputPtr output, *outputs;
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- int len;
- Bool primary;
+ xf86OutputPtr output, *outputs;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ int len;
+ Bool primary;
if (name)
- len = strlen (name) + 1;
+ len = strlen(name) + 1;
else
- len = 0;
+ len = 0;
- output = calloc(sizeof (xf86OutputRec) + len, 1);
+ output = calloc(sizeof(xf86OutputRec) + len, 1);
if (!output)
- return NULL;
+ return NULL;
output->scrn = scrn;
output->funcs = funcs;
- if (name)
- {
- output->name = (char *) (output + 1);
- strcpy (output->name, name);
+ if (name) {
+ output->name = (char *) (output + 1);
+ strcpy(output->name, name);
}
output->subpixel_order = SubPixelUnknown;
/*
@@ -620,39 +606,34 @@ xf86OutputCreate (ScrnInfoPtr scrn,
#ifdef RANDR_12_INTERFACE
output->randr_output = NULL;
#endif
- if (name)
- {
- xf86OutputSetMonitor (output);
- if (xf86OutputIgnored (output))
- {
- free(output);
- return FALSE;
- }
- }
-
-
+ if (name) {
+ xf86OutputSetMonitor(output);
+ if (xf86OutputIgnored(output)) {
+ free(output);
+ return FALSE;
+ }
+ }
+
if (xf86_config->output)
- outputs = realloc(xf86_config->output,
- (xf86_config->num_output + 1) * sizeof (xf86OutputPtr));
+ outputs = realloc(xf86_config->output,
+ (xf86_config->num_output +
+ 1) * sizeof(xf86OutputPtr));
else
- outputs = malloc((xf86_config->num_output + 1) * sizeof (xf86OutputPtr));
- if (!outputs)
- {
- free(output);
- return NULL;
+ outputs = malloc((xf86_config->num_output + 1) * sizeof(xf86OutputPtr));
+ if (!outputs) {
+ free(output);
+ return NULL;
}
xf86_config->output = outputs;
- if (xf86GetOptValBool (output->options, OPTION_PRIMARY, &primary) && primary)
- {
- memmove(xf86_config->output + 1, xf86_config->output,
- xf86_config->num_output * sizeof (xf86OutputPtr));
- xf86_config->output[0] = output;
+ if (xf86GetOptValBool(output->options, OPTION_PRIMARY, &primary) && primary) {
+ memmove(xf86_config->output + 1, xf86_config->output,
+ xf86_config->num_output * sizeof(xf86OutputPtr));
+ xf86_config->output[0] = output;
}
- else
- {
- xf86_config->output[xf86_config->num_output] = output;
+ else {
+ xf86_config->output[xf86_config->num_output] = output;
}
xf86_config->num_output++;
@@ -661,53 +642,51 @@ xf86OutputCreate (ScrnInfoPtr scrn,
}
Bool
-xf86OutputRename (xf86OutputPtr output, const char *name)
+xf86OutputRename(xf86OutputPtr output, const char *name)
{
- char *newname = strdup(name);
-
+ char *newname = strdup(name);
+
if (!newname)
- return FALSE; /* so sorry... */
-
+ return FALSE; /* so sorry... */
+
if (output->name && output->name != (char *) (output + 1))
- free(output->name);
+ free(output->name);
output->name = newname;
- xf86OutputSetMonitor (output);
- if (xf86OutputIgnored (output))
- return FALSE;
+ xf86OutputSetMonitor(output);
+ if (xf86OutputIgnored(output))
+ return FALSE;
return TRUE;
}
void
-xf86OutputUseScreenMonitor (xf86OutputPtr output, Bool use_screen_monitor)
+xf86OutputUseScreenMonitor(xf86OutputPtr output, Bool use_screen_monitor)
{
- if (use_screen_monitor != output->use_screen_monitor)
- {
- output->use_screen_monitor = use_screen_monitor;
- xf86OutputSetMonitor (output);
+ if (use_screen_monitor != output->use_screen_monitor) {
+ output->use_screen_monitor = use_screen_monitor;
+ xf86OutputSetMonitor(output);
}
}
void
-xf86OutputDestroy (xf86OutputPtr output)
+xf86OutputDestroy(xf86OutputPtr output)
{
- ScrnInfoPtr scrn = output->scrn;
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- int o;
-
+ ScrnInfoPtr scrn = output->scrn;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ int o;
+
(*output->funcs->destroy) (output);
while (output->probed_modes)
- xf86DeleteMode (&output->probed_modes, output->probed_modes);
+ xf86DeleteMode(&output->probed_modes, output->probed_modes);
for (o = 0; o < xf86_config->num_output; o++)
- if (xf86_config->output[o] == output)
- {
- memmove (&xf86_config->output[o],
- &xf86_config->output[o+1],
- ((xf86_config->num_output - (o + 1)) * sizeof(void*)));
- xf86_config->num_output--;
- break;
- }
+ if (xf86_config->output[o] == output) {
+ memmove(&xf86_config->output[o],
+ &xf86_config->output[o + 1],
+ ((xf86_config->num_output - (o + 1)) * sizeof(void *)));
+ xf86_config->num_output--;
+ break;
+ }
if (output->name && output->name != (char *) (output + 1))
- free(output->name);
+ free(output->name);
free(output);
}
@@ -715,18 +694,18 @@ xf86OutputDestroy (xf86OutputPtr output)
* Called during CreateScreenResources to hook up RandR
*/
static Bool
-xf86CrtcCreateScreenResources (ScreenPtr screen)
+xf86CrtcCreateScreenResources(ScreenPtr screen)
{
- ScrnInfoPtr scrn = xf86Screens[screen->myNum];
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
screen->CreateScreenResources = config->CreateScreenResources;
-
- if (!(*screen->CreateScreenResources)(screen))
- return FALSE;
- if (!xf86RandR12CreateScreenResources (screen))
- return FALSE;
+ if (!(*screen->CreateScreenResources) (screen))
+ return FALSE;
+
+ if (!xf86RandR12CreateScreenResources(screen))
+ return FALSE;
return TRUE;
}
@@ -735,31 +714,29 @@ xf86CrtcCreateScreenResources (ScreenPtr screen)
* Clean up config on server reset
*/
static Bool
-xf86CrtcCloseScreen (int index, ScreenPtr screen)
+xf86CrtcCloseScreen(int index, ScreenPtr screen)
{
- ScrnInfoPtr scrn = xf86Screens[screen->myNum];
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
- int o, c;
-
+ ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ int o, c;
+
screen->CloseScreen = config->CloseScreen;
- xf86RotateCloseScreen (screen);
+ xf86RotateCloseScreen(screen);
- for (o = 0; o < config->num_output; o++)
- {
- xf86OutputPtr output = config->output[o];
+ for (o = 0; o < config->num_output; o++) {
+ xf86OutputPtr output = config->output[o];
- output->randr_output = NULL;
+ output->randr_output = NULL;
}
- for (c = 0; c < config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = config->crtc[c];
+ for (c = 0; c < config->num_crtc; c++) {
+ xf86CrtcPtr crtc = config->crtc[c];
- crtc->randr_crtc = NULL;
+ crtc->randr_crtc = NULL;
}
- xf86RandR12CloseScreen (screen);
+ xf86RandR12CloseScreen(screen);
- return screen->CloseScreen (index, screen);
+ return screen->CloseScreen(index, screen);
}
/*
@@ -770,37 +747,36 @@ int
#else
Bool
#endif
-xf86CrtcScreenInit (ScreenPtr screen)
+xf86CrtcScreenInit(ScreenPtr screen)
{
- ScrnInfoPtr scrn = xf86Screens[screen->myNum];
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
- int c;
+ ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ int c;
/* Rotation */
- xf86DrvMsg(scrn->scrnIndex, X_INFO, "RandR 1.2 enabled, ignore the following RandR disabled message.\n");
- xf86DisableRandR(); /* Disable old RandR extension support */
- xf86RandR12Init (screen);
+ xf86DrvMsg(scrn->scrnIndex, X_INFO,
+ "RandR 1.2 enabled, ignore the following RandR disabled message.\n");
+ xf86DisableRandR(); /* Disable old RandR extension support */
+ xf86RandR12Init(screen);
/* support all rotations if every crtc has the shadow alloc funcs */
- for (c = 0; c < config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = config->crtc[c];
- if (!crtc->funcs->shadow_allocate || !crtc->funcs->shadow_create)
- break;
- }
- if (c == config->num_crtc)
- {
- xf86RandR12SetRotations (screen, RR_Rotate_0 | RR_Rotate_90 |
- RR_Rotate_180 | RR_Rotate_270 |
- RR_Reflect_X | RR_Reflect_Y);
- xf86RandR12SetTransformSupport (screen, TRUE);
+ for (c = 0; c < config->num_crtc; c++) {
+ xf86CrtcPtr crtc = config->crtc[c];
+
+ if (!crtc->funcs->shadow_allocate || !crtc->funcs->shadow_create)
+ break;
}
- else
- {
- xf86RandR12SetRotations (screen, RR_Rotate_0);
- xf86RandR12SetTransformSupport (screen, FALSE);
+ if (c == config->num_crtc) {
+ xf86RandR12SetRotations(screen, RR_Rotate_0 | RR_Rotate_90 |
+ RR_Rotate_180 | RR_Rotate_270 |
+ RR_Reflect_X | RR_Reflect_Y);
+ xf86RandR12SetTransformSupport(screen, TRUE);
+ }
+ else {
+ xf86RandR12SetRotations(screen, RR_Rotate_0);
+ xf86RandR12SetTransformSupport(screen, FALSE);
}
-
+
/* Wrap CreateScreenResources so we can initialize the RandR code */
config->CreateScreenResources = screen->CreateScreenResources;
screen->CreateScreenResources = xf86CrtcCreateScreenResources;
@@ -810,7 +786,7 @@ xf86CrtcScreenInit (ScreenPtr screen)
/* This might still be marked wrapped from a previous generation */
config->BlockHandler = NULL;
-
+
#ifdef XFreeXDGA
_xf86_di_dga_init_internal(screen);
#endif
@@ -822,205 +798,198 @@ xf86CrtcScreenInit (ScreenPtr screen)
}
static DisplayModePtr
-xf86DefaultMode (xf86OutputPtr output, int width, int height)
-{
- DisplayModePtr target_mode = NULL;
- DisplayModePtr mode;
- int target_diff = 0;
- int target_preferred = 0;
- int mm_height;
-
+xf86DefaultMode(xf86OutputPtr output, int width, int height)
+{
+ DisplayModePtr target_mode = NULL;
+ DisplayModePtr mode;
+ int target_diff = 0;
+ int target_preferred = 0;
+ int mm_height;
+
mm_height = output->mm_height;
if (!mm_height)
- mm_height = (768 * 25.4) / DEFAULT_DPI;
+ mm_height = (768 * 25.4) / DEFAULT_DPI;
/*
* Pick a mode closest to DEFAULT_DPI
*/
- for (mode = output->probed_modes; mode; mode = mode->next)
- {
- int dpi;
- int preferred = (((mode->type & M_T_PREFERRED) != 0) +
- ((mode->type & M_T_USERPREF) != 0));
- int diff;
-
- if (xf86ModeWidth (mode, output->initial_rotation) > width ||
- xf86ModeHeight (mode, output->initial_rotation) > height)
- continue;
-
- /* yes, use VDisplay here, not xf86ModeHeight */
- dpi = (mode->VDisplay * 254) / (mm_height * 10);
- diff = dpi - DEFAULT_DPI;
- diff = diff < 0 ? -diff : diff;
- if (target_mode == NULL || (preferred > target_preferred) ||
- (preferred == target_preferred && diff < target_diff))
- {
- target_mode = mode;
- target_diff = diff;
- target_preferred = preferred;
- }
+ for (mode = output->probed_modes; mode; mode = mode->next) {
+ int dpi;
+ int preferred = (((mode->type & M_T_PREFERRED) != 0) +
+ ((mode->type & M_T_USERPREF) != 0));
+ int diff;
+
+ if (xf86ModeWidth(mode, output->initial_rotation) > width ||
+ xf86ModeHeight(mode, output->initial_rotation) > height)
+ continue;
+
+ /* yes, use VDisplay here, not xf86ModeHeight */
+ dpi = (mode->VDisplay * 254) / (mm_height * 10);
+ diff = dpi - DEFAULT_DPI;
+ diff = diff < 0 ? -diff : diff;
+ if (target_mode == NULL || (preferred > target_preferred) ||
+ (preferred == target_preferred && diff < target_diff)) {
+ target_mode = mode;
+ target_diff = diff;
+ target_preferred = preferred;
+ }
}
return target_mode;
}
static DisplayModePtr
-xf86ClosestMode (xf86OutputPtr output,
- DisplayModePtr match, Rotation match_rotation,
- int width, int height)
-{
- DisplayModePtr target_mode = NULL;
- DisplayModePtr mode;
- int target_diff = 0;
-
+xf86ClosestMode(xf86OutputPtr output,
+ DisplayModePtr match, Rotation match_rotation,
+ int width, int height)
+{
+ DisplayModePtr target_mode = NULL;
+ DisplayModePtr mode;
+ int target_diff = 0;
+
/*
* Pick a mode closest to the specified mode
*/
- for (mode = output->probed_modes; mode; mode = mode->next)
- {
- int dx, dy;
- int diff;
-
- if (xf86ModeWidth (mode, output->initial_rotation) > width ||
- xf86ModeHeight (mode, output->initial_rotation) > height)
- continue;
-
- /* exact matches are preferred */
- if (output->initial_rotation == match_rotation &&
- xf86ModesEqual (mode, match))
- return mode;
-
- dx = xf86ModeWidth (match, match_rotation) - xf86ModeWidth (mode, output->initial_rotation);
- dy = xf86ModeHeight (match, match_rotation) - xf86ModeHeight (mode, output->initial_rotation);
- diff = dx * dx + dy * dy;
- if (target_mode == NULL || diff < target_diff)
- {
- target_mode = mode;
- target_diff = diff;
- }
+ for (mode = output->probed_modes; mode; mode = mode->next) {
+ int dx, dy;
+ int diff;
+
+ if (xf86ModeWidth(mode, output->initial_rotation) > width ||
+ xf86ModeHeight(mode, output->initial_rotation) > height)
+ continue;
+
+ /* exact matches are preferred */
+ if (output->initial_rotation == match_rotation &&
+ xf86ModesEqual(mode, match))
+ return mode;
+
+ dx = xf86ModeWidth(match, match_rotation) - xf86ModeWidth(mode,
+ output->
+ initial_rotation);
+ dy = xf86ModeHeight(match, match_rotation) - xf86ModeHeight(mode,
+ output->
+ initial_rotation);
+ diff = dx * dx + dy * dy;
+ if (target_mode == NULL || diff < target_diff) {
+ target_mode = mode;
+ target_diff = diff;
+ }
}
return target_mode;
}
static DisplayModePtr
-xf86OutputHasPreferredMode (xf86OutputPtr output, int width, int height)
+xf86OutputHasPreferredMode(xf86OutputPtr output, int width, int height)
{
- DisplayModePtr mode;
+ DisplayModePtr mode;
- for (mode = output->probed_modes; mode; mode = mode->next)
- {
- if (xf86ModeWidth (mode, output->initial_rotation) > width ||
- xf86ModeHeight (mode, output->initial_rotation) > height)
- continue;
+ for (mode = output->probed_modes; mode; mode = mode->next) {
+ if (xf86ModeWidth(mode, output->initial_rotation) > width ||
+ xf86ModeHeight(mode, output->initial_rotation) > height)
+ continue;
- if (mode->type & M_T_PREFERRED)
- return mode;
+ if (mode->type & M_T_PREFERRED)
+ return mode;
}
return NULL;
}
static DisplayModePtr
-xf86OutputHasUserPreferredMode (xf86OutputPtr output)
+xf86OutputHasUserPreferredMode(xf86OutputPtr output)
{
DisplayModePtr mode, first = output->probed_modes;
for (mode = first; mode && mode->next != first; mode = mode->next)
- if (mode->type & M_T_USERPREF)
- return mode;
+ if (mode->type & M_T_USERPREF)
+ return mode;
return NULL;
}
static int
-xf86PickCrtcs (ScrnInfoPtr scrn,
- xf86CrtcPtr *best_crtcs,
- DisplayModePtr *modes,
- int n,
- int width,
- int height)
-{
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
- int c, o;
- xf86OutputPtr output;
- xf86CrtcPtr crtc;
- xf86CrtcPtr *crtcs;
- xf86CrtcPtr best_crtc;
- int best_score;
- int score;
- int my_score;
-
+xf86PickCrtcs(ScrnInfoPtr scrn,
+ xf86CrtcPtr * best_crtcs,
+ DisplayModePtr * modes, int n, int width, int height)
+{
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ int c, o;
+ xf86OutputPtr output;
+ xf86CrtcPtr crtc;
+ xf86CrtcPtr *crtcs;
+ xf86CrtcPtr best_crtc;
+ int best_score;
+ int score;
+ int my_score;
+
if (n == config->num_output)
- return 0;
+ return 0;
output = config->output[n];
-
+
/*
* Compute score with this output disabled
*/
best_crtcs[n] = NULL;
best_crtc = NULL;
- best_score = xf86PickCrtcs (scrn, best_crtcs, modes, n+1, width, height);
+ best_score = xf86PickCrtcs(scrn, best_crtcs, modes, n + 1, width, height);
if (modes[n] == NULL)
- return best_score;
-
- crtcs = malloc(config->num_output * sizeof (xf86CrtcPtr));
+ return best_score;
+
+ crtcs = malloc(config->num_output * sizeof(xf86CrtcPtr));
if (!crtcs)
- return best_score;
+ return best_score;
my_score = 1;
/* Score outputs that are known to be connected higher */
if (output->status == XF86OutputStatusConnected)
- my_score++;
+ my_score++;
/* Score outputs with preferred modes higher */
- if (xf86OutputHasPreferredMode (output, width, height))
- my_score++;
+ if (xf86OutputHasPreferredMode(output, width, height))
+ my_score++;
/*
* Select a crtc for this output and
* then attempt to configure the remaining
* outputs
*/
- for (c = 0; c < config->num_crtc; c++)
- {
- if ((output->possible_crtcs & (1 << c)) == 0)
- continue;
-
- crtc = config->crtc[c];
- /*
- * Check to see if some other output is
- * using this crtc
- */
- for (o = 0; o < n; o++)
- if (best_crtcs[o] == crtc)
- break;
- if (o < n)
- {
- /*
- * If the two outputs desire the same mode,
- * see if they can be cloned
- */
- if (xf86ModesEqual (modes[o], modes[n]) &&
- config->output[o]->initial_rotation == config->output[n]->initial_rotation &&
- config->output[o]->initial_x == config->output[n]->initial_x &&
- config->output[o]->initial_y == config->output[n]->initial_y)
- {
- if ((output->possible_clones & (1 << o)) == 0)
- continue; /* nope, try next CRTC */
- }
- else
- continue; /* different modes, can't clone */
- }
- crtcs[n] = crtc;
- memcpy (crtcs, best_crtcs, n * sizeof (xf86CrtcPtr));
- score = my_score + xf86PickCrtcs (scrn, crtcs, modes, n+1, width, height);
- if (score > best_score)
- {
- best_crtc = crtc;
- best_score = score;
- memcpy (best_crtcs, crtcs, config->num_output * sizeof (xf86CrtcPtr));
- }
+ for (c = 0; c < config->num_crtc; c++) {
+ if ((output->possible_crtcs & (1 << c)) == 0)
+ continue;
+
+ crtc = config->crtc[c];
+ /*
+ * Check to see if some other output is
+ * using this crtc
+ */
+ for (o = 0; o < n; o++)
+ if (best_crtcs[o] == crtc)
+ break;
+ if (o < n) {
+ /*
+ * If the two outputs desire the same mode,
+ * see if they can be cloned
+ */
+ if (xf86ModesEqual(modes[o], modes[n]) &&
+ config->output[o]->initial_rotation ==
+ config->output[n]->initial_rotation &&
+ config->output[o]->initial_x == config->output[n]->initial_x &&
+ config->output[o]->initial_y == config->output[n]->initial_y) {
+ if ((output->possible_clones & (1 << o)) == 0)
+ continue; /* nope, try next CRTC */
+ }
+ else
+ continue; /* different modes, can't clone */
+ }
+ crtcs[n] = crtc;
+ memcpy(crtcs, best_crtcs, n * sizeof(xf86CrtcPtr));
+ score =
+ my_score + xf86PickCrtcs(scrn, crtcs, modes, n + 1, width, height);
+ if (score > best_score) {
+ best_crtc = crtc;
+ best_score = score;
+ memcpy(best_crtcs, crtcs, config->num_output * sizeof(xf86CrtcPtr));
+ }
}
free(crtcs);
return best_score;
}
-
/*
* Compute the virtual size necessary to place all of the available
* crtcs in the specified configuration.
@@ -1031,57 +1000,62 @@ xf86PickCrtcs (ScrnInfoPtr scrn,
*/
static void
-xf86DefaultScreenLimits (ScrnInfoPtr scrn, int *widthp, int *heightp,
- Bool canGrow)
-{
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
- int width = 0, height = 0;
- int o;
- int c;
- int s;
-
- for (c = 0; c < config->num_crtc; c++)
- {
- int crtc_width = 0, crtc_height = 0;
- xf86CrtcPtr crtc = config->crtc[c];
-
- if (crtc->enabled)
- {
- crtc_width = crtc->desiredX + xf86ModeWidth (&crtc->desiredMode, crtc->desiredRotation);
- crtc_height = crtc->desiredY + xf86ModeHeight (&crtc->desiredMode, crtc->desiredRotation);
- }
- if (!canGrow) {
- for (o = 0; o < config->num_output; o++)
- {
- xf86OutputPtr output = config->output[o];
-
- for (s = 0; s < config->num_crtc; s++)
- if (output->possible_crtcs & (1 << s))
- {
- DisplayModePtr mode;
- for (mode = output->probed_modes; mode; mode = mode->next)
- {
- if (mode->HDisplay > crtc_width)
- crtc_width = mode->HDisplay;
- if (mode->VDisplay > crtc_width)
- crtc_width = mode->VDisplay;
- if (mode->VDisplay > crtc_height)
- crtc_height = mode->VDisplay;
- if (mode->HDisplay > crtc_height)
- crtc_height = mode->HDisplay;
- }
- }
- }
- }
- if (crtc_width > width)
- width = crtc_width;
- if (crtc_height > height)
- height = crtc_height;
- }
- if (config->maxWidth && width > config->maxWidth) width = config->maxWidth;
- if (config->maxHeight && height > config->maxHeight) height = config->maxHeight;
- if (config->minWidth && width < config->minWidth) width = config->minWidth;
- if (config->minHeight && height < config->minHeight) height = config->minHeight;
+xf86DefaultScreenLimits(ScrnInfoPtr scrn, int *widthp, int *heightp,
+ Bool canGrow)
+{
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ int width = 0, height = 0;
+ int o;
+ int c;
+ int s;
+
+ for (c = 0; c < config->num_crtc; c++) {
+ int crtc_width = 0, crtc_height = 0;
+ xf86CrtcPtr crtc = config->crtc[c];
+
+ if (crtc->enabled) {
+ crtc_width =
+ crtc->desiredX + xf86ModeWidth(&crtc->desiredMode,
+ crtc->desiredRotation);
+ crtc_height =
+ crtc->desiredY + xf86ModeHeight(&crtc->desiredMode,
+ crtc->desiredRotation);
+ }
+ if (!canGrow) {
+ for (o = 0; o < config->num_output; o++) {
+ xf86OutputPtr output = config->output[o];
+
+ for (s = 0; s < config->num_crtc; s++)
+ if (output->possible_crtcs & (1 << s)) {
+ DisplayModePtr mode;
+
+ for (mode = output->probed_modes; mode;
+ mode = mode->next) {
+ if (mode->HDisplay > crtc_width)
+ crtc_width = mode->HDisplay;
+ if (mode->VDisplay > crtc_width)
+ crtc_width = mode->VDisplay;
+ if (mode->VDisplay > crtc_height)
+ crtc_height = mode->VDisplay;
+ if (mode->HDisplay > crtc_height)
+ crtc_height = mode->HDisplay;
+ }
+ }
+ }
+ }
+ if (crtc_width > width)
+ width = crtc_width;
+ if (crtc_height > height)
+ height = crtc_height;
+ }
+ if (config->maxWidth && width > config->maxWidth)
+ width = config->maxWidth;
+ if (config->maxHeight && height > config->maxHeight)
+ height = config->maxHeight;
+ if (config->minWidth && width < config->minWidth)
+ width = config->minWidth;
+ if (config->minHeight && height < config->minHeight)
+ height = config->minHeight;
*widthp = width;
*heightp = height;
}
@@ -1093,216 +1067,200 @@ xf86DefaultScreenLimits (ScrnInfoPtr scrn, int *widthp, int *heightp,
* with either a position or a relative setting or a mode.
*/
static Bool
-xf86UserConfiguredOutputs(ScrnInfoPtr scrn, DisplayModePtr *modes)
+xf86UserConfiguredOutputs(ScrnInfoPtr scrn, DisplayModePtr * modes)
{
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
int o;
Bool user_conf = FALSE;
- for (o = 0; o < config->num_output; o++)
- {
- xf86OutputPtr output = config->output[o];
- char *position;
- char *relative_name;
- OutputOpts relation;
- int r;
- static const OutputOpts relations[] = {
- OPTION_BELOW, OPTION_RIGHT_OF, OPTION_ABOVE, OPTION_LEFT_OF
- };
-
- position = xf86GetOptValString (output->options,
- OPTION_POSITION);
- if (position)
- user_conf = TRUE;
-
- relation = 0;
- relative_name = NULL;
- for (r = 0; r < 4; r++)
- {
- relation = relations[r];
- relative_name = xf86GetOptValString (output->options,
- relation);
- if (relative_name)
- break;
- }
- if (relative_name)
- user_conf = TRUE;
-
- modes[o] = xf86OutputHasUserPreferredMode(output);
- if (modes[o])
- user_conf = TRUE;
+ for (o = 0; o < config->num_output; o++) {
+ xf86OutputPtr output = config->output[o];
+ char *position;
+ char *relative_name;
+ OutputOpts relation;
+ int r;
+
+ static const OutputOpts relations[] = {
+ OPTION_BELOW, OPTION_RIGHT_OF, OPTION_ABOVE, OPTION_LEFT_OF
+ };
+
+ position = xf86GetOptValString(output->options, OPTION_POSITION);
+ if (position)
+ user_conf = TRUE;
+
+ relation = 0;
+ relative_name = NULL;
+ for (r = 0; r < 4; r++) {
+ relation = relations[r];
+ relative_name = xf86GetOptValString(output->options, relation);
+ if (relative_name)
+ break;
+ }
+ if (relative_name)
+ user_conf = TRUE;
+
+ modes[o] = xf86OutputHasUserPreferredMode(output);
+ if (modes[o])
+ user_conf = TRUE;
}
return user_conf;
}
static Bool
-xf86InitialOutputPositions (ScrnInfoPtr scrn, DisplayModePtr *modes)
+xf86InitialOutputPositions(ScrnInfoPtr scrn, DisplayModePtr * modes)
{
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
- int o;
- int min_x, min_y;
-
- for (o = 0; o < config->num_output; o++)
- {
- xf86OutputPtr output = config->output[o];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ int o;
+ int min_x, min_y;
+
+ for (o = 0; o < config->num_output; o++) {
+ xf86OutputPtr output = config->output[o];
- output->initial_x = output->initial_y = POSITION_UNSET;
+ output->initial_x = output->initial_y = POSITION_UNSET;
}
-
+
/*
* Loop until all outputs are set
*/
- for (;;)
- {
- Bool any_set = FALSE;
- Bool keep_going = FALSE;
-
- for (o = 0; o < config->num_output; o++)
- {
- static const OutputOpts relations[] = {
- OPTION_BELOW, OPTION_RIGHT_OF, OPTION_ABOVE, OPTION_LEFT_OF
- };
- xf86OutputPtr output = config->output[o];
- xf86OutputPtr relative;
- char *relative_name;
- char *position;
- OutputOpts relation;
- int r;
-
- if (output->initial_x != POSITION_UNSET)
- continue;
- position = xf86GetOptValString (output->options,
- OPTION_POSITION);
- /*
- * Absolute position wins
- */
- if (position)
- {
- int x, y;
- if (sscanf (position, "%d %d", &x, &y) == 2)
- {
- output->initial_x = x;
- output->initial_y = y;
- }
- else
- {
- xf86DrvMsg (scrn->scrnIndex, X_ERROR,
- "Output %s position not of form \"x y\"\n",
- output->name);
- output->initial_x = output->initial_y = 0;
- }
- any_set = TRUE;
- continue;
- }
- /*
- * Next comes relative positions
- */
- relation = 0;
- relative_name = NULL;
- for (r = 0; r < 4; r++)
- {
- relation = relations[r];
- relative_name = xf86GetOptValString (output->options,
- relation);
- if (relative_name)
- break;
- }
- if (relative_name)
- {
- int or;
- relative = NULL;
- for (or = 0; or < config->num_output; or++)
- {
- xf86OutputPtr out_rel = config->output[or];
- XF86ConfMonitorPtr rel_mon = out_rel->conf_monitor;
-
- if (rel_mon)
- {
- if (xf86nameCompare (rel_mon->mon_identifier,
- relative_name) == 0)
- {
- relative = config->output[or];
- break;
- }
- }
- if (strcmp (out_rel->name, relative_name) == 0)
- {
- relative = config->output[or];
- break;
- }
- }
- if (!relative)
- {
- xf86DrvMsg (scrn->scrnIndex, X_ERROR,
- "Cannot position output %s relative to unknown output %s\n",
- output->name, relative_name);
- output->initial_x = 0;
- output->initial_y = 0;
- any_set = TRUE;
- continue;
- }
- if (!modes[or])
- {
- xf86DrvMsg (scrn->scrnIndex, X_ERROR,
- "Cannot position output %s relative to output %s without modes\n",
- output->name, relative_name);
- output->initial_x = 0;
- output->initial_y = 0;
- any_set = TRUE;
- continue;
- }
- if (relative->initial_x == POSITION_UNSET)
- {
- keep_going = TRUE;
- continue;
- }
- output->initial_x = relative->initial_x;
- output->initial_y = relative->initial_y;
- switch (relation) {
- case OPTION_BELOW:
- output->initial_y += xf86ModeHeight (modes[or], relative->initial_rotation);
- break;
- case OPTION_RIGHT_OF:
- output->initial_x += xf86ModeWidth (modes[or], relative->initial_rotation);
- break;
- case OPTION_ABOVE:
- if (modes[o])
- output->initial_y -= xf86ModeHeight (modes[o], output->initial_rotation);
- break;
- case OPTION_LEFT_OF:
- if (modes[o])
- output->initial_x -= xf86ModeWidth (modes[o], output->initial_rotation);
- break;
- default:
- break;
- }
- any_set = TRUE;
- continue;
- }
-
- /* Nothing set, just stick them at 0,0 */
- output->initial_x = 0;
- output->initial_y = 0;
- any_set = TRUE;
- }
- if (!keep_going)
- break;
- if (!any_set)
- {
- for (o = 0; o < config->num_output; o++)
- {
- xf86OutputPtr output = config->output[o];
- if (output->initial_x == POSITION_UNSET)
- {
- xf86DrvMsg (scrn->scrnIndex, X_ERROR,
- "Output position loop. Moving %s to 0,0\n",
- output->name);
- output->initial_x = output->initial_y = 0;
- break;
- }
- }
- }
+ for (;;) {
+ Bool any_set = FALSE;
+ Bool keep_going = FALSE;
+
+ for (o = 0; o < config->num_output; o++) {
+ static const OutputOpts relations[] = {
+ OPTION_BELOW, OPTION_RIGHT_OF, OPTION_ABOVE, OPTION_LEFT_OF
+ };
+ xf86OutputPtr output = config->output[o];
+ xf86OutputPtr relative;
+ char *relative_name;
+ char *position;
+ OutputOpts relation;
+ int r;
+
+ if (output->initial_x != POSITION_UNSET)
+ continue;
+ position = xf86GetOptValString(output->options, OPTION_POSITION);
+ /*
+ * Absolute position wins
+ */
+ if (position) {
+ int x, y;
+
+ if (sscanf(position, "%d %d", &x, &y) == 2) {
+ output->initial_x = x;
+ output->initial_y = y;
+ }
+ else {
+ xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+ "Output %s position not of form \"x y\"\n",
+ output->name);
+ output->initial_x = output->initial_y = 0;
+ }
+ any_set = TRUE;
+ continue;
+ }
+ /*
+ * Next comes relative positions
+ */
+ relation = 0;
+ relative_name = NULL;
+ for (r = 0; r < 4; r++) {
+ relation = relations[r];
+ relative_name = xf86GetOptValString(output->options, relation);
+ if (relative_name)
+ break;
+ }
+ if (relative_name) {
+ int or;
+
+ relative = NULL;
+ for (or = 0; or < config->num_output; or++) {
+ xf86OutputPtr out_rel = config->output[or];
+ XF86ConfMonitorPtr rel_mon = out_rel->conf_monitor;
+
+ if (rel_mon) {
+ if (xf86nameCompare(rel_mon->mon_identifier,
+ relative_name) == 0) {
+ relative = config->output[or];
+ break;
+ }
+ }
+ if (strcmp(out_rel->name, relative_name) == 0) {
+ relative = config->output[or];
+ break;
+ }
+ }
+ if (!relative) {
+ xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+ "Cannot position output %s relative to unknown output %s\n",
+ output->name, relative_name);
+ output->initial_x = 0;
+ output->initial_y = 0;
+ any_set = TRUE;
+ continue;
+ }
+ if (!modes[or]) {
+ xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+ "Cannot position output %s relative to output %s without modes\n",
+ output->name, relative_name);
+ output->initial_x = 0;
+ output->initial_y = 0;
+ any_set = TRUE;
+ continue;
+ }
+ if (relative->initial_x == POSITION_UNSET) {
+ keep_going = TRUE;
+ continue;
+ }
+ output->initial_x = relative->initial_x;
+ output->initial_y = relative->initial_y;
+ switch (relation) {
+ case OPTION_BELOW:
+ output->initial_y +=
+ xf86ModeHeight(modes[or], relative->initial_rotation);
+ break;
+ case OPTION_RIGHT_OF:
+ output->initial_x +=
+ xf86ModeWidth(modes[or], relative->initial_rotation);
+ break;
+ case OPTION_ABOVE:
+ if (modes[o])
+ output->initial_y -=
+ xf86ModeHeight(modes[o], output->initial_rotation);
+ break;
+ case OPTION_LEFT_OF:
+ if (modes[o])
+ output->initial_x -=
+ xf86ModeWidth(modes[o], output->initial_rotation);
+ break;
+ default:
+ break;
+ }
+ any_set = TRUE;
+ continue;
+ }
+
+ /* Nothing set, just stick them at 0,0 */
+ output->initial_x = 0;
+ output->initial_y = 0;
+ any_set = TRUE;
+ }
+ if (!keep_going)
+ break;
+ if (!any_set) {
+ for (o = 0; o < config->num_output; o++) {
+ xf86OutputPtr output = config->output[o];
+
+ if (output->initial_x == POSITION_UNSET) {
+ xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+ "Output position loop. Moving %s to 0,0\n",
+ output->name);
+ output->initial_x = output->initial_y = 0;
+ break;
+ }
+ }
+ }
}
/*
@@ -1310,92 +1268,89 @@ xf86InitialOutputPositions (ScrnInfoPtr scrn, DisplayModePtr *modes)
*/
min_x = 1000000;
min_y = 1000000;
- for (o = 0; o < config->num_output; o++)
- {
- xf86OutputPtr output = config->output[o];
+ for (o = 0; o < config->num_output; o++) {
+ xf86OutputPtr output = config->output[o];
- if (output->initial_x < min_x)
- min_x = output->initial_x;
- if (output->initial_y < min_y)
- min_y = output->initial_y;
+ if (output->initial_x < min_x)
+ min_x = output->initial_x;
+ if (output->initial_y < min_y)
+ min_y = output->initial_y;
}
-
- for (o = 0; o < config->num_output; o++)
- {
- xf86OutputPtr output = config->output[o];
- output->initial_x -= min_x;
- output->initial_y -= min_y;
+ for (o = 0; o < config->num_output; o++) {
+ xf86OutputPtr output = config->output[o];
+
+ output->initial_x -= min_x;
+ output->initial_y -= min_y;
}
return TRUE;
}
static void
-xf86InitialPanning (ScrnInfoPtr scrn)
+xf86InitialPanning(ScrnInfoPtr scrn)
{
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
- int o;
-
- for (o = 0; o < config->num_output; o++)
- {
- xf86OutputPtr output = config->output[o];
- char *panning = xf86GetOptValString (output->options, OPTION_PANNING);
- int width, height, left, top;
- int track_width, track_height, track_left, track_top;
- int brdr[4];
-
- memset (&output->initialTotalArea, 0, sizeof(BoxRec));
- memset (&output->initialTrackingArea, 0, sizeof(BoxRec));
- memset (output->initialBorder, 0, 4*sizeof(INT16));
-
- if (! panning)
- continue;
-
- switch (sscanf (panning, "%dx%d+%d+%d/%dx%d+%d+%d/%d/%d/%d/%d",
- &width, &height, &left, &top,
- &track_width, &track_height, &track_left, &track_top,
- &brdr[0], &brdr[1], &brdr[2], &brdr[3])) {
- case 12:
- output->initialBorder[0] = brdr[0];
- output->initialBorder[1] = brdr[1];
- output->initialBorder[2] = brdr[2];
- output->initialBorder[3] = brdr[3];
- /* fall through */
- case 8:
- output->initialTrackingArea.x1 = track_left;
- output->initialTrackingArea.y1 = track_top;
- output->initialTrackingArea.x2 = track_left + track_width;
- output->initialTrackingArea.y2 = track_top + track_height;
- /* fall through */
- case 4:
- output->initialTotalArea.x1 = left;
- output->initialTotalArea.y1 = top;
- /* fall through */
- case 2:
- output->initialTotalArea.x2 = output->initialTotalArea.x1 + width;
- output->initialTotalArea.y2 = output->initialTotalArea.y1 + height;
- break;
- default:
- xf86DrvMsg (scrn->scrnIndex, X_ERROR,
- "Broken panning specification '%s' for output %s in config file\n",
- panning, output->name);
- }
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ int o;
+
+ for (o = 0; o < config->num_output; o++) {
+ xf86OutputPtr output = config->output[o];
+ char *panning = xf86GetOptValString(output->options, OPTION_PANNING);
+ int width, height, left, top;
+ int track_width, track_height, track_left, track_top;
+ int brdr[4];
+
+ memset(&output->initialTotalArea, 0, sizeof(BoxRec));
+ memset(&output->initialTrackingArea, 0, sizeof(BoxRec));
+ memset(output->initialBorder, 0, 4 * sizeof(INT16));
+
+ if (!panning)
+ continue;
+
+ switch (sscanf(panning, "%dx%d+%d+%d/%dx%d+%d+%d/%d/%d/%d/%d",
+ &width, &height, &left, &top,
+ &track_width, &track_height, &track_left, &track_top,
+ &brdr[0], &brdr[1], &brdr[2], &brdr[3])) {
+ case 12:
+ output->initialBorder[0] = brdr[0];
+ output->initialBorder[1] = brdr[1];
+ output->initialBorder[2] = brdr[2];
+ output->initialBorder[3] = brdr[3];
+ /* fall through */
+ case 8:
+ output->initialTrackingArea.x1 = track_left;
+ output->initialTrackingArea.y1 = track_top;
+ output->initialTrackingArea.x2 = track_left + track_width;
+ output->initialTrackingArea.y2 = track_top + track_height;
+ /* fall through */
+ case 4:
+ output->initialTotalArea.x1 = left;
+ output->initialTotalArea.y1 = top;
+ /* fall through */
+ case 2:
+ output->initialTotalArea.x2 = output->initialTotalArea.x1 + width;
+ output->initialTotalArea.y2 = output->initialTotalArea.y1 + height;
+ break;
+ default:
+ xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+ "Broken panning specification '%s' for output %s in config file\n",
+ panning, output->name);
+ }
}
}
/** Return - 0 + if a should be earlier, same or later than b in list
*/
static int
-xf86ModeCompare (DisplayModePtr a, DisplayModePtr b)
+xf86ModeCompare(DisplayModePtr a, DisplayModePtr b)
{
- int diff;
+ int diff;
diff = ((b->type & M_T_PREFERRED) != 0) - ((a->type & M_T_PREFERRED) != 0);
if (diff)
- return diff;
+ return diff;
diff = b->HDisplay * b->VDisplay - a->HDisplay * a->VDisplay;
if (diff)
- return diff;
+ return diff;
diff = b->Clock - a->Clock;
return diff;
}
@@ -1404,38 +1359,34 @@ xf86ModeCompare (DisplayModePtr a, DisplayModePtr b)
* Insertion sort input in-place and return the resulting head
*/
static DisplayModePtr
-xf86SortModes (DisplayModePtr input)
+xf86SortModes(DisplayModePtr input)
{
- DisplayModePtr output = NULL, i, o, n, *op, prev;
+ DisplayModePtr output = NULL, i, o, n, *op, prev;
/* sort by preferred status and pixel area */
- while (input)
- {
- i = input;
- input = input->next;
- for (op = &output; (o = *op); op = &o->next)
- if (xf86ModeCompare (o, i) > 0)
- break;
- i->next = *op;
- *op = i;
+ while (input) {
+ i = input;
+ input = input->next;
+ for (op = &output; (o = *op); op = &o->next)
+ if (xf86ModeCompare(o, i) > 0)
+ break;
+ i->next = *op;
+ *op = i;
}
/* prune identical modes */
- for (o = output; o && (n = o->next); o = n)
- {
- if (!strcmp (o->name, n->name) && xf86ModesEqual (o, n))
- {
- o->next = n->next;
- free(n->name);
- free(n);
- n = o;
- }
+ for (o = output; o && (n = o->next); o = n) {
+ if (!strcmp(o->name, n->name) && xf86ModesEqual(o, n)) {
+ o->next = n->next;
+ free(n->name);
+ free(n);
+ n = o;
+ }
}
/* hook up backward links */
prev = NULL;
- for (o = output; o; o = o->next)
- {
- o->prev = prev;
- prev = o;
+ for (o = output; o; o = o->next) {
+ o->prev = prev;
+ prev = o;
}
return output;
}
@@ -1446,13 +1397,13 @@ preferredMode(ScrnInfoPtr pScrn, xf86OutputPtr output)
char *preferred_mode = NULL;
/* Check for a configured preference for a particular mode */
- preferred_mode = xf86GetOptValString (output->options,
- OPTION_PREFERRED_MODE);
+ preferred_mode = xf86GetOptValString(output->options,
+ OPTION_PREFERRED_MODE);
if (preferred_mode)
- return preferred_mode;
+ return preferred_mode;
if (pScrn->display->modes && *pScrn->display->modes)
- preferred_mode = *pScrn->display->modes;
+ preferred_mode = *pScrn->display->modes;
return preferred_mode;
}
@@ -1461,7 +1412,7 @@ static void
GuessRangeFromModes(MonPtr mon, DisplayModePtr mode)
{
if (!mon || !mode)
- return;
+ return;
mon->nHsync = 1;
mon->hsync[0].lo = 1024.0;
@@ -1472,33 +1423,33 @@ GuessRangeFromModes(MonPtr mon, DisplayModePtr mode)
mon->vrefresh[0].hi = 0.0;
while (mode) {
- if (!mode->HSync)
- mode->HSync = ((float) mode->Clock ) / ((float) mode->HTotal);
+ if (!mode->HSync)
+ mode->HSync = ((float) mode->Clock) / ((float) mode->HTotal);
- if (!mode->VRefresh)
- mode->VRefresh = (1000.0 * ((float) mode->Clock)) /
- ((float) (mode->HTotal * mode->VTotal));
+ if (!mode->VRefresh)
+ mode->VRefresh = (1000.0 * ((float) mode->Clock)) /
+ ((float) (mode->HTotal * mode->VTotal));
- if (mode->HSync < mon->hsync[0].lo)
- mon->hsync[0].lo = mode->HSync;
+ if (mode->HSync < mon->hsync[0].lo)
+ mon->hsync[0].lo = mode->HSync;
- if (mode->HSync > mon->hsync[0].hi)
- mon->hsync[0].hi = mode->HSync;
+ if (mode->HSync > mon->hsync[0].hi)
+ mon->hsync[0].hi = mode->HSync;
- if (mode->VRefresh < mon->vrefresh[0].lo)
- mon->vrefresh[0].lo = mode->VRefresh;
+ if (mode->VRefresh < mon->vrefresh[0].lo)
+ mon->vrefresh[0].lo = mode->VRefresh;
- if (mode->VRefresh > mon->vrefresh[0].hi)
- mon->vrefresh[0].hi = mode->VRefresh;
+ if (mode->VRefresh > mon->vrefresh[0].hi)
+ mon->vrefresh[0].hi = mode->VRefresh;
- mode = mode->next;
+ mode = mode->next;
}
/* stretch out the bottom to fit 640x480@60 */
if (mon->hsync[0].lo > 31.0)
- mon->hsync[0].lo = 31.0;
+ mon->hsync[0].lo = 31.0;
if (mon->vrefresh[0].lo > 58.0)
- mon->vrefresh[0].lo = 58.0;
+ mon->vrefresh[0].lo = 58.0;
}
enum det_monrec_source {
@@ -1513,14 +1464,16 @@ struct det_monrec_parameter {
enum det_monrec_source *sync_source;
};
-static void handle_detailed_monrec(struct detailed_monitor_section *det_mon,
- void *data)
+static void
+handle_detailed_monrec(struct detailed_monitor_section *det_mon, void *data)
{
struct det_monrec_parameter *p;
- p = (struct det_monrec_parameter *)data;
+
+ p = (struct det_monrec_parameter *) data;
if (det_mon->type == DS_RANGES) {
struct monitor_ranges *ranges = &det_mon->section.ranges;
+
if (p->set_hsync && ranges->max_h) {
p->mon_rec->hsync[p->mon_rec->nHsync].lo = ranges->min_h;
p->mon_rec->hsync[p->mon_rec->nHsync].hi = ranges->max_h;
@@ -1541,10 +1494,10 @@ static void handle_detailed_monrec(struct detailed_monitor_section *det_mon,
}
void
-xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY)
+xf86ProbeOutputModes(ScrnInfoPtr scrn, int maxX, int maxY)
{
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
- int o;
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ int o;
/* When canGrow was TRUE in the initial configuration we have to
* compare against the maximum values so that we don't drop modes.
@@ -1552,251 +1505,238 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY)
* anyway.
*/
if (maxX == 0 || maxY == 0) {
- maxX = config->maxWidth;
- maxY = config->maxHeight;
+ maxX = config->maxWidth;
+ maxY = config->maxHeight;
}
/* Probe the list of modes for each output. */
- for (o = 0; o < config->num_output; o++)
- {
- xf86OutputPtr output = config->output[o];
- DisplayModePtr mode;
- DisplayModePtr config_modes = NULL, output_modes, default_modes = NULL;
- char *preferred_mode;
- xf86MonPtr edid_monitor;
- XF86ConfMonitorPtr conf_monitor;
- MonRec mon_rec;
- int min_clock = 0;
- int max_clock = 0;
- double clock;
- Bool add_default_modes;
- Bool debug_modes = config->debug_modes ||
- xf86Initialising;
- enum det_monrec_source sync_source = sync_default;
-
- while (output->probed_modes != NULL)
- xf86DeleteMode(&output->probed_modes, output->probed_modes);
-
- /*
- * Check connection status
- */
- output->status = (*output->funcs->detect)(output);
-
- if (output->status == XF86OutputStatusDisconnected &&
- !xf86ReturnOptValBool(output->options, OPTION_ENABLE, FALSE))
- {
- xf86OutputSetEDID (output, NULL);
- continue;
- }
-
- memset (&mon_rec, '\0', sizeof (mon_rec));
-
- conf_monitor = output->conf_monitor;
-
- if (conf_monitor)
- {
- int i;
-
- for (i = 0; i < conf_monitor->mon_n_hsync; i++)
- {
- mon_rec.hsync[mon_rec.nHsync].lo = conf_monitor->mon_hsync[i].lo;
- mon_rec.hsync[mon_rec.nHsync].hi = conf_monitor->mon_hsync[i].hi;
- mon_rec.nHsync++;
- sync_source = sync_config;
- }
- for (i = 0; i < conf_monitor->mon_n_vrefresh; i++)
- {
- mon_rec.vrefresh[mon_rec.nVrefresh].lo = conf_monitor->mon_vrefresh[i].lo;
- mon_rec.vrefresh[mon_rec.nVrefresh].hi = conf_monitor->mon_vrefresh[i].hi;
- mon_rec.nVrefresh++;
- sync_source = sync_config;
- }
- config_modes = xf86GetMonitorModes (scrn, conf_monitor);
- }
-
- output_modes = (*output->funcs->get_modes) (output);
-
- /*
- * If the user has a preference, respect it.
- * Otherwise, don't second-guess the driver.
- */
- if (!xf86GetOptValBool(output->options, OPTION_DEFAULT_MODES,
- &add_default_modes))
- add_default_modes = (output_modes == NULL);
-
- edid_monitor = output->MonInfo;
-
- if (edid_monitor)
- {
+ for (o = 0; o < config->num_output; o++) {
+ xf86OutputPtr output = config->output[o];
+ DisplayModePtr mode;
+ DisplayModePtr config_modes = NULL, output_modes, default_modes = NULL;
+ char *preferred_mode;
+ xf86MonPtr edid_monitor;
+ XF86ConfMonitorPtr conf_monitor;
+ MonRec mon_rec;
+ int min_clock = 0;
+ int max_clock = 0;
+ double clock;
+ Bool add_default_modes;
+ Bool debug_modes = config->debug_modes || xf86Initialising;
+ enum det_monrec_source sync_source = sync_default;
+
+ while (output->probed_modes != NULL)
+ xf86DeleteMode(&output->probed_modes, output->probed_modes);
+
+ /*
+ * Check connection status
+ */
+ output->status = (*output->funcs->detect) (output);
+
+ if (output->status == XF86OutputStatusDisconnected &&
+ !xf86ReturnOptValBool(output->options, OPTION_ENABLE, FALSE)) {
+ xf86OutputSetEDID(output, NULL);
+ continue;
+ }
+
+ memset(&mon_rec, '\0', sizeof(mon_rec));
+
+ conf_monitor = output->conf_monitor;
+
+ if (conf_monitor) {
+ int i;
+
+ for (i = 0; i < conf_monitor->mon_n_hsync; i++) {
+ mon_rec.hsync[mon_rec.nHsync].lo =
+ conf_monitor->mon_hsync[i].lo;
+ mon_rec.hsync[mon_rec.nHsync].hi =
+ conf_monitor->mon_hsync[i].hi;
+ mon_rec.nHsync++;
+ sync_source = sync_config;
+ }
+ for (i = 0; i < conf_monitor->mon_n_vrefresh; i++) {
+ mon_rec.vrefresh[mon_rec.nVrefresh].lo =
+ conf_monitor->mon_vrefresh[i].lo;
+ mon_rec.vrefresh[mon_rec.nVrefresh].hi =
+ conf_monitor->mon_vrefresh[i].hi;
+ mon_rec.nVrefresh++;
+ sync_source = sync_config;
+ }
+ config_modes = xf86GetMonitorModes(scrn, conf_monitor);
+ }
+
+ output_modes = (*output->funcs->get_modes) (output);
+
+ /*
+ * If the user has a preference, respect it.
+ * Otherwise, don't second-guess the driver.
+ */
+ if (!xf86GetOptValBool(output->options, OPTION_DEFAULT_MODES,
+ &add_default_modes))
+ add_default_modes = (output_modes == NULL);
+
+ edid_monitor = output->MonInfo;
+
+ if (edid_monitor) {
struct det_monrec_parameter p;
- struct disp_features *features = &edid_monitor->features;
-
- /* if display is not continuous-frequency, don't add default modes */
- if (!GTF_SUPPORTED(features->msc))
- add_default_modes = FALSE;
-
- p.mon_rec = &mon_rec;
- p.max_clock = &max_clock;
- p.set_hsync = mon_rec.nHsync == 0;
- p.set_vrefresh = mon_rec.nVrefresh == 0;
- p.sync_source = &sync_source;
-
- xf86ForEachDetailedBlock(edid_monitor,
- handle_detailed_monrec,
- &p);
- }
-
- if (xf86GetOptValFreq (output->options, OPTION_MIN_CLOCK,
- OPTUNITS_KHZ, &clock))
- min_clock = (int) clock;
- if (xf86GetOptValFreq (output->options, OPTION_MAX_CLOCK,
- OPTUNITS_KHZ, &clock))
- max_clock = (int) clock;
-
- /* If we still don't have a sync range, guess wildly */
- if (!mon_rec.nHsync || !mon_rec.nVrefresh)
- GuessRangeFromModes(&mon_rec, output_modes);
-
- /*
- * These limits will end up setting a 1024x768@60Hz mode by default,
- * which seems like a fairly good mode to use when nothing else is
- * specified
- */
- if (mon_rec.nHsync == 0)
- {
- mon_rec.hsync[0].lo = 31.0;
- mon_rec.hsync[0].hi = 55.0;
- mon_rec.nHsync = 1;
- }
- if (mon_rec.nVrefresh == 0)
- {
- mon_rec.vrefresh[0].lo = 58.0;
- mon_rec.vrefresh[0].hi = 62.0;
- mon_rec.nVrefresh = 1;
- }
-
- if (add_default_modes)
- default_modes = xf86GetDefaultModes ();
-
- /*
- * If this is not an RB monitor, remove RB modes from the default
- * pool. RB modes from the config or the monitor itself are fine.
- */
- if (!mon_rec.reducedblanking)
- xf86ValidateModesReducedBlanking (scrn, default_modes);
-
- if (sync_source == sync_config)
- {
- /*
- * Check output and config modes against sync range from config file
- */
- xf86ValidateModesSync (scrn, output_modes, &mon_rec);
- xf86ValidateModesSync (scrn, config_modes, &mon_rec);
- }
- /*
- * Check default modes against sync range
- */
- xf86ValidateModesSync (scrn, default_modes, &mon_rec);
- /*
- * Check default modes against monitor max clock
- */
- if (max_clock) {
- xf86ValidateModesClocks(scrn, default_modes,
- &min_clock, &max_clock, 1);
- xf86ValidateModesClocks(scrn, output_modes,
- &min_clock, &max_clock, 1);
- }
-
- output->probed_modes = NULL;
- output->probed_modes = xf86ModesAdd (output->probed_modes, config_modes);
- output->probed_modes = xf86ModesAdd (output->probed_modes, output_modes);
- output->probed_modes = xf86ModesAdd (output->probed_modes, default_modes);
-
- /*
- * Check all modes against max size, interlace, and doublescan
- */
- if (maxX && maxY)
- xf86ValidateModesSize (scrn, output->probed_modes,
- maxX, maxY, 0);
-
- {
- int flags = (output->interlaceAllowed ? V_INTERLACE : 0) |
- (output->doubleScanAllowed ? V_DBLSCAN : 0);
- xf86ValidateModesFlags (scrn, output->probed_modes, flags);
- }
-
- /*
- * Check all modes against output
- */
- for (mode = output->probed_modes; mode != NULL; mode = mode->next)
- if (mode->status == MODE_OK)
- mode->status = (*output->funcs->mode_valid)(output, mode);
-
- xf86PruneInvalidModes(scrn, &output->probed_modes, debug_modes);
-
- output->probed_modes = xf86SortModes (output->probed_modes);
-
- /* Check for a configured preference for a particular mode */
- preferred_mode = preferredMode(scrn, output);
-
- if (preferred_mode)
- {
- for (mode = output->probed_modes; mode; mode = mode->next)
- {
- if (!strcmp (preferred_mode, mode->name))
- {
- if (mode != output->probed_modes)
- {
- if (mode->prev)
- mode->prev->next = mode->next;
- if (mode->next)
- mode->next->prev = mode->prev;
- mode->next = output->probed_modes;
- output->probed_modes->prev = mode;
- mode->prev = NULL;
- output->probed_modes = mode;
- }
- mode->type |= (M_T_PREFERRED|M_T_USERPREF);
- break;
- }
- }
- }
-
- output->initial_rotation = xf86OutputInitialRotation (output);
-
- if (debug_modes) {
- if (output->probed_modes != NULL) {
- xf86DrvMsg(scrn->scrnIndex, X_INFO,
- "Printing probed modes for output %s\n",
- output->name);
- } else {
- xf86DrvMsg(scrn->scrnIndex, X_INFO,
- "No remaining probed modes for output %s\n",
- output->name);
- }
- }
- for (mode = output->probed_modes; mode != NULL; mode = mode->next)
- {
- /* The code to choose the best mode per pipe later on will require
- * VRefresh to be set.
- */
- mode->VRefresh = xf86ModeVRefresh(mode);
- xf86SetModeCrtc(mode, INTERLACE_HALVE_V);
-
- if (debug_modes)
- xf86PrintModeline(scrn->scrnIndex, mode);
- }
+ struct disp_features *features = &edid_monitor->features;
+
+ /* if display is not continuous-frequency, don't add default modes */
+ if (!GTF_SUPPORTED(features->msc))
+ add_default_modes = FALSE;
+
+ p.mon_rec = &mon_rec;
+ p.max_clock = &max_clock;
+ p.set_hsync = mon_rec.nHsync == 0;
+ p.set_vrefresh = mon_rec.nVrefresh == 0;
+ p.sync_source = &sync_source;
+
+ xf86ForEachDetailedBlock(edid_monitor, handle_detailed_monrec, &p);
+ }
+
+ if (xf86GetOptValFreq(output->options, OPTION_MIN_CLOCK,
+ OPTUNITS_KHZ, &clock))
+ min_clock = (int) clock;
+ if (xf86GetOptValFreq(output->options, OPTION_MAX_CLOCK,
+ OPTUNITS_KHZ, &clock))
+ max_clock = (int) clock;
+
+ /* If we still don't have a sync range, guess wildly */
+ if (!mon_rec.nHsync || !mon_rec.nVrefresh)
+ GuessRangeFromModes(&mon_rec, output_modes);
+
+ /*
+ * These limits will end up setting a 1024x768@60Hz mode by default,
+ * which seems like a fairly good mode to use when nothing else is
+ * specified
+ */
+ if (mon_rec.nHsync == 0) {
+ mon_rec.hsync[0].lo = 31.0;
+ mon_rec.hsync[0].hi = 55.0;
+ mon_rec.nHsync = 1;
+ }
+ if (mon_rec.nVrefresh == 0) {
+ mon_rec.vrefresh[0].lo = 58.0;
+ mon_rec.vrefresh[0].hi = 62.0;
+ mon_rec.nVrefresh = 1;
+ }
+
+ if (add_default_modes)
+ default_modes = xf86GetDefaultModes();
+
+ /*
+ * If this is not an RB monitor, remove RB modes from the default
+ * pool. RB modes from the config or the monitor itself are fine.
+ */
+ if (!mon_rec.reducedblanking)
+ xf86ValidateModesReducedBlanking(scrn, default_modes);
+
+ if (sync_source == sync_config) {
+ /*
+ * Check output and config modes against sync range from config file
+ */
+ xf86ValidateModesSync(scrn, output_modes, &mon_rec);
+ xf86ValidateModesSync(scrn, config_modes, &mon_rec);
+ }
+ /*
+ * Check default modes against sync range
+ */
+ xf86ValidateModesSync(scrn, default_modes, &mon_rec);
+ /*
+ * Check default modes against monitor max clock
+ */
+ if (max_clock) {
+ xf86ValidateModesClocks(scrn, default_modes,
+ &min_clock, &max_clock, 1);
+ xf86ValidateModesClocks(scrn, output_modes,
+ &min_clock, &max_clock, 1);
+ }
+
+ output->probed_modes = NULL;
+ output->probed_modes = xf86ModesAdd(output->probed_modes, config_modes);
+ output->probed_modes = xf86ModesAdd(output->probed_modes, output_modes);
+ output->probed_modes =
+ xf86ModesAdd(output->probed_modes, default_modes);
+
+ /*
+ * Check all modes against max size, interlace, and doublescan
+ */
+ if (maxX && maxY)
+ xf86ValidateModesSize(scrn, output->probed_modes, maxX, maxY, 0);
+
+ {
+ int flags = (output->interlaceAllowed ? V_INTERLACE : 0) |
+ (output->doubleScanAllowed ? V_DBLSCAN : 0);
+ xf86ValidateModesFlags(scrn, output->probed_modes, flags);
+ }
+
+ /*
+ * Check all modes against output
+ */
+ for (mode = output->probed_modes; mode != NULL; mode = mode->next)
+ if (mode->status == MODE_OK)
+ mode->status = (*output->funcs->mode_valid) (output, mode);
+
+ xf86PruneInvalidModes(scrn, &output->probed_modes, debug_modes);
+
+ output->probed_modes = xf86SortModes(output->probed_modes);
+
+ /* Check for a configured preference for a particular mode */
+ preferred_mode = preferredMode(scrn, output);
+
+ if (preferred_mode) {
+ for (mode = output->probed_modes; mode; mode = mode->next) {
+ if (!strcmp(preferred_mode, mode->name)) {
+ if (mode != output->probed_modes) {
+ if (mode->prev)
+ mode->prev->next = mode->next;
+ if (mode->next)
+ mode->next->prev = mode->prev;
+ mode->next = output->probed_modes;
+ output->probed_modes->prev = mode;
+ mode->prev = NULL;
+ output->probed_modes = mode;
+ }
+ mode->type |= (M_T_PREFERRED | M_T_USERPREF);
+ break;
+ }
+ }
+ }
+
+ output->initial_rotation = xf86OutputInitialRotation(output);
+
+ if (debug_modes) {
+ if (output->probed_modes != NULL) {
+ xf86DrvMsg(scrn->scrnIndex, X_INFO,
+ "Printing probed modes for output %s\n",
+ output->name);
+ }
+ else {
+ xf86DrvMsg(scrn->scrnIndex, X_INFO,
+ "No remaining probed modes for output %s\n",
+ output->name);
+ }
+ }
+ for (mode = output->probed_modes; mode != NULL; mode = mode->next) {
+ /* The code to choose the best mode per pipe later on will require
+ * VRefresh to be set.
+ */
+ mode->VRefresh = xf86ModeVRefresh(mode);
+ xf86SetModeCrtc(mode, INTERLACE_HALVE_V);
+
+ if (debug_modes)
+ xf86PrintModeline(scrn->scrnIndex, mode);
+ }
}
}
-
/**
* Copy one of the output mode lists to the ScrnInfo record
*/
/* XXX where does this function belong? Here? */
void
-xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr scrn, int *x, int *y);
+ xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr scrn, int *x, int *y);
static DisplayModePtr
biggestMode(DisplayModePtr a, DisplayModePtr b)
@@ -1804,15 +1744,15 @@ biggestMode(DisplayModePtr a, DisplayModePtr b)
int A, B;
if (!a)
- return b;
+ return b;
if (!b)
- return a;
+ return a;
A = a->HDisplay * a->VDisplay;
B = b->HDisplay * b->VDisplay;
if (A > B)
- return a;
+ return a;
return b;
}
@@ -1825,141 +1765,143 @@ SetCompatOutput(xf86CrtcConfigPtr config)
int o, compat = -1, count, mincount = 0;
/* Look for one that's definitely connected */
- for (o = 0; o < config->num_output; o++)
- {
- test = config->output[o];
- if (!test->crtc)
- continue;
- if (test->status != XF86OutputStatusConnected)
- continue;
- if (!test->probed_modes)
- continue;
-
- testmode = mode = test->probed_modes;
- for (count = 0; mode; mode = mode->next, count++)
- testmode = biggestMode(testmode, mode);
-
- if (!output) {
- output = test;
- compat = o;
- maxmode = testmode;
- mincount = count;
- } else if (maxmode == biggestMode(maxmode, testmode)) {
- output = test;
- compat = o;
- maxmode = testmode;
- mincount = count;
- } else if ((maxmode->HDisplay == testmode->HDisplay) &&
- (maxmode->VDisplay == testmode->VDisplay) &&
- count <= mincount) {
- output = test;
- compat = o;
- maxmode = testmode;
- mincount = count;
- }
+ for (o = 0; o < config->num_output; o++) {
+ test = config->output[o];
+ if (!test->crtc)
+ continue;
+ if (test->status != XF86OutputStatusConnected)
+ continue;
+ if (!test->probed_modes)
+ continue;
+
+ testmode = mode = test->probed_modes;
+ for (count = 0; mode; mode = mode->next, count++)
+ testmode = biggestMode(testmode, mode);
+
+ if (!output) {
+ output = test;
+ compat = o;
+ maxmode = testmode;
+ mincount = count;
+ }
+ else if (maxmode == biggestMode(maxmode, testmode)) {
+ output = test;
+ compat = o;
+ maxmode = testmode;
+ mincount = count;
+ }
+ else if ((maxmode->HDisplay == testmode->HDisplay) &&
+ (maxmode->VDisplay == testmode->VDisplay) &&
+ count <= mincount) {
+ output = test;
+ compat = o;
+ maxmode = testmode;
+ mincount = count;
+ }
}
/* If we didn't find one, take anything we can get */
- if (!output)
- {
- for (o = 0; o < config->num_output; o++)
- {
- test = config->output[o];
- if (!test->crtc)
- continue;
- if (!test->probed_modes)
- continue;
-
- if (!output) {
- output = test;
- compat = o;
- } else if (test->probed_modes->HDisplay < output->probed_modes->HDisplay) {
- output = test;
- compat = o;
- }
- }
+ if (!output) {
+ for (o = 0; o < config->num_output; o++) {
+ test = config->output[o];
+ if (!test->crtc)
+ continue;
+ if (!test->probed_modes)
+ continue;
+
+ if (!output) {
+ output = test;
+ compat = o;
+ }
+ else if (test->probed_modes->HDisplay <
+ output->probed_modes->HDisplay) {
+ output = test;
+ compat = o;
+ }
+ }
}
if (compat >= 0) {
- config->compat_output = compat;
- } else {
- /* Don't change the compat output when no valid outputs found */
- output = config->output[config->compat_output];
+ config->compat_output = compat;
+ }
+ else {
+ /* Don't change the compat output when no valid outputs found */
+ output = config->output[config->compat_output];
}
return output;
}
void
-xf86SetScrnInfoModes (ScrnInfoPtr scrn)
+xf86SetScrnInfoModes(ScrnInfoPtr scrn)
{
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
- xf86OutputPtr output;
- xf86CrtcPtr crtc;
- DisplayModePtr last, mode = NULL;
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86OutputPtr output;
+ xf86CrtcPtr crtc;
+ DisplayModePtr last, mode = NULL;
output = SetCompatOutput(config);
if (!output)
- return; /* punt */
+ return; /* punt */
crtc = output->crtc;
/* Clear any existing modes from scrn->modes */
while (scrn->modes != NULL)
- xf86DeleteMode(&scrn->modes, scrn->modes);
+ xf86DeleteMode(&scrn->modes, scrn->modes);
/* Set scrn->modes to the mode list for the 'compat' output */
scrn->modes = xf86DuplicateModes(scrn, output->probed_modes);
if (crtc) {
- for (mode = scrn->modes; mode; mode = mode->next)
- if (xf86ModesEqual (mode, &crtc->desiredMode))
- break;
+ for (mode = scrn->modes; mode; mode = mode->next)
+ if (xf86ModesEqual(mode, &crtc->desiredMode))
+ break;
}
if (!scrn->modes) {
- scrn->modes = xf86ModesAdd(scrn->modes,
- xf86CVTMode(scrn->display->virtualX,
- scrn->display->virtualY,
- 60, 0, 0));
+ scrn->modes = xf86ModesAdd(scrn->modes,
+ xf86CVTMode(scrn->display->virtualX,
+ scrn->display->virtualY,
+ 60, 0, 0));
}
/* For some reason, scrn->modes is circular, unlike the other mode
* lists. How great is that?
*/
- for (last = scrn->modes; last && last->next; last = last->next)
- ;
+ for (last = scrn->modes; last && last->next; last = last->next);
last->next = scrn->modes;
scrn->modes->prev = last;
if (mode) {
- while (scrn->modes != mode)
- scrn->modes = scrn->modes->next;
+ while (scrn->modes != mode)
+ scrn->modes = scrn->modes->next;
}
scrn->currentMode = scrn->modes;
#ifdef XFreeXDGA
if (scrn->pScreen)
- _xf86_di_dga_reinit_internal(scrn->pScreen);
+ _xf86_di_dga_reinit_internal(scrn->pScreen);
#endif
}
static Bool
xf86CollectEnabledOutputs(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
- Bool *enabled)
+ Bool *enabled)
{
Bool any_enabled = FALSE;
int o;
for (o = 0; o < config->num_output; o++)
- any_enabled |= enabled[o] = xf86OutputEnabled(config->output[o], TRUE);
-
+ any_enabled |= enabled[o] = xf86OutputEnabled(config->output[o], TRUE);
+
if (!any_enabled) {
- xf86DrvMsg(scrn->scrnIndex, X_WARNING,
- "No outputs definitely connected, trying again...\n");
+ xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+ "No outputs definitely connected, trying again...\n");
- for (o = 0; o < config->num_output; o++)
- any_enabled |= enabled[o] = xf86OutputEnabled(config->output[o], FALSE);
+ for (o = 0; o < config->num_output; o++)
+ any_enabled |= enabled[o] =
+ xf86OutputEnabled(config->output[o], FALSE);
}
return any_enabled;
@@ -1971,12 +1913,12 @@ nextEnabledOutput(xf86CrtcConfigPtr config, Bool *enabled, int *index)
int o = *index;
for (o++; o < config->num_output; o++) {
- if (enabled[o]) {
- *index = o;
- return TRUE;
- }
+ if (enabled[o]) {
+ *index = o;
+ return TRUE;
+ }
}
-
+
return FALSE;
}
@@ -1992,16 +1934,16 @@ nextAspectMode(xf86OutputPtr o, DisplayModePtr last, float aspect)
DisplayModePtr m = NULL;
if (!o)
- return NULL;
+ return NULL;
if (!last)
- m = o->probed_modes;
+ m = o->probed_modes;
else
- m = last->next;
+ m = last->next;
for (; m; m = m->next)
- if (aspectMatch(aspect, (float)m->HDisplay / (float)m->VDisplay))
- return m;
+ if (aspectMatch(aspect, (float) m->HDisplay / (float) m->VDisplay))
+ return m;
return NULL;
}
@@ -2013,27 +1955,27 @@ bestModeForAspect(xf86CrtcConfigPtr config, Bool *enabled, float aspect)
DisplayModePtr mode = NULL, test = NULL, match = NULL;
if (!nextEnabledOutput(config, enabled, &o))
- return NULL;
+ return NULL;
while ((mode = nextAspectMode(config->output[o], mode, aspect))) {
- test = mode;
- for (p = o; nextEnabledOutput(config, enabled, &p); ) {
- test = xf86OutputFindClosestMode(config->output[p], mode);
- if (!test)
- break;
- if (test->HDisplay != mode->HDisplay ||
- test->VDisplay != mode->VDisplay) {
- test = NULL;
- break;
- }
- }
-
- /* if we didn't match it on all outputs, try the next one */
- if (!test)
- continue;
-
- /* if it's bigger than the last one, save it */
- if (!match || (test->HDisplay > match->HDisplay))
- match = test;
+ test = mode;
+ for (p = o; nextEnabledOutput(config, enabled, &p);) {
+ test = xf86OutputFindClosestMode(config->output[p], mode);
+ if (!test)
+ break;
+ if (test->HDisplay != mode->HDisplay ||
+ test->VDisplay != mode->VDisplay) {
+ test = NULL;
+ break;
+ }
+ }
+
+ /* if we didn't match it on all outputs, try the next one */
+ if (!test)
+ continue;
+
+ /* if it's bigger than the last one, save it */
+ if (!match || (test->HDisplay > match->HDisplay))
+ match = test;
}
/* return the biggest one found */
@@ -2042,8 +1984,8 @@ bestModeForAspect(xf86CrtcConfigPtr config, Bool *enabled, float aspect)
static Bool
xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
- DisplayModePtr *modes, Bool *enabled,
- int width, int height)
+ DisplayModePtr * modes, Bool *enabled,
+ int width, int height)
{
int o, p;
int max_pref_width = 0, max_pref_height = 0;
@@ -2054,91 +1996,95 @@ xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
preferred_match = xnfcalloc(config->num_output, sizeof(DisplayModePtr));
/* Check if the preferred mode is available on all outputs */
- for (p = -1; nextEnabledOutput(config, enabled, &p); ) {
- Rotation r = config->output[p]->initial_rotation;
- DisplayModePtr mode;
- if ((preferred[p] = xf86OutputHasPreferredMode(config->output[p],
- width, height))) {
- int pref_width = xf86ModeWidth(preferred[p], r);
- int pref_height = xf86ModeHeight(preferred[p], r);
- Bool all_match = TRUE;
-
- for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
- Bool match = FALSE;
- xf86OutputPtr output = config->output[o];
- if (o == p)
- continue;
-
- /*
- * First see if the preferred mode matches on the next
- * output as well. This catches the common case of identical
- * monitors and makes sure they all have the same timings
- * and refresh. If that fails, we fall back to trying to
- * match just width & height.
- */
- mode = xf86OutputHasPreferredMode(output, pref_width,
- pref_height);
- if (mode && xf86ModesEqual(mode, preferred[p])) {
- preferred[o] = mode;
- match = TRUE;
- } else {
- for (mode = output->probed_modes; mode;
- mode = mode->next) {
- Rotation r = output->initial_rotation;
- if (xf86ModeWidth(mode, r) == pref_width &&
- xf86ModeHeight(mode, r) == pref_height) {
- preferred[o] = mode;
- match = TRUE;
- }
- }
- }
-
- all_match &= match;
- }
-
- if (all_match &&
- (pref_width*pref_height > max_pref_width*max_pref_height)) {
- for (o = -1; nextEnabledOutput(config, enabled, &o); )
- preferred_match[o] = preferred[o];
- max_pref_width = pref_width;
- max_pref_height = pref_height;
- ret = TRUE;
- }
- }
+ for (p = -1; nextEnabledOutput(config, enabled, &p);) {
+ Rotation r = config->output[p]->initial_rotation;
+ DisplayModePtr mode;
+
+ if ((preferred[p] = xf86OutputHasPreferredMode(config->output[p],
+ width, height))) {
+ int pref_width = xf86ModeWidth(preferred[p], r);
+ int pref_height = xf86ModeHeight(preferred[p], r);
+ Bool all_match = TRUE;
+
+ for (o = -1; nextEnabledOutput(config, enabled, &o);) {
+ Bool match = FALSE;
+ xf86OutputPtr output = config->output[o];
+
+ if (o == p)
+ continue;
+
+ /*
+ * First see if the preferred mode matches on the next
+ * output as well. This catches the common case of identical
+ * monitors and makes sure they all have the same timings
+ * and refresh. If that fails, we fall back to trying to
+ * match just width & height.
+ */
+ mode = xf86OutputHasPreferredMode(output, pref_width,
+ pref_height);
+ if (mode && xf86ModesEqual(mode, preferred[p])) {
+ preferred[o] = mode;
+ match = TRUE;
+ }
+ else {
+ for (mode = output->probed_modes; mode; mode = mode->next) {
+ Rotation r = output->initial_rotation;
+
+ if (xf86ModeWidth(mode, r) == pref_width &&
+ xf86ModeHeight(mode, r) == pref_height) {
+ preferred[o] = mode;
+ match = TRUE;
+ }
+ }
+ }
+
+ all_match &= match;
+ }
+
+ if (all_match &&
+ (pref_width * pref_height > max_pref_width * max_pref_height)) {
+ for (o = -1; nextEnabledOutput(config, enabled, &o);)
+ preferred_match[o] = preferred[o];
+ max_pref_width = pref_width;
+ max_pref_height = pref_height;
+ ret = TRUE;
+ }
+ }
}
/*
* If there's no preferred mode, but only one monitor, pick the
* biggest mode for its aspect ratio, assuming one exists.
*/
- if (!ret) do {
- int i = 0;
- float aspect = 0.0;
+ if (!ret)
+ do {
+ int i = 0;
+ float aspect = 0.0;
- /* count the number of enabled outputs */
- for (i = 0, p = -1; nextEnabledOutput(config, enabled, &p); i++) ;
+ /* count the number of enabled outputs */
+ for (i = 0, p = -1; nextEnabledOutput(config, enabled, &p); i++);
- if (i != 1)
- break;
+ if (i != 1)
+ break;
- p = -1;
- nextEnabledOutput(config, enabled, &p);
- if (config->output[p]->mm_height)
- aspect = (float)config->output[p]->mm_width /
- (float)config->output[p]->mm_height;
+ p = -1;
+ nextEnabledOutput(config, enabled, &p);
+ if (config->output[p]->mm_height)
+ aspect = (float) config->output[p]->mm_width /
+ (float) config->output[p]->mm_height;
- if (aspect)
- preferred_match[p] = bestModeForAspect(config, enabled, aspect);
+ if (aspect)
+ preferred_match[p] = bestModeForAspect(config, enabled, aspect);
- if (preferred_match[p])
- ret = TRUE;
+ if (preferred_match[p])
+ ret = TRUE;
- } while (0);
+ } while (0);
if (ret) {
- /* oh good, there is a match. stash the selected modes and return. */
- memcpy(modes, preferred_match,
- config->num_output * sizeof(DisplayModePtr));
+ /* oh good, there is a match. stash the selected modes and return. */
+ memcpy(modes, preferred_match,
+ config->num_output * sizeof(DisplayModePtr));
}
free(preferred);
@@ -2148,8 +2094,7 @@ xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
static Bool
xf86TargetAspect(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
- DisplayModePtr *modes, Bool *enabled,
- int width, int height)
+ DisplayModePtr * modes, Bool *enabled, int width, int height)
{
int o;
float aspect = 0.0, *aspects;
@@ -2160,51 +2105,51 @@ xf86TargetAspect(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
aspects = xnfcalloc(config->num_output, sizeof(float));
/* collect the aspect ratios */
- for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
- output = config->output[o];
- if (output->mm_height)
- aspects[o] = (float)output->mm_width / (float)output->mm_height;
- else
- aspects[o] = 4.0 / 3.0;
+ for (o = -1; nextEnabledOutput(config, enabled, &o);) {
+ output = config->output[o];
+ if (output->mm_height)
+ aspects[o] = (float) output->mm_width / (float) output->mm_height;
+ else
+ aspects[o] = 4.0 / 3.0;
}
/* check that they're all the same */
- for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
- output = config->output[o];
- if (!aspect) {
- aspect = aspects[o];
- } else if (!aspectMatch(aspect, aspects[o])) {
- goto no_aspect_match;
- }
+ for (o = -1; nextEnabledOutput(config, enabled, &o);) {
+ output = config->output[o];
+ if (!aspect) {
+ aspect = aspects[o];
+ }
+ else if (!aspectMatch(aspect, aspects[o])) {
+ goto no_aspect_match;
+ }
}
/* if they're all 4:3, just skip ahead and save effort */
- if (!aspectMatch(aspect, 4.0/3.0))
- aspect_guess = bestModeForAspect(config, enabled, aspect);
+ if (!aspectMatch(aspect, 4.0 / 3.0))
+ aspect_guess = bestModeForAspect(config, enabled, aspect);
-no_aspect_match:
- base_guess = bestModeForAspect(config, enabled, 4.0/3.0);
+ no_aspect_match:
+ base_guess = bestModeForAspect(config, enabled, 4.0 / 3.0);
guess = biggestMode(base_guess, aspect_guess);
if (!guess)
- goto out;
+ goto out;
/* found a mode that works everywhere, now apply it */
- for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
- modes[o] = xf86OutputFindClosestMode(config->output[o], guess);
+ for (o = -1; nextEnabledOutput(config, enabled, &o);) {
+ modes[o] = xf86OutputFindClosestMode(config->output[o], guess);
}
ret = TRUE;
-out:
+ out:
free(aspects);
return ret;
}
static Bool
xf86TargetFallback(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
- DisplayModePtr *modes, Bool *enabled,
- int width, int height)
+ DisplayModePtr * modes, Bool *enabled, int width, int height)
{
DisplayModePtr target_mode = NULL;
Rotation target_rotation = RR_Rotate_0;
@@ -2212,30 +2157,30 @@ xf86TargetFallback(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
int default_preferred, target_preferred = 0, o;
/* User preferred > preferred > other modes */
- for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
- default_mode = xf86DefaultMode (config->output[o], width, height);
- if (!default_mode)
- continue;
-
- default_preferred = (((default_mode->type & M_T_PREFERRED) != 0) +
- ((default_mode->type & M_T_USERPREF) != 0));
-
- if (default_preferred > target_preferred || !target_mode) {
- target_mode = default_mode;
- target_preferred = default_preferred;
- target_rotation = config->output[o]->initial_rotation;
- config->compat_output = o;
- }
+ for (o = -1; nextEnabledOutput(config, enabled, &o);) {
+ default_mode = xf86DefaultMode(config->output[o], width, height);
+ if (!default_mode)
+ continue;
+
+ default_preferred = (((default_mode->type & M_T_PREFERRED) != 0) +
+ ((default_mode->type & M_T_USERPREF) != 0));
+
+ if (default_preferred > target_preferred || !target_mode) {
+ target_mode = default_mode;
+ target_preferred = default_preferred;
+ target_rotation = config->output[o]->initial_rotation;
+ config->compat_output = o;
+ }
}
if (target_mode)
- modes[config->compat_output] = target_mode;
+ modes[config->compat_output] = target_mode;
/* Fill in other output modes */
- for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
- if (!modes[o])
- modes[o] = xf86ClosestMode(config->output[o], target_mode,
- target_rotation, width, height);
+ for (o = -1; nextEnabledOutput(config, enabled, &o);) {
+ if (!modes[o])
+ modes[o] = xf86ClosestMode(config->output[o], target_mode,
+ target_rotation, width, height);
}
return target_mode != NULL;
@@ -2243,25 +2188,24 @@ xf86TargetFallback(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
static Bool
xf86TargetUserpref(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
- DisplayModePtr *modes, Bool *enabled,
- int width, int height)
+ DisplayModePtr * modes, Bool *enabled, int width, int height)
{
int o;
if (xf86UserConfiguredOutputs(scrn, modes))
- return xf86TargetFallback(scrn, config, modes, enabled, width, height);
-
- for (o = -1; nextEnabledOutput(config, enabled, &o); )
- if (xf86OutputHasUserPreferredMode(config->output[o]))
- return
- xf86TargetFallback(scrn, config, modes, enabled, width, height);
+ return xf86TargetFallback(scrn, config, modes, enabled, width, height);
+
+ for (o = -1; nextEnabledOutput(config, enabled, &o);)
+ if (xf86OutputHasUserPreferredMode(config->output[o]))
+ return
+ xf86TargetFallback(scrn, config, modes, enabled, width, height);
return FALSE;
}
static Bool
xf86CrtcSetInitialGamma(xf86CrtcPtr crtc, float gamma_red, float gamma_green,
- float gamma_blue)
+ float gamma_blue)
{
int i, size = 256;
CARD16 *red, *green, *blue;
@@ -2270,14 +2214,16 @@ xf86CrtcSetInitialGamma(xf86CrtcPtr crtc, float gamma_red, float gamma_green,
green = red + size;
blue = green + size;
- /* Only cause warning if user wanted gamma to be set. */
- if (!crtc->funcs->gamma_set && (gamma_red != 1.0 || gamma_green != 1.0 || gamma_blue != 1.0)) {
+ /* Only cause warning if user wanted gamma to be set. */
+ if (!crtc->funcs->gamma_set &&
+ (gamma_red != 1.0 || gamma_green != 1.0 || gamma_blue != 1.0)) {
free(red);
return FALSE;
- } else if (!crtc->funcs->gamma_set) {
+ }
+ else if (!crtc->funcs->gamma_set) {
free(red);
return TRUE;
- }
+ }
/* At this early stage none of the randr-interface stuff is up.
* So take the default gamma size for lack of something better.
@@ -2286,32 +2232,37 @@ xf86CrtcSetInitialGamma(xf86CrtcPtr crtc, float gamma_red, float gamma_green,
if (gamma_red == 1.0)
red[i] = i << 8;
else
- red[i] = (CARD16)(pow((double)i/(double)(size - 1),
- 1. / (double)gamma_red) * (double)(size - 1) * 256);
+ red[i] = (CARD16) (pow((double) i / (double) (size - 1),
+ 1. / (double) gamma_red) * (double) (size -
+ 1) *
+ 256);
if (gamma_green == 1.0)
green[i] = i << 8;
else
- green[i] = (CARD16)(pow((double)i/(double)(size - 1),
- 1. / (double)gamma_green) * (double)(size - 1) * 256);
+ green[i] = (CARD16) (pow((double) i / (double) (size - 1),
+ 1. / (double) gamma_green) *
+ (double) (size - 1) * 256);
if (gamma_blue == 1.0)
blue[i] = i << 8;
else
- blue[i] = (CARD16)(pow((double)i/(double)(size - 1),
- 1. / (double)gamma_blue) * (double)(size - 1) * 256);
+ blue[i] = (CARD16) (pow((double) i / (double) (size - 1),
+ 1. / (double) gamma_blue) * (double) (size -
+ 1) *
+ 256);
}
/* Default size is 256, so anything else is failure. */
if (size != crtc->gamma_size) {
free(red);
return FALSE;
- }
+ }
crtc->gamma_size = size;
- memcpy (crtc->gamma_red, red, crtc->gamma_size * sizeof (CARD16));
- memcpy (crtc->gamma_green, green, crtc->gamma_size * sizeof (CARD16));
- memcpy (crtc->gamma_blue, blue, crtc->gamma_size * sizeof (CARD16));
+ memcpy(crtc->gamma_red, red, crtc->gamma_size * sizeof(CARD16));
+ memcpy(crtc->gamma_green, green, crtc->gamma_size * sizeof(CARD16));
+ memcpy(crtc->gamma_blue, blue, crtc->gamma_size * sizeof(CARD16));
/* Do not set gamma now, delay until the crtc is activated. */
@@ -2325,7 +2276,7 @@ xf86OutputSetInitialGamma(xf86OutputPtr output)
{
XF86ConfMonitorPtr mon = output->conf_monitor;
float gamma_red = 1.0, gamma_green = 1.0, gamma_blue = 1.0;
-
+
if (!mon)
return TRUE;
@@ -2333,24 +2284,25 @@ xf86OutputSetInitialGamma(xf86OutputPtr output)
return FALSE;
/* Get configured values, where they exist. */
- if (mon->mon_gamma_red >= GAMMA_MIN &&
- mon->mon_gamma_red <= GAMMA_MAX)
- gamma_red = mon->mon_gamma_red;
+ if (mon->mon_gamma_red >= GAMMA_MIN && mon->mon_gamma_red <= GAMMA_MAX)
+ gamma_red = mon->mon_gamma_red;
- if (mon->mon_gamma_green >= GAMMA_MIN &&
- mon->mon_gamma_green <= GAMMA_MAX)
- gamma_green = mon->mon_gamma_green;
+ if (mon->mon_gamma_green >= GAMMA_MIN && mon->mon_gamma_green <= GAMMA_MAX)
+ gamma_green = mon->mon_gamma_green;
- if (mon->mon_gamma_blue >= GAMMA_MIN &&
- mon->mon_gamma_blue <= GAMMA_MAX)
- gamma_blue = mon->mon_gamma_blue;
+ if (mon->mon_gamma_blue >= GAMMA_MIN && mon->mon_gamma_blue <= GAMMA_MAX)
+ gamma_blue = mon->mon_gamma_blue;
/* This avoids setting gamma 1.0 in case another cloned output on this crtc has a specific gamma. */
if (gamma_red != 1.0 || gamma_green != 1.0 || gamma_blue != 1.0) {
- xf86DrvMsg(output->scrn->scrnIndex, X_INFO, "Output %s wants gamma correction (%.1f, %.1f, %.1f)\n", output->name, gamma_red, gamma_green, gamma_blue);
- return xf86CrtcSetInitialGamma(output->crtc, gamma_red, gamma_green, gamma_blue);
- }else
- return TRUE;
+ xf86DrvMsg(output->scrn->scrnIndex, X_INFO,
+ "Output %s wants gamma correction (%.1f, %.1f, %.1f)\n",
+ output->name, gamma_red, gamma_green, gamma_blue);
+ return xf86CrtcSetInitialGamma(output->crtc, gamma_red, gamma_green,
+ gamma_blue);
+ }
+ else
+ return TRUE;
}
/**
@@ -2368,177 +2320,183 @@ xf86OutputSetInitialGamma(xf86OutputPtr output)
*/
Bool
-xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
-{
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
- int o, c;
- xf86CrtcPtr *crtcs;
- DisplayModePtr *modes;
- Bool *enabled;
- int width, height;
- int i = scrn->scrnIndex;
+xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow)
+{
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ int o, c;
+ xf86CrtcPtr *crtcs;
+ DisplayModePtr *modes;
+ Bool *enabled;
+ int width, height;
+ int i = scrn->scrnIndex;
Bool have_outputs = TRUE;
Bool ret;
Bool success = FALSE;
/* Set up the device options */
- config->options = xnfalloc (sizeof (xf86DeviceOptions));
- memcpy (config->options, xf86DeviceOptions, sizeof (xf86DeviceOptions));
- xf86ProcessOptions (scrn->scrnIndex,
- scrn->options,
- config->options);
- config->debug_modes = xf86ReturnOptValBool (config->options,
- OPTION_MODEDEBUG, FALSE);
+ config->options = xnfalloc(sizeof(xf86DeviceOptions));
+ memcpy(config->options, xf86DeviceOptions, sizeof(xf86DeviceOptions));
+ xf86ProcessOptions(scrn->scrnIndex, scrn->options, config->options);
+ config->debug_modes = xf86ReturnOptValBool(config->options,
+ OPTION_MODEDEBUG, FALSE);
if (scrn->display->virtualX)
- width = scrn->display->virtualX;
+ width = scrn->display->virtualX;
else
- width = config->maxWidth;
+ width = config->maxWidth;
if (scrn->display->virtualY)
- height = scrn->display->virtualY;
+ height = scrn->display->virtualY;
else
- height = config->maxHeight;
+ height = config->maxHeight;
- xf86ProbeOutputModes (scrn, width, height);
+ xf86ProbeOutputModes(scrn, width, height);
+
+ crtcs = xnfcalloc(config->num_output, sizeof(xf86CrtcPtr));
+ modes = xnfcalloc(config->num_output, sizeof(DisplayModePtr));
+ enabled = xnfcalloc(config->num_output, sizeof(Bool));
- crtcs = xnfcalloc (config->num_output, sizeof (xf86CrtcPtr));
- modes = xnfcalloc (config->num_output, sizeof (DisplayModePtr));
- enabled = xnfcalloc (config->num_output, sizeof (Bool));
-
ret = xf86CollectEnabledOutputs(scrn, config, enabled);
if (ret == FALSE && canGrow) {
- xf86DrvMsg(i, X_WARNING, "Unable to find connected outputs - setting %dx%d initial framebuffer\n",
- NO_OUTPUT_DEFAULT_WIDTH, NO_OUTPUT_DEFAULT_HEIGHT);
- have_outputs = FALSE;
- } else {
- if (xf86TargetUserpref(scrn, config, modes, enabled, width, height))
- xf86DrvMsg(i, X_INFO, "Using user preference for initial modes\n");
- else if (xf86TargetPreferred(scrn, config, modes, enabled, width, height))
- xf86DrvMsg(i, X_INFO, "Using exact sizes for initial modes\n");
- else if (xf86TargetAspect(scrn, config, modes, enabled, width, height))
- xf86DrvMsg(i, X_INFO, "Using fuzzy aspect match for initial modes\n");
- else if (xf86TargetFallback(scrn, config, modes, enabled, width, height))
- xf86DrvMsg(i, X_INFO, "Using sloppy heuristic for initial modes\n");
- else
- xf86DrvMsg(i, X_WARNING, "Unable to find initial modes\n");
- }
-
- for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
- if (!modes[o])
- xf86DrvMsg (scrn->scrnIndex, X_ERROR,
- "Output %s enabled but has no modes\n",
- config->output[o]->name);
- else
- xf86DrvMsg (scrn->scrnIndex, X_INFO,
- "Output %s using initial mode %s\n",
- config->output[o]->name, modes[o]->name);
+ xf86DrvMsg(i, X_WARNING,
+ "Unable to find connected outputs - setting %dx%d initial framebuffer\n",
+ NO_OUTPUT_DEFAULT_WIDTH, NO_OUTPUT_DEFAULT_HEIGHT);
+ have_outputs = FALSE;
+ }
+ else {
+ if (xf86TargetUserpref(scrn, config, modes, enabled, width, height))
+ xf86DrvMsg(i, X_INFO, "Using user preference for initial modes\n");
+ else if (xf86TargetPreferred
+ (scrn, config, modes, enabled, width, height))
+ xf86DrvMsg(i, X_INFO, "Using exact sizes for initial modes\n");
+ else if (xf86TargetAspect(scrn, config, modes, enabled, width, height))
+ xf86DrvMsg(i, X_INFO,
+ "Using fuzzy aspect match for initial modes\n");
+ else if (xf86TargetFallback
+ (scrn, config, modes, enabled, width, height))
+ xf86DrvMsg(i, X_INFO, "Using sloppy heuristic for initial modes\n");
+ else
+ xf86DrvMsg(i, X_WARNING, "Unable to find initial modes\n");
+ }
+
+ for (o = -1; nextEnabledOutput(config, enabled, &o);) {
+ if (!modes[o])
+ xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+ "Output %s enabled but has no modes\n",
+ config->output[o]->name);
+ else
+ xf86DrvMsg(scrn->scrnIndex, X_INFO,
+ "Output %s using initial mode %s\n",
+ config->output[o]->name, modes[o]->name);
}
/*
* Set the position of each output
*/
- if (!xf86InitialOutputPositions (scrn, modes))
- goto bailout;
+ if (!xf86InitialOutputPositions(scrn, modes))
+ goto bailout;
/*
* Set initial panning of each output
*/
- xf86InitialPanning (scrn);
-
+ xf86InitialPanning(scrn);
+
/*
* Assign CRTCs to fit output configuration
*/
- if (have_outputs && !xf86PickCrtcs (scrn, crtcs, modes, 0, width, height))
- goto bailout;
-
+ if (have_outputs && !xf86PickCrtcs(scrn, crtcs, modes, 0, width, height))
+ goto bailout;
+
/* XXX override xf86 common frame computation code */
-
+
scrn->display->frameX0 = 0;
scrn->display->frameY0 = 0;
-
- for (c = 0; c < config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = config->crtc[c];
- crtc->enabled = FALSE;
- memset (&crtc->desiredMode, '\0', sizeof (crtc->desiredMode));
- /* Set default gamma for all crtc's. */
- /* This is done to avoid problems later on with cloned outputs. */
- xf86CrtcSetInitialGamma(crtc, 1.0, 1.0, 1.0);
+ for (c = 0; c < config->num_crtc; c++) {
+ xf86CrtcPtr crtc = config->crtc[c];
+
+ crtc->enabled = FALSE;
+ memset(&crtc->desiredMode, '\0', sizeof(crtc->desiredMode));
+ /* Set default gamma for all crtc's. */
+ /* This is done to avoid problems later on with cloned outputs. */
+ xf86CrtcSetInitialGamma(crtc, 1.0, 1.0, 1.0);
}
if (xf86_crtc_supports_gamma(scrn))
- xf86DrvMsg(scrn->scrnIndex, X_INFO, "Using default gamma of (1.0, 1.0, 1.0) unless otherwise stated.\n");
+ xf86DrvMsg(scrn->scrnIndex, X_INFO,
+ "Using default gamma of (1.0, 1.0, 1.0) unless otherwise stated.\n");
/*
* Set initial configuration
*/
- for (o = 0; o < config->num_output; o++)
- {
- xf86OutputPtr output = config->output[o];
- DisplayModePtr mode = modes[o];
- xf86CrtcPtr crtc = crtcs[o];
-
- if (mode && crtc)
- {
- crtc->desiredMode = *mode;
- crtc->desiredRotation = output->initial_rotation;
- crtc->desiredX = output->initial_x;
- crtc->desiredY = output->initial_y;
- crtc->desiredTransformPresent = FALSE;
- crtc->enabled = TRUE;
- memcpy (&crtc->panningTotalArea, &output->initialTotalArea, sizeof(BoxRec));
- memcpy (&crtc->panningTrackingArea, &output->initialTrackingArea, sizeof(BoxRec));
- memcpy (crtc->panningBorder, output->initialBorder, 4*sizeof(INT16));
- output->crtc = crtc;
- if (!xf86OutputSetInitialGamma(output))
- xf86DrvMsg (scrn->scrnIndex, X_WARNING, "Initial gamma correction for output %s: failed.\n", output->name);
- } else {
- output->crtc = NULL;
- }
- }
-
- if (scrn->display->virtualX == 0)
- {
- /*
- * Expand virtual size to cover the current config and potential mode
- * switches, if the driver can't enlarge the screen later.
- */
- xf86DefaultScreenLimits (scrn, &width, &height, canGrow);
-
- if (have_outputs == FALSE) {
- if (width < NO_OUTPUT_DEFAULT_WIDTH && height < NO_OUTPUT_DEFAULT_HEIGHT) {
- width = NO_OUTPUT_DEFAULT_WIDTH;
- height = NO_OUTPUT_DEFAULT_HEIGHT;
- }
- }
-
- scrn->display->virtualX = width;
- scrn->display->virtualY = height;
+ for (o = 0; o < config->num_output; o++) {
+ xf86OutputPtr output = config->output[o];
+ DisplayModePtr mode = modes[o];
+ xf86CrtcPtr crtc = crtcs[o];
+
+ if (mode && crtc) {
+ crtc->desiredMode = *mode;
+ crtc->desiredRotation = output->initial_rotation;
+ crtc->desiredX = output->initial_x;
+ crtc->desiredY = output->initial_y;
+ crtc->desiredTransformPresent = FALSE;
+ crtc->enabled = TRUE;
+ memcpy(&crtc->panningTotalArea, &output->initialTotalArea,
+ sizeof(BoxRec));
+ memcpy(&crtc->panningTrackingArea, &output->initialTrackingArea,
+ sizeof(BoxRec));
+ memcpy(crtc->panningBorder, output->initialBorder,
+ 4 * sizeof(INT16));
+ output->crtc = crtc;
+ if (!xf86OutputSetInitialGamma(output))
+ xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+ "Initial gamma correction for output %s: failed.\n",
+ output->name);
+ }
+ else {
+ output->crtc = NULL;
+ }
+ }
+
+ if (scrn->display->virtualX == 0) {
+ /*
+ * Expand virtual size to cover the current config and potential mode
+ * switches, if the driver can't enlarge the screen later.
+ */
+ xf86DefaultScreenLimits(scrn, &width, &height, canGrow);
+
+ if (have_outputs == FALSE) {
+ if (width < NO_OUTPUT_DEFAULT_WIDTH &&
+ height < NO_OUTPUT_DEFAULT_HEIGHT) {
+ width = NO_OUTPUT_DEFAULT_WIDTH;
+ height = NO_OUTPUT_DEFAULT_HEIGHT;
+ }
+ }
+
+ scrn->display->virtualX = width;
+ scrn->display->virtualY = height;
}
if (width > scrn->virtualX)
- scrn->virtualX = width;
+ scrn->virtualX = width;
if (height > scrn->virtualY)
- scrn->virtualY = height;
+ scrn->virtualY = height;
/*
* Make sure the configuration isn't too small.
*/
if (width < config->minWidth || height < config->minHeight)
- goto bailout;
+ goto bailout;
/*
* Limit the crtc config to virtual[XY] if the driver can't grow the
* desktop.
*/
- if (!canGrow)
- {
- xf86CrtcSetSizeRange (scrn, config->minWidth, config->minHeight,
- width, height);
+ if (!canGrow) {
+ xf86CrtcSetSizeRange(scrn, config->minWidth, config->minHeight,
+ width, height);
}
- xf86SetScrnInfoModes (scrn);
+ xf86SetScrnInfoModes(scrn);
success = TRUE;
bailout:
@@ -2554,58 +2512,58 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
* since the driver will have to re-route things.
*/
static void
-xf86PrepareOutputs (ScrnInfoPtr scrn)
+xf86PrepareOutputs(ScrnInfoPtr scrn)
{
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
- int o;
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ int o;
for (o = 0; o < config->num_output; o++) {
- xf86OutputPtr output = config->output[o];
+ xf86OutputPtr output = config->output[o];
+
#if RANDR_GET_CRTC_INTERFACE
- /* Disable outputs that are unused or will be re-routed */
- if (!output->funcs->get_crtc ||
- output->crtc != (*output->funcs->get_crtc)(output) ||
- output->crtc == NULL)
+ /* Disable outputs that are unused or will be re-routed */
+ if (!output->funcs->get_crtc ||
+ output->crtc != (*output->funcs->get_crtc) (output) ||
+ output->crtc == NULL)
#endif
- (*output->funcs->dpms)(output, DPMSModeOff);
+ (*output->funcs->dpms) (output, DPMSModeOff);
}
}
static void
-xf86PrepareCrtcs (ScrnInfoPtr scrn)
+xf86PrepareCrtcs(ScrnInfoPtr scrn)
{
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
- int c;
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ int c;
for (c = 0; c < config->num_crtc; c++) {
#if RANDR_GET_CRTC_INTERFACE
- xf86CrtcPtr crtc = config->crtc[c];
- xf86OutputPtr output = NULL;
- uint32_t desired_outputs = 0, current_outputs = 0;
- int o;
-
- for (o = 0; o < config->num_output; o++) {
- output = config->output[o];
- if (output->crtc == crtc)
- desired_outputs |= (1<<o);
- /* If we can't tell where it's mapped, force it off */
- if (!output->funcs->get_crtc) {
- desired_outputs = 0;
- break;
- }
- if ((*output->funcs->get_crtc)(output) == crtc)
- current_outputs |= (1<<o);
- }
-
- /*
- * If mappings are different or the CRTC is unused,
- * we need to disable it
- */
- if (desired_outputs != current_outputs ||
- !desired_outputs)
- (*crtc->funcs->dpms)(crtc, DPMSModeOff);
+ xf86CrtcPtr crtc = config->crtc[c];
+ xf86OutputPtr output = NULL;
+ uint32_t desired_outputs = 0, current_outputs = 0;
+ int o;
+
+ for (o = 0; o < config->num_output; o++) {
+ output = config->output[o];
+ if (output->crtc == crtc)
+ desired_outputs |= (1 << o);
+ /* If we can't tell where it's mapped, force it off */
+ if (!output->funcs->get_crtc) {
+ desired_outputs = 0;
+ break;
+ }
+ if ((*output->funcs->get_crtc) (output) == crtc)
+ current_outputs |= (1 << o);
+ }
+
+ /*
+ * If mappings are different or the CRTC is unused,
+ * we need to disable it
+ */
+ if (desired_outputs != current_outputs || !desired_outputs)
+ (*crtc->funcs->dpms) (crtc, DPMSModeOff);
#else
- (*crtc->funcs->dpms)(crtc, DPMSModeOff);
+ (*crtc->funcs->dpms) (crtc, DPMSModeOff);
#endif
}
}
@@ -2616,67 +2574,65 @@ xf86PrepareCrtcs (ScrnInfoPtr scrn)
*/
Bool
-xf86SetDesiredModes (ScrnInfoPtr scrn)
+xf86SetDesiredModes(ScrnInfoPtr scrn)
{
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
- xf86CrtcPtr crtc = config->crtc[0];
- int c;
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86CrtcPtr crtc = config->crtc[0];
+ int c;
/* A driver with this hook will take care of this */
if (!crtc->funcs->set_mode_major) {
- xf86PrepareOutputs(scrn);
- xf86PrepareCrtcs(scrn);
- }
-
- for (c = 0; c < config->num_crtc; c++)
- {
- xf86OutputPtr output = NULL;
- int o;
- RRTransformPtr transform;
-
- crtc = config->crtc[c];
-
- /* Skip disabled CRTCs */
- if (!crtc->enabled)
- continue;
-
- if (xf86CompatOutput(scrn) && xf86CompatCrtc(scrn) == crtc)
- output = xf86CompatOutput(scrn);
- else
- {
- for (o = 0; o < config->num_output; o++)
- if (config->output[o]->crtc == crtc)
- {
- output = config->output[o];
- break;
- }
- }
- /* paranoia */
- if (!output)
- continue;
-
- /* Mark that we'll need to re-set the mode for sure */
- memset(&crtc->mode, 0, sizeof(crtc->mode));
- if (!crtc->desiredMode.CrtcHDisplay)
- {
- DisplayModePtr mode = xf86OutputFindClosestMode (output, scrn->currentMode);
-
- if (!mode)
- return FALSE;
- crtc->desiredMode = *mode;
- crtc->desiredRotation = RR_Rotate_0;
- crtc->desiredTransformPresent = FALSE;
- crtc->desiredX = 0;
- crtc->desiredY = 0;
- }
-
- if (crtc->desiredTransformPresent)
- transform = &crtc->desiredTransform;
- else
- transform = NULL;
- if (!xf86CrtcSetModeTransform (crtc, &crtc->desiredMode, crtc->desiredRotation,
- transform, crtc->desiredX, crtc->desiredY))
- return FALSE;
+ xf86PrepareOutputs(scrn);
+ xf86PrepareCrtcs(scrn);
+ }
+
+ for (c = 0; c < config->num_crtc; c++) {
+ xf86OutputPtr output = NULL;
+ int o;
+ RRTransformPtr transform;
+
+ crtc = config->crtc[c];
+
+ /* Skip disabled CRTCs */
+ if (!crtc->enabled)
+ continue;
+
+ if (xf86CompatOutput(scrn) && xf86CompatCrtc(scrn) == crtc)
+ output = xf86CompatOutput(scrn);
+ else {
+ for (o = 0; o < config->num_output; o++)
+ if (config->output[o]->crtc == crtc) {
+ output = config->output[o];
+ break;
+ }
+ }
+ /* paranoia */
+ if (!output)
+ continue;
+
+ /* Mark that we'll need to re-set the mode for sure */
+ memset(&crtc->mode, 0, sizeof(crtc->mode));
+ if (!crtc->desiredMode.CrtcHDisplay) {
+ DisplayModePtr mode =
+ xf86OutputFindClosestMode(output, scrn->currentMode);
+
+ if (!mode)
+ return FALSE;
+ crtc->desiredMode = *mode;
+ crtc->desiredRotation = RR_Rotate_0;
+ crtc->desiredTransformPresent = FALSE;
+ crtc->desiredX = 0;
+ crtc->desiredY = 0;
+ }
+
+ if (crtc->desiredTransformPresent)
+ transform = &crtc->desiredTransform;
+ else
+ transform = NULL;
+ if (!xf86CrtcSetModeTransform
+ (crtc, &crtc->desiredMode, crtc->desiredRotation, transform,
+ crtc->desiredX, crtc->desiredY))
+ return FALSE;
}
xf86DisableUnusedFunctions(scrn);
@@ -2694,56 +2650,52 @@ xf86SetDesiredModes (ScrnInfoPtr scrn)
*/
DisplayModePtr
-xf86OutputFindClosestMode (xf86OutputPtr output, DisplayModePtr desired)
-{
- DisplayModePtr best = NULL, scan = NULL;
-
- for (scan = output->probed_modes; scan != NULL; scan = scan->next)
- {
- /* If there's an exact match, we're done. */
- if (xf86ModesEqual(scan, desired)) {
- best = desired;
- break;
- }
-
- /* Reject if it's larger than the desired mode. */
- if (scan->HDisplay > desired->HDisplay ||
- scan->VDisplay > desired->VDisplay)
- {
- continue;
- }
-
- /*
- * If we haven't picked a best mode yet, use the first
- * one in the size range
- */
- if (best == NULL)
- {
- best = scan;
- continue;
- }
-
- /* Find if it's closer to the right size than the current best
- * option.
- */
- if ((scan->HDisplay > best->HDisplay &&
- scan->VDisplay >= best->VDisplay) ||
- (scan->HDisplay >= best->HDisplay &&
- scan->VDisplay > best->VDisplay))
- {
- best = scan;
- continue;
- }
-
- /* Find if it's still closer to the right refresh than the current
- * best resolution.
- */
- if (scan->HDisplay == best->HDisplay &&
- scan->VDisplay == best->VDisplay &&
- (fabs(scan->VRefresh - desired->VRefresh) <
- fabs(best->VRefresh - desired->VRefresh))) {
- best = scan;
- }
+xf86OutputFindClosestMode(xf86OutputPtr output, DisplayModePtr desired)
+{
+ DisplayModePtr best = NULL, scan = NULL;
+
+ for (scan = output->probed_modes; scan != NULL; scan = scan->next) {
+ /* If there's an exact match, we're done. */
+ if (xf86ModesEqual(scan, desired)) {
+ best = desired;
+ break;
+ }
+
+ /* Reject if it's larger than the desired mode. */
+ if (scan->HDisplay > desired->HDisplay ||
+ scan->VDisplay > desired->VDisplay) {
+ continue;
+ }
+
+ /*
+ * If we haven't picked a best mode yet, use the first
+ * one in the size range
+ */
+ if (best == NULL) {
+ best = scan;
+ continue;
+ }
+
+ /* Find if it's closer to the right size than the current best
+ * option.
+ */
+ if ((scan->HDisplay > best->HDisplay &&
+ scan->VDisplay >= best->VDisplay) ||
+ (scan->HDisplay >= best->HDisplay &&
+ scan->VDisplay > best->VDisplay)) {
+ best = scan;
+ continue;
+ }
+
+ /* Find if it's still closer to the right refresh than the current
+ * best resolution.
+ */
+ if (scan->HDisplay == best->HDisplay &&
+ scan->VDisplay == best->VDisplay &&
+ (fabs(scan->VRefresh - desired->VRefresh) <
+ fabs(best->VRefresh - desired->VRefresh))) {
+ best = scan;
+ }
}
return best;
}
@@ -2757,74 +2709,68 @@ xf86OutputFindClosestMode (xf86OutputPtr output, DisplayModePtr desired)
*/
Bool
-xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation)
+xf86SetSingleMode(ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation)
{
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- Bool ok = TRUE;
- xf86OutputPtr compat_output;
- DisplayModePtr compat_mode = NULL;
- int c;
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ Bool ok = TRUE;
+ xf86OutputPtr compat_output;
+ DisplayModePtr compat_mode = NULL;
+ int c;
/*
* Let the compat output drive the final mode selection
*/
compat_output = xf86CompatOutput(pScrn);
if (compat_output)
- compat_mode = xf86OutputFindClosestMode (compat_output, desired);
+ compat_mode = xf86OutputFindClosestMode(compat_output, desired);
if (compat_mode)
- desired = compat_mode;
-
- for (c = 0; c < config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = config->crtc[c];
- DisplayModePtr crtc_mode = NULL;
- int o;
-
- if (!crtc->enabled)
- continue;
-
- for (o = 0; o < config->num_output; o++)
- {
- xf86OutputPtr output = config->output[o];
- DisplayModePtr output_mode;
-
- /* skip outputs not on this crtc */
- if (output->crtc != crtc)
- continue;
-
- if (crtc_mode)
- {
- output_mode = xf86OutputFindClosestMode (output, crtc_mode);
- if (output_mode != crtc_mode)
- output->crtc = NULL;
- }
- else
- crtc_mode = xf86OutputFindClosestMode (output, desired);
- }
- if (!crtc_mode)
- {
- crtc->enabled = FALSE;
- continue;
- }
- if (!xf86CrtcSetModeTransform (crtc, crtc_mode, rotation, NULL, 0, 0))
- ok = FALSE;
- else
- {
- crtc->desiredMode = *crtc_mode;
- crtc->desiredRotation = rotation;
- crtc->desiredTransformPresent = FALSE;
- crtc->desiredX = 0;
- crtc->desiredY = 0;
- }
+ desired = compat_mode;
+
+ for (c = 0; c < config->num_crtc; c++) {
+ xf86CrtcPtr crtc = config->crtc[c];
+ DisplayModePtr crtc_mode = NULL;
+ int o;
+
+ if (!crtc->enabled)
+ continue;
+
+ for (o = 0; o < config->num_output; o++) {
+ xf86OutputPtr output = config->output[o];
+ DisplayModePtr output_mode;
+
+ /* skip outputs not on this crtc */
+ if (output->crtc != crtc)
+ continue;
+
+ if (crtc_mode) {
+ output_mode = xf86OutputFindClosestMode(output, crtc_mode);
+ if (output_mode != crtc_mode)
+ output->crtc = NULL;
+ }
+ else
+ crtc_mode = xf86OutputFindClosestMode(output, desired);
+ }
+ if (!crtc_mode) {
+ crtc->enabled = FALSE;
+ continue;
+ }
+ if (!xf86CrtcSetModeTransform(crtc, crtc_mode, rotation, NULL, 0, 0))
+ ok = FALSE;
+ else {
+ crtc->desiredMode = *crtc_mode;
+ crtc->desiredRotation = rotation;
+ crtc->desiredTransformPresent = FALSE;
+ crtc->desiredX = 0;
+ crtc->desiredY = 0;
+ }
}
xf86DisableUnusedFunctions(pScrn);
#ifdef RANDR_12_INTERFACE
- xf86RandR12TellChanged (pScrn->pScreen);
+ xf86RandR12TellChanged(pScrn->pScreen);
#endif
return ok;
}
-
/**
* Set the DPMS power mode of all outputs and CRTCs.
*
@@ -2834,32 +2780,35 @@ xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation)
void
xf86DPMSSet(ScrnInfoPtr scrn, int mode, int flags)
{
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
- int i;
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ int i;
if (!scrn->vtSema)
- return;
+ return;
if (mode == DPMSModeOff) {
- for (i = 0; i < config->num_output; i++) {
- xf86OutputPtr output = config->output[i];
- if (output->crtc != NULL)
- (*output->funcs->dpms) (output, mode);
- }
+ for (i = 0; i < config->num_output; i++) {
+ xf86OutputPtr output = config->output[i];
+
+ if (output->crtc != NULL)
+ (*output->funcs->dpms) (output, mode);
+ }
}
for (i = 0; i < config->num_crtc; i++) {
- xf86CrtcPtr crtc = config->crtc[i];
- if (crtc->enabled)
- (*crtc->funcs->dpms) (crtc, mode);
+ xf86CrtcPtr crtc = config->crtc[i];
+
+ if (crtc->enabled)
+ (*crtc->funcs->dpms) (crtc, mode);
}
if (mode != DPMSModeOff) {
- for (i = 0; i < config->num_output; i++) {
- xf86OutputPtr output = config->output[i];
- if (output->crtc != NULL)
- (*output->funcs->dpms) (output, mode);
- }
+ for (i = 0; i < config->num_output; i++) {
+ xf86OutputPtr output = config->output[i];
+
+ if (output->crtc != NULL)
+ (*output->funcs->dpms) (output, mode);
+ }
}
}
@@ -2875,9 +2824,9 @@ xf86SaveScreen(ScreenPtr pScreen, int mode)
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
if (xf86IsUnblank(mode))
- xf86DPMSSet(pScrn, DPMSModeOn, 0);
+ xf86DPMSSet(pScrn, DPMSModeOn, 0);
else
- xf86DPMSSet(pScrn, DPMSModeOff, 0);
+ xf86DPMSSet(pScrn, DPMSModeOff, 0);
return TRUE;
}
@@ -2888,32 +2837,30 @@ xf86SaveScreen(ScreenPtr pScreen, int mode)
void
xf86DisableUnusedFunctions(ScrnInfoPtr pScrn)
{
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
- int o, c;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int o, c;
+
+ for (o = 0; o < xf86_config->num_output; o++) {
+ xf86OutputPtr output = xf86_config->output[o];
- for (o = 0; o < xf86_config->num_output; o++)
- {
- xf86OutputPtr output = xf86_config->output[o];
- if (!output->crtc)
- (*output->funcs->dpms)(output, DPMSModeOff);
+ if (!output->crtc)
+ (*output->funcs->dpms) (output, DPMSModeOff);
}
- for (c = 0; c < xf86_config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = xf86_config->crtc[c];
+ for (c = 0; c < xf86_config->num_crtc; c++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
- if (!crtc->enabled)
- {
- crtc->funcs->dpms(crtc, DPMSModeOff);
- memset(&crtc->mode, 0, sizeof(crtc->mode));
- xf86RotateDestroy(crtc);
- crtc->active = FALSE;
- }
+ if (!crtc->enabled) {
+ crtc->funcs->dpms(crtc, DPMSModeOff);
+ memset(&crtc->mode, 0, sizeof(crtc->mode));
+ xf86RotateDestroy(crtc);
+ crtc->active = FALSE;
+ }
}
if (pScrn->pScreen)
- xf86_crtc_notify(pScrn->pScreen);
+ xf86_crtc_notify(pScrn->pScreen);
if (pScrn->ModeSet)
- pScrn->ModeSet(pScrn);
+ pScrn->ModeSet(pScrn);
}
#ifdef RANDR_12_INTERFACE
@@ -2924,19 +2871,20 @@ xf86DisableUnusedFunctions(ScrnInfoPtr pScrn)
* Set the RandR EDID property
*/
static void
-xf86OutputSetEDIDProperty (xf86OutputPtr output, void *data, int data_len)
+xf86OutputSetEDIDProperty(xf86OutputPtr output, void *data, int data_len)
{
Atom edid_atom = MakeAtom(EDID_ATOM_NAME, sizeof(EDID_ATOM_NAME) - 1, TRUE);
/* This may get called before the RandR resources have been created */
if (output->randr_output == NULL)
- return;
+ return;
if (data_len != 0) {
- RRChangeOutputProperty(output->randr_output, edid_atom, XA_INTEGER, 8,
- PropModeReplace, data_len, data, FALSE, TRUE);
- } else {
- RRDeleteOutputProperty(output->randr_output, edid_atom);
+ RRChangeOutputProperty(output->randr_output, edid_atom, XA_INTEGER, 8,
+ PropModeReplace, data_len, data, FALSE, TRUE);
+ }
+ else {
+ RRDeleteOutputProperty(output->randr_output, edid_atom);
}
}
@@ -2949,14 +2897,16 @@ struct det_phySize_parameter {
Bool ret;
};
-static void handle_detailed_physical_size(struct detailed_monitor_section
- *det_mon, void *data)
+static void
+handle_detailed_physical_size(struct detailed_monitor_section
+ *det_mon, void *data)
{
struct det_phySize_parameter *p;
- p = (struct det_phySize_parameter *)data;
- if (p->ret == TRUE )
- return ;
+ p = (struct det_phySize_parameter *) data;
+
+ if (p->ret == TRUE)
+ return;
xf86DetTimingApplyQuirks(det_mon, p->quirks,
p->output->MonInfo->features.hsize,
@@ -2975,25 +2925,26 @@ static void handle_detailed_physical_size(struct detailed_monitor_section
* Set the EDID information for the specified output
*/
void
-xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon)
+xf86OutputSetEDID(xf86OutputPtr output, xf86MonPtr edid_mon)
{
- ScrnInfoPtr scrn = output->scrn;
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
- Bool debug_modes = config->debug_modes || xf86Initialising;
+ ScrnInfoPtr scrn = output->scrn;
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ Bool debug_modes = config->debug_modes || xf86Initialising;
+
#ifdef RANDR_12_INTERFACE
- int size;
+ int size;
#endif
-
+
free(output->MonInfo);
-
+
output->MonInfo = edid_mon;
output->mm_width = 0;
output->mm_height = 0;
if (debug_modes) {
- xf86DrvMsg(scrn->scrnIndex, X_INFO, "EDID for output %s\n",
- output->name);
- xf86PrintEDID(edid_mon);
+ xf86DrvMsg(scrn->scrnIndex, X_INFO, "EDID for output %s\n",
+ output->name);
+ xf86PrintEDID(edid_mon);
}
/* Set the DDC properties for the 'compat' output */
@@ -3003,34 +2954,34 @@ xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon)
#ifdef RANDR_12_INTERFACE
/* Set the RandR output properties */
size = 0;
- if (edid_mon)
- {
- if (edid_mon->ver.version == 1) {
- size = 128;
- if (edid_mon->flags & EDID_COMPLETE_RAWDATA)
- size += edid_mon->no_sections * 128;
- } else if (edid_mon->ver.version == 2)
- size = 256;
- }
- xf86OutputSetEDIDProperty (output, edid_mon ? edid_mon->rawData : NULL, size);
+ if (edid_mon) {
+ if (edid_mon->ver.version == 1) {
+ size = 128;
+ if (edid_mon->flags & EDID_COMPLETE_RAWDATA)
+ size += edid_mon->no_sections * 128;
+ }
+ else if (edid_mon->ver.version == 2)
+ size = 256;
+ }
+ xf86OutputSetEDIDProperty(output, edid_mon ? edid_mon->rawData : NULL,
+ size);
#endif
if (edid_mon) {
struct det_phySize_parameter p;
+
p.output = output;
- p.quirks = xf86DDCDetectQuirks(scrn->scrnIndex,edid_mon, FALSE);
+ p.quirks = xf86DDCDetectQuirks(scrn->scrnIndex, edid_mon, FALSE);
p.ret = FALSE;
- xf86ForEachDetailedBlock(edid_mon,
- handle_detailed_physical_size, &p);
+ xf86ForEachDetailedBlock(edid_mon, handle_detailed_physical_size, &p);
- /* if no mm size is available from a detailed timing, check the max size field */
- if ((!output->mm_width || !output->mm_height) &&
- (edid_mon->features.hsize && edid_mon->features.vsize))
- {
- output->mm_width = edid_mon->features.hsize * 10;
- output->mm_height = edid_mon->features.vsize * 10;
- }
+ /* if no mm size is available from a detailed timing, check the max size field */
+ if ((!output->mm_width || !output->mm_height) &&
+ (edid_mon->features.hsize && edid_mon->features.vsize)) {
+ output->mm_width = edid_mon->features.hsize * 10;
+ output->mm_height = edid_mon->features.vsize * 10;
+ }
}
}
@@ -3039,21 +2990,21 @@ xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon)
* stored in 'output'
*/
DisplayModePtr
-xf86OutputGetEDIDModes (xf86OutputPtr output)
+xf86OutputGetEDIDModes(xf86OutputPtr output)
{
- ScrnInfoPtr scrn = output->scrn;
- xf86MonPtr edid_mon = output->MonInfo;
+ ScrnInfoPtr scrn = output->scrn;
+ xf86MonPtr edid_mon = output->MonInfo;
if (!edid_mon)
- return NULL;
+ return NULL;
return xf86DDCGetModes(scrn->scrnIndex, edid_mon);
}
/* maybe we should care about DDC1? meh. */
xf86MonPtr
-xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus)
+xf86OutputGetEDID(xf86OutputPtr output, I2CBusPtr pDDCBus)
{
- ScrnInfoPtr scrn = output->scrn;
+ ScrnInfoPtr scrn = output->scrn;
xf86MonPtr mon;
mon = xf86DoEEDID(scrn->scrnIndex, pDDCBus, TRUE);
@@ -3064,11 +3015,12 @@ xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus)
}
static const char *_xf86ConnectorNames[] = {
- "None", "VGA", "DVI-I", "DVI-D",
- "DVI-A", "Composite", "S-Video",
- "Component", "LFP", "Proprietary",
- "HDMI", "DisplayPort",
- };
+ "None", "VGA", "DVI-I", "DVI-D",
+ "DVI-A", "Composite", "S-Video",
+ "Component", "LFP", "Proprietary",
+ "HDMI", "DisplayPort",
+};
+
const char *
xf86ConnectorGetName(xf86ConnectorType connector)
{
@@ -3084,19 +3036,20 @@ x86_crtc_box_intersect(BoxPtr dest, BoxPtr a, BoxPtr b)
dest->y2 = a->y2 < b->y2 ? a->y2 : b->y2;
if (dest->x1 >= dest->x2 || dest->y1 >= dest->y2)
- dest->x1 = dest->x2 = dest->y1 = dest->y2 = 0;
+ dest->x1 = dest->x2 = dest->y1 = dest->y2 = 0;
}
static void
x86_crtc_box(xf86CrtcPtr crtc, BoxPtr crtc_box)
{
if (crtc->enabled) {
- crtc_box->x1 = crtc->x;
- crtc_box->x2 = crtc->x + xf86ModeWidth(&crtc->mode, crtc->rotation);
- crtc_box->y1 = crtc->y;
- crtc_box->y2 = crtc->y + xf86ModeHeight(&crtc->mode, crtc->rotation);
- } else
- crtc_box->x1 = crtc_box->x2 = crtc_box->y1 = crtc_box->y2 = 0;
+ crtc_box->x1 = crtc->x;
+ crtc_box->x2 = crtc->x + xf86ModeWidth(&crtc->mode, crtc->rotation);
+ crtc_box->y1 = crtc->y;
+ crtc_box->y2 = crtc->y + xf86ModeHeight(&crtc->mode, crtc->rotation);
+ }
+ else
+ crtc_box->x1 = crtc_box->x2 = crtc_box->y1 = crtc_box->y2 = 0;
}
static int
@@ -3114,15 +3067,13 @@ xf86_crtc_box_area(BoxPtr box)
static xf86CrtcPtr
xf86_covering_crtc(ScrnInfoPtr pScrn,
- BoxPtr box,
- xf86CrtcPtr desired,
- BoxPtr crtc_box_ret)
+ BoxPtr box, xf86CrtcPtr desired, BoxPtr crtc_box_ret)
{
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
- xf86CrtcPtr crtc, best_crtc;
- int coverage, best_coverage;
- int c;
- BoxRec crtc_box, cover_box;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ xf86CrtcPtr crtc, best_crtc;
+ int coverage, best_coverage;
+ int c;
+ BoxRec crtc_box, cover_box;
best_crtc = NULL;
best_coverage = 0;
@@ -3131,18 +3082,19 @@ xf86_covering_crtc(ScrnInfoPtr pScrn,
crtc_box_ret->y1 = 0;
crtc_box_ret->y2 = 0;
for (c = 0; c < xf86_config->num_crtc; c++) {
- crtc = xf86_config->crtc[c];
- x86_crtc_box(crtc, &crtc_box);
- x86_crtc_box_intersect(&cover_box, &crtc_box, box);
- coverage = xf86_crtc_box_area(&cover_box);
- if (coverage && crtc == desired) {
- *crtc_box_ret = crtc_box;
- return crtc;
- } else if (coverage > best_coverage) {
- *crtc_box_ret = crtc_box;
- best_crtc = crtc;
- best_coverage = coverage;
- }
+ crtc = xf86_config->crtc[c];
+ x86_crtc_box(crtc, &crtc_box);
+ x86_crtc_box_intersect(&cover_box, &crtc_box, box);
+ coverage = xf86_crtc_box_area(&cover_box);
+ if (coverage && crtc == desired) {
+ *crtc_box_ret = crtc_box;
+ return crtc;
+ }
+ else if (coverage > best_coverage) {
+ *crtc_box_ret = crtc_box;
+ best_crtc = crtc;
+ best_coverage = coverage;
+ }
}
return best_crtc;
}
@@ -3157,57 +3109,53 @@ xf86_covering_crtc(ScrnInfoPtr pScrn,
Bool
xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn,
- xf86CrtcPtr *crtc_ret,
- xf86CrtcPtr desired_crtc,
- BoxPtr dst,
- INT32 *xa,
- INT32 *xb,
- INT32 *ya,
- INT32 *yb,
- RegionPtr reg,
- INT32 width,
- INT32 height)
-{
- Bool ret;
- RegionRec crtc_region_local;
- RegionPtr crtc_region = reg;
-
- if (crtc_ret) {
- BoxRec crtc_box;
- xf86CrtcPtr crtc = xf86_covering_crtc(pScrn, dst,
- desired_crtc,
- &crtc_box);
+ xf86CrtcPtr * crtc_ret,
+ xf86CrtcPtr desired_crtc,
+ BoxPtr dst,
+ INT32 *xa,
+ INT32 *xb,
+ INT32 *ya,
+ INT32 *yb, RegionPtr reg, INT32 width, INT32 height)
+{
+ Bool ret;
+ RegionRec crtc_region_local;
+ RegionPtr crtc_region = reg;
- if (crtc) {
- RegionInit(&crtc_region_local, &crtc_box, 1);
- crtc_region = &crtc_region_local;
- RegionIntersect(crtc_region, crtc_region, reg);
- }
- *crtc_ret = crtc;
+ if (crtc_ret) {
+ BoxRec crtc_box;
+ xf86CrtcPtr crtc = xf86_covering_crtc(pScrn, dst,
+ desired_crtc,
+ &crtc_box);
+
+ if (crtc) {
+ RegionInit(&crtc_region_local, &crtc_box, 1);
+ crtc_region = &crtc_region_local;
+ RegionIntersect(crtc_region, crtc_region, reg);
+ }
+ *crtc_ret = crtc;
}
- ret = xf86XVClipVideoHelper(dst, xa, xb, ya, yb,
- crtc_region, width, height);
+ ret = xf86XVClipVideoHelper(dst, xa, xb, ya, yb,
+ crtc_region, width, height);
if (crtc_region != reg)
- RegionUninit(&crtc_region_local);
+ RegionUninit(&crtc_region_local);
return ret;
}
#endif
xf86_crtc_notify_proc_ptr
-xf86_wrap_crtc_notify (ScreenPtr screen, xf86_crtc_notify_proc_ptr new)
-{
- if (xf86CrtcConfigPrivateIndex != -1)
- {
- ScrnInfoPtr scrn = xf86Screens[screen->myNum];
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
- xf86_crtc_notify_proc_ptr old;
-
- old = config->xf86_crtc_notify;
- config->xf86_crtc_notify = new;
- return old;
+xf86_wrap_crtc_notify(ScreenPtr screen, xf86_crtc_notify_proc_ptr new)
+{
+ if (xf86CrtcConfigPrivateIndex != -1) {
+ ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86_crtc_notify_proc_ptr old;
+
+ old = config->xf86_crtc_notify;
+ config->xf86_crtc_notify = new;
+ return old;
}
return NULL;
}
@@ -3215,40 +3163,39 @@ xf86_wrap_crtc_notify (ScreenPtr screen, xf86_crtc_notify_proc_ptr new)
void
xf86_unwrap_crtc_notify(ScreenPtr screen, xf86_crtc_notify_proc_ptr old)
{
- if (xf86CrtcConfigPrivateIndex != -1)
- {
- ScrnInfoPtr scrn = xf86Screens[screen->myNum];
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
-
- config->xf86_crtc_notify = old;
+ if (xf86CrtcConfigPrivateIndex != -1) {
+ ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+
+ config->xf86_crtc_notify = old;
}
}
void
xf86_crtc_notify(ScreenPtr screen)
{
- ScrnInfoPtr scrn = xf86Screens[screen->myNum];
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
-
+ ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+
if (config->xf86_crtc_notify)
- config->xf86_crtc_notify(screen);
+ config->xf86_crtc_notify(screen);
}
Bool
xf86_crtc_supports_gamma(ScrnInfoPtr pScrn)
{
if (xf86CrtcConfigPrivateIndex != -1) {
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
- xf86CrtcPtr crtc;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ xf86CrtcPtr crtc;
- /* for multiple drivers loaded we need this */
- if (!xf86_config)
- return FALSE;
- if (xf86_config->num_crtc == 0)
- return FALSE;
- crtc = xf86_config->crtc[0];
+ /* for multiple drivers loaded we need this */
+ if (!xf86_config)
+ return FALSE;
+ if (xf86_config->num_crtc == 0)
+ return FALSE;
+ crtc = xf86_config->crtc[0];
- return crtc->funcs->gamma_set != NULL;
+ return crtc->funcs->gamma_set != NULL;
}
return FALSE;
diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.h b/xorg-server/hw/xfree86/modes/xf86Crtc.h
index 8d4a08938..a6a3c2e95 100644
--- a/xorg-server/hw/xfree86/modes/xf86Crtc.h
+++ b/xorg-server/hw/xfree86/modes/xf86Crtc.h
@@ -53,24 +53,24 @@ typedef struct _xf86Output xf86OutputRec, *xf86OutputPtr;
/* define a standard for connector types */
typedef enum _xf86ConnectorType {
- XF86ConnectorNone,
- XF86ConnectorVGA,
- XF86ConnectorDVI_I,
- XF86ConnectorDVI_D,
- XF86ConnectorDVI_A,
- XF86ConnectorComposite,
- XF86ConnectorSvideo,
- XF86ConnectorComponent,
- XF86ConnectorLFP,
- XF86ConnectorProprietary,
- XF86ConnectorHDMI,
- XF86ConnectorDisplayPort,
+ XF86ConnectorNone,
+ XF86ConnectorVGA,
+ XF86ConnectorDVI_I,
+ XF86ConnectorDVI_D,
+ XF86ConnectorDVI_A,
+ XF86ConnectorComposite,
+ XF86ConnectorSvideo,
+ XF86ConnectorComponent,
+ XF86ConnectorLFP,
+ XF86ConnectorProprietary,
+ XF86ConnectorHDMI,
+ XF86ConnectorDisplayPort,
} xf86ConnectorType;
typedef enum _xf86OutputStatus {
- XF86OutputStatusConnected,
- XF86OutputStatusDisconnected,
- XF86OutputStatusUnknown
+ XF86OutputStatusConnected,
+ XF86OutputStatusDisconnected,
+ XF86OutputStatusUnknown
} xf86OutputStatus;
typedef struct _xf86CrtcFuncs {
@@ -81,35 +81,34 @@ typedef struct _xf86CrtcFuncs {
* mode is DPMSModeOff, the crtc must be disabled sufficiently for it to
* be safe to call mode_set.
*/
- void
- (*dpms)(xf86CrtcPtr crtc,
- int mode);
+ void
+ (*dpms) (xf86CrtcPtr crtc, int mode);
/**
* Saves the crtc's state for restoration on VT switch.
*/
- void
- (*save)(xf86CrtcPtr crtc);
+ void
+ (*save) (xf86CrtcPtr crtc);
/**
* Restore's the crtc's state at VT switch.
*/
- void
- (*restore)(xf86CrtcPtr crtc);
+ void
+ (*restore) (xf86CrtcPtr crtc);
/**
* Lock CRTC prior to mode setting, mostly for DRI.
* Returns whether unlock is needed
*/
Bool
- (*lock) (xf86CrtcPtr crtc);
-
+ (*lock) (xf86CrtcPtr crtc);
+
/**
* Unlock CRTC after mode setting, mostly for DRI
*/
void
- (*unlock) (xf86CrtcPtr crtc);
-
+ (*unlock) (xf86CrtcPtr crtc);
+
/**
* Callback to adjust the mode to be set in the CRTC.
*
@@ -118,109 +117,106 @@ typedef struct _xf86CrtcFuncs {
* buses with clock limitations.
*/
Bool
- (*mode_fixup)(xf86CrtcPtr crtc,
- DisplayModePtr mode,
- DisplayModePtr adjusted_mode);
+ (*mode_fixup) (xf86CrtcPtr crtc,
+ DisplayModePtr mode, DisplayModePtr adjusted_mode);
/**
* Prepare CRTC for an upcoming mode set.
*/
void
- (*prepare)(xf86CrtcPtr crtc);
+ (*prepare) (xf86CrtcPtr crtc);
/**
* Callback for setting up a video mode after fixups have been made.
*/
void
- (*mode_set)(xf86CrtcPtr crtc,
- DisplayModePtr mode,
- DisplayModePtr adjusted_mode,
- int x, int y);
+ (*mode_set) (xf86CrtcPtr crtc,
+ DisplayModePtr mode,
+ DisplayModePtr adjusted_mode, int x, int y);
/**
* Commit mode changes to a CRTC
*/
void
- (*commit)(xf86CrtcPtr crtc);
+ (*commit) (xf86CrtcPtr crtc);
/* Set the color ramps for the CRTC to the given values. */
void
- (*gamma_set)(xf86CrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue,
- int size);
+ (*gamma_set) (xf86CrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue,
+ int size);
/**
* Allocate the shadow area, delay the pixmap creation until needed
*/
- void *
- (*shadow_allocate) (xf86CrtcPtr crtc, int width, int height);
-
+ void *(*shadow_allocate) (xf86CrtcPtr crtc, int width, int height);
+
/**
* Create shadow pixmap for rotation support
*/
PixmapPtr
- (*shadow_create) (xf86CrtcPtr crtc, void *data, int width, int height);
-
+ (*shadow_create) (xf86CrtcPtr crtc, void *data, int width, int height);
+
/**
* Destroy shadow pixmap
*/
void
- (*shadow_destroy) (xf86CrtcPtr crtc, PixmapPtr pPixmap, void *data);
+ (*shadow_destroy) (xf86CrtcPtr crtc, PixmapPtr pPixmap, void *data);
/**
* Set cursor colors
*/
void
- (*set_cursor_colors) (xf86CrtcPtr crtc, int bg, int fg);
+ (*set_cursor_colors) (xf86CrtcPtr crtc, int bg, int fg);
/**
* Set cursor position
*/
void
- (*set_cursor_position) (xf86CrtcPtr crtc, int x, int y);
+ (*set_cursor_position) (xf86CrtcPtr crtc, int x, int y);
/**
* Show cursor
*/
void
- (*show_cursor) (xf86CrtcPtr crtc);
+ (*show_cursor) (xf86CrtcPtr crtc);
/**
* Hide cursor
*/
void
- (*hide_cursor) (xf86CrtcPtr crtc);
+ (*hide_cursor) (xf86CrtcPtr crtc);
/**
* Load monochrome image
*/
void
- (*load_cursor_image) (xf86CrtcPtr crtc, CARD8 *image);
+ (*load_cursor_image) (xf86CrtcPtr crtc, CARD8 *image);
/**
* Load ARGB image
*/
- void
+ void
(*load_cursor_argb) (xf86CrtcPtr crtc, CARD32 *image);
-
+
/**
* Clean up driver-specific bits of the crtc
*/
void
- (*destroy) (xf86CrtcPtr crtc);
+ (*destroy) (xf86CrtcPtr crtc);
/**
* Less fine-grained mode setting entry point for kernel modesetting
*/
Bool
- (*set_mode_major)(xf86CrtcPtr crtc, DisplayModePtr mode,
- Rotation rotation, int x, int y);
+ (*set_mode_major) (xf86CrtcPtr crtc, DisplayModePtr mode,
+ Rotation rotation, int x, int y);
/**
* Callback for panning. Doesn't change the mode.
* Added in ABI version 2
*/
void
- (*set_origin)(xf86CrtcPtr crtc, int x, int y);
+ (*set_origin) (xf86CrtcPtr crtc, int x, int y);
} xf86CrtcFuncsRec, *xf86CrtcFuncsPtr;
@@ -235,15 +231,15 @@ struct _xf86Crtc {
/**
* Associated ScrnInfo
*/
- ScrnInfoPtr scrn;
-
+ ScrnInfoPtr scrn;
+
/**
* Desired state of this CRTC
*
* Set when this CRTC should be driving one or more outputs
*/
- Bool enabled;
-
+ Bool enabled;
+
/**
* Active mode
*
@@ -251,18 +247,18 @@ struct _xf86Crtc {
* It will be cleared when the VT is not active or
* during server startup
*/
- DisplayModeRec mode;
- Rotation rotation;
- PixmapPtr rotatedPixmap;
- void *rotatedData;
-
+ DisplayModeRec mode;
+ Rotation rotation;
+ PixmapPtr rotatedPixmap;
+ void *rotatedData;
+
/**
* Position on screen
*
* Locates this CRTC within the frame buffer
*/
- int x, y;
-
+ int x, y;
+
/**
* Desired mode
*
@@ -271,10 +267,10 @@ struct _xf86Crtc {
* the startup configured mode and saves the active mode
* on VT switch.
*/
- DisplayModeRec desiredMode;
- Rotation desiredRotation;
- int desiredX, desiredY;
-
+ DisplayModeRec desiredMode;
+ Rotation desiredRotation;
+ int desiredX, desiredY;
+
/** crtc-specific functions */
const xf86CrtcFuncsRec *funcs;
@@ -283,7 +279,7 @@ struct _xf86Crtc {
*
* Holds driver-private information
*/
- void *driver_private;
+ void *driver_private;
#ifdef RANDR_12_INTERFACE
/**
@@ -292,45 +288,45 @@ struct _xf86Crtc {
* When RandR 1.2 is available, this
* points at the associated crtc object
*/
- RRCrtcPtr randr_crtc;
+ RRCrtcPtr randr_crtc;
#else
- void *randr_crtc;
+ void *randr_crtc;
#endif
/**
* Current cursor is ARGB
*/
- Bool cursor_argb;
+ Bool cursor_argb;
/**
* Track whether cursor is within CRTC range
*/
- Bool cursor_in_range;
+ Bool cursor_in_range;
/**
* Track state of cursor associated with this CRTC
*/
- Bool cursor_shown;
+ Bool cursor_shown;
/**
* Current transformation matrix
*/
- PictTransform crtc_to_framebuffer;
+ PictTransform crtc_to_framebuffer;
/* framebuffer_to_crtc was removed in ABI 2 */
- struct pict_f_transform f_crtc_to_framebuffer; /* ABI 2 */
- struct pict_f_transform f_framebuffer_to_crtc; /* ABI 2 */
- PictFilterPtr filter; /* ABI 2 */
- xFixed *params; /* ABI 2 */
- int nparams; /* ABI 2 */
- int filter_width; /* ABI 2 */
- int filter_height; /* ABI 2 */
- Bool transform_in_use;
- RRTransformRec transform; /* ABI 2 */
- Bool transformPresent; /* ABI 2 */
- RRTransformRec desiredTransform; /* ABI 2 */
- Bool desiredTransformPresent; /* ABI 2 */
+ struct pict_f_transform f_crtc_to_framebuffer; /* ABI 2 */
+ struct pict_f_transform f_framebuffer_to_crtc; /* ABI 2 */
+ PictFilterPtr filter; /* ABI 2 */
+ xFixed *params; /* ABI 2 */
+ int nparams; /* ABI 2 */
+ int filter_width; /* ABI 2 */
+ int filter_height; /* ABI 2 */
+ Bool transform_in_use;
+ RRTransformRec transform; /* ABI 2 */
+ Bool transformPresent; /* ABI 2 */
+ RRTransformRec desiredTransform; /* ABI 2 */
+ Bool desiredTransformPresent; /* ABI 2 */
/**
* Bounding box in screen space
*/
- BoxRec bounds;
+ BoxRec bounds;
/**
* Panning:
* TotalArea: total panning area, larger than CRTC's size
@@ -338,9 +334,9 @@ struct _xf86Crtc {
* border: Borders of the displayed CRTC area which induces panning if the pointer reaches them
* Added in ABI version 2
*/
- BoxRec panningTotalArea;
- BoxRec panningTrackingArea;
- INT16 panningBorder[4];
+ BoxRec panningTotalArea;
+ BoxRec panningTrackingArea;
+ INT16 panningBorder[4];
/**
* Current gamma, especially useful after initial config.
@@ -357,11 +353,11 @@ struct _xf86Crtc {
* Set to TRUE after modesetting, set to FALSE if no outputs are connected
* Added in ABI version 3
*/
- Bool active;
+ Bool active;
/**
* Clear the shadow
*/
- Bool shadowClear;
+ Bool shadowClear;
/**
* Indicates that the driver is handling the transform, so the shadow
@@ -374,7 +370,7 @@ struct _xf86Crtc {
*
* Added in ABI version 4
*/
- Bool driverIsPerformingTransform;
+ Bool driverIsPerformingTransform;
};
typedef struct _xf86OutputFuncs {
@@ -383,7 +379,7 @@ typedef struct _xf86OutputFuncs {
* RandR objects have been created.
*/
void
- (*create_resources)(xf86OutputPtr output);
+ (*create_resources) (xf86OutputPtr output);
/**
* Turns the output on/off, or sets intermediate power levels if available.
@@ -393,20 +389,19 @@ typedef struct _xf86OutputFuncs {
* disabled afterwards.
*/
void
- (*dpms)(xf86OutputPtr output,
- int mode);
+ (*dpms) (xf86OutputPtr output, int mode);
/**
* Saves the output's state for restoration on VT switch.
*/
void
- (*save)(xf86OutputPtr output);
+ (*save) (xf86OutputPtr output);
/**
* Restore's the output's state at VT switch.
*/
void
- (*restore)(xf86OutputPtr output);
+ (*restore) (xf86OutputPtr output);
/**
* Callback for testing a video mode for a given output.
@@ -417,8 +412,7 @@ typedef struct _xf86OutputFuncs {
* \return MODE_OK if the mode is valid, or another MODE_* otherwise.
*/
int
- (*mode_valid)(xf86OutputPtr output,
- DisplayModePtr pMode);
+ (*mode_valid) (xf86OutputPtr output, DisplayModePtr pMode);
/**
* Callback to adjust the mode to be set in the CRTC.
@@ -428,21 +422,20 @@ typedef struct _xf86OutputFuncs {
* buses with clock limitations.
*/
Bool
- (*mode_fixup)(xf86OutputPtr output,
- DisplayModePtr mode,
- DisplayModePtr adjusted_mode);
+ (*mode_fixup) (xf86OutputPtr output,
+ DisplayModePtr mode, DisplayModePtr adjusted_mode);
/**
* Callback for preparing mode changes on an output
*/
void
- (*prepare)(xf86OutputPtr output);
+ (*prepare) (xf86OutputPtr output);
/**
* Callback for committing mode changes on an output
*/
void
- (*commit)(xf86OutputPtr output);
+ (*commit) (xf86OutputPtr output);
/**
* Callback for setting up a video mode after fixups have been made.
@@ -452,15 +445,13 @@ typedef struct _xf86OutputFuncs {
* after this function is called.
*/
void
- (*mode_set)(xf86OutputPtr output,
- DisplayModePtr mode,
- DisplayModePtr adjusted_mode);
+ (*mode_set) (xf86OutputPtr output,
+ DisplayModePtr mode, DisplayModePtr adjusted_mode);
/**
* Probe for a connected output, and return detect_status.
*/
- xf86OutputStatus
- (*detect)(xf86OutputPtr output);
+ xf86OutputStatus(*detect) (xf86OutputPtr output);
/**
* Query the device for the modes it provides.
@@ -469,41 +460,36 @@ typedef struct _xf86OutputFuncs {
*
* \return singly-linked list of modes or NULL if no modes found.
*/
- DisplayModePtr
- (*get_modes)(xf86OutputPtr output);
+ DisplayModePtr(*get_modes) (xf86OutputPtr output);
#ifdef RANDR_12_INTERFACE
/**
* Callback when an output's property has changed.
*/
Bool
- (*set_property)(xf86OutputPtr output,
- Atom property,
- RRPropertyValuePtr value);
+ (*set_property) (xf86OutputPtr output,
+ Atom property, RRPropertyValuePtr value);
#endif
#ifdef RANDR_13_INTERFACE
/**
* Callback to get an updated property value
*/
Bool
- (*get_property)(xf86OutputPtr output,
- Atom property);
+ (*get_property) (xf86OutputPtr output, Atom property);
#endif
#ifdef RANDR_GET_CRTC_INTERFACE
/**
* Callback to get current CRTC for a given output
*/
- xf86CrtcPtr
- (*get_crtc)(xf86OutputPtr output);
+ xf86CrtcPtr(*get_crtc) (xf86OutputPtr output);
#endif
/**
* Clean up driver-specific bits of the output
*/
void
- (*destroy) (xf86OutputPtr output);
+ (*destroy) (xf86OutputPtr output);
} xf86OutputFuncsRec, *xf86OutputFuncsPtr;
-
#define XF86_OUTPUT_VERSION 2
struct _xf86Output {
@@ -515,34 +501,34 @@ struct _xf86Output {
/**
* Associated ScrnInfo
*/
- ScrnInfoPtr scrn;
+ ScrnInfoPtr scrn;
/**
* Currently connected crtc (if any)
*
* If this output is not in use, this field will be NULL.
*/
- xf86CrtcPtr crtc;
+ xf86CrtcPtr crtc;
/**
* Possible CRTCs for this output as a mask of crtc indices
*/
- CARD32 possible_crtcs;
+ CARD32 possible_crtcs;
/**
* Possible outputs to share the same CRTC as a mask of output indices
*/
- CARD32 possible_clones;
-
+ CARD32 possible_clones;
+
/**
* Whether this output can support interlaced modes
*/
- Bool interlaceAllowed;
+ Bool interlaceAllowed;
/**
* Whether this output can support double scan modes
*/
- Bool doubleScanAllowed;
+ Bool doubleScanAllowed;
/**
* List of available modes on this output.
@@ -550,27 +536,27 @@ struct _xf86Output {
* This should be the list from get_modes(), plus perhaps additional
* compatible modes added later.
*/
- DisplayModePtr probed_modes;
+ DisplayModePtr probed_modes;
/**
* Options parsed from the related monitor section
*/
- OptionInfoPtr options;
-
+ OptionInfoPtr options;
+
/**
* Configured monitor section
*/
- XF86ConfMonitorPtr conf_monitor;
-
+ XF86ConfMonitorPtr conf_monitor;
+
/**
* Desired initial position
*/
- int initial_x, initial_y;
+ int initial_x, initial_y;
/**
* Desired initial rotation
*/
- Rotation initial_rotation;
+ Rotation initial_rotation;
/**
* Current connection status
@@ -578,28 +564,28 @@ struct _xf86Output {
* This indicates whether a monitor is known to be connected
* to this output or not, or whether there is no way to tell
*/
- xf86OutputStatus status;
+ xf86OutputStatus status;
/** EDID monitor information */
- xf86MonPtr MonInfo;
+ xf86MonPtr MonInfo;
/** subpixel order */
- int subpixel_order;
+ int subpixel_order;
/** Physical size of the currently attached output device. */
- int mm_width, mm_height;
+ int mm_width, mm_height;
/** Output name */
- char *name;
+ char *name;
/** output-specific functions */
const xf86OutputFuncsRec *funcs;
/** driver private information */
- void *driver_private;
-
+ void *driver_private;
+
/** Whether to use the old per-screen Monitor config section */
- Bool use_screen_monitor;
+ Bool use_screen_monitor;
#ifdef RANDR_12_INTERFACE
/**
@@ -608,17 +594,17 @@ struct _xf86Output {
* When RandR 1.2 is available, this points at the associated
* RandR output structure and is created when this output is created
*/
- RROutputPtr randr_output;
+ RROutputPtr randr_output;
#else
- void *randr_output;
+ void *randr_output;
#endif
/**
* Desired initial panning
* Added in ABI version 2
*/
- BoxRec initialTotalArea;
- BoxRec initialTrackingArea;
- INT16 initialBorder[4];
+ BoxRec initialTotalArea;
+ BoxRec initialTrackingArea;
+ INT16 initialBorder[4];
};
typedef struct _xf86CrtcConfigFuncs {
@@ -635,67 +621,65 @@ typedef struct _xf86CrtcConfigFuncs {
* pixmaps it may have moved, and change pScrn->displayWidth.
*/
Bool
- (*resize)(ScrnInfoPtr scrn,
- int width,
- int height);
+ (*resize) (ScrnInfoPtr scrn, int width, int height);
} xf86CrtcConfigFuncsRec, *xf86CrtcConfigFuncsPtr;
typedef void (*xf86_crtc_notify_proc_ptr) (ScreenPtr pScreen);
typedef struct _xf86CrtcConfig {
- int num_output;
- xf86OutputPtr *output;
+ int num_output;
+ xf86OutputPtr *output;
/**
* compat_output is used whenever we deal
* with legacy code that only understands a single
* output. pScrn->modes will be loaded from this output,
* adjust frame will whack this output, etc.
*/
- int compat_output;
+ int compat_output;
+
+ int num_crtc;
+ xf86CrtcPtr *crtc;
- int num_crtc;
- xf86CrtcPtr *crtc;
+ int minWidth, minHeight;
+ int maxWidth, maxHeight;
- int minWidth, minHeight;
- int maxWidth, maxHeight;
-
/* For crtc-based rotation */
- DamagePtr rotation_damage;
- Bool rotation_damage_registered;
+ DamagePtr rotation_damage;
+ Bool rotation_damage_registered;
/* DGA */
- unsigned int dga_flags;
- unsigned long dga_address;
- DGAModePtr dga_modes;
- int dga_nmode;
- int dga_width, dga_height, dga_stride;
- DisplayModePtr dga_save_mode;
+ unsigned int dga_flags;
+ unsigned long dga_address;
+ DGAModePtr dga_modes;
+ int dga_nmode;
+ int dga_width, dga_height, dga_stride;
+ DisplayModePtr dga_save_mode;
const xf86CrtcConfigFuncsRec *funcs;
- CreateScreenResourcesProcPtr CreateScreenResources;
+ CreateScreenResourcesProcPtr CreateScreenResources;
- CloseScreenProcPtr CloseScreen;
+ CloseScreenProcPtr CloseScreen;
/* Cursor information */
- xf86CursorInfoPtr cursor_info;
- CursorPtr cursor;
- CARD8 *cursor_image;
- Bool cursor_on;
- CARD32 cursor_fg, cursor_bg;
+ xf86CursorInfoPtr cursor_info;
+ CursorPtr cursor;
+ CARD8 *cursor_image;
+ Bool cursor_on;
+ CARD32 cursor_fg, cursor_bg;
/**
* Options parsed from the related device section
*/
- OptionInfoPtr options;
+ OptionInfoPtr options;
- Bool debug_modes;
+ Bool debug_modes;
/* wrap screen BlockHandler for rotation */
- ScreenBlockHandlerProcPtr BlockHandler;
+ ScreenBlockHandlerProcPtr BlockHandler;
/* callback when crtc configuration changes */
- xf86_crtc_notify_proc_ptr xf86_crtc_notify;
+ xf86_crtc_notify_proc_ptr xf86_crtc_notify;
} xf86CrtcConfigRec, *xf86CrtcConfigPtr;
@@ -707,6 +691,7 @@ static _X_INLINE xf86OutputPtr
xf86CompatOutput(ScrnInfoPtr pScrn)
{
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+
return config->output[config->compat_output];
}
@@ -714,156 +699,155 @@ static _X_INLINE xf86CrtcPtr
xf86CompatCrtc(ScrnInfoPtr pScrn)
{
xf86OutputPtr compat_output = xf86CompatOutput(pScrn);
+
if (!compat_output)
- return NULL;
+ return NULL;
return compat_output->crtc;
}
static _X_INLINE RRCrtcPtr
xf86CompatRRCrtc(ScrnInfoPtr pScrn)
{
- xf86CrtcPtr compat_crtc = xf86CompatCrtc(pScrn);
+ xf86CrtcPtr compat_crtc = xf86CompatCrtc(pScrn);
+
if (!compat_crtc)
- return NULL;
+ return NULL;
return compat_crtc->randr_crtc;
}
-
/*
* Initialize xf86CrtcConfig structure
*/
extern _X_EXPORT void
-xf86CrtcConfigInit (ScrnInfoPtr scrn,
- const xf86CrtcConfigFuncsRec *funcs);
+ xf86CrtcConfigInit(ScrnInfoPtr scrn, const xf86CrtcConfigFuncsRec * funcs);
extern _X_EXPORT void
-xf86CrtcSetSizeRange (ScrnInfoPtr scrn,
- int minWidth, int minHeight,
- int maxWidth, int maxHeight);
+
+xf86CrtcSetSizeRange(ScrnInfoPtr scrn,
+ int minWidth, int minHeight, int maxWidth, int maxHeight);
/*
* Crtc functions
*/
extern _X_EXPORT xf86CrtcPtr
-xf86CrtcCreate (ScrnInfoPtr scrn,
- const xf86CrtcFuncsRec *funcs);
+xf86CrtcCreate(ScrnInfoPtr scrn, const xf86CrtcFuncsRec * funcs);
extern _X_EXPORT void
-xf86CrtcDestroy (xf86CrtcPtr crtc);
-
+ xf86CrtcDestroy(xf86CrtcPtr crtc);
/**
* Sets the given video mode on the given crtc
*/
extern _X_EXPORT Bool
-xf86CrtcSetModeTransform (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
- RRTransformPtr transform, int x, int y);
+
+xf86CrtcSetModeTransform(xf86CrtcPtr crtc, DisplayModePtr mode,
+ Rotation rotation, RRTransformPtr transform, int x,
+ int y);
extern _X_EXPORT Bool
-xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
- int x, int y);
+
+xf86CrtcSetMode(xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
+ int x, int y);
extern _X_EXPORT void
-xf86CrtcSetOrigin (xf86CrtcPtr crtc, int x, int y);
+ xf86CrtcSetOrigin(xf86CrtcPtr crtc, int x, int y);
/*
* Assign crtc rotation during mode set
*/
extern _X_EXPORT Bool
-xf86CrtcRotate (xf86CrtcPtr crtc);
+ xf86CrtcRotate(xf86CrtcPtr crtc);
/*
* Clean up any rotation data, used when a crtc is turned off
* as well as when rotation is disabled.
*/
extern _X_EXPORT void
-xf86RotateDestroy (xf86CrtcPtr crtc);
+ xf86RotateDestroy(xf86CrtcPtr crtc);
/*
* free shadow memory allocated for all crtcs
*/
extern _X_EXPORT void
-xf86RotateFreeShadow(ScrnInfoPtr pScrn);
+ xf86RotateFreeShadow(ScrnInfoPtr pScrn);
/*
* Clean up rotation during CloseScreen
*/
extern _X_EXPORT void
-xf86RotateCloseScreen (ScreenPtr pScreen);
+ xf86RotateCloseScreen(ScreenPtr pScreen);
/**
* Return whether any output is assigned to the crtc
*/
extern _X_EXPORT Bool
-xf86CrtcInUse (xf86CrtcPtr crtc);
+ xf86CrtcInUse(xf86CrtcPtr crtc);
/*
* Output functions
*/
extern _X_EXPORT xf86OutputPtr
-xf86OutputCreate (ScrnInfoPtr scrn,
- const xf86OutputFuncsRec *funcs,
- const char *name);
+xf86OutputCreate(ScrnInfoPtr scrn,
+ const xf86OutputFuncsRec * funcs, const char *name);
extern _X_EXPORT void
-xf86OutputUseScreenMonitor (xf86OutputPtr output, Bool use_screen_monitor);
+ xf86OutputUseScreenMonitor(xf86OutputPtr output, Bool use_screen_monitor);
extern _X_EXPORT Bool
-xf86OutputRename (xf86OutputPtr output, const char *name);
+ xf86OutputRename(xf86OutputPtr output, const char *name);
extern _X_EXPORT void
-xf86OutputDestroy (xf86OutputPtr output);
+ xf86OutputDestroy(xf86OutputPtr output);
extern _X_EXPORT void
-xf86ProbeOutputModes (ScrnInfoPtr pScrn, int maxX, int maxY);
+ xf86ProbeOutputModes(ScrnInfoPtr pScrn, int maxX, int maxY);
extern _X_EXPORT void
-xf86SetScrnInfoModes (ScrnInfoPtr pScrn);
+ xf86SetScrnInfoModes(ScrnInfoPtr pScrn);
#ifdef RANDR_13_INTERFACE
-# define ScreenInitRetType int
+#define ScreenInitRetType int
#else
-# define ScreenInitRetType Bool
+#define ScreenInitRetType Bool
#endif
-extern _X_EXPORT ScreenInitRetType
-xf86CrtcScreenInit (ScreenPtr pScreen);
+extern _X_EXPORT ScreenInitRetType xf86CrtcScreenInit(ScreenPtr pScreen);
extern _X_EXPORT Bool
-xf86InitialConfiguration (ScrnInfoPtr pScrn, Bool canGrow);
+ xf86InitialConfiguration(ScrnInfoPtr pScrn, Bool canGrow);
extern _X_EXPORT void
-xf86DPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags);
-
+ xf86DPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags);
+
extern _X_EXPORT Bool
-xf86SaveScreen(ScreenPtr pScreen, int mode);
+ xf86SaveScreen(ScreenPtr pScreen, int mode);
extern _X_EXPORT void
-xf86DisableUnusedFunctions(ScrnInfoPtr pScrn);
+ xf86DisableUnusedFunctions(ScrnInfoPtr pScrn);
extern _X_EXPORT DisplayModePtr
-xf86OutputFindClosestMode (xf86OutputPtr output, DisplayModePtr desired);
-
+xf86OutputFindClosestMode(xf86OutputPtr output, DisplayModePtr desired);
+
extern _X_EXPORT Bool
-xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation);
+
+xf86SetSingleMode(ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation);
/**
* Set the EDID information for the specified output
*/
extern _X_EXPORT void
-xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon);
+ xf86OutputSetEDID(xf86OutputPtr output, xf86MonPtr edid_mon);
/**
* Return the list of modes supported by the EDID information
* stored in 'output'
*/
-extern _X_EXPORT DisplayModePtr
-xf86OutputGetEDIDModes (xf86OutputPtr output);
+extern _X_EXPORT DisplayModePtr xf86OutputGetEDIDModes(xf86OutputPtr output);
extern _X_EXPORT xf86MonPtr
-xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus);
+xf86OutputGetEDID(xf86OutputPtr output, I2CBusPtr pDDCBus);
/**
* Initialize dga for this screen
@@ -871,23 +855,23 @@ xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus);
#ifdef XFreeXDGA
extern _X_EXPORT Bool
-xf86DiDGAInit (ScreenPtr pScreen, unsigned long dga_address);
+ xf86DiDGAInit(ScreenPtr pScreen, unsigned long dga_address);
/* this is the real function, used only internally */
_X_INTERNAL Bool
-_xf86_di_dga_init_internal (ScreenPtr pScreen);
+ _xf86_di_dga_init_internal(ScreenPtr pScreen);
/**
* Re-initialize dga for this screen (as when the set of modes changes)
*/
extern _X_EXPORT Bool
-xf86DiDGAReInit (ScreenPtr pScreen);
+ xf86DiDGAReInit(ScreenPtr pScreen);
#endif
/* This is the real function, used only internally */
_X_INTERNAL Bool
-_xf86_di_dga_reinit_internal (ScreenPtr pScreen);
+ _xf86_di_dga_reinit_internal(ScreenPtr pScreen);
/*
* Set the subpixel order reported for the screen using
@@ -895,13 +879,12 @@ _xf86_di_dga_reinit_internal (ScreenPtr pScreen);
*/
extern _X_EXPORT void
-xf86CrtcSetScreenSubpixelOrder (ScreenPtr pScreen);
+ xf86CrtcSetScreenSubpixelOrder(ScreenPtr pScreen);
/*
* Get a standard string name for a connector type
*/
-extern _X_EXPORT const char *
-xf86ConnectorGetName(xf86ConnectorType connector);
+extern _X_EXPORT const char *xf86ConnectorGetName(xf86ConnectorType connector);
/*
* Using the desired mode information in each crtc, set
@@ -909,7 +892,7 @@ xf86ConnectorGetName(xf86ConnectorType connector);
*/
extern _X_EXPORT Bool
-xf86SetDesiredModes (ScrnInfoPtr pScrn);
+ xf86SetDesiredModes(ScrnInfoPtr pScrn);
/**
* Initialize the CRTC-based cursor code. CRTC function vectors must
@@ -918,7 +901,7 @@ xf86SetDesiredModes (ScrnInfoPtr pScrn);
* Driver should call this from ScreenInit function
*/
extern _X_EXPORT Bool
-xf86_cursors_init (ScreenPtr screen, int max_width, int max_height, int flags);
+ xf86_cursors_init(ScreenPtr screen, int max_width, int max_height, int flags);
/**
* Called when anything on the screen is reconfigured.
@@ -928,25 +911,25 @@ xf86_cursors_init (ScreenPtr screen, int max_width, int max_height, int flags);
* Driver should call this from crtc commit function.
*/
extern _X_EXPORT void
-xf86_reload_cursors (ScreenPtr screen);
+ xf86_reload_cursors(ScreenPtr screen);
/**
* Called from EnterVT to turn the cursors back on
*/
extern _X_EXPORT void
-xf86_show_cursors (ScrnInfoPtr scrn);
+ xf86_show_cursors(ScrnInfoPtr scrn);
/**
* Called by the driver to turn cursors off
*/
extern _X_EXPORT void
-xf86_hide_cursors (ScrnInfoPtr scrn);
+ xf86_hide_cursors(ScrnInfoPtr scrn);
/**
* Clean up CRTC-based cursor code. Driver must call this at CloseScreen time.
*/
extern _X_EXPORT void
-xf86_cursors_fini (ScreenPtr screen);
+ xf86_cursors_fini(ScreenPtr screen);
/**
* Transform the cursor's coordinates based on the crtc transform. Normally
@@ -954,7 +937,7 @@ xf86_cursors_fini (ScreenPtr screen);
* then the server does not transform the cursor position automatically.
*/
extern _X_EXPORT void
-xf86CrtcTransformCursorPos (xf86CrtcPtr crtc, int *x, int *y);
+ xf86CrtcTransformCursorPos(xf86CrtcPtr crtc, int *x, int *y);
#ifdef XV
/*
@@ -964,33 +947,32 @@ xf86CrtcTransformCursorPos (xf86CrtcPtr crtc, int *x, int *y);
*/
extern _X_EXPORT Bool
+
xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn,
- xf86CrtcPtr *crtc_ret,
- xf86CrtcPtr desired_crtc,
- BoxPtr dst,
- INT32 *xa,
- INT32 *xb,
- INT32 *ya,
- INT32 *yb,
- RegionPtr reg,
- INT32 width,
- INT32 height);
+ xf86CrtcPtr * crtc_ret,
+ xf86CrtcPtr desired_crtc,
+ BoxPtr dst,
+ INT32 *xa,
+ INT32 *xb,
+ INT32 *ya,
+ INT32 *yb,
+ RegionPtr reg, INT32 width, INT32 height);
#endif
-
+
extern _X_EXPORT xf86_crtc_notify_proc_ptr
-xf86_wrap_crtc_notify (ScreenPtr pScreen, xf86_crtc_notify_proc_ptr new);
+xf86_wrap_crtc_notify(ScreenPtr pScreen, xf86_crtc_notify_proc_ptr new);
extern _X_EXPORT void
-xf86_unwrap_crtc_notify(ScreenPtr pScreen, xf86_crtc_notify_proc_ptr old);
+ xf86_unwrap_crtc_notify(ScreenPtr pScreen, xf86_crtc_notify_proc_ptr old);
extern _X_EXPORT void
-xf86_crtc_notify(ScreenPtr pScreen);
+ xf86_crtc_notify(ScreenPtr pScreen);
/**
* Gamma
*/
extern _X_EXPORT Bool
-xf86_crtc_supports_gamma(ScrnInfoPtr pScrn);
+ xf86_crtc_supports_gamma(ScrnInfoPtr pScrn);
-#endif /* _XF86CRTC_H_ */
+#endif /* _XF86CRTC_H_ */
diff --git a/xorg-server/hw/xfree86/modes/xf86Cursors.c b/xorg-server/hw/xfree86/modes/xf86Cursors.c
index 669da0d5b..95a78921d 100644
--- a/xorg-server/hw/xfree86/modes/xf86Cursors.c
+++ b/xorg-server/hw/xfree86/modes/xf86Cursors.c
@@ -52,10 +52,10 @@
* that it's handling the screen transform, then this returns RR_Rotate_0.
*/
static Rotation
-xf86_crtc_cursor_rotation (xf86CrtcPtr crtc)
+xf86_crtc_cursor_rotation(xf86CrtcPtr crtc)
{
if (crtc->driverIsPerformingTransform)
- return RR_Rotate_0;
+ return RR_Rotate_0;
return crtc->rotation;
}
@@ -63,38 +63,34 @@ xf86_crtc_cursor_rotation (xf86CrtcPtr crtc)
* Given a screen coordinate, rotate back to a cursor source coordinate
*/
static void
-xf86_crtc_rotate_coord (Rotation rotation,
- int width,
- int height,
- int x_dst,
- int y_dst,
- int *x_src,
- int *y_src)
+xf86_crtc_rotate_coord(Rotation rotation,
+ int width,
+ int height, int x_dst, int y_dst, int *x_src, int *y_src)
{
int t;
-
+
switch (rotation & 0xf) {
case RR_Rotate_0:
- break;
+ break;
case RR_Rotate_90:
- t = x_dst;
- x_dst = height - y_dst - 1;
- y_dst = t;
- break;
+ t = x_dst;
+ x_dst = height - y_dst - 1;
+ y_dst = t;
+ break;
case RR_Rotate_180:
- x_dst = width - x_dst - 1;
- y_dst = height - y_dst - 1;
- break;
+ x_dst = width - x_dst - 1;
+ y_dst = height - y_dst - 1;
+ break;
case RR_Rotate_270:
- t = x_dst;
- x_dst = y_dst;
- y_dst = width - t - 1;
- break;
+ t = x_dst;
+ x_dst = y_dst;
+ y_dst = width - t - 1;
+ break;
}
if (rotation & RR_Reflect_X)
- x_dst = width - x_dst - 1;
+ x_dst = width - x_dst - 1;
if (rotation & RR_Reflect_Y)
- y_dst = height - y_dst - 1;
+ y_dst = height - y_dst - 1;
*x_src = x_dst;
*y_src = y_dst;
}
@@ -103,38 +99,35 @@ xf86_crtc_rotate_coord (Rotation rotation,
* Given a cursor source coordinate, rotate to a screen coordinate
*/
static void
-xf86_crtc_rotate_coord_back (Rotation rotation,
- int width,
- int height,
- int x_dst,
- int y_dst,
- int *x_src,
- int *y_src)
+xf86_crtc_rotate_coord_back(Rotation rotation,
+ int width,
+ int height,
+ int x_dst, int y_dst, int *x_src, int *y_src)
{
int t;
-
+
if (rotation & RR_Reflect_X)
- x_dst = width - x_dst - 1;
+ x_dst = width - x_dst - 1;
if (rotation & RR_Reflect_Y)
- y_dst = height - y_dst - 1;
+ y_dst = height - y_dst - 1;
switch (rotation & 0xf) {
case RR_Rotate_0:
- break;
+ break;
case RR_Rotate_90:
- t = x_dst;
- x_dst = y_dst;
- y_dst = width - t - 1;
- break;
+ t = x_dst;
+ x_dst = y_dst;
+ y_dst = width - t - 1;
+ break;
case RR_Rotate_180:
- x_dst = width - x_dst - 1;
- y_dst = height - y_dst - 1;
- break;
+ x_dst = width - x_dst - 1;
+ y_dst = height - y_dst - 1;
+ break;
case RR_Rotate_270:
- t = x_dst;
- x_dst = height - y_dst - 1;
- y_dst = t;
- break;
+ t = x_dst;
+ x_dst = height - y_dst - 1;
+ y_dst = t;
+ break;
}
*x_src = x_dst;
*y_src = y_dst;
@@ -149,16 +142,16 @@ struct cursor_bit {
* Convert an x coordinate to a position within the cursor bitmap
*/
static struct cursor_bit
-cursor_bitpos (CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y,
- Bool mask)
+cursor_bitpos(CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y,
+ Bool mask)
{
const int flags = cursor_info->Flags;
const Bool interleaved =
- !!(flags & (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 |
- HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8 |
- HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16 |
- HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32 |
- HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64));
+ ! !(flags & (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 |
+ HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8 |
+ HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16 |
+ HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32 |
+ HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64));
const int width = cursor_info->MaxWidth;
const int height = cursor_info->MaxHeight;
const int stride = interleaved ? width / 4 : width / 8;
@@ -168,24 +161,24 @@ cursor_bitpos (CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y,
image += y * stride;
if (flags & HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK)
- mask = !mask;
+ mask = !mask;
if (flags & HARDWARE_CURSOR_NIBBLE_SWAPPED)
- x = (x & ~3) | (3 - (x & 3));
+ x = (x & ~3) | (3 - (x & 3));
if (((flags & HARDWARE_CURSOR_BIT_ORDER_MSBFIRST) == 0) ==
- (X_BYTE_ORDER == X_BIG_ENDIAN))
- x = (x & ~7) | (7 - (x & 7));
+ (X_BYTE_ORDER == X_BIG_ENDIAN))
+ x = (x & ~7) | (7 - (x & 7));
if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1)
- x = (x << 1) + mask;
+ x = (x << 1) + mask;
else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8)
- x = ((x & ~7) << 1) | (mask << 3) | (x & 7);
+ x = ((x & ~7) << 1) | (mask << 3) | (x & 7);
else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16)
- x = ((x & ~15) << 1) | (mask << 4) | (x & 15);
+ x = ((x & ~15) << 1) | (mask << 4) | (x & 15);
else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32)
- x = ((x & ~31) << 1) | (mask << 5) | (x & 31);
+ x = ((x & ~31) << 1) | (mask << 5) | (x & 31);
else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64)
- x = ((x & ~63) << 1) | (mask << 6) | (x & 63);
+ x = ((x & ~63) << 1) | (mask << 6) | (x & 63);
else if (mask)
- image += stride * height;
+ image += stride * height;
ret.byte = image + (x / 8);
ret.bitpos = x & 7;
@@ -197,9 +190,10 @@ cursor_bitpos (CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y,
* Fetch one bit from a cursor bitmap
*/
static CARD8
-get_bit (CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y, Bool mask)
+get_bit(CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y, Bool mask)
{
struct cursor_bit bit = cursor_bitpos(image, cursor_info, x, y, mask);
+
return (*bit.byte >> bit.bitpos) & 1;
}
@@ -207,185 +201,177 @@ get_bit (CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y, Bool mask)
* Set one bit in a cursor bitmap
*/
static void
-set_bit (CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y, Bool mask)
+set_bit(CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y, Bool mask)
{
struct cursor_bit bit = cursor_bitpos(image, cursor_info, x, y, mask);
+
*bit.byte |= 1 << bit.bitpos;
}
-
+
/*
* Load a two color cursor into a driver that supports only ARGB cursors
*/
static void
-xf86_crtc_convert_cursor_to_argb (xf86CrtcPtr crtc, unsigned char *src)
+xf86_crtc_convert_cursor_to_argb(xf86CrtcPtr crtc, unsigned char *src)
{
- ScrnInfoPtr scrn = crtc->scrn;
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
- CARD32 *cursor_image = (CARD32 *) xf86_config->cursor_image;
- int x, y;
- int xin, yin;
- int flags = cursor_info->Flags;
- CARD32 bits;
- const Rotation rotation = xf86_crtc_cursor_rotation(crtc);
+ ScrnInfoPtr scrn = crtc->scrn;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
+ CARD32 *cursor_image = (CARD32 *) xf86_config->cursor_image;
+ int x, y;
+ int xin, yin;
+ int flags = cursor_info->Flags;
+ CARD32 bits;
+ const Rotation rotation = xf86_crtc_cursor_rotation(crtc);
#ifdef ARGB_CURSOR
crtc->cursor_argb = FALSE;
#endif
for (y = 0; y < cursor_info->MaxHeight; y++)
- for (x = 0; x < cursor_info->MaxWidth; x++)
- {
- xf86_crtc_rotate_coord (rotation,
- cursor_info->MaxWidth,
- cursor_info->MaxHeight,
- x, y, &xin, &yin);
- if (get_bit (src, cursor_info, xin, yin, TRUE) ==
- ((flags & HARDWARE_CURSOR_INVERT_MASK) == 0))
- {
- if (get_bit (src, cursor_info, xin, yin, FALSE))
- bits = xf86_config->cursor_fg;
- else
- bits = xf86_config->cursor_bg;
- }
- else
- bits = 0;
- cursor_image[y * cursor_info->MaxWidth + x] = bits;
- }
- crtc->funcs->load_cursor_argb (crtc, cursor_image);
+ for (x = 0; x < cursor_info->MaxWidth; x++) {
+ xf86_crtc_rotate_coord(rotation,
+ cursor_info->MaxWidth,
+ cursor_info->MaxHeight, x, y, &xin, &yin);
+ if (get_bit(src, cursor_info, xin, yin, TRUE) ==
+ ((flags & HARDWARE_CURSOR_INVERT_MASK) == 0)) {
+ if (get_bit(src, cursor_info, xin, yin, FALSE))
+ bits = xf86_config->cursor_fg;
+ else
+ bits = xf86_config->cursor_bg;
+ }
+ else
+ bits = 0;
+ cursor_image[y * cursor_info->MaxWidth + x] = bits;
+ }
+ crtc->funcs->load_cursor_argb(crtc, cursor_image);
}
/*
* Set the colors for a two-color cursor (ignore for ARGB cursors)
*/
static void
-xf86_set_cursor_colors (ScrnInfoPtr scrn, int bg, int fg)
+xf86_set_cursor_colors(ScrnInfoPtr scrn, int bg, int fg)
{
- ScreenPtr screen = scrn->pScreen;
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- CursorPtr cursor = xf86_config->cursor;
- int c;
- CARD8 *bits = cursor ?
+ ScreenPtr screen = scrn->pScreen;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ CursorPtr cursor = xf86_config->cursor;
+ int c;
+ CARD8 *bits = cursor ?
dixLookupScreenPrivate(&cursor->devPrivates, CursorScreenKey, screen)
- : NULL;
+ : NULL;
/* Save ARGB versions of these colors */
xf86_config->cursor_fg = (CARD32) fg | 0xff000000;
xf86_config->cursor_bg = (CARD32) bg | 0xff000000;
-
- for (c = 0; c < xf86_config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = xf86_config->crtc[c];
-
- if (crtc->enabled && !crtc->cursor_argb)
- {
- if (crtc->funcs->load_cursor_image)
- crtc->funcs->set_cursor_colors (crtc, bg, fg);
- else if (bits)
- xf86_crtc_convert_cursor_to_argb (crtc, bits);
- }
+
+ for (c = 0; c < xf86_config->num_crtc; c++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+ if (crtc->enabled && !crtc->cursor_argb) {
+ if (crtc->funcs->load_cursor_image)
+ crtc->funcs->set_cursor_colors(crtc, bg, fg);
+ else if (bits)
+ xf86_crtc_convert_cursor_to_argb(crtc, bits);
+ }
}
}
static void
-xf86_crtc_hide_cursor (xf86CrtcPtr crtc)
+xf86_crtc_hide_cursor(xf86CrtcPtr crtc)
{
- if (crtc->cursor_shown)
- {
- crtc->funcs->hide_cursor (crtc);
- crtc->cursor_shown = FALSE;
+ if (crtc->cursor_shown) {
+ crtc->funcs->hide_cursor(crtc);
+ crtc->cursor_shown = FALSE;
}
}
void
-xf86_hide_cursors (ScrnInfoPtr scrn)
+xf86_hide_cursors(ScrnInfoPtr scrn)
{
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- int c;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ int c;
xf86_config->cursor_on = FALSE;
- for (c = 0; c < xf86_config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = xf86_config->crtc[c];
+ for (c = 0; c < xf86_config->num_crtc; c++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
- if (crtc->enabled)
- xf86_crtc_hide_cursor (crtc);
+ if (crtc->enabled)
+ xf86_crtc_hide_cursor(crtc);
}
}
-
+
static void
-xf86_crtc_show_cursor (xf86CrtcPtr crtc)
+xf86_crtc_show_cursor(xf86CrtcPtr crtc)
{
- if (!crtc->cursor_shown && crtc->cursor_in_range)
- {
- crtc->funcs->show_cursor (crtc);
- crtc->cursor_shown = TRUE;
+ if (!crtc->cursor_shown && crtc->cursor_in_range) {
+ crtc->funcs->show_cursor(crtc);
+ crtc->cursor_shown = TRUE;
}
}
void
-xf86_show_cursors (ScrnInfoPtr scrn)
+xf86_show_cursors(ScrnInfoPtr scrn)
{
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- int c;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ int c;
xf86_config->cursor_on = TRUE;
- for (c = 0; c < xf86_config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = xf86_config->crtc[c];
+ for (c = 0; c < xf86_config->num_crtc; c++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
- if (crtc->enabled)
- xf86_crtc_show_cursor (crtc);
+ if (crtc->enabled)
+ xf86_crtc_show_cursor(crtc);
}
}
-void xf86CrtcTransformCursorPos (xf86CrtcPtr crtc, int *x, int *y)
+void
+xf86CrtcTransformCursorPos(xf86CrtcPtr crtc, int *x, int *y)
{
ScrnInfoPtr scrn = crtc->scrn;
ScreenPtr screen = scrn->pScreen;
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
xf86CursorScreenPtr ScreenPriv =
- (xf86CursorScreenPtr)dixLookupPrivate(&screen->devPrivates,
- xf86CursorScreenKey);
+ (xf86CursorScreenPtr) dixLookupPrivate(&screen->devPrivates,
+ xf86CursorScreenKey);
struct pict_f_vector v;
int dx, dy;
v.v[0] = (*x + ScreenPriv->HotX) + 0.5;
v.v[1] = (*y + ScreenPriv->HotY) + 0.5;
v.v[2] = 1;
- pixman_f_transform_point (&crtc->f_framebuffer_to_crtc, &v);
+ pixman_f_transform_point(&crtc->f_framebuffer_to_crtc, &v);
/* cursor will have 0.5 added to it already so floor is sufficent */
- *x = floor (v.v[0]);
- *y = floor (v.v[1]);
+ *x = floor(v.v[0]);
+ *y = floor(v.v[1]);
/*
* Transform position of cursor upper left corner
*/
- xf86_crtc_rotate_coord_back (crtc->rotation, cursor_info->MaxWidth,
- cursor_info->MaxHeight, ScreenPriv->HotX,
- ScreenPriv->HotY, &dx, &dy);
+ xf86_crtc_rotate_coord_back(crtc->rotation, cursor_info->MaxWidth,
+ cursor_info->MaxHeight, ScreenPriv->HotX,
+ ScreenPriv->HotY, &dx, &dy);
*x -= dx;
*y -= dy;
}
static void
-xf86_crtc_set_cursor_position (xf86CrtcPtr crtc, int x, int y)
+xf86_crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
{
- ScrnInfoPtr scrn = crtc->scrn;
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
- DisplayModePtr mode = &crtc->mode;
- Bool in_range;
+ ScrnInfoPtr scrn = crtc->scrn;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
+ DisplayModePtr mode = &crtc->mode;
+ Bool in_range;
/*
* Transform position of cursor on screen
*/
if (crtc->transform_in_use && !crtc->driverIsPerformingTransform)
- xf86CrtcTransformCursorPos(crtc, &x, &y);
- else
- {
- x -= crtc->x;
- y -= crtc->y;
+ xf86CrtcTransformCursorPos(crtc, &x, &y);
+ else {
+ x -= crtc->x;
+ y -= crtc->y;
}
/*
@@ -393,216 +379,206 @@ xf86_crtc_set_cursor_position (xf86CrtcPtr crtc, int x, int y)
*/
in_range = TRUE;
if (x >= mode->HDisplay || y >= mode->VDisplay ||
- x <= -cursor_info->MaxWidth || y <= -cursor_info->MaxHeight)
- {
- in_range = FALSE;
- x = 0;
- y = 0;
+ x <= -cursor_info->MaxWidth || y <= -cursor_info->MaxHeight) {
+ in_range = FALSE;
+ x = 0;
+ y = 0;
}
crtc->cursor_in_range = in_range;
-
- if (in_range)
- {
- crtc->funcs->set_cursor_position (crtc, x, y);
- xf86_crtc_show_cursor (crtc);
+
+ if (in_range) {
+ crtc->funcs->set_cursor_position(crtc, x, y);
+ xf86_crtc_show_cursor(crtc);
}
else
- xf86_crtc_hide_cursor (crtc);
+ xf86_crtc_hide_cursor(crtc);
}
static void
-xf86_set_cursor_position (ScrnInfoPtr scrn, int x, int y)
+xf86_set_cursor_position(ScrnInfoPtr scrn, int x, int y)
{
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- int c;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ int c;
/* undo what xf86HWCurs did to the coordinates */
x += scrn->frameX0;
y += scrn->frameY0;
- for (c = 0; c < xf86_config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = xf86_config->crtc[c];
+ for (c = 0; c < xf86_config->num_crtc; c++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
- if (crtc->enabled)
- xf86_crtc_set_cursor_position (crtc, x, y);
+ if (crtc->enabled)
+ xf86_crtc_set_cursor_position(crtc, x, y);
}
}
-
+
/*
* Load a two-color cursor into a crtc, performing rotation as needed
*/
static void
-xf86_crtc_load_cursor_image (xf86CrtcPtr crtc, CARD8 *src)
+xf86_crtc_load_cursor_image(xf86CrtcPtr crtc, CARD8 *src)
{
- ScrnInfoPtr scrn = crtc->scrn;
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
- CARD8 *cursor_image;
- const Rotation rotation = xf86_crtc_cursor_rotation(crtc);
+ ScrnInfoPtr scrn = crtc->scrn;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
+ CARD8 *cursor_image;
+ const Rotation rotation = xf86_crtc_cursor_rotation(crtc);
#ifdef ARGB_CURSOR
crtc->cursor_argb = FALSE;
#endif
if (rotation == RR_Rotate_0)
- cursor_image = src;
- else
- {
+ cursor_image = src;
+ else {
int x, y;
- int xin, yin;
- int stride = cursor_info->MaxWidth >> 2;
-
- cursor_image = xf86_config->cursor_image;
- memset(cursor_image, 0, cursor_info->MaxHeight * stride);
-
+ int xin, yin;
+ int stride = cursor_info->MaxWidth >> 2;
+
+ cursor_image = xf86_config->cursor_image;
+ memset(cursor_image, 0, cursor_info->MaxHeight * stride);
+
for (y = 0; y < cursor_info->MaxHeight; y++)
- for (x = 0; x < cursor_info->MaxWidth; x++)
- {
- xf86_crtc_rotate_coord (rotation,
- cursor_info->MaxWidth,
- cursor_info->MaxHeight,
- x, y, &xin, &yin);
- if (get_bit(src, cursor_info, xin, yin, FALSE))
- set_bit(cursor_image, cursor_info, x, y, FALSE);
- if (get_bit(src, cursor_info, xin, yin, TRUE))
- set_bit(cursor_image, cursor_info, x, y, TRUE);
- }
+ for (x = 0; x < cursor_info->MaxWidth; x++) {
+ xf86_crtc_rotate_coord(rotation,
+ cursor_info->MaxWidth,
+ cursor_info->MaxHeight,
+ x, y, &xin, &yin);
+ if (get_bit(src, cursor_info, xin, yin, FALSE))
+ set_bit(cursor_image, cursor_info, x, y, FALSE);
+ if (get_bit(src, cursor_info, xin, yin, TRUE))
+ set_bit(cursor_image, cursor_info, x, y, TRUE);
+ }
}
- crtc->funcs->load_cursor_image (crtc, cursor_image);
+ crtc->funcs->load_cursor_image(crtc, cursor_image);
}
-
+
/*
* Load a cursor image into all active CRTCs
*/
static void
-xf86_load_cursor_image (ScrnInfoPtr scrn, unsigned char *src)
+xf86_load_cursor_image(ScrnInfoPtr scrn, unsigned char *src)
{
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- int c;
-
- for (c = 0; c < xf86_config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = xf86_config->crtc[c];
-
- if (crtc->enabled)
- {
- if (crtc->funcs->load_cursor_image)
- xf86_crtc_load_cursor_image (crtc, src);
- else if (crtc->funcs->load_cursor_argb)
- xf86_crtc_convert_cursor_to_argb (crtc, src);
- }
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ int c;
+
+ for (c = 0; c < xf86_config->num_crtc; c++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+ if (crtc->enabled) {
+ if (crtc->funcs->load_cursor_image)
+ xf86_crtc_load_cursor_image(crtc, src);
+ else if (crtc->funcs->load_cursor_argb)
+ xf86_crtc_convert_cursor_to_argb(crtc, src);
+ }
}
}
static Bool
-xf86_use_hw_cursor (ScreenPtr screen, CursorPtr cursor)
+xf86_use_hw_cursor(ScreenPtr screen, CursorPtr cursor)
{
- ScrnInfoPtr scrn = xf86Screens[screen->myNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
+ ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
++cursor->refcnt;
if (xf86_config->cursor)
- FreeCursor (xf86_config->cursor, None);
+ FreeCursor(xf86_config->cursor, None);
xf86_config->cursor = cursor;
if (cursor->bits->width > cursor_info->MaxWidth ||
- cursor->bits->height> cursor_info->MaxHeight)
- return FALSE;
+ cursor->bits->height > cursor_info->MaxHeight)
+ return FALSE;
return TRUE;
}
static Bool
-xf86_use_hw_cursor_argb (ScreenPtr screen, CursorPtr cursor)
+xf86_use_hw_cursor_argb(ScreenPtr screen, CursorPtr cursor)
{
- ScrnInfoPtr scrn = xf86Screens[screen->myNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
-
+ ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
+
++cursor->refcnt;
if (xf86_config->cursor)
- FreeCursor (xf86_config->cursor, None);
+ FreeCursor(xf86_config->cursor, None);
xf86_config->cursor = cursor;
-
+
/* Make sure ARGB support is available */
if ((cursor_info->Flags & HARDWARE_CURSOR_ARGB) == 0)
- return FALSE;
-
+ return FALSE;
+
if (cursor->bits->width > cursor_info->MaxWidth ||
- cursor->bits->height> cursor_info->MaxHeight)
- return FALSE;
+ cursor->bits->height > cursor_info->MaxHeight)
+ return FALSE;
return TRUE;
}
static void
-xf86_crtc_load_cursor_argb (xf86CrtcPtr crtc, CursorPtr cursor)
+xf86_crtc_load_cursor_argb(xf86CrtcPtr crtc, CursorPtr cursor)
{
- ScrnInfoPtr scrn = crtc->scrn;
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
- CARD32 *cursor_image = (CARD32 *) xf86_config->cursor_image;
- CARD32 *cursor_source = (CARD32 *) cursor->bits->argb;
- int x, y;
- int xin, yin;
- CARD32 bits;
- int source_width = cursor->bits->width;
- int source_height = cursor->bits->height;
- int image_width = cursor_info->MaxWidth;
- int image_height = cursor_info->MaxHeight;
- const Rotation rotation = xf86_crtc_cursor_rotation(crtc);
+ ScrnInfoPtr scrn = crtc->scrn;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
+ CARD32 *cursor_image = (CARD32 *) xf86_config->cursor_image;
+ CARD32 *cursor_source = (CARD32 *) cursor->bits->argb;
+ int x, y;
+ int xin, yin;
+ CARD32 bits;
+ int source_width = cursor->bits->width;
+ int source_height = cursor->bits->height;
+ int image_width = cursor_info->MaxWidth;
+ int image_height = cursor_info->MaxHeight;
+ const Rotation rotation = xf86_crtc_cursor_rotation(crtc);
for (y = 0; y < image_height; y++)
- for (x = 0; x < image_width; x++)
- {
- xf86_crtc_rotate_coord (rotation, image_width, image_height, x, y,
- &xin, &yin);
- if (xin < source_width && yin < source_height)
- bits = cursor_source[yin * source_width + xin];
- else
- bits = 0;
- cursor_image[y * image_width + x] = bits;
- }
-
- crtc->funcs->load_cursor_argb (crtc, cursor_image);
+ for (x = 0; x < image_width; x++) {
+ xf86_crtc_rotate_coord(rotation, image_width, image_height, x, y,
+ &xin, &yin);
+ if (xin < source_width && yin < source_height)
+ bits = cursor_source[yin * source_width + xin];
+ else
+ bits = 0;
+ cursor_image[y * image_width + x] = bits;
+ }
+
+ crtc->funcs->load_cursor_argb(crtc, cursor_image);
}
static void
-xf86_load_cursor_argb (ScrnInfoPtr scrn, CursorPtr cursor)
+xf86_load_cursor_argb(ScrnInfoPtr scrn, CursorPtr cursor)
{
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- int c;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ int c;
- for (c = 0; c < xf86_config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = xf86_config->crtc[c];
+ for (c = 0; c < xf86_config->num_crtc; c++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
- if (crtc->enabled)
- xf86_crtc_load_cursor_argb (crtc, cursor);
+ if (crtc->enabled)
+ xf86_crtc_load_cursor_argb(crtc, cursor);
}
}
Bool
-xf86_cursors_init (ScreenPtr screen, int max_width, int max_height, int flags)
+xf86_cursors_init(ScreenPtr screen, int max_width, int max_height, int flags)
{
- ScrnInfoPtr scrn = xf86Screens[screen->myNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- xf86CursorInfoPtr cursor_info;
+ ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86CursorInfoPtr cursor_info;
cursor_info = xf86CreateCursorInfoRec();
if (!cursor_info)
- return FALSE;
+ return FALSE;
xf86_config->cursor_image = malloc(max_width * max_height * 4);
- if (!xf86_config->cursor_image)
- {
- xf86DestroyCursorInfoRec (cursor_info);
- return FALSE;
+ if (!xf86_config->cursor_image) {
+ xf86DestroyCursorInfoRec(cursor_info);
+ return FALSE;
}
-
+
xf86_config->cursor_info = cursor_info;
cursor_info->MaxWidth = max_width;
@@ -616,17 +592,16 @@ xf86_cursors_init (ScreenPtr screen, int max_width, int max_height, int flags)
cursor_info->ShowCursor = xf86_show_cursors;
cursor_info->UseHWCursor = xf86_use_hw_cursor;
#ifdef ARGB_CURSOR
- if (flags & HARDWARE_CURSOR_ARGB)
- {
- cursor_info->UseHWCursorARGB = xf86_use_hw_cursor_argb;
- cursor_info->LoadCursorARGB = xf86_load_cursor_argb;
+ if (flags & HARDWARE_CURSOR_ARGB) {
+ cursor_info->UseHWCursorARGB = xf86_use_hw_cursor_argb;
+ cursor_info->LoadCursorARGB = xf86_load_cursor_argb;
}
#endif
-
+
xf86_config->cursor = NULL;
- xf86_hide_cursors (scrn);
-
- return xf86InitCursor (screen, cursor_info);
+ xf86_hide_cursors(scrn);
+
+ return xf86InitCursor(screen, cursor_info);
}
/**
@@ -636,25 +611,25 @@ xf86_cursors_init (ScreenPtr screen, int max_width, int max_height, int flags)
*/
void
-xf86_reload_cursors (ScreenPtr screen)
+xf86_reload_cursors(ScreenPtr screen)
{
- ScrnInfoPtr scrn;
- xf86CrtcConfigPtr xf86_config;
- xf86CursorInfoPtr cursor_info;
- CursorPtr cursor;
- int x, y;
+ ScrnInfoPtr scrn;
+ xf86CrtcConfigPtr xf86_config;
+ xf86CursorInfoPtr cursor_info;
+ CursorPtr cursor;
+ int x, y;
xf86CursorScreenPtr cursor_screen_priv;
-
+
/* initial mode setting will not have set a screen yet.
May be called before the devices are initialised.
*/
if (!screen || !inputInfo.pointer)
- return;
+ return;
cursor_screen_priv = dixLookupPrivate(&screen->devPrivates,
- xf86CursorScreenKey);
+ xf86CursorScreenKey);
/* return if HW cursor is inactive, to avoid displaying two cursors */
if (!cursor_screen_priv || !cursor_screen_priv->isUp)
- return;
+ return;
scrn = xf86Screens[screen->myNum];
xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
@@ -662,26 +637,27 @@ xf86_reload_cursors (ScreenPtr screen)
/* make sure the cursor code has been initialized */
cursor_info = xf86_config->cursor_info;
if (!cursor_info)
- return;
+ return;
cursor = xf86_config->cursor;
- GetSpritePosition (inputInfo.pointer, &x, &y);
+ GetSpritePosition(inputInfo.pointer, &x, &y);
if (!(cursor_info->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN))
- (*cursor_info->HideCursor)(scrn);
+ (*cursor_info->HideCursor) (scrn);
- if (cursor)
- {
- void *src = dixLookupScreenPrivate(&cursor->devPrivates, CursorScreenKey, screen);
+ if (cursor) {
+ void *src =
+ dixLookupScreenPrivate(&cursor->devPrivates, CursorScreenKey,
+ screen);
#ifdef ARGB_CURSOR
- if (cursor->bits->argb && cursor_info->LoadCursorARGB)
- (*cursor_info->LoadCursorARGB) (scrn, cursor);
- else if (src)
+ if (cursor->bits->argb && cursor_info->LoadCursorARGB)
+ (*cursor_info->LoadCursorARGB) (scrn, cursor);
+ else if (src)
#endif
- (*cursor_info->LoadCursorImage)(scrn, src);
+ (*cursor_info->LoadCursorImage) (scrn, src);
- x += scrn->frameX0 + cursor_screen_priv->HotX;
- y += scrn->frameY0 + cursor_screen_priv->HotY;
- (*cursor_info->SetCursorPosition)(scrn, x, y);
+ x += scrn->frameX0 + cursor_screen_priv->HotX;
+ y += scrn->frameY0 + cursor_screen_priv->HotY;
+ (*cursor_info->SetCursorPosition) (scrn, x, y);
}
}
@@ -689,21 +665,19 @@ xf86_reload_cursors (ScreenPtr screen)
* Clean up CRTC-based cursor code
*/
void
-xf86_cursors_fini (ScreenPtr screen)
+xf86_cursors_fini(ScreenPtr screen)
{
- ScrnInfoPtr scrn = xf86Screens[screen->myNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
-
- if (xf86_config->cursor_info)
- {
- xf86DestroyCursorInfoRec (xf86_config->cursor_info);
- xf86_config->cursor_info = NULL;
+ ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+
+ if (xf86_config->cursor_info) {
+ xf86DestroyCursorInfoRec(xf86_config->cursor_info);
+ xf86_config->cursor_info = NULL;
}
free(xf86_config->cursor_image);
xf86_config->cursor_image = NULL;
- if (xf86_config->cursor)
- {
- FreeCursor (xf86_config->cursor, None);
- xf86_config->cursor = NULL;
+ if (xf86_config->cursor) {
+ FreeCursor(xf86_config->cursor, None);
+ xf86_config->cursor = NULL;
}
}
diff --git a/xorg-server/hw/xfree86/modes/xf86DiDGA.c b/xorg-server/hw/xfree86/modes/xf86DiDGA.c
index b2bbefa62..fafd95aed 100644
--- a/xorg-server/hw/xfree86/modes/xf86DiDGA.c
+++ b/xorg-server/hw/xfree86/modes/xf86DiDGA.c
@@ -1,217 +1,214 @@
-/*
- * Copyright © 2006 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that copyright
- * notice and this permission notice appear in supporting documentation, and
- * that the name of the copyright holders not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. The copyright holders make no representations
- * about the suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#else
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#endif
-
-#include "xf86.h"
-#include "xf86DDC.h"
-#include "xf86_OSproc.h"
-#include "dgaproc.h"
-#include "xf86Crtc.h"
-#include "xf86Modes.h"
-#include "gcstruct.h"
-#include "scrnintstr.h"
-#include "windowstr.h"
-
-static Bool
-xf86_dga_get_modes (ScreenPtr pScreen)
-{
- ScrnInfoPtr scrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- DGAModePtr modes, mode;
- DisplayModePtr display_mode;
- int bpp = scrn->bitsPerPixel >> 3;
- int num;
-
- num = 0;
- display_mode = scrn->modes;
- while (display_mode)
- {
- num++;
- display_mode = display_mode->next;
- if (display_mode == scrn->modes)
- break;
- }
-
- if (!num)
- return FALSE;
-
- modes = malloc(num * sizeof(DGAModeRec));
- if (!modes)
- return FALSE;
-
- num = 0;
- display_mode = scrn->modes;
- while (display_mode)
- {
- mode = modes + num++;
-
- mode->mode = display_mode;
- mode->flags = DGA_CONCURRENT_ACCESS;
- if (display_mode->Flags & V_DBLSCAN)
- mode->flags |= DGA_DOUBLESCAN;
- if (display_mode->Flags & V_INTERLACE)
- mode->flags |= DGA_INTERLACED;
- mode->byteOrder = scrn->imageByteOrder;
- mode->depth = scrn->depth;
- mode->bitsPerPixel = scrn->bitsPerPixel;
- mode->red_mask = scrn->mask.red;
- mode->green_mask = scrn->mask.green;
- mode->blue_mask = scrn->mask.blue;
- mode->visualClass = (bpp == 1) ? PseudoColor : TrueColor;
- mode->viewportWidth = display_mode->HDisplay;
- mode->viewportHeight = display_mode->VDisplay;
- mode->xViewportStep = (bpp == 3) ? 2 : 1;
- mode->yViewportStep = 1;
- mode->viewportFlags = DGA_FLIP_RETRACE;
- mode->offset = 0;
- mode->address = 0;
- mode->imageWidth = mode->viewportWidth;
- mode->imageHeight = mode->viewportHeight;
- mode->bytesPerScanline = (mode->imageWidth * scrn->bitsPerPixel) >> 3;
- mode->pixmapWidth = mode->imageWidth;
- mode->pixmapHeight = mode->imageHeight;
- mode->maxViewportX = 0;
- mode->maxViewportY = 0;
-
- display_mode = display_mode->next;
- if (display_mode == scrn->modes)
- break;
- }
- free(xf86_config->dga_modes);
- xf86_config->dga_nmode = num;
- xf86_config->dga_modes = modes;
- return TRUE;
-}
-
-static Bool
-xf86_dga_set_mode(ScrnInfoPtr scrn, DGAModePtr display_mode)
-{
- ScreenPtr pScreen = scrn->pScreen;
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
-
- if (!display_mode)
- {
- if (xf86_config->dga_save_mode)
- {
- xf86SwitchMode(pScreen, xf86_config->dga_save_mode);
- xf86_config->dga_save_mode = NULL;
- }
- }
- else
- {
- if (!xf86_config->dga_save_mode)
- {
- xf86_config->dga_save_mode = scrn->currentMode;
- xf86SwitchMode(pScreen, display_mode->mode);
- }
- }
- return TRUE;
-}
-
-static int
-xf86_dga_get_viewport(ScrnInfoPtr scrn)
-{
- return 0;
-}
-
-static void
-xf86_dga_set_viewport(ScrnInfoPtr scrn, int x, int y, int flags)
-{
- scrn->AdjustFrame(scrn->pScreen->myNum, x, y, flags);
-}
-
-static Bool
-xf86_dga_open_framebuffer(ScrnInfoPtr scrn,
- char **name,
- unsigned char **mem, int *size, int *offset, int *flags)
-{
- return FALSE;
-}
-
-static void
-xf86_dga_close_framebuffer(ScrnInfoPtr scrn)
-{
-}
-
-static DGAFunctionRec xf86_dga_funcs = {
- xf86_dga_open_framebuffer,
- xf86_dga_close_framebuffer,
- xf86_dga_set_mode,
- xf86_dga_set_viewport,
- xf86_dga_get_viewport,
- NULL,
- NULL,
- NULL,
- NULL
-};
-
-Bool
-xf86DiDGAReInit (ScreenPtr pScreen)
-{
- return TRUE;
-}
-
-Bool
-_xf86_di_dga_reinit_internal (ScreenPtr pScreen)
-{
- ScrnInfoPtr scrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
-
- if (!DGAAvailable(pScreen->myNum))
- return TRUE;
-
- if (!xf86_dga_get_modes (pScreen))
- return FALSE;
-
- return DGAReInitModes (pScreen, xf86_config->dga_modes, xf86_config->dga_nmode);
-}
-
-Bool
-xf86DiDGAInit (ScreenPtr pScreen, unsigned long dga_address)
-{
- return TRUE;
-}
-
-Bool
-_xf86_di_dga_init_internal (ScreenPtr pScreen)
-{
- ScrnInfoPtr scrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
-
- xf86_config->dga_flags = 0;
- xf86_config->dga_address = 0;
- xf86_config->dga_width = 0;
- xf86_config->dga_height = 0;
- xf86_config->dga_stride = 0;
-
- if (!xf86_dga_get_modes (pScreen))
- return FALSE;
-
- return DGAInit(pScreen, &xf86_dga_funcs, xf86_config->dga_modes, xf86_config->dga_nmode);
-}
+/*
+ * Copyright © 2006 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#else
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#endif
+
+#include "xf86.h"
+#include "xf86DDC.h"
+#include "xf86_OSproc.h"
+#include "dgaproc.h"
+#include "xf86Crtc.h"
+#include "xf86Modes.h"
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+
+static Bool
+xf86_dga_get_modes(ScreenPtr pScreen)
+{
+ ScrnInfoPtr scrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ DGAModePtr modes, mode;
+ DisplayModePtr display_mode;
+ int bpp = scrn->bitsPerPixel >> 3;
+ int num;
+
+ num = 0;
+ display_mode = scrn->modes;
+ while (display_mode) {
+ num++;
+ display_mode = display_mode->next;
+ if (display_mode == scrn->modes)
+ break;
+ }
+
+ if (!num)
+ return FALSE;
+
+ modes = malloc(num * sizeof(DGAModeRec));
+ if (!modes)
+ return FALSE;
+
+ num = 0;
+ display_mode = scrn->modes;
+ while (display_mode) {
+ mode = modes + num++;
+
+ mode->mode = display_mode;
+ mode->flags = DGA_CONCURRENT_ACCESS;
+ if (display_mode->Flags & V_DBLSCAN)
+ mode->flags |= DGA_DOUBLESCAN;
+ if (display_mode->Flags & V_INTERLACE)
+ mode->flags |= DGA_INTERLACED;
+ mode->byteOrder = scrn->imageByteOrder;
+ mode->depth = scrn->depth;
+ mode->bitsPerPixel = scrn->bitsPerPixel;
+ mode->red_mask = scrn->mask.red;
+ mode->green_mask = scrn->mask.green;
+ mode->blue_mask = scrn->mask.blue;
+ mode->visualClass = (bpp == 1) ? PseudoColor : TrueColor;
+ mode->viewportWidth = display_mode->HDisplay;
+ mode->viewportHeight = display_mode->VDisplay;
+ mode->xViewportStep = (bpp == 3) ? 2 : 1;
+ mode->yViewportStep = 1;
+ mode->viewportFlags = DGA_FLIP_RETRACE;
+ mode->offset = 0;
+ mode->address = 0;
+ mode->imageWidth = mode->viewportWidth;
+ mode->imageHeight = mode->viewportHeight;
+ mode->bytesPerScanline = (mode->imageWidth * scrn->bitsPerPixel) >> 3;
+ mode->pixmapWidth = mode->imageWidth;
+ mode->pixmapHeight = mode->imageHeight;
+ mode->maxViewportX = 0;
+ mode->maxViewportY = 0;
+
+ display_mode = display_mode->next;
+ if (display_mode == scrn->modes)
+ break;
+ }
+ free(xf86_config->dga_modes);
+ xf86_config->dga_nmode = num;
+ xf86_config->dga_modes = modes;
+ return TRUE;
+}
+
+static Bool
+xf86_dga_set_mode(ScrnInfoPtr scrn, DGAModePtr display_mode)
+{
+ ScreenPtr pScreen = scrn->pScreen;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+
+ if (!display_mode) {
+ if (xf86_config->dga_save_mode) {
+ xf86SwitchMode(pScreen, xf86_config->dga_save_mode);
+ xf86_config->dga_save_mode = NULL;
+ }
+ }
+ else {
+ if (!xf86_config->dga_save_mode) {
+ xf86_config->dga_save_mode = scrn->currentMode;
+ xf86SwitchMode(pScreen, display_mode->mode);
+ }
+ }
+ return TRUE;
+}
+
+static int
+xf86_dga_get_viewport(ScrnInfoPtr scrn)
+{
+ return 0;
+}
+
+static void
+xf86_dga_set_viewport(ScrnInfoPtr scrn, int x, int y, int flags)
+{
+ scrn->AdjustFrame(scrn->pScreen->myNum, x, y, flags);
+}
+
+static Bool
+xf86_dga_open_framebuffer(ScrnInfoPtr scrn,
+ char **name,
+ unsigned char **mem, int *size, int *offset,
+ int *flags)
+{
+ return FALSE;
+}
+
+static void
+xf86_dga_close_framebuffer(ScrnInfoPtr scrn)
+{
+}
+
+static DGAFunctionRec xf86_dga_funcs = {
+ xf86_dga_open_framebuffer,
+ xf86_dga_close_framebuffer,
+ xf86_dga_set_mode,
+ xf86_dga_set_viewport,
+ xf86_dga_get_viewport,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+Bool
+xf86DiDGAReInit(ScreenPtr pScreen)
+{
+ return TRUE;
+}
+
+Bool
+_xf86_di_dga_reinit_internal(ScreenPtr pScreen)
+{
+ ScrnInfoPtr scrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+
+ if (!DGAAvailable(pScreen->myNum))
+ return TRUE;
+
+ if (!xf86_dga_get_modes(pScreen))
+ return FALSE;
+
+ return DGAReInitModes(pScreen, xf86_config->dga_modes,
+ xf86_config->dga_nmode);
+}
+
+Bool
+xf86DiDGAInit(ScreenPtr pScreen, unsigned long dga_address)
+{
+ return TRUE;
+}
+
+Bool
+_xf86_di_dga_init_internal(ScreenPtr pScreen)
+{
+ ScrnInfoPtr scrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+
+ xf86_config->dga_flags = 0;
+ xf86_config->dga_address = 0;
+ xf86_config->dga_width = 0;
+ xf86_config->dga_height = 0;
+ xf86_config->dga_stride = 0;
+
+ if (!xf86_dga_get_modes(pScreen))
+ return FALSE;
+
+ return DGAInit(pScreen, &xf86_dga_funcs, xf86_config->dga_modes,
+ xf86_config->dga_nmode);
+}
diff --git a/xorg-server/hw/xfree86/modes/xf86DisplayIDModes.c b/xorg-server/hw/xfree86/modes/xf86DisplayIDModes.c
index d507e3b14..781c806bc 100644
--- a/xorg-server/hw/xfree86/modes/xf86DisplayIDModes.c
+++ b/xorg-server/hw/xfree86/modes/xf86DisplayIDModes.c
@@ -1,437 +1,452 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software")
- * to deal in the software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * them Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTIBILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Adam Jackson <ajax@redhat.com>
- */
-
-#include "xorg-config.h"
-#include "xf86.h"
-#include "xf86str.h"
-#include "edid.h"
-#include "xf86DDC.h"
-
-typedef void (*did_proc)(int scrnIndex, unsigned char *data, void *closure);
-
-#define DID_PRODUCT_ID 0x00
-#define DID_DISPLAY_PARAMETERS 0x01
-#define DID_COLOR_INFO 0x02
-#define DID_TIMING_1_DETAILED 0x03
-#define DID_TIMING_2_DETAILED 0x04
-#define DID_TIMING_3_SHORT 0x05
-#define DID_TIMING_4_DMT 0x06
-#define DID_TIMING_VESA 0x07
-#define DID_TIMING_CEA 0x08
-#define DID_TIMING_RANGE_LIMITS 0x09
-#define DID_PRODUCT_SERIAL 0x0A
-#define DID_ASCII_STRING 0x0B
-#define DID_DISPLAY_DEVICE 0x0C
-#define DID_POWER_SEQUENCING 0x0D
-#define DID_TRANSFER_INFO 0x0E
-#define DID_DISPLAY_INTERFACE 0x0F
-#define DID_STEREO 0x10
-#define DID_VENDOR 0x7F
-
-#define extract_le16(x, i) ((x[i+1] << 8) + (x[i]))
-#define extract_le24(x, i) ((x[i+2] << 16) + (x[i+1] << 8) + (x[i]))
-
-static DisplayModePtr
-modeCalloc(void)
-{
- return calloc(1, sizeof(DisplayModeRec));
-}
-
-/*
- * How awesome is it to have two detailed timing formats, neither of which
- * are compatible with the format in EDID? So awesome.
- */
-
-static void
-didDetailedTiming1(int i, unsigned char *x, MonPtr mon)
-{
- DisplayModePtr m = modeCalloc();
-
- if (!m)
- return;
-
- m->Clock = extract_le24(x, 0);
-
- m->HDisplay = extract_le16(x, 4);
- m->HSyncStart = m->HDisplay + (extract_le16(x, 8) & 0x7f);
- m->HSyncEnd = m->HSyncStart + extract_le16(x, 10);
- m->HTotal = m->HDisplay + extract_le16(x, 6);
- m->Flags |= (x[9] & 0x80) ? V_PHSYNC : V_NHSYNC;
-
- m->VDisplay = extract_le16(x, 12);
- m->VSyncStart = m->VDisplay + (extract_le16(x, 16) & 0x7f);
- m->VSyncEnd = m->VSyncStart + extract_le16(x, 18);
- m->VTotal = m->VDisplay + extract_le16(x, 14);
- m->Flags |= (x[17] & 0x80) ? V_PVSYNC : V_NVSYNC;
-
- m->type = M_T_DRIVER;
- if (x[3] & 0x80)
- m->type |= M_T_PREFERRED;
-
- /* XXX double check handling of this */
- if (x[3] & 0x10)
- m->Flags |= V_INTERLACE;
-
- mon->Modes = xf86ModesAdd(mon->Modes, m);
-}
-
-/* XXX no sync bits. what to do? */
-static void
-didDetailedTiming2(int i, unsigned char *x, MonPtr mon)
-{
- DisplayModePtr mode = modeCalloc();
-
- if (!mode)
- return;
-
- mode->Clock = extract_le24(x, 0);
-
- /* horiz sizes are in character cells, not pixels, hence * 8 */
- mode->HDisplay = ((extract_le16(x, 4) & 0x01ff) + 1) * 8;
- mode->HSyncStart = mode->HDisplay + (((x[6] & 0xf0) >> 4) + 1) * 8;
- mode->HSyncEnd = mode->HSyncStart + ((x[6] & 0x0f) + 1) * 8;
- mode->HTotal = mode->HDisplay + ((x[5] >> 1) + 1) * 8;
-
- mode->VDisplay = extract_le16(x, 7) & 0x07ff;
- mode->VSyncStart = mode->VDisplay + (x[10] >> 4) + 1;
- mode->VSyncEnd = mode->VSyncStart + (x[10] & 0x0f) + 1;
- mode->VTotal = mode->VDisplay + x[9];
-
- mode->status = M_T_DRIVER;
- if (x[3] & 0x80)
- mode->status |= M_T_PREFERRED;
-
- /* XXX double check handling of this */
- if (x[3] & 0x10)
- mode->Flags |= V_INTERLACE;
-
- mon->Modes = xf86ModesAdd(mon->Modes, mode);
-}
-
-static void
-didShortTiming(int i, unsigned char *x, MonPtr mon)
-{
- DisplayModePtr m;
- int w, h, r;
-
- w = (x[1] + 1) * 8;
- switch (x[0] & 0x0f) {
- case 0:
- h = w;
- break;
- case 1:
- h = (w * 4) / 5;
- break;
- case 2:
- h = (w * 3) / 4;
- break;
- case 3:
- h = (w * 9) / 15;
- break;
- case 4:
- h = (w * 9) / 16;
- break;
- case 5:
- h = (w * 10) / 16;
- break;
- default:
- return;
- }
- r = (x[2] & 0x7f) + 1;
-
- m = xf86CVTMode(w, h, r, !!(x[0] & 0x10), !!(x[2] & 0x80));
-
- m->type = M_T_DRIVER;
- if (x[0] & 0x80)
- m->type |= M_T_PREFERRED;
-
- mon->Modes = xf86ModesAdd(mon->Modes, m);
-}
-
-static void
-didDMTTiming(int i, unsigned char *x, void *closure)
-{
- MonPtr mon = closure;
-
- mon->Modes = xf86ModesAdd(mon->Modes,
- xf86DuplicateMode(DMTModes + *x));
-}
-
-#define RB 1
-#define INT 2
-static const struct did_dmt {
- short w, h, r, f;
-} did_dmt[] = {
- /* byte 3 */
- { 640, 350, 85, 0 },
- { 640, 400, 85, 0 },
- { 720, 400, 85, 0 },
- { 640, 480, 60, 0 },
- { 640, 480, 72, 0 },
- { 640, 480, 75, 0 },
- { 640, 480, 85, 0 },
- { 800, 600, 56, 0 },
- /* byte 4 */
- { 800, 600, 60, 0 },
- { 800, 600, 72, 0 },
- { 800, 600, 75, 0 },
- { 800, 600, 85, 0 },
- { 800, 600, 120, RB },
- { 848, 480, 60, 0 },
- { 1024, 768, 43, INT },
- { 1024, 768, 60, 0 },
- /* byte 5 */
- { 1024, 768, 70, 0 },
- { 1024, 768, 75, 0 },
- { 1024, 768, 85, 0 },
- { 1024, 768, 120, RB },
- { 1152, 864, 75, 0 },
- { 1280, 768, 60, RB },
- { 1280, 768, 60, 0 },
- { 1280, 768, 75, 0 },
- /* byte 6 */
- { 1280, 768, 85, 0 },
- { 1280, 768, 120, RB },
- { 1280, 800, 60, RB },
- { 1280, 800, 60, 0 },
- { 1280, 800, 75, 0 },
- { 1280, 800, 85, 0 },
- { 1280, 800, 120, RB },
- { 1280, 960, 60, 0 },
- /* byte 7 */
- { 1280, 960, 85, 0 },
- { 1280, 960, 120, RB },
- { 1280, 1024, 60, 0 },
- { 1280, 1024, 75, 0 },
- { 1280, 1024, 85, 0 },
- { 1280, 1024, 120, RB },
- { 1360, 768, 60, 0 },
- { 1360, 768, 120, RB },
- /* byte 8 */
- { 1400, 1050, 60, RB },
- { 1400, 1050, 60, 0 },
- { 1400, 1050, 75, 0 },
- { 1400, 1050, 85, 0 },
- { 1400, 1050, 120, RB },
- { 1440, 900, 60, RB },
- { 1440, 900, 60, 0 },
- { 1440, 900, 75, 0 },
- /* byte 9 */
- { 1440, 900, 85, 0 },
- { 1440, 900, 120, RB },
- { 1600, 1200, 60, 0 },
- { 1600, 1200, 65, 0 },
- { 1600, 1200, 70, 0 },
- { 1600, 1200, 75, 0 },
- { 1600, 1200, 85, 0 },
- { 1600, 1200, 120, RB },
- /* byte a */
- { 1680, 1050, 60, RB },
- { 1680, 1050, 60, 0 },
- { 1680, 1050, 75, 0 },
- { 1680, 1050, 85, 0 },
- { 1680, 1050, 120, RB },
- { 1792, 1344, 60, 0 },
- { 1792, 1344, 75, 0 },
- { 1792, 1344, 120, RB },
- /* byte b */
- { 1856, 1392, 60, 0 },
- { 1856, 1392, 75, 0 },
- { 1856, 1392, 120, RB },
- { 1920, 1200, 60, RB },
- { 1920, 1200, 60, 0 },
- { 1920, 1200, 75, 0 },
- { 1920, 1200, 85, 0 },
- { 1920, 1200, 120, RB },
- /* byte c */
- { 1920, 1440, 60, 0 },
- { 1920, 1440, 75, 0 },
- { 1920, 1440, 120, RB },
- { 2560, 1600, 60, RB },
- { 2560, 1600, 60, 0 },
- { 2560, 1600, 75, 0 },
- { 2560, 1600, 85, 0 },
- { 2560, 1600, 120, RB },
-};
-
-static void
-didVesaTiming(int scrn, unsigned char *x, MonPtr mon)
-{
- int i, j;
-
- x += 3;
-
- for (i = 0; i < 10; i++)
- for (j = 0; j < 8; j++)
- if (x[i] & (1 << j)) {
- const struct did_dmt *d = &(did_dmt[i * 8 + j]);
- if (d->f == INT)
- continue;
- mon->Modes = xf86ModesAdd(mon->Modes,
- FindDMTMode(d->w, d->h, d->r,
- d->f == RB));
- }
-
-}
-
-static void
-handleDisplayIDBlock(int scrnIndex, unsigned char *x, void *closure)
-{
- MonPtr mon = closure;
-
- switch (x[0]) {
- case DID_DISPLAY_PARAMETERS:
- /* w/h are in decimillimeters */
- mon->widthmm = (extract_le16(x, 3) + 5) / 10;
- mon->heightmm = (extract_le16(x, 5) + 5) / 10;
- /* XXX pixel count, feature flags, gamma, aspect, color depth */
- break;
-
- case DID_TIMING_RANGE_LIMITS:
- {
- int n;
-
- mon->maxPixClock = max(mon->maxPixClock, extract_le24(x, 6) * 10);
-
- n = mon->nHsync++;
- if (n < MAX_HSYNC) {
- mon->hsync[n].lo = x[9];
- mon->hsync[n].hi = x[10];
- } else {
- n = MAX_HSYNC;
- }
- n = mon->nVrefresh++;
- if (n < MAX_VREFRESH) {
- mon->vrefresh[n].lo = x[13];
- mon->vrefresh[n].hi = x[14];
- } else {
- n = MAX_VREFRESH;
- }
- break;
- }
-
- case DID_TIMING_1_DETAILED:
- {
- int i;
- for (i = 0; i < x[2]; i += 20)
- didDetailedTiming1(scrnIndex, x + i + 3, mon);
- break;
- }
-
- case DID_TIMING_2_DETAILED:
- {
- int i;
- for (i = 0; i < x[2]; i += 11)
- didDetailedTiming2(scrnIndex, x + i + 3, mon);
- break;
- }
-
- case DID_TIMING_3_SHORT:
- {
- int i;
- for (i = 0; i < x[2]; i += 3)
- didShortTiming(scrnIndex, x + i + 3, mon);
- break;
- }
-
- case DID_TIMING_4_DMT:
- {
- int i;
- for (i = 0; i < x[2]; i++)
- didDMTTiming(scrnIndex, x + i + 3, mon);
- break;
- }
-
- case DID_TIMING_VESA:
- didVesaTiming(scrnIndex, x, mon);
- break;
-
- /* XXX pixel format, ar, orientation, subpixel, dot pitch, bit depth */
- case DID_DISPLAY_DEVICE:
-
- /* XXX interface, links, color encoding, ss, drm */
- case DID_DISPLAY_INTERFACE:
-
- /* XXX stereo */
- case DID_STEREO:
-
- /* nothing interesting in these */
- case DID_COLOR_INFO:
- case DID_PRODUCT_SERIAL:
- case DID_ASCII_STRING:
- case DID_POWER_SEQUENCING:
- case DID_TRANSFER_INFO:
- case DID_VENDOR:
- break;
-
- /* warn about anything else */
- default:
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Unknown DisplayID block type %hx\n", x[0]);
- break;
- }
-}
-
-static void
-forEachDisplayIDBlock(int scrnIndex, unsigned char *did, did_proc proc,
- void *closure)
-{
- int num_extensions = did[3];
- int section_size = did[1];
- unsigned char *block;
-
- do {
- if ((did[0] & 0xf0) != 0x10) /* not 1.x, abort */
- return;
- /* XXX also, checksum */
-
- block = did + 4;
-
- while (section_size > 0) {
- int block_size = (block[2] + 2);
-
- proc(scrnIndex, block, closure);
-
- section_size -= block_size;
- block += block_size;
- }
-
- did += (did[1] + 5);
- } while (num_extensions--);
-}
-
-/*
- * Fill out MonPtr with xf86MonPtr information.
- */
-void
-xf86DisplayIDMonitorSet(int scrnIndex, MonPtr mon, xf86MonPtr DDC)
-{
- if (!mon || !DDC)
- return;
-
- mon->DDC = DDC;
-
- forEachDisplayIDBlock(scrnIndex, DDC->rawData, handleDisplayIDBlock, mon);
-}
+/*
+ * Copyright 2009 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software")
+ * to deal in the software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * them Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTIBILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Adam Jackson <ajax@redhat.com>
+ */
+
+#include "xorg-config.h"
+#include "xf86.h"
+#include "xf86str.h"
+#include "edid.h"
+#include "xf86DDC.h"
+
+typedef void (*did_proc) (int scrnIndex, unsigned char *data, void *closure);
+
+#define DID_PRODUCT_ID 0x00
+#define DID_DISPLAY_PARAMETERS 0x01
+#define DID_COLOR_INFO 0x02
+#define DID_TIMING_1_DETAILED 0x03
+#define DID_TIMING_2_DETAILED 0x04
+#define DID_TIMING_3_SHORT 0x05
+#define DID_TIMING_4_DMT 0x06
+#define DID_TIMING_VESA 0x07
+#define DID_TIMING_CEA 0x08
+#define DID_TIMING_RANGE_LIMITS 0x09
+#define DID_PRODUCT_SERIAL 0x0A
+#define DID_ASCII_STRING 0x0B
+#define DID_DISPLAY_DEVICE 0x0C
+#define DID_POWER_SEQUENCING 0x0D
+#define DID_TRANSFER_INFO 0x0E
+#define DID_DISPLAY_INTERFACE 0x0F
+#define DID_STEREO 0x10
+#define DID_VENDOR 0x7F
+
+#define extract_le16(x, i) ((x[i+1] << 8) + (x[i]))
+#define extract_le24(x, i) ((x[i+2] << 16) + (x[i+1] << 8) + (x[i]))
+
+static DisplayModePtr
+modeCalloc(void)
+{
+ return calloc(1, sizeof(DisplayModeRec));
+}
+
+/*
+ * How awesome is it to have two detailed timing formats, neither of which
+ * are compatible with the format in EDID? So awesome.
+ */
+
+static void
+didDetailedTiming1(int i, unsigned char *x, MonPtr mon)
+{
+ DisplayModePtr m = modeCalloc();
+
+ if (!m)
+ return;
+
+ m->Clock = extract_le24(x, 0);
+
+ m->HDisplay = extract_le16(x, 4);
+ m->HSyncStart = m->HDisplay + (extract_le16(x, 8) & 0x7f);
+ m->HSyncEnd = m->HSyncStart + extract_le16(x, 10);
+ m->HTotal = m->HDisplay + extract_le16(x, 6);
+ m->Flags |= (x[9] & 0x80) ? V_PHSYNC : V_NHSYNC;
+
+ m->VDisplay = extract_le16(x, 12);
+ m->VSyncStart = m->VDisplay + (extract_le16(x, 16) & 0x7f);
+ m->VSyncEnd = m->VSyncStart + extract_le16(x, 18);
+ m->VTotal = m->VDisplay + extract_le16(x, 14);
+ m->Flags |= (x[17] & 0x80) ? V_PVSYNC : V_NVSYNC;
+
+ m->type = M_T_DRIVER;
+ if (x[3] & 0x80)
+ m->type |= M_T_PREFERRED;
+
+ /* XXX double check handling of this */
+ if (x[3] & 0x10)
+ m->Flags |= V_INTERLACE;
+
+ mon->Modes = xf86ModesAdd(mon->Modes, m);
+}
+
+/* XXX no sync bits. what to do? */
+static void
+didDetailedTiming2(int i, unsigned char *x, MonPtr mon)
+{
+ DisplayModePtr mode = modeCalloc();
+
+ if (!mode)
+ return;
+
+ mode->Clock = extract_le24(x, 0);
+
+ /* horiz sizes are in character cells, not pixels, hence * 8 */
+ mode->HDisplay = ((extract_le16(x, 4) & 0x01ff) + 1) * 8;
+ mode->HSyncStart = mode->HDisplay + (((x[6] & 0xf0) >> 4) + 1) * 8;
+ mode->HSyncEnd = mode->HSyncStart + ((x[6] & 0x0f) + 1) * 8;
+ mode->HTotal = mode->HDisplay + ((x[5] >> 1) + 1) * 8;
+
+ mode->VDisplay = extract_le16(x, 7) & 0x07ff;
+ mode->VSyncStart = mode->VDisplay + (x[10] >> 4) + 1;
+ mode->VSyncEnd = mode->VSyncStart + (x[10] & 0x0f) + 1;
+ mode->VTotal = mode->VDisplay + x[9];
+
+ mode->status = M_T_DRIVER;
+ if (x[3] & 0x80)
+ mode->status |= M_T_PREFERRED;
+
+ /* XXX double check handling of this */
+ if (x[3] & 0x10)
+ mode->Flags |= V_INTERLACE;
+
+ mon->Modes = xf86ModesAdd(mon->Modes, mode);
+}
+
+static void
+didShortTiming(int i, unsigned char *x, MonPtr mon)
+{
+ DisplayModePtr m;
+ int w, h, r;
+
+ w = (x[1] + 1) * 8;
+ switch (x[0] & 0x0f) {
+ case 0:
+ h = w;
+ break;
+ case 1:
+ h = (w * 4) / 5;
+ break;
+ case 2:
+ h = (w * 3) / 4;
+ break;
+ case 3:
+ h = (w * 9) / 15;
+ break;
+ case 4:
+ h = (w * 9) / 16;
+ break;
+ case 5:
+ h = (w * 10) / 16;
+ break;
+ default:
+ return;
+ }
+ r = (x[2] & 0x7f) + 1;
+
+ m = xf86CVTMode(w, h, r, ! !(x[0] & 0x10), ! !(x[2] & 0x80));
+
+ m->type = M_T_DRIVER;
+ if (x[0] & 0x80)
+ m->type |= M_T_PREFERRED;
+
+ mon->Modes = xf86ModesAdd(mon->Modes, m);
+}
+
+static void
+didDMTTiming(int i, unsigned char *x, void *closure)
+{
+ MonPtr mon = closure;
+
+ mon->Modes = xf86ModesAdd(mon->Modes, xf86DuplicateMode(DMTModes + *x));
+}
+
+#define RB 1
+#define INT 2
+static const struct did_dmt {
+ short w, h, r, f;
+} did_dmt[] = {
+ /* byte 3 */
+ {
+ 640, 350, 85, 0}, {
+ 640, 400, 85, 0}, {
+ 720, 400, 85, 0}, {
+ 640, 480, 60, 0}, {
+ 640, 480, 72, 0}, {
+ 640, 480, 75, 0}, {
+ 640, 480, 85, 0}, {
+ 800, 600, 56, 0},
+ /* byte 4 */
+ {
+ 800, 600, 60, 0}, {
+ 800, 600, 72, 0}, {
+ 800, 600, 75, 0}, {
+ 800, 600, 85, 0}, {
+ 800, 600, 120, RB}, {
+ 848, 480, 60, 0}, {
+ 1024, 768, 43, INT}, {
+ 1024, 768, 60, 0},
+ /* byte 5 */
+ {
+ 1024, 768, 70, 0}, {
+ 1024, 768, 75, 0}, {
+ 1024, 768, 85, 0}, {
+ 1024, 768, 120, RB}, {
+ 1152, 864, 75, 0}, {
+ 1280, 768, 60, RB}, {
+ 1280, 768, 60, 0}, {
+ 1280, 768, 75, 0},
+ /* byte 6 */
+ {
+ 1280, 768, 85, 0}, {
+ 1280, 768, 120, RB}, {
+ 1280, 800, 60, RB}, {
+ 1280, 800, 60, 0}, {
+ 1280, 800, 75, 0}, {
+ 1280, 800, 85, 0}, {
+ 1280, 800, 120, RB}, {
+ 1280, 960, 60, 0},
+ /* byte 7 */
+ {
+ 1280, 960, 85, 0}, {
+ 1280, 960, 120, RB}, {
+ 1280, 1024, 60, 0}, {
+ 1280, 1024, 75, 0}, {
+ 1280, 1024, 85, 0}, {
+ 1280, 1024, 120, RB}, {
+ 1360, 768, 60, 0}, {
+ 1360, 768, 120, RB},
+ /* byte 8 */
+ {
+ 1400, 1050, 60, RB}, {
+ 1400, 1050, 60, 0}, {
+ 1400, 1050, 75, 0}, {
+ 1400, 1050, 85, 0}, {
+ 1400, 1050, 120, RB}, {
+ 1440, 900, 60, RB}, {
+ 1440, 900, 60, 0}, {
+ 1440, 900, 75, 0},
+ /* byte 9 */
+ {
+ 1440, 900, 85, 0}, {
+ 1440, 900, 120, RB}, {
+ 1600, 1200, 60, 0}, {
+ 1600, 1200, 65, 0}, {
+ 1600, 1200, 70, 0}, {
+ 1600, 1200, 75, 0}, {
+ 1600, 1200, 85, 0}, {
+ 1600, 1200, 120, RB},
+ /* byte a */
+ {
+ 1680, 1050, 60, RB}, {
+ 1680, 1050, 60, 0}, {
+ 1680, 1050, 75, 0}, {
+ 1680, 1050, 85, 0}, {
+ 1680, 1050, 120, RB}, {
+ 1792, 1344, 60, 0}, {
+ 1792, 1344, 75, 0}, {
+ 1792, 1344, 120, RB},
+ /* byte b */
+ {
+ 1856, 1392, 60, 0}, {
+ 1856, 1392, 75, 0}, {
+ 1856, 1392, 120, RB}, {
+ 1920, 1200, 60, RB}, {
+ 1920, 1200, 60, 0}, {
+ 1920, 1200, 75, 0}, {
+ 1920, 1200, 85, 0}, {
+ 1920, 1200, 120, RB},
+ /* byte c */
+ {
+ 1920, 1440, 60, 0}, {
+ 1920, 1440, 75, 0}, {
+ 1920, 1440, 120, RB}, {
+ 2560, 1600, 60, RB}, {
+ 2560, 1600, 60, 0}, {
+ 2560, 1600, 75, 0}, {
+ 2560, 1600, 85, 0}, {
+2560, 1600, 120, RB},};
+
+static void
+didVesaTiming(int scrn, unsigned char *x, MonPtr mon)
+{
+ int i, j;
+
+ x += 3;
+
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 8; j++)
+ if (x[i] & (1 << j)) {
+ const struct did_dmt *d = &(did_dmt[i * 8 + j]);
+
+ if (d->f == INT)
+ continue;
+ mon->Modes = xf86ModesAdd(mon->Modes,
+ FindDMTMode(d->w, d->h, d->r,
+ d->f == RB));
+ }
+
+}
+
+static void
+handleDisplayIDBlock(int scrnIndex, unsigned char *x, void *closure)
+{
+ MonPtr mon = closure;
+
+ switch (x[0]) {
+ case DID_DISPLAY_PARAMETERS:
+ /* w/h are in decimillimeters */
+ mon->widthmm = (extract_le16(x, 3) + 5) / 10;
+ mon->heightmm = (extract_le16(x, 5) + 5) / 10;
+ /* XXX pixel count, feature flags, gamma, aspect, color depth */
+ break;
+
+ case DID_TIMING_RANGE_LIMITS:
+ {
+ int n;
+
+ mon->maxPixClock = max(mon->maxPixClock, extract_le24(x, 6) * 10);
+
+ n = mon->nHsync++;
+ if (n < MAX_HSYNC) {
+ mon->hsync[n].lo = x[9];
+ mon->hsync[n].hi = x[10];
+ }
+ else {
+ n = MAX_HSYNC;
+ }
+ n = mon->nVrefresh++;
+ if (n < MAX_VREFRESH) {
+ mon->vrefresh[n].lo = x[13];
+ mon->vrefresh[n].hi = x[14];
+ }
+ else {
+ n = MAX_VREFRESH;
+ }
+ break;
+ }
+
+ case DID_TIMING_1_DETAILED:
+ {
+ int i;
+
+ for (i = 0; i < x[2]; i += 20)
+ didDetailedTiming1(scrnIndex, x + i + 3, mon);
+ break;
+ }
+
+ case DID_TIMING_2_DETAILED:
+ {
+ int i;
+
+ for (i = 0; i < x[2]; i += 11)
+ didDetailedTiming2(scrnIndex, x + i + 3, mon);
+ break;
+ }
+
+ case DID_TIMING_3_SHORT:
+ {
+ int i;
+
+ for (i = 0; i < x[2]; i += 3)
+ didShortTiming(scrnIndex, x + i + 3, mon);
+ break;
+ }
+
+ case DID_TIMING_4_DMT:
+ {
+ int i;
+
+ for (i = 0; i < x[2]; i++)
+ didDMTTiming(scrnIndex, x + i + 3, mon);
+ break;
+ }
+
+ case DID_TIMING_VESA:
+ didVesaTiming(scrnIndex, x, mon);
+ break;
+
+ /* XXX pixel format, ar, orientation, subpixel, dot pitch, bit depth */
+ case DID_DISPLAY_DEVICE:
+
+ /* XXX interface, links, color encoding, ss, drm */
+ case DID_DISPLAY_INTERFACE:
+
+ /* XXX stereo */
+ case DID_STEREO:
+
+ /* nothing interesting in these */
+ case DID_COLOR_INFO:
+ case DID_PRODUCT_SERIAL:
+ case DID_ASCII_STRING:
+ case DID_POWER_SEQUENCING:
+ case DID_TRANSFER_INFO:
+ case DID_VENDOR:
+ break;
+
+ /* warn about anything else */
+ default:
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Unknown DisplayID block type %hx\n", x[0]);
+ break;
+ }
+}
+
+static void
+forEachDisplayIDBlock(int scrnIndex, unsigned char *did, did_proc proc,
+ void *closure)
+{
+ int num_extensions = did[3];
+ int section_size = did[1];
+ unsigned char *block;
+
+ do {
+ if ((did[0] & 0xf0) != 0x10) /* not 1.x, abort */
+ return;
+ /* XXX also, checksum */
+
+ block = did + 4;
+
+ while (section_size > 0) {
+ int block_size = (block[2] + 2);
+
+ proc(scrnIndex, block, closure);
+
+ section_size -= block_size;
+ block += block_size;
+ }
+
+ did += (did[1] + 5);
+ } while (num_extensions--);
+}
+
+/*
+ * Fill out MonPtr with xf86MonPtr information.
+ */
+void
+xf86DisplayIDMonitorSet(int scrnIndex, MonPtr mon, xf86MonPtr DDC)
+{
+ if (!mon || !DDC)
+ return;
+
+ mon->DDC = DDC;
+
+ forEachDisplayIDBlock(scrnIndex, DDC->rawData, handleDisplayIDBlock, mon);
+}
diff --git a/xorg-server/hw/xfree86/modes/xf86EdidModes.c b/xorg-server/hw/xfree86/modes/xf86EdidModes.c
index 0100d2a59..8aa82d114 100644
--- a/xorg-server/hw/xfree86/modes/xf86EdidModes.c
+++ b/xorg-server/hw/xfree86/modes/xf86EdidModes.c
@@ -45,12 +45,12 @@
#include <string.h>
#include <math.h>
-static void handle_detailed_rblank(struct detailed_monitor_section *det_mon,
- void *data)
+static void
+handle_detailed_rblank(struct detailed_monitor_section *det_mon, void *data)
{
if (det_mon->type == DS_RANGES)
if (det_mon->section.ranges.supported_blanking & CVT_REDUCED)
- *(Bool*)data = TRUE;
+ *(Bool *) data = TRUE;
}
static Bool
@@ -71,209 +71,189 @@ xf86MonitorSupportsReducedBlanking(xf86MonPtr DDC)
return FALSE;
}
-static Bool quirk_prefer_large_60 (int scrnIndex, xf86MonPtr DDC)
+static Bool
+quirk_prefer_large_60(int scrnIndex, xf86MonPtr DDC)
{
/* Belinea 10 15 55 */
- if (memcmp (DDC->vendor.name, "MAX", 4) == 0 &&
- ((DDC->vendor.prod_id == 1516) ||
- (DDC->vendor.prod_id == 0x77e)))
- return TRUE;
-
+ if (memcmp(DDC->vendor.name, "MAX", 4) == 0 &&
+ ((DDC->vendor.prod_id == 1516) || (DDC->vendor.prod_id == 0x77e)))
+ return TRUE;
+
/* Acer AL1706 */
- if (memcmp (DDC->vendor.name, "ACR", 4) == 0 &&
- DDC->vendor.prod_id == 44358)
- return TRUE;
+ if (memcmp(DDC->vendor.name, "ACR", 4) == 0 && DDC->vendor.prod_id == 44358)
+ return TRUE;
/* Bug #10814: Samsung SyncMaster 225BW */
- if (memcmp (DDC->vendor.name, "SAM", 4) == 0 &&
- DDC->vendor.prod_id == 596)
- return TRUE;
+ if (memcmp(DDC->vendor.name, "SAM", 4) == 0 && DDC->vendor.prod_id == 596)
+ return TRUE;
/* Bug #10545: Samsung SyncMaster 226BW */
- if (memcmp (DDC->vendor.name, "SAM", 4) == 0 &&
- DDC->vendor.prod_id == 638)
- return TRUE;
+ if (memcmp(DDC->vendor.name, "SAM", 4) == 0 && DDC->vendor.prod_id == 638)
+ return TRUE;
/* Acer F51 */
- if (memcmp (DDC->vendor.name, "API", 4) == 0 &&
- DDC->vendor.prod_id == 0x7602)
- return TRUE;
-
+ if (memcmp(DDC->vendor.name, "API", 4) == 0 &&
+ DDC->vendor.prod_id == 0x7602)
+ return TRUE;
return FALSE;
}
-static Bool quirk_prefer_large_75 (int scrnIndex, xf86MonPtr DDC)
+static Bool
+quirk_prefer_large_75(int scrnIndex, xf86MonPtr DDC)
{
/* Bug #11603: Funai Electronics PM36B */
- if (memcmp (DDC->vendor.name, "FCM", 4) == 0 &&
- DDC->vendor.prod_id == 13600)
- return TRUE;
+ if (memcmp(DDC->vendor.name, "FCM", 4) == 0 && DDC->vendor.prod_id == 13600)
+ return TRUE;
return FALSE;
}
-static Bool quirk_detailed_h_in_cm (int scrnIndex, xf86MonPtr DDC)
+static Bool
+quirk_detailed_h_in_cm(int scrnIndex, xf86MonPtr DDC)
{
/* Bug #11603: Funai Electronics PM36B */
- if (memcmp (DDC->vendor.name, "FCM", 4) == 0 &&
- DDC->vendor.prod_id == 13600)
- return TRUE;
+ if (memcmp(DDC->vendor.name, "FCM", 4) == 0 && DDC->vendor.prod_id == 13600)
+ return TRUE;
return FALSE;
}
-static Bool quirk_detailed_v_in_cm (int scrnIndex, xf86MonPtr DDC)
+static Bool
+quirk_detailed_v_in_cm(int scrnIndex, xf86MonPtr DDC)
{
/* Bug #11603: Funai Electronics PM36B */
- if (memcmp (DDC->vendor.name, "FCM", 4) == 0 &&
- DDC->vendor.prod_id == 13600)
- return TRUE;
+ if (memcmp(DDC->vendor.name, "FCM", 4) == 0 && DDC->vendor.prod_id == 13600)
+ return TRUE;
/* Bug #21000: LGPhilipsLCD LP154W01-TLAJ */
- if (memcmp (DDC->vendor.name, "LPL", 4) == 0 &&
- DDC->vendor.prod_id == 47360)
- return TRUE;
+ if (memcmp(DDC->vendor.name, "LPL", 4) == 0 && DDC->vendor.prod_id == 47360)
+ return TRUE;
/* Bug #10304: LGPhilipsLCD LP154W01-A5 */
- if (memcmp(DDC->vendor.name, "LPL", 4) == 0 &&
- DDC->vendor.prod_id == 0)
- return TRUE;
+ if (memcmp(DDC->vendor.name, "LPL", 4) == 0 && DDC->vendor.prod_id == 0)
+ return TRUE;
/* Bug #24482: LGPhilipsLCD LP154W01-TLA1 */
if (memcmp(DDC->vendor.name, "LPL", 4) == 0 &&
- DDC->vendor.prod_id == 0x2a00)
- return TRUE;
+ DDC->vendor.prod_id == 0x2a00)
+ return TRUE;
/* Bug #28414: HP Compaq NC8430 LP154W01-TLA8 */
- if (memcmp (DDC->vendor.name, "LPL", 4) == 0 &&
- DDC->vendor.prod_id == 5750)
- return TRUE;
+ if (memcmp(DDC->vendor.name, "LPL", 4) == 0 && DDC->vendor.prod_id == 5750)
+ return TRUE;
/* Bug #21750: Samsung Syncmaster 2333HD */
- if (memcmp (DDC->vendor.name, "SAM", 4) == 0 &&
- DDC->vendor.prod_id == 1157)
- return TRUE;
+ if (memcmp(DDC->vendor.name, "SAM", 4) == 0 && DDC->vendor.prod_id == 1157)
+ return TRUE;
return FALSE;
}
-static Bool quirk_detailed_use_maximum_size (int scrnIndex, xf86MonPtr DDC)
+static Bool
+quirk_detailed_use_maximum_size(int scrnIndex, xf86MonPtr DDC)
{
/* Bug #21324: Iiyama Vision Master 450 */
- if (memcmp (DDC->vendor.name, "IVM", 4) == 0 &&
- DDC->vendor.prod_id == 6400)
- return TRUE;
+ if (memcmp(DDC->vendor.name, "IVM", 4) == 0 && DDC->vendor.prod_id == 6400)
+ return TRUE;
/* Bug #41141: Acer Aspire One */
- if (memcmp (DDC->vendor.name, "LGD", 4) == 0 &&
- DDC->vendor.prod_id == 0x7f01)
- return TRUE;
+ if (memcmp(DDC->vendor.name, "LGD", 4) == 0 &&
+ DDC->vendor.prod_id == 0x7f01)
+ return TRUE;
return FALSE;
}
-static Bool quirk_135_clock_too_high (int scrnIndex, xf86MonPtr DDC)
+static Bool
+quirk_135_clock_too_high(int scrnIndex, xf86MonPtr DDC)
{
/* Envision Peripherals, Inc. EN-7100e. See bug #9550. */
- if (memcmp (DDC->vendor.name, "EPI", 4) == 0 &&
- DDC->vendor.prod_id == 59264)
- return TRUE;
-
+ if (memcmp(DDC->vendor.name, "EPI", 4) == 0 && DDC->vendor.prod_id == 59264)
+ return TRUE;
+
return FALSE;
}
-static Bool quirk_first_detailed_preferred (int scrnIndex, xf86MonPtr DDC)
+static Bool
+quirk_first_detailed_preferred(int scrnIndex, xf86MonPtr DDC)
{
/* Philips 107p5 CRT. Reported on xorg@ with pastebin. */
- if (memcmp (DDC->vendor.name, "PHL", 4) == 0 &&
- DDC->vendor.prod_id == 57364)
- return TRUE;
+ if (memcmp(DDC->vendor.name, "PHL", 4) == 0 && DDC->vendor.prod_id == 57364)
+ return TRUE;
- /* Proview AY765C 17" LCD. See bug #15160*/
- if (memcmp (DDC->vendor.name, "PTS", 4) == 0 &&
- DDC->vendor.prod_id == 765)
- return TRUE;
+ /* Proview AY765C 17" LCD. See bug #15160 */
+ if (memcmp(DDC->vendor.name, "PTS", 4) == 0 && DDC->vendor.prod_id == 765)
+ return TRUE;
/* ACR of some sort RH #284231 */
- if (memcmp (DDC->vendor.name, "ACR", 4) == 0 &&
- DDC->vendor.prod_id == 2423)
- return TRUE;
+ if (memcmp(DDC->vendor.name, "ACR", 4) == 0 && DDC->vendor.prod_id == 2423)
+ return TRUE;
/* Peacock Ergovision 19. See rh#492359 */
- if (memcmp (DDC->vendor.name, "PEA", 4) == 0 &&
- DDC->vendor.prod_id == 9003)
- return TRUE;
+ if (memcmp(DDC->vendor.name, "PEA", 4) == 0 && DDC->vendor.prod_id == 9003)
+ return TRUE;
return FALSE;
}
-static Bool quirk_detailed_sync_pp(int scrnIndex, xf86MonPtr DDC)
+static Bool
+quirk_detailed_sync_pp(int scrnIndex, xf86MonPtr DDC)
{
/* Bug #12439: Samsung SyncMaster 205BW */
- if (memcmp (DDC->vendor.name, "SAM", 4) == 0 &&
- DDC->vendor.prod_id == 541)
- return TRUE;
+ if (memcmp(DDC->vendor.name, "SAM", 4) == 0 && DDC->vendor.prod_id == 541)
+ return TRUE;
return FALSE;
}
/* This should probably be made more generic */
-static Bool quirk_dvi_single_link(int scrnIndex, xf86MonPtr DDC)
+static Bool
+quirk_dvi_single_link(int scrnIndex, xf86MonPtr DDC)
{
/* Red Hat bug #453106: Apple 23" Cinema Display */
- if (memcmp (DDC->vendor.name, "APL", 4) == 0 &&
- DDC->vendor.prod_id == 0x921c)
- return TRUE;
+ if (memcmp(DDC->vendor.name, "APL", 4) == 0 &&
+ DDC->vendor.prod_id == 0x921c)
+ return TRUE;
return FALSE;
}
typedef struct {
- Bool (*detect) (int scrnIndex, xf86MonPtr DDC);
- ddc_quirk_t quirk;
- const char *description;
+ Bool (*detect) (int scrnIndex, xf86MonPtr DDC);
+ ddc_quirk_t quirk;
+ const char *description;
} ddc_quirk_map_t;
static const ddc_quirk_map_t ddc_quirks[] = {
{
- quirk_prefer_large_60, DDC_QUIRK_PREFER_LARGE_60,
- "Detailed timing is not preferred, use largest mode at 60Hz"
- },
+ quirk_prefer_large_60, DDC_QUIRK_PREFER_LARGE_60,
+ "Detailed timing is not preferred, use largest mode at 60Hz"},
+ {
+ quirk_135_clock_too_high, DDC_QUIRK_135_CLOCK_TOO_HIGH,
+ "Recommended 135MHz pixel clock is too high"},
{
- quirk_135_clock_too_high, DDC_QUIRK_135_CLOCK_TOO_HIGH,
- "Recommended 135MHz pixel clock is too high"
- },
+ quirk_prefer_large_75, DDC_QUIRK_PREFER_LARGE_75,
+ "Detailed timing is not preferred, use largest mode at 75Hz"},
{
- quirk_prefer_large_75, DDC_QUIRK_PREFER_LARGE_75,
- "Detailed timing is not preferred, use largest mode at 75Hz"
- },
+ quirk_detailed_h_in_cm, DDC_QUIRK_DETAILED_H_IN_CM,
+ "Detailed timings give horizontal size in cm."},
{
- quirk_detailed_h_in_cm, DDC_QUIRK_DETAILED_H_IN_CM,
- "Detailed timings give horizontal size in cm."
- },
+ quirk_detailed_v_in_cm, DDC_QUIRK_DETAILED_V_IN_CM,
+ "Detailed timings give vertical size in cm."},
{
- quirk_detailed_v_in_cm, DDC_QUIRK_DETAILED_V_IN_CM,
- "Detailed timings give vertical size in cm."
- },
+ quirk_detailed_use_maximum_size, DDC_QUIRK_DETAILED_USE_MAXIMUM_SIZE,
+ "Use maximum size instead of detailed timing sizes."},
{
- quirk_detailed_use_maximum_size, DDC_QUIRK_DETAILED_USE_MAXIMUM_SIZE,
- "Use maximum size instead of detailed timing sizes."
- },
+ quirk_first_detailed_preferred, DDC_QUIRK_FIRST_DETAILED_PREFERRED,
+ "First detailed timing was not marked as preferred."},
{
- quirk_first_detailed_preferred, DDC_QUIRK_FIRST_DETAILED_PREFERRED,
- "First detailed timing was not marked as preferred."
- },
+ quirk_detailed_sync_pp, DDC_QUIRK_DETAILED_SYNC_PP,
+ "Use +hsync +vsync for detailed timing."},
{
- quirk_detailed_sync_pp, DDC_QUIRK_DETAILED_SYNC_PP,
- "Use +hsync +vsync for detailed timing."
- },
+ quirk_dvi_single_link, DDC_QUIRK_DVI_SINGLE_LINK,
+ "Forcing maximum pixel clock to single DVI link."},
{
- quirk_dvi_single_link, DDC_QUIRK_DVI_SINGLE_LINK,
- "Forcing maximum pixel clock to single DVI link."
- },
- {
- NULL, DDC_QUIRK_NONE,
- "No known quirks"
- },
+ NULL, DDC_QUIRK_NONE,
+ "No known quirks"},
};
/*
@@ -289,28 +269,28 @@ static const ddc_quirk_map_t ddc_quirks[] = {
#define MODESUFFIX 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0
static const DisplayModeRec DDCEstablishedModes[17] = {
- { MODEPREFIX, 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@60Hz */
- { MODEPREFIX, 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@56Hz */
- { MODEPREFIX, 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@75Hz */
- { MODEPREFIX, 31500, 640, 664, 704, 832, 0, 480, 489, 492, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@72Hz */
- { MODEPREFIX, 30240, 640, 704, 768, 864, 0, 480, 483, 486, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@67Hz */
- { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@60Hz */
- { MODEPREFIX, 35500, 720, 738, 846, 900, 0, 400, 421, 423, 449, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 720x400@88Hz */
- { MODEPREFIX, 28320, 720, 738, 846, 900, 0, 400, 412, 414, 449, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400@70Hz */
- { MODEPREFIX, 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@75Hz */
- { MODEPREFIX, 78750, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@75Hz */
- { MODEPREFIX, 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@70Hz */
- { MODEPREFIX, 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@60Hz */
- { MODEPREFIX, 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 772, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768@43Hz */
- { MODEPREFIX, 57284, 832, 864, 928, 1152, 0, 624, 625, 628, 667, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 832x624@75Hz */
- { MODEPREFIX, 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@75Hz */
- { MODEPREFIX, 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@72Hz */
- { MODEPREFIX, 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864@75Hz */
+ {MODEPREFIX, 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 800x600@60Hz */
+ {MODEPREFIX, 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 800x600@56Hz */
+ {MODEPREFIX, 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* 640x480@75Hz */
+ {MODEPREFIX, 31500, 640, 664, 704, 832, 0, 480, 489, 492, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* 640x480@72Hz */
+ {MODEPREFIX, 30240, 640, 704, 768, 864, 0, 480, 483, 486, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* 640x480@67Hz */
+ {MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* 640x480@60Hz */
+ {MODEPREFIX, 35500, 720, 738, 846, 900, 0, 400, 421, 423, 449, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* 720x400@88Hz */
+ {MODEPREFIX, 28320, 720, 738, 846, 900, 0, 400, 412, 414, 449, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 720x400@70Hz */
+ {MODEPREFIX, 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 1280x1024@75Hz */
+ {MODEPREFIX, 78750, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 1024x768@75Hz */
+ {MODEPREFIX, 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* 1024x768@70Hz */
+ {MODEPREFIX, 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* 1024x768@60Hz */
+ {MODEPREFIX, 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 772, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX}, /* 1024x768@43Hz */
+ {MODEPREFIX, 57284, 832, 864, 928, 1152, 0, 624, 625, 628, 667, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* 832x624@75Hz */
+ {MODEPREFIX, 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 800x600@75Hz */
+ {MODEPREFIX, 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 800x600@72Hz */
+ {MODEPREFIX, 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 1152x864@75Hz */
};
static DisplayModePtr
DDCModesFromEstablished(int scrnIndex, struct established_timings *timing,
- ddc_quirk_t quirks)
+ ddc_quirk_t quirks)
{
DisplayModePtr Modes = NULL, Mode = NULL;
CARD32 bits = (timing->t1) | (timing->t2 << 8) |
@@ -329,86 +309,86 @@ DDCModesFromEstablished(int scrnIndex, struct established_timings *timing,
/* Autogenerated from the DMT spec */
const DisplayModeRec DMTModes[] = {
- { MODEPREFIX, 31500, 640, 672, 736, 832, 0, 350, 382, 385, 445, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x350@85Hz */
- { MODEPREFIX, 31500, 640, 672, 736, 832, 0, 400, 401, 404, 445, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 640x400@85Hz */
- { MODEPREFIX, 35500, 720, 756, 828, 936, 0, 400, 401, 404, 446, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400@85Hz */
- { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@60Hz */
- { MODEPREFIX, 31500, 640, 664, 704, 832, 0, 480, 489, 492, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@72Hz */
- { MODEPREFIX, 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@75Hz */
- { MODEPREFIX, 36000, 640, 696, 752, 832, 0, 480, 481, 484, 509, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@85Hz */
- { MODEPREFIX, 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@56Hz */
- { MODEPREFIX, 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@60Hz */
- { MODEPREFIX, 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@72Hz */
- { MODEPREFIX, 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@75Hz */
- { MODEPREFIX, 56250, 800, 832, 896, 1048, 0, 600, 601, 604, 631, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@85Hz */
- { MODEPREFIX, 73250, 800, 848, 880, 960, 0, 600, 603, 607, 636, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 800x600@120Hz RB */
- { MODEPREFIX, 33750, 848, 864, 976, 1088, 0, 480, 486, 494, 517, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 848x480@60Hz */
- { MODEPREFIX, 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 772, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768@43Hz (interlaced) */
- { MODEPREFIX, 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@60Hz */
- { MODEPREFIX, 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@70Hz */
- { MODEPREFIX, 78750, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@75Hz */
- { MODEPREFIX, 94500, 1024, 1072, 1168, 1376, 0, 768, 769, 772, 808, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@85Hz */
- { MODEPREFIX, 115500, 1024, 1072, 1104, 1184, 0, 768, 771, 775, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@120Hz RB */
- { MODEPREFIX, 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864@75Hz */
- { MODEPREFIX, 68250, 1280, 1328, 1360, 1440, 0, 768, 771, 778, 790, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x768@60Hz RB */
- { MODEPREFIX, 79500, 1280, 1344, 1472, 1664, 0, 768, 771, 778, 798, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@60Hz */
- { MODEPREFIX, 102250, 1280, 1360, 1488, 1696, 0, 768, 771, 778, 805, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@75Hz */
- { MODEPREFIX, 117500, 1280, 1360, 1496, 1712, 0, 768, 771, 778, 809, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@85Hz */
- { MODEPREFIX, 140250, 1280, 1328, 1360, 1440, 0, 768, 771, 778, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x768@120Hz RB */
- { MODEPREFIX, 71000, 1280, 1328, 1360, 1440, 0, 800, 803, 809, 823, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x800@60Hz RB */
- { MODEPREFIX, 83500, 1280, 1352, 1480, 1680, 0, 800, 803, 809, 831, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@60Hz */
- { MODEPREFIX, 106500, 1280, 1360, 1488, 1696, 0, 800, 803, 809, 838, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@75Hz */
- { MODEPREFIX, 122500, 1280, 1360, 1496, 1712, 0, 800, 803, 809, 843, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@85Hz */
- { MODEPREFIX, 146250, 1280, 1328, 1360, 1440, 0, 800, 803, 809, 847, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x800@120Hz RB */
- { MODEPREFIX, 108000, 1280, 1376, 1488, 1800, 0, 960, 961, 964, 1000, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x960@60Hz */
- { MODEPREFIX, 148500, 1280, 1344, 1504, 1728, 0, 960, 961, 964, 1011, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x960@85Hz */
- { MODEPREFIX, 175500, 1280, 1328, 1360, 1440, 0, 960, 963, 967, 1017, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x960@120Hz RB */
- { MODEPREFIX, 108000, 1280, 1328, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@60Hz */
- { MODEPREFIX, 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@75Hz */
- { MODEPREFIX, 157500, 1280, 1344, 1504, 1728, 0, 1024, 1025, 1028, 1072, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@85Hz */
- { MODEPREFIX, 187250, 1280, 1328, 1360, 1440, 0, 1024, 1027, 1034, 1084, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x1024@120Hz RB */
- { MODEPREFIX, 85500, 1360, 1424, 1536, 1792, 0, 768, 771, 777, 795, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1360x768@60Hz */
- { MODEPREFIX, 148250, 1360, 1408, 1440, 1520, 0, 768, 771, 776, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1360x768@120Hz RB */
- { MODEPREFIX, 101000, 1400, 1448, 1480, 1560, 0, 1050, 1053, 1057, 1080, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1400x1050@60Hz RB */
- { MODEPREFIX, 121750, 1400, 1488, 1632, 1864, 0, 1050, 1053, 1057, 1089, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@60Hz */
- { MODEPREFIX, 156000, 1400, 1504, 1648, 1896, 0, 1050, 1053, 1057, 1099, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@75Hz */
- { MODEPREFIX, 179500, 1400, 1504, 1656, 1912, 0, 1050, 1053, 1057, 1105, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@85Hz */
- { MODEPREFIX, 208000, 1400, 1448, 1480, 1560, 0, 1050, 1053, 1057, 1112, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1400x1050@120Hz RB */
- { MODEPREFIX, 88750, 1440, 1488, 1520, 1600, 0, 900, 903, 909, 926, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1440x900@60Hz RB */
- { MODEPREFIX, 106500, 1440, 1520, 1672, 1904, 0, 900, 903, 909, 934, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@60Hz */
- { MODEPREFIX, 136750, 1440, 1536, 1688, 1936, 0, 900, 903, 909, 942, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@75Hz */
- { MODEPREFIX, 157000, 1440, 1544, 1696, 1952, 0, 900, 903, 909, 948, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@85Hz */
- { MODEPREFIX, 182750, 1440, 1488, 1520, 1600, 0, 900, 903, 909, 953, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1440x900@120Hz RB */
- { MODEPREFIX, 162000, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@60Hz */
- { MODEPREFIX, 175500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@65Hz */
- { MODEPREFIX, 189000, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@70Hz */
- { MODEPREFIX, 202500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@75Hz */
- { MODEPREFIX, 229500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@85Hz */
- { MODEPREFIX, 268250, 1600, 1648, 1680, 1760, 0, 1200, 1203, 1207, 1271, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1600x1200@120Hz RB */
- { MODEPREFIX, 119000, 1680, 1728, 1760, 1840, 0, 1050, 1053, 1059, 1080, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1680x1050@60Hz RB */
- { MODEPREFIX, 146250, 1680, 1784, 1960, 2240, 0, 1050, 1053, 1059, 1089, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@60Hz */
- { MODEPREFIX, 187000, 1680, 1800, 1976, 2272, 0, 1050, 1053, 1059, 1099, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@75Hz */
- { MODEPREFIX, 214750, 1680, 1808, 1984, 2288, 0, 1050, 1053, 1059, 1105, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@85Hz */
- { MODEPREFIX, 245500, 1680, 1728, 1760, 1840, 0, 1050, 1053, 1059, 1112, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1680x1050@120Hz RB */
- { MODEPREFIX, 204750, 1792, 1920, 2120, 2448, 0, 1344, 1345, 1348, 1394, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1792x1344@60Hz */
- { MODEPREFIX, 261000, 1792, 1888, 2104, 2456, 0, 1344, 1345, 1348, 1417, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1792x1344@75Hz */
- { MODEPREFIX, 333250, 1792, 1840, 1872, 1952, 0, 1344, 1347, 1351, 1423, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1792x1344@120Hz RB */
- { MODEPREFIX, 218250, 1856, 1952, 2176, 2528, 0, 1392, 1393, 1396, 1439, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1856x1392@60Hz */
- { MODEPREFIX, 288000, 1856, 1984, 2208, 2560, 0, 1392, 1393, 1396, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1856x1392@75Hz */
- { MODEPREFIX, 356500, 1856, 1904, 1936, 2016, 0, 1392, 1395, 1399, 1474, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1856x1392@120Hz RB */
- { MODEPREFIX, 154000, 1920, 1968, 2000, 2080, 0, 1200, 1203, 1209, 1235, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1200@60Hz RB */
- { MODEPREFIX, 193250, 1920, 2056, 2256, 2592, 0, 1200, 1203, 1209, 1245, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@60Hz */
- { MODEPREFIX, 245250, 1920, 2056, 2264, 2608, 0, 1200, 1203, 1209, 1255, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@75Hz */
- { MODEPREFIX, 281250, 1920, 2064, 2272, 2624, 0, 1200, 1203, 1209, 1262, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@85Hz */
- { MODEPREFIX, 317000, 1920, 1968, 2000, 2080, 0, 1200, 1203, 1209, 1271, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1200@120Hz RB */
- { MODEPREFIX, 234000, 1920, 2048, 2256, 2600, 0, 1440, 1441, 1444, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1440@60Hz */
- { MODEPREFIX, 297000, 1920, 2064, 2288, 2640, 0, 1440, 1441, 1444, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1440@75Hz */
- { MODEPREFIX, 380500, 1920, 1968, 2000, 2080, 0, 1440, 1443, 1447, 1525, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1440@120Hz RB */
- { MODEPREFIX, 268500, 2560, 2608, 2640, 2720, 0, 1600, 1603, 1609, 1646, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 2560x1600@60Hz RB */
- { MODEPREFIX, 348500, 2560, 2752, 3032, 3504, 0, 1600, 1603, 1609, 1658, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@60Hz */
- { MODEPREFIX, 443250, 2560, 2768, 3048, 3536, 0, 1600, 1603, 1609, 1672, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@75Hz */
- { MODEPREFIX, 505250, 2560, 2768, 3048, 3536, 0, 1600, 1603, 1609, 1682, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@85Hz */
- { MODEPREFIX, 552750, 2560, 2608, 2640, 2720, 0, 1600, 1603, 1609, 1694, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 2560x1600@120Hz RB */
+ {MODEPREFIX, 31500, 640, 672, 736, 832, 0, 350, 382, 385, 445, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 640x350@85Hz */
+ {MODEPREFIX, 31500, 640, 672, 736, 832, 0, 400, 401, 404, 445, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 640x400@85Hz */
+ {MODEPREFIX, 35500, 720, 756, 828, 936, 0, 400, 401, 404, 446, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 720x400@85Hz */
+ {MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* 640x480@60Hz */
+ {MODEPREFIX, 31500, 640, 664, 704, 832, 0, 480, 489, 492, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* 640x480@72Hz */
+ {MODEPREFIX, 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* 640x480@75Hz */
+ {MODEPREFIX, 36000, 640, 696, 752, 832, 0, 480, 481, 484, 509, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* 640x480@85Hz */
+ {MODEPREFIX, 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 800x600@56Hz */
+ {MODEPREFIX, 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 800x600@60Hz */
+ {MODEPREFIX, 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 800x600@72Hz */
+ {MODEPREFIX, 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 800x600@75Hz */
+ {MODEPREFIX, 56250, 800, 832, 896, 1048, 0, 600, 601, 604, 631, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 800x600@85Hz */
+ {MODEPREFIX, 73250, 800, 848, 880, 960, 0, 600, 603, 607, 636, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 800x600@120Hz RB */
+ {MODEPREFIX, 33750, 848, 864, 976, 1088, 0, 480, 486, 494, 517, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 848x480@60Hz */
+ {MODEPREFIX, 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 772, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX}, /* 1024x768@43Hz (interlaced) */
+ {MODEPREFIX, 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* 1024x768@60Hz */
+ {MODEPREFIX, 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* 1024x768@70Hz */
+ {MODEPREFIX, 78750, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 1024x768@75Hz */
+ {MODEPREFIX, 94500, 1024, 1072, 1168, 1376, 0, 768, 769, 772, 808, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 1024x768@85Hz */
+ {MODEPREFIX, 115500, 1024, 1072, 1104, 1184, 0, 768, 771, 775, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 1024x768@120Hz RB */
+ {MODEPREFIX, 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 1152x864@75Hz */
+ {MODEPREFIX, 68250, 1280, 1328, 1360, 1440, 0, 768, 771, 778, 790, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 1280x768@60Hz RB */
+ {MODEPREFIX, 79500, 1280, 1344, 1472, 1664, 0, 768, 771, 778, 798, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1280x768@60Hz */
+ {MODEPREFIX, 102250, 1280, 1360, 1488, 1696, 0, 768, 771, 778, 805, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1280x768@75Hz */
+ {MODEPREFIX, 117500, 1280, 1360, 1496, 1712, 0, 768, 771, 778, 809, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1280x768@85Hz */
+ {MODEPREFIX, 140250, 1280, 1328, 1360, 1440, 0, 768, 771, 778, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 1280x768@120Hz RB */
+ {MODEPREFIX, 71000, 1280, 1328, 1360, 1440, 0, 800, 803, 809, 823, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 1280x800@60Hz RB */
+ {MODEPREFIX, 83500, 1280, 1352, 1480, 1680, 0, 800, 803, 809, 831, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1280x800@60Hz */
+ {MODEPREFIX, 106500, 1280, 1360, 1488, 1696, 0, 800, 803, 809, 838, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1280x800@75Hz */
+ {MODEPREFIX, 122500, 1280, 1360, 1496, 1712, 0, 800, 803, 809, 843, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1280x800@85Hz */
+ {MODEPREFIX, 146250, 1280, 1328, 1360, 1440, 0, 800, 803, 809, 847, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 1280x800@120Hz RB */
+ {MODEPREFIX, 108000, 1280, 1376, 1488, 1800, 0, 960, 961, 964, 1000, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 1280x960@60Hz */
+ {MODEPREFIX, 148500, 1280, 1344, 1504, 1728, 0, 960, 961, 964, 1011, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 1280x960@85Hz */
+ {MODEPREFIX, 175500, 1280, 1328, 1360, 1440, 0, 960, 963, 967, 1017, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 1280x960@120Hz RB */
+ {MODEPREFIX, 108000, 1280, 1328, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 1280x1024@60Hz */
+ {MODEPREFIX, 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 1280x1024@75Hz */
+ {MODEPREFIX, 157500, 1280, 1344, 1504, 1728, 0, 1024, 1025, 1028, 1072, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 1280x1024@85Hz */
+ {MODEPREFIX, 187250, 1280, 1328, 1360, 1440, 0, 1024, 1027, 1034, 1084, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 1280x1024@120Hz RB */
+ {MODEPREFIX, 85500, 1360, 1424, 1536, 1792, 0, 768, 771, 777, 795, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 1360x768@60Hz */
+ {MODEPREFIX, 148250, 1360, 1408, 1440, 1520, 0, 768, 771, 776, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 1360x768@120Hz RB */
+ {MODEPREFIX, 101000, 1400, 1448, 1480, 1560, 0, 1050, 1053, 1057, 1080, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 1400x1050@60Hz RB */
+ {MODEPREFIX, 121750, 1400, 1488, 1632, 1864, 0, 1050, 1053, 1057, 1089, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1400x1050@60Hz */
+ {MODEPREFIX, 156000, 1400, 1504, 1648, 1896, 0, 1050, 1053, 1057, 1099, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1400x1050@75Hz */
+ {MODEPREFIX, 179500, 1400, 1504, 1656, 1912, 0, 1050, 1053, 1057, 1105, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1400x1050@85Hz */
+ {MODEPREFIX, 208000, 1400, 1448, 1480, 1560, 0, 1050, 1053, 1057, 1112, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 1400x1050@120Hz RB */
+ {MODEPREFIX, 88750, 1440, 1488, 1520, 1600, 0, 900, 903, 909, 926, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 1440x900@60Hz RB */
+ {MODEPREFIX, 106500, 1440, 1520, 1672, 1904, 0, 900, 903, 909, 934, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1440x900@60Hz */
+ {MODEPREFIX, 136750, 1440, 1536, 1688, 1936, 0, 900, 903, 909, 942, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1440x900@75Hz */
+ {MODEPREFIX, 157000, 1440, 1544, 1696, 1952, 0, 900, 903, 909, 948, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1440x900@85Hz */
+ {MODEPREFIX, 182750, 1440, 1488, 1520, 1600, 0, 900, 903, 909, 953, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 1440x900@120Hz RB */
+ {MODEPREFIX, 162000, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 1600x1200@60Hz */
+ {MODEPREFIX, 175500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 1600x1200@65Hz */
+ {MODEPREFIX, 189000, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 1600x1200@70Hz */
+ {MODEPREFIX, 202500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 1600x1200@75Hz */
+ {MODEPREFIX, 229500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* 1600x1200@85Hz */
+ {MODEPREFIX, 268250, 1600, 1648, 1680, 1760, 0, 1200, 1203, 1207, 1271, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 1600x1200@120Hz RB */
+ {MODEPREFIX, 119000, 1680, 1728, 1760, 1840, 0, 1050, 1053, 1059, 1080, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 1680x1050@60Hz RB */
+ {MODEPREFIX, 146250, 1680, 1784, 1960, 2240, 0, 1050, 1053, 1059, 1089, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1680x1050@60Hz */
+ {MODEPREFIX, 187000, 1680, 1800, 1976, 2272, 0, 1050, 1053, 1059, 1099, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1680x1050@75Hz */
+ {MODEPREFIX, 214750, 1680, 1808, 1984, 2288, 0, 1050, 1053, 1059, 1105, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1680x1050@85Hz */
+ {MODEPREFIX, 245500, 1680, 1728, 1760, 1840, 0, 1050, 1053, 1059, 1112, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 1680x1050@120Hz RB */
+ {MODEPREFIX, 204750, 1792, 1920, 2120, 2448, 0, 1344, 1345, 1348, 1394, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1792x1344@60Hz */
+ {MODEPREFIX, 261000, 1792, 1888, 2104, 2456, 0, 1344, 1345, 1348, 1417, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1792x1344@75Hz */
+ {MODEPREFIX, 333250, 1792, 1840, 1872, 1952, 0, 1344, 1347, 1351, 1423, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 1792x1344@120Hz RB */
+ {MODEPREFIX, 218250, 1856, 1952, 2176, 2528, 0, 1392, 1393, 1396, 1439, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1856x1392@60Hz */
+ {MODEPREFIX, 288000, 1856, 1984, 2208, 2560, 0, 1392, 1393, 1396, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1856x1392@75Hz */
+ {MODEPREFIX, 356500, 1856, 1904, 1936, 2016, 0, 1392, 1395, 1399, 1474, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 1856x1392@120Hz RB */
+ {MODEPREFIX, 154000, 1920, 1968, 2000, 2080, 0, 1200, 1203, 1209, 1235, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 1920x1200@60Hz RB */
+ {MODEPREFIX, 193250, 1920, 2056, 2256, 2592, 0, 1200, 1203, 1209, 1245, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1920x1200@60Hz */
+ {MODEPREFIX, 245250, 1920, 2056, 2264, 2608, 0, 1200, 1203, 1209, 1255, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1920x1200@75Hz */
+ {MODEPREFIX, 281250, 1920, 2064, 2272, 2624, 0, 1200, 1203, 1209, 1262, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1920x1200@85Hz */
+ {MODEPREFIX, 317000, 1920, 1968, 2000, 2080, 0, 1200, 1203, 1209, 1271, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 1920x1200@120Hz RB */
+ {MODEPREFIX, 234000, 1920, 2048, 2256, 2600, 0, 1440, 1441, 1444, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1920x1440@60Hz */
+ {MODEPREFIX, 297000, 1920, 2064, 2288, 2640, 0, 1440, 1441, 1444, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 1920x1440@75Hz */
+ {MODEPREFIX, 380500, 1920, 1968, 2000, 2080, 0, 1440, 1443, 1447, 1525, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 1920x1440@120Hz RB */
+ {MODEPREFIX, 268500, 2560, 2608, 2640, 2720, 0, 1600, 1603, 1609, 1646, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 2560x1600@60Hz RB */
+ {MODEPREFIX, 348500, 2560, 2752, 3032, 3504, 0, 1600, 1603, 1609, 1658, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 2560x1600@60Hz */
+ {MODEPREFIX, 443250, 2560, 2768, 3048, 3536, 0, 1600, 1603, 1609, 1672, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 2560x1600@75Hz */
+ {MODEPREFIX, 505250, 2560, 2768, 3048, 3536, 0, 1600, 1603, 1609, 1682, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX}, /* 2560x1600@85Hz */
+ {MODEPREFIX, 552750, 2560, 2608, 2640, 2720, 0, 1600, 1603, 1609, 1694, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX}, /* 2560x1600@120Hz RB */
};
#define LEVEL_DMT 0
@@ -419,18 +399,18 @@ static int
MonitorStandardTimingLevel(xf86MonPtr DDC)
{
if (DDC->ver.revision >= 2) {
- if (DDC->ver.revision >= 4 && CVT_SUPPORTED(DDC->features.msc)) {
- return LEVEL_CVT;
- }
- return LEVEL_GTF;
+ if (DDC->ver.revision >= 4 && CVT_SUPPORTED(DDC->features.msc)) {
+ return LEVEL_CVT;
+ }
+ return LEVEL_GTF;
}
return LEVEL_DMT;
}
static int
-ModeRefresh(const DisplayModeRec *mode)
+ModeRefresh(const DisplayModeRec * mode)
{
- return (int)(xf86ModeVRefresh(mode) + 0.5);
+ return (int) (xf86ModeVRefresh(mode) + 0.5);
}
/*
@@ -445,15 +425,14 @@ FindDMTMode(int hsize, int vsize, int refresh, Bool rb)
const DisplayModeRec *ret;
for (i = 0; i < sizeof(DMTModes) / sizeof(DisplayModeRec); i++) {
- ret = &DMTModes[i];
+ ret = &DMTModes[i];
- if (!rb && xf86ModeIsReduced(ret))
- continue;
+ if (!rb && xf86ModeIsReduced(ret))
+ continue;
- if (ret->HDisplay == hsize &&
- ret->VDisplay == vsize &&
- refresh == ModeRefresh(ret))
- return xf86DuplicateMode(ret);
+ if (ret->HDisplay == hsize &&
+ ret->VDisplay == vsize && refresh == ModeRefresh(ret))
+ return xf86DuplicateMode(ret);
}
return NULL;
@@ -478,42 +457,43 @@ FindDMTMode(int hsize, int vsize, int refresh, Bool rb)
*/
static DisplayModePtr
DDCModesFromStandardTiming(struct std_timings *timing, ddc_quirk_t quirks,
- int timing_level, Bool rb)
+ int timing_level, Bool rb)
{
DisplayModePtr Modes = NULL, Mode = NULL;
int i, hsize, vsize, refresh;
for (i = 0; i < STD_TIMINGS; i++) {
- hsize = timing[i].hsize;
- vsize = timing[i].vsize;
- refresh = timing[i].refresh;
-
- /* HDTV hack, because you can't say 1366 */
- if (refresh == 60 &&
- ((hsize == 1360 && vsize == 765) ||
- (hsize == 1368 && vsize == 769))) {
- Mode = xf86CVTMode(1366, 768, 60, FALSE, FALSE);
- Mode->HDisplay = 1366;
- Mode->HSyncStart--;
- Mode->HSyncEnd--;
- } else if (hsize && vsize && refresh) {
- Mode = FindDMTMode(hsize, vsize, refresh, rb);
-
- if (!Mode) {
- if (timing_level == LEVEL_CVT)
- /* pass rb here too? */
- Mode = xf86CVTMode(hsize, vsize, refresh, FALSE, FALSE);
- else if (timing_level == LEVEL_GTF)
- Mode = xf86GTFMode(hsize, vsize, refresh, FALSE, FALSE);
- }
-
- }
-
- if (Mode) {
- Mode->type = M_T_DRIVER;
- Modes = xf86ModesAdd(Modes, Mode);
- }
- Mode = NULL;
+ hsize = timing[i].hsize;
+ vsize = timing[i].vsize;
+ refresh = timing[i].refresh;
+
+ /* HDTV hack, because you can't say 1366 */
+ if (refresh == 60 &&
+ ((hsize == 1360 && vsize == 765) ||
+ (hsize == 1368 && vsize == 769))) {
+ Mode = xf86CVTMode(1366, 768, 60, FALSE, FALSE);
+ Mode->HDisplay = 1366;
+ Mode->HSyncStart--;
+ Mode->HSyncEnd--;
+ }
+ else if (hsize && vsize && refresh) {
+ Mode = FindDMTMode(hsize, vsize, refresh, rb);
+
+ if (!Mode) {
+ if (timing_level == LEVEL_CVT)
+ /* pass rb here too? */
+ Mode = xf86CVTMode(hsize, vsize, refresh, FALSE, FALSE);
+ else if (timing_level == LEVEL_GTF)
+ Mode = xf86GTFMode(hsize, vsize, refresh, FALSE, FALSE);
+ }
+
+ }
+
+ if (Mode) {
+ Mode->type = M_T_DRIVER;
+ Modes = xf86ModesAdd(Modes, Mode);
+ }
+ Mode = NULL;
}
return Modes;
@@ -531,28 +511,29 @@ DDCModeDoInterlaceQuirks(DisplayModePtr mode)
* should be checking refresh rate too. Whatever.
*/
static const struct {
- int w, h;
+ int w, h;
} cea_interlaced[] = {
- { 1920, 1080 },
- { 720, 480 },
- { 1440, 480 },
- { 2880, 480 },
- { 720, 576 },
- { 1440, 576 },
- { 2880, 576 },
- };
- static const int n_modes = sizeof(cea_interlaced)/sizeof(cea_interlaced[0]);
+ {
+ 1920, 1080}, {
+ 720, 480}, {
+ 1440, 480}, {
+ 2880, 480}, {
+ 720, 576}, {
+ 1440, 576}, {
+ 2880, 576},};
+ static const int n_modes =
+ sizeof(cea_interlaced) / sizeof(cea_interlaced[0]);
int i;
for (i = 0; i < n_modes; i++) {
- if ((mode->HDisplay == cea_interlaced[i].w) &&
- (mode->VDisplay == cea_interlaced[i].h / 2)) {
- mode->VDisplay *= 2;
- mode->VSyncStart *= 2;
- mode->VSyncEnd *= 2;
- mode->VTotal *= 2;
- mode->VTotal |= 1;
- }
+ if ((mode->HDisplay == cea_interlaced[i].w) &&
+ (mode->VDisplay == cea_interlaced[i].h / 2)) {
+ mode->VDisplay *= 2;
+ mode->VSyncStart *= 2;
+ mode->VSyncEnd *= 2;
+ mode->VTotal *= 2;
+ mode->VTotal |= 1;
+ }
}
mode->Flags |= V_INTERLACE;
@@ -563,7 +544,7 @@ DDCModeDoInterlaceQuirks(DisplayModePtr mode)
*/
static DisplayModePtr
DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing,
- Bool preferred, ddc_quirk_t quirks)
+ Bool preferred, ddc_quirk_t quirks)
{
DisplayModePtr Mode;
@@ -574,34 +555,33 @@ DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing,
* our parser is just being too aggresive there.
*/
if (timing->h_active < 64 || timing->v_active < 64) {
- xf86DrvMsg(scrnIndex, X_INFO,
- "%s: Ignoring tiny %dx%d mode\n", __func__,
- timing->h_active, timing->v_active);
- return NULL;
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "%s: Ignoring tiny %dx%d mode\n", __func__,
+ timing->h_active, timing->v_active);
+ return NULL;
}
/* We don't do stereo */
if (timing->stereo) {
xf86DrvMsg(scrnIndex, X_INFO,
- "%s: Ignoring: We don't handle stereo.\n", __func__);
+ "%s: Ignoring: We don't handle stereo.\n", __func__);
return NULL;
}
/* We only do seperate sync currently */
if (timing->sync != 0x03) {
- xf86DrvMsg(scrnIndex, X_INFO,
- "%s: %dx%d Warning: We only handle separate"
- " sync.\n", __func__, timing->h_active, timing->v_active);
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "%s: %dx%d Warning: We only handle separate"
+ " sync.\n", __func__, timing->h_active, timing->v_active);
}
Mode = xnfcalloc(1, sizeof(DisplayModeRec));
Mode->type = M_T_DRIVER;
if (preferred)
- Mode->type |= M_T_PREFERRED;
+ Mode->type |= M_T_PREFERRED;
- if( ( quirks & DDC_QUIRK_135_CLOCK_TOO_HIGH ) &&
- timing->clock == 135000000 )
+ if ((quirks & DDC_QUIRK_135_CLOCK_TOO_HIGH) && timing->clock == 135000000)
Mode->Clock = 108880;
else
Mode->Clock = timing->clock / 1000.0;
@@ -618,27 +598,27 @@ DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing,
/* perform basic check on the detail timing */
if (Mode->HSyncEnd > Mode->HTotal || Mode->VSyncEnd > Mode->VTotal) {
- free(Mode);
- return NULL;
+ free(Mode);
+ return NULL;
}
/* We ignore h/v_size and h/v_border for now. */
if (timing->interlaced)
- DDCModeDoInterlaceQuirks(Mode);
+ DDCModeDoInterlaceQuirks(Mode);
if (quirks & DDC_QUIRK_DETAILED_SYNC_PP)
- Mode->Flags |= V_PVSYNC | V_PHSYNC;
+ Mode->Flags |= V_PVSYNC | V_PHSYNC;
else {
- if (timing->misc & 0x02)
- Mode->Flags |= V_PVSYNC;
- else
- Mode->Flags |= V_NVSYNC;
-
- if (timing->misc & 0x01)
- Mode->Flags |= V_PHSYNC;
- else
- Mode->Flags |= V_NHSYNC;
+ if (timing->misc & 0x02)
+ Mode->Flags |= V_PVSYNC;
+ else
+ Mode->Flags |= V_NVSYNC;
+
+ if (timing->misc & 0x01)
+ Mode->Flags |= V_PHSYNC;
+ else
+ Mode->Flags |= V_NHSYNC;
}
xf86SetModeDefaultName(Mode);
@@ -653,23 +633,30 @@ DDCModesFromCVT(int scrnIndex, struct cvt_timings *t)
int i;
for (i = 0; i < 4; i++) {
- if (t[i].height) {
- if (t[i].rates & 0x10)
- modes = xf86ModesAdd(modes,
- xf86CVTMode(t[i].width, t[i].height, 50, 0, 0));
- if (t[i].rates & 0x08)
- modes = xf86ModesAdd(modes,
- xf86CVTMode(t[i].width, t[i].height, 60, 0, 0));
- if (t[i].rates & 0x04)
- modes = xf86ModesAdd(modes,
- xf86CVTMode(t[i].width, t[i].height, 75, 0, 0));
- if (t[i].rates & 0x02)
- modes = xf86ModesAdd(modes,
- xf86CVTMode(t[i].width, t[i].height, 85, 0, 0));
- if (t[i].rates & 0x01)
- modes = xf86ModesAdd(modes,
- xf86CVTMode(t[i].width, t[i].height, 60, 1, 0));
- } else break;
+ if (t[i].height) {
+ if (t[i].rates & 0x10)
+ modes = xf86ModesAdd(modes,
+ xf86CVTMode(t[i].width, t[i].height, 50, 0,
+ 0));
+ if (t[i].rates & 0x08)
+ modes = xf86ModesAdd(modes,
+ xf86CVTMode(t[i].width, t[i].height, 60, 0,
+ 0));
+ if (t[i].rates & 0x04)
+ modes = xf86ModesAdd(modes,
+ xf86CVTMode(t[i].width, t[i].height, 75, 0,
+ 0));
+ if (t[i].rates & 0x02)
+ modes = xf86ModesAdd(modes,
+ xf86CVTMode(t[i].width, t[i].height, 85, 0,
+ 0));
+ if (t[i].rates & 0x01)
+ modes = xf86ModesAdd(modes,
+ xf86CVTMode(t[i].width, t[i].height, 60, 1,
+ 0));
+ }
+ else
+ break;
}
return modes;
@@ -682,56 +669,61 @@ static const struct {
short rb;
} EstIIIModes[] = {
/* byte 6 */
- { 640, 350, 85, 0 },
- { 640, 400, 85, 0 },
- { 720, 400, 85, 0 },
- { 640, 480, 85, 0 },
- { 848, 480, 60, 0 },
- { 800, 600, 85, 0 },
- { 1024, 768, 85, 0 },
- { 1152, 864, 75, 0 },
- /* byte 7 */
- { 1280, 768, 60, 1 },
- { 1280, 768, 60, 0 },
- { 1280, 768, 75, 0 },
- { 1280, 768, 85, 0 },
- { 1280, 960, 60, 0 },
- { 1280, 960, 85, 0 },
- { 1280, 1024, 60, 0 },
- { 1280, 1024, 85, 0 },
- /* byte 8 */
- { 1360, 768, 60, 0 },
- { 1440, 900, 60, 1 },
- { 1440, 900, 60, 0 },
- { 1440, 900, 75, 0 },
- { 1440, 900, 85, 0 },
- { 1400, 1050, 60, 1 },
- { 1400, 1050, 60, 0 },
- { 1400, 1050, 75, 0 },
- /* byte 9 */
- { 1400, 1050, 85, 0 },
- { 1680, 1050, 60, 1 },
- { 1680, 1050, 60, 0 },
- { 1680, 1050, 75, 0 },
- { 1680, 1050, 85, 0 },
- { 1600, 1200, 60, 0 },
- { 1600, 1200, 65, 0 },
- { 1600, 1200, 70, 0 },
- /* byte 10 */
- { 1600, 1200, 75, 0 },
- { 1600, 1200, 85, 0 },
- { 1792, 1344, 60, 0 },
- { 1792, 1344, 85, 0 },
- { 1856, 1392, 60, 0 },
- { 1856, 1392, 75, 0 },
- { 1920, 1200, 60, 1 },
- { 1920, 1200, 60, 0 },
- /* byte 11 */
- { 1920, 1200, 75, 0 },
- { 1920, 1200, 85, 0 },
- { 1920, 1440, 60, 0 },
- { 1920, 1440, 75, 0 },
-};
+ {
+ 640, 350, 85, 0}, {
+ 640, 400, 85, 0}, {
+ 720, 400, 85, 0}, {
+ 640, 480, 85, 0}, {
+ 848, 480, 60, 0}, {
+ 800, 600, 85, 0}, {
+ 1024, 768, 85, 0}, {
+ 1152, 864, 75, 0},
+ /* byte 7 */
+ {
+ 1280, 768, 60, 1}, {
+ 1280, 768, 60, 0}, {
+ 1280, 768, 75, 0}, {
+ 1280, 768, 85, 0}, {
+ 1280, 960, 60, 0}, {
+ 1280, 960, 85, 0}, {
+ 1280, 1024, 60, 0}, {
+ 1280, 1024, 85, 0},
+ /* byte 8 */
+ {
+ 1360, 768, 60, 0}, {
+ 1440, 900, 60, 1}, {
+ 1440, 900, 60, 0}, {
+ 1440, 900, 75, 0}, {
+ 1440, 900, 85, 0}, {
+ 1400, 1050, 60, 1}, {
+ 1400, 1050, 60, 0}, {
+ 1400, 1050, 75, 0},
+ /* byte 9 */
+ {
+ 1400, 1050, 85, 0}, {
+ 1680, 1050, 60, 1}, {
+ 1680, 1050, 60, 0}, {
+ 1680, 1050, 75, 0}, {
+ 1680, 1050, 85, 0}, {
+ 1600, 1200, 60, 0}, {
+ 1600, 1200, 65, 0}, {
+ 1600, 1200, 70, 0},
+ /* byte 10 */
+ {
+ 1600, 1200, 75, 0}, {
+ 1600, 1200, 85, 0}, {
+ 1792, 1344, 60, 0}, {
+ 1792, 1344, 85, 0}, {
+ 1856, 1392, 60, 0}, {
+ 1856, 1392, 75, 0}, {
+ 1920, 1200, 60, 1}, {
+ 1920, 1200, 60, 0},
+ /* byte 11 */
+ {
+ 1920, 1200, 75, 0}, {
+ 1920, 1200, 85, 0}, {
+ 1920, 1440, 60, 0}, {
+1920, 1440, 75, 0},};
static DisplayModePtr
DDCModesFromEstIII(unsigned char *est)
@@ -740,16 +732,16 @@ DDCModesFromEstIII(unsigned char *est)
int i, j, m;
for (i = 0; i < 6; i++) {
- for (j = 7; j > 0; j--) {
- if (est[i] & (1 << j)) {
- m = (i * 8) + (7 - j);
- modes = xf86ModesAdd(modes,
- FindDMTMode(EstIIIModes[m].w,
- EstIIIModes[m].h,
- EstIIIModes[m].r,
- EstIIIModes[m].rb));
- }
- }
+ for (j = 7; j > 0; j--) {
+ if (est[i] & (1 << j)) {
+ m = (i * 8) + (7 - j);
+ modes = xf86ModesAdd(modes,
+ FindDMTMode(EstIIIModes[m].w,
+ EstIIIModes[m].h,
+ EstIIIModes[m].r,
+ EstIIIModes[m].rb));
+ }
+ }
}
return modes;
@@ -781,10 +773,10 @@ DDCGuessRangesFromModes(int scrnIndex, MonPtr Monitor, DisplayModePtr Modes)
while (Mode) {
if (!Mode->HSync)
- Mode->HSync = ((float) Mode->Clock ) / ((float) Mode->HTotal);
+ Mode->HSync = ((float) Mode->Clock) / ((float) Mode->HTotal);
if (!Mode->VRefresh)
- Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) /
+ Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) /
((float) (Mode->HTotal * Mode->VTotal));
if (Mode->HSync < Monitor->hsync[0].lo)
@@ -806,26 +798,26 @@ DDCGuessRangesFromModes(int scrnIndex, MonPtr Monitor, DisplayModePtr Modes)
ddc_quirk_t
xf86DDCDetectQuirks(int scrnIndex, xf86MonPtr DDC, Bool verbose)
{
- ddc_quirk_t quirks;
+ ddc_quirk_t quirks;
int i;
quirks = DDC_QUIRK_NONE;
for (i = 0; ddc_quirks[i].detect; i++) {
- if (ddc_quirks[i].detect (scrnIndex, DDC)) {
- if (verbose) {
- xf86DrvMsg (scrnIndex, X_INFO, " EDID quirk: %s\n",
- ddc_quirks[i].description);
- }
- quirks |= ddc_quirks[i].quirk;
- }
+ if (ddc_quirks[i].detect(scrnIndex, DDC)) {
+ if (verbose) {
+ xf86DrvMsg(scrnIndex, X_INFO, " EDID quirk: %s\n",
+ ddc_quirks[i].description);
+ }
+ quirks |= ddc_quirks[i].quirk;
+ }
}
return quirks;
}
-void xf86DetTimingApplyQuirks(struct detailed_monitor_section *det_mon,
- ddc_quirk_t quirks,
- int hsize, int vsize)
+void
+xf86DetTimingApplyQuirks(struct detailed_monitor_section *det_mon,
+ ddc_quirk_t quirks, int hsize, int vsize)
{
if (det_mon->type != DT)
return;
@@ -851,13 +843,12 @@ void xf86DetTimingApplyQuirks(struct detailed_monitor_section *det_mon,
void
xf86DDCApplyQuirks(int scrnIndex, xf86MonPtr DDC)
{
- ddc_quirk_t quirks = xf86DDCDetectQuirks (scrnIndex, DDC, FALSE);
+ ddc_quirk_t quirks = xf86DDCDetectQuirks(scrnIndex, DDC, FALSE);
int i;
for (i = 0; i < DET_TIMINGS; i++) {
xf86DetTimingApplyQuirks(DDC->det_mon + i, quirks,
- DDC->features.hsize,
- DDC->features.vsize);
+ DDC->features.hsize, DDC->features.vsize);
}
}
@@ -867,120 +858,116 @@ xf86DDCApplyQuirks(int scrnIndex, xf86MonPtr DDC)
*/
static void
xf86DDCSetPreferredRefresh(int scrnIndex, DisplayModePtr modes,
- float target_refresh)
+ float target_refresh)
{
- DisplayModePtr mode, best = modes;
-
- for (mode = modes; mode; mode = mode->next)
- {
- mode->type &= ~M_T_PREFERRED;
-
- if (mode == best) continue;
-
- if (mode->HDisplay * mode->VDisplay >
- best->HDisplay * best->VDisplay)
- {
- best = mode;
- continue;
- }
- if (mode->HDisplay * mode->VDisplay ==
- best->HDisplay * best->VDisplay)
- {
- double mode_refresh = xf86ModeVRefresh (mode);
- double best_refresh = xf86ModeVRefresh (best);
- double mode_dist = fabs(mode_refresh - target_refresh);
- double best_dist = fabs(best_refresh - target_refresh);
-
- if (mode_dist < best_dist)
- {
- best = mode;
- continue;
- }
- }
- }
- if (best)
- best->type |= M_T_PREFERRED;
+ DisplayModePtr mode, best = modes;
+
+ for (mode = modes; mode; mode = mode->next) {
+ mode->type &= ~M_T_PREFERRED;
+
+ if (mode == best)
+ continue;
+
+ if (mode->HDisplay * mode->VDisplay > best->HDisplay * best->VDisplay) {
+ best = mode;
+ continue;
+ }
+ if (mode->HDisplay * mode->VDisplay == best->HDisplay * best->VDisplay) {
+ double mode_refresh = xf86ModeVRefresh(mode);
+ double best_refresh = xf86ModeVRefresh(best);
+ double mode_dist = fabs(mode_refresh - target_refresh);
+ double best_dist = fabs(best_refresh - target_refresh);
+
+ if (mode_dist < best_dist) {
+ best = mode;
+ continue;
+ }
+ }
+ }
+ if (best)
+ best->type |= M_T_PREFERRED;
}
#define CEA_VIDEO_MODES_NUM 64
static const DisplayModeRec CEAVideoModes[CEA_VIDEO_MODES_NUM] = {
- { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 1:640x480@60Hz */
- { MODEPREFIX, 27000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 2:720x480@60Hz */
- { MODEPREFIX, 27000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 3:720x480@60Hz */
- { MODEPREFIX, 74250, 1280, 1390, 1430, 1650, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 4: 1280x720@60Hz */
- { MODEPREFIX, 74250, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 5:1920x1080i@60Hz */
- { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 6:1440x480i@60Hz */
- { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 7:1440x480i@60Hz */
- { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 8:1440x240@60Hz */
- { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 9:1440x240@60Hz */
- { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 10:2880x480i@60Hz */
- { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 11:2880x480i@60Hz */
- { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 12:2880x240@60Hz */
- { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 13:2880x240@60Hz */
- { MODEPREFIX, 54000, 1440, 1472, 1596, 1716, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 14:1440x480@60Hz */
- { MODEPREFIX, 54000, 1440, 1472, 1596, 1716, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 15:1440x480@60Hz */
- { MODEPREFIX, 148500, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 16:1920x1080@60Hz */
- { MODEPREFIX, 27000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 17:720x576@50Hz */
- { MODEPREFIX, 27000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 18:720x576@50Hz */
- { MODEPREFIX, 74250, 1280, 1720, 1760, 1980, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 19: 1280x720@50Hz */
- { MODEPREFIX, 74250, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 20:1920x1080i@50Hz */
- { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 21:1440x576i@50Hz */
- { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 22:1440x576i@50Hz */
- { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 23:1440x288@50Hz */
- { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 24:1440x288@50Hz */
- { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 25:2880x576i@50Hz */
- { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 26:2880x576i@50Hz */
- { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 27:2880x288@50Hz */
- { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 28:2880x288@50Hz */
- { MODEPREFIX, 54000, 1440, 1464, 1592, 1728, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 29:1440x576@50Hz */
- { MODEPREFIX, 54000, 1440, 1464, 1592, 1728, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 30:1440x576@50Hz */
- { MODEPREFIX, 148500, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 31:1920x1080@50Hz */
- { MODEPREFIX, 74250, 1920, 2558, 2602, 2750, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 32:1920x1080@24Hz */
- { MODEPREFIX, 74250, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 33:1920x1080@25Hz */
- { MODEPREFIX, 74250, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 34:1920x1080@30Hz */
- { MODEPREFIX, 108000, 2880, 2944, 3192, 3432, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 35:2880x480@60Hz */
- { MODEPREFIX, 108000, 2880, 2944, 3192, 3432, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 36:2880x480@60Hz */
- { MODEPREFIX, 108000, 2880, 2928, 3184, 3456, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 37:2880x576@50Hz */
- { MODEPREFIX, 108000, 2880, 2928, 3184, 3456, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 38:2880x576@50Hz */
- { MODEPREFIX, 72000, 1920, 1952, 2120, 2304, 0, 1080, 1126, 1136, 1250, 0, V_PHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 39:1920x1080i@50Hz */
- { MODEPREFIX, 148500, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 40:1920x1080i@100Hz */
- { MODEPREFIX, 148500, 1280, 1720, 1760, 1980, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 41:1280x720@100Hz */
- { MODEPREFIX, 54000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 42:720x576@100Hz */
- { MODEPREFIX, 54000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 43:720x576@100Hz */
- { MODEPREFIX, 54000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 44:1440x576i@100Hz */
- { MODEPREFIX, 54000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 45:1440x576i@100Hz */
- { MODEPREFIX, 148500, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 46:1920x1080i@120Hz */
- { MODEPREFIX, 148500, 1280, 1390, 1430, 1650, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 47:1280x720@120Hz */
- { MODEPREFIX, 54000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 48:720x480@120Hz */
- { MODEPREFIX, 54000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 49:720x480@120Hz */
- { MODEPREFIX, 54000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 50:1440x480i@120Hz */
- { MODEPREFIX, 54000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 51:1440x480i@120Hz */
- { MODEPREFIX, 108000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 52:720x576@200Hz */
- { MODEPREFIX, 108000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 53:720x576@200Hz */
- { MODEPREFIX, 108000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 54:1440x576i@200Hz */
- { MODEPREFIX, 108000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 55:1440x576i@200Hz */
- { MODEPREFIX, 108000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 56:720x480@240Hz */
- { MODEPREFIX, 108000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 57:720x480@240Hz */
- { MODEPREFIX, 108000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 58:1440x480i@240 */
- { MODEPREFIX, 108000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 59:1440x480i@240 */
- { MODEPREFIX, 59400, 1280, 3040, 3080, 3300, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 60: 1280x720@24Hz */
- { MODEPREFIX, 74250, 1280, 3700, 3740, 3960, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 61: 1280x720@25Hz */
- { MODEPREFIX, 74250, 1280, 3040, 3080, 3300, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 62: 1280x720@30Hz */
- { MODEPREFIX, 297000, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 63: 1920x1080@120Hz */
- { MODEPREFIX, 297000, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 64:1920x1080@100Hz */
+ {MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 1:640x480@60Hz */
+ {MODEPREFIX, 27000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 2:720x480@60Hz */
+ {MODEPREFIX, 27000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 3:720x480@60Hz */
+ {MODEPREFIX, 74250, 1280, 1390, 1430, 1650, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* VIC 4: 1280x720@60Hz */
+ {MODEPREFIX, 74250, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX}, /* VIC 5:1920x1080i@60Hz */
+ {MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX}, /* VIC 6:1440x480i@60Hz */
+ {MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX}, /* VIC 7:1440x480i@60Hz */
+ {MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 8:1440x240@60Hz */
+ {MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 9:1440x240@60Hz */
+ {MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX}, /* VIC 10:2880x480i@60Hz */
+ {MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX}, /* VIC 11:2880x480i@60Hz */
+ {MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 12:2880x240@60Hz */
+ {MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 13:2880x240@60Hz */
+ {MODEPREFIX, 54000, 1440, 1472, 1596, 1716, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 14:1440x480@60Hz */
+ {MODEPREFIX, 54000, 1440, 1472, 1596, 1716, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 15:1440x480@60Hz */
+ {MODEPREFIX, 148500, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* VIC 16:1920x1080@60Hz */
+ {MODEPREFIX, 27000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 17:720x576@50Hz */
+ {MODEPREFIX, 27000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 18:720x576@50Hz */
+ {MODEPREFIX, 74250, 1280, 1720, 1760, 1980, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* VIC 19: 1280x720@50Hz */
+ {MODEPREFIX, 74250, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX}, /* VIC 20:1920x1080i@50Hz */
+ {MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX}, /* VIC 21:1440x576i@50Hz */
+ {MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX}, /* VIC 22:1440x576i@50Hz */
+ {MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 23:1440x288@50Hz */
+ {MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 24:1440x288@50Hz */
+ {MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX}, /* VIC 25:2880x576i@50Hz */
+ {MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX}, /* VIC 26:2880x576i@50Hz */
+ {MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 27:2880x288@50Hz */
+ {MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 28:2880x288@50Hz */
+ {MODEPREFIX, 54000, 1440, 1464, 1592, 1728, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 29:1440x576@50Hz */
+ {MODEPREFIX, 54000, 1440, 1464, 1592, 1728, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 30:1440x576@50Hz */
+ {MODEPREFIX, 148500, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* VIC 31:1920x1080@50Hz */
+ {MODEPREFIX, 74250, 1920, 2558, 2602, 2750, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* VIC 32:1920x1080@24Hz */
+ {MODEPREFIX, 74250, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* VIC 33:1920x1080@25Hz */
+ {MODEPREFIX, 74250, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* VIC 34:1920x1080@30Hz */
+ {MODEPREFIX, 108000, 2880, 2944, 3192, 3432, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 35:2880x480@60Hz */
+ {MODEPREFIX, 108000, 2880, 2944, 3192, 3432, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 36:2880x480@60Hz */
+ {MODEPREFIX, 108000, 2880, 2928, 3184, 3456, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 37:2880x576@50Hz */
+ {MODEPREFIX, 108000, 2880, 2928, 3184, 3456, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 38:2880x576@50Hz */
+ {MODEPREFIX, 72000, 1920, 1952, 2120, 2304, 0, 1080, 1126, 1136, 1250, 0, V_PHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX}, /* VIC 39:1920x1080i@50Hz */
+ {MODEPREFIX, 148500, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX}, /* VIC 40:1920x1080i@100Hz */
+ {MODEPREFIX, 148500, 1280, 1720, 1760, 1980, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* VIC 41:1280x720@100Hz */
+ {MODEPREFIX, 54000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 42:720x576@100Hz */
+ {MODEPREFIX, 54000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 43:720x576@100Hz */
+ {MODEPREFIX, 54000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 44:1440x576i@100Hz */
+ {MODEPREFIX, 54000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 45:1440x576i@100Hz */
+ {MODEPREFIX, 148500, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX}, /* VIC 46:1920x1080i@120Hz */
+ {MODEPREFIX, 148500, 1280, 1390, 1430, 1650, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* VIC 47:1280x720@120Hz */
+ {MODEPREFIX, 54000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 48:720x480@120Hz */
+ {MODEPREFIX, 54000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 49:720x480@120Hz */
+ {MODEPREFIX, 54000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX}, /* VIC 50:1440x480i@120Hz */
+ {MODEPREFIX, 54000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX}, /* VIC 51:1440x480i@120Hz */
+ {MODEPREFIX, 108000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 52:720x576@200Hz */
+ {MODEPREFIX, 108000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 53:720x576@200Hz */
+ {MODEPREFIX, 108000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX}, /* VIC 54:1440x576i@200Hz */
+ {MODEPREFIX, 108000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX}, /* VIC 55:1440x576i@200Hz */
+ {MODEPREFIX, 108000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 56:720x480@240Hz */
+ {MODEPREFIX, 108000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX}, /* VIC 57:720x480@240Hz */
+ {MODEPREFIX, 108000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX}, /* VIC 58:1440x480i@240 */
+ {MODEPREFIX, 108000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX}, /* VIC 59:1440x480i@240 */
+ {MODEPREFIX, 59400, 1280, 3040, 3080, 3300, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* VIC 60: 1280x720@24Hz */
+ {MODEPREFIX, 74250, 1280, 3700, 3740, 3960, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* VIC 61: 1280x720@25Hz */
+ {MODEPREFIX, 74250, 1280, 3040, 3080, 3300, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* VIC 62: 1280x720@30Hz */
+ {MODEPREFIX, 297000, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* VIC 63: 1920x1080@120Hz */
+ {MODEPREFIX, 297000, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX}, /* VIC 64:1920x1080@100Hz */
};
/* chose mode line by cea short video descriptor*/
-static void handle_cea_svd(struct cea_video_block *video, void *data)
+static void
+handle_cea_svd(struct cea_video_block *video, void *data)
{
DisplayModePtr Mode;
DisplayModePtr *Modes = (DisplayModePtr *) data;
int vid;
- vid = video ->video_code & 0x7f;
+ vid = video->video_code & 0x7f;
if (vid < CEA_VIDEO_MODES_NUM) {
- Mode = xf86DuplicateMode(CEAVideoModes + vid);
- *Modes = xf86ModesAdd(*Modes, Mode);
+ Mode = xf86DuplicateMode(CEAVideoModes + vid);
+ *Modes = xf86ModesAdd(*Modes, Mode);
}
}
@@ -989,9 +976,7 @@ DDCModesFromCEAExtension(int scrnIndex, xf86MonPtr MonPtr)
{
DisplayModePtr Modes = NULL;
- xf86ForEachVideoBlock(MonPtr,
- handle_cea_svd,
- &Modes);
+ xf86ForEachVideoBlock(MonPtr, handle_cea_svd, &Modes);
return Modes;
}
@@ -999,34 +984,32 @@ DDCModesFromCEAExtension(int scrnIndex, xf86MonPtr MonPtr)
struct det_modes_parameter {
xf86MonPtr DDC;
ddc_quirk_t quirks;
- DisplayModePtr Modes;
+ DisplayModePtr Modes;
Bool rb;
Bool preferred;
int timing_level;
};
-static void handle_detailed_modes(struct detailed_monitor_section *det_mon,
- void *data)
+static void
+handle_detailed_modes(struct detailed_monitor_section *det_mon, void *data)
{
- DisplayModePtr Mode;
- struct det_modes_parameter *p = (struct det_modes_parameter *)data;
+ DisplayModePtr Mode;
+ struct det_modes_parameter *p = (struct det_modes_parameter *) data;
- xf86DetTimingApplyQuirks(det_mon,p->quirks,
- p->DDC->features.hsize,
- p->DDC->features.vsize);
+ xf86DetTimingApplyQuirks(det_mon, p->quirks,
+ p->DDC->features.hsize, p->DDC->features.vsize);
switch (det_mon->type) {
case DT:
Mode = DDCModeFromDetailedTiming(p->DDC->scrnIndex,
&det_mon->section.d_timings,
- p->preferred,
- p->quirks);
+ p->preferred, p->quirks);
p->preferred = FALSE;
p->Modes = xf86ModesAdd(p->Modes, Mode);
break;
case DS_STD_TIMINGS:
Mode = DDCModesFromStandardTiming(det_mon->section.std_t,
- p->quirks, p->timing_level,p->rb);
+ p->quirks, p->timing_level, p->rb);
p->Modes = xf86ModesAdd(p->Modes, Mode);
break;
case DS_CVT:
@@ -1034,9 +1017,9 @@ static void handle_detailed_modes(struct detailed_monitor_section *det_mon,
p->Modes = xf86ModesAdd(p->Modes, Mode);
break;
case DS_EST_III:
- Mode = DDCModesFromEstIII(det_mon->section.est_iii);
- p->Modes = xf86ModesAdd(p->Modes, Mode);
- break;
+ Mode = DDCModesFromEstIII(det_mon->section.est_iii);
+ p->Modes = xf86ModesAdd(p->Modes, Mode);
+ break;
default:
break;
}
@@ -1045,24 +1028,24 @@ static void handle_detailed_modes(struct detailed_monitor_section *det_mon,
DisplayModePtr
xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC)
{
- DisplayModePtr Modes = NULL, Mode;
- ddc_quirk_t quirks;
- Bool preferred, rb;
- int timing_level;
+ DisplayModePtr Modes = NULL, Mode;
+ ddc_quirk_t quirks;
+ Bool preferred, rb;
+ int timing_level;
struct det_modes_parameter p;
- xf86DrvMsg (scrnIndex, X_INFO, "EDID vendor \"%s\", prod id %d\n",
- DDC->vendor.name, DDC->vendor.prod_id);
+ xf86DrvMsg(scrnIndex, X_INFO, "EDID vendor \"%s\", prod id %d\n",
+ DDC->vendor.name, DDC->vendor.prod_id);
quirks = xf86DDCDetectQuirks(scrnIndex, DDC, TRUE);
preferred = PREFERRED_TIMING_MODE(DDC->features.msc);
if (DDC->ver.revision >= 4)
- preferred = TRUE;
+ preferred = TRUE;
if (quirks & DDC_QUIRK_FIRST_DETAILED_PREFERRED)
- preferred = TRUE;
+ preferred = TRUE;
if (quirks & (DDC_QUIRK_PREFER_LARGE_60 | DDC_QUIRK_PREFER_LARGE_75))
- preferred = FALSE;
+ preferred = FALSE;
rb = xf86MonitorSupportsReducedBlanking(DDC);
@@ -1086,14 +1069,14 @@ xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC)
Modes = xf86ModesAdd(Modes, Mode);
/* Add cea-extension mode timings */
- Mode = DDCModesFromCEAExtension(scrnIndex,DDC);
+ Mode = DDCModesFromCEAExtension(scrnIndex, DDC);
Modes = xf86ModesAdd(Modes, Mode);
if (quirks & DDC_QUIRK_PREFER_LARGE_60)
- xf86DDCSetPreferredRefresh(scrnIndex, Modes, 60);
+ xf86DDCSetPreferredRefresh(scrnIndex, Modes, 60);
if (quirks & DDC_QUIRK_PREFER_LARGE_75)
- xf86DDCSetPreferredRefresh(scrnIndex, Modes, 75);
+ xf86DDCSetPreferredRefresh(scrnIndex, Modes, 75);
Modes = xf86PruneDuplicateModes(Modes);
@@ -1108,41 +1091,43 @@ struct det_mon_parameter {
Bool have_maxpixclock;
};
-static void handle_detailed_monset(struct detailed_monitor_section *det_mon,
- void *data)
+static void
+handle_detailed_monset(struct detailed_monitor_section *det_mon, void *data)
{
int clock;
- struct det_mon_parameter *p = (struct det_mon_parameter *)data;
- int scrnIndex = ((xf86MonPtr)(p->Monitor->DDC))->scrnIndex;
+ struct det_mon_parameter *p = (struct det_mon_parameter *) data;
+ int scrnIndex = ((xf86MonPtr) (p->Monitor->DDC))->scrnIndex;
switch (det_mon->type) {
case DS_RANGES:
if (!p->have_hsync) {
if (!p->Monitor->nHsync)
xf86DrvMsg(scrnIndex, X_INFO,
- "Using EDID range info for horizontal sync\n");
- p->Monitor->hsync[p->Monitor->nHsync].lo =
- det_mon->section.ranges.min_h;
- p->Monitor->hsync[p->Monitor->nHsync].hi =
- det_mon->section.ranges.max_h;
- p->Monitor->nHsync++;
- } else {
+ "Using EDID range info for horizontal sync\n");
+ p->Monitor->hsync[p->Monitor->nHsync].lo =
+ det_mon->section.ranges.min_h;
+ p->Monitor->hsync[p->Monitor->nHsync].hi =
+ det_mon->section.ranges.max_h;
+ p->Monitor->nHsync++;
+ }
+ else {
xf86DrvMsg(scrnIndex, X_INFO,
- "Using hsync ranges from config file\n");
+ "Using hsync ranges from config file\n");
}
if (!p->have_vrefresh) {
if (!p->Monitor->nVrefresh)
xf86DrvMsg(scrnIndex, X_INFO,
- "Using EDID range info for vertical refresh\n");
+ "Using EDID range info for vertical refresh\n");
p->Monitor->vrefresh[p->Monitor->nVrefresh].lo =
det_mon->section.ranges.min_v;
p->Monitor->vrefresh[p->Monitor->nVrefresh].hi =
det_mon->section.ranges.max_v;
p->Monitor->nVrefresh++;
- } else {
+ }
+ else {
xf86DrvMsg(scrnIndex, X_INFO,
- "Using vrefresh ranges from config file\n");
+ "Using vrefresh ranges from config file\n");
}
clock = det_mon->section.ranges.max_clock * 1000;
@@ -1172,8 +1157,8 @@ xf86EdidMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC)
Monitor->DDC = DDC;
if (Monitor->widthmm <= 0 || Monitor->heightmm <= 0) {
- Monitor->widthmm = 10 * DDC->features.hsize;
- Monitor->heightmm = 10 * DDC->features.vsize;
+ Monitor->widthmm = 10 * DDC->features.hsize;
+ Monitor->heightmm = 10 * DDC->features.vsize;
}
Monitor->reducedblanking = xf86MonitorSupportsReducedBlanking(DDC);
@@ -1213,7 +1198,8 @@ xf86EdidMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC)
Monitor->Last->next = Modes;
Modes->prev = Monitor->Last;
Monitor->Last = Mode;
- } else {
+ }
+ else {
Monitor->Modes = Modes;
Monitor->Last = Mode;
}
diff --git a/xorg-server/hw/xfree86/modes/xf86Modes.c b/xorg-server/hw/xfree86/modes/xf86Modes.c
index 49cc14992..2a6d26756 100644
--- a/xorg-server/hw/xfree86/modes/xf86Modes.c
+++ b/xorg-server/hw/xfree86/modes/xf86Modes.c
@@ -42,14 +42,14 @@ extern XF86ConfigPtr xf86configptr;
* Calculates the horizontal sync rate of a mode.
*/
double
-xf86ModeHSync(const DisplayModeRec *mode)
+xf86ModeHSync(const DisplayModeRec * mode)
{
double hsync = 0.0;
-
+
if (mode->HSync > 0.0)
- hsync = mode->HSync;
+ hsync = mode->HSync;
else if (mode->HTotal > 0)
- hsync = (float)mode->Clock / (float)mode->HTotal;
+ hsync = (float) mode->Clock / (float) mode->HTotal;
return hsync;
}
@@ -58,51 +58,51 @@ xf86ModeHSync(const DisplayModeRec *mode)
* Calculates the vertical refresh rate of a mode.
*/
double
-xf86ModeVRefresh(const DisplayModeRec *mode)
+xf86ModeVRefresh(const DisplayModeRec * mode)
{
double refresh = 0.0;
if (mode->VRefresh > 0.0)
- refresh = mode->VRefresh;
+ refresh = mode->VRefresh;
else if (mode->HTotal > 0 && mode->VTotal > 0) {
- refresh = mode->Clock * 1000.0 / mode->HTotal / mode->VTotal;
- if (mode->Flags & V_INTERLACE)
- refresh *= 2.0;
- if (mode->Flags & V_DBLSCAN)
- refresh /= 2.0;
- if (mode->VScan > 1)
- refresh /= (float)(mode->VScan);
+ refresh = mode->Clock * 1000.0 / mode->HTotal / mode->VTotal;
+ if (mode->Flags & V_INTERLACE)
+ refresh *= 2.0;
+ if (mode->Flags & V_DBLSCAN)
+ refresh /= 2.0;
+ if (mode->VScan > 1)
+ refresh /= (float) (mode->VScan);
}
return refresh;
}
int
-xf86ModeWidth (const DisplayModeRec *mode, Rotation rotation)
+xf86ModeWidth(const DisplayModeRec * mode, Rotation rotation)
{
switch (rotation & 0xf) {
case RR_Rotate_0:
case RR_Rotate_180:
- return mode->HDisplay;
+ return mode->HDisplay;
case RR_Rotate_90:
case RR_Rotate_270:
- return mode->VDisplay;
+ return mode->VDisplay;
default:
- return 0;
+ return 0;
}
}
int
-xf86ModeHeight (const DisplayModeRec *mode, Rotation rotation)
+xf86ModeHeight(const DisplayModeRec * mode, Rotation rotation)
{
switch (rotation & 0xf) {
case RR_Rotate_0:
case RR_Rotate_180:
- return mode->VDisplay;
+ return mode->VDisplay;
case RR_Rotate_90:
case RR_Rotate_270:
- return mode->HDisplay;
+ return mode->HDisplay;
default:
- return 0;
+ return 0;
}
}
@@ -114,26 +114,26 @@ xf86ModeBandwidth(DisplayModePtr mode, int depth)
int bytes_per_pixel = bits_to_bytes(depth);
if (!mode->HTotal || !mode->VTotal || !mode->Clock)
- return 0;
+ return 0;
a_active = mode->HDisplay * mode->VDisplay;
a_total = mode->HTotal * mode->VTotal;
active_percent = a_active / a_total;
pixels_per_second = active_percent * mode->Clock * 1000.0;
- return (unsigned int)(pixels_per_second * bytes_per_pixel / (1024 * 1024));
+ return (unsigned int) (pixels_per_second * bytes_per_pixel / (1024 * 1024));
}
/** Sets a default mode name of <width>x<height> on a mode. */
void
xf86SetModeDefaultName(DisplayModePtr mode)
{
- Bool interlaced = !!(mode->Flags & V_INTERLACE);
+ Bool interlaced = ! !(mode->Flags & V_INTERLACE);
free(mode->name);
XNFasprintf(&mode->name, "%dx%d%s", mode->HDisplay, mode->VDisplay,
- interlaced ? "i" : "");
+ interlaced ? "i" : "");
}
/*
@@ -146,40 +146,40 @@ void
xf86SetModeCrtc(DisplayModePtr p, int adjustFlags)
{
if ((p == NULL) || ((p->type & M_T_CRTC_C) == M_T_BUILTIN))
- return;
-
- p->CrtcHDisplay = p->HDisplay;
- p->CrtcHSyncStart = p->HSyncStart;
- p->CrtcHSyncEnd = p->HSyncEnd;
- p->CrtcHTotal = p->HTotal;
- p->CrtcHSkew = p->HSkew;
- p->CrtcVDisplay = p->VDisplay;
- p->CrtcVSyncStart = p->VSyncStart;
- p->CrtcVSyncEnd = p->VSyncEnd;
- p->CrtcVTotal = p->VTotal;
+ return;
+
+ p->CrtcHDisplay = p->HDisplay;
+ p->CrtcHSyncStart = p->HSyncStart;
+ p->CrtcHSyncEnd = p->HSyncEnd;
+ p->CrtcHTotal = p->HTotal;
+ p->CrtcHSkew = p->HSkew;
+ p->CrtcVDisplay = p->VDisplay;
+ p->CrtcVSyncStart = p->VSyncStart;
+ p->CrtcVSyncEnd = p->VSyncEnd;
+ p->CrtcVTotal = p->VTotal;
if (p->Flags & V_INTERLACE) {
- if (adjustFlags & INTERLACE_HALVE_V) {
- p->CrtcVDisplay /= 2;
- p->CrtcVSyncStart /= 2;
- p->CrtcVSyncEnd /= 2;
- p->CrtcVTotal /= 2;
- }
- /* Force interlaced modes to have an odd VTotal */
- /* maybe we should only do this when INTERLACE_HALVE_V is set? */
- p->CrtcVTotal |= 1;
+ if (adjustFlags & INTERLACE_HALVE_V) {
+ p->CrtcVDisplay /= 2;
+ p->CrtcVSyncStart /= 2;
+ p->CrtcVSyncEnd /= 2;
+ p->CrtcVTotal /= 2;
+ }
+ /* Force interlaced modes to have an odd VTotal */
+ /* maybe we should only do this when INTERLACE_HALVE_V is set? */
+ p->CrtcVTotal |= 1;
}
if (p->Flags & V_DBLSCAN) {
- p->CrtcVDisplay *= 2;
- p->CrtcVSyncStart *= 2;
- p->CrtcVSyncEnd *= 2;
- p->CrtcVTotal *= 2;
+ p->CrtcVDisplay *= 2;
+ p->CrtcVSyncStart *= 2;
+ p->CrtcVSyncEnd *= 2;
+ p->CrtcVTotal *= 2;
}
if (p->VScan > 1) {
- p->CrtcVDisplay *= p->VScan;
- p->CrtcVSyncStart *= p->VScan;
- p->CrtcVSyncEnd *= p->VScan;
- p->CrtcVTotal *= p->VScan;
+ p->CrtcVDisplay *= p->VScan;
+ p->CrtcVSyncStart *= p->VScan;
+ p->CrtcVSyncEnd *= p->VScan;
+ p->CrtcVTotal *= p->VScan;
}
p->CrtcVBlankStart = min(p->CrtcVSyncStart, p->CrtcVDisplay);
p->CrtcVBlankEnd = max(p->CrtcVSyncEnd, p->CrtcVTotal);
@@ -194,7 +194,7 @@ xf86SetModeCrtc(DisplayModePtr p, int adjustFlags)
* Allocates and returns a copy of pMode, including pointers within pMode.
*/
DisplayModePtr
-xf86DuplicateMode(const DisplayModeRec *pMode)
+xf86DuplicateMode(const DisplayModeRec * pMode)
{
DisplayModePtr pNew;
@@ -204,9 +204,9 @@ xf86DuplicateMode(const DisplayModeRec *pMode)
pNew->prev = NULL;
if (pMode->name == NULL)
- xf86SetModeDefaultName(pNew);
+ xf86SetModeDefaultName(pNew);
else
- pNew->name = xnfstrdup(pMode->name);
+ pNew->name = xnfstrdup(pMode->name);
return pNew;
}
@@ -224,20 +224,21 @@ xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList)
DisplayModePtr mode;
for (mode = modeList; mode != NULL; mode = mode->next) {
- DisplayModePtr new;
-
- new = xf86DuplicateMode(mode);
-
- /* Insert pNew into modeList */
- if (last) {
- last->next = new;
- new->prev = last;
- } else {
- first = new;
- new->prev = NULL;
- }
- new->next = NULL;
- last = new;
+ DisplayModePtr new;
+
+ new = xf86DuplicateMode(mode);
+
+ /* Insert pNew into modeList */
+ if (last) {
+ last->next = new;
+ new->prev = last;
+ }
+ else {
+ first = new;
+ new->prev = NULL;
+ }
+ new->next = NULL;
+ last = new;
}
return first;
@@ -250,25 +251,24 @@ xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList)
* Crtc values set. So, it's assumed that the other numbers are enough.
*/
Bool
-xf86ModesEqual(const DisplayModeRec *pMode1, const DisplayModeRec *pMode2)
+xf86ModesEqual(const DisplayModeRec * pMode1, const DisplayModeRec * pMode2)
{
- if (pMode1->Clock == pMode2->Clock &&
- pMode1->HDisplay == pMode2->HDisplay &&
- pMode1->HSyncStart == pMode2->HSyncStart &&
- pMode1->HSyncEnd == pMode2->HSyncEnd &&
- pMode1->HTotal == pMode2->HTotal &&
- pMode1->HSkew == pMode2->HSkew &&
- pMode1->VDisplay == pMode2->VDisplay &&
- pMode1->VSyncStart == pMode2->VSyncStart &&
- pMode1->VSyncEnd == pMode2->VSyncEnd &&
- pMode1->VTotal == pMode2->VTotal &&
- pMode1->VScan == pMode2->VScan &&
- pMode1->Flags == pMode2->Flags)
- {
- return TRUE;
- } else {
- return FALSE;
- }
+ if (pMode1->Clock == pMode2->Clock &&
+ pMode1->HDisplay == pMode2->HDisplay &&
+ pMode1->HSyncStart == pMode2->HSyncStart &&
+ pMode1->HSyncEnd == pMode2->HSyncEnd &&
+ pMode1->HTotal == pMode2->HTotal &&
+ pMode1->HSkew == pMode2->HSkew &&
+ pMode1->VDisplay == pMode2->VDisplay &&
+ pMode1->VSyncStart == pMode2->VSyncStart &&
+ pMode1->VSyncEnd == pMode2->VSyncEnd &&
+ pMode1->VTotal == pMode2->VTotal &&
+ pMode1->VScan == pMode2->VScan && pMode1->Flags == pMode2->Flags) {
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
}
static void
@@ -309,54 +309,68 @@ xf86PrintModeline(int scrnIndex, DisplayModePtr mode)
{
char tmp[256];
char *flags = xnfcalloc(1, 1);
+
#define TBITS 6
- const char tchar[TBITS+1] = "UezdPb";
+ const char tchar[TBITS + 1] = "UezdPb";
+
int tbit[TBITS] = {
- M_T_USERPREF, M_T_DRIVER, M_T_USERDEF,
- M_T_DEFAULT, M_T_PREFERRED, M_T_BUILTIN
+ M_T_USERPREF, M_T_DRIVER, M_T_USERDEF,
+ M_T_DEFAULT, M_T_PREFERRED, M_T_BUILTIN
};
- char type[TBITS+2]; /* +1 for leading space */
+ char type[TBITS + 2]; /* +1 for leading space */
+
#undef TBITS
int tlen = 0;
if (mode->type) {
- int i;
+ int i;
- type[tlen++] = ' ';
- for (i = 0; tchar[i]; i++)
- if (mode->type & tbit[i])
- type[tlen++] = tchar[i];
+ type[tlen++] = ' ';
+ for (i = 0; tchar[i]; i++)
+ if (mode->type & tbit[i])
+ type[tlen++] = tchar[i];
}
type[tlen] = '\0';
- if (mode->HSkew) {
- snprintf(tmp, 256, "hskew %i", mode->HSkew);
- add(&flags, tmp);
+ if (mode->HSkew) {
+ snprintf(tmp, 256, "hskew %i", mode->HSkew);
+ add(&flags, tmp);
}
- if (mode->VScan) {
- snprintf(tmp, 256, "vscan %i", mode->VScan);
- add(&flags, tmp);
+ if (mode->VScan) {
+ snprintf(tmp, 256, "vscan %i", mode->VScan);
+ add(&flags, tmp);
}
- if (mode->Flags & V_INTERLACE) add(&flags, "interlace");
- if (mode->Flags & V_CSYNC) add(&flags, "composite");
- if (mode->Flags & V_DBLSCAN) add(&flags, "doublescan");
- if (mode->Flags & V_BCAST) add(&flags, "bcast");
- if (mode->Flags & V_PHSYNC) add(&flags, "+hsync");
- if (mode->Flags & V_NHSYNC) add(&flags, "-hsync");
- if (mode->Flags & V_PVSYNC) add(&flags, "+vsync");
- if (mode->Flags & V_NVSYNC) add(&flags, "-vsync");
- if (mode->Flags & V_PCSYNC) add(&flags, "+csync");
- if (mode->Flags & V_NCSYNC) add(&flags, "-csync");
+ if (mode->Flags & V_INTERLACE)
+ add(&flags, "interlace");
+ if (mode->Flags & V_CSYNC)
+ add(&flags, "composite");
+ if (mode->Flags & V_DBLSCAN)
+ add(&flags, "doublescan");
+ if (mode->Flags & V_BCAST)
+ add(&flags, "bcast");
+ if (mode->Flags & V_PHSYNC)
+ add(&flags, "+hsync");
+ if (mode->Flags & V_NHSYNC)
+ add(&flags, "-hsync");
+ if (mode->Flags & V_PVSYNC)
+ add(&flags, "+vsync");
+ if (mode->Flags & V_NVSYNC)
+ add(&flags, "-vsync");
+ if (mode->Flags & V_PCSYNC)
+ add(&flags, "+csync");
+ if (mode->Flags & V_NCSYNC)
+ add(&flags, "-csync");
#if 0
- if (mode->Flags & V_CLKDIV2) add(&flags, "vclk/2");
+ if (mode->Flags & V_CLKDIV2)
+ add(&flags, "vclk/2");
#endif
xf86DrvMsg(scrnIndex, X_INFO,
- "Modeline \"%s\"x%.01f %6.2f %i %i %i %i %i %i %i %i%s"
- " (%.01f kHz%s)\n",
- mode->name, mode->VRefresh, mode->Clock/1000.,
- mode->HDisplay, mode->HSyncStart, mode->HSyncEnd, mode->HTotal,
- mode->VDisplay, mode->VSyncStart, mode->VSyncEnd, mode->VTotal,
- flags, xf86ModeHSync(mode), type);
+ "Modeline \"%s\"x%.01f %6.2f %i %i %i %i %i %i %i %i%s"
+ " (%.01f kHz%s)\n",
+ mode->name, mode->VRefresh, mode->Clock / 1000.,
+ mode->HDisplay, mode->HSyncStart, mode->HSyncEnd, mode->HTotal,
+ mode->VDisplay, mode->VSyncStart, mode->VSyncEnd, mode->VTotal,
+ flags, xf86ModeHSync(mode), type);
free(flags);
}
@@ -369,19 +383,18 @@ xf86PrintModeline(int scrnIndex, DisplayModePtr mode)
* \bug only V_INTERLACE and V_DBLSCAN are supported. Is that enough?
*/
void
-xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList,
- int flags)
+xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList, int flags)
{
DisplayModePtr mode;
if (flags == (V_INTERLACE | V_DBLSCAN))
- return;
+ return;
for (mode = modeList; mode != NULL; mode = mode->next) {
- if (mode->Flags & V_INTERLACE && !(flags & V_INTERLACE))
- mode->status = MODE_NO_INTERLACE;
- if (mode->Flags & V_DBLSCAN && !(flags & V_DBLSCAN))
- mode->status = MODE_NO_DBLESCAN;
+ if (mode->Flags & V_INTERLACE && !(flags & V_INTERLACE))
+ mode->status = MODE_NO_INTERLACE;
+ if (mode->Flags & V_DBLSCAN && !(flags & V_DBLSCAN))
+ mode->status = MODE_NO_DBLESCAN;
}
}
@@ -392,39 +405,39 @@ xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList,
*/
void
xf86ValidateModesSize(ScrnInfoPtr pScrn, DisplayModePtr modeList,
- int maxX, int maxY, int maxPitch)
+ int maxX, int maxY, int maxPitch)
{
DisplayModePtr mode;
if (maxPitch <= 0)
- maxPitch = MAXINT;
+ maxPitch = MAXINT;
if (maxX <= 0)
- maxX = MAXINT;
+ maxX = MAXINT;
if (maxY <= 0)
- maxY = MAXINT;
+ maxY = MAXINT;
for (mode = modeList; mode != NULL; mode = mode->next) {
- if ((xf86ModeWidth(mode, RR_Rotate_0) > maxPitch ||
- xf86ModeWidth(mode, RR_Rotate_0) > maxX ||
- xf86ModeHeight(mode, RR_Rotate_0) > maxY) &&
- (xf86ModeWidth(mode, RR_Rotate_90) > maxPitch ||
- xf86ModeWidth(mode, RR_Rotate_90) > maxX ||
- xf86ModeHeight(mode, RR_Rotate_90) > maxY)) {
- if (xf86ModeWidth(mode, RR_Rotate_0) > maxPitch ||
- xf86ModeWidth(mode, RR_Rotate_90) > maxPitch)
- mode->status = MODE_BAD_WIDTH;
-
- if (xf86ModeWidth(mode, RR_Rotate_0) > maxX ||
- xf86ModeWidth(mode, RR_Rotate_90) > maxX)
- mode->status = MODE_VIRTUAL_X;
-
- if (xf86ModeHeight(mode, RR_Rotate_0) > maxY ||
- xf86ModeHeight(mode, RR_Rotate_90) > maxY)
- mode->status = MODE_VIRTUAL_Y;
- }
-
- if (mode->next == modeList)
- break;
+ if ((xf86ModeWidth(mode, RR_Rotate_0) > maxPitch ||
+ xf86ModeWidth(mode, RR_Rotate_0) > maxX ||
+ xf86ModeHeight(mode, RR_Rotate_0) > maxY) &&
+ (xf86ModeWidth(mode, RR_Rotate_90) > maxPitch ||
+ xf86ModeWidth(mode, RR_Rotate_90) > maxX ||
+ xf86ModeHeight(mode, RR_Rotate_90) > maxY)) {
+ if (xf86ModeWidth(mode, RR_Rotate_0) > maxPitch ||
+ xf86ModeWidth(mode, RR_Rotate_90) > maxPitch)
+ mode->status = MODE_BAD_WIDTH;
+
+ if (xf86ModeWidth(mode, RR_Rotate_0) > maxX ||
+ xf86ModeWidth(mode, RR_Rotate_90) > maxX)
+ mode->status = MODE_VIRTUAL_X;
+
+ if (xf86ModeHeight(mode, RR_Rotate_0) > maxY ||
+ xf86ModeHeight(mode, RR_Rotate_90) > maxY)
+ mode->status = MODE_VIRTUAL_Y;
+ }
+
+ if (mode->next == modeList)
+ break;
}
}
@@ -435,39 +448,39 @@ xf86ValidateModesSize(ScrnInfoPtr pScrn, DisplayModePtr modeList,
* \param modeList doubly-linked list of modes.
*/
void
-xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList,
- MonPtr mon)
+xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList, MonPtr mon)
{
DisplayModePtr mode;
for (mode = modeList; mode != NULL; mode = mode->next) {
- Bool bad;
- int i;
-
- bad = TRUE;
- for (i = 0; i < mon->nHsync; i++) {
- if (xf86ModeHSync(mode) >= mon->hsync[i].lo * (1-SYNC_TOLERANCE) &&
- xf86ModeHSync(mode) <= mon->hsync[i].hi * (1+SYNC_TOLERANCE))
- {
- bad = FALSE;
- }
- }
- if (bad)
- mode->status = MODE_HSYNC;
-
- bad = TRUE;
- for (i = 0; i < mon->nVrefresh; i++) {
- if (xf86ModeVRefresh(mode) >= mon->vrefresh[i].lo * (1-SYNC_TOLERANCE) &&
- xf86ModeVRefresh(mode) <= mon->vrefresh[i].hi * (1+SYNC_TOLERANCE))
- {
- bad = FALSE;
- }
- }
- if (bad)
- mode->status = MODE_VSYNC;
-
- if (mode->next == modeList)
- break;
+ Bool bad;
+ int i;
+
+ bad = TRUE;
+ for (i = 0; i < mon->nHsync; i++) {
+ if (xf86ModeHSync(mode) >= mon->hsync[i].lo * (1 - SYNC_TOLERANCE)
+ && xf86ModeHSync(mode) <=
+ mon->hsync[i].hi * (1 + SYNC_TOLERANCE)) {
+ bad = FALSE;
+ }
+ }
+ if (bad)
+ mode->status = MODE_HSYNC;
+
+ bad = TRUE;
+ for (i = 0; i < mon->nVrefresh; i++) {
+ if (xf86ModeVRefresh(mode) >=
+ mon->vrefresh[i].lo * (1 - SYNC_TOLERANCE) &&
+ xf86ModeVRefresh(mode) <=
+ mon->vrefresh[i].hi * (1 + SYNC_TOLERANCE)) {
+ bad = FALSE;
+ }
+ }
+ if (bad)
+ mode->status = MODE_VSYNC;
+
+ if (mode->next == modeList)
+ break;
}
}
@@ -481,22 +494,23 @@ xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList,
*/
void
xf86ValidateModesClocks(ScrnInfoPtr pScrn, DisplayModePtr modeList,
- int *min, int *max, int n_ranges)
+ int *min, int *max, int n_ranges)
{
DisplayModePtr mode;
int i;
for (mode = modeList; mode != NULL; mode = mode->next) {
- Bool good = FALSE;
- for (i = 0; i < n_ranges; i++) {
- if (mode->Clock >= min[i] * (1-SYNC_TOLERANCE) &&
- mode->Clock <= max[i] * (1+SYNC_TOLERANCE)) {
- good = TRUE;
- break;
- }
- }
- if (!good)
- mode->status = MODE_CLOCK_RANGE;
+ Bool good = FALSE;
+
+ for (i = 0; i < n_ranges; i++) {
+ if (mode->Clock >= min[i] * (1 - SYNC_TOLERANCE) &&
+ mode->Clock <= max[i] * (1 + SYNC_TOLERANCE)) {
+ good = TRUE;
+ break;
+ }
+ }
+ if (!good)
+ mode->status = MODE_CLOCK_RANGE;
}
}
@@ -518,25 +532,24 @@ xf86ValidateModesUserConfig(ScrnInfoPtr pScrn, DisplayModePtr modeList)
DisplayModePtr mode;
if (pScrn->display->modes[0] == NULL)
- return;
+ return;
for (mode = modeList; mode != NULL; mode = mode->next) {
- int i;
- Bool good = FALSE;
-
- for (i = 0; pScrn->display->modes[i] != NULL; i++) {
- if (strncmp(pScrn->display->modes[i], mode->name,
- strlen(pScrn->display->modes[i])) == 0) {
- good = TRUE;
- break;
- }
- }
- if (!good)
- mode->status = MODE_BAD;
+ int i;
+ Bool good = FALSE;
+
+ for (i = 0; pScrn->display->modes[i] != NULL; i++) {
+ if (strncmp(pScrn->display->modes[i], mode->name,
+ strlen(pScrn->display->modes[i])) == 0) {
+ good = TRUE;
+ break;
+ }
+ }
+ if (!good)
+ mode->status = MODE_BAD;
}
}
-
/**
* Marks as bad any modes exceeding the given bandwidth.
*
@@ -546,25 +559,25 @@ xf86ValidateModesUserConfig(ScrnInfoPtr pScrn, DisplayModePtr modeList)
*/
void
xf86ValidateModesBandwidth(ScrnInfoPtr pScrn, DisplayModePtr modeList,
- unsigned int bandwidth, int depth)
+ unsigned int bandwidth, int depth)
{
DisplayModePtr mode;
for (mode = modeList; mode != NULL; mode = mode->next) {
- if (xf86ModeBandwidth(mode, depth) > bandwidth)
- mode->status = MODE_BANDWIDTH;
+ if (xf86ModeBandwidth(mode, depth) > bandwidth)
+ mode->status = MODE_BANDWIDTH;
}
}
Bool
-xf86ModeIsReduced(const DisplayModeRec *mode)
+xf86ModeIsReduced(const DisplayModeRec * mode)
{
if ((((mode->HDisplay * 5 / 4) & ~0x07) > mode->HTotal) &&
((mode->HTotal - mode->HDisplay) == 160) &&
- ((mode->HSyncEnd - mode->HDisplay) == 80) &&
- ((mode->HSyncEnd - mode->HSyncStart) == 32) &&
- ((mode->VSyncStart - mode->VDisplay) == 3))
- return TRUE;
+ ((mode->HSyncEnd - mode->HDisplay) == 80) &&
+ ((mode->HSyncEnd - mode->HSyncStart) == 32) &&
+ ((mode->VSyncStart - mode->VDisplay) == 3))
+ return TRUE;
return FALSE;
}
@@ -577,8 +590,8 @@ void
xf86ValidateModesReducedBlanking(ScrnInfoPtr pScrn, DisplayModePtr modeList)
{
for (; modeList != NULL; modeList = modeList->next)
- if (xf86ModeIsReduced(modeList))
- modeList->status = MODE_NO_REDUCED;
+ if (xf86ModeIsReduced(modeList))
+ modeList->status = MODE_NO_REDUCED;
}
/**
@@ -589,31 +602,32 @@ xf86ValidateModesReducedBlanking(ScrnInfoPtr pScrn, DisplayModePtr modeList)
* printed.
*/
void
-xf86PruneInvalidModes(ScrnInfoPtr pScrn, DisplayModePtr *modeList,
- Bool verbose)
+xf86PruneInvalidModes(ScrnInfoPtr pScrn, DisplayModePtr * modeList,
+ Bool verbose)
{
DisplayModePtr mode;
for (mode = *modeList; mode != NULL;) {
- DisplayModePtr next = mode->next, first = *modeList;
-
- if (mode->status != MODE_OK) {
- if (verbose) {
- const char *type = "";
- if (mode->type & M_T_BUILTIN)
- type = "built-in ";
- else if (mode->type & M_T_DEFAULT)
- type = "default ";
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Not using %smode \"%s\" (%s)\n", type, mode->name,
- xf86ModeStatusToString(mode->status));
- }
- xf86DeleteMode(modeList, mode);
- }
-
- if (next == first)
- break;
- mode = next;
+ DisplayModePtr next = mode->next, first = *modeList;
+
+ if (mode->status != MODE_OK) {
+ if (verbose) {
+ const char *type = "";
+
+ if (mode->type & M_T_BUILTIN)
+ type = "built-in ";
+ else if (mode->type & M_T_DEFAULT)
+ type = "default ";
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Not using %smode \"%s\" (%s)\n", type, mode->name,
+ xf86ModeStatusToString(mode->status));
+ }
+ xf86DeleteMode(modeList, mode);
+ }
+
+ if (next == first)
+ break;
+ mode = next;
}
}
@@ -626,16 +640,16 @@ DisplayModePtr
xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new)
{
if (modes == NULL)
- return new;
+ return new;
if (new) {
- DisplayModePtr mode = modes;
+ DisplayModePtr mode = modes;
- while (mode->next)
- mode = mode->next;
+ while (mode->next)
+ mode = mode->next;
- mode->next = new;
- new->prev = mode;
+ mode->next = new;
+ new->prev = mode;
}
return modes;
@@ -645,42 +659,40 @@ xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new)
* Build a mode list from a list of config file modes
*/
static DisplayModePtr
-xf86GetConfigModes (XF86ConfModeLinePtr conf_mode)
+xf86GetConfigModes(XF86ConfModeLinePtr conf_mode)
{
- DisplayModePtr head = NULL, prev = NULL, mode;
-
- for (; conf_mode; conf_mode = (XF86ConfModeLinePtr) conf_mode->list.next)
- {
+ DisplayModePtr head = NULL, prev = NULL, mode;
+
+ for (; conf_mode; conf_mode = (XF86ConfModeLinePtr) conf_mode->list.next) {
mode = calloc(1, sizeof(DisplayModeRec));
- if (!mode)
- continue;
- mode->name = xstrdup(conf_mode->ml_identifier);
- if (!mode->name)
- {
- free(mode);
- continue;
- }
- mode->type = 0;
- mode->Clock = conf_mode->ml_clock;
- mode->HDisplay = conf_mode->ml_hdisplay;
+ if (!mode)
+ continue;
+ mode->name = xstrdup(conf_mode->ml_identifier);
+ if (!mode->name) {
+ free(mode);
+ continue;
+ }
+ mode->type = 0;
+ mode->Clock = conf_mode->ml_clock;
+ mode->HDisplay = conf_mode->ml_hdisplay;
mode->HSyncStart = conf_mode->ml_hsyncstart;
- mode->HSyncEnd = conf_mode->ml_hsyncend;
- mode->HTotal = conf_mode->ml_htotal;
- mode->VDisplay = conf_mode->ml_vdisplay;
+ mode->HSyncEnd = conf_mode->ml_hsyncend;
+ mode->HTotal = conf_mode->ml_htotal;
+ mode->VDisplay = conf_mode->ml_vdisplay;
mode->VSyncStart = conf_mode->ml_vsyncstart;
- mode->VSyncEnd = conf_mode->ml_vsyncend;
- mode->VTotal = conf_mode->ml_vtotal;
- mode->Flags = conf_mode->ml_flags;
- mode->HSkew = conf_mode->ml_hskew;
- mode->VScan = conf_mode->ml_vscan;
+ mode->VSyncEnd = conf_mode->ml_vsyncend;
+ mode->VTotal = conf_mode->ml_vtotal;
+ mode->Flags = conf_mode->ml_flags;
+ mode->HSkew = conf_mode->ml_hskew;
+ mode->VScan = conf_mode->ml_vscan;
mode->prev = prev;
- mode->next = NULL;
- if (prev)
- prev->next = mode;
- else
- head = mode;
- prev = mode;
+ mode->next = NULL;
+ if (prev)
+ prev->next = mode;
+ else
+ head = mode;
+ prev = mode;
}
return head;
}
@@ -689,49 +701,47 @@ xf86GetConfigModes (XF86ConfModeLinePtr conf_mode)
* Build a mode list from a monitor configuration
*/
DisplayModePtr
-xf86GetMonitorModes (ScrnInfoPtr pScrn, XF86ConfMonitorPtr conf_monitor)
+xf86GetMonitorModes(ScrnInfoPtr pScrn, XF86ConfMonitorPtr conf_monitor)
{
- DisplayModePtr modes = NULL;
- XF86ConfModesLinkPtr modes_link;
-
+ DisplayModePtr modes = NULL;
+ XF86ConfModesLinkPtr modes_link;
+
if (!conf_monitor)
- return NULL;
+ return NULL;
/*
* first we collect the mode lines from the UseModes directive
*/
- for (modes_link = conf_monitor->mon_modes_sect_lst;
- modes_link;
- modes_link = modes_link->list.next)
- {
- /* If this modes link hasn't been resolved, go look it up now */
- if (!modes_link->ml_modes)
- modes_link->ml_modes = xf86findModes (modes_link->ml_modes_str,
- xf86configptr->conf_modes_lst);
- if (modes_link->ml_modes)
- modes = xf86ModesAdd (modes,
- xf86GetConfigModes (modes_link->ml_modes->mon_modeline_lst));
+ for (modes_link = conf_monitor->mon_modes_sect_lst;
+ modes_link; modes_link = modes_link->list.next) {
+ /* If this modes link hasn't been resolved, go look it up now */
+ if (!modes_link->ml_modes)
+ modes_link->ml_modes = xf86findModes(modes_link->ml_modes_str,
+ xf86configptr->conf_modes_lst);
+ if (modes_link->ml_modes)
+ modes = xf86ModesAdd(modes,
+ xf86GetConfigModes(modes_link->ml_modes->
+ mon_modeline_lst));
}
- return xf86ModesAdd (modes,
- xf86GetConfigModes (conf_monitor->mon_modeline_lst));
+ return xf86ModesAdd(modes,
+ xf86GetConfigModes(conf_monitor->mon_modeline_lst));
}
/**
* Build a mode list containing all of the default modes
*/
DisplayModePtr
-xf86GetDefaultModes (void)
+xf86GetDefaultModes(void)
{
- DisplayModePtr head = NULL, mode;
- int i;
-
- for (i = 0; i < xf86NumDefaultModes; i++)
- {
- const DisplayModeRec *defMode = &xf86DefaultModes[i];
-
- mode = xf86DuplicateMode(defMode);
- head = xf86ModesAdd(head, mode);
+ DisplayModePtr head = NULL, mode;
+ int i;
+
+ for (i = 0; i < xf86NumDefaultModes; i++) {
+ const DisplayModeRec *defMode = &xf86DefaultModes[i];
+
+ mode = xf86DuplicateMode(defMode);
+ head = xf86ModesAdd(head, mode);
}
return head;
}
@@ -752,19 +762,19 @@ xf86PruneDuplicateModes(DisplayModePtr modes)
{
DisplayModePtr m, n, o;
-top:
+ top:
for (m = modes; m; m = m->next) {
- for (n = m->next; n; n = o) {
- o = n->next;
- if (xf86ModesEqual(m, n)) {
- if (n->type & M_T_PREFERRED) {
- xf86DeleteMode(&modes, m);
- goto top;
- }
- else
- xf86DeleteMode(&modes, n);
- }
- }
+ for (n = m->next; n; n = o) {
+ o = n->next;
+ if (xf86ModesEqual(m, n)) {
+ if (n->type & M_T_PREFERRED) {
+ xf86DeleteMode(&modes, m);
+ goto top;
+ }
+ else
+ xf86DeleteMode(&modes, n);
+ }
+ }
}
return modes;
diff --git a/xorg-server/hw/xfree86/modes/xf86Modes.h b/xorg-server/hw/xfree86/modes/xf86Modes.h
index 89ec0d81d..aec7688c4 100644
--- a/xorg-server/hw/xfree86/modes/xf86Modes.h
+++ b/xorg-server/hw/xfree86/modes/xf86Modes.h
@@ -40,74 +40,78 @@
#include "xf86Rename.h"
#endif
-extern _X_EXPORT double xf86ModeHSync(const DisplayModeRec *mode);
-extern _X_EXPORT double xf86ModeVRefresh(const DisplayModeRec *mode);
+extern _X_EXPORT double xf86ModeHSync(const DisplayModeRec * mode);
+extern _X_EXPORT double xf86ModeVRefresh(const DisplayModeRec * mode);
extern _X_EXPORT unsigned int xf86ModeBandwidth(DisplayModePtr mode, int depth);
extern _X_EXPORT int
-xf86ModeWidth (const DisplayModeRec *mode, Rotation rotation);
-
+ xf86ModeWidth(const DisplayModeRec * mode, Rotation rotation);
+
extern _X_EXPORT int
-xf86ModeHeight (const DisplayModeRec *mode, Rotation rotation);
+ xf86ModeHeight(const DisplayModeRec * mode, Rotation rotation);
-extern _X_EXPORT DisplayModePtr xf86DuplicateMode(const DisplayModeRec *pMode);
+extern _X_EXPORT DisplayModePtr xf86DuplicateMode(const DisplayModeRec * pMode);
extern _X_EXPORT DisplayModePtr xf86DuplicateModes(ScrnInfoPtr pScrn,
- DisplayModePtr modeList);
+ DisplayModePtr modeList);
extern _X_EXPORT void xf86SetModeDefaultName(DisplayModePtr mode);
extern _X_EXPORT void xf86SetModeCrtc(DisplayModePtr p, int adjustFlags);
-extern _X_EXPORT Bool xf86ModesEqual(const DisplayModeRec *pMode1,
- const DisplayModeRec *pMode2);
-extern _X_EXPORT void xf86PrintModeline(int scrnIndex,DisplayModePtr mode);
-extern _X_EXPORT DisplayModePtr xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new);
+extern _X_EXPORT Bool xf86ModesEqual(const DisplayModeRec * pMode1,
+ const DisplayModeRec * pMode2);
+extern _X_EXPORT void xf86PrintModeline(int scrnIndex, DisplayModePtr mode);
+extern _X_EXPORT DisplayModePtr xf86ModesAdd(DisplayModePtr modes,
+ DisplayModePtr new);
extern _X_EXPORT DisplayModePtr xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC);
-extern _X_EXPORT DisplayModePtr xf86CVTMode(int HDisplay, int VDisplay, float VRefresh,
- Bool Reduced, Bool Interlaced);
-extern _X_EXPORT DisplayModePtr xf86GTFMode(int h_pixels, int v_lines, float freq, int interlaced, int margins);
+extern _X_EXPORT DisplayModePtr xf86CVTMode(int HDisplay, int VDisplay,
+ float VRefresh, Bool Reduced,
+ Bool Interlaced);
+extern _X_EXPORT DisplayModePtr xf86GTFMode(int h_pixels, int v_lines,
+ float freq, int interlaced,
+ int margins);
extern _X_EXPORT Bool
-xf86ModeIsReduced(const DisplayModeRec *mode);
+ xf86ModeIsReduced(const DisplayModeRec * mode);
extern _X_EXPORT void
-xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList,
- int flags);
+ xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList, int flags);
extern _X_EXPORT void
+
xf86ValidateModesClocks(ScrnInfoPtr pScrn, DisplayModePtr modeList,
- int *min, int *max, int n_ranges);
+ int *min, int *max, int n_ranges);
extern _X_EXPORT void
+
xf86ValidateModesSize(ScrnInfoPtr pScrn, DisplayModePtr modeList,
- int maxX, int maxY, int maxPitch);
+ int maxX, int maxY, int maxPitch);
extern _X_EXPORT void
-xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList,
- MonPtr mon);
+ xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList, MonPtr mon);
extern _X_EXPORT void
+
xf86ValidateModesBandwidth(ScrnInfoPtr pScrn, DisplayModePtr modeList,
- unsigned int bandwidth, int depth);
+ unsigned int bandwidth, int depth);
extern _X_EXPORT void
-xf86ValidateModesReducedBlanking(ScrnInfoPtr pScrn, DisplayModePtr modeList);
+ xf86ValidateModesReducedBlanking(ScrnInfoPtr pScrn, DisplayModePtr modeList);
extern _X_EXPORT void
-xf86PruneInvalidModes(ScrnInfoPtr pScrn, DisplayModePtr *modeList,
- Bool verbose);
-extern _X_EXPORT DisplayModePtr
-xf86PruneDuplicateModes(DisplayModePtr modes);
+xf86PruneInvalidModes(ScrnInfoPtr pScrn, DisplayModePtr * modeList,
+ Bool verbose);
+
+extern _X_EXPORT DisplayModePtr xf86PruneDuplicateModes(DisplayModePtr modes);
extern _X_EXPORT void
-xf86ValidateModesUserConfig(ScrnInfoPtr pScrn, DisplayModePtr modeList);
+ xf86ValidateModesUserConfig(ScrnInfoPtr pScrn, DisplayModePtr modeList);
extern _X_EXPORT DisplayModePtr
-xf86GetMonitorModes (ScrnInfoPtr pScrn, XF86ConfMonitorPtr conf_monitor);
+xf86GetMonitorModes(ScrnInfoPtr pScrn, XF86ConfMonitorPtr conf_monitor);
-extern _X_EXPORT DisplayModePtr
-xf86GetDefaultModes (void);
+extern _X_EXPORT DisplayModePtr xf86GetDefaultModes(void);
extern _X_EXPORT void
-xf86DDCApplyQuirks(int scrnIndex, xf86MonPtr DDC);
+ xf86DDCApplyQuirks(int scrnIndex, xf86MonPtr DDC);
-#endif /* _XF86MODES_H_ */
+#endif /* _XF86MODES_H_ */
diff --git a/xorg-server/hw/xfree86/modes/xf86RandR12.c b/xorg-server/hw/xfree86/modes/xf86RandR12.c
index d5031a2f1..a773c34c6 100644
--- a/xorg-server/hw/xfree86/modes/xf86RandR12.c
+++ b/xorg-server/hw/xfree86/modes/xf86RandR12.c
@@ -43,16 +43,16 @@
#include "xf86RandR12.h"
typedef struct _xf86RandR12Info {
- int virtualX;
- int virtualY;
- int mmWidth;
- int mmHeight;
- int maxX;
- int maxY;
- int pointerX;
- int pointerY;
- Rotation rotation; /* current mode */
- Rotation supported_rotations; /* driver supported */
+ int virtualX;
+ int virtualY;
+ int mmWidth;
+ int mmHeight;
+ int maxX;
+ int maxY;
+ int pointerX;
+ int pointerY;
+ Rotation rotation; /* current mode */
+ Rotation supported_rotations; /* driver supported */
/* Used to wrap EnterVT so we can re-probe the outputs when a laptop unsuspends
* (actually, any time that we switch back into our VT).
@@ -63,106 +63,117 @@ typedef struct _xf86RandR12Info {
} XF86RandRInfoRec, *XF86RandRInfoPtr;
#ifdef RANDR_12_INTERFACE
-static Bool xf86RandR12Init12 (ScreenPtr pScreen);
-static Bool xf86RandR12CreateScreenResources12 (ScreenPtr pScreen);
+static Bool xf86RandR12Init12(ScreenPtr pScreen);
+static Bool xf86RandR12CreateScreenResources12(ScreenPtr pScreen);
#endif
static int xf86RandR12Generation;
static DevPrivateKeyRec xf86RandR12KeyRec;
static DevPrivateKey xf86RandR12Key;
+
#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) \
dixLookupPrivate(&(p)->devPrivates, xf86RandR12Key))
-
static int
-xf86RandR12ModeRefresh (DisplayModePtr mode)
+xf86RandR12ModeRefresh(DisplayModePtr mode)
{
if (mode->VRefresh)
- return (int) (mode->VRefresh + 0.5);
+ return (int) (mode->VRefresh + 0.5);
else
- return (int) (mode->Clock * 1000.0 / mode->HTotal / mode->VTotal + 0.5);
+ return (int) (mode->Clock * 1000.0 / mode->HTotal / mode->VTotal + 0.5);
}
/* Adapt panning area; return TRUE if panning area was valid without adaption */
static int
-xf86RandR13VerifyPanningArea (xf86CrtcPtr crtc, int screenWidth, int screenHeight)
+xf86RandR13VerifyPanningArea(xf86CrtcPtr crtc, int screenWidth,
+ int screenHeight)
{
int ret = TRUE;
if (crtc->version < 2)
- return FALSE;
+ return FALSE;
if (crtc->panningTotalArea.x2 <= crtc->panningTotalArea.x1) {
- /* Panning in X is disabled */
- if (crtc->panningTotalArea.x1 || crtc->panningTotalArea.x2)
- /* Illegal configuration -> fail/disable */
- ret = FALSE;
- crtc->panningTotalArea.x1 = crtc->panningTotalArea.x2 = 0;
- crtc->panningTrackingArea.x1 = crtc->panningTrackingArea.x2 = 0;
- crtc->panningBorder[0] = crtc->panningBorder[2] = 0;
- } else {
- /* Panning in X is enabled */
- if (crtc->panningTotalArea.x1 < 0) {
- /* Panning region outside screen -> move inside */
- crtc->panningTotalArea.x2 -= crtc->panningTotalArea.x1;
- crtc->panningTotalArea.x1 = 0;
- ret = FALSE;
- }
- if (crtc->panningTotalArea.x2 < crtc->panningTotalArea.x1 + crtc->mode.HDisplay) {
- /* Panning region smaller than displayed area -> crop to displayed area */
- crtc->panningTotalArea.x2 = crtc->panningTotalArea.x1 + crtc->mode.HDisplay;
- ret = FALSE;
- }
- if (crtc->panningTotalArea.x2 > screenWidth) {
- /* Panning region larger than screen -> move inside, then crop to screen */
- crtc->panningTotalArea.x1 -= crtc->panningTotalArea.x2 - screenWidth;
- crtc->panningTotalArea.x2 = screenWidth;
- ret = FALSE;
- if (crtc->panningTotalArea.x1 < 0)
- crtc->panningTotalArea.x1 = 0;
- }
- if (crtc->panningBorder[0] + crtc->panningBorder[2] > crtc->mode.HDisplay) {
- /* Borders too large -> set to 0 */
- crtc->panningBorder[0] = crtc->panningBorder[2] = 0;
- ret = FALSE;
- }
+ /* Panning in X is disabled */
+ if (crtc->panningTotalArea.x1 || crtc->panningTotalArea.x2)
+ /* Illegal configuration -> fail/disable */
+ ret = FALSE;
+ crtc->panningTotalArea.x1 = crtc->panningTotalArea.x2 = 0;
+ crtc->panningTrackingArea.x1 = crtc->panningTrackingArea.x2 = 0;
+ crtc->panningBorder[0] = crtc->panningBorder[2] = 0;
+ }
+ else {
+ /* Panning in X is enabled */
+ if (crtc->panningTotalArea.x1 < 0) {
+ /* Panning region outside screen -> move inside */
+ crtc->panningTotalArea.x2 -= crtc->panningTotalArea.x1;
+ crtc->panningTotalArea.x1 = 0;
+ ret = FALSE;
+ }
+ if (crtc->panningTotalArea.x2 <
+ crtc->panningTotalArea.x1 + crtc->mode.HDisplay) {
+ /* Panning region smaller than displayed area -> crop to displayed area */
+ crtc->panningTotalArea.x2 =
+ crtc->panningTotalArea.x1 + crtc->mode.HDisplay;
+ ret = FALSE;
+ }
+ if (crtc->panningTotalArea.x2 > screenWidth) {
+ /* Panning region larger than screen -> move inside, then crop to screen */
+ crtc->panningTotalArea.x1 -=
+ crtc->panningTotalArea.x2 - screenWidth;
+ crtc->panningTotalArea.x2 = screenWidth;
+ ret = FALSE;
+ if (crtc->panningTotalArea.x1 < 0)
+ crtc->panningTotalArea.x1 = 0;
+ }
+ if (crtc->panningBorder[0] + crtc->panningBorder[2] >
+ crtc->mode.HDisplay) {
+ /* Borders too large -> set to 0 */
+ crtc->panningBorder[0] = crtc->panningBorder[2] = 0;
+ ret = FALSE;
+ }
}
if (crtc->panningTotalArea.y2 <= crtc->panningTotalArea.y1) {
- /* Panning in Y is disabled */
- if (crtc->panningTotalArea.y1 || crtc->panningTotalArea.y2)
- /* Illegal configuration -> fail/disable */
- ret = FALSE;
- crtc->panningTotalArea.y1 = crtc->panningTotalArea.y2 = 0;
- crtc->panningTrackingArea.y1 = crtc->panningTrackingArea.y2 = 0;
- crtc->panningBorder[1] = crtc->panningBorder[3] = 0;
- } else {
- /* Panning in Y is enabled */
- if (crtc->panningTotalArea.y1 < 0) {
- /* Panning region outside screen -> move inside */
- crtc->panningTotalArea.y2 -= crtc->panningTotalArea.y1;
- crtc->panningTotalArea.y1 = 0;
- ret = FALSE;
- }
- if (crtc->panningTotalArea.y2 < crtc->panningTotalArea.y1 + crtc->mode.VDisplay) {
- /* Panning region smaller than displayed area -> crop to displayed area */
- crtc->panningTotalArea.y2 = crtc->panningTotalArea.y1 + crtc->mode.VDisplay;
- ret = FALSE;
- }
- if (crtc->panningTotalArea.y2 > screenHeight) {
- /* Panning region larger than screen -> move inside, then crop to screen */
- crtc->panningTotalArea.y1 -= crtc->panningTotalArea.y2 - screenHeight;
- crtc->panningTotalArea.y2 = screenHeight;
- ret = FALSE;
- if (crtc->panningTotalArea.y1 < 0)
- crtc->panningTotalArea.y1 = 0;
- }
- if (crtc->panningBorder[1] + crtc->panningBorder[3] > crtc->mode.VDisplay) {
- /* Borders too large -> set to 0 */
- crtc->panningBorder[1] = crtc->panningBorder[3] = 0;
- ret = FALSE;
- }
+ /* Panning in Y is disabled */
+ if (crtc->panningTotalArea.y1 || crtc->panningTotalArea.y2)
+ /* Illegal configuration -> fail/disable */
+ ret = FALSE;
+ crtc->panningTotalArea.y1 = crtc->panningTotalArea.y2 = 0;
+ crtc->panningTrackingArea.y1 = crtc->panningTrackingArea.y2 = 0;
+ crtc->panningBorder[1] = crtc->panningBorder[3] = 0;
+ }
+ else {
+ /* Panning in Y is enabled */
+ if (crtc->panningTotalArea.y1 < 0) {
+ /* Panning region outside screen -> move inside */
+ crtc->panningTotalArea.y2 -= crtc->panningTotalArea.y1;
+ crtc->panningTotalArea.y1 = 0;
+ ret = FALSE;
+ }
+ if (crtc->panningTotalArea.y2 <
+ crtc->panningTotalArea.y1 + crtc->mode.VDisplay) {
+ /* Panning region smaller than displayed area -> crop to displayed area */
+ crtc->panningTotalArea.y2 =
+ crtc->panningTotalArea.y1 + crtc->mode.VDisplay;
+ ret = FALSE;
+ }
+ if (crtc->panningTotalArea.y2 > screenHeight) {
+ /* Panning region larger than screen -> move inside, then crop to screen */
+ crtc->panningTotalArea.y1 -=
+ crtc->panningTotalArea.y2 - screenHeight;
+ crtc->panningTotalArea.y2 = screenHeight;
+ ret = FALSE;
+ if (crtc->panningTotalArea.y1 < 0)
+ crtc->panningTotalArea.y1 = 0;
+ }
+ if (crtc->panningBorder[1] + crtc->panningBorder[3] >
+ crtc->mode.VDisplay) {
+ /* Borders too large -> set to 0 */
+ crtc->panningBorder[1] = crtc->panningBorder[3] = 0;
+ ret = FALSE;
+ }
}
return ret;
@@ -179,232 +190,232 @@ xf86RandR13VerifyPanningArea (xf86CrtcPtr crtc, int screenWidth, int screenHeigh
*/
static void
-xf86ComputeCrtcPan (Bool transform_in_use,
- struct pixman_f_transform *m,
- double screen_x, double screen_y,
- double crtc_x, double crtc_y,
- int old_pan_x, int old_pan_y,
- int *new_pan_x, int *new_pan_y)
+xf86ComputeCrtcPan(Bool transform_in_use,
+ struct pixman_f_transform *m,
+ double screen_x, double screen_y,
+ double crtc_x, double crtc_y,
+ int old_pan_x, int old_pan_y, int *new_pan_x, int *new_pan_y)
{
if (transform_in_use) {
- /*
- * Given the current transform, M, the current position
- * on the Screen, S, and the desired position on the CRTC,
- * C, compute a translation, T, such that:
- *
- * M T S = C
- *
- * where T is of the form
- *
- * | 1 0 dx |
- * | 0 1 dy |
- * | 0 0 1 |
- *
- * M T S =
- * | M00 Sx + M01 Sy + M00 dx + M01 dy + M02 | | Cx F |
- * | M10 Sx + M11 Sy + M10 dx + M11 dy + M12 | = | Cy F |
- * | M20 Sx + M21 Sy + M20 dx + M21 dy + M22 | | F |
- *
- * R = M S
- *
- * Cx F = M00 dx + M01 dy + R0
- * Cy F = M10 dx + M11 dy + R1
- * F = M20 dx + M21 dy + R2
- *
- * Zero out dx, then dy
- *
- * F (Cx M10 - Cy M00) =
- * (M10 M01 - M00 M11) dy + M10 R0 - M00 R1
- * F (M10 - Cy M20) =
- * (M10 M21 - M20 M11) dy + M10 R2 - M20 R1
- *
- * F (Cx M11 - Cy M01) =
- * (M11 M00 - M01 M10) dx + M11 R0 - M01 R1
- * F (M11 - Cy M21) =
- * (M11 M20 - M21 M10) dx + M11 R2 - M21 R1
- *
- * Make some temporaries
- *
- * T = | Cx M10 - Cy M00 |
- * | Cx M11 - Cy M01 |
- *
- * U = | M10 M01 - M00 M11 |
- * | M11 M00 - M01 M10 |
- *
- * Q = | M10 R0 - M00 R1 |
- * | M11 R0 - M01 R1 |
- *
- * P = | M10 - Cy M20 |
- * | M11 - Cy M21 |
- *
- * W = | M10 M21 - M20 M11 |
- * | M11 M20 - M21 M10 |
- *
- * V = | M10 R2 - M20 R1 |
- * | M11 R2 - M21 R1 |
- *
- * Rewrite:
- *
- * F T0 = U0 dy + Q0
- * F P0 = W0 dy + V0
- * F T1 = U1 dx + Q1
- * F P1 = W1 dx + V1
- *
- * Solve for F (two ways)
- *
- * F (W0 T0 - U0 P0) = W0 Q0 - U0 V0
- *
- * W0 Q0 - U0 V0
- * F = -------------
- * W0 T0 - U0 P0
- *
- * F (W1 T1 - U1 P1) = W1 Q1 - U1 V1
- *
- * W1 Q1 - U1 V1
- * F = -------------
- * W1 T1 - U1 P1
- *
- * We'll use which ever solution works (denominator != 0)
- *
- * Finally, solve for dx and dy:
- *
- * dx = (F T1 - Q1) / U1
- * dx = (F P1 - V1) / W1
- *
- * dy = (F T0 - Q0) / U0
- * dy = (F P0 - V0) / W0
- */
- double r[3];
- double q[2], u[2], t[2], v[2], w[2], p[2];
- double f;
- struct pict_f_vector d;
- int i;
-
- /* Get the un-normalized crtc coordinates again */
- for (i = 0; i < 3; i++)
- r[i] = m->m[i][0] * screen_x + m->m[i][1] * screen_y + m->m[i][2];
-
- /* Combine values into temporaries */
- for (i = 0; i < 2; i++) {
- q[i] = m->m[1][i] * r[0] - m->m[0][i] * r[1];
- u[i] = m->m[1][i] * m->m[0][1-i] - m->m[0][i] * m->m[1][1-i];
- t[i] = m->m[1][i] * crtc_x - m->m[0][i] * crtc_y;
-
- v[i] = m->m[1][i] * r[2] - m->m[2][i] * r[1];
- w[i] = m->m[1][i] * m->m[2][1-i] - m->m[2][i] * m->m[1][1-i];
- p[i] = m->m[1][i] - m->m[2][i] * crtc_y;
- }
-
- /* Find a way to compute f */
- f = 0;
- for (i = 0; i < 2; i++) {
- double a = w[i] * q[i] - u[i] * v[i];
- double b = w[i] * t[i] - u[i] * p[i];
- if (b != 0) {
- f = a/b;
- break;
- }
- }
-
- /* Solve for the resulting transform vector */
- for (i = 0; i < 2; i++) {
- if (u[i])
- d.v[1-i] = (t[i] * f - q[i]) / u[i];
- else if (w[1])
- d.v[1-i] = (p[i] * f - v[i]) / w[i];
- else
- d.v[1-i] = 0;
- }
- *new_pan_x = old_pan_x - floor (d.v[0] + 0.5);
- *new_pan_y = old_pan_y - floor (d.v[1] + 0.5);
- } else {
- *new_pan_x = screen_x - crtc_x;
- *new_pan_y = screen_y - crtc_y;
+ /*
+ * Given the current transform, M, the current position
+ * on the Screen, S, and the desired position on the CRTC,
+ * C, compute a translation, T, such that:
+ *
+ * M T S = C
+ *
+ * where T is of the form
+ *
+ * | 1 0 dx |
+ * | 0 1 dy |
+ * | 0 0 1 |
+ *
+ * M T S =
+ * | M00 Sx + M01 Sy + M00 dx + M01 dy + M02 | | Cx F |
+ * | M10 Sx + M11 Sy + M10 dx + M11 dy + M12 | = | Cy F |
+ * | M20 Sx + M21 Sy + M20 dx + M21 dy + M22 | | F |
+ *
+ * R = M S
+ *
+ * Cx F = M00 dx + M01 dy + R0
+ * Cy F = M10 dx + M11 dy + R1
+ * F = M20 dx + M21 dy + R2
+ *
+ * Zero out dx, then dy
+ *
+ * F (Cx M10 - Cy M00) =
+ * (M10 M01 - M00 M11) dy + M10 R0 - M00 R1
+ * F (M10 - Cy M20) =
+ * (M10 M21 - M20 M11) dy + M10 R2 - M20 R1
+ *
+ * F (Cx M11 - Cy M01) =
+ * (M11 M00 - M01 M10) dx + M11 R0 - M01 R1
+ * F (M11 - Cy M21) =
+ * (M11 M20 - M21 M10) dx + M11 R2 - M21 R1
+ *
+ * Make some temporaries
+ *
+ * T = | Cx M10 - Cy M00 |
+ * | Cx M11 - Cy M01 |
+ *
+ * U = | M10 M01 - M00 M11 |
+ * | M11 M00 - M01 M10 |
+ *
+ * Q = | M10 R0 - M00 R1 |
+ * | M11 R0 - M01 R1 |
+ *
+ * P = | M10 - Cy M20 |
+ * | M11 - Cy M21 |
+ *
+ * W = | M10 M21 - M20 M11 |
+ * | M11 M20 - M21 M10 |
+ *
+ * V = | M10 R2 - M20 R1 |
+ * | M11 R2 - M21 R1 |
+ *
+ * Rewrite:
+ *
+ * F T0 = U0 dy + Q0
+ * F P0 = W0 dy + V0
+ * F T1 = U1 dx + Q1
+ * F P1 = W1 dx + V1
+ *
+ * Solve for F (two ways)
+ *
+ * F (W0 T0 - U0 P0) = W0 Q0 - U0 V0
+ *
+ * W0 Q0 - U0 V0
+ * F = -------------
+ * W0 T0 - U0 P0
+ *
+ * F (W1 T1 - U1 P1) = W1 Q1 - U1 V1
+ *
+ * W1 Q1 - U1 V1
+ * F = -------------
+ * W1 T1 - U1 P1
+ *
+ * We'll use which ever solution works (denominator != 0)
+ *
+ * Finally, solve for dx and dy:
+ *
+ * dx = (F T1 - Q1) / U1
+ * dx = (F P1 - V1) / W1
+ *
+ * dy = (F T0 - Q0) / U0
+ * dy = (F P0 - V0) / W0
+ */
+ double r[3];
+ double q[2], u[2], t[2], v[2], w[2], p[2];
+ double f;
+ struct pict_f_vector d;
+ int i;
+
+ /* Get the un-normalized crtc coordinates again */
+ for (i = 0; i < 3; i++)
+ r[i] = m->m[i][0] * screen_x + m->m[i][1] * screen_y + m->m[i][2];
+
+ /* Combine values into temporaries */
+ for (i = 0; i < 2; i++) {
+ q[i] = m->m[1][i] * r[0] - m->m[0][i] * r[1];
+ u[i] = m->m[1][i] * m->m[0][1 - i] - m->m[0][i] * m->m[1][1 - i];
+ t[i] = m->m[1][i] * crtc_x - m->m[0][i] * crtc_y;
+
+ v[i] = m->m[1][i] * r[2] - m->m[2][i] * r[1];
+ w[i] = m->m[1][i] * m->m[2][1 - i] - m->m[2][i] * m->m[1][1 - i];
+ p[i] = m->m[1][i] - m->m[2][i] * crtc_y;
+ }
+
+ /* Find a way to compute f */
+ f = 0;
+ for (i = 0; i < 2; i++) {
+ double a = w[i] * q[i] - u[i] * v[i];
+ double b = w[i] * t[i] - u[i] * p[i];
+
+ if (b != 0) {
+ f = a / b;
+ break;
+ }
+ }
+
+ /* Solve for the resulting transform vector */
+ for (i = 0; i < 2; i++) {
+ if (u[i])
+ d.v[1 - i] = (t[i] * f - q[i]) / u[i];
+ else if (w[1])
+ d.v[1 - i] = (p[i] * f - v[i]) / w[i];
+ else
+ d.v[1 - i] = 0;
+ }
+ *new_pan_x = old_pan_x - floor(d.v[0] + 0.5);
+ *new_pan_y = old_pan_y - floor(d.v[1] + 0.5);
+ }
+ else {
+ *new_pan_x = screen_x - crtc_x;
+ *new_pan_y = screen_y - crtc_y;
}
}
static void
-xf86RandR13Pan (xf86CrtcPtr crtc, int x, int y)
+xf86RandR13Pan(xf86CrtcPtr crtc, int x, int y)
{
int newX, newY;
int width, height;
Bool panned = FALSE;
if (crtc->version < 2)
- return;
+ return;
- if (! crtc->enabled ||
- (crtc->panningTotalArea.x2 <= crtc->panningTotalArea.x1 &&
- crtc->panningTotalArea.y2 <= crtc->panningTotalArea.y1))
- return;
+ if (!crtc->enabled ||
+ (crtc->panningTotalArea.x2 <= crtc->panningTotalArea.x1 &&
+ crtc->panningTotalArea.y2 <= crtc->panningTotalArea.y1))
+ return;
- newX = crtc->x;
- newY = crtc->y;
- width = crtc->mode.HDisplay;
+ newX = crtc->x;
+ newY = crtc->y;
+ width = crtc->mode.HDisplay;
height = crtc->mode.VDisplay;
if ((crtc->panningTrackingArea.x2 <= crtc->panningTrackingArea.x1 ||
- (x >= crtc->panningTrackingArea.x1 && x < crtc->panningTrackingArea.x2)) &&
- (crtc->panningTrackingArea.y2 <= crtc->panningTrackingArea.y1 ||
- (y >= crtc->panningTrackingArea.y1 && y < crtc->panningTrackingArea.y2)))
- {
- struct pict_f_vector c;
-
- /*
- * Pre-clip the mouse position to the panning area so that we don't
- * push the crtc outside. This doesn't deal with changes to the
- * panning values, only mouse position changes.
- */
- if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1)
- {
- if (x < crtc->panningTotalArea.x1)
- x = crtc->panningTotalArea.x1;
- if (x >= crtc->panningTotalArea.x2)
- x = crtc->panningTotalArea.x2 - 1;
- }
- if (crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1)
- {
- if (y < crtc->panningTotalArea.y1)
- y = crtc->panningTotalArea.y1;
- if (y >= crtc->panningTotalArea.y2)
- y = crtc->panningTotalArea.y2 - 1;
- }
-
- c.v[0] = x;
- c.v[1] = y;
- c.v[2] = 1.0;
- if (crtc->transform_in_use) {
- pixman_f_transform_point(&crtc->f_framebuffer_to_crtc, &c);
- } else {
- c.v[0] -= crtc->x;
- c.v[1] -= crtc->y;
- }
-
- if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1) {
- if (c.v[0] < crtc->panningBorder[0]) {
- c.v[0] = crtc->panningBorder[0];
- panned = TRUE;
- }
- if (c.v[0] >= width - crtc->panningBorder[2]) {
- c.v[0] = width - crtc->panningBorder[2] - 1;
- panned = TRUE;
- }
- }
- if (crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1) {
- if (c.v[1] < crtc->panningBorder[1]) {
- c.v[1] = crtc->panningBorder[1];
- panned = TRUE;
- }
- if (c.v[1] >= height - crtc->panningBorder[3]) {
- c.v[1] = height - crtc->panningBorder[3] - 1;
- panned = TRUE;
- }
- }
- if (panned)
- xf86ComputeCrtcPan (crtc->transform_in_use,
- &crtc->f_framebuffer_to_crtc,
- x, y, c.v[0], c.v[1],
- newX, newY, &newX, &newY);
+ (x >= crtc->panningTrackingArea.x1 &&
+ x < crtc->panningTrackingArea.x2)) &&
+ (crtc->panningTrackingArea.y2 <= crtc->panningTrackingArea.y1 ||
+ (y >= crtc->panningTrackingArea.y1 &&
+ y < crtc->panningTrackingArea.y2))) {
+ struct pict_f_vector c;
+
+ /*
+ * Pre-clip the mouse position to the panning area so that we don't
+ * push the crtc outside. This doesn't deal with changes to the
+ * panning values, only mouse position changes.
+ */
+ if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1) {
+ if (x < crtc->panningTotalArea.x1)
+ x = crtc->panningTotalArea.x1;
+ if (x >= crtc->panningTotalArea.x2)
+ x = crtc->panningTotalArea.x2 - 1;
+ }
+ if (crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1) {
+ if (y < crtc->panningTotalArea.y1)
+ y = crtc->panningTotalArea.y1;
+ if (y >= crtc->panningTotalArea.y2)
+ y = crtc->panningTotalArea.y2 - 1;
+ }
+
+ c.v[0] = x;
+ c.v[1] = y;
+ c.v[2] = 1.0;
+ if (crtc->transform_in_use) {
+ pixman_f_transform_point(&crtc->f_framebuffer_to_crtc, &c);
+ }
+ else {
+ c.v[0] -= crtc->x;
+ c.v[1] -= crtc->y;
+ }
+
+ if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1) {
+ if (c.v[0] < crtc->panningBorder[0]) {
+ c.v[0] = crtc->panningBorder[0];
+ panned = TRUE;
+ }
+ if (c.v[0] >= width - crtc->panningBorder[2]) {
+ c.v[0] = width - crtc->panningBorder[2] - 1;
+ panned = TRUE;
+ }
+ }
+ if (crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1) {
+ if (c.v[1] < crtc->panningBorder[1]) {
+ c.v[1] = crtc->panningBorder[1];
+ panned = TRUE;
+ }
+ if (c.v[1] >= height - crtc->panningBorder[3]) {
+ c.v[1] = height - crtc->panningBorder[3] - 1;
+ panned = TRUE;
+ }
+ }
+ if (panned)
+ xf86ComputeCrtcPan(crtc->transform_in_use,
+ &crtc->f_framebuffer_to_crtc,
+ x, y, c.v[0], c.v[1], newX, newY, &newX, &newY);
}
/*
@@ -413,131 +424,119 @@ xf86RandR13Pan (xf86CrtcPtr crtc, int x, int y)
* XXX This computation only works when we do not have a transform
* in use.
*/
- if (!crtc->transform_in_use)
- {
- /* Validate against [xy]1 after [xy]2, to be sure that results are > 0 for [xy]1 > 0 */
- if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1) {
- if (newX > crtc->panningTotalArea.x2 - width)
- newX = crtc->panningTotalArea.x2 - width;
- if (newX < crtc->panningTotalArea.x1)
- newX = crtc->panningTotalArea.x1;
- }
- if (crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1) {
- if (newY > crtc->panningTotalArea.y2 - height)
- newY = crtc->panningTotalArea.y2 - height;
- if (newY < crtc->panningTotalArea.y1)
- newY = crtc->panningTotalArea.y1;
- }
+ if (!crtc->transform_in_use) {
+ /* Validate against [xy]1 after [xy]2, to be sure that results are > 0 for [xy]1 > 0 */
+ if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1) {
+ if (newX > crtc->panningTotalArea.x2 - width)
+ newX = crtc->panningTotalArea.x2 - width;
+ if (newX < crtc->panningTotalArea.x1)
+ newX = crtc->panningTotalArea.x1;
+ }
+ if (crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1) {
+ if (newY > crtc->panningTotalArea.y2 - height)
+ newY = crtc->panningTotalArea.y2 - height;
+ if (newY < crtc->panningTotalArea.y1)
+ newY = crtc->panningTotalArea.y1;
+ }
}
if (newX != crtc->x || newY != crtc->y)
- xf86CrtcSetOrigin (crtc, newX, newY);
+ xf86CrtcSetOrigin(crtc, newX, newY);
}
static Bool
-xf86RandR12GetInfo (ScreenPtr pScreen, Rotation *rotations)
+xf86RandR12GetInfo(ScreenPtr pScreen, Rotation * rotations)
{
- RRScreenSizePtr pSize;
- ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- DisplayModePtr mode;
- int refresh0 = 60;
- int maxX = 0, maxY = 0;
+ RRScreenSizePtr pSize;
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ DisplayModePtr mode;
+ int refresh0 = 60;
+ int maxX = 0, maxY = 0;
*rotations = randrp->supported_rotations;
- if (randrp->virtualX == -1 || randrp->virtualY == -1)
- {
- randrp->virtualX = scrp->virtualX;
- randrp->virtualY = scrp->virtualY;
+ if (randrp->virtualX == -1 || randrp->virtualY == -1) {
+ randrp->virtualX = scrp->virtualX;
+ randrp->virtualY = scrp->virtualY;
}
/* Re-probe the outputs for new monitors or modes */
- if (scrp->vtSema)
- {
- xf86ProbeOutputModes (scrp, 0, 0);
- xf86SetScrnInfoModes (scrp);
+ if (scrp->vtSema) {
+ xf86ProbeOutputModes(scrp, 0, 0);
+ xf86SetScrnInfoModes(scrp);
}
- for (mode = scrp->modes; ; mode = mode->next)
- {
- int refresh = xf86RandR12ModeRefresh (mode);
- if (randrp->maxX == 0 || randrp->maxY == 0)
- {
- if (maxX < mode->HDisplay)
- maxX = mode->HDisplay;
- if (maxY < mode->VDisplay)
- maxY = mode->VDisplay;
- }
- if (mode == scrp->modes)
- refresh0 = refresh;
- pSize = RRRegisterSize (pScreen,
- mode->HDisplay, mode->VDisplay,
- randrp->mmWidth, randrp->mmHeight);
- if (!pSize)
- return FALSE;
- RRRegisterRate (pScreen, pSize, refresh);
-
- if (xf86ModesEqual(mode, scrp->currentMode))
- {
- RRSetCurrentConfig (pScreen, randrp->rotation, refresh, pSize);
- }
- if (mode->next == scrp->modes)
- break;
+ for (mode = scrp->modes;; mode = mode->next) {
+ int refresh = xf86RandR12ModeRefresh(mode);
+
+ if (randrp->maxX == 0 || randrp->maxY == 0) {
+ if (maxX < mode->HDisplay)
+ maxX = mode->HDisplay;
+ if (maxY < mode->VDisplay)
+ maxY = mode->VDisplay;
+ }
+ if (mode == scrp->modes)
+ refresh0 = refresh;
+ pSize = RRRegisterSize(pScreen,
+ mode->HDisplay, mode->VDisplay,
+ randrp->mmWidth, randrp->mmHeight);
+ if (!pSize)
+ return FALSE;
+ RRRegisterRate(pScreen, pSize, refresh);
+
+ if (xf86ModesEqual(mode, scrp->currentMode)) {
+ RRSetCurrentConfig(pScreen, randrp->rotation, refresh, pSize);
+ }
+ if (mode->next == scrp->modes)
+ break;
}
- if (randrp->maxX == 0 || randrp->maxY == 0)
- {
- randrp->maxX = maxX;
- randrp->maxY = maxY;
+ if (randrp->maxX == 0 || randrp->maxY == 0) {
+ randrp->maxX = maxX;
+ randrp->maxY = maxY;
}
return TRUE;
}
static Bool
-xf86RandR12SetMode (ScreenPtr pScreen,
- DisplayModePtr mode,
- Bool useVirtual,
- int mmWidth,
- int mmHeight)
+xf86RandR12SetMode(ScreenPtr pScreen,
+ DisplayModePtr mode,
+ Bool useVirtual, int mmWidth, int mmHeight)
{
- ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- int oldWidth = pScreen->width;
- int oldHeight = pScreen->height;
- int oldmmWidth = pScreen->mmWidth;
- int oldmmHeight = pScreen->mmHeight;
- WindowPtr pRoot = pScreen->root;
- DisplayModePtr currentMode = NULL;
- Bool ret = TRUE;
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ int oldWidth = pScreen->width;
+ int oldHeight = pScreen->height;
+ int oldmmWidth = pScreen->mmWidth;
+ int oldmmHeight = pScreen->mmHeight;
+ WindowPtr pRoot = pScreen->root;
+ DisplayModePtr currentMode = NULL;
+ Bool ret = TRUE;
if (pRoot)
- (*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE);
- if (useVirtual)
- {
- scrp->virtualX = randrp->virtualX;
- scrp->virtualY = randrp->virtualY;
+ (*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE);
+ if (useVirtual) {
+ scrp->virtualX = randrp->virtualX;
+ scrp->virtualY = randrp->virtualY;
}
- else
- {
- scrp->virtualX = mode->HDisplay;
- scrp->virtualY = mode->VDisplay;
+ else {
+ scrp->virtualX = mode->HDisplay;
+ scrp->virtualY = mode->VDisplay;
}
- if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270))
- {
- /* If the screen is rotated 90 or 270 degrees, swap the sizes. */
- pScreen->width = scrp->virtualY;
- pScreen->height = scrp->virtualX;
- pScreen->mmWidth = mmHeight;
- pScreen->mmHeight = mmWidth;
+ if (randrp->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
+ /* If the screen is rotated 90 or 270 degrees, swap the sizes. */
+ pScreen->width = scrp->virtualY;
+ pScreen->height = scrp->virtualX;
+ pScreen->mmWidth = mmHeight;
+ pScreen->mmHeight = mmWidth;
}
- else
- {
- pScreen->width = scrp->virtualX;
- pScreen->height = scrp->virtualY;
- pScreen->mmWidth = mmWidth;
- pScreen->mmHeight = mmHeight;
+ else {
+ pScreen->width = scrp->virtualX;
+ pScreen->height = scrp->virtualY;
+ pScreen->mmWidth = mmWidth;
+ pScreen->mmHeight = mmHeight;
}
if (scrp->currentMode == mode) {
/* Save current mode */
@@ -549,13 +548,12 @@ xf86RandR12SetMode (ScreenPtr pScreen,
* We know that if the driver failed to SwitchMode to the rotated
* version, then it should revert back to it's prior mode.
*/
- if (!xf86SwitchMode (pScreen, mode))
- {
+ if (!xf86SwitchMode(pScreen, mode)) {
ret = FALSE;
- scrp->virtualX = pScreen->width = oldWidth;
- scrp->virtualY = pScreen->height = oldHeight;
- pScreen->mmWidth = oldmmWidth;
- pScreen->mmHeight = oldmmHeight;
+ scrp->virtualX = pScreen->width = oldWidth;
+ scrp->virtualY = pScreen->height = oldHeight;
+ pScreen->mmWidth = oldmmWidth;
+ pScreen->mmHeight = oldmmHeight;
scrp->currentMode = currentMode;
}
@@ -567,182 +565,169 @@ xf86RandR12SetMode (ScreenPtr pScreen,
/*
* Make sure the whole screen is visible
*/
- xf86SetViewport (pScreen, pScreen->width, pScreen->height);
- xf86SetViewport (pScreen, 0, 0);
+ xf86SetViewport(pScreen, pScreen->width, pScreen->height);
+ xf86SetViewport(pScreen, 0, 0);
if (pRoot)
- (*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE);
+ (*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE);
return ret;
}
Bool
-xf86RandR12SetConfig (ScreenPtr pScreen,
- Rotation rotation,
- int rate,
- RRScreenSizePtr pSize)
+xf86RandR12SetConfig(ScreenPtr pScreen,
+ Rotation rotation, int rate, RRScreenSizePtr pSize)
{
- ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- DisplayModePtr mode;
- int pos[MAXDEVICES][2];
- Bool useVirtual = FALSE;
- int maxX = 0, maxY = 0;
- Rotation oldRotation = randrp->rotation;
- DeviceIntPtr dev;
- Bool view_adjusted = FALSE;
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ DisplayModePtr mode;
+ int pos[MAXDEVICES][2];
+ Bool useVirtual = FALSE;
+ int maxX = 0, maxY = 0;
+ Rotation oldRotation = randrp->rotation;
+ DeviceIntPtr dev;
+ Bool view_adjusted = FALSE;
randrp->rotation = rotation;
- if (randrp->virtualX == -1 || randrp->virtualY == -1)
- {
- randrp->virtualX = scrp->virtualX;
- randrp->virtualY = scrp->virtualY;
+ if (randrp->virtualX == -1 || randrp->virtualY == -1) {
+ randrp->virtualX = scrp->virtualX;
+ randrp->virtualY = scrp->virtualY;
}
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (!IsMaster(dev) && !IsFloating(dev))
- continue;
+ for (dev = inputInfo.devices; dev; dev = dev->next) {
+ if (!IsMaster(dev) && !IsFloating(dev))
+ continue;
- miPointerGetPosition(dev, &pos[dev->id][0], &pos[dev->id][1]);
+ miPointerGetPosition(dev, &pos[dev->id][0], &pos[dev->id][1]);
}
- for (mode = scrp->modes; ; mode = mode->next)
- {
- if (randrp->maxX == 0 || randrp->maxY == 0)
- {
- if (maxX < mode->HDisplay)
- maxX = mode->HDisplay;
- if (maxY < mode->VDisplay)
- maxY = mode->VDisplay;
- }
- if (mode->HDisplay == pSize->width &&
- mode->VDisplay == pSize->height &&
- (rate == 0 || xf86RandR12ModeRefresh (mode) == rate))
- break;
- if (mode->next == scrp->modes)
- {
- if (pSize->width == randrp->virtualX &&
- pSize->height == randrp->virtualY)
- {
- mode = scrp->modes;
- useVirtual = TRUE;
- break;
- }
- if (randrp->maxX == 0 || randrp->maxY == 0)
- {
- randrp->maxX = maxX;
- randrp->maxY = maxY;
- }
- return FALSE;
- }
+ for (mode = scrp->modes;; mode = mode->next) {
+ if (randrp->maxX == 0 || randrp->maxY == 0) {
+ if (maxX < mode->HDisplay)
+ maxX = mode->HDisplay;
+ if (maxY < mode->VDisplay)
+ maxY = mode->VDisplay;
+ }
+ if (mode->HDisplay == pSize->width &&
+ mode->VDisplay == pSize->height &&
+ (rate == 0 || xf86RandR12ModeRefresh(mode) == rate))
+ break;
+ if (mode->next == scrp->modes) {
+ if (pSize->width == randrp->virtualX &&
+ pSize->height == randrp->virtualY) {
+ mode = scrp->modes;
+ useVirtual = TRUE;
+ break;
+ }
+ if (randrp->maxX == 0 || randrp->maxY == 0) {
+ randrp->maxX = maxX;
+ randrp->maxY = maxY;
+ }
+ return FALSE;
+ }
}
- if (randrp->maxX == 0 || randrp->maxY == 0)
- {
- randrp->maxX = maxX;
- randrp->maxY = maxY;
+ if (randrp->maxX == 0 || randrp->maxY == 0) {
+ randrp->maxX = maxX;
+ randrp->maxY = maxY;
}
- if (!xf86RandR12SetMode (pScreen, mode, useVirtual, pSize->mmWidth,
- pSize->mmHeight)) {
+ if (!xf86RandR12SetMode(pScreen, mode, useVirtual, pSize->mmWidth,
+ pSize->mmHeight)) {
randrp->rotation = oldRotation;
- return FALSE;
+ return FALSE;
}
/*
* Move the cursor back where it belongs; SwitchMode repositions it
* FIXME: duplicated code, see modes/xf86RandR12.c
*/
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (!IsMaster(dev) && !IsFloating(dev))
- continue;
-
- if (pScreen == miPointerGetScreen(dev)) {
- int px = pos[dev->id][0];
- int py = pos[dev->id][1];
-
- px = (px >= pScreen->width ? (pScreen->width - 1) : px);
- py = (py >= pScreen->height ? (pScreen->height - 1) : py);
-
- /* Setting the viewpoint makes only sense on one device */
- if (!view_adjusted && IsMaster(dev)) {
- xf86SetViewport(pScreen, px, py);
- view_adjusted = TRUE;
- }
-
- (*pScreen->SetCursorPosition) (dev, pScreen, px, py, FALSE);
- }
+ for (dev = inputInfo.devices; dev; dev = dev->next) {
+ if (!IsMaster(dev) && !IsFloating(dev))
+ continue;
+
+ if (pScreen == miPointerGetScreen(dev)) {
+ int px = pos[dev->id][0];
+ int py = pos[dev->id][1];
+
+ px = (px >= pScreen->width ? (pScreen->width - 1) : px);
+ py = (py >= pScreen->height ? (pScreen->height - 1) : py);
+
+ /* Setting the viewpoint makes only sense on one device */
+ if (!view_adjusted && IsMaster(dev)) {
+ xf86SetViewport(pScreen, px, py);
+ view_adjusted = TRUE;
+ }
+
+ (*pScreen->SetCursorPosition) (dev, pScreen, px, py, FALSE);
+ }
}
return TRUE;
}
static Bool
-xf86RandR12ScreenSetSize (ScreenPtr pScreen,
- CARD16 width,
- CARD16 height,
- CARD32 mmWidth,
- CARD32 mmHeight)
+xf86RandR12ScreenSetSize(ScreenPtr pScreen,
+ CARD16 width,
+ CARD16 height, CARD32 mmWidth, CARD32 mmHeight)
{
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- WindowPtr pRoot = pScreen->root;
- PixmapPtr pScrnPix;
- Bool ret = FALSE;
- int c;
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ WindowPtr pRoot = pScreen->root;
+ PixmapPtr pScrnPix;
+ Bool ret = FALSE;
+ int c;
if (xf86RandR12Key) {
- if (randrp->virtualX == -1 || randrp->virtualY == -1)
- {
- randrp->virtualX = pScrn->virtualX;
- randrp->virtualY = pScrn->virtualY;
+ if (randrp->virtualX == -1 || randrp->virtualY == -1) {
+ randrp->virtualX = pScrn->virtualX;
+ randrp->virtualY = pScrn->virtualY;
}
}
if (pRoot && pScrn->vtSema)
- (*pScrn->EnableDisableFBAccess) (pScreen->myNum, FALSE);
+ (*pScrn->EnableDisableFBAccess) (pScreen->myNum, FALSE);
/* Let the driver update virtualX and virtualY */
- if (!(*config->funcs->resize)(pScrn, width, height))
- goto finish;
+ if (!(*config->funcs->resize) (pScrn, width, height))
+ goto finish;
ret = TRUE;
/* Update panning information */
for (c = 0; c < config->num_crtc; c++) {
- xf86CrtcPtr crtc = config->crtc[c];
- if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1 ||
- crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1) {
- if (crtc->panningTotalArea.x2 > crtc->panningTrackingArea.x1)
- crtc->panningTotalArea.x2 += width - pScreen->width;
- if (crtc->panningTotalArea.y2 > crtc->panningTrackingArea.y1)
- crtc->panningTotalArea.y2 += height - pScreen->height;
- if (crtc->panningTrackingArea.x2 > crtc->panningTrackingArea.x1)
- crtc->panningTrackingArea.x2 += width - pScreen->width;
- if (crtc->panningTrackingArea.y2 > crtc->panningTrackingArea.y1)
- crtc->panningTrackingArea.y2 += height - pScreen->height;
- xf86RandR13VerifyPanningArea (crtc, width, height);
- xf86RandR13Pan (crtc, randrp->pointerX, randrp->pointerY);
- }
+ xf86CrtcPtr crtc = config->crtc[c];
+
+ if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1 ||
+ crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1) {
+ if (crtc->panningTotalArea.x2 > crtc->panningTrackingArea.x1)
+ crtc->panningTotalArea.x2 += width - pScreen->width;
+ if (crtc->panningTotalArea.y2 > crtc->panningTrackingArea.y1)
+ crtc->panningTotalArea.y2 += height - pScreen->height;
+ if (crtc->panningTrackingArea.x2 > crtc->panningTrackingArea.x1)
+ crtc->panningTrackingArea.x2 += width - pScreen->width;
+ if (crtc->panningTrackingArea.y2 > crtc->panningTrackingArea.y1)
+ crtc->panningTrackingArea.y2 += height - pScreen->height;
+ xf86RandR13VerifyPanningArea(crtc, width, height);
+ xf86RandR13Pan(crtc, randrp->pointerX, randrp->pointerY);
+ }
}
- pScrnPix = (*pScreen->GetScreenPixmap)(pScreen);
+ pScrnPix = (*pScreen->GetScreenPixmap) (pScreen);
pScreen->width = pScrnPix->drawable.width = width;
pScreen->height = pScrnPix->drawable.height = height;
randrp->mmWidth = pScreen->mmWidth = mmWidth;
randrp->mmHeight = pScreen->mmHeight = mmHeight;
- xf86SetViewport (pScreen, pScreen->width-1, pScreen->height-1);
- xf86SetViewport (pScreen, 0, 0);
+ xf86SetViewport(pScreen, pScreen->width - 1, pScreen->height - 1);
+ xf86SetViewport(pScreen, 0, 0);
-finish:
+ finish:
update_desktop_dimensions();
if (pRoot && pScrn->vtSema)
- (*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE);
+ (*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE);
#if RANDR_12_INTERFACE
if (xf86RandR12Key && pScreen->root && ret)
- RRScreenSizeNotify (pScreen);
+ RRScreenSizeNotify(pScreen);
#endif
return ret;
}
@@ -750,24 +735,25 @@ finish:
Rotation
xf86RandR12GetRotation(ScreenPtr pScreen)
{
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
return randrp->rotation;
}
Bool
-xf86RandR12CreateScreenResources (ScreenPtr pScreen)
+xf86RandR12CreateScreenResources(ScreenPtr pScreen)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr config;
- XF86RandRInfoPtr randrp;
- int c;
- int width, height;
- int mmWidth, mmHeight;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr config;
+ XF86RandRInfoPtr randrp;
+ int c;
+ int width, height;
+ int mmWidth, mmHeight;
+
#ifdef PANORAMIX
/* XXX disable RandR when using Xinerama */
if (!noPanoramiXExtension)
- return TRUE;
+ return TRUE;
#endif
config = XF86_CRTC_CONFIG_PTR(pScrn);
@@ -775,103 +761,91 @@ xf86RandR12CreateScreenResources (ScreenPtr pScreen)
/*
* Compute size of screen
*/
- width = 0; height = 0;
- for (c = 0; c < config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = config->crtc[c];
- int crtc_width = crtc->x + xf86ModeWidth (&crtc->mode, crtc->rotation);
- int crtc_height = crtc->y + xf86ModeHeight (&crtc->mode, crtc->rotation);
-
- if (crtc->enabled) {
- if (crtc_width > width)
- width = crtc_width;
- if (crtc_height > height)
- height = crtc_height;
- if (crtc->panningTotalArea.x2 > width)
- width = crtc->panningTotalArea.x2;
- if (crtc->panningTotalArea.y2 > height)
- height = crtc->panningTotalArea.y2;
- }
+ width = 0;
+ height = 0;
+ for (c = 0; c < config->num_crtc; c++) {
+ xf86CrtcPtr crtc = config->crtc[c];
+ int crtc_width = crtc->x + xf86ModeWidth(&crtc->mode, crtc->rotation);
+ int crtc_height = crtc->y + xf86ModeHeight(&crtc->mode, crtc->rotation);
+
+ if (crtc->enabled) {
+ if (crtc_width > width)
+ width = crtc_width;
+ if (crtc_height > height)
+ height = crtc_height;
+ if (crtc->panningTotalArea.x2 > width)
+ width = crtc->panningTotalArea.x2;
+ if (crtc->panningTotalArea.y2 > height)
+ height = crtc->panningTotalArea.y2;
+ }
}
-
- if (width && height)
- {
- /*
- * Compute physical size of screen
- */
- if (monitorResolution)
- {
- mmWidth = width * 25.4 / monitorResolution;
- mmHeight = height * 25.4 / monitorResolution;
- }
- else
- {
- xf86OutputPtr output = xf86CompatOutput(pScrn);
-
- if (output &&
- output->conf_monitor &&
- (output->conf_monitor->mon_width > 0 &&
- output->conf_monitor->mon_height > 0))
- {
- /*
- * Prefer user configured DisplaySize
- */
- mmWidth = output->conf_monitor->mon_width;
- mmHeight = output->conf_monitor->mon_height;
- }
- else
- {
- /*
- * Otherwise, just set the screen to DEFAULT_DPI
- */
- mmWidth = width * 25.4 / DEFAULT_DPI;
- mmHeight = height * 25.4 / DEFAULT_DPI;
- }
- }
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Setting screen physical size to %d x %d\n",
- mmWidth, mmHeight);
- /*
- * This is the initial setting of the screen size.
- * We have to pre-set it here, otherwise panning would be adapted
- * to the new screen size.
- */
- pScreen->width = width;
- pScreen->height = height;
- xf86RandR12ScreenSetSize (pScreen,
- width,
- height,
- mmWidth,
- mmHeight);
+
+ if (width && height) {
+ /*
+ * Compute physical size of screen
+ */
+ if (monitorResolution) {
+ mmWidth = width * 25.4 / monitorResolution;
+ mmHeight = height * 25.4 / monitorResolution;
+ }
+ else {
+ xf86OutputPtr output = xf86CompatOutput(pScrn);
+
+ if (output &&
+ output->conf_monitor &&
+ (output->conf_monitor->mon_width > 0 &&
+ output->conf_monitor->mon_height > 0)) {
+ /*
+ * Prefer user configured DisplaySize
+ */
+ mmWidth = output->conf_monitor->mon_width;
+ mmHeight = output->conf_monitor->mon_height;
+ }
+ else {
+ /*
+ * Otherwise, just set the screen to DEFAULT_DPI
+ */
+ mmWidth = width * 25.4 / DEFAULT_DPI;
+ mmHeight = height * 25.4 / DEFAULT_DPI;
+ }
+ }
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Setting screen physical size to %d x %d\n",
+ mmWidth, mmHeight);
+ /*
+ * This is the initial setting of the screen size.
+ * We have to pre-set it here, otherwise panning would be adapted
+ * to the new screen size.
+ */
+ pScreen->width = width;
+ pScreen->height = height;
+ xf86RandR12ScreenSetSize(pScreen, width, height, mmWidth, mmHeight);
}
if (xf86RandR12Key == NULL)
- return TRUE;
+ return TRUE;
- if (randrp->virtualX == -1 || randrp->virtualY == -1)
- {
- randrp->virtualX = pScrn->virtualX;
- randrp->virtualY = pScrn->virtualY;
+ if (randrp->virtualX == -1 || randrp->virtualY == -1) {
+ randrp->virtualX = pScrn->virtualX;
+ randrp->virtualY = pScrn->virtualY;
}
- xf86CrtcSetScreenSubpixelOrder (pScreen);
+ xf86CrtcSetScreenSubpixelOrder(pScreen);
#if RANDR_12_INTERFACE
- if (xf86RandR12CreateScreenResources12 (pScreen))
- return TRUE;
+ if (xf86RandR12CreateScreenResources12(pScreen))
+ return TRUE;
#endif
return TRUE;
}
-
Bool
-xf86RandR12Init (ScreenPtr pScreen)
+xf86RandR12Init(ScreenPtr pScreen)
{
- rrScrPrivPtr rp;
- XF86RandRInfoPtr randrp;
+ rrScrPrivPtr rp;
+ XF86RandRInfoPtr randrp;
#ifdef PANORAMIX
/* XXX disable RandR when using Xinerama */
- if (!noPanoramiXExtension)
- {
+ if (!noPanoramiXExtension) {
if (xf86NumScreens == 1)
noPanoramiXExtension = TRUE;
else
@@ -880,20 +854,19 @@ xf86RandR12Init (ScreenPtr pScreen)
#endif
if (xf86RandR12Generation != serverGeneration)
- xf86RandR12Generation = serverGeneration;
+ xf86RandR12Generation = serverGeneration;
xf86RandR12Key = &xf86RandR12KeyRec;
if (!dixRegisterPrivateKey(&xf86RandR12KeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
+ return FALSE;
- randrp = malloc(sizeof (XF86RandRInfoRec));
+ randrp = malloc(sizeof(XF86RandRInfoRec));
if (!randrp)
- return FALSE;
+ return FALSE;
- if (!RRScreenInit(pScreen))
- {
- free(randrp);
- return FALSE;
+ if (!RRScreenInit(pScreen)) {
+ free(randrp);
+ return FALSE;
}
rp = rrGetScrPriv(pScreen);
rp->rrGetInfo = xf86RandR12GetInfo;
@@ -904,7 +877,7 @@ xf86RandR12Init (ScreenPtr pScreen)
randrp->mmWidth = pScreen->mmWidth;
randrp->mmHeight = pScreen->mmHeight;
- randrp->rotation = RR_Rotate_0; /* initial rotated mode */
+ randrp->rotation = RR_Rotate_0; /* initial rotated mode */
randrp->supported_rotations = RR_Rotate_0;
@@ -913,19 +886,19 @@ xf86RandR12Init (ScreenPtr pScreen)
dixSetPrivate(&pScreen->devPrivates, xf86RandR12Key, randrp);
#if RANDR_12_INTERFACE
- if (!xf86RandR12Init12 (pScreen))
- return FALSE;
+ if (!xf86RandR12Init12(pScreen))
+ return FALSE;
#endif
return TRUE;
}
void
-xf86RandR12CloseScreen (ScreenPtr pScreen)
+xf86RandR12CloseScreen(ScreenPtr pScreen)
{
- XF86RandRInfoPtr randrp;
+ XF86RandRInfoPtr randrp;
if (xf86RandR12Key == NULL)
- return;
+ return;
randrp = XF86RANDRINFO(pScreen);
#if RANDR_12_INTERFACE
@@ -936,48 +909,50 @@ xf86RandR12CloseScreen (ScreenPtr pScreen)
}
void
-xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotations)
+xf86RandR12SetRotations(ScreenPtr pScreen, Rotation rotations)
{
- XF86RandRInfoPtr randrp;
+ XF86RandRInfoPtr randrp;
+
#if RANDR_12_INTERFACE
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- int c;
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ int c;
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
#endif
if (xf86RandR12Key == NULL)
- return;
+ return;
randrp = XF86RANDRINFO(pScreen);
#if RANDR_12_INTERFACE
for (c = 0; c < config->num_crtc; c++) {
- xf86CrtcPtr crtc = config->crtc[c];
+ xf86CrtcPtr crtc = config->crtc[c];
- RRCrtcSetRotations (crtc->randr_crtc, rotations);
+ RRCrtcSetRotations(crtc->randr_crtc, rotations);
}
#endif
randrp->supported_rotations = rotations;
}
void
-xf86RandR12SetTransformSupport (ScreenPtr pScreen, Bool transforms)
+xf86RandR12SetTransformSupport(ScreenPtr pScreen, Bool transforms)
{
- XF86RandRInfoPtr randrp;
+ XF86RandRInfoPtr randrp;
+
#if RANDR_13_INTERFACE
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- int c;
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ int c;
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
#endif
if (xf86RandR12Key == NULL)
- return;
+ return;
randrp = XF86RANDRINFO(pScreen);
#if RANDR_13_INTERFACE
for (c = 0; c < config->num_crtc; c++) {
- xf86CrtcPtr crtc = config->crtc[c];
+ xf86CrtcPtr crtc = config->crtc[c];
- RRCrtcSetTransformSupport (crtc->randr_crtc, transforms);
+ RRCrtcSetTransformSupport(crtc->randr_crtc, transforms);
}
#endif
}
@@ -988,15 +963,15 @@ xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y)
ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
if (xf86RandR12Generation != serverGeneration ||
- XF86RANDRINFO(pScreen)->virtualX == -1)
- {
- *x = pScrn->virtualX;
- *y = pScrn->virtualY;
- } else {
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
-
- *x = randrp->virtualX;
- *y = randrp->virtualY;
+ XF86RANDRINFO(pScreen)->virtualX == -1) {
+ *x = pScrn->virtualX;
+ *y = pScrn->virtualY;
+ }
+ else {
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+
+ *x = randrp->virtualX;
+ *y = randrp->virtualY;
}
}
@@ -1018,95 +993,106 @@ xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y)
RR_ClockDivideBy2)
static Bool
-xf86RandRModeMatches (RRModePtr randr_mode,
- DisplayModePtr mode)
+xf86RandRModeMatches(RRModePtr randr_mode, DisplayModePtr mode)
{
#if 0
- if (match_name)
- {
- /* check for same name */
- int len = strlen (mode->name);
- if (randr_mode->mode.nameLength != len) return FALSE;
- if (memcmp (randr_mode->name, mode->name, len) != 0) return FALSE;
+ if (match_name) {
+ /* check for same name */
+ int len = strlen(mode->name);
+
+ if (randr_mode->mode.nameLength != len)
+ return FALSE;
+ if (memcmp(randr_mode->name, mode->name, len) != 0)
+ return FALSE;
}
#endif
-
+
/* check for same timings */
- if (randr_mode->mode.dotClock / 1000 != mode->Clock) return FALSE;
- if (randr_mode->mode.width != mode->HDisplay) return FALSE;
- if (randr_mode->mode.hSyncStart != mode->HSyncStart) return FALSE;
- if (randr_mode->mode.hSyncEnd != mode->HSyncEnd) return FALSE;
- if (randr_mode->mode.hTotal != mode->HTotal) return FALSE;
- if (randr_mode->mode.hSkew != mode->HSkew) return FALSE;
- if (randr_mode->mode.height != mode->VDisplay) return FALSE;
- if (randr_mode->mode.vSyncStart != mode->VSyncStart) return FALSE;
- if (randr_mode->mode.vSyncEnd != mode->VSyncEnd) return FALSE;
- if (randr_mode->mode.vTotal != mode->VTotal) return FALSE;
-
+ if (randr_mode->mode.dotClock / 1000 != mode->Clock)
+ return FALSE;
+ if (randr_mode->mode.width != mode->HDisplay)
+ return FALSE;
+ if (randr_mode->mode.hSyncStart != mode->HSyncStart)
+ return FALSE;
+ if (randr_mode->mode.hSyncEnd != mode->HSyncEnd)
+ return FALSE;
+ if (randr_mode->mode.hTotal != mode->HTotal)
+ return FALSE;
+ if (randr_mode->mode.hSkew != mode->HSkew)
+ return FALSE;
+ if (randr_mode->mode.height != mode->VDisplay)
+ return FALSE;
+ if (randr_mode->mode.vSyncStart != mode->VSyncStart)
+ return FALSE;
+ if (randr_mode->mode.vSyncEnd != mode->VSyncEnd)
+ return FALSE;
+ if (randr_mode->mode.vTotal != mode->VTotal)
+ return FALSE;
+
/* check for same flags (using only the XF86 valid flag bits) */
if ((randr_mode->mode.modeFlags & FLAG_BITS) != (mode->Flags & FLAG_BITS))
- return FALSE;
-
+ return FALSE;
+
/* everything matches */
return TRUE;
}
static Bool
-xf86RandR12CrtcNotify (RRCrtcPtr randr_crtc)
+xf86RandR12CrtcNotify(RRCrtcPtr randr_crtc)
{
- ScreenPtr pScreen = randr_crtc->pScreen;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- RRModePtr randr_mode = NULL;
- int x;
- int y;
- Rotation rotation;
- int numOutputs;
- RROutputPtr *randr_outputs;
- RROutputPtr randr_output;
- xf86CrtcPtr crtc = randr_crtc->devPrivate;
- xf86OutputPtr output;
- int i, j;
- DisplayModePtr mode = &crtc->mode;
- Bool ret;
-
- randr_outputs = malloc(config->num_output * sizeof (RROutputPtr));
+ ScreenPtr pScreen = randr_crtc->pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ RRModePtr randr_mode = NULL;
+ int x;
+ int y;
+ Rotation rotation;
+ int numOutputs;
+ RROutputPtr *randr_outputs;
+ RROutputPtr randr_output;
+ xf86CrtcPtr crtc = randr_crtc->devPrivate;
+ xf86OutputPtr output;
+ int i, j;
+ DisplayModePtr mode = &crtc->mode;
+ Bool ret;
+
+ randr_outputs = malloc(config->num_output * sizeof(RROutputPtr));
if (!randr_outputs)
- return FALSE;
+ return FALSE;
x = crtc->x;
y = crtc->y;
rotation = crtc->rotation;
numOutputs = 0;
randr_mode = NULL;
- for (i = 0; i < config->num_output; i++)
- {
- output = config->output[i];
- if (output->crtc == crtc)
- {
- randr_output = output->randr_output;
- randr_outputs[numOutputs++] = randr_output;
- /*
- * We make copies of modes, so pointer equality
- * isn't sufficient
- */
- for (j = 0; j < randr_output->numModes + randr_output->numUserModes; j++)
- {
- RRModePtr m = (j < randr_output->numModes ?
- randr_output->modes[j] :
- randr_output->userModes[j-randr_output->numModes]);
-
- if (xf86RandRModeMatches (m, mode))
- {
- randr_mode = m;
- break;
- }
- }
- }
+ for (i = 0; i < config->num_output; i++) {
+ output = config->output[i];
+ if (output->crtc == crtc) {
+ randr_output = output->randr_output;
+ randr_outputs[numOutputs++] = randr_output;
+ /*
+ * We make copies of modes, so pointer equality
+ * isn't sufficient
+ */
+ for (j = 0; j < randr_output->numModes + randr_output->numUserModes;
+ j++) {
+ RRModePtr m =
+ (j <
+ randr_output->numModes ? randr_output->
+ modes[j] : randr_output->userModes[j -
+ randr_output->
+ numModes]);
+
+ if (xf86RandRModeMatches(m, mode)) {
+ randr_mode = m;
+ break;
+ }
+ }
+ }
}
- ret = RRCrtcNotify (randr_crtc, randr_mode, x, y,
- rotation,
- crtc->transformPresent ? &crtc->transform : NULL,
- numOutputs, randr_outputs);
+ ret = RRCrtcNotify(randr_crtc, randr_mode, x, y,
+ rotation,
+ crtc->transformPresent ? &crtc->transform : NULL,
+ numOutputs, randr_outputs);
free(randr_outputs);
return ret;
}
@@ -1115,21 +1101,20 @@ xf86RandR12CrtcNotify (RRCrtcPtr randr_crtc)
* Convert a RandR mode to a DisplayMode
*/
static void
-xf86RandRModeConvert (ScrnInfoPtr scrn,
- RRModePtr randr_mode,
- DisplayModePtr mode)
+xf86RandRModeConvert(ScrnInfoPtr scrn,
+ RRModePtr randr_mode, DisplayModePtr mode)
{
memset(mode, 0, sizeof(DisplayModeRec));
mode->status = MODE_OK;
mode->Clock = randr_mode->mode.dotClock / 1000;
-
+
mode->HDisplay = randr_mode->mode.width;
mode->HSyncStart = randr_mode->mode.hSyncStart;
mode->HSyncEnd = randr_mode->mode.hSyncEnd;
mode->HTotal = randr_mode->mode.hTotal;
mode->HSkew = randr_mode->mode.hSkew;
-
+
mode->VDisplay = randr_mode->mode.height;
mode->VSyncStart = randr_mode->mode.vSyncStart;
mode->VSyncEnd = randr_mode->mode.vSyncEnd;
@@ -1138,137 +1123,134 @@ xf86RandRModeConvert (ScrnInfoPtr scrn,
mode->Flags = randr_mode->mode.modeFlags & FLAG_BITS;
- xf86SetModeCrtc (mode, scrn->adjustFlags);
+ xf86SetModeCrtc(mode, scrn->adjustFlags);
}
static Bool
-xf86RandR12CrtcSet (ScreenPtr pScreen,
- RRCrtcPtr randr_crtc,
- RRModePtr randr_mode,
- int x,
- int y,
- Rotation rotation,
- int num_randr_outputs,
- RROutputPtr *randr_outputs)
+xf86RandR12CrtcSet(ScreenPtr pScreen,
+ RRCrtcPtr randr_crtc,
+ RRModePtr randr_mode,
+ int x,
+ int y,
+ Rotation rotation,
+ int num_randr_outputs, RROutputPtr * randr_outputs)
{
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- xf86CrtcPtr crtc = randr_crtc->devPrivate;
- RRTransformPtr transform;
- Bool changed = FALSE;
- int o, ro;
- xf86CrtcPtr *save_crtcs;
- Bool save_enabled = crtc->enabled;
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ xf86CrtcPtr crtc = randr_crtc->devPrivate;
+ RRTransformPtr transform;
+ Bool changed = FALSE;
+ int o, ro;
+ xf86CrtcPtr *save_crtcs;
+ Bool save_enabled = crtc->enabled;
if (!crtc->scrn->vtSema)
- return FALSE;
+ return FALSE;
- save_crtcs = malloc(config->num_output * sizeof (xf86CrtcPtr));
+ save_crtcs = malloc(config->num_output * sizeof(xf86CrtcPtr));
if ((randr_mode != NULL) != crtc->enabled)
- changed = TRUE;
- else if (randr_mode && !xf86RandRModeMatches (randr_mode, &crtc->mode))
- changed = TRUE;
-
+ changed = TRUE;
+ else if (randr_mode && !xf86RandRModeMatches(randr_mode, &crtc->mode))
+ changed = TRUE;
+
if (rotation != crtc->rotation)
- changed = TRUE;
+ changed = TRUE;
- transform = RRCrtcGetTransform (randr_crtc);
+ transform = RRCrtcGetTransform(randr_crtc);
if ((transform != NULL) != crtc->transformPresent)
- changed = TRUE;
- else if (transform && memcmp (&transform->transform, &crtc->transform.transform,
- sizeof (transform->transform)) != 0)
- changed = TRUE;
+ changed = TRUE;
+ else if (transform &&
+ memcmp(&transform->transform, &crtc->transform.transform,
+ sizeof(transform->transform)) != 0)
+ changed = TRUE;
if (x != crtc->x || y != crtc->y)
- changed = TRUE;
- for (o = 0; o < config->num_output; o++)
- {
- xf86OutputPtr output = config->output[o];
- xf86CrtcPtr new_crtc;
-
- save_crtcs[o] = output->crtc;
-
- if (output->crtc == crtc)
- new_crtc = NULL;
- else
- new_crtc = output->crtc;
- for (ro = 0; ro < num_randr_outputs; ro++)
- if (output->randr_output == randr_outputs[ro])
- {
- new_crtc = crtc;
- break;
- }
- if (new_crtc != output->crtc)
- {
- changed = TRUE;
- output->crtc = new_crtc;
- }
+ changed = TRUE;
+ for (o = 0; o < config->num_output; o++) {
+ xf86OutputPtr output = config->output[o];
+ xf86CrtcPtr new_crtc;
+
+ save_crtcs[o] = output->crtc;
+
+ if (output->crtc == crtc)
+ new_crtc = NULL;
+ else
+ new_crtc = output->crtc;
+ for (ro = 0; ro < num_randr_outputs; ro++)
+ if (output->randr_output == randr_outputs[ro]) {
+ new_crtc = crtc;
+ break;
+ }
+ if (new_crtc != output->crtc) {
+ changed = TRUE;
+ output->crtc = new_crtc;
+ }
}
- for (ro = 0; ro < num_randr_outputs; ro++)
+ for (ro = 0; ro < num_randr_outputs; ro++)
if (randr_outputs[ro]->pendingProperties)
- changed = TRUE;
+ changed = TRUE;
/* XXX need device-independent mode setting code through an API */
- if (changed)
- {
- crtc->enabled = randr_mode != NULL;
-
- if (randr_mode)
- {
- DisplayModeRec mode;
- RRTransformPtr transform = RRCrtcGetTransform (randr_crtc);
-
- xf86RandRModeConvert (pScrn, randr_mode, &mode);
- if (!xf86CrtcSetModeTransform (crtc, &mode, rotation, transform, x, y))
- {
- crtc->enabled = save_enabled;
- for (o = 0; o < config->num_output; o++)
- {
- xf86OutputPtr output = config->output[o];
- output->crtc = save_crtcs[o];
- }
- free(save_crtcs);
- return FALSE;
- }
- xf86RandR13VerifyPanningArea (crtc, pScreen->width, pScreen->height);
- xf86RandR13Pan (crtc, randrp->pointerX, randrp->pointerY);
- /*
- * Save the last successful setting for EnterVT
- */
- crtc->desiredMode = mode;
- crtc->desiredRotation = rotation;
- if (transform) {
- crtc->desiredTransform = *transform;
- crtc->desiredTransformPresent = TRUE;
- } else
- crtc->desiredTransformPresent = FALSE;
-
- crtc->desiredX = x;
- crtc->desiredY = y;
- }
- xf86DisableUnusedFunctions (pScrn);
+ if (changed) {
+ crtc->enabled = randr_mode != NULL;
+
+ if (randr_mode) {
+ DisplayModeRec mode;
+ RRTransformPtr transform = RRCrtcGetTransform(randr_crtc);
+
+ xf86RandRModeConvert(pScrn, randr_mode, &mode);
+ if (!xf86CrtcSetModeTransform
+ (crtc, &mode, rotation, transform, x, y)) {
+ crtc->enabled = save_enabled;
+ for (o = 0; o < config->num_output; o++) {
+ xf86OutputPtr output = config->output[o];
+
+ output->crtc = save_crtcs[o];
+ }
+ free(save_crtcs);
+ return FALSE;
+ }
+ xf86RandR13VerifyPanningArea(crtc, pScreen->width, pScreen->height);
+ xf86RandR13Pan(crtc, randrp->pointerX, randrp->pointerY);
+ /*
+ * Save the last successful setting for EnterVT
+ */
+ crtc->desiredMode = mode;
+ crtc->desiredRotation = rotation;
+ if (transform) {
+ crtc->desiredTransform = *transform;
+ crtc->desiredTransformPresent = TRUE;
+ }
+ else
+ crtc->desiredTransformPresent = FALSE;
+
+ crtc->desiredX = x;
+ crtc->desiredY = y;
+ }
+ xf86DisableUnusedFunctions(pScrn);
}
free(save_crtcs);
- return xf86RandR12CrtcNotify (randr_crtc);
+ return xf86RandR12CrtcNotify(randr_crtc);
}
static Bool
-xf86RandR12CrtcSetGamma (ScreenPtr pScreen,
- RRCrtcPtr randr_crtc)
+xf86RandR12CrtcSetGamma(ScreenPtr pScreen, RRCrtcPtr randr_crtc)
{
- xf86CrtcPtr crtc = randr_crtc->devPrivate;
+ xf86CrtcPtr crtc = randr_crtc->devPrivate;
if (crtc->funcs->gamma_set == NULL)
- return FALSE;
+ return FALSE;
if (!crtc->scrn->vtSema)
- return TRUE;
+ return TRUE;
/* Realloc local gamma if needed. */
if (randr_crtc->gammaSize != crtc->gamma_size) {
CARD16 *tmp_ptr;
- tmp_ptr = realloc(crtc->gamma_red, 3 * crtc->gamma_size * sizeof (CARD16));
+
+ tmp_ptr =
+ realloc(crtc->gamma_red, 3 * crtc->gamma_size * sizeof(CARD16));
if (!tmp_ptr)
return FALSE;
crtc->gamma_red = tmp_ptr;
@@ -1277,23 +1259,25 @@ xf86RandR12CrtcSetGamma (ScreenPtr pScreen,
}
crtc->gamma_size = randr_crtc->gammaSize;
- memcpy (crtc->gamma_red, randr_crtc->gammaRed, crtc->gamma_size * sizeof (CARD16));
- memcpy (crtc->gamma_green, randr_crtc->gammaGreen, crtc->gamma_size * sizeof (CARD16));
- memcpy (crtc->gamma_blue, randr_crtc->gammaBlue, crtc->gamma_size * sizeof (CARD16));
+ memcpy(crtc->gamma_red, randr_crtc->gammaRed,
+ crtc->gamma_size * sizeof(CARD16));
+ memcpy(crtc->gamma_green, randr_crtc->gammaGreen,
+ crtc->gamma_size * sizeof(CARD16));
+ memcpy(crtc->gamma_blue, randr_crtc->gammaBlue,
+ crtc->gamma_size * sizeof(CARD16));
/* Only set it when the crtc is actually running.
* Otherwise it will be set when it's activated.
*/
if (crtc->active)
- crtc->funcs->gamma_set(crtc, crtc->gamma_red, crtc->gamma_green,
- crtc->gamma_blue, crtc->gamma_size);
+ crtc->funcs->gamma_set(crtc, crtc->gamma_red, crtc->gamma_green,
+ crtc->gamma_blue, crtc->gamma_size);
return TRUE;
}
static Bool
-xf86RandR12CrtcGetGamma (ScreenPtr pScreen,
- RRCrtcPtr randr_crtc)
+xf86RandR12CrtcGetGamma(ScreenPtr pScreen, RRCrtcPtr randr_crtc)
{
xf86CrtcPtr crtc = randr_crtc->devPrivate;
@@ -1306,7 +1290,10 @@ xf86RandR12CrtcGetGamma (ScreenPtr pScreen,
/* Realloc randr gamma if needed. */
if (randr_crtc->gammaSize != crtc->gamma_size) {
CARD16 *tmp_ptr;
- tmp_ptr = realloc(randr_crtc->gammaRed, 3 * crtc->gamma_size * sizeof (CARD16));
+
+ tmp_ptr =
+ realloc(randr_crtc->gammaRed,
+ 3 * crtc->gamma_size * sizeof(CARD16));
if (!tmp_ptr)
return FALSE;
randr_crtc->gammaRed = tmp_ptr;
@@ -1314,18 +1301,20 @@ xf86RandR12CrtcGetGamma (ScreenPtr pScreen,
randr_crtc->gammaBlue = randr_crtc->gammaGreen + crtc->gamma_size;
}
randr_crtc->gammaSize = crtc->gamma_size;
- memcpy (randr_crtc->gammaRed, crtc->gamma_red, crtc->gamma_size * sizeof (CARD16));
- memcpy (randr_crtc->gammaGreen, crtc->gamma_green, crtc->gamma_size * sizeof (CARD16));
- memcpy (randr_crtc->gammaBlue, crtc->gamma_blue, crtc->gamma_size * sizeof (CARD16));
+ memcpy(randr_crtc->gammaRed, crtc->gamma_red,
+ crtc->gamma_size * sizeof(CARD16));
+ memcpy(randr_crtc->gammaGreen, crtc->gamma_green,
+ crtc->gamma_size * sizeof(CARD16));
+ memcpy(randr_crtc->gammaBlue, crtc->gamma_blue,
+ crtc->gamma_size * sizeof(CARD16));
return TRUE;
}
static Bool
-xf86RandR12OutputSetProperty (ScreenPtr pScreen,
- RROutputPtr randr_output,
- Atom property,
- RRPropertyValuePtr value)
+xf86RandR12OutputSetProperty(ScreenPtr pScreen,
+ RROutputPtr randr_output,
+ Atom property, RRPropertyValuePtr value)
{
xf86OutputPtr output = randr_output->devPrivate;
@@ -1333,7 +1322,7 @@ xf86RandR12OutputSetProperty (ScreenPtr pScreen,
* user is setting properties to.
*/
if (output->funcs->set_property == NULL)
- return TRUE;
+ return TRUE;
/*
* This function gets called even when vtSema is FALSE, as
@@ -1344,41 +1333,39 @@ xf86RandR12OutputSetProperty (ScreenPtr pScreen,
}
static Bool
-xf86RandR13OutputGetProperty (ScreenPtr pScreen,
- RROutputPtr randr_output,
- Atom property)
+xf86RandR13OutputGetProperty(ScreenPtr pScreen,
+ RROutputPtr randr_output, Atom property)
{
xf86OutputPtr output = randr_output->devPrivate;
if (output->funcs->get_property == NULL)
- return TRUE;
+ return TRUE;
/* Should be safe even w/o vtSema */
return output->funcs->get_property(output, property);
}
static Bool
-xf86RandR12OutputValidateMode (ScreenPtr pScreen,
- RROutputPtr randr_output,
- RRModePtr randr_mode)
+xf86RandR12OutputValidateMode(ScreenPtr pScreen,
+ RROutputPtr randr_output, RRModePtr randr_mode)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86OutputPtr output = randr_output->devPrivate;
- DisplayModeRec mode;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86OutputPtr output = randr_output->devPrivate;
+ DisplayModeRec mode;
- xf86RandRModeConvert (pScrn, randr_mode, &mode);
+ xf86RandRModeConvert(pScrn, randr_mode, &mode);
/*
* This function may be called when vtSema is FALSE, so
* the underlying function must either avoid touching the hardware
* or return FALSE when vtSema is FALSE
*/
- if (output->funcs->mode_valid (output, &mode) != MODE_OK)
- return FALSE;
+ if (output->funcs->mode_valid(output, &mode) != MODE_OK)
+ return FALSE;
return TRUE;
}
static void
-xf86RandR12ModeDestroy (ScreenPtr pScreen, RRModePtr randr_mode)
+xf86RandR12ModeDestroy(ScreenPtr pScreen, RRModePtr randr_mode)
{
}
@@ -1387,56 +1374,56 @@ xf86RandR12ModeDestroy (ScreenPtr pScreen, RRModePtr randr_mode)
* RandR modes and assign them to the output
*/
static Bool
-xf86RROutputSetModes (RROutputPtr randr_output, DisplayModePtr modes)
+xf86RROutputSetModes(RROutputPtr randr_output, DisplayModePtr modes)
{
- DisplayModePtr mode;
- RRModePtr *rrmodes = NULL;
- int nmode = 0;
- int npreferred = 0;
- Bool ret = TRUE;
- int pref;
+ DisplayModePtr mode;
+ RRModePtr *rrmodes = NULL;
+ int nmode = 0;
+ int npreferred = 0;
+ Bool ret = TRUE;
+ int pref;
for (mode = modes; mode; mode = mode->next)
- nmode++;
+ nmode++;
if (nmode) {
- rrmodes = malloc(nmode * sizeof (RRModePtr));
-
- if (!rrmodes)
- return FALSE;
- nmode = 0;
-
- for (pref = 1; pref >= 0; pref--) {
- for (mode = modes; mode; mode = mode->next) {
- if ((pref != 0) == ((mode->type & M_T_PREFERRED) != 0)) {
- xRRModeInfo modeInfo;
- RRModePtr rrmode;
-
- modeInfo.nameLength = strlen (mode->name);
- modeInfo.width = mode->HDisplay;
- modeInfo.dotClock = mode->Clock * 1000;
- modeInfo.hSyncStart = mode->HSyncStart;
- modeInfo.hSyncEnd = mode->HSyncEnd;
- modeInfo.hTotal = mode->HTotal;
- modeInfo.hSkew = mode->HSkew;
-
- modeInfo.height = mode->VDisplay;
- modeInfo.vSyncStart = mode->VSyncStart;
- modeInfo.vSyncEnd = mode->VSyncEnd;
- modeInfo.vTotal = mode->VTotal;
- modeInfo.modeFlags = mode->Flags;
-
- rrmode = RRModeGet (&modeInfo, mode->name);
- if (rrmode) {
- rrmodes[nmode++] = rrmode;
- npreferred += pref;
- }
- }
- }
- }
+ rrmodes = malloc(nmode * sizeof(RRModePtr));
+
+ if (!rrmodes)
+ return FALSE;
+ nmode = 0;
+
+ for (pref = 1; pref >= 0; pref--) {
+ for (mode = modes; mode; mode = mode->next) {
+ if ((pref != 0) == ((mode->type & M_T_PREFERRED) != 0)) {
+ xRRModeInfo modeInfo;
+ RRModePtr rrmode;
+
+ modeInfo.nameLength = strlen(mode->name);
+ modeInfo.width = mode->HDisplay;
+ modeInfo.dotClock = mode->Clock * 1000;
+ modeInfo.hSyncStart = mode->HSyncStart;
+ modeInfo.hSyncEnd = mode->HSyncEnd;
+ modeInfo.hTotal = mode->HTotal;
+ modeInfo.hSkew = mode->HSkew;
+
+ modeInfo.height = mode->VDisplay;
+ modeInfo.vSyncStart = mode->VSyncStart;
+ modeInfo.vSyncEnd = mode->VSyncEnd;
+ modeInfo.vTotal = mode->VTotal;
+ modeInfo.modeFlags = mode->Flags;
+
+ rrmode = RRModeGet(&modeInfo, mode->name);
+ if (rrmode) {
+ rrmodes[nmode++] = rrmode;
+ npreferred += pref;
+ }
+ }
+ }
+ }
}
-
- ret = RROutputSetModes (randr_output, rrmodes, nmode, npreferred);
+
+ ret = RROutputSetModes(randr_output, rrmodes, nmode, npreferred);
free(rrmodes);
return ret;
}
@@ -1445,154 +1432,144 @@ xf86RROutputSetModes (RROutputPtr randr_output, DisplayModePtr modes)
* Mirror the current mode configuration to RandR
*/
static Bool
-xf86RandR12SetInfo12 (ScreenPtr pScreen)
+xf86RandR12SetInfo12(ScreenPtr pScreen)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- RROutputPtr *clones;
- RRCrtcPtr *crtcs;
- int ncrtc;
- int o, c, l;
- RRCrtcPtr randr_crtc;
- int nclone;
-
- clones = malloc(config->num_output * sizeof (RROutputPtr));
- crtcs = malloc(config->num_crtc * sizeof (RRCrtcPtr));
- for (o = 0; o < config->num_output; o++)
- {
- xf86OutputPtr output = config->output[o];
-
- ncrtc = 0;
- for (c = 0; c < config->num_crtc; c++)
- if (output->possible_crtcs & (1 << c))
- crtcs[ncrtc++] = config->crtc[c]->randr_crtc;
-
- if (output->crtc)
- randr_crtc = output->crtc->randr_crtc;
- else
- randr_crtc = NULL;
-
- if (!RROutputSetCrtcs (output->randr_output, crtcs, ncrtc))
- {
- free(crtcs);
- free(clones);
- return FALSE;
- }
-
- RROutputSetPhysicalSize(output->randr_output,
- output->mm_width,
- output->mm_height);
- xf86RROutputSetModes (output->randr_output, output->probed_modes);
-
- switch (output->status) {
- case XF86OutputStatusConnected:
- RROutputSetConnection (output->randr_output, RR_Connected);
- break;
- case XF86OutputStatusDisconnected:
- RROutputSetConnection (output->randr_output, RR_Disconnected);
- break;
- case XF86OutputStatusUnknown:
- RROutputSetConnection (output->randr_output, RR_UnknownConnection);
- break;
- }
-
- RROutputSetSubpixelOrder (output->randr_output, output->subpixel_order);
-
- /*
- * Valid clones
- */
- nclone = 0;
- for (l = 0; l < config->num_output; l++)
- {
- xf86OutputPtr clone = config->output[l];
-
- if (l != o && (output->possible_clones & (1 << l)))
- clones[nclone++] = clone->randr_output;
- }
- if (!RROutputSetClones (output->randr_output, clones, nclone))
- {
- free(crtcs);
- free(clones);
- return FALSE;
- }
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ RROutputPtr *clones;
+ RRCrtcPtr *crtcs;
+ int ncrtc;
+ int o, c, l;
+ RRCrtcPtr randr_crtc;
+ int nclone;
+
+ clones = malloc(config->num_output * sizeof(RROutputPtr));
+ crtcs = malloc(config->num_crtc * sizeof(RRCrtcPtr));
+ for (o = 0; o < config->num_output; o++) {
+ xf86OutputPtr output = config->output[o];
+
+ ncrtc = 0;
+ for (c = 0; c < config->num_crtc; c++)
+ if (output->possible_crtcs & (1 << c))
+ crtcs[ncrtc++] = config->crtc[c]->randr_crtc;
+
+ if (output->crtc)
+ randr_crtc = output->crtc->randr_crtc;
+ else
+ randr_crtc = NULL;
+
+ if (!RROutputSetCrtcs(output->randr_output, crtcs, ncrtc)) {
+ free(crtcs);
+ free(clones);
+ return FALSE;
+ }
+
+ RROutputSetPhysicalSize(output->randr_output,
+ output->mm_width, output->mm_height);
+ xf86RROutputSetModes(output->randr_output, output->probed_modes);
+
+ switch (output->status) {
+ case XF86OutputStatusConnected:
+ RROutputSetConnection(output->randr_output, RR_Connected);
+ break;
+ case XF86OutputStatusDisconnected:
+ RROutputSetConnection(output->randr_output, RR_Disconnected);
+ break;
+ case XF86OutputStatusUnknown:
+ RROutputSetConnection(output->randr_output, RR_UnknownConnection);
+ break;
+ }
+
+ RROutputSetSubpixelOrder(output->randr_output, output->subpixel_order);
+
+ /*
+ * Valid clones
+ */
+ nclone = 0;
+ for (l = 0; l < config->num_output; l++) {
+ xf86OutputPtr clone = config->output[l];
+
+ if (l != o && (output->possible_clones & (1 << l)))
+ clones[nclone++] = clone->randr_output;
+ }
+ if (!RROutputSetClones(output->randr_output, clones, nclone)) {
+ free(crtcs);
+ free(clones);
+ return FALSE;
+ }
}
free(crtcs);
free(clones);
return TRUE;
}
-
-
/*
* Query the hardware for the current state, then mirror
* that to RandR
*/
static Bool
-xf86RandR12GetInfo12 (ScreenPtr pScreen, Rotation *rotations)
+xf86RandR12GetInfo12(ScreenPtr pScreen, Rotation * rotations)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
if (!pScrn->vtSema)
- return TRUE;
- xf86ProbeOutputModes (pScrn, 0, 0);
- xf86SetScrnInfoModes (pScrn);
- return xf86RandR12SetInfo12 (pScreen);
+ return TRUE;
+ xf86ProbeOutputModes(pScrn, 0, 0);
+ xf86SetScrnInfoModes(pScrn);
+ return xf86RandR12SetInfo12(pScreen);
}
static Bool
-xf86RandR12CreateObjects12 (ScreenPtr pScreen)
+xf86RandR12CreateObjects12(ScreenPtr pScreen)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- int c;
- int o;
-
- if (!RRInit ())
- return FALSE;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int c;
+ int o;
+
+ if (!RRInit())
+ return FALSE;
/*
* Configure crtcs
*/
- for (c = 0; c < config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = config->crtc[c];
-
- crtc->randr_crtc = RRCrtcCreate (pScreen, crtc);
- RRCrtcGammaSetSize (crtc->randr_crtc, 256);
+ for (c = 0; c < config->num_crtc; c++) {
+ xf86CrtcPtr crtc = config->crtc[c];
+
+ crtc->randr_crtc = RRCrtcCreate(pScreen, crtc);
+ RRCrtcGammaSetSize(crtc->randr_crtc, 256);
}
/*
* Configure outputs
*/
- for (o = 0; o < config->num_output; o++)
- {
- xf86OutputPtr output = config->output[o];
+ for (o = 0; o < config->num_output; o++) {
+ xf86OutputPtr output = config->output[o];
- output->randr_output = RROutputCreate (pScreen, output->name,
- strlen (output->name),
- output);
+ output->randr_output = RROutputCreate(pScreen, output->name,
+ strlen(output->name), output);
- if (output->funcs->create_resources != NULL)
- output->funcs->create_resources(output);
- RRPostPendingProperties (output->randr_output);
+ if (output->funcs->create_resources != NULL)
+ output->funcs->create_resources(output);
+ RRPostPendingProperties(output->randr_output);
}
return TRUE;
}
static Bool
-xf86RandR12CreateScreenResources12 (ScreenPtr pScreen)
+xf86RandR12CreateScreenResources12(ScreenPtr pScreen)
{
- int c;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int c;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
if (xf86RandR12Key == NULL)
- return TRUE;
+ return TRUE;
for (c = 0; c < config->num_crtc; c++)
- xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc);
-
- RRScreenSetSizeRange (pScreen, config->minWidth, config->minHeight,
- config->maxWidth, config->maxHeight);
+ xf86RandR12CrtcNotify(config->crtc[c]->randr_crtc);
+
+ RRScreenSetSizeRange(pScreen, config->minWidth, config->minHeight,
+ config->maxWidth, config->maxHeight);
return TRUE;
}
@@ -1602,95 +1579,91 @@ xf86RandR12CreateScreenResources12 (ScreenPtr pScreen)
*/
void
-xf86RandR12TellChanged (ScreenPtr pScreen)
+xf86RandR12TellChanged(ScreenPtr pScreen)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- int c;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int c;
if (xf86RandR12Key == NULL)
- return;
+ return;
- xf86RandR12SetInfo12 (pScreen);
+ xf86RandR12SetInfo12(pScreen);
for (c = 0; c < config->num_crtc; c++)
- xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc);
+ xf86RandR12CrtcNotify(config->crtc[c]->randr_crtc);
- RRTellChanged (pScreen);
+ RRTellChanged(pScreen);
}
static void
-xf86RandR12PointerMoved (int scrnIndex, int x, int y)
+xf86RandR12PointerMoved(int scrnIndex, int x, int y)
{
- ScreenPtr pScreen = screenInfo.screens[scrnIndex];
- ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ ScreenPtr pScreen = screenInfo.screens[scrnIndex];
+ ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
int c;
randrp->pointerX = x;
randrp->pointerY = y;
for (c = 0; c < config->num_crtc; c++)
- xf86RandR13Pan (config->crtc[c], x, y);
+ xf86RandR13Pan(config->crtc[c], x, y);
}
static Bool
-xf86RandR13GetPanning (ScreenPtr pScreen,
- RRCrtcPtr randr_crtc,
- BoxPtr totalArea,
- BoxPtr trackingArea,
- INT16 *border)
+xf86RandR13GetPanning(ScreenPtr pScreen,
+ RRCrtcPtr randr_crtc,
+ BoxPtr totalArea, BoxPtr trackingArea, INT16 *border)
{
- xf86CrtcPtr crtc = randr_crtc->devPrivate;
+ xf86CrtcPtr crtc = randr_crtc->devPrivate;
if (crtc->version < 2)
- return FALSE;
+ return FALSE;
if (totalArea)
- memcpy (totalArea, &crtc->panningTotalArea, sizeof(BoxRec));
+ memcpy(totalArea, &crtc->panningTotalArea, sizeof(BoxRec));
if (trackingArea)
- memcpy (trackingArea, &crtc->panningTrackingArea, sizeof(BoxRec));
+ memcpy(trackingArea, &crtc->panningTrackingArea, sizeof(BoxRec));
if (border)
- memcpy (border, crtc->panningBorder, 4*sizeof(INT16));
+ memcpy(border, crtc->panningBorder, 4 * sizeof(INT16));
return TRUE;
}
static Bool
-xf86RandR13SetPanning (ScreenPtr pScreen,
- RRCrtcPtr randr_crtc,
- BoxPtr totalArea,
- BoxPtr trackingArea,
- INT16 *border)
+xf86RandR13SetPanning(ScreenPtr pScreen,
+ RRCrtcPtr randr_crtc,
+ BoxPtr totalArea, BoxPtr trackingArea, INT16 *border)
{
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- xf86CrtcPtr crtc = randr_crtc->devPrivate;
- BoxRec oldTotalArea;
- BoxRec oldTrackingArea;
- INT16 oldBorder[4];
-
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ xf86CrtcPtr crtc = randr_crtc->devPrivate;
+ BoxRec oldTotalArea;
+ BoxRec oldTrackingArea;
+ INT16 oldBorder[4];
if (crtc->version < 2)
- return FALSE;
+ return FALSE;
- memcpy (&oldTotalArea, &crtc->panningTotalArea, sizeof(BoxRec));
- memcpy (&oldTrackingArea, &crtc->panningTrackingArea, sizeof(BoxRec));
- memcpy (oldBorder, crtc->panningBorder, 4*sizeof(INT16));
+ memcpy(&oldTotalArea, &crtc->panningTotalArea, sizeof(BoxRec));
+ memcpy(&oldTrackingArea, &crtc->panningTrackingArea, sizeof(BoxRec));
+ memcpy(oldBorder, crtc->panningBorder, 4 * sizeof(INT16));
if (totalArea)
- memcpy (&crtc->panningTotalArea, totalArea, sizeof(BoxRec));
+ memcpy(&crtc->panningTotalArea, totalArea, sizeof(BoxRec));
if (trackingArea)
- memcpy (&crtc->panningTrackingArea, trackingArea, sizeof(BoxRec));
+ memcpy(&crtc->panningTrackingArea, trackingArea, sizeof(BoxRec));
if (border)
- memcpy (crtc->panningBorder, border, 4*sizeof(INT16));
-
- if (xf86RandR13VerifyPanningArea (crtc, pScreen->width, pScreen->height)) {
- xf86RandR13Pan (crtc, randrp->pointerX, randrp->pointerY);
- return TRUE;
- } else {
- /* Restore old settings */
- memcpy (&crtc->panningTotalArea, &oldTotalArea, sizeof(BoxRec));
- memcpy (&crtc->panningTrackingArea, &oldTrackingArea, sizeof(BoxRec));
- memcpy (crtc->panningBorder, oldBorder, 4*sizeof(INT16));
- return FALSE;
+ memcpy(crtc->panningBorder, border, 4 * sizeof(INT16));
+
+ if (xf86RandR13VerifyPanningArea(crtc, pScreen->width, pScreen->height)) {
+ xf86RandR13Pan(crtc, randrp->pointerX, randrp->pointerY);
+ return TRUE;
+ }
+ else {
+ /* Restore old settings */
+ memcpy(&crtc->panningTotalArea, &oldTotalArea, sizeof(BoxRec));
+ memcpy(&crtc->panningTrackingArea, &oldTrackingArea, sizeof(BoxRec));
+ memcpy(crtc->panningBorder, oldBorder, 4 * sizeof(INT16));
+ return FALSE;
}
}
@@ -1705,11 +1678,12 @@ gamma_to_ramp(float gamma, CARD16 *ramp, int size)
int i;
for (i = 0; i < size; i++) {
- if (gamma == 1.0)
- ramp[i] = i << 8;
- else
- ramp[i] = (CARD16)(pow((double)i / (double)(size - 1), 1. / gamma)
- * (double)(size - 1) * 256);
+ if (gamma == 1.0)
+ ramp[i] = i << 8;
+ else
+ ramp[i] =
+ (CARD16) (pow((double) i / (double) (size - 1), 1. / gamma)
+ * (double) (size - 1) * 256);
}
}
@@ -1722,15 +1696,15 @@ xf86RandR12ChangeGamma(int scrnIndex, Gamma gamma)
int size;
if (!crtc)
- return Success;
+ return Success;
size = max(0, crtc->gammaSize);
if (!size)
- return Success;
+ return Success;
points = calloc(size, 3 * sizeof(CARD16));
if (!points)
- return BadAlloc;
+ return BadAlloc;
red = points;
green = points + size;
@@ -1749,37 +1723,37 @@ xf86RandR12ChangeGamma(int scrnIndex, Gamma gamma)
}
static Bool
-xf86RandR12EnterVT (int screen_index, int flags)
+xf86RandR12EnterVT(int screen_index, int flags)
{
- ScreenPtr pScreen = screenInfo.screens[screen_index];
- ScrnInfoPtr pScrn = xf86Screens[screen_index];
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- rrScrPrivPtr rp = rrGetScrPriv(pScreen);
- Bool ret;
- int i;
+ ScreenPtr pScreen = screenInfo.screens[screen_index];
+ ScrnInfoPtr pScrn = xf86Screens[screen_index];
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ rrScrPrivPtr rp = rrGetScrPriv(pScreen);
+ Bool ret;
+ int i;
if (randrp->orig_EnterVT) {
- pScrn->EnterVT = randrp->orig_EnterVT;
- ret = pScrn->EnterVT (screen_index, flags);
- randrp->orig_EnterVT = pScrn->EnterVT;
- pScrn->EnterVT = xf86RandR12EnterVT;
- if (!ret)
- return FALSE;
+ pScrn->EnterVT = randrp->orig_EnterVT;
+ ret = pScrn->EnterVT(screen_index, flags);
+ randrp->orig_EnterVT = pScrn->EnterVT;
+ pScrn->EnterVT = xf86RandR12EnterVT;
+ if (!ret)
+ return FALSE;
}
/* reload gamma */
for (i = 0; i < rp->numCrtcs; i++)
- xf86RandR12CrtcSetGamma(pScreen, rp->crtcs[i]);
+ xf86RandR12CrtcSetGamma(pScreen, rp->crtcs[i]);
- return RRGetInfo (pScreen, TRUE); /* force a re-probe of outputs and notify clients about changes */
+ return RRGetInfo(pScreen, TRUE); /* force a re-probe of outputs and notify clients about changes */
}
static Bool
-xf86RandR12Init12 (ScreenPtr pScreen)
+xf86RandR12Init12(ScreenPtr pScreen)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- rrScrPrivPtr rp = rrGetScrPriv(pScreen);
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ rrScrPrivPtr rp = rrGetScrPriv(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
int i;
rp->rrGetInfo = xf86RandR12GetInfo12;
@@ -1802,16 +1776,16 @@ xf86RandR12Init12 (ScreenPtr pScreen)
randrp->orig_EnterVT = pScrn->EnterVT;
pScrn->EnterVT = xf86RandR12EnterVT;
- if (!xf86RandR12CreateObjects12 (pScreen))
- return FALSE;
+ if (!xf86RandR12CreateObjects12(pScreen))
+ return FALSE;
/*
* Configure output modes
*/
- if (!xf86RandR12SetInfo12 (pScreen))
- return FALSE;
+ if (!xf86RandR12SetInfo12(pScreen))
+ return FALSE;
for (i = 0; i < rp->numCrtcs; i++) {
- xf86RandR12CrtcGetGamma(pScreen, rp->crtcs[i]);
+ xf86RandR12CrtcGetGamma(pScreen, rp->crtcs[i]);
}
return TRUE;
}
@@ -1819,7 +1793,7 @@ xf86RandR12Init12 (ScreenPtr pScreen)
#endif
Bool
-xf86RandR12PreInit (ScrnInfoPtr pScrn)
+xf86RandR12PreInit(ScrnInfoPtr pScrn)
{
return TRUE;
}
diff --git a/xorg-server/hw/xfree86/modes/xf86RandR12.h b/xorg-server/hw/xfree86/modes/xf86RandR12.h
index 755a472d1..9ad695cec 100644
--- a/xorg-server/hw/xfree86/modes/xf86RandR12.h
+++ b/xorg-server/hw/xfree86/modes/xf86RandR12.h
@@ -1,43 +1,46 @@
-/*
- * Copyright © 2006 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that copyright
- * notice and this permission notice appear in supporting documentation, and
- * that the name of the copyright holders not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. The copyright holders make no representations
- * about the suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#ifndef _XF86_RANDR_H_
-#define _XF86_RANDR_H_
-#include <randrstr.h>
-#include <X11/extensions/render.h>
-#if XF86_MODES_RENAME
-#include "xf86Rename.h"
-#endif
-
-extern _X_EXPORT Bool xf86RandR12CreateScreenResources (ScreenPtr pScreen);
-extern _X_EXPORT Bool xf86RandR12Init(ScreenPtr pScreen);
-extern _X_EXPORT void xf86RandR12CloseScreen(ScreenPtr pScreen);
-extern _X_EXPORT void xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotation);
-extern _X_EXPORT void xf86RandR12SetTransformSupport (ScreenPtr pScreen, Bool transforms);
-extern _X_EXPORT Bool xf86RandR12SetConfig(ScreenPtr pScreen, Rotation rotation, int rate,
- RRScreenSizePtr pSize);
-extern _X_EXPORT Rotation xf86RandR12GetRotation(ScreenPtr pScreen);
-extern _X_EXPORT void xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y);
-extern _X_EXPORT Bool xf86RandR12PreInit (ScrnInfoPtr pScrn);
-extern _X_EXPORT void xf86RandR12TellChanged (ScreenPtr pScreen);
-
-#endif /* _XF86_RANDR_H_ */
+/*
+ * Copyright © 2006 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifndef _XF86_RANDR_H_
+#define _XF86_RANDR_H_
+#include <randrstr.h>
+#include <X11/extensions/render.h>
+#if XF86_MODES_RENAME
+#include "xf86Rename.h"
+#endif
+
+extern _X_EXPORT Bool xf86RandR12CreateScreenResources(ScreenPtr pScreen);
+extern _X_EXPORT Bool xf86RandR12Init(ScreenPtr pScreen);
+extern _X_EXPORT void xf86RandR12CloseScreen(ScreenPtr pScreen);
+extern _X_EXPORT void xf86RandR12SetRotations(ScreenPtr pScreen,
+ Rotation rotation);
+extern _X_EXPORT void xf86RandR12SetTransformSupport(ScreenPtr pScreen,
+ Bool transforms);
+extern _X_EXPORT Bool xf86RandR12SetConfig(ScreenPtr pScreen, Rotation rotation,
+ int rate, RRScreenSizePtr pSize);
+extern _X_EXPORT Rotation xf86RandR12GetRotation(ScreenPtr pScreen);
+extern _X_EXPORT void xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn,
+ int *x, int *y);
+extern _X_EXPORT Bool xf86RandR12PreInit(ScrnInfoPtr pScrn);
+extern _X_EXPORT void xf86RandR12TellChanged(ScreenPtr pScreen);
+
+#endif /* _XF86_RANDR_H_ */
diff --git a/xorg-server/hw/xfree86/modes/xf86Rotate.c b/xorg-server/hw/xfree86/modes/xf86Rotate.c
index ff7000b5a..85d75573d 100644
--- a/xorg-server/hw/xfree86/modes/xf86Rotate.c
+++ b/xorg-server/hw/xfree86/modes/xf86Rotate.c
@@ -47,25 +47,25 @@
/* borrowed from composite extension, move to Render and publish? */
static VisualPtr
-compGetWindowVisual (WindowPtr pWin)
+compGetWindowVisual(WindowPtr pWin)
{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- VisualID vid = wVisual (pWin);
- int i;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ VisualID vid = wVisual(pWin);
+ int i;
for (i = 0; i < pScreen->numVisuals; i++)
- if (pScreen->visuals[i].vid == vid)
- return &pScreen->visuals[i];
+ if (pScreen->visuals[i].vid == vid)
+ return &pScreen->visuals[i];
return 0;
}
static PictFormatPtr
-compWindowFormat (WindowPtr pWin)
+compWindowFormat(WindowPtr pWin)
{
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
- return PictureMatchVisual (pScreen, pWin->drawable.depth,
- compGetWindowVisual (pWin));
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ return PictureMatchVisual(pScreen, pWin->drawable.depth,
+ compGetWindowVisual(pWin));
}
#define F(x) IntToxFixed(x)
@@ -73,201 +73,190 @@ compWindowFormat (WindowPtr pWin)
#define toF(x) ((float) (x) / 65536.0f)
static void
-xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region)
+xf86RotateCrtcRedisplay(xf86CrtcPtr crtc, RegionPtr region)
{
- ScrnInfoPtr scrn = crtc->scrn;
- ScreenPtr screen = scrn->pScreen;
- WindowPtr root = screen->root;
- PixmapPtr dst_pixmap = crtc->rotatedPixmap;
- PictFormatPtr format = compWindowFormat (screen->root);
- int error;
- PicturePtr src, dst;
- int n = RegionNumRects(region);
- BoxPtr b = RegionRects(region);
- XID include_inferiors = IncludeInferiors;
+ ScrnInfoPtr scrn = crtc->scrn;
+ ScreenPtr screen = scrn->pScreen;
+ WindowPtr root = screen->root;
+ PixmapPtr dst_pixmap = crtc->rotatedPixmap;
+ PictFormatPtr format = compWindowFormat(screen->root);
+ int error;
+ PicturePtr src, dst;
+ int n = RegionNumRects(region);
+ BoxPtr b = RegionRects(region);
+ XID include_inferiors = IncludeInferiors;
if (crtc->driverIsPerformingTransform)
- return;
-
- src = CreatePicture (None,
- &root->drawable,
- format,
- CPSubwindowMode,
- &include_inferiors,
- serverClient,
- &error);
+ return;
+
+ src = CreatePicture(None,
+ &root->drawable,
+ format,
+ CPSubwindowMode,
+ &include_inferiors, serverClient, &error);
if (!src)
- return;
-
- dst = CreatePicture (None,
- &dst_pixmap->drawable,
- format,
- 0L,
- NULL,
- serverClient,
- &error);
+ return;
+
+ dst = CreatePicture(None,
+ &dst_pixmap->drawable,
+ format, 0L, NULL, serverClient, &error);
if (!dst)
- return;
+ return;
- error = SetPictureTransform (src, &crtc->crtc_to_framebuffer);
+ error = SetPictureTransform(src, &crtc->crtc_to_framebuffer);
if (error)
- return;
+ return;
if (crtc->transform_in_use && crtc->filter)
- SetPicturePictFilter (src, crtc->filter,
- crtc->params, crtc->nparams);
-
- if (crtc->shadowClear)
- {
- CompositePicture (PictOpSrc,
- src, NULL, dst,
- 0, 0, 0, 0, 0, 0,
- crtc->mode.HDisplay, crtc->mode.VDisplay);
- crtc->shadowClear = FALSE;
+ SetPicturePictFilter(src, crtc->filter, crtc->params, crtc->nparams);
+
+ if (crtc->shadowClear) {
+ CompositePicture(PictOpSrc,
+ src, NULL, dst,
+ 0, 0, 0, 0, 0, 0,
+ crtc->mode.HDisplay, crtc->mode.VDisplay);
+ crtc->shadowClear = FALSE;
}
- else
- {
- while (n--)
- {
- BoxRec dst_box;
-
- dst_box = *b;
- dst_box.x1 -= crtc->filter_width >> 1;
- dst_box.x2 += crtc->filter_width >> 1;
- dst_box.y1 -= crtc->filter_height >> 1;
- dst_box.y2 += crtc->filter_height >> 1;
- pixman_f_transform_bounds (&crtc->f_framebuffer_to_crtc, &dst_box);
- CompositePicture (PictOpSrc,
- src, NULL, dst,
- dst_box.x1, dst_box.y1, 0, 0, dst_box.x1, dst_box.y1,
- dst_box.x2 - dst_box.x1,
- dst_box.y2 - dst_box.y1);
- b++;
- }
+ else {
+ while (n--) {
+ BoxRec dst_box;
+
+ dst_box = *b;
+ dst_box.x1 -= crtc->filter_width >> 1;
+ dst_box.x2 += crtc->filter_width >> 1;
+ dst_box.y1 -= crtc->filter_height >> 1;
+ dst_box.y2 += crtc->filter_height >> 1;
+ pixman_f_transform_bounds(&crtc->f_framebuffer_to_crtc, &dst_box);
+ CompositePicture(PictOpSrc,
+ src, NULL, dst,
+ dst_box.x1, dst_box.y1, 0, 0, dst_box.x1,
+ dst_box.y1, dst_box.x2 - dst_box.x1,
+ dst_box.y2 - dst_box.y1);
+ b++;
+ }
}
- FreePicture (src, None);
- FreePicture (dst, None);
+ FreePicture(src, None);
+ FreePicture(dst, None);
}
static void
-xf86CrtcDamageShadow (xf86CrtcPtr crtc)
+xf86CrtcDamageShadow(xf86CrtcPtr crtc)
{
- ScrnInfoPtr pScrn = crtc->scrn;
- BoxRec damage_box;
- RegionRec damage_region;
- ScreenPtr pScreen = pScrn->pScreen;
+ ScrnInfoPtr pScrn = crtc->scrn;
+ BoxRec damage_box;
+ RegionRec damage_region;
+ ScreenPtr pScreen = pScrn->pScreen;
damage_box.x1 = 0;
damage_box.x2 = crtc->mode.HDisplay;
damage_box.y1 = 0;
damage_box.y2 = crtc->mode.VDisplay;
- if (!pixman_transform_bounds (&crtc->crtc_to_framebuffer, &damage_box))
- {
- damage_box.x1 = 0;
- damage_box.y1 = 0;
- damage_box.x2 = pScreen->width;
- damage_box.y2 = pScreen->height;
+ if (!pixman_transform_bounds(&crtc->crtc_to_framebuffer, &damage_box)) {
+ damage_box.x1 = 0;
+ damage_box.y1 = 0;
+ damage_box.x2 = pScreen->width;
+ damage_box.y2 = pScreen->height;
}
- if (damage_box.x1 < 0) damage_box.x1 = 0;
- if (damage_box.y1 < 0) damage_box.y1 = 0;
- if (damage_box.x2 > pScreen->width) damage_box.x2 = pScreen->width;
- if (damage_box.y2 > pScreen->height) damage_box.y2 = pScreen->height;
+ if (damage_box.x1 < 0)
+ damage_box.x1 = 0;
+ if (damage_box.y1 < 0)
+ damage_box.y1 = 0;
+ if (damage_box.x2 > pScreen->width)
+ damage_box.x2 = pScreen->width;
+ if (damage_box.y2 > pScreen->height)
+ damage_box.y2 = pScreen->height;
RegionInit(&damage_region, &damage_box, 1);
- DamageDamageRegion (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
- &damage_region);
+ DamageDamageRegion(&(*pScreen->GetScreenPixmap) (pScreen)->drawable,
+ &damage_region);
RegionUninit(&damage_region);
crtc->shadowClear = TRUE;
}
static void
-xf86RotatePrepare (ScreenPtr pScreen)
+xf86RotatePrepare(ScreenPtr pScreen)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
- int c;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int c;
- for (c = 0; c < xf86_config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = xf86_config->crtc[c];
-
- if (crtc->rotatedData && !crtc->rotatedPixmap)
- {
- crtc->rotatedPixmap = crtc->funcs->shadow_create (crtc,
- crtc->rotatedData,
- crtc->mode.HDisplay,
- crtc->mode.VDisplay);
- if (!xf86_config->rotation_damage_registered)
- {
- /* Hook damage to screen pixmap */
- DamageRegister (&pScreen->root->drawable,
- xf86_config->rotation_damage);
- xf86_config->rotation_damage_registered = TRUE;
- EnableLimitedSchedulingLatency();
- }
-
- xf86CrtcDamageShadow (crtc);
- }
+ for (c = 0; c < xf86_config->num_crtc; c++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+ if (crtc->rotatedData && !crtc->rotatedPixmap) {
+ crtc->rotatedPixmap = crtc->funcs->shadow_create(crtc,
+ crtc->rotatedData,
+ crtc->mode.
+ HDisplay,
+ crtc->mode.
+ VDisplay);
+ if (!xf86_config->rotation_damage_registered) {
+ /* Hook damage to screen pixmap */
+ DamageRegister(&pScreen->root->drawable,
+ xf86_config->rotation_damage);
+ xf86_config->rotation_damage_registered = TRUE;
+ EnableLimitedSchedulingLatency();
+ }
+
+ xf86CrtcDamageShadow(crtc);
+ }
}
}
static Bool
xf86RotateRedisplay(ScreenPtr pScreen)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
- DamagePtr damage = xf86_config->rotation_damage;
- RegionPtr region;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ DamagePtr damage = xf86_config->rotation_damage;
+ RegionPtr region;
if (!damage)
- return FALSE;
- xf86RotatePrepare (pScreen);
+ return FALSE;
+ xf86RotatePrepare(pScreen);
region = DamageRegion(damage);
- if (RegionNotEmpty(region))
- {
- int c;
- SourceValidateProcPtr SourceValidate;
-
- /*
- * SourceValidate is used by the software cursor code
- * to pull the cursor off of the screen when reading
- * bits from the frame buffer. Bypassing this function
- * leaves the software cursor in place
- */
- SourceValidate = pScreen->SourceValidate;
- pScreen->SourceValidate = NULL;
-
- for (c = 0; c < xf86_config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = xf86_config->crtc[c];
-
- if (crtc->transform_in_use && crtc->enabled)
- {
- RegionRec crtc_damage;
-
- /* compute portion of damage that overlaps crtc */
- RegionInit(&crtc_damage, &crtc->bounds, 1);
- RegionIntersect(&crtc_damage, &crtc_damage, region);
-
- /* update damaged region */
- if (RegionNotEmpty(&crtc_damage))
- xf86RotateCrtcRedisplay (crtc, &crtc_damage);
-
- RegionUninit(&crtc_damage);
- }
- }
- pScreen->SourceValidate = SourceValidate;
- DamageEmpty(damage);
+ if (RegionNotEmpty(region)) {
+ int c;
+ SourceValidateProcPtr SourceValidate;
+
+ /*
+ * SourceValidate is used by the software cursor code
+ * to pull the cursor off of the screen when reading
+ * bits from the frame buffer. Bypassing this function
+ * leaves the software cursor in place
+ */
+ SourceValidate = pScreen->SourceValidate;
+ pScreen->SourceValidate = NULL;
+
+ for (c = 0; c < xf86_config->num_crtc; c++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+ if (crtc->transform_in_use && crtc->enabled) {
+ RegionRec crtc_damage;
+
+ /* compute portion of damage that overlaps crtc */
+ RegionInit(&crtc_damage, &crtc->bounds, 1);
+ RegionIntersect(&crtc_damage, &crtc_damage, region);
+
+ /* update damaged region */
+ if (RegionNotEmpty(&crtc_damage))
+ xf86RotateCrtcRedisplay(crtc, &crtc_damage);
+
+ RegionUninit(&crtc_damage);
+ }
+ }
+ pScreen->SourceValidate = SourceValidate;
+ DamageEmpty(damage);
}
return TRUE;
}
static void
xf86RotateBlockHandler(int screenNum, pointer blockData,
- pointer pTimeout, pointer pReadmask)
+ pointer pTimeout, pointer pReadmask)
{
- ScreenPtr pScreen = screenInfo.screens[screenNum];
- ScrnInfoPtr pScrn = xf86Screens[screenNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
- Bool rotation_active;
+ ScreenPtr pScreen = screenInfo.screens[screenNum];
+ ScrnInfoPtr pScrn = xf86Screens[screenNum];
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ Bool rotation_active;
rotation_active = xf86RotateRedisplay(pScreen);
pScreen->BlockHandler = xf86_config->BlockHandler;
@@ -278,40 +267,38 @@ xf86RotateBlockHandler(int screenNum, pointer blockData,
}
void
-xf86RotateDestroy (xf86CrtcPtr crtc)
+xf86RotateDestroy(xf86CrtcPtr crtc)
{
- ScrnInfoPtr pScrn = crtc->scrn;
- ScreenPtr pScreen = pScrn->pScreen;
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
- int c;
-
+ ScrnInfoPtr pScrn = crtc->scrn;
+ ScreenPtr pScreen = pScrn->pScreen;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int c;
+
/* Free memory from rotation */
- if (crtc->rotatedPixmap || crtc->rotatedData)
- {
- crtc->funcs->shadow_destroy (crtc, crtc->rotatedPixmap, crtc->rotatedData);
- crtc->rotatedPixmap = NULL;
- crtc->rotatedData = NULL;
+ if (crtc->rotatedPixmap || crtc->rotatedData) {
+ crtc->funcs->shadow_destroy(crtc, crtc->rotatedPixmap,
+ crtc->rotatedData);
+ crtc->rotatedPixmap = NULL;
+ crtc->rotatedData = NULL;
}
for (c = 0; c < xf86_config->num_crtc; c++)
- if (xf86_config->crtc[c]->rotatedData)
- return;
+ if (xf86_config->crtc[c]->rotatedData)
+ return;
/*
* Clean up damage structures when no crtcs are rotated
*/
- if (xf86_config->rotation_damage)
- {
- /* Free damage structure */
- if (xf86_config->rotation_damage_registered)
- {
- DamageUnregister (&pScreen->root->drawable,
- xf86_config->rotation_damage);
- xf86_config->rotation_damage_registered = FALSE;
- DisableLimitedSchedulingLatency();
- }
- DamageDestroy (xf86_config->rotation_damage);
- xf86_config->rotation_damage = NULL;
+ if (xf86_config->rotation_damage) {
+ /* Free damage structure */
+ if (xf86_config->rotation_damage_registered) {
+ DamageUnregister(&pScreen->root->drawable,
+ xf86_config->rotation_damage);
+ xf86_config->rotation_damage_registered = FALSE;
+ DisableLimitedSchedulingLatency();
+ }
+ DamageDestroy(xf86_config->rotation_damage);
+ xf86_config->rotation_damage = NULL;
}
}
@@ -321,193 +308,186 @@ xf86RotateFreeShadow(ScrnInfoPtr pScrn)
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
int c;
- for (c = 0; c < config->num_crtc; c++) {
- xf86CrtcPtr crtc = config->crtc[c];
+ for (c = 0; c < config->num_crtc; c++) {
+ xf86CrtcPtr crtc = config->crtc[c];
- if (crtc->rotatedPixmap || crtc->rotatedData) {
- crtc->funcs->shadow_destroy(crtc, crtc->rotatedPixmap,
- crtc->rotatedData);
- crtc->rotatedPixmap = NULL;
- crtc->rotatedData = NULL;
- }
- }
+ if (crtc->rotatedPixmap || crtc->rotatedData) {
+ crtc->funcs->shadow_destroy(crtc, crtc->rotatedPixmap,
+ crtc->rotatedData);
+ crtc->rotatedPixmap = NULL;
+ crtc->rotatedData = NULL;
+ }
+ }
}
void
-xf86RotateCloseScreen (ScreenPtr screen)
+xf86RotateCloseScreen(ScreenPtr screen)
{
- ScrnInfoPtr scrn = xf86Screens[screen->myNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- int c;
+ ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ int c;
for (c = 0; c < xf86_config->num_crtc; c++)
- xf86RotateDestroy (xf86_config->crtc[c]);
+ xf86RotateDestroy(xf86_config->crtc[c]);
}
static Bool
-xf86CrtcFitsScreen (xf86CrtcPtr crtc, struct pict_f_transform *crtc_to_fb)
+xf86CrtcFitsScreen(xf86CrtcPtr crtc, struct pict_f_transform *crtc_to_fb)
{
- ScrnInfoPtr pScrn = crtc->scrn;
- BoxRec b;
+ ScrnInfoPtr pScrn = crtc->scrn;
+ BoxRec b;
/* When called before PreInit, the driver is
* presumably doing load detect
*/
if (pScrn->virtualX == 0 || pScrn->virtualY == 0)
- return TRUE;
+ return TRUE;
b.x1 = 0;
b.y1 = 0;
b.x2 = crtc->mode.HDisplay;
b.y2 = crtc->mode.VDisplay;
if (crtc_to_fb)
- pixman_f_transform_bounds (crtc_to_fb, &b);
+ pixman_f_transform_bounds(crtc_to_fb, &b);
else {
- b.x1 += crtc->x;
- b.y1 += crtc->y;
- b.x2 += crtc->x;
- b.y2 += crtc->y;
+ b.x1 += crtc->x;
+ b.y1 += crtc->y;
+ b.x2 += crtc->x;
+ b.y2 += crtc->y;
}
return (0 <= b.x1 && b.x2 <= pScrn->virtualX &&
- 0 <= b.y1 && b.y2 <= pScrn->virtualY);
+ 0 <= b.y1 && b.y2 <= pScrn->virtualY);
}
Bool
-xf86CrtcRotate (xf86CrtcPtr crtc)
+xf86CrtcRotate(xf86CrtcPtr crtc)
{
- ScrnInfoPtr pScrn = crtc->scrn;
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ ScrnInfoPtr pScrn = crtc->scrn;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+
/* if this is called during ScreenInit() we don't have pScrn->pScreen yet */
- ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
- PictTransform crtc_to_fb;
+ ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
+ PictTransform crtc_to_fb;
struct pict_f_transform f_crtc_to_fb, f_fb_to_crtc;
- xFixed *new_params = NULL;
- int new_nparams = 0;
- PictFilterPtr new_filter = NULL;
- int new_width = 0;
- int new_height = 0;
- RRTransformPtr transform = NULL;
- Bool damage = FALSE;
+ xFixed *new_params = NULL;
+ int new_nparams = 0;
+ PictFilterPtr new_filter = NULL;
+ int new_width = 0;
+ int new_height = 0;
+ RRTransformPtr transform = NULL;
+ Bool damage = FALSE;
if (crtc->transformPresent)
- transform = &crtc->transform;
-
- if (!RRTransformCompute (crtc->x, crtc->y,
- crtc->mode.HDisplay, crtc->mode.VDisplay,
- crtc->rotation,
- transform,
-
- &crtc_to_fb,
- &f_crtc_to_fb,
- &f_fb_to_crtc) &&
- xf86CrtcFitsScreen (crtc, &f_crtc_to_fb))
- {
- /*
- * If the untranslated transformation is the identity,
- * disable the shadow buffer
- */
- xf86RotateDestroy (crtc);
- crtc->transform_in_use = FALSE;
- free(new_params);
- new_params = NULL;
- new_nparams = 0;
- new_filter = NULL;
- new_width = 0;
- new_height = 0;
+ transform = &crtc->transform;
+
+ if (!RRTransformCompute(crtc->x, crtc->y,
+ crtc->mode.HDisplay, crtc->mode.VDisplay,
+ crtc->rotation,
+ transform,
+ &crtc_to_fb,
+ &f_crtc_to_fb,
+ &f_fb_to_crtc) &&
+ xf86CrtcFitsScreen(crtc, &f_crtc_to_fb)) {
+ /*
+ * If the untranslated transformation is the identity,
+ * disable the shadow buffer
+ */
+ xf86RotateDestroy(crtc);
+ crtc->transform_in_use = FALSE;
+ free(new_params);
+ new_params = NULL;
+ new_nparams = 0;
+ new_filter = NULL;
+ new_width = 0;
+ new_height = 0;
}
- else
- {
- if (crtc->driverIsPerformingTransform) {
- xf86RotateDestroy(crtc);
- } else {
- /*
- * these are the size of the shadow pixmap, which
- * matches the mode, not the pre-rotated copy in the
- * frame buffer
- */
- int width = crtc->mode.HDisplay;
- int height = crtc->mode.VDisplay;
- void *shadowData = crtc->rotatedData;
- PixmapPtr shadow = crtc->rotatedPixmap;
- int old_width = shadow ? shadow->drawable.width : 0;
- int old_height = shadow ? shadow->drawable.height : 0;
-
- /* Allocate memory for rotation */
- if (old_width != width || old_height != height)
- {
- if (shadow || shadowData)
- {
- crtc->funcs->shadow_destroy (crtc, shadow, shadowData);
- crtc->rotatedPixmap = NULL;
- crtc->rotatedData = NULL;
- }
- shadowData = crtc->funcs->shadow_allocate (crtc, width, height);
- if (!shadowData)
- goto bail1;
- crtc->rotatedData = shadowData;
- /* shadow will be damaged in xf86RotatePrepare */
- }
- else
- {
- /* mark shadowed area as damaged so it will be repainted */
- damage = TRUE;
- }
-
- if (!xf86_config->rotation_damage)
- {
- /* Create damage structure */
- xf86_config->rotation_damage = DamageCreate (NULL, NULL,
- DamageReportNone,
- TRUE, pScreen, pScreen);
- if (!xf86_config->rotation_damage)
- goto bail2;
-
- /* Wrap block handler */
- if (!xf86_config->BlockHandler) {
- xf86_config->BlockHandler = pScreen->BlockHandler;
- pScreen->BlockHandler = xf86RotateBlockHandler;
- }
- }
-
- if (0)
- {
- bail2:
- if (shadow || shadowData)
- {
- crtc->funcs->shadow_destroy (crtc, shadow, shadowData);
- crtc->rotatedPixmap = NULL;
- crtc->rotatedData = NULL;
- }
- bail1:
- if (old_width && old_height)
- crtc->rotatedPixmap =
- crtc->funcs->shadow_create (crtc, NULL, old_width,
- old_height);
- return FALSE;
- }
- }
+ else {
+ if (crtc->driverIsPerformingTransform) {
+ xf86RotateDestroy(crtc);
+ }
+ else {
+ /*
+ * these are the size of the shadow pixmap, which
+ * matches the mode, not the pre-rotated copy in the
+ * frame buffer
+ */
+ int width = crtc->mode.HDisplay;
+ int height = crtc->mode.VDisplay;
+ void *shadowData = crtc->rotatedData;
+ PixmapPtr shadow = crtc->rotatedPixmap;
+ int old_width = shadow ? shadow->drawable.width : 0;
+ int old_height = shadow ? shadow->drawable.height : 0;
+
+ /* Allocate memory for rotation */
+ if (old_width != width || old_height != height) {
+ if (shadow || shadowData) {
+ crtc->funcs->shadow_destroy(crtc, shadow, shadowData);
+ crtc->rotatedPixmap = NULL;
+ crtc->rotatedData = NULL;
+ }
+ shadowData = crtc->funcs->shadow_allocate(crtc, width, height);
+ if (!shadowData)
+ goto bail1;
+ crtc->rotatedData = shadowData;
+ /* shadow will be damaged in xf86RotatePrepare */
+ }
+ else {
+ /* mark shadowed area as damaged so it will be repainted */
+ damage = TRUE;
+ }
+
+ if (!xf86_config->rotation_damage) {
+ /* Create damage structure */
+ xf86_config->rotation_damage = DamageCreate(NULL, NULL,
+ DamageReportNone,
+ TRUE, pScreen,
+ pScreen);
+ if (!xf86_config->rotation_damage)
+ goto bail2;
+
+ /* Wrap block handler */
+ if (!xf86_config->BlockHandler) {
+ xf86_config->BlockHandler = pScreen->BlockHandler;
+ pScreen->BlockHandler = xf86RotateBlockHandler;
+ }
+ }
+
+ if (0) {
+ bail2:
+ if (shadow || shadowData) {
+ crtc->funcs->shadow_destroy(crtc, shadow, shadowData);
+ crtc->rotatedPixmap = NULL;
+ crtc->rotatedData = NULL;
+ }
+ bail1:
+ if (old_width && old_height)
+ crtc->rotatedPixmap =
+ crtc->funcs->shadow_create(crtc, NULL, old_width,
+ old_height);
+ return FALSE;
+ }
+ }
#ifdef RANDR_12_INTERFACE
- if (transform)
- {
- if (transform->nparams) {
- new_params = malloc(transform->nparams * sizeof (xFixed));
- if (new_params) {
- memcpy (new_params, transform->params,
- transform->nparams * sizeof (xFixed));
- new_nparams = transform->nparams;
- new_filter = transform->filter;
- }
- } else
- new_filter = transform->filter;
- if (new_filter)
- {
- new_width = new_filter->width;
- new_height = new_filter->height;
- }
- }
+ if (transform) {
+ if (transform->nparams) {
+ new_params = malloc(transform->nparams * sizeof(xFixed));
+ if (new_params) {
+ memcpy(new_params, transform->params,
+ transform->nparams * sizeof(xFixed));
+ new_nparams = transform->nparams;
+ new_filter = transform->filter;
+ }
+ }
+ else
+ new_filter = transform->filter;
+ if (new_filter) {
+ new_width = new_filter->width;
+ new_height = new_filter->height;
+ }
+ }
#endif
- crtc->transform_in_use = TRUE;
+ crtc->transform_in_use = TRUE;
}
crtc->crtc_to_framebuffer = crtc_to_fb;
crtc->f_crtc_to_framebuffer = f_crtc_to_fb;
@@ -522,10 +502,10 @@ xf86CrtcRotate (xf86CrtcPtr crtc)
crtc->bounds.x2 = crtc->mode.HDisplay;
crtc->bounds.y1 = 0;
crtc->bounds.y2 = crtc->mode.VDisplay;
- pixman_f_transform_bounds (&f_crtc_to_fb, &crtc->bounds);
+ pixman_f_transform_bounds(&f_crtc_to_fb, &crtc->bounds);
if (damage)
- xf86CrtcDamageShadow (crtc);
+ xf86CrtcDamageShadow(crtc);
/* All done */
return TRUE;
diff --git a/xorg-server/hw/xfree86/modes/xf86cvt.c b/xorg-server/hw/xfree86/modes/xf86cvt.c
index d5fecccb5..de0784493 100644
--- a/xorg-server/hw/xfree86/modes/xf86cvt.c
+++ b/xorg-server/hw/xfree86/modes/xf86cvt.c
@@ -65,12 +65,12 @@
*/
DisplayModePtr
xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
- Bool Interlaced)
+ Bool Interlaced)
{
- DisplayModeRec *Mode = xnfcalloc(1, sizeof(DisplayModeRec));
+ DisplayModeRec *Mode = xnfcalloc(1, sizeof(DisplayModeRec));
/* 1) top/bottom margin size (% of height) - default: 1.8 */
-#define CVT_MARGIN_PERCENTAGE 1.8
+#define CVT_MARGIN_PERCENTAGE 1.8
/* 2) character cell horizontal granularity (pixels) - default 8 */
#define CVT_H_GRANULARITY 8
@@ -85,10 +85,10 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
#define CVT_CLOCK_STEP 250
Bool Margins = FALSE;
- float VFieldRate, HPeriod;
- int HDisplayRnd, HMargin;
- int VDisplayRnd, VMargin, VSync;
- float Interlace; /* Please rename this */
+ float VFieldRate, HPeriod;
+ int HDisplayRnd, HMargin;
+ int VDisplayRnd, VMargin, VSync;
+ float Interlace; /* Please rename this */
/* CVT default is 60.0Hz */
if (!VRefresh)
@@ -108,11 +108,12 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
/* right margin is actually exactly the same as left */
HMargin = (((float) HDisplayRnd) * CVT_MARGIN_PERCENTAGE / 100.0);
HMargin -= HMargin % CVT_H_GRANULARITY;
- } else
+ }
+ else
HMargin = 0;
/* 4. Find total active pixels */
- Mode->HDisplay = HDisplayRnd + 2*HMargin;
+ Mode->HDisplay = HDisplayRnd + 2 * HMargin;
/* 5. Find number of lines per field */
if (Interlaced)
@@ -128,7 +129,7 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
else
VMargin = 0;
- Mode->VDisplay = VDisplay + 2*VMargin;
+ Mode->VDisplay = VDisplay + 2 * VMargin;
/* 7. Interlace */
if (Interlaced)
@@ -147,10 +148,10 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
VSync = 7;
else if (!(VDisplay % 9) && ((VDisplay * 15 / 9) == HDisplay))
VSync = 7;
- else /* Custom */
+ else /* Custom */
VSync = 10;
- if (!Reduced) { /* simplified GTF calculation */
+ if (!Reduced) { /* simplified GTF calculation */
/* 4) Minimum time of vertical sync + back porch interval (µs)
* default 550.0 */
@@ -159,19 +160,20 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
/* 3) Nominal HSync width (% of line period) - default 8 */
#define CVT_HSYNC_PERCENTAGE 8
- float HBlankPercentage;
- int VSyncAndBackPorch, VBackPorch;
- int HBlank;
+ float HBlankPercentage;
+ int VSyncAndBackPorch, VBackPorch;
+ int HBlank;
/* 8. Estimated Horizontal period */
- HPeriod = ((float) (1000000.0 / VFieldRate - CVT_MIN_VSYNC_BP)) /
+ HPeriod = ((float) (1000000.0 / VFieldRate - CVT_MIN_VSYNC_BP)) /
(VDisplayRnd + 2 * VMargin + CVT_MIN_V_PORCH + Interlace);
/* 9. Find number of lines in sync + backporch */
- if (((int)(CVT_MIN_VSYNC_BP / HPeriod) + 1) < (VSync + CVT_MIN_V_PORCH))
+ if (((int) (CVT_MIN_VSYNC_BP / HPeriod) + 1) <
+ (VSync + CVT_MIN_V_PORCH))
VSyncAndBackPorch = VSync + CVT_MIN_V_PORCH;
else
- VSyncAndBackPorch = (int)(CVT_MIN_VSYNC_BP / HPeriod) + 1;
+ VSyncAndBackPorch = (int) (CVT_MIN_VSYNC_BP / HPeriod) + 1;
/* 10. Find number of lines in back porch */
VBackPorch = VSyncAndBackPorch - VSync;
@@ -198,31 +200,32 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
CVT_J_FACTOR
/* 12. Find ideal blanking duty cycle from formula */
- HBlankPercentage = CVT_C_PRIME - CVT_M_PRIME * HPeriod/1000.0;
+ HBlankPercentage = CVT_C_PRIME - CVT_M_PRIME * HPeriod / 1000.0;
/* 13. Blanking time */
if (HBlankPercentage < 20)
HBlankPercentage = 20;
- HBlank = Mode->HDisplay * HBlankPercentage/(100.0 - HBlankPercentage);
- HBlank -= HBlank % (2*CVT_H_GRANULARITY);
-
+ HBlank = Mode->HDisplay * HBlankPercentage / (100.0 - HBlankPercentage);
+ HBlank -= HBlank % (2 * CVT_H_GRANULARITY);
+
/* 14. Find total number of pixels in a line. */
Mode->HTotal = Mode->HDisplay + HBlank;
/* Fill in HSync values */
Mode->HSyncEnd = Mode->HDisplay + HBlank / 2;
- Mode->HSyncStart = Mode->HSyncEnd -
+ Mode->HSyncStart = Mode->HSyncEnd -
(Mode->HTotal * CVT_HSYNC_PERCENTAGE) / 100;
- Mode->HSyncStart += CVT_H_GRANULARITY -
+ Mode->HSyncStart += CVT_H_GRANULARITY -
Mode->HSyncStart % CVT_H_GRANULARITY;
/* Fill in VSync values */
Mode->VSyncStart = Mode->VDisplay + CVT_MIN_V_PORCH;
Mode->VSyncEnd = Mode->VSyncStart + VSync;
- } else { /* Reduced blanking */
+ }
+ else { /* Reduced blanking */
/* Minimum vertical blanking interval time (µs) - default 460 */
#define CVT_RB_MIN_VBLANK 460.0
@@ -235,11 +238,11 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
/* Fixed number of lines for vertical front porch - default 3 */
#define CVT_RB_VFPORCH 3
- int VBILines;
+ int VBILines;
/* 8. Estimate Horizontal period. */
- HPeriod = ((float) (1000000.0 / VFieldRate - CVT_RB_MIN_VBLANK)) /
- (VDisplayRnd + 2*VMargin);
+ HPeriod = ((float) (1000000.0 / VFieldRate - CVT_RB_MIN_VBLANK)) /
+ (VDisplayRnd + 2 * VMargin);
/* 9. Find number of lines in vertical blanking */
VBILines = ((float) CVT_RB_MIN_VBLANK) / HPeriod + 1;
@@ -247,7 +250,7 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
/* 10. Check if vertical blanking is sufficient */
if (VBILines < (CVT_RB_VFPORCH + VSync + CVT_MIN_V_BPORCH))
VBILines = CVT_RB_VFPORCH + VSync + CVT_MIN_V_BPORCH;
-
+
/* 11. Find total number of lines in vertical field */
Mode->VTotal = VDisplayRnd + 2 * VMargin + Interlace + VBILines;
@@ -271,7 +274,7 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
Mode->HSync = ((float) Mode->Clock) / ((float) Mode->HTotal);
/* 17/15. Find actual Field rate */
- Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) /
+ Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) /
((float) (Mode->HTotal * Mode->VTotal));
/* 18/16. Find actual vertical frame frequency */
diff --git a/xorg-server/hw/xfree86/modes/xf86gtf.c b/xorg-server/hw/xfree86/modes/xf86gtf.c
index 9d5d50a2d..23707b481 100644
--- a/xorg-server/hw/xfree86/modes/xf86gtf.c
+++ b/xorg-server/hw/xfree86/modes/xf86gtf.c
@@ -61,7 +61,7 @@
/* Ruthlessly converted to server code by Adam Jackson <ajax@redhat.com> */
#ifdef HAVE_XORG_CONFIG_H
-# include <xorg-config.h>
+#include <xorg-config.h>
#else
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -88,7 +88,6 @@
#define C_PRIME (((C - J) * K/256.0) + J)
#define M_PRIME (K/256.0 * M)
-
/*
* xf86GTFMode() - as defined by the GTF Timing Standard, compute the
* Stage 1 Parameters using the vertical refresh frequency. In other
@@ -141,9 +140,9 @@ xf86GTFMode(int h_pixels, int v_lines, float freq, int interlaced, int margins)
*
* [H PIXELS RND] = ((ROUND([H PIXELS]/[CELL GRAN RND],0))*[CELLGRAN RND])
*/
-
+
h_pixels_rnd = rint((float) h_pixels / CELL_GRAN) * CELL_GRAN;
-
+
/* 2. If interlace is requested, the number of vertical lines assumed
* by the calculation must be halved, as the computation calculates
* the number of vertical lines per field. In either case, the
@@ -154,9 +153,8 @@ xf86GTFMode(int h_pixels, int v_lines, float freq, int interlaced, int margins)
*/
v_lines_rnd = interlaced ?
- rint((float) v_lines) / 2.0 :
- rint((float) v_lines);
-
+ rint((float) v_lines) / 2.0 : rint((float) v_lines);
+
/* 3. Find the frame rate required:
*
* [V FIELD RATE RQD] = IF([INT RQD?]="y", [I/P FREQ RQD]*2,
@@ -181,7 +179,8 @@ xf86GTFMode(int h_pixels, int v_lines, float freq, int interlaced, int margins)
* 0)
*/
- bottom_margin = margins ? rint(MARGIN_PERCENT/100.0 * v_lines_rnd) : (0.0);
+ bottom_margin =
+ margins ? rint(MARGIN_PERCENT / 100.0 * v_lines_rnd) : (0.0);
/* 6. If interlace is required, then set variable [INTERLACE]=0.5:
*
@@ -197,8 +196,8 @@ xf86GTFMode(int h_pixels, int v_lines, float freq, int interlaced, int margins)
* [MIN PORCH RND]+[INTERLACE]) * 1000000
*/
- h_period_est = (((1.0/v_field_rate_rqd) - (MIN_VSYNC_PLUS_BP/1000000.0))
- / (v_lines_rnd + (2*top_margin) + MIN_PORCH + interlace)
+ h_period_est = (((1.0 / v_field_rate_rqd) - (MIN_VSYNC_PLUS_BP / 1000000.0))
+ / (v_lines_rnd + (2 * top_margin) + MIN_PORCH + interlace)
* 1000000.0);
/* 8. Find the number of lines in V sync + back porch:
@@ -206,7 +205,7 @@ xf86GTFMode(int h_pixels, int v_lines, float freq, int interlaced, int margins)
* [V SYNC+BP] = ROUND(([MIN VSYNC+BP]/[H PERIOD EST]),0)
*/
- vsync_plus_bp = rint(MIN_VSYNC_PLUS_BP/h_period_est);
+ vsync_plus_bp = rint(MIN_VSYNC_PLUS_BP / h_period_est);
/* 9. Find the number of lines in V back porch alone:
*
@@ -214,9 +213,9 @@ xf86GTFMode(int h_pixels, int v_lines, float freq, int interlaced, int margins)
*
* XXX is "[V SYNC RND]" a typo? should be [V SYNC RQD]?
*/
-
+
v_back_porch = vsync_plus_bp - V_SYNC_RQD;
-
+
/* 10. Find the total number of lines in Vertical field period:
*
* [TOTAL V LINES] = [V LINES RND] + [TOP MARGIN (LINES)] +
@@ -226,21 +225,21 @@ xf86GTFMode(int h_pixels, int v_lines, float freq, int interlaced, int margins)
total_v_lines = v_lines_rnd + top_margin + bottom_margin + vsync_plus_bp +
interlace + MIN_PORCH;
-
+
/* 11. Estimate the Vertical field frequency:
*
* [V FIELD RATE EST] = 1 / [H PERIOD EST] / [TOTAL V LINES] * 1000000
*/
v_field_rate_est = 1.0 / h_period_est / total_v_lines * 1000000.0;
-
+
/* 12. Find the actual horizontal period:
*
* [H PERIOD] = [H PERIOD EST] / ([V FIELD RATE RQD] / [V FIELD RATE EST])
*/
h_period = h_period_est / (v_field_rate_rqd / v_field_rate_est);
-
+
/* 13. Find the actual Vertical field frequency:
*
* [V FIELD RATE] = 1 / [H PERIOD] / [TOTAL V LINES] * 1000000
@@ -266,7 +265,7 @@ xf86GTFMode(int h_pixels, int v_lines, float freq, int interlaced, int margins)
left_margin = margins ?
rint(h_pixels_rnd * MARGIN_PERCENT / 100.0 / CELL_GRAN) * CELL_GRAN :
0.0;
-
+
/* 16. Find number of pixels in right margin:
*
* [RIGHT MARGIN (PIXELS)] = (IF( [MARGINS RQD?]="Y",
@@ -274,11 +273,11 @@ xf86GTFMode(int h_pixels, int v_lines, float freq, int interlaced, int margins)
* [CELL GRAN RND]),0)) * [CELL GRAN RND],
* 0))
*/
-
+
right_margin = margins ?
rint(h_pixels_rnd * MARGIN_PERCENT / 100.0 / CELL_GRAN) * CELL_GRAN :
0.0;
-
+
/* 17. Find total number of active pixels in image and left and right
* margins:
*
@@ -287,7 +286,7 @@ xf86GTFMode(int h_pixels, int v_lines, float freq, int interlaced, int margins)
*/
total_active_pixels = h_pixels_rnd + left_margin + right_margin;
-
+
/* 18. Find the ideal blanking duty cycle from the blanking duty cycle
* equation:
*
@@ -295,7 +294,7 @@ xf86GTFMode(int h_pixels, int v_lines, float freq, int interlaced, int margins)
*/
ideal_duty_cycle = C_PRIME - (M_PRIME * h_period / 1000.0);
-
+
/* 19. Find the number of pixels in the blanking time to the nearest
* double character cell:
*
@@ -310,34 +309,32 @@ xf86GTFMode(int h_pixels, int v_lines, float freq, int interlaced, int margins)
ideal_duty_cycle /
(100.0 - ideal_duty_cycle) /
(2.0 * CELL_GRAN)) * (2.0 * CELL_GRAN);
-
+
/* 20. Find total number of pixels:
*
* [TOTAL PIXELS] = [TOTAL ACTIVE PIXELS] + [H BLANK (PIXELS)]
*/
total_pixels = total_active_pixels + h_blank;
-
+
/* 21. Find pixel clock frequency:
*
* [PIXEL FREQ] = [TOTAL PIXELS] / [H PERIOD]
*/
-
+
pixel_freq = total_pixels / h_period;
-
+
/* 22. Find horizontal frequency:
*
* [H FREQ] = 1000 / [H PERIOD]
*/
h_freq = 1000.0 / h_period;
-
/* Stage 1 computations are now complete; I should really pass
the results to another function and do the Stage 2
computations, but I only need a few more values so I'll just
append the computations here for now */
-
/* 17. Find the number of pixels in the horizontal sync period:
*
@@ -345,7 +342,8 @@ xf86GTFMode(int h_pixels, int v_lines, float freq, int interlaced, int margins)
* [CELL GRAN RND]),0))*[CELL GRAN RND]
*/
- h_sync = rint(H_SYNC_PERCENT/100.0 * total_pixels / CELL_GRAN) * CELL_GRAN;
+ h_sync =
+ rint(H_SYNC_PERCENT / 100.0 * total_pixels / CELL_GRAN) * CELL_GRAN;
/* 18. Find the number of pixels in the horizontal front porch period:
*
@@ -358,30 +356,30 @@ xf86GTFMode(int h_pixels, int v_lines, float freq, int interlaced, int margins)
*
* [V ODD FRONT PORCH(LINES)]=([MIN PORCH RND]+[INTERLACE])
*/
-
+
v_odd_front_porch_lines = MIN_PORCH + interlace;
-
+
/* finally, pack the results in the mode struct */
- mode->HDisplay = (int) (h_pixels_rnd);
- mode->HSyncStart = (int) (h_pixels_rnd + h_front_porch);
- mode->HSyncEnd = (int) (h_pixels_rnd + h_front_porch + h_sync);
- mode->HTotal = (int) (total_pixels);
- mode->VDisplay = (int) (v_lines_rnd);
- mode->VSyncStart = (int) (v_lines_rnd + v_odd_front_porch_lines);
- mode->VSyncEnd = (int) (v_lines_rnd + v_odd_front_porch_lines + V_SYNC_RQD);
- mode->VTotal = (int) (total_v_lines);
+ mode->HDisplay = (int) (h_pixels_rnd);
+ mode->HSyncStart = (int) (h_pixels_rnd + h_front_porch);
+ mode->HSyncEnd = (int) (h_pixels_rnd + h_front_porch + h_sync);
+ mode->HTotal = (int) (total_pixels);
+ mode->VDisplay = (int) (v_lines_rnd);
+ mode->VSyncStart = (int) (v_lines_rnd + v_odd_front_porch_lines);
+ mode->VSyncEnd = (int) (v_lines_rnd + v_odd_front_porch_lines + V_SYNC_RQD);
+ mode->VTotal = (int) (total_v_lines);
- mode->Clock = (int) (pixel_freq * 1000.0);
- mode->HSync = h_freq;
- mode->VRefresh = freq;
+ mode->Clock = (int) (pixel_freq * 1000.0);
+ mode->HSync = h_freq;
+ mode->VRefresh = freq;
xf86SetModeDefaultName(mode);
mode->Flags = V_NHSYNC | V_PVSYNC;
if (interlaced) {
- mode->VTotal *= 2;
- mode->Flags |= V_INTERLACE;
+ mode->VTotal *= 2;
+ mode->Flags |= V_INTERLACE;
}
return mode;
diff --git a/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c b/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c
index 882fb3b46..91f9fc826 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c
@@ -65,21 +65,21 @@ memory_base(void)
static unsigned long base = 0;
if (base == 0) {
- size_t len = sizeof(base);
- int error;
+ size_t len = sizeof(base);
+ int error;
+
#ifdef __OpenBSD__
- int mib[3];
+ int mib[3];
- mib[0] = CTL_MACHDEP;
- mib[1] = CPU_CHIPSET;
- mib[2] = CPU_CHIPSET_MEM;
+ mib[0] = CTL_MACHDEP;
+ mib[1] = CPU_CHIPSET;
+ mib[2] = CPU_CHIPSET_MEM;
- if ((error = sysctl(mib, 3, &base, &len, NULL, 0)) < 0)
+ if ((error = sysctl(mib, 3, &base, &len, NULL, 0)) < 0)
#else
- if ((error = sysctlbyname("hw.chipset.memory", &base, &len,
- 0, 0)) < 0)
+ if ((error = sysctlbyname("hw.chipset.memory", &base, &len, 0, 0)) < 0)
#endif
- FatalError("xf86MapVidMem: can't find memory\n");
+ FatalError("xf86MapVidMem: can't find memory\n");
}
return base;
@@ -91,6 +91,7 @@ has_bwx(void)
static int bwx = 0;
size_t len = sizeof(bwx);
int error;
+
#ifdef __OpenBSD__
int mib[3];
@@ -99,76 +100,74 @@ has_bwx(void)
mib[2] = CPU_CHIPSET_BWX;
if ((error = sysctl(mib, 3, &bwx, &len, NULL, 0)) < 0)
- return FALSE;
+ return FALSE;
else
- return bwx;
+ return bwx;
#else
if ((error = sysctlbyname("hw.chipset.bwx", &bwx, &len, 0, 0)) < 0)
- return FALSE;
+ return FALSE;
else
- return bwx;
+ return bwx;
#endif
}
-#else /* __NetBSD__ */
+#else /* __NetBSD__ */
static unsigned long hae_thresh = (1UL << 24);
-static unsigned long hae_mask = 0xf8000000UL; /* XXX - should use xf86AXP.c */
+static unsigned long hae_mask = 0xf8000000UL; /* XXX - should use xf86AXP.c */
static struct alpha_bus_window *abw;
static int abw_count = -1;
static void
init_abw(void)
{
- if (abw_count < 0) {
- abw_count = alpha_bus_getwindows(ALPHA_BUS_TYPE_PCI_MEM, &abw);
- if (abw_count <= 0)
- FatalError("init_abw: alpha_bus_getwindows failed\n");
- }
+ if (abw_count < 0) {
+ abw_count = alpha_bus_getwindows(ALPHA_BUS_TYPE_PCI_MEM, &abw);
+ if (abw_count <= 0)
+ FatalError("init_abw: alpha_bus_getwindows failed\n");
+ }
}
static int
has_bwx(void)
{
- if (abw_count < 0)
- init_abw();
+ if (abw_count < 0)
+ init_abw();
- xf86Msg(X_INFO, "has_bwx = %d\n",
- abw[0].abw_abst.abst_flags & ABST_BWX ? 1 : 0); /* XXXX */
- return abw[0].abw_abst.abst_flags & ABST_BWX;
+ xf86Msg(X_INFO, "has_bwx = %d\n", abw[0].abw_abst.abst_flags & ABST_BWX ? 1 : 0); /* XXXX */
+ return abw[0].abw_abst.abst_flags & ABST_BWX;
}
static unsigned long
dense_base(void)
{
- if (abw_count < 0)
- init_abw();
+ if (abw_count < 0)
+ init_abw();
- /* XXX check abst_flags for ABST_DENSE just to be safe? */
- xf86Msg(X_INFO, "dense base = %#lx\n",
- abw[0].abw_abst.abst_sys_start); /* XXXX */
- return abw[0].abw_abst.abst_sys_start;
+ /* XXX check abst_flags for ABST_DENSE just to be safe? */
+ xf86Msg(X_INFO, "dense base = %#lx\n", abw[0].abw_abst.abst_sys_start); /* XXXX */
+ return abw[0].abw_abst.abst_sys_start;
}
static unsigned long
memory_base(void)
{
- if (abw_count < 0)
- init_abw();
-
- if (abw_count > 1) {
- xf86Msg(X_INFO, "memory base = %#lx\n",
- abw[1].abw_abst.abst_sys_start); /* XXXX */
- return abw[1].abw_abst.abst_sys_start;
- } else if (abw_count == 1) {
- /* assume memory_base == dense_base */
- xf86Msg(X_INFO, "memory base = %#lx\n",
- abw[0].abw_abst.abst_sys_start); /* XXXX */
- return abw[0].abw_abst.abst_sys_start;
- } else {
- xf86Msg(X_INFO, "no memory base\n"); /* XXXX */
- return 0;
- }
+ if (abw_count < 0)
+ init_abw();
+
+ if (abw_count > 1) {
+ xf86Msg(X_INFO, "memory base = %#lx\n", abw[1].abw_abst.abst_sys_start); /* XXXX */
+ return abw[1].abw_abst.abst_sys_start;
+ }
+ else if (abw_count == 1) {
+ /* assume memory_base == dense_base */
+ xf86Msg(X_INFO, "memory base = %#lx\n", abw[0].abw_abst.abst_sys_start); /* XXXX */
+ return abw[0].abw_abst.abst_sys_start;
+ }
+ else {
+ xf86Msg(X_INFO, "no memory base\n"); /* XXXX */
+ return 0;
+ }
}
-#endif /* __NetBSD__ */
+#endif /* __NetBSD__ */
#define BUS_BASE dense_base()
#define BUS_BASE_BWX memory_base()
@@ -184,7 +183,7 @@ memory_base(void)
#endif
static Bool useDevMem = FALSE;
-static int devMemFd = -1;
+static int devMemFd = -1;
#ifdef HAS_APERTURE_DRV
#define DEV_APERTURE "/dev/xf86"
@@ -202,148 +201,144 @@ static void unmapVidMemSparse(int, pointer, unsigned long);
static void
checkDevMem(Bool warn)
{
- static Bool devMemChecked = FALSE;
- int fd;
- pointer base;
+ static Bool devMemChecked = FALSE;
+ int fd;
+ pointer base;
- if (devMemChecked)
- return;
- devMemChecked = TRUE;
+ if (devMemChecked)
+ return;
+ devMemChecked = TRUE;
#ifdef HAS_APERTURE_DRV
- /* Try the aperture driver first */
- if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0) {
- /* Try to map a page at the VGA address */
- base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
- MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE);
-
- if (base != MAP_FAILED) {
- munmap((caddr_t)base, 4096);
- devMemFd = fd;
- useDevMem = TRUE;
- xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n",
- DEV_APERTURE);
- return;
- } else {
- if (warn) {
- xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
- DEV_APERTURE, strerror(errno));
- }
- }
- }
+ /* Try the aperture driver first */
+ if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0) {
+ /* Try to map a page at the VGA address */
+ base = mmap((caddr_t) 0, 4096, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t) 0xA0000 + BUS_BASE);
+
+ if (base != MAP_FAILED) {
+ munmap((caddr_t) base, 4096);
+ devMemFd = fd;
+ useDevMem = TRUE;
+ xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n",
+ DEV_APERTURE);
+ return;
+ }
+ else {
+ if (warn) {
+ xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
+ DEV_APERTURE, strerror(errno));
+ }
+ }
+ }
#endif
- if ((fd = open(DEV_MEM, O_RDWR)) >= 0) {
- /* Try to map a page at the VGA address */
- base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
- MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE);
-
- if (base != MAP_FAILED) {
- munmap((caddr_t)base, 4096);
- devMemFd = fd;
- useDevMem = TRUE;
- return;
- } else {
- if (warn) {
- xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
- DEV_MEM, strerror(errno));
- }
- }
- }
- if (warn) {
+ if ((fd = open(DEV_MEM, O_RDWR)) >= 0) {
+ /* Try to map a page at the VGA address */
+ base = mmap((caddr_t) 0, 4096, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t) 0xA0000 + BUS_BASE);
+
+ if (base != MAP_FAILED) {
+ munmap((caddr_t) base, 4096);
+ devMemFd = fd;
+ useDevMem = TRUE;
+ return;
+ }
+ else {
+ if (warn) {
+ xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ }
+ }
+ if (warn) {
#ifndef HAS_APERTURE_DRV
- xf86Msg(X_WARNING, "checkDevMem: failed to open/mmap %s (%s)\n",
- DEV_MEM, strerror(errno));
+ xf86Msg(X_WARNING, "checkDevMem: failed to open/mmap %s (%s)\n",
+ DEV_MEM, strerror(errno));
#else
#ifndef __OpenBSD__
- xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
- "\t(%s)\n", DEV_APERTURE, DEV_MEM, strerror(errno));
-#else /* __OpenBSD__ */
- xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
- "\t(%s)\n%s", DEV_APERTURE, DEV_MEM, strerror(errno),
- SYSCTL_MSG);
-#endif /* __OpenBSD__ */
+ xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
+ "\t(%s)\n", DEV_APERTURE, DEV_MEM, strerror(errno));
+#else /* __OpenBSD__ */
+ xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
+ "\t(%s)\n%s", DEV_APERTURE, DEV_MEM, strerror(errno),
+ SYSCTL_MSG);
+#endif /* __OpenBSD__ */
#endif
- xf86ErrorF("\tlinear framebuffer access unavailable\n");
- }
- useDevMem = FALSE;
- return;
+ xf86ErrorF("\tlinear framebuffer access unavailable\n");
+ }
+ useDevMem = FALSE;
+ return;
}
void
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
- checkDevMem(TRUE);
- pVidMem->linearSupported = useDevMem;
-
- if (has_bwx()) {
- xf86Msg(X_PROBED,"Machine type has 8/16 bit access\n");
- pVidMem->mapMem = mapVidMem;
- pVidMem->unmapMem = unmapVidMem;
- } else {
- xf86Msg(X_PROBED,"Machine needs sparse mapping\n");
- pVidMem->mapMem = mapVidMemSparse;
- pVidMem->unmapMem = unmapVidMemSparse;
+ checkDevMem(TRUE);
+ pVidMem->linearSupported = useDevMem;
+
+ if (has_bwx()) {
+ xf86Msg(X_PROBED, "Machine type has 8/16 bit access\n");
+ pVidMem->mapMem = mapVidMem;
+ pVidMem->unmapMem = unmapVidMem;
+ }
+ else {
+ xf86Msg(X_PROBED, "Machine needs sparse mapping\n");
+ pVidMem->mapMem = mapVidMemSparse;
+ pVidMem->unmapMem = unmapVidMemSparse;
#ifndef __NetBSD__
- if (axpSystem == -1)
- axpSystem = bsdGetAXP();
- hae_thresh = xf86AXPParams[axpSystem].hae_thresh;
- hae_mask = xf86AXPParams[axpSystem].hae_mask;
-#endif /* __NetBSD__ */
- }
- pVidMem->initialised = TRUE;
+ if (axpSystem == -1)
+ axpSystem = bsdGetAXP();
+ hae_thresh = xf86AXPParams[axpSystem].hae_thresh;
+ hae_mask = xf86AXPParams[axpSystem].hae_mask;
+#endif /* __NetBSD__ */
+ }
+ pVidMem->initialised = TRUE;
}
static pointer
mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
{
- pointer base;
-
- checkDevMem(FALSE);
- Base = Base & ((1L<<32) - 1);
-
- if (useDevMem)
- {
- if (devMemFd < 0)
- {
- FatalError("xf86MapVidMem: failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- }
- base = mmap((caddr_t)0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX);
- if (base == MAP_FAILED)
- {
- FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)\n",
- "xf86MapVidMem", DEV_MEM, Size, Base,
- strerror(errno));
- }
- return base;
- }
-
- /* else, mmap /dev/vga */
- if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000)
- {
- FatalError("%s: Address 0x%lx outside allowable range\n",
- "xf86MapVidMem", Base);
- }
- base = mmap(0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_FLAGS, xf86Info.consoleFd,
- (unsigned long)Base + BUS_BASE);
- if (base == MAP_FAILED)
- {
- FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n",
- strerror(errno));
- }
- return base;
+ pointer base;
+
+ checkDevMem(FALSE);
+ Base = Base & ((1L << 32) - 1);
+
+ if (useDevMem) {
+ if (devMemFd < 0) {
+ FatalError("xf86MapVidMem: failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ base = mmap((caddr_t) 0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FLAGS, devMemFd, (off_t) Base + BUS_BASE_BWX);
+ if (base == MAP_FAILED) {
+ FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)\n",
+ "xf86MapVidMem", DEV_MEM, Size, Base, strerror(errno));
+ }
+ return base;
+ }
+
+ /* else, mmap /dev/vga */
+ if ((unsigned long) Base < 0xA0000 || (unsigned long) Base >= 0xC0000) {
+ FatalError("%s: Address 0x%lx outside allowable range\n",
+ "xf86MapVidMem", Base);
+ }
+ base = mmap(0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FLAGS, xf86Info.consoleFd, (unsigned long) Base + BUS_BASE);
+ if (base == MAP_FAILED) {
+ FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n",
+ strerror(errno));
+ }
+ return base;
}
static void
unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
{
- munmap((caddr_t)Base, Size);
+ munmap((caddr_t) Base, Size);
}
/*
@@ -352,45 +347,44 @@ unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
int
xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
+ int Len)
{
- unsigned char *ptr;
- int psize;
- int mlen;
-
- checkDevMem(TRUE);
- if (devMemFd == -1) {
- return -1;
- }
-
- psize = getpagesize();
- Offset += Base & (psize - 1);
- Base &= ~(psize - 1);
- mlen = (Offset + Len + psize - 1) & ~(psize - 1);
- ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
- MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE);
- if ((long)ptr == -1)
- {
- xf86Msg(X_WARNING,
- "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n",
- DEV_MEM, Len, Base, Offset, strerror(errno));
- return -1;
- }
+ unsigned char *ptr;
+ int psize;
+ int mlen;
+
+ checkDevMem(TRUE);
+ if (devMemFd == -1) {
+ return -1;
+ }
+
+ psize = getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+ ptr = (unsigned char *) mmap((caddr_t) 0, mlen, PROT_READ,
+ MAP_SHARED, devMemFd, (off_t) Base + BUS_BASE);
+ if ((long) ptr == -1) {
+ xf86Msg(X_WARNING,
+ "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n",
+ DEV_MEM, Len, Base, Offset, strerror(errno));
+ return -1;
+ }
#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
- Base, ptr[0] | (ptr[1] << 8));
+ xf86MsgVerb(X_INFO, 3,
+ "xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", Base,
+ ptr[0] | (ptr[1] << 8));
#endif
- (void)memcpy(Buf, (void *)(ptr + Offset), Len);
- (void)munmap((caddr_t)ptr, mlen);
+ (void) memcpy(Buf, (void *) (ptr + Offset), Len);
+ (void) munmap((caddr_t) ptr, mlen);
#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
- "-> %02x %02x %02x %02x...\n",
- Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
+ xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
+ "-> %02x %02x %02x %02x...\n",
+ Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
#endif
- return Len;
+ return Len;
}
-
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
extern int ioperm(unsigned long from, unsigned long num, int on);
@@ -399,34 +393,34 @@ Bool
xf86EnableIO()
{
if (!ioperm(0, 65536, TRUE))
- return TRUE;
+ return TRUE;
return FALSE;
}
void
xf86DisableIO()
{
- return;
+ return;
}
-#endif /* __FreeBSD_kernel__ || __OpenBSD__ */
+#endif /* __FreeBSD_kernel__ || __OpenBSD__ */
#ifdef USE_ALPHA_PIO
Bool
xf86EnableIO()
{
- alpha_pci_io_enable(1);
- return TRUE;
+ alpha_pci_io_enable(1);
+ return TRUE;
}
void
xf86DisableIO()
{
- alpha_pci_io_enable(0);
+ alpha_pci_io_enable(0);
}
-#endif /* USE_ALPHA_PIO */
+#endif /* USE_ALPHA_PIO */
#define vuip volatile unsigned int *
@@ -437,39 +431,39 @@ extern int readDense8(pointer Base, register unsigned long Offset);
extern int readDense16(pointer Base, register unsigned long Offset);
extern int readDense32(pointer Base, register unsigned long Offset);
extern void
-writeDenseNB8(int Value, pointer Base, register unsigned long Offset);
+ writeDenseNB8(int Value, pointer Base, register unsigned long Offset);
extern void
-writeDenseNB16(int Value, pointer Base, register unsigned long Offset);
+ writeDenseNB16(int Value, pointer Base, register unsigned long Offset);
extern void
-writeDenseNB32(int Value, pointer Base, register unsigned long Offset);
+ writeDenseNB32(int Value, pointer Base, register unsigned long Offset);
extern void
-writeDense8(int Value, pointer Base, register unsigned long Offset);
+ writeDense8(int Value, pointer Base, register unsigned long Offset);
extern void
-writeDense16(int Value, pointer Base, register unsigned long Offset);
+ writeDense16(int Value, pointer Base, register unsigned long Offset);
extern void
-writeDense32(int Value, pointer Base, register unsigned long Offset);
+ writeDense32(int Value, pointer Base, register unsigned long Offset);
static int readSparse8(pointer Base, register unsigned long Offset);
static int readSparse16(pointer Base, register unsigned long Offset);
static int readSparse32(pointer Base, register unsigned long Offset);
static void
-writeSparseNB8(int Value, pointer Base, register unsigned long Offset);
+ writeSparseNB8(int Value, pointer Base, register unsigned long Offset);
static void
-writeSparseNB16(int Value, pointer Base, register unsigned long Offset);
+ writeSparseNB16(int Value, pointer Base, register unsigned long Offset);
static void
-writeSparseNB32(int Value, pointer Base, register unsigned long Offset);
+ writeSparseNB32(int Value, pointer Base, register unsigned long Offset);
static void
-writeSparse8(int Value, pointer Base, register unsigned long Offset);
+ writeSparse8(int Value, pointer Base, register unsigned long Offset);
static void
-writeSparse16(int Value, pointer Base, register unsigned long Offset);
+ writeSparse16(int Value, pointer Base, register unsigned long Offset);
static void
-writeSparse32(int Value, pointer Base, register unsigned long Offset);
+ writeSparse32(int Value, pointer Base, register unsigned long Offset);
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
extern int sysarch(int, void *);
struct parms {
- u_int64_t hae;
+ u_int64_t hae;
};
static void
@@ -478,50 +472,49 @@ sethae(u_int64_t hae)
#ifndef ALPHA_SETHAE
#define ALPHA_SETHAE 0
#endif
- static struct parms p;
+ static struct parms p;
- if (p.hae != hae) {
- p.hae = hae;
- sysarch(ALPHA_SETHAE, (char *)&p);
- }
+ if (p.hae != hae) {
+ p.hae = hae;
+ sysarch(ALPHA_SETHAE, (char *) &p);
+ }
}
#endif
static pointer
-mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size,
+ int flags)
{
static Bool was_here = FALSE;
if (!was_here) {
- was_here = TRUE;
-
- checkDevMem(FALSE);
-
- xf86WriteMmio8 = writeSparse8;
- xf86WriteMmio16 = writeSparse16;
- xf86WriteMmio32 = writeSparse32;
- xf86WriteMmioNB8 = writeSparseNB8;
- xf86WriteMmioNB16 = writeSparseNB16;
- xf86WriteMmioNB32 = writeSparseNB32;
- xf86ReadMmio8 = readSparse8;
- xf86ReadMmio16 = readSparse16;
- xf86ReadMmio32 = readSparse32;
-
- memBase = mmap((caddr_t)0, 0x100000000,
- PROT_READ | PROT_WRITE,
- MAP_SHARED, devMemFd,
- (off_t) BUS_BASE);
- memSBase = mmap((caddr_t)0, 0x100000000,
- PROT_READ | PROT_WRITE,
- MAP_SHARED, devMemFd,
- (off_t) BUS_BASE_BWX);
-
- if (memSBase == MAP_FAILED || memBase == MAP_FAILED) {
- FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n",
- strerror(errno));
- }
+ was_here = TRUE;
+
+ checkDevMem(FALSE);
+
+ xf86WriteMmio8 = writeSparse8;
+ xf86WriteMmio16 = writeSparse16;
+ xf86WriteMmio32 = writeSparse32;
+ xf86WriteMmioNB8 = writeSparseNB8;
+ xf86WriteMmioNB16 = writeSparseNB16;
+ xf86WriteMmioNB32 = writeSparseNB32;
+ xf86ReadMmio8 = readSparse8;
+ xf86ReadMmio16 = readSparse16;
+ xf86ReadMmio32 = readSparse32;
+
+ memBase = mmap((caddr_t) 0, 0x100000000,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED, devMemFd, (off_t) BUS_BASE);
+ memSBase = mmap((caddr_t) 0, 0x100000000,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED, devMemFd, (off_t) BUS_BASE_BWX);
+
+ if (memSBase == MAP_FAILED || memBase == MAP_FAILED) {
+ FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n",
+ strerror(errno));
+ }
}
- return (pointer)((unsigned long)memBase + Base);
+ return (pointer) ((unsigned long) memBase + Base);
}
static void
@@ -534,17 +527,18 @@ readSparse8(pointer Base, register unsigned long Offset)
{
register unsigned long result, shift;
register unsigned long msb;
+
mem_barrier();
- Offset += (unsigned long)Base - (unsigned long)memBase;
+ Offset += (unsigned long) Base - (unsigned long) memBase;
shift = (Offset & 0x3) << 3;
- if (Offset >= (hae_thresh)) {
+ if (Offset >= (hae_thresh)) {
msb = Offset & hae_mask;
Offset -= msb;
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
- sethae(msb);
+ sethae(msb);
#endif
- }
- result = *(vuip) ((unsigned long)memSBase + (Offset << 5));
+ }
+ result = *(vuip) ((unsigned long) memSBase + (Offset << 5));
result >>= shift;
return 0xffUL & result;
}
@@ -556,16 +550,17 @@ readSparse16(pointer Base, register unsigned long Offset)
register unsigned long msb;
mem_barrier();
- Offset += (unsigned long)Base - (unsigned long)memBase;
+ Offset += (unsigned long) Base - (unsigned long) memBase;
shift = (Offset & 0x2) << 3;
if (Offset >= (hae_thresh)) {
msb = Offset & hae_mask;
Offset -= msb;
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
- sethae(msb);
+ sethae(msb);
#endif
}
- result = *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2)));
+ result =
+ *(vuip) ((unsigned long) memSBase + (Offset << 5) + (1 << (5 - 2)));
result >>= shift;
return 0xffffUL & result;
}
@@ -574,7 +569,7 @@ static int
readSparse32(pointer Base, register unsigned long Offset)
{
mem_barrier();
- return *(vuip)((unsigned long)Base+(Offset));
+ return *(vuip) ((unsigned long) Base + (Offset));
}
static void
@@ -584,15 +579,15 @@ writeSparse8(int Value, pointer Base, register unsigned long Offset)
register unsigned int b = Value & 0xffU;
write_mem_barrier();
- Offset += (unsigned long)Base - (unsigned long)memBase;
+ Offset += (unsigned long) Base - (unsigned long) memBase;
if (Offset >= (hae_thresh)) {
- msb = Offset & hae_mask;
- Offset -= msb;
+ msb = Offset & hae_mask;
+ Offset -= msb;
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
- sethae(msb);
+ sethae(msb);
#endif
}
- *(vuip) ((unsigned long)memSBase + (Offset << 5)) = b * 0x01010101;
+ *(vuip) ((unsigned long) memSBase + (Offset << 5)) = b * 0x01010101;
}
static void
@@ -602,16 +597,16 @@ writeSparse16(int Value, pointer Base, register unsigned long Offset)
register unsigned int w = Value & 0xffffU;
write_mem_barrier();
- Offset += (unsigned long)Base - (unsigned long)memBase;
+ Offset += (unsigned long) Base - (unsigned long) memBase;
if (Offset >= (hae_thresh)) {
- msb = Offset & hae_mask;
- Offset -= msb;
+ msb = Offset & hae_mask;
+ Offset -= msb;
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
- sethae(msb);
+ sethae(msb);
#endif
}
- *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))) =
- w * 0x00010001;
+ *(vuip) ((unsigned long) memSBase + (Offset << 5) + (1 << (5 - 2))) =
+ w * 0x00010001;
}
@@ -619,7 +614,7 @@ static void
writeSparse32(int Value, pointer Base, register unsigned long Offset)
{
write_mem_barrier();
- *(vuip)((unsigned long)Base + (Offset)) = Value;
+ *(vuip) ((unsigned long) Base + (Offset)) = Value;
return;
}
@@ -629,15 +624,15 @@ writeSparseNB8(int Value, pointer Base, register unsigned long Offset)
register unsigned long msb;
register unsigned int b = Value & 0xffU;
- Offset += (unsigned long)Base - (unsigned long)memBase;
+ Offset += (unsigned long) Base - (unsigned long) memBase;
if (Offset >= (hae_thresh)) {
- msb = Offset & hae_mask;
- Offset -= msb;
+ msb = Offset & hae_mask;
+ Offset -= msb;
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
- sethae(msb);
+ sethae(msb);
#endif
}
- *(vuip) ((unsigned long)memSBase + (Offset << 5)) = b * 0x01010101;
+ *(vuip) ((unsigned long) memSBase + (Offset << 5)) = b * 0x01010101;
}
static void
@@ -646,41 +641,40 @@ writeSparseNB16(int Value, pointer Base, register unsigned long Offset)
register unsigned long msb;
register unsigned int w = Value & 0xffffU;
- Offset += (unsigned long)Base - (unsigned long)memBase;
+ Offset += (unsigned long) Base - (unsigned long) memBase;
if (Offset >= (hae_thresh)) {
- msb = Offset & hae_mask ;
- Offset -= msb;
+ msb = Offset & hae_mask;
+ Offset -= msb;
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
- sethae(msb);
+ sethae(msb);
#endif
}
- *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))) =
- w * 0x00010001;
+ *(vuip) ((unsigned long) memSBase + (Offset << 5) + (1 << (5 - 2))) =
+ w * 0x00010001;
}
static void
writeSparseNB32(int Value, pointer Base, register unsigned long Offset)
{
- *(vuip)((unsigned long)Base + (Offset)) = Value;
+ *(vuip) ((unsigned long) Base + (Offset)) = Value;
return;
}
-void (*xf86WriteMmio8)(int Value, pointer Base, unsigned long Offset)
- = writeDense8;
-void (*xf86WriteMmio16)(int Value, pointer Base, unsigned long Offset)
- = writeDense16;
-void (*xf86WriteMmio32)(int Value, pointer Base, unsigned long Offset)
- = writeDense32;
-void (*xf86WriteMmioNB8)(int Value, pointer Base, unsigned long Offset)
- = writeDenseNB8;
-void (*xf86WriteMmioNB16)(int Value, pointer Base, unsigned long Offset)
- = writeDenseNB16;
-void (*xf86WriteMmioNB32)(int Value, pointer Base, unsigned long Offset)
- = writeDenseNB32;
-int (*xf86ReadMmio8)(pointer Base, unsigned long Offset)
- = readDense8;
-int (*xf86ReadMmio16)(pointer Base, unsigned long Offset)
- = readDense16;
-int (*xf86ReadMmio32)(pointer Base, unsigned long Offset)
- = readDense32;
-
+void (*xf86WriteMmio8) (int Value, pointer Base, unsigned long Offset)
+ = writeDense8;
+void (*xf86WriteMmio16) (int Value, pointer Base, unsigned long Offset)
+ = writeDense16;
+void (*xf86WriteMmio32) (int Value, pointer Base, unsigned long Offset)
+ = writeDense32;
+void (*xf86WriteMmioNB8) (int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB8;
+void (*xf86WriteMmioNB16) (int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB16;
+void (*xf86WriteMmioNB32) (int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB32;
+int (*xf86ReadMmio8) (pointer Base, unsigned long Offset)
+ = readDense8;
+int (*xf86ReadMmio16) (pointer Base, unsigned long Offset)
+ = readDense16;
+int (*xf86ReadMmio32) (pointer Base, unsigned long Offset)
+ = readDense32;
diff --git a/xorg-server/hw/xfree86/os-support/bsd/arm_video.c b/xorg-server/hw/xfree86/os-support/bsd/arm_video.c
index 1de6c87d6..71064af03 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/arm_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/arm_video.c
@@ -68,8 +68,7 @@
#ifdef __arm32__
#include "machine/devmap.h"
-struct memAccess
-{
+struct memAccess {
int ioctl;
struct map_info memInfo;
pointer regionVirtBase;
@@ -82,14 +81,19 @@ static void xf86MapInfoUnmap();
static struct memAccess *checkMapInfo();
extern int vgaPhysLinearBase;
-/* A memAccess structure is needed for each possible region */
-struct memAccess vgaMemInfo = { CONSOLE_GET_MEM_INFO, NULL, NULL,
- FALSE, FALSE };
-struct memAccess linearMemInfo = { CONSOLE_GET_LINEAR_INFO, NULL, NULL,
- FALSE, FALSE };
+/* A memAccess structure is needed for each possible region */
+struct memAccess vgaMemInfo = { CONSOLE_GET_MEM_INFO, NULL, NULL,
+ FALSE, FALSE
+};
+
+struct memAccess linearMemInfo = { CONSOLE_GET_LINEAR_INFO, NULL, NULL,
+ FALSE, FALSE
+};
+
struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL,
- FALSE, FALSE };
-#endif /* __arm32__ */
+ FALSE, FALSE
+};
+#endif /* __arm32__ */
#if defined(__NetBSD__) && !defined(MAP_FILE)
#define MAP_FLAGS MAP_SHARED
@@ -100,13 +104,12 @@ struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL,
#define BUS_BASE 0L
#define BUS_BASE_BWX 0L
-
/***************************************************************************/
/* Video Memory Mapping section */
/***************************************************************************/
static Bool useDevMem = FALSE;
-static int devMemFd = -1;
+static int devMemFd = -1;
static pointer mapVidMem(int, unsigned long, unsigned long, int);
static void unmapVidMem(int, pointer, unsigned long);
@@ -118,108 +121,98 @@ static void unmapVidMem(int, pointer, unsigned long);
static void
checkDevMem(Bool warn)
{
- static Bool devMemChecked = FALSE;
- int fd;
- pointer base;
-
- if (devMemChecked)
- return;
- devMemChecked = TRUE;
-
- if ((fd = open(DEV_MEM, O_RDWR)) >= 0)
- {
- /* Try to map a page at the VGA address */
- base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
- MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE);
-
- if (base != MAP_FAILED)
- {
- munmap((caddr_t)base, 4096);
- devMemFd = fd;
- useDevMem = TRUE;
- return;
- } else {
- /* This should not happen */
- if (warn)
- {
- xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
- DEV_MEM, strerror(errno));
- }
- useDevMem = FALSE;
- return;
- }
- }
- if (warn)
- {
- xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- }
- useDevMem = FALSE;
- return;
+ static Bool devMemChecked = FALSE;
+ int fd;
+ pointer base;
+
+ if (devMemChecked)
+ return;
+ devMemChecked = TRUE;
+
+ if ((fd = open(DEV_MEM, O_RDWR)) >= 0) {
+ /* Try to map a page at the VGA address */
+ base = mmap((caddr_t) 0, 4096, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t) 0xA0000 + BUS_BASE);
+
+ if (base != MAP_FAILED) {
+ munmap((caddr_t) base, 4096);
+ devMemFd = fd;
+ useDevMem = TRUE;
+ return;
+ }
+ else {
+ /* This should not happen */
+ if (warn) {
+ xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ useDevMem = FALSE;
+ return;
+ }
+ }
+ if (warn) {
+ xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ useDevMem = FALSE;
+ return;
}
void
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
- checkDevMem(TRUE);
- pVidMem->linearSupported = useDevMem;
- pVidMem->mapMem = armMapVidMem;
- pVidMem->unmapVidMem = armUnmapVidMem;
+ checkDevMem(TRUE);
+ pVidMem->linearSupported = useDevMem;
+ pVidMem->mapMem = armMapVidMem;
+ pVidMem->unmapVidMem = armUnmapVidMem;
- pVidMem->initialised = TRUE;
+ pVidMem->initialised = TRUE;
}
static pointer
mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
{
- pointer base;
-
- checkDevMem(FALSE);
-
- if (useDevMem)
- {
- if (devMemFd < 0)
- {
- FatalError("xf86MapVidMem: failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- }
- base = mmap((caddr_t)0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX);
- if (base == MAP_FAILED)
- {
- FatalError("%s: could not mmap %s [s=%x,a=%x] (%s)\n",
- "xf86MapVidMem", DEV_MEM, Size, Base,
- strerror(errno));
- }
- return base;
- }
-
- /* else, mmap /dev/vga */
- if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000)
- {
- FatalError("%s: Address 0x%x outside allowable range\n",
- "xf86MapVidMem", Base);
- }
- base = mmap(0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_FLAGS, xf86Info.consoleFd,
- (unsigned long)Base - 0xA0000);
- if (base == MAP_FAILED)
- {
- FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n",
- strerror(errno));
- }
- return base;
+ pointer base;
+
+ checkDevMem(FALSE);
+
+ if (useDevMem) {
+ if (devMemFd < 0) {
+ FatalError("xf86MapVidMem: failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ base = mmap((caddr_t) 0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FLAGS, devMemFd, (off_t) Base + BUS_BASE_BWX);
+ if (base == MAP_FAILED) {
+ FatalError("%s: could not mmap %s [s=%x,a=%x] (%s)\n",
+ "xf86MapVidMem", DEV_MEM, Size, Base, strerror(errno));
+ }
+ return base;
+ }
+
+ /* else, mmap /dev/vga */
+ if ((unsigned long) Base < 0xA0000 || (unsigned long) Base >= 0xC0000) {
+ FatalError("%s: Address 0x%x outside allowable range\n",
+ "xf86MapVidMem", Base);
+ }
+ base = mmap(0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FLAGS, xf86Info.consoleFd, (unsigned long) Base - 0xA0000);
+ if (base == MAP_FAILED) {
+ FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n",
+ strerror(errno));
+ }
+ return base;
}
static void
unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
{
- munmap((caddr_t)Base, Size);
+ munmap((caddr_t) Base, Size);
}
/*
@@ -228,45 +221,43 @@ unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
int
xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
+ int Len)
{
- unsigned char *ptr;
- int psize;
- int mlen;
-
- checkDevMem(TRUE);
- if (devMemFd == -1) {
- return -1;
- }
-
- psize = getpagesize();
- Offset += Base & (psize - 1);
- Base &= ~(psize - 1);
- mlen = (Offset + Len + psize - 1) & ~(psize - 1);
- ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
- MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE);
- if ((long)ptr == -1)
- {
- xf86Msg(X_WARNING,
- "xf86ReadBIOS: %s mmap[s=%x,a=%x,o=%x] failed (%s)\n",
- DEV_MEM, Len, Base, Offset, strerror(errno));
- return -1;
- }
+ unsigned char *ptr;
+ int psize;
+ int mlen;
+
+ checkDevMem(TRUE);
+ if (devMemFd == -1) {
+ return -1;
+ }
+
+ psize = getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+ ptr = (unsigned char *) mmap((caddr_t) 0, mlen, PROT_READ,
+ MAP_SHARED, devMemFd, (off_t) Base + BUS_BASE);
+ if ((long) ptr == -1) {
+ xf86Msg(X_WARNING,
+ "xf86ReadBIOS: %s mmap[s=%x,a=%x,o=%x] failed (%s)\n",
+ DEV_MEM, Len, Base, Offset, strerror(errno));
+ return -1;
+ }
#ifdef DEBUG
- ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
- Base, ptr[0] | (ptr[1] << 8));
+ ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
+ Base, ptr[0] | (ptr[1] << 8));
#endif
- (void)memcpy(Buf, (void *)(ptr + Offset), Len);
- (void)munmap((caddr_t)ptr, mlen);
+ (void) memcpy(Buf, (void *) (ptr + Offset), Len);
+ (void) munmap((caddr_t) ptr, mlen);
#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
- "-> %02x %02x %02x %02x...\n",
- Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
+ xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
+ "-> %02x %02x %02x %02x...\n",
+ Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
#endif
- return Len;
+ return Len;
}
-
/* XXX This needs to be updated for the ND */
/*
@@ -277,52 +268,45 @@ static struct memAccess *
checkMapInfo(Bool warn, int Region)
{
struct memAccess *memAccP;
-
- switch (Region)
- {
- case VGA_REGION:
- memAccP = &vgaMemInfo;
- break;
-
- case LINEAR_REGION:
- memAccP = &linearMemInfo;
- break;
-
- case MMIO_REGION:
- memAccP = &ioMemInfo;
- break;
-
- default:
- return NULL;
- break;
+
+ switch (Region) {
+ case VGA_REGION:
+ memAccP = &vgaMemInfo;
+ break;
+
+ case LINEAR_REGION:
+ memAccP = &linearMemInfo;
+ break;
+
+ case MMIO_REGION:
+ memAccP = &ioMemInfo;
+ break;
+
+ default:
+ return NULL;
+ break;
}
-
- if(!memAccP->Checked)
- {
- if(ioctl(xf86Info.consoleFd, memAccP->ioctl, &(memAccP->memInfo)) == -1)
- {
- if(warn)
- {
- xf86Msg(X_WARNING,
- "checkMapInfo: failed to get map info for region %d\n\t(%s)\n",
- Region, strerror(errno));
- }
- }
- else
- {
- if(memAccP->memInfo.u.map_info_mmap.map_offset
- != MAP_INFO_UNKNOWN)
- memAccP->OK = TRUE;
- }
- memAccP->Checked = TRUE;
+
+ if (!memAccP->Checked) {
+ if (ioctl(xf86Info.consoleFd, memAccP->ioctl, &(memAccP->memInfo)) ==
+ -1) {
+ if (warn) {
+ xf86Msg(X_WARNING,
+ "checkMapInfo: failed to get map info for region %d\n\t(%s)\n",
+ Region, strerror(errno));
+ }
+ }
+ else {
+ if (memAccP->memInfo.u.map_info_mmap.map_offset != MAP_INFO_UNKNOWN)
+ memAccP->OK = TRUE;
+ }
+ memAccP->Checked = TRUE;
}
- if (memAccP->OK)
- {
- return memAccP;
+ if (memAccP->OK) {
+ return memAccP;
}
- else
- {
- return NULL;
+ else {
+ return NULL;
}
}
@@ -331,113 +315,103 @@ xf86MapInfoMap(struct memAccess *memInfoP, pointer Base, unsigned long Size)
{
struct map_info *mapInfoP = &(memInfoP->memInfo);
- if (mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN)
- {
- Size = (unsigned long)Base + Size;
+ if (mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN) {
+ Size = (unsigned long) Base + Size;
}
- else
- {
- Size = mapInfoP->u.map_info_mmap.map_size;
+ else {
+ Size = mapInfoP->u.map_info_mmap.map_size;
}
-
- switch(mapInfoP->method)
- {
- case MAP_MMAP:
- /* Need to remap if size is unknown because we may not have
- mapped the whole region initially */
- if(memInfoP->regionVirtBase == NULL ||
- mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN)
- {
- if((memInfoP->regionVirtBase =
- mmap((caddr_t)0,
- Size,
- PROT_READ | PROT_WRITE,
- MAP_SHARED,
- xf86Info.consoleFd,
- (unsigned long)mapInfoP->u.map_info_mmap.map_offset))
- == (pointer)-1)
- {
- FatalError("xf86MapInfoMap: Failed to map memory at 0x%x\n\t%s\n",
- mapInfoP->u.map_info_mmap.map_offset, strerror(errno));
- }
- if(mapInfoP->u.map_info_mmap.internal_offset > 0)
- memInfoP->regionVirtBase +=
- mapInfoP->u.map_info_mmap.internal_offset;
- }
- break;
-
- default:
- FatalError("xf86MapInfoMap: Unsuported mapping method\n");
- break;
+
+ switch (mapInfoP->method) {
+ case MAP_MMAP:
+ /* Need to remap if size is unknown because we may not have
+ mapped the whole region initially */
+ if (memInfoP->regionVirtBase == NULL ||
+ mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN) {
+ if ((memInfoP->regionVirtBase =
+ mmap((caddr_t) 0,
+ Size,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED,
+ xf86Info.consoleFd,
+ (unsigned long) mapInfoP->u.map_info_mmap.map_offset))
+ == (pointer) -1) {
+ FatalError
+ ("xf86MapInfoMap: Failed to map memory at 0x%x\n\t%s\n",
+ mapInfoP->u.map_info_mmap.map_offset, strerror(errno));
+ }
+ if (mapInfoP->u.map_info_mmap.internal_offset > 0)
+ memInfoP->regionVirtBase +=
+ mapInfoP->u.map_info_mmap.internal_offset;
+ }
+ break;
+
+ default:
+ FatalError("xf86MapInfoMap: Unsuported mapping method\n");
+ break;
}
-
- return (pointer)((int)memInfoP->regionVirtBase + (int)Base);
+
+ return (pointer) ((int) memInfoP->regionVirtBase + (int) Base);
}
static void
xf86MapInfoUnmap(struct memAccess *memInfoP, unsigned long Size)
{
struct map_info *mapInfoP = &(memInfoP->memInfo);
-
- switch(mapInfoP->method)
- {
- case MAP_MMAP:
- if(memInfoP->regionVirtBase != NULL)
- {
- if(mapInfoP->u.map_info_mmap.map_size != MAP_INFO_UNKNOWN)
- Size = mapInfoP->u.map_info_mmap.map_size;
- munmap((caddr_t)memInfoP->regionVirtBase, Size);
- memInfoP->regionVirtBase = NULL;
- }
- break;
- default:
- FatalError("xf86MapInfoMap: Unsuported mapping method\n");
- break;
+
+ switch (mapInfoP->method) {
+ case MAP_MMAP:
+ if (memInfoP->regionVirtBase != NULL) {
+ if (mapInfoP->u.map_info_mmap.map_size != MAP_INFO_UNKNOWN)
+ Size = mapInfoP->u.map_info_mmap.map_size;
+ munmap((caddr_t) memInfoP->regionVirtBase, Size);
+ memInfoP->regionVirtBase = NULL;
+ }
+ break;
+ default:
+ FatalError("xf86MapInfoMap: Unsuported mapping method\n");
+ break;
}
}
static pointer
armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
{
- struct memAccess *memInfoP;
-
- if((memInfoP = checkMapInfo(FALSE, Region)) != NULL)
- {
- /*
- ** xf86 passes in a physical address offset from the start
- ** of physical memory, but xf86MapInfoMap expects an
- ** offset from the start of the specified region - it gets
- ** the physical address of the region from the display driver.
- */
- switch(Region)
- {
- case LINEAR_REGION:
- if (vgaPhysLinearBase)
- {
- Base -= vgaPhysLinearBase;
- }
- break;
- case VGA_REGION:
- Base -= 0xA0000;
- break;
- }
-
- base = xf86MapInfoMap(memInfoP, Base, Size);
- return base;
- }
- return mapVidMem(ScreenNum, Base, Size, flags);
+ struct memAccess *memInfoP;
+
+ if ((memInfoP = checkMapInfo(FALSE, Region)) != NULL) {
+ /*
+ ** xf86 passes in a physical address offset from the start
+ ** of physical memory, but xf86MapInfoMap expects an
+ ** offset from the start of the specified region - it gets
+ ** the physical address of the region from the display driver.
+ */
+ switch (Region) {
+ case LINEAR_REGION:
+ if (vgaPhysLinearBase) {
+ Base -= vgaPhysLinearBase;
+ }
+ break;
+ case VGA_REGION:
+ Base -= 0xA0000;
+ break;
+ }
+
+ base = xf86MapInfoMap(memInfoP, Base, Size);
+ return base;
+ }
+ return mapVidMem(ScreenNum, Base, Size, flags);
}
static void
armUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
{
- struct memAccess *memInfoP;
-
- if((memInfoP = checkMapInfo(FALSE, Region)) != NULL)
- {
- xf86MapInfoUnmap(memInfoP, Base, Size);
- }
- unmapVidMem(ScreenNum, Base, Size);
+ struct memAccess *memInfoP;
+
+ if ((memInfoP = checkMapInfo(FALSE, Region)) != NULL) {
+ xf86MapInfoUnmap(memInfoP, Base, Size);
+ }
+ unmapVidMem(ScreenNum, Base, Size);
}
#ifdef USE_DEV_IO
@@ -446,27 +420,26 @@ static int IoFd = -1;
Bool
xf86EnableIO()
{
- if (IoFd >= 0)
- return TRUE;
-
- if ((IoFd = open("/dev/io", O_RDWR)) == -1)
- {
- xf86Msg(X_WARNING,"xf86EnableIO: "
- "Failed to open /dev/io for extended I/O\n");
- return FALSE;
- }
- return TRUE;
+ if (IoFd >= 0)
+ return TRUE;
+
+ if ((IoFd = open("/dev/io", O_RDWR)) == -1) {
+ xf86Msg(X_WARNING, "xf86EnableIO: "
+ "Failed to open /dev/io for extended I/O\n");
+ return FALSE;
+ }
+ return TRUE;
}
void
xf86DisableIO()
{
- if (IoFd < 0)
- return;
+ if (IoFd < 0)
+ return;
- close(IoFd);
- IoFd = -1;
- return;
+ close(IoFd);
+ IoFd = -1;
+ return;
}
#endif
@@ -476,44 +449,44 @@ xf86DisableIO()
Bool
xf86EnableIO()
{
- int fd;
- pointer base;
-
- if (ExtendedEnabled)
- return TRUE;
-
- if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) {
- /* Try to map a page at the pccons I/O space */
- base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE,
- MAP_FLAGS, fd, (off_t)0x0000);
-
- if (base != (pointer)-1) {
- IOPortBase = base;
- }
- else {
- xf86Msg(X_WARNING,"EnableIO: failed to mmap %s (%s)\n",
- "/dev/ttyC0", strerror(errno));
- return FALSE;
- }
- }
- else {
- xf86Msg("EnableIO: failed to open %s (%s)\n",
- "/dev/ttyC0", strerror(errno));
- return FALSE;
- }
-
- ExtendedEnabled = TRUE;
-
- return TRUE;
+ int fd;
+ pointer base;
+
+ if (ExtendedEnabled)
+ return TRUE;
+
+ if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) {
+ /* Try to map a page at the pccons I/O space */
+ base = (pointer) mmap((caddr_t) 0, 65536, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t) 0x0000);
+
+ if (base != (pointer) -1) {
+ IOPortBase = base;
+ }
+ else {
+ xf86Msg(X_WARNING, "EnableIO: failed to mmap %s (%s)\n",
+ "/dev/ttyC0", strerror(errno));
+ return FALSE;
+ }
+ }
+ else {
+ xf86Msg("EnableIO: failed to open %s (%s)\n",
+ "/dev/ttyC0", strerror(errno));
+ return FALSE;
+ }
+
+ ExtendedEnabled = TRUE;
+
+ return TRUE;
}
void
xf86DisableIO()
{
- return;
+ return;
}
-#endif /* USE_ARC_MMAP */
+#endif /* USE_ARC_MMAP */
#if 0
/*
@@ -534,126 +507,122 @@ Bool
xf86EnableIOPorts(ScreenNum)
int ScreenNum;
{
- int i;
- int fd;
- pointer base;
+ int i;
+ int fd;
+ pointer base;
#ifdef __arm32__
- struct memAccess *memInfoP;
- int *Size;
+ struct memAccess *memInfoP;
+ int *Size;
#endif
- ScreenEnabled[ScreenNum] = TRUE;
+ ScreenEnabled[ScreenNum] = TRUE;
- if (ExtendedEnabled)
- return TRUE;
+ if (ExtendedEnabled)
+ return TRUE;
#ifdef USE_ARC_MMAP
- if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) {
- /* Try to map a page at the pccons I/O space */
- base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE,
- MAP_FLAGS, fd, (off_t)0x0000);
-
- if (base != (pointer)-1) {
- IOPortBase = base;
- }
- else {
- xf86Msg(X_ERROR,
- "EnableIOPorts: failed to mmap %s (%s)\n",
- "/dev/ttyC0", strerror(errno));
- }
- }
- else {
- xf86Msg(X_ERROR, "EnableIOPorts: failed to open %s (%s)\n",
- "/dev/ttyC0", strerror(errno));
- }
+ if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) {
+ /* Try to map a page at the pccons I/O space */
+ base = (pointer) mmap((caddr_t) 0, 65536, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t) 0x0000);
+
+ if (base != (pointer) -1) {
+ IOPortBase = base;
+ }
+ else {
+ xf86Msg(X_ERROR,
+ "EnableIOPorts: failed to mmap %s (%s)\n",
+ "/dev/ttyC0", strerror(errno));
+ }
+ }
+ else {
+ xf86Msg(X_ERROR, "EnableIOPorts: failed to open %s (%s)\n",
+ "/dev/ttyC0", strerror(errno));
+ }
#endif
#ifdef __arm32__
- IOPortBase = (unsigned int)-1;
-
- if((memInfoP = checkMapInfo(TRUE, MMIO_REGION)) != NULL)
- {
- /*
- * xf86MapInfoMap maps an offset from the start of video IO
- * space (e.g. 0x3B0), but IOPortBase is expected to map to
- * physical address 0x000, so subtract the start of video I/O
- * space from the result. This is safe for now becase we
- * actually mmap the start of the page, then the start of video
- * I/O space is added as an internal offset.
- */
- IOPortBase = (unsigned int)xf86MapInfoMap(memInfoP,
- (caddr_t)0x0, 0L)
- - memInfoP->memInfo.u.map_info_mmap.internal_offset;
- ExtendedEnabled = TRUE;
- return TRUE;
- }
+ IOPortBase = (unsigned int) -1;
+
+ if ((memInfoP = checkMapInfo(TRUE, MMIO_REGION)) != NULL) {
+ /*
+ * xf86MapInfoMap maps an offset from the start of video IO
+ * space (e.g. 0x3B0), but IOPortBase is expected to map to
+ * physical address 0x000, so subtract the start of video I/O
+ * space from the result. This is safe for now becase we
+ * actually mmap the start of the page, then the start of video
+ * I/O space is added as an internal offset.
+ */
+ IOPortBase = (unsigned int) xf86MapInfoMap(memInfoP, (caddr_t) 0x0, 0L)
+ - memInfoP->memInfo.u.map_info_mmap.internal_offset;
+ ExtendedEnabled = TRUE;
+ return TRUE;
+ }
#ifdef USE_ARM32_MMAP
- checkDevMem(TRUE);
+ checkDevMem(TRUE);
- if (devMemFd >= 0 && useDevMem)
- {
- base = (pointer)mmap((caddr_t)0, 0x400, PROT_READ | PROT_WRITE,
- MAP_FLAGS, devMemFd, (off_t)DEV_MEM_IOBASE);
+ if (devMemFd >= 0 && useDevMem) {
+ base = (pointer) mmap((caddr_t) 0, 0x400, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, devMemFd, (off_t) DEV_MEM_IOBASE);
- if (base != (pointer)-1)
- IOPortBase = (unsigned int)base;
- }
+ if (base != (pointer) -1)
+ IOPortBase = (unsigned int) base;
+ }
- if (IOPortBase == (unsigned int)-1)
- {
- xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\
+ if (IOPortBase == (unsigned int) -1) {
+ xf86Msg(X_WARNING,
+ "xf86EnableIOPorts: failed to open mem device or map IO base. \n\
Make sure you have the Aperture Driver installed, or a kernel built with the INSECURE option\n");
- return FALSE;
- }
+ return FALSE;
+ }
#else
- /* We don't have the IOBASE, so we can't map the address */
- xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\
+ /* We don't have the IOBASE, so we can't map the address */
+ xf86Msg(X_WARNING,
+ "xf86EnableIOPorts: failed to open mem device or map IO base. \n\
Try building the server with USE_ARM32_MMAP defined\n");
- return FALSE;
+ return FALSE;
#endif
#endif
-
- ExtendedEnabled = TRUE;
- return TRUE;
+ ExtendedEnabled = TRUE;
+
+ return TRUE;
}
void
xf86DisableIOPorts(ScreenNum)
int ScreenNum;
{
- int i;
+ int i;
+
#ifdef __arm32__
- struct memAccess *memInfoP;
+ struct memAccess *memInfoP;
#endif
- ScreenEnabled[ScreenNum] = FALSE;
+ ScreenEnabled[ScreenNum] = FALSE;
#ifdef __arm32__
- if((memInfoP = checkMapInfo(FALSE, MMIO_REGION)) != NULL)
- {
- xf86MapInfoUnmap(memInfoP, 0);
- }
+ if ((memInfoP = checkMapInfo(FALSE, MMIO_REGION)) != NULL) {
+ xf86MapInfoUnmap(memInfoP, 0);
+ }
#endif
#ifdef USE_ARM32_MMAP
- if (!ExtendedEnabled)
- return;
+ if (!ExtendedEnabled)
+ return;
- for (i = 0; i < MAXSCREENS; i++)
- if (ScreenEnabled[i])
- return;
+ for (i = 0; i < MAXSCREENS; i++)
+ if (ScreenEnabled[i])
+ return;
- munmap((caddr_t)IOPortBase, 0x400);
- IOPortBase = (unsigned int)-1;
- ExtendedEnabled = FALSE;
+ munmap((caddr_t) IOPortBase, 0x400);
+ IOPortBase = (unsigned int) -1;
+ ExtendedEnabled = FALSE;
#endif
- return;
+ return;
}
-#endif /* USE_ARC_MMAP || USE_ARM32_MMAP */
+#endif /* USE_ARC_MMAP || USE_ARM32_MMAP */
#endif
-
-
diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c
index 73c88dca3..a8a4164e0 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c
@@ -20,20 +20,22 @@ static void bsdCloseAPM(void);
static struct {
u_int apmBsd;
pmEvent xf86;
-} bsdToXF86Array [] = {
- { APM_STANDBY_REQ, XF86_APM_SYS_STANDBY },
- { APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND },
- { APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME },
- { APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME },
- { APM_BATTERY_LOW, XF86_APM_LOW_BATTERY },
- { APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE },
- { APM_UPDATE_TIME, XF86_APM_UPDATE_TIME },
- { APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND },
- { APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY },
- { APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND },
- { APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME },
+} bsdToXF86Array[] = {
+ {
+ APM_STANDBY_REQ, XF86_APM_SYS_STANDBY}, {
+ APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND}, {
+ APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, {
+ APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME}, {
+ APM_BATTERY_LOW, XF86_APM_LOW_BATTERY}, {
+ APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, {
+ APM_UPDATE_TIME, XF86_APM_UPDATE_TIME}, {
+ APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND}, {
+ APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY}, {
+ APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND}, {
+ APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME},
#ifdef APM_CAPABILITY_CHANGE
- { APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED },
+ {
+ APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED},
#endif
};
@@ -45,9 +47,9 @@ bsdToXF86(int type)
int i;
for (i = 0; i < numApmEvents; i++) {
- if (type == bsdToXF86Array[i].apmBsd) {
- return bsdToXF86Array[i].xf86;
- }
+ if (type == bsdToXF86Array[i].apmBsd) {
+ return bsdToXF86Array[i].xf86;
+ }
}
return XF86_APM_UNKNOWN;
}
@@ -55,22 +57,22 @@ bsdToXF86(int type)
/*
* APM events can be requested direclty from /dev/apm
*/
-static int
-bsdPMGetEventFromOS(int fd, pmEvent *events, int num)
+static int
+bsdPMGetEventFromOS(int fd, pmEvent * events, int num)
{
struct apm_event_info bsdEvent;
int i;
for (i = 0; i < num; i++) {
-
- if (ioctl(fd, APM_IOC_NEXTEVENT, &bsdEvent) < 0) {
- if (errno != EAGAIN) {
- xf86Msg(X_WARNING, "bsdPMGetEventFromOS: APM_IOC_NEXTEVENT"
- " %s\n", strerror(errno));
- }
- break;
- }
- events[i] = bsdToXF86(bsdEvent.type);
+
+ if (ioctl(fd, APM_IOC_NEXTEVENT, &bsdEvent) < 0) {
+ if (errno != EAGAIN) {
+ xf86Msg(X_WARNING, "bsdPMGetEventFromOS: APM_IOC_NEXTEVENT"
+ " %s\n", strerror(errno));
+ }
+ break;
+ }
+ events[i] = bsdToXF86(bsdEvent.type);
}
return i;
}
@@ -84,27 +86,27 @@ static pmWait
bsdPMConfirmEventToOs(int fd, pmEvent event)
{
switch (event) {
- case XF86_APM_SYS_STANDBY:
- case XF86_APM_USER_STANDBY:
- if (ioctl( fd, APM_IOC_STANDBY, NULL ) == 0)
- return PM_WAIT; /* should we stop the Xserver in standby, too? */
+ case XF86_APM_SYS_STANDBY:
+ case XF86_APM_USER_STANDBY:
+ if (ioctl(fd, APM_IOC_STANDBY, NULL) == 0)
+ return PM_WAIT; /* should we stop the Xserver in standby, too? */
else
return PM_NONE;
- case XF86_APM_SYS_SUSPEND:
- case XF86_APM_CRITICAL_SUSPEND:
- case XF86_APM_USER_SUSPEND:
- if (ioctl( fd, APM_IOC_SUSPEND, NULL ) == 0)
+ case XF86_APM_SYS_SUSPEND:
+ case XF86_APM_CRITICAL_SUSPEND:
+ case XF86_APM_USER_SUSPEND:
+ if (ioctl(fd, APM_IOC_SUSPEND, NULL) == 0)
return PM_WAIT;
else
return PM_NONE;
- case XF86_APM_STANDBY_RESUME:
- case XF86_APM_NORMAL_RESUME:
- case XF86_APM_CRITICAL_RESUME:
- case XF86_APM_STANDBY_FAILED:
- case XF86_APM_SUSPEND_FAILED:
+ case XF86_APM_STANDBY_RESUME:
+ case XF86_APM_NORMAL_RESUME:
+ case XF86_APM_CRITICAL_RESUME:
+ case XF86_APM_STANDBY_FAILED:
+ case XF86_APM_SUSPEND_FAILED:
return PM_CONTINUE;
- default:
- return PM_NONE;
+ default:
+ return PM_NONE;
}
}
@@ -114,11 +116,11 @@ xf86OSPMOpen(void)
int fd;
if (APMihPtr || !xf86Info.pmFlag) {
- return NULL;
+ return NULL;
}
if ((fd = open(APM_DEVICE, O_RDWR)) == -1) {
- return NULL;
+ return NULL;
}
xf86PMGetEventFromOs = bsdPMGetEventFromOS;
xf86PMConfirmEventToOs = bsdPMConfirmEventToOs;
@@ -132,8 +134,8 @@ bsdCloseAPM(void)
int fd;
if (APMihPtr) {
- fd = xf86RemoveGeneralHandler(APMihPtr);
- close(fd);
- APMihPtr = NULL;
+ fd = xf86RemoveGeneralHandler(APMihPtr);
+ close(fd);
+ APMihPtr = NULL;
}
}
diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_axp.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_axp.c
index 77c87ce1d..e7a36f8bf 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/bsd_axp.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_axp.c
@@ -24,49 +24,48 @@ axpDevice bsdGetAXP(void);
*/
typedef struct {
- char *name;
- int type;
-} _AXP;
+ char *name;
+ int type;
+} _AXP;
static _AXP axpList[] = {
- {"apecs",APECS},
- {"pyxis",PYXIS},
- {"cia",CIA},
- {"irongate",IRONGATE},
- {"lca",LCA},
- {"t2",T2},
- {"tsunami",TSUNAMI},
- {NULL,SYS_NONE}
+ {"apecs", APECS},
+ {"pyxis", PYXIS},
+ {"cia", CIA},
+ {"irongate", IRONGATE},
+ {"lca", LCA},
+ {"t2", T2},
+ {"tsunami", TSUNAMI},
+ {NULL, SYS_NONE}
};
axpDevice
bsdGetAXP(void)
{
- int i;
- char sysname[64];
- size_t len = sizeof(sysname);
-
+ int i;
+ char sysname[64];
+ size_t len = sizeof(sysname);
+
#ifdef __OpenBSD__
- int mib[3];
- int error;
+ int mib[3];
+ int error;
- mib[0] = CTL_MACHDEP;
- mib[1] = CPU_CHIPSET;
- mib[2] = CPU_CHIPSET_TYPE;
+ mib[0] = CTL_MACHDEP;
+ mib[1] = CPU_CHIPSET;
+ mib[2] = CPU_CHIPSET_TYPE;
- if ((error = sysctl(mib, 3, &sysname, &len, NULL, 0)) < 0)
-#else
- if ((sysctlbyname("hw.chipset.type", &sysname, &len,
- 0, 0)) < 0)
+ if ((error = sysctl(mib, 3, &sysname, &len, NULL, 0)) < 0)
+#else
+ if ((sysctlbyname("hw.chipset.type", &sysname, &len, 0, 0)) < 0)
#endif
- FatalError("bsdGetAXP: can't find machine type\n");
+ FatalError("bsdGetAXP: can't find machine type\n");
#ifdef DEBUG
- xf86Msg(X_INFO,"AXP is a: %s\n",sysname);
+ xf86Msg(X_INFO, "AXP is a: %s\n", sysname);
#endif
- for (i=0;;i++) {
- if (axpList[i].name == NULL)
- return SYS_NONE;
- if (!strcmp(sysname, axpList[i].name))
- return axpList[i].type;
- }
-}
+ for (i = 0;; i++) {
+ if (axpList[i].name == NULL)
+ return SYS_NONE;
+ if (!strcmp(sysname, axpList[i].name))
+ return axpList[i].type;
+ }
+}
diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_bell.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_bell.c
index fb457db71..f6643ee62 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/bsd_bell.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_bell.c
@@ -41,42 +41,40 @@ void
xf86OSRingBell(int loudness, int pitch, int duration)
{
#ifdef WSCONS_SUPPORT
- struct wskbd_bell_data wsb;
+ struct wskbd_bell_data wsb;
#endif
- if (loudness && pitch)
- {
+ if (loudness && pitch) {
#ifdef PCCONS_SUPPORT
- int data[2];
+ int data[2];
#endif
- switch (xf86Info.consType) {
+ switch (xf86Info.consType) {
#ifdef PCCONS_SUPPORT
- case PCCONS:
- data[0] = pitch;
- data[1] = (duration * loudness) / 50;
- ioctl(xf86Info.consoleFd, CONSOLE_X_BELL, data);
- break;
+ case PCCONS:
+ data[0] = pitch;
+ data[1] = (duration * loudness) / 50;
+ ioctl(xf86Info.consoleFd, CONSOLE_X_BELL, data);
+ break;
#endif
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- case SYSCONS:
- case PCVT:
- ioctl(xf86Info.consoleFd, KDMKTONE,
- ((1193190 / pitch) & 0xffff) |
- (((unsigned long)duration*loudness/50)<<16));
- break;
+ case SYSCONS:
+ case PCVT:
+ ioctl(xf86Info.consoleFd, KDMKTONE,
+ ((1193190 / pitch) & 0xffff) |
+ (((unsigned long) duration * loudness / 50) << 16));
+ break;
#endif
#if defined (WSCONS_SUPPORT)
- case WSCONS:
- wsb.which = WSKBD_BELL_DOALL;
- wsb.pitch = pitch;
- wsb.period = duration;
- wsb.volume = loudness;
- ioctl(xf86Info.consoleFd, WSKBDIO_COMPLEXBELL,
- &wsb);
- break;
+ case WSCONS:
+ wsb.which = WSKBD_BELL_DOALL;
+ wsb.pitch = pitch;
+ wsb.period = duration;
+ wsb.volume = loudness;
+ ioctl(xf86Info.consoleFd, WSKBDIO_COMPLEXBELL, &wsb);
+ break;
#endif
- }
}
+ }
}
diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c
index 7079d62b4..c9f823321 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c
@@ -67,9 +67,9 @@ static int initialVT = -1;
#ifdef PCVT_SUPPORT
/* Hellmuth Michaelis' pcvt driver */
#ifndef __OpenBSD__
-# define PCVT_CONSOLE_DEV "/dev/ttyv0"
+#define PCVT_CONSOLE_DEV "/dev/ttyv0"
#else
-# define PCVT_CONSOLE_DEV "/dev/ttyC0"
+#define PCVT_CONSOLE_DEV "/dev/ttyC0"
#endif
#define PCVT_CONSOLE_MODE O_RDWR|O_NDELAY
#endif
@@ -88,20 +88,19 @@ static int initialVT = -1;
static char *supported_drivers[] = {
#ifdef PCCONS_SUPPORT
- "pccons (with X support)",
+ "pccons (with X support)",
#endif
#ifdef SYSCONS_SUPPORT
- "syscons",
+ "syscons",
#endif
#ifdef PCVT_SUPPORT
- "pcvt",
+ "pcvt",
#endif
#ifdef WSCONS_SUPPORT
- "wscons",
+ "wscons",
#endif
};
-
/*
* Functions to probe for the existance of a supported console driver.
* Any function returns either a valid file descriptor (driver probed
@@ -110,19 +109,19 @@ static char *supported_drivers[] = {
* an X server.
*/
-typedef int (*xf86ConsOpen_t)(void);
+typedef int (*xf86ConsOpen_t) (void);
#ifdef PCCONS_SUPPORT
static int xf86OpenPccons(void);
-#endif /* PCCONS_SUPPORT */
+#endif /* PCCONS_SUPPORT */
#ifdef SYSCONS_SUPPORT
static int xf86OpenSyscons(void);
-#endif /* SYSCONS_SUPPORT */
+#endif /* SYSCONS_SUPPORT */
#ifdef PCVT_SUPPORT
static int xf86OpenPcvt(void);
-#endif /* PCVT_SUPPORT */
+#endif /* PCVT_SUPPORT */
#ifdef WSCONS_SUPPORT
static int xf86OpenWScons(void);
@@ -147,191 +146,174 @@ static xf86ConsOpen_t xf86ConsTab[] = {
#ifdef WSCONS_SUPPORT
xf86OpenWScons,
#endif
- (xf86ConsOpen_t)NULL
+ (xf86ConsOpen_t) NULL
};
-
void
xf86OpenConsole()
{
int i, fd = -1;
xf86ConsOpen_t *driver;
+
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
int result;
+
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
struct utsname uts;
#endif
vtmode_t vtmode;
#endif
-
- if (serverGeneration == 1)
- {
- /* check if we are run with euid==0 */
- if (geteuid() != 0)
- {
- FatalError("xf86OpenConsole: Server must be suid root");
- }
-
- if (!KeepTty)
- {
- /*
- * detaching the controlling tty solves problems of kbd character
- * loss. This is not interesting for CO driver, because it is
- * exclusive.
- */
- setpgrp(0, getpid());
- if ((i = open("/dev/tty",O_RDWR)) >= 0)
- {
- ioctl(i,TIOCNOTTY,(char *)0);
- close(i);
- }
- }
-
- /* detect which driver we are running on */
- for (driver = xf86ConsTab; *driver; driver++)
- {
- if ((fd = (*driver)()) >= 0)
- break;
- }
-
- /* Check that a supported console driver was found */
- if (fd < 0)
- {
- char cons_drivers[80] = {0, };
- for (i = 0; i < sizeof(supported_drivers) / sizeof(char *); i++)
- {
- if (i)
- {
- strcat(cons_drivers, ", ");
- }
- strcat(cons_drivers, supported_drivers[i]);
- }
- FatalError(
- "%s: No console driver found\n\tSupported drivers: %s\n\t%s",
- "xf86OpenConsole", cons_drivers, CHECK_DRIVER_MSG);
- }
- xf86Info.consoleFd = fd;
-
- switch (xf86Info.consType)
- {
+
+ if (serverGeneration == 1) {
+ /* check if we are run with euid==0 */
+ if (geteuid() != 0) {
+ FatalError("xf86OpenConsole: Server must be suid root");
+ }
+
+ if (!KeepTty) {
+ /*
+ * detaching the controlling tty solves problems of kbd character
+ * loss. This is not interesting for CO driver, because it is
+ * exclusive.
+ */
+ setpgrp(0, getpid());
+ if ((i = open("/dev/tty", O_RDWR)) >= 0) {
+ ioctl(i, TIOCNOTTY, (char *) 0);
+ close(i);
+ }
+ }
+
+ /* detect which driver we are running on */
+ for (driver = xf86ConsTab; *driver; driver++) {
+ if ((fd = (*driver) ()) >= 0)
+ break;
+ }
+
+ /* Check that a supported console driver was found */
+ if (fd < 0) {
+ char cons_drivers[80] = { 0, };
+ for (i = 0; i < sizeof(supported_drivers) / sizeof(char *); i++) {
+ if (i) {
+ strcat(cons_drivers, ", ");
+ }
+ strcat(cons_drivers, supported_drivers[i]);
+ }
+ FatalError
+ ("%s: No console driver found\n\tSupported drivers: %s\n\t%s",
+ "xf86OpenConsole", cons_drivers, CHECK_DRIVER_MSG);
+ }
+ xf86Info.consoleFd = fd;
+
+ switch (xf86Info.consType) {
#ifdef PCCONS_SUPPORT
- case PCCONS:
- if (ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_ON, 0) < 0)
- {
- FatalError("%s: CONSOLE_X_MODE_ON failed (%s)\n%s",
- "xf86OpenConsole", strerror(errno),
- CHECK_DRIVER_MSG);
- }
- /*
- * Hack to prevent keyboard hanging when syslogd closes
- * /dev/console
- */
- if ((devConsoleFd = open("/dev/console", O_WRONLY,0)) < 0)
- {
- xf86Msg(X_WARNING,
- "xf86OpenConsole: couldn't open /dev/console (%s)\n",
- strerror(errno));
- }
- break;
+ case PCCONS:
+ if (ioctl(xf86Info.consoleFd, CONSOLE_X_MODE_ON, 0) < 0) {
+ FatalError("%s: CONSOLE_X_MODE_ON failed (%s)\n%s",
+ "xf86OpenConsole", strerror(errno),
+ CHECK_DRIVER_MSG);
+ }
+ /*
+ * Hack to prevent keyboard hanging when syslogd closes
+ * /dev/console
+ */
+ if ((devConsoleFd = open("/dev/console", O_WRONLY, 0)) < 0) {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: couldn't open /dev/console (%s)\n",
+ strerror(errno));
+ }
+ break;
#endif
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- case SYSCONS:
- /* as of FreeBSD 2.2.8, syscons driver does not need the #1 vt
- * switching anymore. Here we check for FreeBSD 3.1 and up.
- * Add cases for other *BSD that behave the same.
- */
+ case SYSCONS:
+ /* as of FreeBSD 2.2.8, syscons driver does not need the #1 vt
+ * switching anymore. Here we check for FreeBSD 3.1 and up.
+ * Add cases for other *BSD that behave the same.
+ */
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
- uname (&uts);
- i = atof(uts.release) * 100;
- if (i >= 310) goto acquire_vt;
+ uname(&uts);
+ i = atof(uts.release) * 100;
+ if (i >= 310)
+ goto acquire_vt;
#endif
- /* otherwise fall through */
- case PCVT:
+ /* otherwise fall through */
+ case PCVT:
#if !(defined(__NetBSD__) && (__NetBSD_Version__ >= 200000000))
- /*
- * First activate the #1 VT. This is a hack to allow a server
- * to be started while another one is active. There should be
- * a better way.
- */
- if (initialVT != 1) {
-
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) != 0)
- {
- xf86Msg(X_WARNING,
- "xf86OpenConsole: VT_ACTIVATE failed\n");
- }
- sleep(1);
- }
-#endif
-acquire_vt:
- if (!xf86Info.ShareVTs) {
- /*
- * now get the VT
- */
- SYSCALL(result =
- ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno));
- if (result != 0)
- {
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
- }
- SYSCALL(result =
- ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno));
- if (result != 0)
- {
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
- }
-
- signal(SIGUSR1, xf86VTRequest);
-
- vtmode.mode = VT_PROCESS;
- vtmode.relsig = SIGUSR1;
- vtmode.acqsig = SIGUSR1;
- vtmode.frsig = SIGUSR1;
- if (ioctl(xf86Info.consoleFd, VT_SETMODE, &vtmode) < 0)
- {
- FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed");
- }
+ /*
+ * First activate the #1 VT. This is a hack to allow a server
+ * to be started while another one is active. There should be
+ * a better way.
+ */
+ if (initialVT != 1) {
+
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) != 0) {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ sleep(1);
+ }
+#endif
+ acquire_vt:
+ if (!xf86Info.ShareVTs) {
+ /*
+ * now get the VT
+ */
+ SYSCALL(result =
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno));
+ if (result != 0) {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ SYSCALL(result =
+ ioctl(xf86Info.consoleFd, VT_WAITACTIVE,
+ xf86Info.vtno));
+ if (result != 0) {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: VT_WAITACTIVE failed\n");
+ }
+
+ signal(SIGUSR1, xf86VTRequest);
+
+ vtmode.mode = VT_PROCESS;
+ vtmode.relsig = SIGUSR1;
+ vtmode.acqsig = SIGUSR1;
+ vtmode.frsig = SIGUSR1;
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &vtmode) < 0) {
+ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed");
+ }
#if !defined(__OpenBSD__) && !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
- if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0)
- {
- FatalError("xf86OpenConsole: KDENABIO failed (%s)",
- strerror(errno));
- }
-#endif
- if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
- {
- FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed");
- }
- } else { /* xf86Info.ShareVTs */
- close(xf86Info.consoleFd);
- }
- break;
-#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+ if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0) {
+ FatalError("xf86OpenConsole: KDENABIO failed (%s)",
+ strerror(errno));
+ }
+#endif
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) {
+ FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed");
+ }
+ }
+ else { /* xf86Info.ShareVTs */
+ close(xf86Info.consoleFd);
+ }
+ break;
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
#ifdef WSCONS_SUPPORT
- case WSCONS:
- /* Nothing to do */
- break;
+ case WSCONS:
+ /* Nothing to do */
+ break;
#endif
}
}
- else
- {
- /* serverGeneration != 1 */
+ else {
+ /* serverGeneration != 1 */
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- if (!xf86Info.ShareVTs &&
- (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT))
- {
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
- {
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
- }
+ if (!xf86Info.ShareVTs &&
+ (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)) {
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
}
-#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
}
return;
}
-
#ifdef PCCONS_SUPPORT
static int
@@ -340,26 +322,22 @@ xf86OpenPccons()
int fd = -1;
if ((fd = open(PCCONS_CONSOLE_DEV1, PCCONS_CONSOLE_MODE, 0))
- >= 0 ||
- (fd = open(PCCONS_CONSOLE_DEV2, PCCONS_CONSOLE_MODE, 0))
- >= 0)
- {
- if (ioctl(fd, CONSOLE_X_MODE_OFF, 0) < 0)
- {
- FatalError(
- "%s: CONSOLE_X_MODE_OFF failed (%s)\n%s\n%s",
- "xf86OpenPccons",
- strerror(errno),
- "Was expecting pccons driver with X support",
- CHECK_DRIVER_MSG);
- }
- xf86Info.consType = PCCONS;
- xf86Msg(X_PROBED, "Using pccons driver with X support\n");
+ >= 0 || (fd = open(PCCONS_CONSOLE_DEV2, PCCONS_CONSOLE_MODE, 0))
+ >= 0) {
+ if (ioctl(fd, CONSOLE_X_MODE_OFF, 0) < 0) {
+ FatalError("%s: CONSOLE_X_MODE_OFF failed (%s)\n%s\n%s",
+ "xf86OpenPccons",
+ strerror(errno),
+ "Was expecting pccons driver with X support",
+ CHECK_DRIVER_MSG);
+ }
+ xf86Info.consType = PCCONS;
+ xf86Msg(X_PROBED, "Using pccons driver with X support\n");
}
return fd;
}
-#endif /* PCCONS_SUPPORT */
+#endif /* PCCONS_SUPPORT */
#ifdef SYSCONS_SUPPORT
@@ -374,113 +352,98 @@ xf86OpenSyscons()
/* Check for syscons */
if ((fd = open(SYSCONS_CONSOLE_DEV1, SYSCONS_CONSOLE_MODE, 0)) >= 0
- || (fd = open(SYSCONS_CONSOLE_DEV2, SYSCONS_CONSOLE_MODE, 0)) >= 0)
- {
- if (ioctl(fd, VT_GETMODE, &vtmode) >= 0)
- {
- /* Get syscons version */
- if (ioctl(fd, CONS_GETVERS, &syscons_version) < 0)
- {
- syscons_version = 0;
- }
+ || (fd = open(SYSCONS_CONSOLE_DEV2, SYSCONS_CONSOLE_MODE, 0)) >= 0) {
+ if (ioctl(fd, VT_GETMODE, &vtmode) >= 0) {
+ /* Get syscons version */
+ if (ioctl(fd, CONS_GETVERS, &syscons_version) < 0) {
+ syscons_version = 0;
+ }
- xf86Info.vtno = VTnum;
- from = X_CMDLINE;
+ xf86Info.vtno = VTnum;
+ from = X_CMDLINE;
#ifdef VT_GETACTIVE
- if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
- initialVT = -1;
+ if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
+ initialVT = -1;
#endif
if (xf86Info.ShareVTs)
- xf86Info.vtno = initialVT;
+ xf86Info.vtno = initialVT;
- if (xf86Info.vtno == -1)
- {
- /*
- * For old syscons versions (<0x100), VT_OPENQRY returns
- * the current VT rather than the next free VT. In this
- * case, the server gets started on the current VT instead
- * of the next free VT.
- */
+ if (xf86Info.vtno == -1) {
+ /*
+ * For old syscons versions (<0x100), VT_OPENQRY returns
+ * the current VT rather than the next free VT. In this
+ * case, the server gets started on the current VT instead
+ * of the next free VT.
+ */
#if 0
- /* check for the fixed VT_OPENQRY */
- if (syscons_version >= 0x100)
- {
-#endif
- if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0)
- {
- /* No free VTs */
- xf86Info.vtno = -1;
- }
+ /* check for the fixed VT_OPENQRY */
+ if (syscons_version >= 0x100) {
+#endif
+ if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) {
+ /* No free VTs */
+ xf86Info.vtno = -1;
+ }
#if 0
- }
-#endif
-
- if (xf86Info.vtno == -1)
- {
- /*
- * All VTs are in use. If initialVT was found, use it.
- */
- if (initialVT != -1)
- {
- xf86Info.vtno = initialVT;
- }
- else
- {
- if (syscons_version >= 0x100)
- {
- FatalError("%s: Cannot find a free VT",
- "xf86OpenSyscons");
- }
- /* Should no longer reach here */
- FatalError("%s: %s %s\n\t%s %s",
- "xf86OpenSyscons",
- "syscons versions prior to 1.0 require",
- "either the",
- "server's stdin be a VT",
- "or the use of the vtxx server option");
- }
- }
- from = X_PROBED;
- }
-
- close(fd);
- snprintf(vtname, sizeof(vtname), "/dev/ttyv%01x", xf86Info.vtno - 1);
- if ((fd = open(vtname, SYSCONS_CONSOLE_MODE, 0)) < 0)
- {
- FatalError("xf86OpenSyscons: Cannot open %s (%s)",
- vtname, strerror(errno));
- }
- if (ioctl(fd, VT_GETMODE, &vtmode) < 0)
- {
- FatalError("xf86OpenSyscons: VT_GETMODE failed");
- }
- xf86Info.consType = SYSCONS;
- xf86Msg(X_PROBED, "Using syscons driver with X support");
- if (syscons_version >= 0x100)
- {
- xf86ErrorF(" (version %ld.%ld)\n", syscons_version >> 8,
- syscons_version & 0xFF);
- }
- else
- {
- xf86ErrorF(" (version 0.x)\n");
- }
- xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
- }
- else
- {
- /* VT_GETMODE failed, probably not syscons */
- close(fd);
- fd = -1;
- }
+ }
+#endif
+
+ if (xf86Info.vtno == -1) {
+ /*
+ * All VTs are in use. If initialVT was found, use it.
+ */
+ if (initialVT != -1) {
+ xf86Info.vtno = initialVT;
+ }
+ else {
+ if (syscons_version >= 0x100) {
+ FatalError("%s: Cannot find a free VT",
+ "xf86OpenSyscons");
+ }
+ /* Should no longer reach here */
+ FatalError("%s: %s %s\n\t%s %s",
+ "xf86OpenSyscons",
+ "syscons versions prior to 1.0 require",
+ "either the",
+ "server's stdin be a VT",
+ "or the use of the vtxx server option");
+ }
+ }
+ from = X_PROBED;
+ }
+
+ close(fd);
+ snprintf(vtname, sizeof(vtname), "/dev/ttyv%01x",
+ xf86Info.vtno - 1);
+ if ((fd = open(vtname, SYSCONS_CONSOLE_MODE, 0)) < 0) {
+ FatalError("xf86OpenSyscons: Cannot open %s (%s)",
+ vtname, strerror(errno));
+ }
+ if (ioctl(fd, VT_GETMODE, &vtmode) < 0) {
+ FatalError("xf86OpenSyscons: VT_GETMODE failed");
+ }
+ xf86Info.consType = SYSCONS;
+ xf86Msg(X_PROBED, "Using syscons driver with X support");
+ if (syscons_version >= 0x100) {
+ xf86ErrorF(" (version %ld.%ld)\n", syscons_version >> 8,
+ syscons_version & 0xFF);
+ }
+ else {
+ xf86ErrorF(" (version 0.x)\n");
+ }
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
+ }
+ else {
+ /* VT_GETMODE failed, probably not syscons */
+ close(fd);
+ fd = -1;
+ }
}
return fd;
}
-#endif /* SYSCONS_SUPPORT */
-
+#endif /* SYSCONS_SUPPORT */
#ifdef PCVT_SUPPORT
@@ -501,93 +464,82 @@ xf86OpenPcvt()
fd = open(PCVT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0);
#ifdef WSCONS_PCVT_COMPAT_CONSOLE_DEV
- if (fd < 0)
- {
- fd = open(WSCONS_PCVT_COMPAT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0);
- vtprefix = "/dev/ttyE";
+ if (fd < 0) {
+ fd = open(WSCONS_PCVT_COMPAT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0);
+ vtprefix = "/dev/ttyE";
}
#endif
- if (fd >= 0)
- {
- if (ioctl(fd, VGAPCVTID, &pcvt_version) >= 0)
- {
- if(ioctl(fd, VT_GETMODE, &vtmode) < 0)
- {
- FatalError("%s: VT_GETMODE failed\n%s%s\n%s",
- "xf86OpenPcvt",
- "Found pcvt driver but X11 seems to be",
- " not supported.", CHECK_DRIVER_MSG);
- }
-
- xf86Info.vtno = VTnum;
-
- if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
- initialVT = -1;
-
- if (xf86Info.vtno == -1)
- {
- if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0)
- {
- /* No free VTs */
- xf86Info.vtno = -1;
- }
-
- if (xf86Info.vtno == -1)
- {
- /*
- * All VTs are in use. If initialVT was found, use it.
- */
- if (initialVT != -1)
- {
- xf86Info.vtno = initialVT;
- }
- else
- {
- FatalError("%s: Cannot find a free VT",
- "xf86OpenPcvt");
- }
- }
- }
-
- close(fd);
- snprintf(vtname, sizeof(vtname), "%s%01x", vtprefix, xf86Info.vtno - 1);
- if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0)
- {
- ErrorF("xf86OpenPcvt: Cannot open %s (%s)",
- vtname, strerror(errno));
- xf86Info.vtno = initialVT;
- snprintf(vtname, sizeof(vtname), "%s%01x", vtprefix, xf86Info.vtno - 1);
- if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) {
- FatalError("xf86OpenPcvt: Cannot open %s (%s)",
- vtname, strerror(errno));
- }
- }
- if (ioctl(fd, VT_GETMODE, &vtmode) < 0)
- {
- FatalError("xf86OpenPcvt: VT_GETMODE failed");
- }
- xf86Info.consType = PCVT;
+ if (fd >= 0) {
+ if (ioctl(fd, VGAPCVTID, &pcvt_version) >= 0) {
+ if (ioctl(fd, VT_GETMODE, &vtmode) < 0) {
+ FatalError("%s: VT_GETMODE failed\n%s%s\n%s",
+ "xf86OpenPcvt",
+ "Found pcvt driver but X11 seems to be",
+ " not supported.", CHECK_DRIVER_MSG);
+ }
+
+ xf86Info.vtno = VTnum;
+
+ if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
+ initialVT = -1;
+
+ if (xf86Info.vtno == -1) {
+ if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) {
+ /* No free VTs */
+ xf86Info.vtno = -1;
+ }
+
+ if (xf86Info.vtno == -1) {
+ /*
+ * All VTs are in use. If initialVT was found, use it.
+ */
+ if (initialVT != -1) {
+ xf86Info.vtno = initialVT;
+ }
+ else {
+ FatalError("%s: Cannot find a free VT", "xf86OpenPcvt");
+ }
+ }
+ }
+
+ close(fd);
+ snprintf(vtname, sizeof(vtname), "%s%01x", vtprefix,
+ xf86Info.vtno - 1);
+ if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) {
+ ErrorF("xf86OpenPcvt: Cannot open %s (%s)",
+ vtname, strerror(errno));
+ xf86Info.vtno = initialVT;
+ snprintf(vtname, sizeof(vtname), "%s%01x", vtprefix,
+ xf86Info.vtno - 1);
+ if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) {
+ FatalError("xf86OpenPcvt: Cannot open %s (%s)",
+ vtname, strerror(errno));
+ }
+ }
+ if (ioctl(fd, VT_GETMODE, &vtmode) < 0) {
+ FatalError("xf86OpenPcvt: VT_GETMODE failed");
+ }
+ xf86Info.consType = PCVT;
#ifdef WSCONS_SUPPORT
- xf86Msg(X_PROBED,
- "Using wscons driver on %s in pcvt compatibility mode "
- "(version %d.%d)\n", vtname,
- pcvt_version.rmajor, pcvt_version.rminor);
+ xf86Msg(X_PROBED,
+ "Using wscons driver on %s in pcvt compatibility mode "
+ "(version %d.%d)\n", vtname,
+ pcvt_version.rmajor, pcvt_version.rminor);
#else
- xf86Msg(X_PROBED, "Using pcvt driver (version %d.%d)\n",
- pcvt_version.rmajor, pcvt_version.rminor);
-#endif
- }
- else
- {
- /* Not pcvt */
- close(fd);
- fd = -1;
- }
+ xf86Msg(X_PROBED, "Using pcvt driver (version %d.%d)\n",
+ pcvt_version.rmajor, pcvt_version.rminor);
+#endif
+ }
+ else {
+ /* Not pcvt */
+ close(fd);
+ fd = -1;
+ }
}
return fd;
}
-#endif /* PCVT_SUPPORT */
+#endif /* PCVT_SUPPORT */
#ifdef WSCONS_SUPPORT
@@ -602,77 +554,75 @@ xf86OpenWScons()
/* XXX Is this ok? */
for (i = 0; i < 8; i++) {
#if defined(__NetBSD__)
- snprintf(ttyname, sizeof(ttyname), "/dev/ttyE%d", i);
+ snprintf(ttyname, sizeof(ttyname), "/dev/ttyE%d", i);
#elif defined(__OpenBSD__)
- snprintf(ttyname, sizeof(ttyname), "/dev/ttyC%x", i);
+ snprintf(ttyname, sizeof(ttyname), "/dev/ttyC%x", i);
#endif
- if ((fd = open(ttyname, 2)) != -1)
- break;
+ if ((fd = open(ttyname, 2)) != -1)
+ break;
}
if (fd != -1) {
- if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) < 0) {
- FatalError("%s: WSDISPLAYIO_MODE_MAPPED failed (%s)\n%s",
- "xf86OpenConsole", strerror(errno),
- CHECK_DRIVER_MSG);
- }
- xf86Info.consType = WSCONS;
- xf86Msg(X_PROBED, "Using wscons driver\n");
+ if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) < 0) {
+ FatalError("%s: WSDISPLAYIO_MODE_MAPPED failed (%s)\n%s",
+ "xf86OpenConsole", strerror(errno), CHECK_DRIVER_MSG);
+ }
+ xf86Info.consType = WSCONS;
+ xf86Msg(X_PROBED, "Using wscons driver\n");
}
return fd;
}
-#endif /* WSCONS_SUPPORT */
+#endif /* WSCONS_SUPPORT */
void
xf86CloseConsole()
{
#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
- struct vt_mode VT;
+ struct vt_mode VT;
#endif
- if (xf86Info.ShareVTs) return;
+ if (xf86Info.ShareVTs)
+ return;
- switch (xf86Info.consType)
- {
+ switch (xf86Info.consType) {
#ifdef PCCONS_SUPPORT
case PCCONS:
- ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_OFF, 0);
- break;
-#endif /* PCCONS_SUPPORT */
+ ioctl(xf86Info.consoleFd, CONSOLE_X_MODE_OFF, 0);
+ break;
+#endif /* PCCONS_SUPPORT */
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
case SYSCONS:
case PCVT:
ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode */
- if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
- {
- VT.mode = VT_AUTO;
- ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) {
+ VT.mode = VT_AUTO;
+ ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */
}
#if !defined(__OpenBSD__) && !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
- if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0)
- {
+ if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0) {
xf86FatalError("xf86CloseConsole: KDDISABIO failed (%s)",
- strerror(errno));
+ strerror(errno));
}
#endif
- if (initialVT != -1)
- ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT);
+ if (initialVT != -1)
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT);
break;
-#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
#ifdef WSCONS_SUPPORT
case WSCONS:
- {
- int mode = WSDISPLAYIO_MODE_EMUL;
- ioctl(xf86Info.consoleFd, WSDISPLAYIO_SMODE, &mode);
- break;
- }
+ {
+ int mode = WSDISPLAYIO_MODE_EMUL;
+
+ ioctl(xf86Info.consoleFd, WSDISPLAYIO_SMODE, &mode);
+ break;
+ }
#endif
}
close(xf86Info.consoleFd);
#ifdef PCCONS_SUPPORT
if (devConsoleFd >= 0)
- close(devConsoleFd);
+ close(devConsoleFd);
#endif
return;
}
@@ -680,38 +630,34 @@ xf86CloseConsole()
int
xf86ProcessArgument(int argc, char *argv[], int i)
{
- /*
- * Keep server from detaching from controlling tty. This is useful
- * when debugging (so the server can receive keyboard signals.
- */
- if (!strcmp(argv[i], "-keeptty"))
- {
- KeepTty = TRUE;
- return 1;
- }
+ /*
+ * Keep server from detaching from controlling tty. This is useful
+ * when debugging (so the server can receive keyboard signals.
+ */
+ if (!strcmp(argv[i], "-keeptty")) {
+ KeepTty = TRUE;
+ return 1;
+ }
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
- {
- if (sscanf(argv[i], "vt%2d", &VTnum) == 0 ||
- VTnum < 1 || VTnum > 12)
- {
- UseMsg();
- VTnum = -1;
- return 0;
- }
- return 1;
- }
-#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
- return 0;
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't')) {
+ if (sscanf(argv[i], "vt%2d", &VTnum) == 0 || VTnum < 1 || VTnum > 12) {
+ UseMsg();
+ VTnum = -1;
+ return 0;
+ }
+ return 1;
+ }
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+ return 0;
}
void
xf86UseMsg()
{
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- ErrorF("vtXX use the specified VT number (1-12)\n");
-#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
- ErrorF("-keeptty ");
- ErrorF("don't detach controlling tty (for debugging only)\n");
- return;
+ ErrorF("vtXX use the specified VT number (1-12)\n");
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+ ErrorF("-keeptty ");
+ ErrorF("don't detach controlling tty (for debugging only)\n");
+ return;
}
diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_kmod.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_kmod.c
index 34e434188..150bb0db4 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/bsd_kmod.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_kmod.c
@@ -19,10 +19,11 @@
* Return:
* 0 for failure, 1 for success
*/
-int xf86LoadKernelModule(const char *modName)
+int
+xf86LoadKernelModule(const char *modName)
{
if (kldload(modName) != -1)
- return 1;
+ return 1;
else
- return 0;
+ return 0;
}
diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c
index 053619e1d..10251f38e 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c
@@ -53,20 +53,22 @@ static void bsdCloseAPM(void);
static struct {
u_int apmBsd;
pmEvent xf86;
-} bsdToXF86Array [] = {
- { APM_STANDBY_REQ, XF86_APM_SYS_STANDBY },
- { APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND },
- { APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME },
- { APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME },
- { APM_BATTERY_LOW, XF86_APM_LOW_BATTERY },
- { APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE },
- { APM_UPDATE_TIME, XF86_APM_UPDATE_TIME },
- { APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND },
- { APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY },
- { APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND },
- { APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME },
+} bsdToXF86Array[] = {
+ {
+ APM_STANDBY_REQ, XF86_APM_SYS_STANDBY}, {
+ APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND}, {
+ APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, {
+ APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME}, {
+ APM_BATTERY_LOW, XF86_APM_LOW_BATTERY}, {
+ APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, {
+ APM_UPDATE_TIME, XF86_APM_UPDATE_TIME}, {
+ APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND}, {
+ APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY}, {
+ APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND}, {
+ APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME},
#ifdef APM_CAPABILITY_CHANGE
- { APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED },
+ {
+ APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED},
#endif
};
@@ -78,9 +80,9 @@ bsdToXF86(int type)
int i;
for (i = 0; i < numApmEvents; i++) {
- if (type == bsdToXF86Array[i].apmBsd) {
- return bsdToXF86Array[i].xf86;
- }
+ if (type == bsdToXF86Array[i].apmBsd) {
+ return bsdToXF86Array[i].xf86;
+ }
}
return XF86_APM_UNKNOWN;
}
@@ -88,24 +90,25 @@ bsdToXF86(int type)
/*
* APM events can be requested direclty from /dev/apm
*/
-static int
-bsdPMGetEventFromOS(int kq, pmEvent *events, int num)
+static int
+bsdPMGetEventFromOS(int kq, pmEvent * events, int num)
{
struct kevent ev;
int i, result;
struct timespec ts = { 0, 0 };
-
+
for (i = 0; i < num; i++) {
- result = kevent(kq, NULL, 0, &ev, 1, &ts);
- if (result == 0 || APM_EVENT_TYPE(ev.data) == APM_NOEVENT) {
- /* no event */
- break;
- } else if (result < 0) {
- xf86Msg(X_WARNING, "bsdPMGetEventFromOS: kevent returns"
- " %s\n", strerror(errno));
- break;
- }
- events[i] = bsdToXF86(APM_EVENT_TYPE(ev.data));
+ result = kevent(kq, NULL, 0, &ev, 1, &ts);
+ if (result == 0 || APM_EVENT_TYPE(ev.data) == APM_NOEVENT) {
+ /* no event */
+ break;
+ }
+ else if (result < 0) {
+ xf86Msg(X_WARNING, "bsdPMGetEventFromOS: kevent returns"
+ " %s\n", strerror(errno));
+ break;
+ }
+ events[i] = bsdToXF86(APM_EVENT_TYPE(ev.data));
}
return i;
}
@@ -120,36 +123,36 @@ static pmWait
bsdPMConfirmEventToOs(int dummyfd, pmEvent event)
{
if (ctlFd < 0) {
- if ((ctlFd = open(_PATH_APM_CTLDEV, O_RDWR)) < 0) {
- return PM_NONE;
- }
+ if ((ctlFd = open(_PATH_APM_CTLDEV, O_RDWR)) < 0) {
+ return PM_NONE;
+ }
}
/* apmctl open succeedeed */
switch (event) {
- case XF86_APM_SYS_STANDBY:
- case XF86_APM_USER_STANDBY:
- if (ioctl( ctlFd, APM_IOC_STANDBY, NULL ) == 0)
- return PM_WAIT; /* should we stop the Xserver in standby, too? */
+ case XF86_APM_SYS_STANDBY:
+ case XF86_APM_USER_STANDBY:
+ if (ioctl(ctlFd, APM_IOC_STANDBY, NULL) == 0)
+ return PM_WAIT; /* should we stop the Xserver in standby, too? */
else
return PM_NONE;
- case XF86_APM_SYS_SUSPEND:
- case XF86_APM_CRITICAL_SUSPEND:
- case XF86_APM_USER_SUSPEND:
- if (ioctl( ctlFd, APM_IOC_SUSPEND, NULL ) == 0)
+ case XF86_APM_SYS_SUSPEND:
+ case XF86_APM_CRITICAL_SUSPEND:
+ case XF86_APM_USER_SUSPEND:
+ if (ioctl(ctlFd, APM_IOC_SUSPEND, NULL) == 0)
return PM_WAIT;
else
return PM_NONE;
- break;
- case XF86_APM_STANDBY_RESUME:
- case XF86_APM_NORMAL_RESUME:
- case XF86_APM_CRITICAL_RESUME:
- case XF86_APM_STANDBY_FAILED:
- case XF86_APM_SUSPEND_FAILED:
+ break;
+ case XF86_APM_STANDBY_RESUME:
+ case XF86_APM_NORMAL_RESUME:
+ case XF86_APM_CRITICAL_RESUME:
+ case XF86_APM_STANDBY_FAILED:
+ case XF86_APM_SUSPEND_FAILED:
return PM_CONTINUE;
- break;
- default:
- return PM_NONE;
+ break;
+ default:
+ return PM_NONE;
}
}
@@ -160,20 +163,19 @@ xf86OSPMOpen(void)
struct kevent ev;
if (APMihPtr || !xf86Info.pmFlag) {
- return NULL;
+ return NULL;
}
if ((devFd = open(_PATH_APM_DEV, O_RDONLY)) == -1) {
- return NULL;
+ return NULL;
}
if ((kq = kqueue()) <= 0) {
- close(devFd);
- return NULL;
+ close(devFd);
+ return NULL;
}
- EV_SET(&ev, devFd, EVFILT_READ, EV_ADD | EV_ENABLE | EV_CLEAR,
- 0, 0, NULL);
+ EV_SET(&ev, devFd, EVFILT_READ, EV_ADD | EV_ENABLE | EV_CLEAR, 0, 0, NULL);
if (kevent(kq, &ev, 1, NULL, 0, NULL) < 0) {
- close(devFd);
- return NULL;
+ close(devFd);
+ return NULL;
}
xf86PMGetEventFromOs = bsdPMGetEventFromOS;
@@ -188,14 +190,14 @@ bsdCloseAPM(void)
int kq;
if (APMihPtr) {
- kq = xf86RemoveGeneralHandler(APMihPtr);
- close(devFd);
- devFd = -1;
- close(kq);
- if (ctlFd >= 0) {
- close(ctlFd);
- ctlFd = -1;
- }
- APMihPtr = NULL;
+ kq = xf86RemoveGeneralHandler(APMihPtr);
+ close(devFd);
+ devFd = -1;
+ close(kq);
+ if (ctlFd >= 0) {
+ close(ctlFd);
+ ctlFd = -1;
+ }
+ APMihPtr = NULL;
}
}
diff --git a/xorg-server/hw/xfree86/os-support/bsd/i386_video.c b/xorg-server/hw/xfree86/os-support/bsd/i386_video.c
index 35e00fce7..569a4ec51 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/i386_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/i386_video.c
@@ -79,7 +79,7 @@
/***************************************************************************/
static Bool useDevMem = FALSE;
-static int devMemFd = -1;
+static int devMemFd = -1;
#ifdef HAS_APERTURE_DRV
#define DEV_APERTURE "/dev/xf86"
@@ -95,7 +95,7 @@ static Bool cleanMTRR(void);
#endif
#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
static pointer NetBSDsetWC(int, unsigned long, unsigned long, Bool,
- MessageType);
+ MessageType);
static void NetBSDundoWC(int, pointer);
#endif
@@ -106,85 +106,80 @@ static void NetBSDundoWC(int, pointer);
static void
checkDevMem(Bool warn)
{
- static Bool devMemChecked = FALSE;
- int fd;
- pointer base;
-
- if (devMemChecked)
- return;
- devMemChecked = TRUE;
-
- if ((fd = open(DEV_MEM, O_RDWR)) >= 0)
- {
- /* Try to map a page at the VGA address */
- base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
- MAP_FLAGS, fd, (off_t)0xA0000);
-
- if (base != MAP_FAILED)
- {
- munmap((caddr_t)base, 4096);
- devMemFd = fd;
- useDevMem = TRUE;
- return;
- } else {
- /* This should not happen */
- if (warn)
- {
- xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
- DEV_MEM, strerror(errno));
- }
- useDevMem = FALSE;
- return;
- }
- }
+ static Bool devMemChecked = FALSE;
+ int fd;
+ pointer base;
+
+ if (devMemChecked)
+ return;
+ devMemChecked = TRUE;
+
+ if ((fd = open(DEV_MEM, O_RDWR)) >= 0) {
+ /* Try to map a page at the VGA address */
+ base = mmap((caddr_t) 0, 4096, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t) 0xA0000);
+
+ if (base != MAP_FAILED) {
+ munmap((caddr_t) base, 4096);
+ devMemFd = fd;
+ useDevMem = TRUE;
+ return;
+ }
+ else {
+ /* This should not happen */
+ if (warn) {
+ xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ useDevMem = FALSE;
+ return;
+ }
+ }
#ifndef HAS_APERTURE_DRV
- if (warn)
- {
- xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- }
- useDevMem = FALSE;
- return;
+ if (warn) {
+ xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ useDevMem = FALSE;
+ return;
#else
- /* Failed to open /dev/mem, try the aperture driver */
- if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0)
- {
- /* Try to map a page at the VGA address */
- base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
- MAP_FLAGS, fd, (off_t)0xA0000);
-
- if (base != MAP_FAILED)
- {
- munmap((caddr_t)base, 4096);
- devMemFd = fd;
- useDevMem = TRUE;
- xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n",
- DEV_APERTURE);
- return;
- } else {
-
- if (warn)
- {
- xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
- DEV_APERTURE, strerror(errno));
- }
- }
- } else {
- if (warn)
- {
+ /* Failed to open /dev/mem, try the aperture driver */
+ if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0) {
+ /* Try to map a page at the VGA address */
+ base = mmap((caddr_t) 0, 4096, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t) 0xA0000);
+
+ if (base != MAP_FAILED) {
+ munmap((caddr_t) base, 4096);
+ devMemFd = fd;
+ useDevMem = TRUE;
+ xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n",
+ DEV_APERTURE);
+ return;
+ }
+ else {
+
+ if (warn) {
+ xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
+ DEV_APERTURE, strerror(errno));
+ }
+ }
+ }
+ else {
+ if (warn) {
#ifndef __OpenBSD__
- xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
- "\t(%s)\n", DEV_MEM, DEV_APERTURE, strerror(errno));
-#else /* __OpenBSD__ */
- xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
- "\t(%s)\n%s", DEV_MEM, DEV_APERTURE, strerror(errno),
- SYSCTL_MSG);
-#endif /* __OpenBSD__ */
- }
- }
-
- useDevMem = FALSE;
- return;
+ xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
+ "\t(%s)\n", DEV_MEM, DEV_APERTURE, strerror(errno));
+#else /* __OpenBSD__ */
+ xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
+ "\t(%s)\n%s", DEV_MEM, DEV_APERTURE, strerror(errno),
+ SYSCTL_MSG);
+#endif /* __OpenBSD__ */
+ }
+ }
+
+ useDevMem = FALSE;
+ return;
#endif
}
@@ -192,80 +187,72 @@ checkDevMem(Bool warn)
void
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
- checkDevMem(TRUE);
- pVidMem->linearSupported = useDevMem;
- pVidMem->mapMem = mapVidMem;
- pVidMem->unmapMem = unmapVidMem;
+ checkDevMem(TRUE);
+ pVidMem->linearSupported = useDevMem;
+ pVidMem->mapMem = mapVidMem;
+ pVidMem->unmapMem = unmapVidMem;
- if (useDevMem)
- pci_system_init_dev_mem(devMemFd);
+ if (useDevMem)
+ pci_system_init_dev_mem(devMemFd);
#ifdef HAS_MTRR_SUPPORT
- if (useDevMem) {
- if (cleanMTRR()) {
- pVidMem->setWC = setWC;
- pVidMem->undoWC = undoWC;
- }
- }
+ if (useDevMem) {
+ if (cleanMTRR()) {
+ pVidMem->setWC = setWC;
+ pVidMem->undoWC = undoWC;
+ }
+ }
#endif
#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
- pVidMem->setWC = NetBSDsetWC;
- pVidMem->undoWC = NetBSDundoWC;
+ pVidMem->setWC = NetBSDsetWC;
+ pVidMem->undoWC = NetBSDundoWC;
#endif
- pVidMem->initialised = TRUE;
+ pVidMem->initialised = TRUE;
}
static pointer
mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
{
- pointer base;
-
- checkDevMem(FALSE);
-
- if (useDevMem)
- {
- if (devMemFd < 0)
- {
- FatalError("xf86MapVidMem: failed to open %s (%s)",
- DEV_MEM, strerror(errno));
- }
- base = mmap((caddr_t)0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_FLAGS, devMemFd, (off_t)Base);
- if (base == MAP_FAILED)
- {
- FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)",
- "xf86MapVidMem", DEV_MEM, Size, Base,
- strerror(errno));
- }
- return base;
- }
-
- /* else, mmap /dev/vga */
- if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000)
- {
- FatalError("%s: Address 0x%lx outside allowable range",
- "xf86MapVidMem", Base);
- }
- base = mmap(0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_FLAGS, xf86Info.consoleFd,
- (unsigned long)Base - 0xA0000
- );
- if (base == MAP_FAILED)
- {
- FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)",
- strerror(errno));
- }
- return base;
+ pointer base;
+
+ checkDevMem(FALSE);
+
+ if (useDevMem) {
+ if (devMemFd < 0) {
+ FatalError("xf86MapVidMem: failed to open %s (%s)",
+ DEV_MEM, strerror(errno));
+ }
+ base = mmap((caddr_t) 0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FLAGS, devMemFd, (off_t) Base);
+ if (base == MAP_FAILED) {
+ FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)",
+ "xf86MapVidMem", DEV_MEM, Size, Base, strerror(errno));
+ }
+ return base;
+ }
+
+ /* else, mmap /dev/vga */
+ if ((unsigned long) Base < 0xA0000 || (unsigned long) Base >= 0xC0000) {
+ FatalError("%s: Address 0x%lx outside allowable range",
+ "xf86MapVidMem", Base);
+ }
+ base = mmap(0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FLAGS, xf86Info.consoleFd, (unsigned long) Base - 0xA0000);
+ if (base == MAP_FAILED) {
+ FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)",
+ strerror(errno));
+ }
+ return base;
}
static void
unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
{
- munmap((caddr_t)Base, Size);
+ munmap((caddr_t) Base, Size);
}
/*
@@ -274,47 +261,46 @@ unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
int
xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
+ int Len)
{
- unsigned char *ptr;
- int psize;
- int mlen;
-
- checkDevMem(TRUE);
- if (devMemFd == -1) {
- return -1;
- }
-
- psize = getpagesize();
- Offset += Base & (psize - 1);
- Base &= ~(psize - 1);
- mlen = (Offset + Len + psize - 1) & ~(psize - 1);
- ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
- MAP_SHARED, devMemFd, (off_t)Base);
- if ((long)ptr == -1)
- {
- xf86Msg(X_WARNING,
- "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n",
- DEV_MEM, Len, Base, Offset, strerror(errno));
+ unsigned char *ptr;
+ int psize;
+ int mlen;
+
+ checkDevMem(TRUE);
+ if (devMemFd == -1) {
+ return -1;
+ }
+
+ psize = getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+ ptr = (unsigned char *) mmap((caddr_t) 0, mlen, PROT_READ,
+ MAP_SHARED, devMemFd, (off_t) Base);
+ if ((long) ptr == -1) {
+ xf86Msg(X_WARNING,
+ "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n",
+ DEV_MEM, Len, Base, Offset, strerror(errno));
#ifdef __OpenBSD__
- if (Base < 0xa0000) {
- xf86Msg(X_WARNING, SYSCTL_MSG2);
- }
+ if (Base < 0xa0000) {
+ xf86Msg(X_WARNING, SYSCTL_MSG2);
+ }
#endif
- return -1;
- }
+ return -1;
+ }
#ifdef DEBUG
- ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
- Base, ptr[0] | (ptr[1] << 8));
+ ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
+ Base, ptr[0] | (ptr[1] << 8));
#endif
- (void)memcpy(Buf, (void *)(ptr + Offset), Len);
- (void)munmap((caddr_t)ptr, mlen);
+ (void) memcpy(Buf, (void *) (ptr + Offset), Len);
+ (void) munmap((caddr_t) ptr, mlen);
#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
- "-> %02x %02x %02x %02x...\n",
- Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
+ xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
+ "-> %02x %02x %02x %02x...\n",
+ Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
#endif
- return Len;
+ return Len;
}
#ifdef USE_I386_IOPL
@@ -327,38 +313,37 @@ static Bool ExtendedEnabled = FALSE;
Bool
xf86EnableIO()
{
- if (ExtendedEnabled)
- return TRUE;
+ if (ExtendedEnabled)
+ return TRUE;
- if (i386_iopl(TRUE) < 0)
- {
+ if (i386_iopl(TRUE) < 0) {
#ifndef __OpenBSD__
- xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O",
- "xf86EnableIO");
+ xf86Msg(X_WARNING, "%s: Failed to set IOPL for extended I/O",
+ "xf86EnableIO");
#else
- xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O\n%s",
- "xf86EnableIO", SYSCTL_MSG);
+ xf86Msg(X_WARNING, "%s: Failed to set IOPL for extended I/O\n%s",
+ "xf86EnableIO", SYSCTL_MSG);
#endif
- return FALSE;
- }
- ExtendedEnabled = TRUE;
+ return FALSE;
+ }
+ ExtendedEnabled = TRUE;
- return TRUE;
+ return TRUE;
}
-
+
void
xf86DisableIO()
{
- if (!ExtendedEnabled)
- return;
+ if (!ExtendedEnabled)
+ return;
- i386_iopl(FALSE);
- ExtendedEnabled = FALSE;
+ i386_iopl(FALSE);
+ ExtendedEnabled = FALSE;
- return;
+ return;
}
-#endif /* USE_I386_IOPL */
+#endif /* USE_I386_IOPL */
#ifdef USE_AMD64_IOPL
/***************************************************************************/
@@ -370,41 +355,40 @@ static Bool ExtendedEnabled = FALSE;
Bool
xf86EnableIO()
{
- if (ExtendedEnabled)
- return TRUE;
+ if (ExtendedEnabled)
+ return TRUE;
- if (amd64_iopl(TRUE) < 0)
- {
+ if (amd64_iopl(TRUE) < 0) {
#ifndef __OpenBSD__
- xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O",
- "xf86EnableIO");
+ xf86Msg(X_WARNING, "%s: Failed to set IOPL for extended I/O",
+ "xf86EnableIO");
#else
- xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O\n%s",
- "xf86EnableIO", SYSCTL_MSG);
+ xf86Msg(X_WARNING, "%s: Failed to set IOPL for extended I/O\n%s",
+ "xf86EnableIO", SYSCTL_MSG);
#endif
- return FALSE;
- }
- ExtendedEnabled = TRUE;
+ return FALSE;
+ }
+ ExtendedEnabled = TRUE;
- return TRUE;
+ return TRUE;
}
-
+
void
xf86DisableIO()
{
- if (!ExtendedEnabled)
- return;
-
- if (amd64_iopl(FALSE) == 0) {
- ExtendedEnabled = FALSE;
- }
- /* Otherwise, the X server has revoqued its root uid,
- and thus cannot give up IO privileges any more */
-
- return;
+ if (!ExtendedEnabled)
+ return;
+
+ if (amd64_iopl(FALSE) == 0) {
+ ExtendedEnabled = FALSE;
+ }
+ /* Otherwise, the X server has revoqued its root uid,
+ and thus cannot give up IO privileges any more */
+
+ return;
}
-#endif /* USE_AMD64_IOPL */
+#endif /* USE_AMD64_IOPL */
#ifdef USE_DEV_IO
static int IoFd = -1;
@@ -412,27 +396,26 @@ static int IoFd = -1;
Bool
xf86EnableIO()
{
- if (IoFd >= 0)
- return TRUE;
-
- if ((IoFd = open("/dev/io", O_RDWR)) == -1)
- {
- xf86Msg(X_WARNING,"xf86EnableIO: "
- "Failed to open /dev/io for extended I/O");
- return FALSE;
- }
- return TRUE;
+ if (IoFd >= 0)
+ return TRUE;
+
+ if ((IoFd = open("/dev/io", O_RDWR)) == -1) {
+ xf86Msg(X_WARNING, "xf86EnableIO: "
+ "Failed to open /dev/io for extended I/O");
+ return FALSE;
+ }
+ return TRUE;
}
void
xf86DisableIO()
{
- if (IoFd < 0)
- return;
+ if (IoFd < 0)
+ return;
- close(IoFd);
- IoFd = -1;
- return;
+ close(IoFd);
+ IoFd = -1;
+ return;
}
#endif
@@ -443,50 +426,46 @@ xf86DisableIO()
/***************************************************************************/
void
xf86SetTVOut(int mode)
-{
- switch (xf86Info.consType)
- {
+{
+ switch (xf86Info.consType) {
#ifdef PCCONS_SUPPORT
- case PCCONS:{
-
- if (ioctl (xf86Info.consoleFd, CONSOLE_X_TV_ON, &mode) < 0)
- {
- xf86Msg(X_WARNING,
- "xf86SetTVOut: Could not set console to TV output, %s\n",
- strerror(errno));
- }
- }
- break;
-#endif /* PCCONS_SUPPORT */
-
- default:
- FatalError("Xf86SetTVOut: Unsupported console");
- break;
+ case PCCONS:{
+
+ if (ioctl(xf86Info.consoleFd, CONSOLE_X_TV_ON, &mode) < 0) {
+ xf86Msg(X_WARNING,
+ "xf86SetTVOut: Could not set console to TV output, %s\n",
+ strerror(errno));
+ }
+ }
+ break;
+#endif /* PCCONS_SUPPORT */
+
+ default:
+ FatalError("Xf86SetTVOut: Unsupported console");
+ break;
}
return;
}
void
xf86SetRGBOut()
-{
- switch (xf86Info.consType)
- {
+{
+ switch (xf86Info.consType) {
#ifdef PCCONS_SUPPORT
- case PCCONS:{
-
- if (ioctl (xf86Info.consoleFd, CONSOLE_X_TV_OFF, 0) < 0)
- {
- xf86Msg(X_WARNING,
- "xf86SetTVOut: Could not set console to RGB output, %s\n",
- strerror(errno));
- }
- }
- break;
-#endif /* PCCONS_SUPPORT */
-
- default:
- FatalError("Xf86SetTVOut: Unsupported console");
- break;
+ case PCCONS:{
+
+ if (ioctl(xf86Info.consoleFd, CONSOLE_X_TV_OFF, 0) < 0) {
+ xf86Msg(X_WARNING,
+ "xf86SetTVOut: Could not set console to RGB output, %s\n",
+ strerror(errno));
+ }
+ }
+ break;
+#endif /* PCCONS_SUPPORT */
+
+ default:
+ FatalError("Xf86SetTVOut: Unsupported console");
+ break;
}
return;
}
@@ -507,25 +486,25 @@ xf86SetRGBOut()
static struct mem_range_desc *
getAllRanges(int *nmr)
{
- struct mem_range_desc *mrd;
- struct mem_range_op mro;
-
- /*
- * Find how many ranges there are. If this fails, then the kernel
- * probably doesn't have MTRR support.
- */
- mro.mo_arg[0] = 0;
- if (ioctl(devMemFd, MEMRANGE_GET, &mro))
- return NULL;
- *nmr = mro.mo_arg[0];
- mrd = xnfalloc(*nmr * sizeof(struct mem_range_desc));
- mro.mo_arg[0] = *nmr;
- mro.mo_desc = mrd;
- if (ioctl(devMemFd, MEMRANGE_GET, &mro)) {
- free(mrd);
- return NULL;
- }
- return mrd;
+ struct mem_range_desc *mrd;
+ struct mem_range_op mro;
+
+ /*
+ * Find how many ranges there are. If this fails, then the kernel
+ * probably doesn't have MTRR support.
+ */
+ mro.mo_arg[0] = 0;
+ if (ioctl(devMemFd, MEMRANGE_GET, &mro))
+ return NULL;
+ *nmr = mro.mo_arg[0];
+ mrd = xnfalloc(*nmr * sizeof(struct mem_range_desc));
+ mro.mo_arg[0] = *nmr;
+ mro.mo_desc = mrd;
+ if (ioctl(devMemFd, MEMRANGE_GET, &mro)) {
+ free(mrd);
+ return NULL;
+ }
+ return mrd;
}
/*
@@ -537,109 +516,111 @@ getAllRanges(int *nmr)
static Bool
cleanMTRR()
{
- struct mem_range_desc *mrd;
- struct mem_range_op mro;
- int nmr, i;
+ struct mem_range_desc *mrd;
+ struct mem_range_op mro;
+ int nmr, i;
- /* This shouldn't happen */
- if (devMemFd < 0)
- return FALSE;
+ /* This shouldn't happen */
+ if (devMemFd < 0)
+ return FALSE;
- if (!(mrd = getAllRanges(&nmr)))
- return FALSE;
+ if (!(mrd = getAllRanges(&nmr)))
+ return FALSE;
- for (i = 0; i < nmr; i++) {
- if (strcmp(mrd[i].mr_owner, X_MTRR_ID) == 0 &&
- (mrd[i].mr_flags & MDF_ACTIVE)) {
+ for (i = 0; i < nmr; i++) {
+ if (strcmp(mrd[i].mr_owner, X_MTRR_ID) == 0 &&
+ (mrd[i].mr_flags & MDF_ACTIVE)) {
#ifdef DEBUG
- ErrorF("Clean for (0x%lx,0x%lx)\n",
- (unsigned long)mrd[i].mr_base,
- (unsigned long)mrd[i].mr_len);
+ ErrorF("Clean for (0x%lx,0x%lx)\n",
+ (unsigned long) mrd[i].mr_base,
+ (unsigned long) mrd[i].mr_len);
#endif
- if (mrd[i].mr_flags & MDF_FIXACTIVE) {
- mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
- mrd[i].mr_flags = MDF_UNCACHEABLE;
- } else {
- mro.mo_arg[0] = MEMRANGE_SET_REMOVE;
- }
- mro.mo_desc = mrd + i;
- ioctl(devMemFd, MEMRANGE_SET, &mro);
- }
- }
+ if (mrd[i].mr_flags & MDF_FIXACTIVE) {
+ mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ mrd[i].mr_flags = MDF_UNCACHEABLE;
+ }
+ else {
+ mro.mo_arg[0] = MEMRANGE_SET_REMOVE;
+ }
+ mro.mo_desc = mrd + i;
+ ioctl(devMemFd, MEMRANGE_SET, &mro);
+ }
+ }
#ifdef DEBUG
- sleep(10);
+ sleep(10);
#endif
- free(mrd);
- return TRUE;
+ free(mrd);
+ return TRUE;
}
typedef struct x_RangeRec {
- struct mem_range_desc mrd;
- Bool wasWC;
- struct x_RangeRec * next;
+ struct mem_range_desc mrd;
+ Bool wasWC;
+ struct x_RangeRec *next;
} RangeRec, *RangePtr;
static void
freeRangeList(RangePtr range)
{
- RangePtr rp;
+ RangePtr rp;
- while (range) {
- rp = range;
- range = rp->next;
- free(rp);
- }
+ while (range) {
+ rp = range;
+ range = rp->next;
+ free(rp);
+ }
}
static RangePtr
dupRangeList(RangePtr list)
{
- RangePtr new = NULL, rp, p;
-
- rp = list;
- while (rp) {
- p = xnfalloc(sizeof(RangeRec));
- *p = *rp;
- p->next = new;
- new = p;
- rp = rp->next;
- }
- return new;
+ RangePtr new = NULL, rp, p;
+
+ rp = list;
+ while (rp) {
+ p = xnfalloc(sizeof(RangeRec));
+ *p = *rp;
+ p->next = new;
+ new = p;
+ rp = rp->next;
+ }
+ return new;
}
static RangePtr
sortRangeList(RangePtr list)
{
- RangePtr rp1, rp2, copy, sorted = NULL, minp, prev, minprev;
- unsigned long minBase;
-
- /* Sort by base address */
- rp1 = copy = dupRangeList(list);
- while (rp1) {
- minBase = rp1->mrd.mr_base;
- minp = rp1;
- minprev = NULL;
- prev = rp1;
- rp2 = rp1->next;
- while (rp2) {
- if (rp2->mrd.mr_base < minBase) {
- minBase = rp2->mrd.mr_base;
- minp = rp2;
- minprev = prev;
- }
- prev = rp2;
- rp2 = rp2->next;
- }
- if (minprev) {
- minprev->next = minp->next;
- rp1 = copy;
- } else {
- rp1 = minp->next;
- }
- minp->next = sorted;
- sorted = minp;
- }
- return sorted;
+ RangePtr rp1, rp2, copy, sorted = NULL, minp, prev, minprev;
+ unsigned long minBase;
+
+ /* Sort by base address */
+ rp1 = copy = dupRangeList(list);
+ while (rp1) {
+ minBase = rp1->mrd.mr_base;
+ minp = rp1;
+ minprev = NULL;
+ prev = rp1;
+ rp2 = rp1->next;
+ while (rp2) {
+ if (rp2->mrd.mr_base < minBase) {
+ minBase = rp2->mrd.mr_base;
+ minp = rp2;
+ minprev = prev;
+ }
+ prev = rp2;
+ rp2 = rp2->next;
+ }
+ if (minprev) {
+ minprev->next = minp->next;
+ rp1 = copy;
+ }
+ else {
+ rp1 = minp->next;
+ }
+ minp->next = sorted;
+ sorted = minp;
+ }
+ return sorted;
}
/*
@@ -647,32 +628,33 @@ sortRangeList(RangePtr list)
*/
static void
-findRanges(unsigned long base, unsigned long size, RangePtr *ucp, RangePtr *wcp)
+findRanges(unsigned long base, unsigned long size, RangePtr * ucp,
+ RangePtr * wcp)
{
- struct mem_range_desc *mrd;
- int nmr, i;
- RangePtr rp, *p;
-
- if (!(mrd = getAllRanges(&nmr)))
- return;
-
- for (i = 0; i < nmr; i++) {
- if ((mrd[i].mr_flags & MDF_ACTIVE) &&
- mrd[i].mr_base < base + size &&
- mrd[i].mr_base + mrd[i].mr_len > base) {
- if (mrd[i].mr_flags & MDF_WRITECOMBINE)
- p = wcp;
- else if (mrd[i].mr_flags & MDF_UNCACHEABLE)
- p = ucp;
- else
- continue;
- rp = xnfalloc(sizeof(RangeRec));
- rp->mrd = mrd[i];
- rp->next = *p;
- *p = rp;
- }
- }
- free(mrd);
+ struct mem_range_desc *mrd;
+ int nmr, i;
+ RangePtr rp, *p;
+
+ if (!(mrd = getAllRanges(&nmr)))
+ return;
+
+ for (i = 0; i < nmr; i++) {
+ if ((mrd[i].mr_flags & MDF_ACTIVE) &&
+ mrd[i].mr_base < base + size &&
+ mrd[i].mr_base + mrd[i].mr_len > base) {
+ if (mrd[i].mr_flags & MDF_WRITECOMBINE)
+ p = wcp;
+ else if (mrd[i].mr_flags & MDF_UNCACHEABLE)
+ p = ucp;
+ else
+ continue;
+ rp = xnfalloc(sizeof(RangeRec));
+ rp->mrd = mrd[i];
+ rp->next = *p;
+ *p = rp;
+ }
+ }
+ free(mrd);
}
/*
@@ -683,219 +665,222 @@ findRanges(unsigned long base, unsigned long size, RangePtr *ucp, RangePtr *wcp)
static Bool
fullCoverage(unsigned long base, unsigned long size, RangePtr overlap)
{
- RangePtr rp1, sorted = NULL;
- unsigned long end;
-
- sorted = sortRangeList(overlap);
- /* Look for gaps */
- rp1 = sorted;
- end = base + size;
- while (rp1) {
- if (rp1->mrd.mr_base > base) {
- freeRangeList(sorted);
- return FALSE;
- } else {
- base = rp1->mrd.mr_base + rp1->mrd.mr_len;
- }
- if (base >= end) {
- freeRangeList(sorted);
- return TRUE;
- }
- rp1 = rp1->next;
- }
- freeRangeList(sorted);
- return FALSE;
+ RangePtr rp1, sorted = NULL;
+ unsigned long end;
+
+ sorted = sortRangeList(overlap);
+ /* Look for gaps */
+ rp1 = sorted;
+ end = base + size;
+ while (rp1) {
+ if (rp1->mrd.mr_base > base) {
+ freeRangeList(sorted);
+ return FALSE;
+ }
+ else {
+ base = rp1->mrd.mr_base + rp1->mrd.mr_len;
+ }
+ if (base >= end) {
+ freeRangeList(sorted);
+ return TRUE;
+ }
+ rp1 = rp1->next;
+ }
+ freeRangeList(sorted);
+ return FALSE;
}
static pointer
addWC(int screenNum, unsigned long base, unsigned long size, MessageType from)
{
- RangePtr uc = NULL, wc = NULL, retlist = NULL;
- struct mem_range_desc mrd;
- struct mem_range_op mro;
-
- findRanges(base, size, &uc, &wc);
-
- /* See of the full range is already WC */
- if (!uc && fullCoverage(base, size, wc)) {
- xf86DrvMsg(screenNum, from,
- "Write-combining range (0x%lx,0x%lx) was already set\n",
- base, size);
- return NULL;
- }
-
- /* Otherwise, try to add the new range */
- mrd.mr_base = base;
- mrd.mr_len = size;
- strcpy(mrd.mr_owner, X_MTRR_ID);
- mrd.mr_flags = MDF_WRITECOMBINE;
- mro.mo_desc = &mrd;
- mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
- if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
- xf86DrvMsg(screenNum, X_WARNING,
- "Failed to set write-combining range "
- "(0x%lx,0x%lx)\n", base, size);
- return NULL;
- } else {
- xf86DrvMsg(screenNum, from,
- "Write-combining range (0x%lx,0x%lx)\n", base, size);
- retlist = xnfalloc(sizeof(RangeRec));
- retlist->mrd = mrd;
- retlist->wasWC = FALSE;
- retlist->next = NULL;
- return retlist;
- }
+ RangePtr uc = NULL, wc = NULL, retlist = NULL;
+ struct mem_range_desc mrd;
+ struct mem_range_op mro;
+
+ findRanges(base, size, &uc, &wc);
+
+ /* See of the full range is already WC */
+ if (!uc && fullCoverage(base, size, wc)) {
+ xf86DrvMsg(screenNum, from,
+ "Write-combining range (0x%lx,0x%lx) was already set\n",
+ base, size);
+ return NULL;
+ }
+
+ /* Otherwise, try to add the new range */
+ mrd.mr_base = base;
+ mrd.mr_len = size;
+ strcpy(mrd.mr_owner, X_MTRR_ID);
+ mrd.mr_flags = MDF_WRITECOMBINE;
+ mro.mo_desc = &mrd;
+ mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "Failed to set write-combining range "
+ "(0x%lx,0x%lx)\n", base, size);
+ return NULL;
+ }
+ else {
+ xf86DrvMsg(screenNum, from,
+ "Write-combining range (0x%lx,0x%lx)\n", base, size);
+ retlist = xnfalloc(sizeof(RangeRec));
+ retlist->mrd = mrd;
+ retlist->wasWC = FALSE;
+ retlist->next = NULL;
+ return retlist;
+ }
}
static pointer
delWC(int screenNum, unsigned long base, unsigned long size, MessageType from)
{
- RangePtr uc = NULL, wc = NULL, retlist = NULL;
- struct mem_range_desc mrd;
- struct mem_range_op mro;
-
- findRanges(base, size, &uc, &wc);
-
- /*
- * See of the full range is already not WC, or if there is full
- * coverage from UC ranges.
- */
- if (!wc || fullCoverage(base, size, uc)) {
- xf86DrvMsg(screenNum, from,
- "Write-combining range (0x%lx,0x%lx) was already clear\n",
- base, size);
- return NULL;
- }
-
- /* Otherwise, try to add the new range */
- mrd.mr_base = base;
- mrd.mr_len = size;
- strcpy(mrd.mr_owner, X_MTRR_ID);
- mrd.mr_flags = MDF_UNCACHEABLE;
- mro.mo_desc = &mrd;
- mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
- if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
- xf86DrvMsg(screenNum, X_WARNING,
- "Failed to remove write-combining range "
- "(0x%lx,0x%lx)\n", base, size);
- /* XXX Should then remove all of the overlapping WC ranges */
- return NULL;
- } else {
- xf86DrvMsg(screenNum, from,
- "Removed Write-combining range (0x%lx,0x%lx)\n",
- base, size);
- retlist = xnfalloc(sizeof(RangeRec));
- retlist->mrd = mrd;
- retlist->wasWC = TRUE;
- retlist->next = NULL;
- return retlist;
- }
+ RangePtr uc = NULL, wc = NULL, retlist = NULL;
+ struct mem_range_desc mrd;
+ struct mem_range_op mro;
+
+ findRanges(base, size, &uc, &wc);
+
+ /*
+ * See of the full range is already not WC, or if there is full
+ * coverage from UC ranges.
+ */
+ if (!wc || fullCoverage(base, size, uc)) {
+ xf86DrvMsg(screenNum, from,
+ "Write-combining range (0x%lx,0x%lx) was already clear\n",
+ base, size);
+ return NULL;
+ }
+
+ /* Otherwise, try to add the new range */
+ mrd.mr_base = base;
+ mrd.mr_len = size;
+ strcpy(mrd.mr_owner, X_MTRR_ID);
+ mrd.mr_flags = MDF_UNCACHEABLE;
+ mro.mo_desc = &mrd;
+ mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "Failed to remove write-combining range "
+ "(0x%lx,0x%lx)\n", base, size);
+ /* XXX Should then remove all of the overlapping WC ranges */
+ return NULL;
+ }
+ else {
+ xf86DrvMsg(screenNum, from,
+ "Removed Write-combining range (0x%lx,0x%lx)\n", base, size);
+ retlist = xnfalloc(sizeof(RangeRec));
+ retlist->mrd = mrd;
+ retlist->wasWC = TRUE;
+ retlist->next = NULL;
+ return retlist;
+ }
}
static pointer
setWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
- MessageType from)
+ MessageType from)
{
- if (enable)
- return addWC(screenNum, base, size, from);
- else
- return delWC(screenNum, base, size, from);
+ if (enable)
+ return addWC(screenNum, base, size, from);
+ else
+ return delWC(screenNum, base, size, from);
}
static void
undoWC(int screenNum, pointer list)
{
- RangePtr rp;
- struct mem_range_op mro;
- Bool failed;
+ RangePtr rp;
+ struct mem_range_op mro;
+ Bool failed;
- rp = list;
- while (rp) {
+ rp = list;
+ while (rp) {
#ifdef DEBUG
- ErrorF("Undo for (0x%lx,0x%lx), %d\n",
- (unsigned long)rp->mrd.mr_base,
- (unsigned long)rp->mrd.mr_len, rp->wasWC);
+ ErrorF("Undo for (0x%lx,0x%lx), %d\n",
+ (unsigned long) rp->mrd.mr_base,
+ (unsigned long) rp->mrd.mr_len, rp->wasWC);
#endif
- failed = FALSE;
- if (rp->wasWC) {
- mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
- rp->mrd.mr_flags = MDF_WRITECOMBINE;
- strcpy(rp->mrd.mr_owner, "unknown");
- } else {
- mro.mo_arg[0] = MEMRANGE_SET_REMOVE;
- }
- mro.mo_desc = &rp->mrd;
-
- if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
- if (!rp->wasWC) {
- mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
- rp->mrd.mr_flags = MDF_UNCACHEABLE;
- strcpy(rp->mrd.mr_owner, "unknown");
- if (ioctl(devMemFd, MEMRANGE_SET, &mro))
- failed = TRUE;
- } else
- failed = TRUE;
- }
- if (failed) {
- xf86DrvMsg(screenNum, X_WARNING,
- "Failed to restore MTRR range (0x%lx,0x%lx)\n",
- (unsigned long)rp->mrd.mr_base,
- (unsigned long)rp->mrd.mr_len);
- }
- rp = rp->next;
- }
+ failed = FALSE;
+ if (rp->wasWC) {
+ mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ rp->mrd.mr_flags = MDF_WRITECOMBINE;
+ strcpy(rp->mrd.mr_owner, "unknown");
+ }
+ else {
+ mro.mo_arg[0] = MEMRANGE_SET_REMOVE;
+ }
+ mro.mo_desc = &rp->mrd;
+
+ if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
+ if (!rp->wasWC) {
+ mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ rp->mrd.mr_flags = MDF_UNCACHEABLE;
+ strcpy(rp->mrd.mr_owner, "unknown");
+ if (ioctl(devMemFd, MEMRANGE_SET, &mro))
+ failed = TRUE;
+ }
+ else
+ failed = TRUE;
+ }
+ if (failed) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "Failed to restore MTRR range (0x%lx,0x%lx)\n",
+ (unsigned long) rp->mrd.mr_base,
+ (unsigned long) rp->mrd.mr_len);
+ }
+ rp = rp->next;
+ }
}
-#endif /* HAS_MTRR_SUPPORT */
-
+#endif /* HAS_MTRR_SUPPORT */
#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
static pointer
NetBSDsetWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
- MessageType from)
+ MessageType from)
{
- struct mtrr *mtrrp;
- int n;
-
- xf86DrvMsg(screenNum, X_WARNING,
- "%s MTRR %lx - %lx\n", enable ? "set" : "remove",
- base, (base + size));
-
- mtrrp = xnfalloc(sizeof (struct mtrr));
- mtrrp->base = base;
- mtrrp->len = size;
- mtrrp->type = MTRR_TYPE_WC;
-
- /*
- * MTRR_PRIVATE will make this MTRR get reset automatically
- * if this process exits, so we have no need for an explicit
- * cleanup operation when starting a new server.
- */
-
- if (enable)
- mtrrp->flags = MTRR_VALID | MTRR_PRIVATE;
- else
- mtrrp->flags = 0;
- n = 1;
-
- if (i386_set_mtrr(mtrrp, &n) < 0) {
- free(mtrrp);
- return NULL;
- }
- return mtrrp;
+ struct mtrr *mtrrp;
+ int n;
+
+ xf86DrvMsg(screenNum, X_WARNING,
+ "%s MTRR %lx - %lx\n", enable ? "set" : "remove",
+ base, (base + size));
+
+ mtrrp = xnfalloc(sizeof(struct mtrr));
+ mtrrp->base = base;
+ mtrrp->len = size;
+ mtrrp->type = MTRR_TYPE_WC;
+
+ /*
+ * MTRR_PRIVATE will make this MTRR get reset automatically
+ * if this process exits, so we have no need for an explicit
+ * cleanup operation when starting a new server.
+ */
+
+ if (enable)
+ mtrrp->flags = MTRR_VALID | MTRR_PRIVATE;
+ else
+ mtrrp->flags = 0;
+ n = 1;
+
+ if (i386_set_mtrr(mtrrp, &n) < 0) {
+ free(mtrrp);
+ return NULL;
+ }
+ return mtrrp;
}
static void
NetBSDundoWC(int screenNum, pointer list)
{
- struct mtrr *mtrrp = (struct mtrr *)list;
- int n;
-
- if (mtrrp == NULL)
- return;
- n = 1;
- mtrrp->flags &= ~MTRR_VALID;
- i386_set_mtrr(mtrrp, &n);
- free(mtrrp);
+ struct mtrr *mtrrp = (struct mtrr *) list;
+ int n;
+
+ if (mtrrp == NULL)
+ return;
+ n = 1;
+ mtrrp->flags &= ~MTRR_VALID;
+ i386_set_mtrr(mtrrp, &n);
+ free(mtrrp);
}
#endif
diff --git a/xorg-server/hw/xfree86/os-support/bsd/memrange.h b/xorg-server/hw/xfree86/os-support/bsd/memrange.h
index 03c479144..bacd4aa0d 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/memrange.h
+++ b/xorg-server/hw/xfree86/os-support/bsd/memrange.h
@@ -10,36 +10,37 @@
#define _MEMRANGE_H
/* Memory range attributes */
-#define MDF_UNCACHEABLE (1<<0) /* region not cached */
-#define MDF_WRITECOMBINE (1<<1) /* region supports "write combine"
- * action */
-#define MDF_WRITETHROUGH (1<<2) /* write-through cached */
-#define MDF_WRITEBACK (1<<3) /* write-back cached */
-#define MDF_WRITEPROTECT (1<<4) /* read-only region */
+#define MDF_UNCACHEABLE (1<<0) /* region not cached */
+#define MDF_WRITECOMBINE (1<<1) /* region supports "write combine"
+ * action */
+#define MDF_WRITETHROUGH (1<<2) /* write-through cached */
+#define MDF_WRITEBACK (1<<3) /* write-back cached */
+#define MDF_WRITEPROTECT (1<<4) /* read-only region */
#define MDF_ATTRMASK (0x00ffffff)
-#define MDF_FIXBASE (1<<24) /* fixed base */
-#define MDF_FIXLEN (1<<25) /* fixed length */
-#define MDF_FIRMWARE (1<<26) /* set by firmware (XXX not useful?) */
-#define MDF_ACTIVE (1<<27) /* currently active */
-#define MDF_BOGUS (1<<28) /* we don't like it */
-#define MDF_FIXACTIVE (1<<29) /* can't be turned off */
-#define MDF_BUSY (1<<30) /* range is in use */
+#define MDF_FIXBASE (1<<24) /* fixed base */
+#define MDF_FIXLEN (1<<25) /* fixed length */
+#define MDF_FIRMWARE (1<<26) /* set by firmware (XXX not useful?) */
+#define MDF_ACTIVE (1<<27) /* currently active */
+#define MDF_BOGUS (1<<28) /* we don't like it */
+#define MDF_FIXACTIVE (1<<29) /* can't be turned off */
+#define MDF_BUSY (1<<30) /* range is in use */
struct mem_range_desc {
- u_int64_t mr_base;
- u_int64_t mr_len;
- int mr_flags;
- char mr_owner[8];
+ u_int64_t mr_base;
+ u_int64_t mr_len;
+ int mr_flags;
+ char mr_owner[8];
};
struct mem_range_op {
- struct mem_range_desc *mo_desc;
- int mo_arg[2];
+ struct mem_range_desc *mo_desc;
+ int mo_arg[2];
#define MEMRANGE_SET_UPDATE 0
#define MEMRANGE_SET_REMOVE 1
- /* XXX want a flag that says "set and undo when I exit" */
+ /* XXX want a flag that says "set and undo when I exit" */
};
+
#define MEMRANGE_GET _IOWR('m', 50, struct mem_range_op)
#define MEMRANGE_SET _IOW('m', 51, struct mem_range_op)
@@ -47,16 +48,18 @@ struct mem_range_op {
struct mem_range_softc;
struct mem_range_ops {
- void (*init) __P((struct mem_range_softc * sc));
- int (*set) __P((struct mem_range_softc * sc, struct mem_range_desc * mrd, int *arg));
- void (*initAP) __P((struct mem_range_softc * sc));
+ void (*init) __P((struct mem_range_softc * sc));
+ int (*set)
+ __P((struct mem_range_softc * sc, struct mem_range_desc * mrd,
+ int *arg));
+ void (*initAP) __P((struct mem_range_softc * sc));
};
struct mem_range_softc {
- struct mem_range_ops *mr_op;
- int mr_cap;
- int mr_ndesc;
- struct mem_range_desc *mr_desc;
+ struct mem_range_ops *mr_op;
+ int mr_cap;
+ int mr_ndesc;
+ struct mem_range_desc *mr_desc;
};
extern struct mem_range_softc mem_range_softc;
diff --git a/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c b/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c
index e5d832eed..417adbf4b 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c
@@ -53,94 +53,89 @@ void xf86DisableIO(void);
void
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
- pVidMem->linearSupported = TRUE;
- pVidMem->mapMem = ppcMapVidMem;
- pVidMem->unmapMem = ppcUnmapVidMem;
- pVidMem->initialised = TRUE;
- xf86EnableIO();
+ pVidMem->linearSupported = TRUE;
+ pVidMem->mapMem = ppcMapVidMem;
+ pVidMem->unmapMem = ppcUnmapVidMem;
+ pVidMem->initialised = TRUE;
+ xf86EnableIO();
}
-
volatile unsigned char *ioBase = MAP_FAILED;
static pointer
ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
{
- int fd = xf86Info.consoleFd;
- pointer base;
+ int fd = xf86Info.consoleFd;
+ pointer base;
+
#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d",
- Base, Size, fd);
+ xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", Base, Size, fd);
#endif
- base = mmap(0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_SHARED, fd, Base);
- if (base == MAP_FAILED)
- FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)",
- "xf86MapVidMem", Size, Base, strerror(errno));
+ base = mmap(0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE), MAP_SHARED, fd, Base);
+ if (base == MAP_FAILED)
+ FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)",
+ "xf86MapVidMem", Size, Base, strerror(errno));
- return base;
+ return base;
}
static void
ppcUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
{
- munmap(Base, Size);
+ munmap(Base, Size);
}
int
xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
+ int Len)
{
- int rv;
- static int kmem = -1;
+ int rv;
+ static int kmem = -1;
- if (kmem == -1) {
- kmem = open(DEV_MEM, 2);
- if (kmem == -1) {
- FatalError("xf86ReadBIOS: open %s", DEV_MEM);
- }
- }
+ if (kmem == -1) {
+ kmem = open(DEV_MEM, 2);
+ if (kmem == -1) {
+ FatalError("xf86ReadBIOS: open %s", DEV_MEM);
+ }
+ }
#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS() %lx %lx, %x\n",
- Base, Offset, Len);
+ xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS() %lx %lx, %x\n", Base, Offset, Len);
#endif
+ lseek(kmem, Base + Offset, 0);
+ rv = read(kmem, Buf, Len);
- lseek(kmem, Base + Offset, 0);
- rv = read(kmem, Buf, Len);
-
- return rv;
+ return rv;
}
-Bool xf86EnableIO()
+Bool
+xf86EnableIO()
{
- int fd = xf86Info.consoleFd;
-
- xf86MsgVerb(X_WARNING, 3, "xf86EnableIO %d\n", fd);
- if (ioBase == MAP_FAILED)
- {
- ioBase=mmap(NULL, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, fd,
- 0xf2000000);
- xf86MsgVerb(X_INFO, 3, "xf86EnableIO: %08x\n", ioBase);
- if (ioBase == MAP_FAILED) {
- xf86MsgVerb(X_WARNING, 3, "Can't map IO space!\n");
- return FALSE;
- }
+ int fd = xf86Info.consoleFd;
+
+ xf86MsgVerb(X_WARNING, 3, "xf86EnableIO %d\n", fd);
+ if (ioBase == MAP_FAILED) {
+ ioBase = mmap(NULL, 0x10000, PROT_READ | PROT_WRITE, MAP_SHARED, fd,
+ 0xf2000000);
+ xf86MsgVerb(X_INFO, 3, "xf86EnableIO: %08x\n", ioBase);
+ if (ioBase == MAP_FAILED) {
+ xf86MsgVerb(X_WARNING, 3, "Can't map IO space!\n");
+ return FALSE;
}
- return TRUE;
+ }
+ return TRUE;
}
-void xf86DisableIO()
+void
+xf86DisableIO()
{
- if (ioBase != MAP_FAILED)
- {
- munmap(__UNVOLATILE(ioBase), 0x10000);
- ioBase = MAP_FAILED;
- }
+ if (ioBase != MAP_FAILED) {
+ munmap(__UNVOLATILE(ioBase), 0x10000);
+ ioBase = MAP_FAILED;
+ }
}
-
diff --git a/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c b/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c
index 960c850a8..21c166105 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c
@@ -44,44 +44,42 @@ static void sparc64UnmapVidMem(int, pointer, unsigned long);
void
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
- pVidMem->linearSupported = TRUE;
- pVidMem->mapMem = sparc64MapVidMem;
- pVidMem->unmapMem = sparc64UnmapVidMem;
- pVidMem->initialised = TRUE;
+ pVidMem->linearSupported = TRUE;
+ pVidMem->mapMem = sparc64MapVidMem;
+ pVidMem->unmapMem = sparc64UnmapVidMem;
+ pVidMem->initialised = TRUE;
}
static pointer
-sparc64MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size,
- int flags)
+sparc64MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size,
+ int flags)
{
- int fd = xf86Info.consoleFd;
- pointer base;
+ int fd = xf86Info.consoleFd;
+ pointer base;
#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d",
- Base, Size, fd);
+ xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", Base, Size, fd);
#endif
- base = mmap(0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_SHARED, fd, Base);
- if (base == MAP_FAILED)
- FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)",
- "xf86MapVidMem", Size, Base, strerror(errno));
- return base;
+ base = mmap(0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE), MAP_SHARED, fd, Base);
+ if (base == MAP_FAILED)
+ FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)",
+ "xf86MapVidMem", Size, Base, strerror(errno));
+ return base;
}
static void
sparc64UnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
{
- munmap(Base, Size);
+ munmap(Base, Size);
}
int
xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
+ int Len)
{
- return 0;
+ return 0;
}
diff --git a/xorg-server/hw/xfree86/os-support/bus/Sbus.c b/xorg-server/hw/xfree86/os-support/bus/Sbus.c
index c02d2cd55..b75308aa1 100644
--- a/xorg-server/hw/xfree86/os-support/bus/Sbus.c
+++ b/xorg-server/hw/xfree86/os-support/bus/Sbus.c
@@ -47,6 +47,7 @@ static int promFd = -1;
static int promCurrentNode;
static int promOpenCount = 0;
static int promP1275 = -1;
+
#define MAX_PROP 128
#define MAX_VAL (4096-128-4)
static struct openpromio *promOpio;
@@ -54,21 +55,23 @@ static struct openpromio *promOpio;
sbusDevicePtr *xf86SbusInfo = NULL;
struct sbus_devtable sbusDeviceTable[] = {
- { SBUS_DEVICE_BW2, FBTYPE_SUN2BW, "bwtwo", "sunbw2", "Sun Monochrome (bwtwo)" },
- { SBUS_DEVICE_CG2, FBTYPE_SUN2COLOR, "cgtwo", NULL, "Sun Color2 (cgtwo)" },
- { SBUS_DEVICE_CG3, FBTYPE_SUN3COLOR, "cgthree", "suncg3", "Sun Color3 (cgthree)" },
- { SBUS_DEVICE_CG4, FBTYPE_SUN4COLOR, "cgfour", NULL, "Sun Color4 (cgfour)" },
- { SBUS_DEVICE_CG6, FBTYPE_SUNFAST_COLOR, "cgsix", "suncg6", "Sun GX" },
- { SBUS_DEVICE_CG8, FBTYPE_MEMCOLOR, "cgeight", NULL, "Sun CG8/RasterOps" },
- { SBUS_DEVICE_CG12, FBTYPE_SUNGP3, "cgtwelve", NULL, "Sun GS (cgtwelve)" },
- { SBUS_DEVICE_CG14, FBTYPE_MDICOLOR, "cgfourteen", "suncg14", "Sun SX" },
- { SBUS_DEVICE_GT, FBTYPE_SUNGT, "gt", NULL, "Sun Graphics Tower" },
- { SBUS_DEVICE_MGX, -1, "mgx", NULL, "Quantum 3D MGXplus" },
- { SBUS_DEVICE_LEO, FBTYPE_SUNLEO, "leo", "sunleo", "Sun ZX or Turbo ZX" },
- { SBUS_DEVICE_TCX, FBTYPE_TCXCOLOR, "tcx", "suntcx", "Sun TCX" },
- { SBUS_DEVICE_FFB, FBTYPE_CREATOR, "ffb", "sunffb", "Sun FFB" },
- { SBUS_DEVICE_FFB, FBTYPE_CREATOR, "afb", "sunffb", "Sun Elite3D" },
- { 0, 0, NULL }
+ {SBUS_DEVICE_BW2, FBTYPE_SUN2BW, "bwtwo", "sunbw2",
+ "Sun Monochrome (bwtwo)"},
+ {SBUS_DEVICE_CG2, FBTYPE_SUN2COLOR, "cgtwo", NULL, "Sun Color2 (cgtwo)"},
+ {SBUS_DEVICE_CG3, FBTYPE_SUN3COLOR, "cgthree", "suncg3",
+ "Sun Color3 (cgthree)"},
+ {SBUS_DEVICE_CG4, FBTYPE_SUN4COLOR, "cgfour", NULL, "Sun Color4 (cgfour)"},
+ {SBUS_DEVICE_CG6, FBTYPE_SUNFAST_COLOR, "cgsix", "suncg6", "Sun GX"},
+ {SBUS_DEVICE_CG8, FBTYPE_MEMCOLOR, "cgeight", NULL, "Sun CG8/RasterOps"},
+ {SBUS_DEVICE_CG12, FBTYPE_SUNGP3, "cgtwelve", NULL, "Sun GS (cgtwelve)"},
+ {SBUS_DEVICE_CG14, FBTYPE_MDICOLOR, "cgfourteen", "suncg14", "Sun SX"},
+ {SBUS_DEVICE_GT, FBTYPE_SUNGT, "gt", NULL, "Sun Graphics Tower"},
+ {SBUS_DEVICE_MGX, -1, "mgx", NULL, "Quantum 3D MGXplus"},
+ {SBUS_DEVICE_LEO, FBTYPE_SUNLEO, "leo", "sunleo", "Sun ZX or Turbo ZX"},
+ {SBUS_DEVICE_TCX, FBTYPE_TCXCOLOR, "tcx", "suntcx", "Sun TCX"},
+ {SBUS_DEVICE_FFB, FBTYPE_CREATOR, "ffb", "sunffb", "Sun FFB"},
+ {SBUS_DEVICE_FFB, FBTYPE_CREATOR, "afb", "sunffb", "Sun Elite3D"},
+ {0, 0, NULL}
};
int
@@ -76,12 +79,13 @@ promGetSibling(int node)
{
promOpio->oprom_size = sizeof(int);
- if (node == -1) return 0;
- *(int *)promOpio->oprom_array = node;
+ 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;
+ return 0;
+ promCurrentNode = *(int *) promOpio->oprom_array;
+ return *(int *) promOpio->oprom_array;
}
int
@@ -89,12 +93,13 @@ promGetChild(int node)
{
promOpio->oprom_size = sizeof(int);
- if (!node || node == -1) return 0;
- *(int *)promOpio->oprom_array = node;
+ 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;
+ return 0;
+ promCurrentNode = *(int *) promOpio->oprom_array;
+ return *(int *) promOpio->oprom_array;
}
char *
@@ -104,8 +109,9 @@ promGetProperty(const char *prop, int *lenp)
strcpy(promOpio->oprom_array, prop);
if (ioctl(promFd, OPROMGETPROP, promOpio) < 0)
- return 0;
- if (lenp) *lenp = promOpio->oprom_size;
+ return 0;
+ if (lenp)
+ *lenp = promOpio->oprom_size;
return promOpio->oprom_array;
}
@@ -114,15 +120,15 @@ promGetBool(const char *prop)
{
promOpio->oprom_size = 0;
- *(int *)promOpio->oprom_array = 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;
+ 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;
}
}
@@ -138,13 +144,13 @@ promSetNode(sbusPromNodePtr pnode)
int node;
if (!pnode->node || pnode->node == -1)
- return -1;
+ return -1;
if (pnode->cookie[0] & PROM_NODE_SIBLING)
- node = promGetSibling(pnode->cookie[1]);
+ node = promGetSibling(pnode->cookie[1]);
else
- node = promGetChild(pnode->cookie[1]);
+ node = promGetChild(pnode->cookie[1]);
if (pnode->node != node)
- return -1;
+ return -1;
return 0;
}
@@ -156,23 +162,24 @@ promIsP1275(void)
char buffer[1024];
if (promP1275 != -1)
- return;
+ return;
promP1275 = 0;
- f = fopen("/proc/cpuinfo","r");
- if (!f) return;
+ 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;
- }
+ if (!strncmp(buffer, "type", 4) && strstr(buffer, "sun4u")) {
+ promP1275 = 1;
+ break;
+ }
fclose(f);
#elif defined(sun)
struct utsname buffer;
if ((uname(&buffer) >= 0) && !strcmp(buffer.machine, "sun4u"))
- promP1275 = TRUE;
+ promP1275 = TRUE;
else
- promP1275 = FALSE;
+ promP1275 = FALSE;
#elif defined(__FreeBSD__)
promP1275 = TRUE;
#else
@@ -184,12 +191,12 @@ void
sparcPromClose(void)
{
if (promOpenCount > 1) {
- promOpenCount--;
- return;
+ promOpenCount--;
+ return;
}
if (promFd != -1) {
- close(promFd);
- promFd = -1;
+ close(promFd);
+ promFd = -1;
}
free(promOpio);
promOpio = NULL;
@@ -200,21 +207,21 @@ int
sparcPromInit(void)
{
if (promOpenCount) {
- promOpenCount++;
- return 0;
+ promOpenCount++;
+ return 0;
}
promFd = open("/dev/openprom", O_RDONLY, 0);
if (promFd == -1)
- return -1;
- promOpio = (struct openpromio *)malloc(4096);
+ return -1;
+ promOpio = (struct openpromio *) malloc(4096);
if (!promOpio) {
- sparcPromClose();
- return -1;
+ sparcPromClose();
+ return -1;
}
promRootNode = promGetSibling(0);
if (!promRootNode) {
- sparcPromClose();
- return -1;
+ sparcPromClose();
+ return -1;
}
promIsP1275();
promOpenCount++;
@@ -226,7 +233,7 @@ char *
sparcPromGetProperty(sbusPromNodePtr pnode, const char *prop, int *lenp)
{
if (promSetNode(pnode))
- return NULL;
+ return NULL;
return promGetProperty(prop, lenp);
}
@@ -234,7 +241,7 @@ int
sparcPromGetBool(sbusPromNodePtr pnode, const char *prop)
{
if (promSetNode(pnode))
- return 0;
+ return 0;
return promGetBool(prop);
}
@@ -247,35 +254,37 @@ promWalkGetDriverName(int node, int oldnode)
int devId, i;
prop = promGetProperty("device_type", &len);
- if (prop && (len > 0)) do {
- if (!strcmp(prop, "display")) {
- prop = promGetProperty("name", &len);
- if (!prop || len <= 0)
- break;
- while ((*prop >= 'A' && *prop <= 'Z') || *prop == ',')
- prop++;
- for (i = 0; sbusDeviceTable[i].devId; i++)
- if (!strcmp(prop, sbusDeviceTable[i].promName))
- break;
- devId = sbusDeviceTable[i].devId;
- if (!devId)
- break;
- if (sbusDeviceTable[i].driverName)
- return sbusDeviceTable[i].driverName;
- }
- } while (0);
+ if (prop && (len > 0))
+ do {
+ if (!strcmp(prop, "display")) {
+ prop = promGetProperty("name", &len);
+ if (!prop || len <= 0)
+ break;
+ while ((*prop >= 'A' && *prop <= 'Z') || *prop == ',')
+ prop++;
+ for (i = 0; sbusDeviceTable[i].devId; i++)
+ if (!strcmp(prop, sbusDeviceTable[i].promName))
+ break;
+ devId = sbusDeviceTable[i].devId;
+ if (!devId)
+ break;
+ if (sbusDeviceTable[i].driverName)
+ return sbusDeviceTable[i].driverName;
+ }
+ } while (0);
nextnode = promGetChild(node);
if (nextnode) {
- char *name;
- name = promWalkGetDriverName(nextnode, node);
- if (name)
- return name;
+ char *name;
+
+ name = promWalkGetDriverName(nextnode, node);
+ if (name)
+ return name;
}
nextnode = promGetSibling(node);
if (nextnode)
- return promWalkGetDriverName(nextnode, node);
+ return promWalkGetDriverName(nextnode, node);
return NULL;
}
@@ -285,7 +294,7 @@ sparcDriverName(void)
char *name;
if (sparcPromInit() < 0)
- return NULL;
+ return NULL;
promGetSibling(0);
name = promWalkGetDriverName(promRootNode, 0);
sparcPromClose();
@@ -293,7 +302,8 @@ sparcDriverName(void)
}
static void
-promWalkAssignNodes(int node, int oldnode, int flags, sbusDevicePtr *devicePtrs)
+promWalkAssignNodes(int node, int oldnode, int flags,
+ sbusDevicePtr * devicePtrs)
{
int nextnode;
int len, sbus = flags & PROM_NODE_SBUS;
@@ -302,67 +312,72 @@ promWalkAssignNodes(int node, int oldnode, int flags, sbusDevicePtr *devicePtrs)
sbusPromNode pNode, pNode2;
prop = promGetProperty("device_type", &len);
- if (prop && (len > 0)) do {
- if (!strcmp(prop, "display")) {
- prop = promGetProperty("name", &len);
- if (!prop || len <= 0)
- break;
- while ((*prop >= 'A' && *prop <= 'Z') || *prop == ',')
- prop++;
- for (i = 0; sbusDeviceTable[i].devId; i++)
- if (!strcmp(prop, sbusDeviceTable[i].promName))
- break;
- devId = sbusDeviceTable[i].devId;
- if (!devId)
- break;
- if (!sbus) {
- if (devId == SBUS_DEVICE_FFB) {
- /*
- * All /SUNW,ffb outside of SBUS tree come before all
- * /SUNW,afb outside of SBUS tree in Linux.
- */
- if (!strcmp(prop, "afb"))
- flags |= PROM_NODE_PREF;
- } else if (devId != SBUS_DEVICE_CG14)
- break;
- }
- for (i = 0; i < 32; i++) {
- if (!devicePtrs[i] || devicePtrs[i]->devId != devId)
- continue;
- if (devicePtrs[i]->node.node) {
- if ((devicePtrs[i]->node.cookie[0] & ~PROM_NODE_SIBLING) <=
- (flags & ~PROM_NODE_SIBLING))
- continue;
- for (j = i + 1, pNode = devicePtrs[i]->node; j < 32; j++) {
- if (!devicePtrs[j] || devicePtrs[j]->devId != devId)
- continue;
- pNode2 = devicePtrs[j]->node;
- devicePtrs[j]->node = pNode;
- pNode = pNode2;
- }
- }
- devicePtrs[i]->node.node = node;
- devicePtrs[i]->node.cookie[0] = flags;
- devicePtrs[i]->node.cookie[1] = oldnode;
- break;
- }
- break;
- }
- } while (0);
+ if (prop && (len > 0))
+ do {
+ if (!strcmp(prop, "display")) {
+ prop = promGetProperty("name", &len);
+ if (!prop || len <= 0)
+ break;
+ while ((*prop >= 'A' && *prop <= 'Z') || *prop == ',')
+ prop++;
+ for (i = 0; sbusDeviceTable[i].devId; i++)
+ if (!strcmp(prop, sbusDeviceTable[i].promName))
+ break;
+ devId = sbusDeviceTable[i].devId;
+ if (!devId)
+ break;
+ if (!sbus) {
+ if (devId == SBUS_DEVICE_FFB) {
+ /*
+ * All /SUNW,ffb outside of SBUS tree come before all
+ * /SUNW,afb outside of SBUS tree in Linux.
+ */
+ if (!strcmp(prop, "afb"))
+ flags |= PROM_NODE_PREF;
+ }
+ else if (devId != SBUS_DEVICE_CG14)
+ break;
+ }
+ for (i = 0; i < 32; i++) {
+ if (!devicePtrs[i] || devicePtrs[i]->devId != devId)
+ continue;
+ if (devicePtrs[i]->node.node) {
+ if ((devicePtrs[i]->node.
+ cookie[0] & ~PROM_NODE_SIBLING) <=
+ (flags & ~PROM_NODE_SIBLING))
+ continue;
+ for (j = i + 1, pNode = devicePtrs[i]->node; j < 32;
+ j++) {
+ if (!devicePtrs[j] || devicePtrs[j]->devId != devId)
+ continue;
+ pNode2 = devicePtrs[j]->node;
+ devicePtrs[j]->node = pNode;
+ pNode = pNode2;
+ }
+ }
+ devicePtrs[i]->node.node = node;
+ devicePtrs[i]->node.cookie[0] = flags;
+ devicePtrs[i]->node.cookie[1] = oldnode;
+ break;
+ }
+ break;
+ }
+ } while (0);
prop = promGetProperty("name", &len);
if (prop && len > 0) {
- if (!strcmp(prop, "sbus") || !strcmp(prop, "sbi"))
- sbus = PROM_NODE_SBUS;
+ if (!strcmp(prop, "sbus") || !strcmp(prop, "sbi"))
+ sbus = PROM_NODE_SBUS;
}
nextnode = promGetChild(node);
if (nextnode)
- promWalkAssignNodes(nextnode, node, sbus, devicePtrs);
+ promWalkAssignNodes(nextnode, node, sbus, devicePtrs);
nextnode = promGetSibling(node);
if (nextnode)
- promWalkAssignNodes(nextnode, node, PROM_NODE_SIBLING | sbus, devicePtrs);
+ promWalkAssignNodes(nextnode, node, PROM_NODE_SIBLING | sbus,
+ devicePtrs);
}
void
@@ -375,63 +390,66 @@ sparcPromAssignNodes(void)
memset(devicePtrs, 0, sizeof(devicePtrs));
for (psdpp = xf86SbusInfo, n = 0; (psdp = *psdpp); psdpp++, n++) {
- if (psdp->fbNum != n)
- holes = 1;
- devicePtrs[psdp->fbNum] = psdp;
+ if (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);
+ /* We could not open one of fb devices, check /proc/fb to see what
+ * were the types of the cards missed. */
+ char buffer[64];
+ int fbNum, devId;
+ static struct {
+ int devId;
+ char *prefix;
+ } procFbPrefixes[] = {
+ {
+ SBUS_DEVICE_BW2, "BWtwo"}, {
+ SBUS_DEVICE_CG14, "CGfourteen"}, {
+ SBUS_DEVICE_CG6, "CGsix"}, {
+ SBUS_DEVICE_CG3, "CGthree"}, {
+ SBUS_DEVICE_FFB, "Creator"}, {
+ SBUS_DEVICE_FFB, "Elite 3D"}, {
+ SBUS_DEVICE_LEO, "Leo"}, {
+ SBUS_DEVICE_TCX, "TCX"}, {
+ 0, NULL},};
+
+ while (fscanf(f, "%d %63s\n", &fbNum, buffer) == 2) {
+ for (i = 0; procFbPrefixes[i].devId; i++)
+ if (!strncmp(procFbPrefixes[i].prefix, buffer,
+ strlen(procFbPrefixes[i].prefix)))
+ break;
+ devId = procFbPrefixes[i].devId;
+ if (!devId)
+ continue;
+ if (devicePtrs[fbNum]) {
+ if (devicePtrs[fbNum]->devId != devId)
+ xf86ErrorF("Inconsistent /proc/fb with FBIOGATTR\n");
+ }
+ else if (!devicePtrs[fbNum]) {
+ devicePtrs[fbNum] = psdp = xnfcalloc(sizeof(sbusDevice), 1);
+ psdp->devId = devId;
+ psdp->fbNum = fbNum;
+ psdp->fd = -2;
+ }
+ }
+ fclose(f);
}
promGetSibling(0);
promWalkAssignNodes(promRootNode, 0, PROM_NODE_PREF, devicePtrs);
for (i = 0, j = 0; i < 32; i++)
- if (devicePtrs[i] && devicePtrs[i]->fbNum == -1)
- j++;
+ 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--;
- }
+ if (devicePtrs[i]) {
+ if (devicePtrs[i]->fbNum == -1) {
+ memmove(psdpp + 1, psdpp, sizeof(psdpp) * (n + 1));
+ *psdpp = devicePtrs[i];
+ }
+ else
+ n--;
+ }
}
static char *
@@ -444,37 +462,43 @@ promGetReg(int type)
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))
- snprintf (regstr, sizeof(regstr), "@%x,%x", reg[0], reg[1]);
- else if (type == PROM_NODE_PCI) {
- if ((reg[0] >> 8) & 7)
- snprintf (regstr, sizeof(regstr), "@%x,%x", (reg[0] >> 11) & 0x1f, (reg[0] >> 8) & 7);
- else
- snprintf (regstr, sizeof(regstr), "@%x", (reg[0] >> 11) & 0x1f);
- } else if (len == 4)
- snprintf (regstr, sizeof(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;
- snprintf (regstr, sizeof(regstr), "@%x,%x", reg[0], regs[1]);
- } else
- snprintf (regstr, sizeof(regstr), "@%x,%x", regs[0] >> 4, regs[1]);
- }
+ unsigned int *reg = (unsigned int *) prop;
+
+ if (!promP1275 || (type == PROM_NODE_SBUS) || (type == PROM_NODE_EBUS))
+ snprintf(regstr, sizeof(regstr), "@%x,%x", reg[0], reg[1]);
+ else if (type == PROM_NODE_PCI) {
+ if ((reg[0] >> 8) & 7)
+ snprintf(regstr, sizeof(regstr), "@%x,%x",
+ (reg[0] >> 11) & 0x1f, (reg[0] >> 8) & 7);
+ else
+ snprintf(regstr, sizeof(regstr), "@%x", (reg[0] >> 11) & 0x1f);
+ }
+ else if (len == 4)
+ snprintf(regstr, sizeof(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;
+ snprintf(regstr, sizeof(regstr), "@%x,%x", reg[0], regs[1]);
+ }
+ else
+ snprintf(regstr, sizeof(regstr), "@%x,%x", regs[0] >> 4,
+ regs[1]);
+ }
}
return regstr;
}
static int
-promWalkNode2Pathname(char *path, int parent, int node, int searchNode, int type)
+promWalkNode2Pathname(char *path, int parent, int node, int searchNode,
+ int type)
{
int nextnode;
int len, ntype = type;
@@ -483,27 +507,28 @@ promWalkNode2Pathname(char *path, int parent, int node, int searchNode, int type
prop = promGetProperty("name", &len);
*path = '/';
if (!prop || len <= 0)
- return 0;
+ return 0;
if ((!strcmp(prop, "sbus") || !strcmp(prop, "sbi")) && !type)
- ntype = PROM_NODE_SBUS;
+ ntype = PROM_NODE_SBUS;
else if (!strcmp(prop, "ebus") && type == PROM_NODE_PCI)
- ntype = PROM_NODE_EBUS;
+ ntype = PROM_NODE_EBUS;
else if (!strcmp(prop, "pci") && !type)
- ntype = PROM_NODE_PCI;
- strcpy (path + 1, prop);
+ ntype = PROM_NODE_PCI;
+ strcpy(path + 1, prop);
p = promGetReg(type);
if (*p)
- strcat (path, p);
+ strcat(path, p);
if (node == searchNode)
- return 1;
+ return 1;
nextnode = promGetChild(node);
if (nextnode &&
- promWalkNode2Pathname(strchr(path, 0), node, nextnode, searchNode, ntype))
- return 1;
+ promWalkNode2Pathname(strchr(path, 0), node, nextnode, searchNode,
+ ntype))
+ return 1;
nextnode = promGetSibling(node);
if (nextnode &&
- promWalkNode2Pathname(path, parent, nextnode, searchNode, type))
- return 1;
+ promWalkNode2Pathname(path, parent, nextnode, searchNode, type))
+ return 1;
return 0;
}
@@ -512,11 +537,14 @@ sparcPromNode2Pathname(sbusPromNodePtr pnode)
{
char *ret;
- if (!pnode->node) return NULL;
+ if (!pnode->node)
+ return NULL;
ret = malloc(4096);
- if (!ret) return NULL;
- if (promWalkNode2Pathname(ret, promRootNode, promGetChild(promRootNode), pnode->node, 0))
- return ret;
+ if (!ret)
+ return NULL;
+ if (promWalkNode2Pathname
+ (ret, promRootNode, promGetChild(promRootNode), pnode->node, 0))
+ return ret;
free(ret);
return NULL;
}
@@ -528,51 +556,52 @@ promWalkPathname2Node(char *name, char *regstr, int parent, int type)
char *prop, *p;
for (;;) {
- prop = promGetProperty("name", &len);
- if (!prop || len <= 0)
- return 0;
- if ((!strcmp(prop, "sbus") || !strcmp(prop, "sbi")) && !type)
- type = PROM_NODE_SBUS;
- else if (!strcmp(prop, "ebus") && type == PROM_NODE_PCI)
- type = PROM_NODE_EBUS;
- else if (!strcmp(prop, "pci") && !type)
- type = PROM_NODE_PCI;
- for (node = promGetChild(parent); node; node = promGetSibling(node)) {
- prop = promGetProperty("name", &len);
- if (!prop || len <= 0)
- continue;
- if (*name && strcmp(name, prop))
- continue;
- if (*regstr) {
- p = promGetReg(type);
- if (! *p || strcmp(p + 1, regstr))
- continue;
- }
- break;
- }
- if (!node) {
- for (node = promGetChild(parent); node; node = promGetSibling(node)) {
- ret = promWalkPathname2Node(name, regstr, node, type);
- if (ret) return ret;
- }
- return 0;
- }
- name = strchr(regstr, 0) + 1;
- if (! *name)
- return node;
- p = strchr(name, '/');
- if (p)
- *p = 0;
- else
- p = strchr(name, 0);
- regstr = strchr(name, '@');
- if (regstr)
- *regstr++ = 0;
- else
- regstr = p;
- if (name == regstr)
- return 0;
- parent = node;
+ prop = promGetProperty("name", &len);
+ if (!prop || len <= 0)
+ return 0;
+ if ((!strcmp(prop, "sbus") || !strcmp(prop, "sbi")) && !type)
+ type = PROM_NODE_SBUS;
+ else if (!strcmp(prop, "ebus") && type == PROM_NODE_PCI)
+ type = PROM_NODE_EBUS;
+ else if (!strcmp(prop, "pci") && !type)
+ type = PROM_NODE_PCI;
+ for (node = promGetChild(parent); node; node = promGetSibling(node)) {
+ prop = promGetProperty("name", &len);
+ if (!prop || len <= 0)
+ continue;
+ if (*name && strcmp(name, prop))
+ continue;
+ if (*regstr) {
+ p = promGetReg(type);
+ if (!*p || strcmp(p + 1, regstr))
+ continue;
+ }
+ break;
+ }
+ if (!node) {
+ for (node = promGetChild(parent); node; node = promGetSibling(node)) {
+ ret = promWalkPathname2Node(name, regstr, node, type);
+ if (ret)
+ return ret;
+ }
+ return 0;
+ }
+ name = strchr(regstr, 0) + 1;
+ if (!*name)
+ return node;
+ p = strchr(name, '/');
+ if (p)
+ *p = 0;
+ else
+ p = strchr(name, 0);
+ regstr = strchr(name, '@');
+ if (regstr)
+ *regstr++ = 0;
+ else
+ regstr = p;
+ if (name == regstr)
+ return 0;
+ parent = node;
}
}
@@ -584,23 +613,24 @@ sparcPromPathname2Node(const char *pathName)
i = strlen(pathName);
name = malloc(i + 2);
- if (! name) return 0;
- strcpy (name, pathName);
- name [i + 1] = 0;
+ if (!name)
+ return 0;
+ strcpy(name, pathName);
+ name[i + 1] = 0;
if (name[0] != '/')
- return 0;
+ return 0;
p = strchr(name + 1, '/');
if (p)
- *p = 0;
+ *p = 0;
else
- p = strchr(name, 0);
+ p = strchr(name, 0);
regstr = strchr(name, '@');
if (regstr)
- *regstr++ = 0;
+ *regstr++ = 0;
else
- regstr = p;
+ regstr = p;
if (name + 1 == regstr)
- return 0;
+ return 0;
promGetSibling(0);
i = promWalkPathname2Node(name + 1, regstr, promRootNode, 0);
free(name);
@@ -616,32 +646,33 @@ xf86MapSbusMem(sbusDevicePtr psdp, unsigned long offset, unsigned long size)
unsigned long len = ((offset + size + pagemask) & ~pagemask) - off;
if (psdp->fd == -1) {
- psdp->fd = open(psdp->device, O_RDWR);
- if (psdp->fd == -1)
- return NULL;
- } else if (psdp->fd < 0)
- return NULL;
-
- ret = (pointer) mmap (NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE,
- psdp->fd, off);
+ psdp->fd = open(psdp->device, O_RDWR);
+ if (psdp->fd == -1)
+ return NULL;
+ }
+ else if (psdp->fd < 0)
+ return NULL;
+
+ ret = (pointer) mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE,
+ psdp->fd, off);
if (ret == (pointer) -1) {
- ret = (pointer) mmap (NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED,
- psdp->fd, off);
+ ret = (pointer) mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED,
+ psdp->fd, off);
}
if (ret == (pointer) -1)
- return NULL;
+ return NULL;
- return (char *)ret + (offset - off);
+ return (char *) ret + (offset - off);
}
void
xf86UnmapSbusMem(sbusDevicePtr psdp, pointer addr, unsigned long size)
{
unsigned long mask = getpagesize() - 1;
- unsigned long base = (unsigned long)addr & ~mask;
- unsigned long len = (((unsigned long)addr + size + mask) & ~mask) - base;
+ unsigned long base = (unsigned long) addr & ~mask;
+ unsigned long len = (((unsigned long) addr + size + mask) & ~mask) - base;
- munmap ((pointer)base, len);
+ munmap((pointer) base, len);
}
/* Tell OS that we are driving the HW cursor ourselves. */
@@ -657,8 +688,8 @@ xf86SbusHideOsHwCursor(sbusDevicePtr psdp)
fbcursor.cmap.red = zeros;
fbcursor.cmap.green = zeros;
fbcursor.cmap.blue = zeros;
- fbcursor.image = (char *)zeros;
- fbcursor.mask = (char *)zeros;
+ fbcursor.image = (char *) zeros;
+ fbcursor.mask = (char *) zeros;
fbcursor.size.x = 32;
fbcursor.size.y = 1;
fbcursor.set = FB_CUR_SETALL;
diff --git a/xorg-server/hw/xfree86/os-support/bus/nobus.c b/xorg-server/hw/xfree86/os-support/bus/nobus.c
index ad23f5288..dca58fee2 100644
--- a/xorg-server/hw/xfree86/os-support/bus/nobus.c
+++ b/xorg-server/hw/xfree86/os-support/bus/nobus.c
@@ -1 +1,5 @@
-static void __noop_to_appease_ar__() { return; }
+static void
+__noop_to_appease_ar__()
+{
+ return;
+}
diff --git a/xorg-server/hw/xfree86/os-support/bus/xf86Pci.h b/xorg-server/hw/xfree86/os-support/bus/xf86Pci.h
index 74ead201e..f69e55b39 100644
--- a/xorg-server/hw/xfree86/os-support/bus/xf86Pci.h
+++ b/xorg-server/hw/xfree86/os-support/bus/xf86Pci.h
@@ -95,7 +95,6 @@
* authorization from the copyright holder(s) and author(s).
*/
-
/*
* This file contains just the public interface to the PCI code.
* Drivers should use this file rather than Pci.h.
@@ -234,8 +233,8 @@
*/
/* Primitive Types */
-typedef unsigned long ADDRESS; /* Memory/PCI address */
-typedef unsigned long IOADDRESS _X_DEPRECATED; /* Must be large enough for a pointer */
+typedef unsigned long ADDRESS; /* Memory/PCI address */
+typedef unsigned long IOADDRESS _X_DEPRECATED; /* Must be large enough for a pointer */
typedef CARD32 PCITAG _X_DEPRECATED;
typedef enum {
@@ -249,12 +248,12 @@ typedef enum {
PCI_IO_SPARSE_MASK
} PciAddrType;
-
/* Public PCI access functions */
extern _X_EXPORT Bool xf86scanpci(void);
/* Domain access functions. Some of these probably shouldn't be public */
extern _X_EXPORT struct pci_io_handle *xf86MapLegacyIO(struct pci_device *dev);
-extern _X_EXPORT void xf86UnmapLegacyIO(struct pci_device *, struct pci_io_handle *);
+extern _X_EXPORT void xf86UnmapLegacyIO(struct pci_device *,
+ struct pci_io_handle *);
-#endif /* _XF86PCI_H */
+#endif /* _XF86PCI_H */
diff --git a/xorg-server/hw/xfree86/os-support/hurd/hurd_init.c b/xorg-server/hw/xfree86/os-support/hurd/hurd_init.c
index 94e261553..185b2b951 100644
--- a/xorg-server/hw/xfree86/os-support/hurd/hurd_init.c
+++ b/xorg-server/hw/xfree86/os-support/hurd/hurd_init.c
@@ -44,39 +44,38 @@
#include <mach.h>
int
-xf86ProcessArgument( int argc,char **argv, int i )
+xf86ProcessArgument(int argc, char **argv, int i)
{
return 0;
}
+
void
xf86UseMsg()
{
return;
}
-
void
xf86OpenConsole()
{
- if( serverGeneration == 1 )
- {
- kern_return_t err;
- mach_port_t device;
- int fd;
- err = get_privileged_ports( NULL, &device );
- if( err )
- {
- errno = err;
- FatalError( "xf86KbdInit can't get_privileged_ports. (%s)\n" , strerror(errno) );
- }
- mach_port_deallocate (mach_task_self (), device);
-
- if( ( fd = open( "/dev/kbd" , O_RDONLY|O_NONBLOCK ) ) < 0 )
- {
- fprintf( stderr , "Cannot open keyboard (%s)\n",strerror(errno) );
- exit(1);
- }
- xf86Info.consoleFd = fd;
+ if (serverGeneration == 1) {
+ kern_return_t err;
+ mach_port_t device;
+ int fd;
+
+ err = get_privileged_ports(NULL, &device);
+ if (err) {
+ errno = err;
+ FatalError("xf86KbdInit can't get_privileged_ports. (%s)\n",
+ strerror(errno));
+ }
+ mach_port_deallocate(mach_task_self(), device);
+
+ if ((fd = open("/dev/kbd", O_RDONLY | O_NONBLOCK)) < 0) {
+ fprintf(stderr, "Cannot open keyboard (%s)\n", strerror(errno));
+ exit(1);
+ }
+ xf86Info.consoleFd = fd;
}
return;
}
@@ -84,6 +83,6 @@ xf86OpenConsole()
void
xf86CloseConsole()
{
- close( xf86Info.consoleFd );
+ close(xf86Info.consoleFd);
return;
}
diff --git a/xorg-server/hw/xfree86/os-support/hurd/hurd_mmap.c b/xorg-server/hw/xfree86/os-support/hurd/hurd_mmap.c
index 9d9b84a28..6ac9efdfe 100644
--- a/xorg-server/hw/xfree86/os-support/hurd/hurd_mmap.c
+++ b/xorg-server/hw/xfree86/os-support/hurd/hurd_mmap.c
@@ -1,95 +1,93 @@
-/*
- * Copyright 1997 by UCHIYAMA Yasushi
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of UCHIYAMA Yasushi not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. UCHIYAMA Yasushi makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include<mach.h>
-#include<device/device.h>
-#include<mach/machine/mach_i386.h>
-
-#include <X11/X.h>
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#define BIOS_SIZE 0x20000
-
-int
-xf86ReadBIOS(unsigned long Base,unsigned long Offset,unsigned char *Buf,int Len)
-{
- mach_port_t device,mem_dev;
- memory_object_t mem_obj;
- vm_address_t addr = (vm_address_t)0; /* serach starting address */
- kern_return_t err;
-
-
- err = get_privileged_ports (NULL, &device);
- if( err )
- {
- errno = err;
- FatalError("xf86ReadBIOS() can't get_privileged_ports. (%s)\n",strerror(errno));
- }
- err = device_open(device,D_READ|D_WRITE,"mem",&mem_dev);
- mach_port_deallocate (mach_task_self (), device);
- if( err )
- {
- errno = err;
- FatalError("xf86ReadBIOS() can't device_open. (%s)\n",strerror(errno));
- }
- err = device_map(mem_dev,VM_PROT_READ|VM_PROT_WRITE, Base , BIOS_SIZE ,&mem_obj,0);
- if( err )
- {
- errno = err;
- FatalError("xf86ReadBIOS() can't device_map. (%s)\n",strerror(errno));
- }
- err = vm_map(mach_task_self(),
- &addr,
- BIOS_SIZE,
- 0,
- TRUE,
- mem_obj,
- Base,
- FALSE,
- VM_PROT_READ|VM_PROT_WRITE,
- VM_PROT_READ|VM_PROT_WRITE,
- VM_INHERIT_SHARE);
- mach_port_deallocate(mach_task_self(),mem_obj);
- if( err )
- {
- errno = err;
- FatalError("xf86ReadBIOS() can't vm_map. (%s)\n",strerror(errno));
- }
-
- memcpy(Buf,(void*)((int)addr + Offset), Len);
-
- err = vm_deallocate(mach_task_self(), addr, BIOS_SIZE);
- if( err )
- {
- errno = err;
- FatalError("xf86ReadBIOS() can't vm_deallocate. (%s)\n",strerror(errno));
- }
-
- return Len;
-}
+/*
+ * Copyright 1997 by UCHIYAMA Yasushi
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of UCHIYAMA Yasushi not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. UCHIYAMA Yasushi makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include<mach.h>
+#include<device/device.h>
+#include<mach/machine/mach_i386.h>
+
+#include <X11/X.h>
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#define BIOS_SIZE 0x20000
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ mach_port_t device, mem_dev;
+ memory_object_t mem_obj;
+ vm_address_t addr = (vm_address_t) 0; /* serach starting address */
+ kern_return_t err;
+
+ err = get_privileged_ports(NULL, &device);
+ if (err) {
+ errno = err;
+ FatalError("xf86ReadBIOS() can't get_privileged_ports. (%s)\n",
+ strerror(errno));
+ }
+ err = device_open(device, D_READ | D_WRITE, "mem", &mem_dev);
+ mach_port_deallocate(mach_task_self(), device);
+ if (err) {
+ errno = err;
+ FatalError("xf86ReadBIOS() can't device_open. (%s)\n", strerror(errno));
+ }
+ err =
+ device_map(mem_dev, VM_PROT_READ | VM_PROT_WRITE, Base, BIOS_SIZE,
+ &mem_obj, 0);
+ if (err) {
+ errno = err;
+ FatalError("xf86ReadBIOS() can't device_map. (%s)\n", strerror(errno));
+ }
+ err = vm_map(mach_task_self(),
+ &addr,
+ BIOS_SIZE,
+ 0,
+ TRUE,
+ mem_obj,
+ Base,
+ FALSE,
+ VM_PROT_READ | VM_PROT_WRITE,
+ VM_PROT_READ | VM_PROT_WRITE, VM_INHERIT_SHARE);
+ mach_port_deallocate(mach_task_self(), mem_obj);
+ if (err) {
+ errno = err;
+ FatalError("xf86ReadBIOS() can't vm_map. (%s)\n", strerror(errno));
+ }
+
+ memcpy(Buf, (void *) ((int) addr + Offset), Len);
+
+ err = vm_deallocate(mach_task_self(), addr, BIOS_SIZE);
+ if (err) {
+ errno = err;
+ FatalError("xf86ReadBIOS() can't vm_deallocate. (%s)\n",
+ strerror(errno));
+ }
+
+ return Len;
+}
diff --git a/xorg-server/hw/xfree86/os-support/hurd/hurd_video.c b/xorg-server/hw/xfree86/os-support/hurd/hurd_video.c
index a0a3b2758..72474ba10 100644
--- a/xorg-server/hw/xfree86/os-support/hurd/hurd_video.c
+++ b/xorg-server/hw/xfree86/os-support/hurd/hurd_video.c
@@ -1,155 +1,152 @@
-/*
- * Copyright 1997, 1998 by UCHIYAMA Yasushi
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of UCHIYAMA Yasushi not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. UCHIYAMA Yasushi makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <mach.h>
-#include <device/device.h>
-#include <mach/machine/mach_i386.h>
-
-#include <X11/X.h>
-#include "input.h"
-#include "scrnintstr.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
-
-/**************************************************************************
- * Video Memory Mapping section
- ***************************************************************************/
-static pointer
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int Flags)
-{
- mach_port_t device,mem_dev;
- memory_object_t mem_obj;
- kern_return_t err;
- vm_address_t addr=(vm_address_t)0;
-
- err = get_privileged_ports (NULL, &device);
- if( err )
- {
- errno = err;
- FatalError("xf86MapVidMem() can't get_privileged_ports. (%s)\n",strerror(errno));
- }
- err = device_open(device,D_READ|D_WRITE,"mem",&mem_dev);
- mach_port_deallocate (mach_task_self(), device);
- if( err )
- {
- errno = err;
- FatalError("xf86MapVidMem() can't device_open. (%s)\n",strerror(errno));
- }
-
- err = device_map(mem_dev,VM_PROT_READ|VM_PROT_WRITE, Base , Size ,&mem_obj,0);
- if( err )
- {
- errno = err;
- FatalError("xf86MapVidMem() can't device_map. (%s)\n",strerror(errno));
- }
- err = vm_map(mach_task_self(),
- &addr,
- Size,
- 0, /* mask */
- TRUE, /* anywhere */
- mem_obj,
- (vm_offset_t)Base,
- FALSE, /* copy on write */
- VM_PROT_READ|VM_PROT_WRITE,
- VM_PROT_READ|VM_PROT_WRITE,
- VM_INHERIT_SHARE);
- mach_port_deallocate(mach_task_self(),mem_obj);
- if( err )
- {
- errno = err;
- FatalError("xf86MapVidMem() can't vm_map.(mem_obj) (%s)\n",strerror(errno));
- }
- mach_port_deallocate(mach_task_self(),mem_dev);
- if( err )
- {
- errno = err;
- FatalError("xf86MapVidMem() can't mach_port_deallocate.(mem_dev) (%s)\n",strerror(errno));
- }
- return (pointer)addr;
-}
-
-static void
-unmapVidMem(int ScreenNum,pointer Base,unsigned long Size)
-{
- kern_return_t err = vm_deallocate(mach_task_self(), (int)Base, Size);
- if( err )
- {
- errno = err;
- ErrorF("xf86UnMapVidMem: can't dealloc framebuffer space (%s)\n",strerror(errno));
- }
- return;
-}
-
-/**************************************************************************
- * I/O Permissions section
- ***************************************************************************/
-
-/*
- * Due to conflicts with "compiler.h", don't rely on <sys/io.h> to declare
- * this.
- */
-extern int ioperm(unsigned long __from, unsigned long __num, int __turn_on);
-
-Bool
-xf86EnableIO()
-{
- if (ioperm(0, 0x10000, 1)) {
- FatalError("xf86EnableIO: ioperm() failed (%s)\n", strerror(errno));
- return FALSE;
- }
-#if 0
- /*
- * Trapping disabled for now, as some VBIOSes (mga-g450 notably) use these
- * ports, and the int10 wrapper is not emulating them. (Note that it's
- * effectively what happens in the Linux variant too, as iopl() is used
- * there, making the ioperm() meaningless.)
- *
- * Reenable this when int10 gets fixed. */
- ioperm(0x40,4,0); /* trap access to the timer chip */
- ioperm(0x60,4,0); /* trap access to the keyboard controller */
-#endif
- return TRUE;
-}
-
-void
-xf86DisableIO()
-{
- ioperm(0,0x10000,0);
- return;
-}
-
-void
-xf86OSInitVidMem(VidMemInfoPtr pVidMem)
-{
- pVidMem->linearSupported = TRUE;
- pVidMem->mapMem = mapVidMem;
- pVidMem->unmapMem = unmapVidMem;
- pVidMem->initialised = TRUE;
-}
+/*
+ * Copyright 1997, 1998 by UCHIYAMA Yasushi
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of UCHIYAMA Yasushi not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. UCHIYAMA Yasushi makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <mach.h>
+#include <device/device.h>
+#include <mach/machine/mach_i386.h>
+
+#include <X11/X.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+/**************************************************************************
+ * Video Memory Mapping section
+ ***************************************************************************/
+static pointer
+mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int Flags)
+{
+ mach_port_t device, mem_dev;
+ memory_object_t mem_obj;
+ kern_return_t err;
+ vm_address_t addr = (vm_address_t) 0;
+
+ err = get_privileged_ports(NULL, &device);
+ if (err) {
+ errno = err;
+ FatalError("xf86MapVidMem() can't get_privileged_ports. (%s)\n",
+ strerror(errno));
+ }
+ err = device_open(device, D_READ | D_WRITE, "mem", &mem_dev);
+ mach_port_deallocate(mach_task_self(), device);
+ if (err) {
+ errno = err;
+ FatalError("xf86MapVidMem() can't device_open. (%s)\n",
+ strerror(errno));
+ }
+
+ err =
+ device_map(mem_dev, VM_PROT_READ | VM_PROT_WRITE, Base, Size, &mem_obj,
+ 0);
+ if (err) {
+ errno = err;
+ FatalError("xf86MapVidMem() can't device_map. (%s)\n", strerror(errno));
+ }
+ err = vm_map(mach_task_self(), &addr, Size, 0, /* mask */
+ TRUE, /* anywhere */
+ mem_obj, (vm_offset_t) Base, FALSE, /* copy on write */
+ VM_PROT_READ | VM_PROT_WRITE,
+ VM_PROT_READ | VM_PROT_WRITE, VM_INHERIT_SHARE);
+ mach_port_deallocate(mach_task_self(), mem_obj);
+ if (err) {
+ errno = err;
+ FatalError("xf86MapVidMem() can't vm_map.(mem_obj) (%s)\n",
+ strerror(errno));
+ }
+ mach_port_deallocate(mach_task_self(), mem_dev);
+ if (err) {
+ errno = err;
+ FatalError
+ ("xf86MapVidMem() can't mach_port_deallocate.(mem_dev) (%s)\n",
+ strerror(errno));
+ }
+ return (pointer) addr;
+}
+
+static void
+unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ kern_return_t err = vm_deallocate(mach_task_self(), (int) Base, Size);
+
+ if (err) {
+ errno = err;
+ ErrorF("xf86UnMapVidMem: can't dealloc framebuffer space (%s)\n",
+ strerror(errno));
+ }
+ return;
+}
+
+/**************************************************************************
+ * I/O Permissions section
+ ***************************************************************************/
+
+/*
+ * Due to conflicts with "compiler.h", don't rely on <sys/io.h> to declare
+ * this.
+ */
+extern int ioperm(unsigned long __from, unsigned long __num, int __turn_on);
+
+Bool
+xf86EnableIO()
+{
+ if (ioperm(0, 0x10000, 1)) {
+ FatalError("xf86EnableIO: ioperm() failed (%s)\n", strerror(errno));
+ return FALSE;
+ }
+#if 0
+ /*
+ * Trapping disabled for now, as some VBIOSes (mga-g450 notably) use these
+ * ports, and the int10 wrapper is not emulating them. (Note that it's
+ * effectively what happens in the Linux variant too, as iopl() is used
+ * there, making the ioperm() meaningless.)
+ *
+ * Reenable this when int10 gets fixed. */
+ ioperm(0x40, 4, 0); /* trap access to the timer chip */
+ ioperm(0x60, 4, 0); /* trap access to the keyboard controller */
+#endif
+ return TRUE;
+}
+
+void
+xf86DisableIO()
+{
+ ioperm(0, 0x10000, 0);
+ return;
+}
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ pVidMem->linearSupported = TRUE;
+ pVidMem->mapMem = mapVidMem;
+ pVidMem->unmapMem = unmapVidMem;
+ pVidMem->initialised = TRUE;
+}
diff --git a/xorg-server/hw/xfree86/os-support/linux/int10/linux.c b/xorg-server/hw/xfree86/os-support/linux/int10/linux.c
index 564447ff6..fa58a72b6 100644
--- a/xorg-server/hw/xfree86/os-support/linux/int10/linux.c
+++ b/xorg-server/hw/xfree86/os-support/linux/int10/linux.c
@@ -50,10 +50,10 @@ int10MemRec linuxMem = {
typedef struct {
int lowMem;
int highMem;
- char* base;
- char* base_high;
+ char *base;
+ char *base_high;
int screen;
- char* alloc;
+ char *alloc;
} linuxInt10Priv;
#if defined DoSubModules
@@ -69,7 +69,7 @@ static Int10LinuxSubModuleState loadedSubModule = INT10_NOT_LOADED;
static Int10LinuxSubModuleState int10LinuxLoadSubModule(ScrnInfoPtr pScrn);
-#endif /* DoSubModules */
+#endif /* DoSubModules */
xf86Int10InfoPtr
xf86ExtendedInitInt10(int entityIndex, int Flags)
@@ -77,152 +77,155 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
xf86Int10InfoPtr pInt = NULL;
int screen;
int fd;
- static void* vidMem = NULL;
- static void* sysMem = NULL;
- void* vMem = NULL;
+ static void *vidMem = NULL;
+ static void *sysMem = NULL;
+ void *vMem = NULL;
void *options = NULL;
int low_mem;
int high_mem = -1;
char *base = SHMERRORPTR;
char *base_high = SHMERRORPTR;
- int pagesize;
+ int pagesize;
memType cs;
legacyVGARec vga;
Bool videoBiosMapped = FALSE;
-
+
if (int10Generation != serverGeneration) {
- counter = 0;
- int10Generation = serverGeneration;
+ counter = 0;
+ int10Generation = serverGeneration;
}
screen = (xf86FindScreenForEntity(entityIndex))->scrnIndex;
- options = xf86HandleInt10Options(xf86Screens[screen],entityIndex);
+ options = xf86HandleInt10Options(xf86Screens[screen], entityIndex);
if (int10skip(options)) {
- free(options);
- return NULL;
+ free(options);
+ return NULL;
}
#if defined DoSubModules
- if (loadedSubModule == INT10_NOT_LOADED)
- loadedSubModule = int10LinuxLoadSubModule(xf86Screens[screen]);
+ if (loadedSubModule == INT10_NOT_LOADED)
+ loadedSubModule = int10LinuxLoadSubModule(xf86Screens[screen]);
if (loadedSubModule == INT10_LOAD_FAILED)
- return NULL;
+ return NULL;
#endif
if ((!vidMem) || (!sysMem)) {
- if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) {
- if (!sysMem) {
- DebugF("Mapping sys bios area\n");
- if ((sysMem = mmap((void *)(SYS_BIOS), BIOS_SIZE,
- PROT_READ | PROT_EXEC,
- MAP_SHARED | MAP_FIXED, fd, SYS_BIOS))
- == MAP_FAILED) {
- xf86DrvMsg(screen, X_ERROR, "Cannot map SYS BIOS\n");
- close(fd);
- goto error0;
- }
- }
- if (!vidMem) {
- DebugF("Mapping VRAM area\n");
- if ((vidMem = mmap((void *)(V_RAM), VRAM_SIZE,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_SHARED | MAP_FIXED, fd, V_RAM))
- == MAP_FAILED) {
- xf86DrvMsg(screen, X_ERROR, "Cannot map V_RAM\n");
- close(fd);
- goto error0;
- }
- }
- close(fd);
- } else {
- xf86DrvMsg(screen, X_ERROR, "Cannot open %s\n", DEV_MEM);
- goto error0;
- }
+ if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) {
+ if (!sysMem) {
+ DebugF("Mapping sys bios area\n");
+ if ((sysMem = mmap((void *) (SYS_BIOS), BIOS_SIZE,
+ PROT_READ | PROT_EXEC,
+ MAP_SHARED | MAP_FIXED, fd, SYS_BIOS))
+ == MAP_FAILED) {
+ xf86DrvMsg(screen, X_ERROR, "Cannot map SYS BIOS\n");
+ close(fd);
+ goto error0;
+ }
+ }
+ if (!vidMem) {
+ DebugF("Mapping VRAM area\n");
+ if ((vidMem = mmap((void *) (V_RAM), VRAM_SIZE,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_SHARED | MAP_FIXED, fd, V_RAM))
+ == MAP_FAILED) {
+ xf86DrvMsg(screen, X_ERROR, "Cannot map V_RAM\n");
+ close(fd);
+ goto error0;
+ }
+ }
+ close(fd);
+ }
+ else {
+ xf86DrvMsg(screen, X_ERROR, "Cannot open %s\n", DEV_MEM);
+ goto error0;
+ }
}
- pInt = (xf86Int10InfoPtr)xnfcalloc(1, sizeof(xf86Int10InfoRec));
+ pInt = (xf86Int10InfoPtr) xnfcalloc(1, sizeof(xf86Int10InfoRec));
pInt->scrnIndex = screen;
pInt->entityIndex = entityIndex;
pInt->dev = xf86GetPciInfoForEntity(entityIndex);
if (!xf86Int10ExecSetup(pInt))
- goto error0;
+ goto error0;
pInt->mem = &linuxMem;
pagesize = getpagesize();
- pInt->private = (pointer)xnfcalloc(1, sizeof(linuxInt10Priv));
- ((linuxInt10Priv*)pInt->private)->screen = screen;
- ((linuxInt10Priv*)pInt->private)->alloc =
- (pointer)xnfcalloc(1, ALLOC_ENTRIES(pagesize));
+ pInt->private = (pointer) xnfcalloc(1, sizeof(linuxInt10Priv));
+ ((linuxInt10Priv *) pInt->private)->screen = screen;
+ ((linuxInt10Priv *) pInt->private)->alloc =
+ (pointer) xnfcalloc(1, ALLOC_ENTRIES(pagesize));
if (!xf86IsEntityPrimary(entityIndex)) {
- DebugF("Mapping high memory area\n");
- if ((high_mem = shmget(counter++, HIGH_MEM_SIZE,
- IPC_CREAT | SHM_R | SHM_W)) == -1) {
- if (errno == ENOSYS)
- xf86DrvMsg(screen, X_ERROR, "shmget error\n Please reconfigure"
- " your kernel to include System V IPC support\n");
- else
- xf86DrvMsg(screen, X_ERROR,
- "shmget(highmem) error: %s\n",strerror(errno));
- goto error1;
- }
- } else {
- DebugF("Mapping Video BIOS\n");
- videoBiosMapped = TRUE;
- if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) {
- if ((vMem = mmap((void *)(V_BIOS), SYS_BIOS - V_BIOS,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_SHARED | MAP_FIXED, fd, V_BIOS))
- == MAP_FAILED) {
- xf86DrvMsg(screen, X_ERROR, "Cannot map V_BIOS\n");
- close(fd);
- goto error1;
- }
- close (fd);
- } else
- goto error1;
+ DebugF("Mapping high memory area\n");
+ if ((high_mem = shmget(counter++, HIGH_MEM_SIZE,
+ IPC_CREAT | SHM_R | SHM_W)) == -1) {
+ if (errno == ENOSYS)
+ xf86DrvMsg(screen, X_ERROR, "shmget error\n Please reconfigure"
+ " your kernel to include System V IPC support\n");
+ else
+ xf86DrvMsg(screen, X_ERROR,
+ "shmget(highmem) error: %s\n", strerror(errno));
+ goto error1;
+ }
+ }
+ else {
+ DebugF("Mapping Video BIOS\n");
+ videoBiosMapped = TRUE;
+ if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) {
+ if ((vMem = mmap((void *) (V_BIOS), SYS_BIOS - V_BIOS,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_SHARED | MAP_FIXED, fd, V_BIOS))
+ == MAP_FAILED) {
+ xf86DrvMsg(screen, X_ERROR, "Cannot map V_BIOS\n");
+ close(fd);
+ goto error1;
+ }
+ close(fd);
+ }
+ else
+ goto error1;
}
- ((linuxInt10Priv*)pInt->private)->highMem = high_mem;
-
+ ((linuxInt10Priv *) pInt->private)->highMem = high_mem;
+
DebugF("Mapping 640kB area\n");
- if ((low_mem = shmget(counter++, V_RAM,
- IPC_CREAT | SHM_R | SHM_W)) == -1) {
- xf86DrvMsg(screen, X_ERROR,
- "shmget(lowmem) error: %s\n",strerror(errno));
- goto error2;
+ if ((low_mem = shmget(counter++, V_RAM, IPC_CREAT | SHM_R | SHM_W)) == -1) {
+ xf86DrvMsg(screen, X_ERROR,
+ "shmget(lowmem) error: %s\n", strerror(errno));
+ goto error2;
}
- ((linuxInt10Priv*)pInt->private)->lowMem = low_mem;
+ ((linuxInt10Priv *) pInt->private)->lowMem = low_mem;
base = shmat(low_mem, 0, 0);
if (base == SHMERRORPTR) {
- xf86DrvMsg(screen, X_ERROR,
- "shmat(low_mem) error: %s\n",strerror(errno));
- goto error3;
+ xf86DrvMsg(screen, X_ERROR,
+ "shmat(low_mem) error: %s\n", strerror(errno));
+ goto error3;
}
- ((linuxInt10Priv *)pInt->private)->base = base;
+ ((linuxInt10Priv *) pInt->private)->base = base;
if (high_mem > -1) {
- base_high = shmat(high_mem, 0, 0);
- if (base_high == SHMERRORPTR) {
- xf86DrvMsg(screen, X_ERROR,
- "shmat(high_mem) error: %s\n",strerror(errno));
- goto error3;
- }
- ((linuxInt10Priv*)pInt->private)->base_high = base_high;
- } else
- ((linuxInt10Priv*)pInt->private)->base_high = NULL;
+ base_high = shmat(high_mem, 0, 0);
+ if (base_high == SHMERRORPTR) {
+ xf86DrvMsg(screen, X_ERROR,
+ "shmat(high_mem) error: %s\n", strerror(errno));
+ goto error3;
+ }
+ ((linuxInt10Priv *) pInt->private)->base_high = base_high;
+ }
+ else
+ ((linuxInt10Priv *) pInt->private)->base_high = NULL;
if (!MapCurrentInt10(pInt))
- goto error3;
-
+ goto error3;
+
Int10Current = pInt;
DebugF("Mapping int area\n");
- if (xf86ReadBIOS(0, 0, (unsigned char *)0, LOW_PAGE_SIZE) < 0) {
- xf86DrvMsg(screen, X_ERROR, "Cannot read int vect\n");
- goto error3;
+ if (xf86ReadBIOS(0, 0, (unsigned char *) 0, LOW_PAGE_SIZE) < 0) {
+ xf86DrvMsg(screen, X_ERROR, "Cannot read int vect\n");
+ goto error3;
}
DebugF("done\n");
/*
@@ -231,57 +234,58 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
* 64K bytes at a time.
*/
if (!videoBiosMapped) {
- memset((pointer)V_BIOS, 0, SYS_BIOS - V_BIOS);
- DebugF("Reading BIOS\n");
- for (cs = V_BIOS; cs < SYS_BIOS; cs += V_BIOS_SIZE)
- if (xf86ReadBIOS(cs, 0, (pointer)cs, V_BIOS_SIZE) < V_BIOS_SIZE)
- xf86DrvMsg(screen, X_WARNING,
- "Unable to retrieve all of segment 0x%06lX.\n",
- (long)cs);
- DebugF("done\n");
+ memset((pointer) V_BIOS, 0, SYS_BIOS - V_BIOS);
+ DebugF("Reading BIOS\n");
+ for (cs = V_BIOS; cs < SYS_BIOS; cs += V_BIOS_SIZE)
+ if (xf86ReadBIOS(cs, 0, (pointer) cs, V_BIOS_SIZE) < V_BIOS_SIZE)
+ xf86DrvMsg(screen, X_WARNING,
+ "Unable to retrieve all of segment 0x%06lX.\n",
+ (long) cs);
+ DebugF("done\n");
}
if (xf86IsEntityPrimary(entityIndex) && !(initPrimary(options))) {
- if (!xf86int10GetBiosSegment(pInt, NULL))
- goto error3;
-
- set_return_trap(pInt);
-#ifdef _PC
- pInt->Flags = Flags & (SET_BIOS_SCRATCH | RESTORE_BIOS_SCRATCH);
- if (! (pInt->Flags & SET_BIOS_SCRATCH))
- pInt->Flags &= ~RESTORE_BIOS_SCRATCH;
- xf86Int10SaveRestoreBIOSVars(pInt, TRUE);
+ if (!xf86int10GetBiosSegment(pInt, NULL))
+ goto error3;
+
+ set_return_trap(pInt);
+#ifdef _PC
+ pInt->Flags = Flags & (SET_BIOS_SCRATCH | RESTORE_BIOS_SCRATCH);
+ if (!(pInt->Flags & SET_BIOS_SCRATCH))
+ pInt->Flags &= ~RESTORE_BIOS_SCRATCH;
+ xf86Int10SaveRestoreBIOSVars(pInt, TRUE);
#endif
- } else {
- const BusType location_type = xf86int10GetBiosLocationType(pInt);
-
- switch (location_type) {
- case BUS_PCI: {
- int err;
- struct pci_device *rom_device =
- xf86GetPciInfoForEntity(pInt->entityIndex);
-
- pci_device_enable(rom_device);
- err = pci_device_read_rom(rom_device, (unsigned char *)(V_BIOS));
- if (err) {
- xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (%s)\n",
- strerror(err));
- goto error3;
- }
-
- pInt->BIOSseg = V_BIOS >> 4;
- break;
- }
- default:
- goto error3;
- }
-
- pInt->num = 0xe6;
- reset_int_vect(pInt);
- set_return_trap(pInt);
- LockLegacyVGA(pInt, &vga);
- xf86ExecX86int10(pInt);
- UnlockLegacyVGA(pInt, &vga);
+ }
+ else {
+ const BusType location_type = xf86int10GetBiosLocationType(pInt);
+
+ switch (location_type) {
+ case BUS_PCI:{
+ int err;
+ struct pci_device *rom_device =
+ xf86GetPciInfoForEntity(pInt->entityIndex);
+
+ pci_device_enable(rom_device);
+ err = pci_device_read_rom(rom_device, (unsigned char *) (V_BIOS));
+ if (err) {
+ xf86DrvMsg(screen, X_ERROR, "Cannot read V_BIOS (%s)\n",
+ strerror(err));
+ goto error3;
+ }
+
+ pInt->BIOSseg = V_BIOS >> 4;
+ break;
+ }
+ default:
+ goto error3;
+ }
+
+ pInt->num = 0xe6;
+ reset_int_vect(pInt);
+ set_return_trap(pInt);
+ LockLegacyVGA(pInt, &vga);
+ xf86ExecX86int10(pInt);
+ UnlockLegacyVGA(pInt, &vga);
}
#ifdef DEBUG
dprint(0xc0000, 0x20);
@@ -290,24 +294,24 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
free(options);
return pInt;
-error3:
+ error3:
if (base_high)
- shmdt(base_high);
+ shmdt(base_high);
shmdt(base);
shmdt(0);
if (base_high)
- shmdt((char*)HIGH_MEM);
+ shmdt((char *) HIGH_MEM);
shmctl(low_mem, IPC_RMID, NULL);
Int10Current = NULL;
-error2:
+ error2:
if (high_mem > -1)
- shmctl(high_mem, IPC_RMID,NULL);
-error1:
+ shmctl(high_mem, IPC_RMID, NULL);
+ error1:
if (vMem)
- munmap(vMem, SYS_BIOS - V_BIOS);
- free(((linuxInt10Priv*)pInt->private)->alloc);
+ munmap(vMem, SYS_BIOS - V_BIOS);
+ free(((linuxInt10Priv *) pInt->private)->alloc);
free(pInt->private);
-error0:
+ error0:
free(options);
free(pInt);
return NULL;
@@ -318,57 +322,60 @@ MapCurrentInt10(xf86Int10InfoPtr pInt)
{
pointer addr;
int fd = -1;
-
+
if (Int10Current) {
- shmdt(0);
- if (((linuxInt10Priv*)Int10Current->private)->highMem >= 0)
- shmdt((char*)HIGH_MEM);
- else
- munmap((pointer)V_BIOS, (SYS_BIOS - V_BIOS));
+ shmdt(0);
+ if (((linuxInt10Priv *) Int10Current->private)->highMem >= 0)
+ shmdt((char *) HIGH_MEM);
+ else
+ munmap((pointer) V_BIOS, (SYS_BIOS - V_BIOS));
}
- addr = shmat(((linuxInt10Priv*)pInt->private)->lowMem, (char*)1, SHM_RND);
+ addr =
+ shmat(((linuxInt10Priv *) pInt->private)->lowMem, (char *) 1, SHM_RND);
if (addr == SHMERRORPTR) {
- xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot shmat() low memory\n");
- xf86DrvMsg(pInt->scrnIndex, X_ERROR,
- "shmat(low_mem) error: %s\n",strerror(errno));
- return FALSE;
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot shmat() low memory\n");
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR,
+ "shmat(low_mem) error: %s\n", strerror(errno));
+ return FALSE;
}
- if (mprotect((void*)0, V_RAM, PROT_READ|PROT_WRITE|PROT_EXEC) != 0)
+ if (mprotect((void *) 0, V_RAM, PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
xf86DrvMsg(pInt->scrnIndex, X_ERROR,
- "Cannot set EXEC bit on low memory: %s\n", strerror(errno));
-
- if (((linuxInt10Priv*)pInt->private)->highMem >= 0) {
- addr = shmat(((linuxInt10Priv*)pInt->private)->highMem,
- (char*)HIGH_MEM, 0);
- if (addr == SHMERRORPTR) {
- xf86DrvMsg(pInt->scrnIndex, X_ERROR,
- "Cannot shmat() high memory\n");
- xf86DrvMsg(pInt->scrnIndex, X_ERROR,
- "shmget error: %s\n",strerror(errno));
- return FALSE;
- }
- if (mprotect((void*)HIGH_MEM, HIGH_MEM_SIZE,
- PROT_READ|PROT_WRITE|PROT_EXEC) != 0)
- xf86DrvMsg(pInt->scrnIndex, X_ERROR,
- "Cannot set EXEC bit on high memory: %s\n",
- strerror(errno));
- } else {
- if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) {
- if (mmap((void *)(V_BIOS), SYS_BIOS - V_BIOS,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_SHARED | MAP_FIXED, fd, V_BIOS)
- == MAP_FAILED) {
- xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot map V_BIOS\n");
- close (fd);
- return FALSE;
- }
- } else {
- xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot open %s\n",DEV_MEM);
- return FALSE;
- }
- close (fd);
+ "Cannot set EXEC bit on low memory: %s\n", strerror(errno));
+
+ if (((linuxInt10Priv *) pInt->private)->highMem >= 0) {
+ addr = shmat(((linuxInt10Priv *) pInt->private)->highMem,
+ (char *) HIGH_MEM, 0);
+ if (addr == SHMERRORPTR) {
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR,
+ "Cannot shmat() high memory\n");
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR,
+ "shmget error: %s\n", strerror(errno));
+ return FALSE;
+ }
+ if (mprotect((void *) HIGH_MEM, HIGH_MEM_SIZE,
+ PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR,
+ "Cannot set EXEC bit on high memory: %s\n",
+ strerror(errno));
}
-
+ else {
+ if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) {
+ if (mmap((void *) (V_BIOS), SYS_BIOS - V_BIOS,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_SHARED | MAP_FIXED, fd, V_BIOS)
+ == MAP_FAILED) {
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot map V_BIOS\n");
+ close(fd);
+ return FALSE;
+ }
+ }
+ else {
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot open %s\n", DEV_MEM);
+ return FALSE;
+ }
+ close(fd);
+ }
+
return TRUE;
}
@@ -376,27 +383,27 @@ void
xf86FreeInt10(xf86Int10InfoPtr pInt)
{
if (!pInt)
- return;
+ return;
#ifdef _PC
- xf86Int10SaveRestoreBIOSVars(pInt, FALSE);
+ xf86Int10SaveRestoreBIOSVars(pInt, FALSE);
#endif
if (Int10Current == pInt) {
- shmdt(0);
- if (((linuxInt10Priv*)pInt->private)->highMem >= 0)
- shmdt((char*)HIGH_MEM);
- else
- munmap((pointer)V_BIOS, (SYS_BIOS - V_BIOS));
- Int10Current = NULL;
+ shmdt(0);
+ if (((linuxInt10Priv *) pInt->private)->highMem >= 0)
+ shmdt((char *) HIGH_MEM);
+ else
+ munmap((pointer) V_BIOS, (SYS_BIOS - V_BIOS));
+ Int10Current = NULL;
}
-
- if (((linuxInt10Priv*)pInt->private)->base_high)
- shmdt(((linuxInt10Priv*)pInt->private)->base_high);
- shmdt(((linuxInt10Priv*)pInt->private)->base);
- shmctl(((linuxInt10Priv*)pInt->private)->lowMem, IPC_RMID, NULL);
- if (((linuxInt10Priv*)pInt->private)->highMem >= 0)
- shmctl(((linuxInt10Priv*)pInt->private)->highMem, IPC_RMID, NULL);
- free(((linuxInt10Priv*)pInt->private)->alloc);
+
+ if (((linuxInt10Priv *) pInt->private)->base_high)
+ shmdt(((linuxInt10Priv *) pInt->private)->base_high);
+ shmdt(((linuxInt10Priv *) pInt->private)->base);
+ shmctl(((linuxInt10Priv *) pInt->private)->lowMem, IPC_RMID, NULL);
+ if (((linuxInt10Priv *) pInt->private)->highMem >= 0)
+ shmctl(((linuxInt10Priv *) pInt->private)->highMem, IPC_RMID, NULL);
+ free(((linuxInt10Priv *) pInt->private)->alloc);
free(pInt->private);
free(pInt);
}
@@ -409,91 +416,93 @@ xf86Int10AllocPages(xf86Int10InfoPtr pInt, int num, int *off)
int i, j;
for (i = 0; i < (num_pages - num); i++) {
- if (((linuxInt10Priv*)pInt->private)->alloc[i] == 0) {
- for (j = i; j < (num + i); j++)
- if ((((linuxInt10Priv*)pInt->private)->alloc[j] != 0))
- break;
- if (j == (num + i))
- break;
- else
- i = i + num;
- }
+ if (((linuxInt10Priv *) pInt->private)->alloc[i] == 0) {
+ for (j = i; j < (num + i); j++)
+ if ((((linuxInt10Priv *) pInt->private)->alloc[j] != 0))
+ break;
+ if (j == (num + i))
+ break;
+ else
+ i = i + num;
+ }
}
if (i == (num_pages - num))
- return NULL;
+ return NULL;
for (j = i; j < (i + num); j++)
- ((linuxInt10Priv*)pInt->private)->alloc[j] = 1;
+ ((linuxInt10Priv *) pInt->private)->alloc[j] = 1;
*off = (i + 1) * pagesize;
- return ((linuxInt10Priv*)pInt->private)->base + ((i + 1) * pagesize);
+ return ((linuxInt10Priv *) pInt->private)->base + ((i + 1) * pagesize);
}
void
xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase, int num)
{
int pagesize = getpagesize();
- int first = (((unsigned long)pbase
- - (unsigned long)((linuxInt10Priv*)pInt->private)->base)
- / pagesize) - 1;
+ int first = (((unsigned long) pbase
+ - (unsigned long) ((linuxInt10Priv *) pInt->private)->base)
+ / pagesize) - 1;
int i;
for (i = first; i < (first + num); i++)
- ((linuxInt10Priv*)pInt->private)->alloc[i] = 0;
+ ((linuxInt10Priv *) pInt->private)->alloc[i] = 0;
}
static CARD8
read_b(xf86Int10InfoPtr pInt, int addr)
{
- return *((CARD8 *)(memType)addr);
+ return *((CARD8 *) (memType) addr);
}
static CARD16
read_w(xf86Int10InfoPtr pInt, int addr)
{
- return *((CARD16 *)(memType)addr);
+ return *((CARD16 *) (memType) addr);
}
static CARD32
read_l(xf86Int10InfoPtr pInt, int addr)
{
- return *((CARD32 *)(memType)addr);
+ return *((CARD32 *) (memType) addr);
}
static void
write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val)
{
- *((CARD8 *)(memType)addr) = val;
+ *((CARD8 *) (memType) addr) = val;
}
static void
write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val)
{
- *((CARD16 *)(memType)addr) = val;
+ *((CARD16 *) (memType) addr) = val;
}
static
-void write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val)
+ void
+write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val)
{
- *((CARD32 *)(memType) addr) = val;
+ *((CARD32 *) (memType) addr) = val;
}
pointer
xf86int10Addr(xf86Int10InfoPtr pInt, CARD32 addr)
{
if (addr < V_RAM)
- return ((linuxInt10Priv*)pInt->private)->base + addr;
+ return ((linuxInt10Priv *) pInt->private)->base + addr;
else if (addr < V_BIOS)
- return (pointer)(memType)addr;
+ return (pointer) (memType) addr;
else if (addr < SYS_BIOS) {
- if (((linuxInt10Priv*)pInt->private)->base_high)
- return (pointer)(((linuxInt10Priv*)pInt->private)->base_high
- - V_BIOS + addr);
- else
- return (pointer) (memType)addr;
- } else
- return (pointer) (memType)addr;
+ if (((linuxInt10Priv *) pInt->private)->base_high)
+ return (pointer) (((linuxInt10Priv *) pInt->private)->base_high
+ - V_BIOS + addr);
+ else
+ return (pointer) (memType) addr;
+ }
+ else
+ return (pointer) (memType) addr;
}
#if defined DoSubModules
@@ -507,20 +516,17 @@ vm86_tst(void)
/* When compiling with -fPIC, we can't use asm constraint "b" because
%ebx is already taken by gcc. */
__asm__ __volatile__("pushl %%ebx\n\t"
- "movl %2,%%ebx\n\t"
- "movl %1,%%eax\n\t"
- "int $0x80\n\t"
- "popl %%ebx"
- :"=a" (__res)
- :"n" ((int)113), "r" (NULL));
+ "movl %2,%%ebx\n\t"
+ "movl %1,%%eax\n\t"
+ "int $0x80\n\t" "popl %%ebx":"=a"(__res)
+ :"n"((int) 113), "r"(NULL));
#else
- __asm__ __volatile__("int $0x80\n\t"
- :"=a" (__res):"a" ((int)113),
- "b" ((struct vm86_struct *)NULL));
+ __asm__ __volatile__("int $0x80\n\t":"=a"(__res):"a"((int) 113),
+ "b"((struct vm86_struct *) NULL));
#endif
- if (__res < 0 && __res == -ENOSYS)
- return FALSE;
+ if (__res < 0 && __res == -ENOSYS)
+ return FALSE;
return TRUE;
}
@@ -529,13 +535,13 @@ static Int10LinuxSubModuleState
int10LinuxLoadSubModule(ScrnInfoPtr pScrn)
{
if (vm86_tst()) {
- if (xf86LoadSubModule(pScrn,"vm86"))
- return INT10_LOADED_VM86;
- }
- if (xf86LoadSubModule(pScrn,"x86emu"))
- return INT10_LOADED_X86EMU;
+ if (xf86LoadSubModule(pScrn, "vm86"))
+ return INT10_LOADED_VM86;
+ }
+ if (xf86LoadSubModule(pScrn, "x86emu"))
+ return INT10_LOADED_X86EMU;
return INT10_LOAD_FAILED;
}
-#endif /* DoSubModules */
+#endif /* DoSubModules */
diff --git a/xorg-server/hw/xfree86/os-support/linux/int10/vm86/linux_vm86.c b/xorg-server/hw/xfree86/os-support/linux/int10/vm86/linux_vm86.c
index 34afd9502..8502b21b7 100644
--- a/xorg-server/hw/xfree86/os-support/linux/int10/vm86/linux_vm86.c
+++ b/xorg-server/hw/xfree86/os-support/linux/int10/vm86/linux_vm86.c
@@ -25,7 +25,7 @@ xf86Int10ExecSetup(xf86Int10InfoPtr pInt)
{
#define VM86S ((struct vm86_struct *)pInt->cpuRegs)
- pInt->cpuRegs = &vm86_s;
+ pInt->cpuRegs = &vm86_s;
VM86S->flags = 0;
VM86S->screen_bitmap = 0;
VM86S->cpu_type = CPU_586;
@@ -58,137 +58,172 @@ vm86_GP_fault(xf86Int10InfoPtr pInt)
/* eat up prefixes */
done = 0;
do {
- switch (MEM_RB(pInt, (int)csp++)) {
- case 0x66: /* operand prefix */ prefix66=1; break;
- case 0x67: /* address prefix */ prefix67=1; break;
- case 0x2e: /* CS */ pref_seg=X86_CS; break;
- case 0x3e: /* DS */ pref_seg=X86_DS; break;
- case 0x26: /* ES */ pref_seg=X86_ES; break;
- case 0x36: /* SS */ pref_seg=X86_SS; break;
- case 0x65: /* GS */ pref_seg=X86_GS; break;
- case 0x64: /* FS */ pref_seg=X86_FS; break;
- case 0xf0: /* lock */ break;
- case 0xf2: /* repnz */
- case 0xf3: /* rep */ is_rep=1; break;
- default: done=1;
- }
+ switch (MEM_RB(pInt, (int) csp++)) {
+ case 0x66: /* operand prefix */
+ prefix66 = 1;
+ break;
+ case 0x67: /* address prefix */
+ prefix67 = 1;
+ break;
+ case 0x2e: /* CS */
+ pref_seg = X86_CS;
+ break;
+ case 0x3e: /* DS */
+ pref_seg = X86_DS;
+ break;
+ case 0x26: /* ES */
+ pref_seg = X86_ES;
+ break;
+ case 0x36: /* SS */
+ pref_seg = X86_SS;
+ break;
+ case 0x65: /* GS */
+ pref_seg = X86_GS;
+ break;
+ case 0x64: /* FS */
+ pref_seg = X86_FS;
+ break;
+ case 0xf0: /* lock */
+ break;
+ case 0xf2: /* repnz */
+ case 0xf3: /* rep */
+ is_rep = 1;
+ break;
+ default:
+ done = 1;
+ }
} while (!done);
- csp--; /* oops one too many */
+ csp--; /* oops one too many */
org_eip = X86_EIP;
X86_IP += (csp - lina);
- switch (MEM_RB(pInt, (int)csp)) {
- case 0x6c: /* insb */
- /* NOTE: ES can't be overwritten; prefixes 66,67 should use esi,edi,ecx
- * but is anyone using extended regs in real mode? */
- /* WARNING: no test for DI wrapping! */
- X86_EDI += port_rep_inb(pInt, X86_DX, SEG_EADR((CARD32), X86_ES, DI),
- X86_FLAGS & DF, is_rep ? LWECX : 1);
- if (is_rep) LWECX_ZERO;
- X86_IP++;
- break;
-
- case 0x6d: /* (rep) insw / insd */
- /* NOTE: ES can't be overwritten */
- /* WARNING: no test for _DI wrapping! */
- if (prefix66) {
- X86_DI += port_rep_inl(pInt, X86_DX, SEG_ADR((CARD32), X86_ES, DI),
- X86_EFLAGS & DF, is_rep ? LWECX : 1);
- }
- else {
- X86_DI += port_rep_inw(pInt, X86_DX, SEG_ADR((CARD32), X86_ES, DI),
- X86_FLAGS & DF, is_rep ? LWECX : 1);
- }
- if (is_rep) LWECX_ZERO;
- X86_IP++;
- break;
-
- case 0x6e: /* (rep) outsb */
- if (pref_seg < 0) pref_seg = X86_DS;
- /* WARNING: no test for _SI wrapping! */
- X86_SI += port_rep_outb(pInt, X86_DX, (CARD32)LIN_PREF_SI,
- X86_FLAGS & DF, is_rep ? LWECX : 1);
- if (is_rep) LWECX_ZERO;
- X86_IP++;
- break;
-
- case 0x6f: /* (rep) outsw / outsd */
- if (pref_seg < 0) pref_seg = X86_DS;
- /* WARNING: no test for _SI wrapping! */
- if (prefix66) {
- X86_SI += port_rep_outl(pInt, X86_DX, (CARD32)LIN_PREF_SI,
- X86_EFLAGS & DF, is_rep ? LWECX : 1);
- }
- else {
- X86_SI += port_rep_outw(pInt, X86_DX, (CARD32)LIN_PREF_SI,
- X86_FLAGS & DF, is_rep ? LWECX : 1);
- }
- if (is_rep) LWECX_ZERO;
- X86_IP++;
- break;
-
- case 0xe5: /* inw xx, inl xx */
- if (prefix66) X86_EAX = x_inl(csp[1]);
- else X86_AX = x_inw(csp[1]);
- X86_IP += 2;
- break;
-
- case 0xe4: /* inb xx */
- X86_AL = x_inb(csp[1]);
- X86_IP += 2;
- break;
-
- case 0xed: /* inw dx, inl dx */
- if (prefix66) X86_EAX = x_inl(X86_DX);
- else X86_AX = x_inw(X86_DX);
- X86_IP += 1;
- break;
-
- case 0xec: /* inb dx */
- X86_AL = x_inb(X86_DX);
- X86_IP += 1;
- break;
-
- case 0xe7: /* outw xx */
- if (prefix66) x_outl(csp[1], X86_EAX);
- else x_outw(csp[1], X86_AX);
- X86_IP += 2;
- break;
-
- case 0xe6: /* outb xx */
- x_outb(csp[1], X86_AL);
- X86_IP += 2;
- break;
-
- case 0xef: /* outw dx */
- if (prefix66) x_outl(X86_DX, X86_EAX);
- else x_outw(X86_DX, X86_AX);
- X86_IP += 1;
- break;
-
- case 0xee: /* outb dx */
- x_outb(X86_DX, X86_AL);
- X86_IP += 1;
- break;
+ switch (MEM_RB(pInt, (int) csp)) {
+ case 0x6c: /* insb */
+ /* NOTE: ES can't be overwritten; prefixes 66,67 should use esi,edi,ecx
+ * but is anyone using extended regs in real mode? */
+ /* WARNING: no test for DI wrapping! */
+ X86_EDI += port_rep_inb(pInt, X86_DX, SEG_EADR((CARD32), X86_ES, DI),
+ X86_FLAGS & DF, is_rep ? LWECX : 1);
+ if (is_rep)
+ LWECX_ZERO;
+ X86_IP++;
+ break;
+
+ case 0x6d: /* (rep) insw / insd */
+ /* NOTE: ES can't be overwritten */
+ /* WARNING: no test for _DI wrapping! */
+ if (prefix66) {
+ X86_DI += port_rep_inl(pInt, X86_DX, SEG_ADR((CARD32), X86_ES, DI),
+ X86_EFLAGS & DF, is_rep ? LWECX : 1);
+ }
+ else {
+ X86_DI += port_rep_inw(pInt, X86_DX, SEG_ADR((CARD32), X86_ES, DI),
+ X86_FLAGS & DF, is_rep ? LWECX : 1);
+ }
+ if (is_rep)
+ LWECX_ZERO;
+ X86_IP++;
+ break;
+
+ case 0x6e: /* (rep) outsb */
+ if (pref_seg < 0)
+ pref_seg = X86_DS;
+ /* WARNING: no test for _SI wrapping! */
+ X86_SI += port_rep_outb(pInt, X86_DX, (CARD32) LIN_PREF_SI,
+ X86_FLAGS & DF, is_rep ? LWECX : 1);
+ if (is_rep)
+ LWECX_ZERO;
+ X86_IP++;
+ break;
+
+ case 0x6f: /* (rep) outsw / outsd */
+ if (pref_seg < 0)
+ pref_seg = X86_DS;
+ /* WARNING: no test for _SI wrapping! */
+ if (prefix66) {
+ X86_SI += port_rep_outl(pInt, X86_DX, (CARD32) LIN_PREF_SI,
+ X86_EFLAGS & DF, is_rep ? LWECX : 1);
+ }
+ else {
+ X86_SI += port_rep_outw(pInt, X86_DX, (CARD32) LIN_PREF_SI,
+ X86_FLAGS & DF, is_rep ? LWECX : 1);
+ }
+ if (is_rep)
+ LWECX_ZERO;
+ X86_IP++;
+ break;
+
+ case 0xe5: /* inw xx, inl xx */
+ if (prefix66)
+ X86_EAX = x_inl(csp[1]);
+ else
+ X86_AX = x_inw(csp[1]);
+ X86_IP += 2;
+ break;
+
+ case 0xe4: /* inb xx */
+ X86_AL = x_inb(csp[1]);
+ X86_IP += 2;
+ break;
+
+ case 0xed: /* inw dx, inl dx */
+ if (prefix66)
+ X86_EAX = x_inl(X86_DX);
+ else
+ X86_AX = x_inw(X86_DX);
+ X86_IP += 1;
+ break;
+
+ case 0xec: /* inb dx */
+ X86_AL = x_inb(X86_DX);
+ X86_IP += 1;
+ break;
+
+ case 0xe7: /* outw xx */
+ if (prefix66)
+ x_outl(csp[1], X86_EAX);
+ else
+ x_outw(csp[1], X86_AX);
+ X86_IP += 2;
+ break;
+
+ case 0xe6: /* outb xx */
+ x_outb(csp[1], X86_AL);
+ X86_IP += 2;
+ break;
+
+ case 0xef: /* outw dx */
+ if (prefix66)
+ x_outl(X86_DX, X86_EAX);
+ else
+ x_outw(X86_DX, X86_AX);
+ X86_IP += 1;
+ break;
+
+ case 0xee: /* outb dx */
+ x_outb(X86_DX, X86_AL);
+ X86_IP += 1;
+ break;
case 0xf4:
- DebugF("hlt at %p\n", lina);
- return FALSE;
+ DebugF("hlt at %p\n", lina);
+ return FALSE;
case 0x0f:
- xf86DrvMsg(pInt->scrnIndex, X_ERROR,
- "CPU 0x0f Trap at CS:EIP=0x%4.4x:0x%8.8lx\n", X86_CS, X86_EIP);
- goto op0ferr;
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR,
+ "CPU 0x0f Trap at CS:EIP=0x%4.4x:0x%8.8lx\n", X86_CS,
+ X86_EIP);
+ goto op0ferr;
default:
- xf86DrvMsg(pInt->scrnIndex, X_ERROR, "unknown reason for exception\n");
-
- op0ferr:
- dump_registers(pInt);
- stack_trace(pInt);
- dump_code(pInt);
- xf86DrvMsg(pInt->scrnIndex, X_ERROR, "cannot continue\n");
- return FALSE;
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR, "unknown reason for exception\n");
+
+ op0ferr:
+ dump_registers(pInt);
+ stack_trace(pInt);
+ dump_code(pInt);
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR, "cannot continue\n");
+ return FALSE;
} /* end of switch() */
return TRUE;
}
@@ -203,51 +238,52 @@ do_vm86(xf86Int10InfoPtr pInt)
xf86InterceptSignals(NULL);
if (signo >= 0) {
- xf86DrvMsg(pInt->scrnIndex, X_ERROR,
- "vm86() syscall generated signal %d.\n", signo);
- dump_registers(pInt);
- dump_code(pInt);
- stack_trace(pInt);
- return 0;
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR,
+ "vm86() syscall generated signal %d.\n", signo);
+ dump_registers(pInt);
+ dump_code(pInt);
+ stack_trace(pInt);
+ return 0;
}
switch (VM86_TYPE(retval)) {
case VM86_UNKNOWN:
- if (!vm86_GP_fault(pInt)) return 0;
- break;
+ if (!vm86_GP_fault(pInt))
+ return 0;
+ break;
case VM86_STI:
- xf86DrvMsg(pInt->scrnIndex, X_ERROR, "vm86_sti :-((\n");
- dump_registers(pInt);
- dump_code(pInt);
- stack_trace(pInt);
- return 0;
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR, "vm86_sti :-((\n");
+ dump_registers(pInt);
+ dump_code(pInt);
+ stack_trace(pInt);
+ return 0;
case VM86_INTx:
- pInt->num = VM86_ARG(retval);
- if (!int_handler(pInt)) {
- xf86DrvMsg(pInt->scrnIndex, X_ERROR,
- "Unknown vm86_int: 0x%X\n\n", VM86_ARG(retval));
- dump_registers(pInt);
- dump_code(pInt);
- stack_trace(pInt);
- return 0;
- }
- /* I'm not sure yet what to do if we can handle ints */
- break;
+ pInt->num = VM86_ARG(retval);
+ if (!int_handler(pInt)) {
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR,
+ "Unknown vm86_int: 0x%X\n\n", VM86_ARG(retval));
+ dump_registers(pInt);
+ dump_code(pInt);
+ stack_trace(pInt);
+ return 0;
+ }
+ /* I'm not sure yet what to do if we can handle ints */
+ break;
case VM86_SIGNAL:
- return 1;
- /*
- * we used to warn here and bail out - but now the sigio stuff
- * always fires signals at us. So we just ignore them for now.
- */
- xf86DrvMsg(pInt->scrnIndex, X_WARNING, "received signal\n");
- return 0;
+ return 1;
+ /*
+ * we used to warn here and bail out - but now the sigio stuff
+ * always fires signals at us. So we just ignore them for now.
+ */
+ xf86DrvMsg(pInt->scrnIndex, X_WARNING, "received signal\n");
+ return 0;
default:
- xf86DrvMsg(pInt->scrnIndex, X_ERROR, "unknown type(0x%x)=0x%x\n",
- VM86_ARG(retval), VM86_TYPE(retval));
- dump_registers(pInt);
- dump_code(pInt);
- stack_trace(pInt);
- return 0;
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR, "unknown type(0x%x)=0x%x\n",
+ VM86_ARG(retval), VM86_TYPE(retval));
+ dump_registers(pInt);
+ dump_code(pInt);
+ stack_trace(pInt);
+ return 0;
}
return 1;
@@ -259,7 +295,8 @@ xf86ExecX86int10(xf86Int10InfoPtr pInt)
int sig = setup_int(pInt);
if (int_handler(pInt))
- while(do_vm86(pInt)) {};
+ while (do_vm86(pInt)) {
+ };
finish_int(pInt, sig);
}
@@ -273,28 +310,25 @@ vm86_rep(struct vm86_struct *ptr)
/* When compiling with -fPIC, we can't use asm constraint "b" because
%ebx is already taken by gcc. */
__asm__ __volatile__("pushl %%ebx\n\t"
- "push %%gs\n\t"
- "movl %2,%%ebx\n\t"
- "movl %1,%%eax\n\t"
- "int $0x80\n\t"
- "pop %%gs\n\t"
- "popl %%ebx"
- :"=a" (__res)
- :"n" ((int)113), "r" ((struct vm86_struct *)ptr));
+ "push %%gs\n\t"
+ "movl %2,%%ebx\n\t"
+ "movl %1,%%eax\n\t"
+ "int $0x80\n\t" "pop %%gs\n\t" "popl %%ebx":"=a"(__res)
+ :"n"((int) 113), "r"((struct vm86_struct *) ptr));
#else
__asm__ __volatile__("push %%gs\n\t"
- "int $0x80\n\t"
- "pop %%gs"
- :"=a" (__res):"a" ((int)113),
- "b" ((struct vm86_struct *)ptr));
+ "int $0x80\n\t"
+ "pop %%gs":"=a"(__res):"a"((int) 113),
+ "b"((struct vm86_struct *) ptr));
#endif
- if (__res < 0) {
- errno = -__res;
- __res = -1;
- }
- else errno = 0;
- return __res;
+ if (__res < 0) {
+ errno = -__res;
+ __res = -1;
+ }
+ else
+ errno = 0;
+ return __res;
}
#endif
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c b/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c
index dcc878060..e1fa3f8a7 100644
--- a/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c
+++ b/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c
@@ -1,374 +1,371 @@
-/*
- * Abstraction of the AGP GART interface.
- *
- * This version is for Linux and Free/Open/NetBSD.
- *
- * Copyright © 2000 VA Linux Systems, Inc.
- * Copyright © 2001 The XFree86 Project, Inc.
- */
-
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
-
-#if defined(linux)
-#include <asm/ioctl.h>
-#include <linux/agpgart.h>
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
-#include <sys/ioctl.h>
-#include <sys/agpio.h>
-#endif
-
-#ifndef AGP_DEVICE
-#define AGP_DEVICE "/dev/agpgart"
-#endif
-/* AGP page size is independent of the host page size. */
-#ifndef AGP_PAGE_SIZE
-#define AGP_PAGE_SIZE 4096
-#endif
-#define AGPGART_MAJOR_VERSION 0
-#define AGPGART_MINOR_VERSION 99
-
-static int gartFd = -1;
-static int acquiredScreen = -1;
-static Bool initDone = FALSE;
-/*
- * Close /dev/agpgart. This frees all associated memory allocated during
- * this server generation.
- */
-Bool
-xf86GARTCloseScreen(int screenNum)
-{
- if(gartFd != -1) {
- close(gartFd);
- acquiredScreen = -1;
- gartFd = -1;
- initDone = FALSE;
- }
- return TRUE;
-}
-
-/*
- * Open /dev/agpgart. Keep it open until xf86GARTCloseScreen is called.
- */
-static Bool
-GARTInit(int screenNum)
-{
- struct _agp_info agpinf;
-
- if (initDone)
- return gartFd != -1;
-
- initDone = TRUE;
-
- if (gartFd == -1)
- gartFd = open(AGP_DEVICE, O_RDWR, 0);
- else
- return FALSE;
-
- if (gartFd == -1) {
- xf86DrvMsg(screenNum, X_ERROR,
- "GARTInit: Unable to open " AGP_DEVICE " (%s)\n",
- strerror(errno));
- return FALSE;
- }
-
- xf86AcquireGART(-1);
- /* Check the kernel driver version. */
- if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
- xf86DrvMsg(screenNum, X_ERROR,
- "GARTInit: AGPIOC_INFO failed (%s)\n", strerror(errno));
- close(gartFd);
- gartFd = -1;
- return FALSE;
- }
- xf86ReleaseGART(-1);
-
-#if defined(linux)
- /* Per Dave Jones, every effort will be made to keep the
- * agpgart interface backwards compatible, so allow all
- * future versions.
- */
- if (
-#if (AGPGART_MAJOR_VERSION > 0) /* quiet compiler */
- agpinf.version.major < AGPGART_MAJOR_VERSION ||
-#endif
- (agpinf.version.major == AGPGART_MAJOR_VERSION &&
- agpinf.version.minor < AGPGART_MINOR_VERSION)) {
- xf86DrvMsg(screenNum, X_ERROR,
- "GARTInit: Kernel agpgart driver version is not current"
- " (%d.%d vs %d.%d)\n",
- agpinf.version.major, agpinf.version.minor,
- AGPGART_MAJOR_VERSION, AGPGART_MINOR_VERSION);
- close(gartFd);
- gartFd = -1;
- return FALSE;
- }
-#endif
-
- return TRUE;
-}
-
-Bool
-xf86AgpGARTSupported(void)
-{
- return GARTInit(-1);
-}
-
-AgpInfoPtr
-xf86GetAGPInfo(int screenNum)
-{
- struct _agp_info agpinf;
- AgpInfoPtr info;
-
- if (!GARTInit(screenNum))
- return NULL;
-
-
- if ((info = calloc(sizeof(AgpInfo), 1)) == NULL) {
- xf86DrvMsg(screenNum, X_ERROR,
- "xf86GetAGPInfo: Failed to allocate AgpInfo\n");
- return NULL;
- }
-
- memset((char*)&agpinf, 0, sizeof(agpinf));
-
- if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
- xf86DrvMsg(screenNum, X_ERROR,
- "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n",
- strerror(errno));
- return NULL;
- }
-
- info->bridgeId = agpinf.bridge_id;
- info->agpMode = agpinf.agp_mode;
- info->base = agpinf.aper_base;
- info->size = agpinf.aper_size;
- info->totalPages = agpinf.pg_total;
- info->systemPages = agpinf.pg_system;
- info->usedPages = agpinf.pg_used;
-
- xf86DrvMsg(screenNum, X_INFO, "Kernel reported %zu total, %zu used\n", agpinf.pg_total, agpinf.pg_used);
-
- return info;
-}
-
-/*
- * XXX If multiple screens can acquire the GART, should we have a reference
- * count instead of using acquiredScreen?
- */
-
-Bool
-xf86AcquireGART(int screenNum)
-{
- if (screenNum != -1 && !GARTInit(screenNum))
- return FALSE;
-
- if (screenNum == -1 || acquiredScreen != screenNum) {
- if (ioctl(gartFd, AGPIOC_ACQUIRE, 0) != 0) {
- xf86DrvMsg(screenNum, X_WARNING,
- "xf86AcquireGART: AGPIOC_ACQUIRE failed (%s)\n",
- strerror(errno));
- return FALSE;
- }
- acquiredScreen = screenNum;
- }
- return TRUE;
-}
-
-Bool
-xf86ReleaseGART(int screenNum)
-{
- if (screenNum != -1 && !GARTInit(screenNum))
- return FALSE;
-
- if (acquiredScreen == screenNum) {
- /*
- * The FreeBSD agp driver removes allocations on release.
- * The Linux driver doesn't. xf86ReleaseGART() is expected
- * to give up access to the GART, but not to remove any
- * allocations.
- */
-#if !defined(linux)
- if (screenNum == -1)
-#endif
- {
- if (ioctl(gartFd, AGPIOC_RELEASE, 0) != 0) {
- xf86DrvMsg(screenNum, X_WARNING,
- "xf86ReleaseGART: AGPIOC_RELEASE failed (%s)\n",
- strerror(errno));
- return FALSE;
- }
- acquiredScreen = -1;
- }
- return TRUE;
- }
- return FALSE;
-}
-
-int
-xf86AllocateGARTMemory(int screenNum, unsigned long size, int type,
- unsigned long *physical)
-{
- struct _agp_allocate alloc;
- int pages;
-
- /*
- * Allocates "size" bytes of GART memory (rounds up to the next
- * page multiple) or type "type". A handle (key) for the allocated
- * memory is returned. On error, the return value is -1.
- */
-
- if (!GARTInit(screenNum) || acquiredScreen != screenNum)
- return -1;
-
- pages = (size / AGP_PAGE_SIZE);
- if (size % AGP_PAGE_SIZE != 0)
- pages++;
-
- /* XXX check for pages == 0? */
-
- alloc.pg_count = pages;
- alloc.type = type;
-
- if (ioctl(gartFd, AGPIOC_ALLOCATE, &alloc) != 0) {
- xf86DrvMsg(screenNum, X_WARNING, "xf86AllocateGARTMemory: "
- "allocation of %d pages failed\n\t(%s)\n", pages,
- strerror(errno));
- return -1;
- }
-
- if (physical)
- *physical = alloc.physical;
-
- return alloc.key;
-}
-
-Bool
-xf86DeallocateGARTMemory(int screenNum, int key)
-{
- if (!GARTInit(screenNum) || acquiredScreen != screenNum)
- return FALSE;
-
- if (acquiredScreen != screenNum) {
- xf86DrvMsg(screenNum, X_ERROR,
- "xf86UnbindGARTMemory: AGP not acquired by this screen\n");
- return FALSE;
- }
-
-#ifdef __linux__
- if (ioctl(gartFd, AGPIOC_DEALLOCATE, (int *)(uintptr_t)key) != 0) {
-#else
- if (ioctl(gartFd, AGPIOC_DEALLOCATE, &key) != 0) {
-#endif
- xf86DrvMsg(screenNum, X_WARNING,"xf86DeAllocateGARTMemory: "
- "deallocation gart memory with key %d failed\n\t(%s)\n",
- key, strerror(errno));
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* Bind GART memory with "key" at "offset" */
-Bool
-xf86BindGARTMemory(int screenNum, int key, unsigned long offset)
-{
- struct _agp_bind bind;
- int pageOffset;
-
- if (!GARTInit(screenNum) || acquiredScreen != screenNum)
- return FALSE;
-
- if (acquiredScreen != screenNum) {
- xf86DrvMsg(screenNum, X_ERROR,
- "xf86BindGARTMemory: AGP not acquired by this screen\n");
- return FALSE;
- }
-
- if (offset % AGP_PAGE_SIZE != 0) {
- xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: "
- "offset (0x%lx) is not page-aligned (%d)\n",
- offset, AGP_PAGE_SIZE);
- return FALSE;
- }
- pageOffset = offset / AGP_PAGE_SIZE;
-
- xf86DrvMsgVerb(screenNum, X_INFO, 3,
- "xf86BindGARTMemory: bind key %d at 0x%08lx "
- "(pgoffset %d)\n", key, offset, pageOffset);
-
- bind.pg_start = pageOffset;
- bind.key = key;
-
- if (ioctl(gartFd, AGPIOC_BIND, &bind) != 0) {
- xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: "
- "binding of gart memory with key %d\n"
- "\tat offset 0x%lx failed (%s)\n",
- key, offset, strerror(errno));
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-/* Unbind GART memory with "key" */
-Bool
-xf86UnbindGARTMemory(int screenNum, int key)
-{
- struct _agp_unbind unbind;
-
- if (!GARTInit(screenNum) || acquiredScreen != screenNum)
- return FALSE;
-
- if (acquiredScreen != screenNum) {
- xf86DrvMsg(screenNum, X_ERROR,
- "xf86UnbindGARTMemory: AGP not acquired by this screen\n");
- return FALSE;
- }
-
- unbind.priority = 0;
- unbind.key = key;
-
- if (ioctl(gartFd, AGPIOC_UNBIND, &unbind) != 0) {
- xf86DrvMsg(screenNum, X_WARNING, "xf86UnbindGARTMemory: "
- "unbinding of gart memory with key %d "
- "failed (%s)\n", key, strerror(errno));
- return FALSE;
- }
-
- xf86DrvMsgVerb(screenNum, X_INFO, 3,
- "xf86UnbindGARTMemory: unbind key %d\n", key);
-
- return TRUE;
-}
-
-
-/* XXX Interface may change. */
-Bool
-xf86EnableAGP(int screenNum, CARD32 mode)
-{
- agp_setup setup;
-
- if (!GARTInit(screenNum) || acquiredScreen != screenNum)
- return FALSE;
-
- setup.agp_mode = mode;
- if (ioctl(gartFd, AGPIOC_SETUP, &setup) != 0) {
- xf86DrvMsg(screenNum, X_WARNING, "xf86EnableAGP: "
- "AGPIOC_SETUP with mode %ld failed (%s)\n",
- (unsigned long)mode, strerror(errno));
- return FALSE;
- }
-
- return TRUE;
-}
-
+/*
+ * Abstraction of the AGP GART interface.
+ *
+ * This version is for Linux and Free/Open/NetBSD.
+ *
+ * Copyright © 2000 VA Linux Systems, Inc.
+ * Copyright © 2001 The XFree86 Project, Inc.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#if defined(linux)
+#include <asm/ioctl.h>
+#include <linux/agpgart.h>
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+#include <sys/ioctl.h>
+#include <sys/agpio.h>
+#endif
+
+#ifndef AGP_DEVICE
+#define AGP_DEVICE "/dev/agpgart"
+#endif
+/* AGP page size is independent of the host page size. */
+#ifndef AGP_PAGE_SIZE
+#define AGP_PAGE_SIZE 4096
+#endif
+#define AGPGART_MAJOR_VERSION 0
+#define AGPGART_MINOR_VERSION 99
+
+static int gartFd = -1;
+static int acquiredScreen = -1;
+static Bool initDone = FALSE;
+
+/*
+ * Close /dev/agpgart. This frees all associated memory allocated during
+ * this server generation.
+ */
+Bool
+xf86GARTCloseScreen(int screenNum)
+{
+ if (gartFd != -1) {
+ close(gartFd);
+ acquiredScreen = -1;
+ gartFd = -1;
+ initDone = FALSE;
+ }
+ return TRUE;
+}
+
+/*
+ * Open /dev/agpgart. Keep it open until xf86GARTCloseScreen is called.
+ */
+static Bool
+GARTInit(int screenNum)
+{
+ struct _agp_info agpinf;
+
+ if (initDone)
+ return gartFd != -1;
+
+ initDone = TRUE;
+
+ if (gartFd == -1)
+ gartFd = open(AGP_DEVICE, O_RDWR, 0);
+ else
+ return FALSE;
+
+ if (gartFd == -1) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "GARTInit: Unable to open " AGP_DEVICE " (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+
+ xf86AcquireGART(-1);
+ /* Check the kernel driver version. */
+ if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "GARTInit: AGPIOC_INFO failed (%s)\n", strerror(errno));
+ close(gartFd);
+ gartFd = -1;
+ return FALSE;
+ }
+ xf86ReleaseGART(-1);
+
+#if defined(linux)
+ /* Per Dave Jones, every effort will be made to keep the
+ * agpgart interface backwards compatible, so allow all
+ * future versions.
+ */
+ if (
+#if (AGPGART_MAJOR_VERSION > 0) /* quiet compiler */
+ agpinf.version.major < AGPGART_MAJOR_VERSION ||
+#endif
+ (agpinf.version.major == AGPGART_MAJOR_VERSION &&
+ agpinf.version.minor < AGPGART_MINOR_VERSION)) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "GARTInit: Kernel agpgart driver version is not current"
+ " (%d.%d vs %d.%d)\n",
+ agpinf.version.major, agpinf.version.minor,
+ AGPGART_MAJOR_VERSION, AGPGART_MINOR_VERSION);
+ close(gartFd);
+ gartFd = -1;
+ return FALSE;
+ }
+#endif
+
+ return TRUE;
+}
+
+Bool
+xf86AgpGARTSupported(void)
+{
+ return GARTInit(-1);
+}
+
+AgpInfoPtr
+xf86GetAGPInfo(int screenNum)
+{
+ struct _agp_info agpinf;
+ AgpInfoPtr info;
+
+ if (!GARTInit(screenNum))
+ return NULL;
+
+ if ((info = calloc(sizeof(AgpInfo), 1)) == NULL) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86GetAGPInfo: Failed to allocate AgpInfo\n");
+ return NULL;
+ }
+
+ memset((char *) &agpinf, 0, sizeof(agpinf));
+
+ if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n",
+ strerror(errno));
+ return NULL;
+ }
+
+ info->bridgeId = agpinf.bridge_id;
+ info->agpMode = agpinf.agp_mode;
+ info->base = agpinf.aper_base;
+ info->size = agpinf.aper_size;
+ info->totalPages = agpinf.pg_total;
+ info->systemPages = agpinf.pg_system;
+ info->usedPages = agpinf.pg_used;
+
+ xf86DrvMsg(screenNum, X_INFO, "Kernel reported %zu total, %zu used\n",
+ agpinf.pg_total, agpinf.pg_used);
+
+ return info;
+}
+
+/*
+ * XXX If multiple screens can acquire the GART, should we have a reference
+ * count instead of using acquiredScreen?
+ */
+
+Bool
+xf86AcquireGART(int screenNum)
+{
+ if (screenNum != -1 && !GARTInit(screenNum))
+ return FALSE;
+
+ if (screenNum == -1 || acquiredScreen != screenNum) {
+ if (ioctl(gartFd, AGPIOC_ACQUIRE, 0) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "xf86AcquireGART: AGPIOC_ACQUIRE failed (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+ acquiredScreen = screenNum;
+ }
+ return TRUE;
+}
+
+Bool
+xf86ReleaseGART(int screenNum)
+{
+ if (screenNum != -1 && !GARTInit(screenNum))
+ return FALSE;
+
+ if (acquiredScreen == screenNum) {
+ /*
+ * The FreeBSD agp driver removes allocations on release.
+ * The Linux driver doesn't. xf86ReleaseGART() is expected
+ * to give up access to the GART, but not to remove any
+ * allocations.
+ */
+#if !defined(linux)
+ if (screenNum == -1)
+#endif
+ {
+ if (ioctl(gartFd, AGPIOC_RELEASE, 0) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "xf86ReleaseGART: AGPIOC_RELEASE failed (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+ acquiredScreen = -1;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+int
+xf86AllocateGARTMemory(int screenNum, unsigned long size, int type,
+ unsigned long *physical)
+{
+ struct _agp_allocate alloc;
+ int pages;
+
+ /*
+ * Allocates "size" bytes of GART memory (rounds up to the next
+ * page multiple) or type "type". A handle (key) for the allocated
+ * memory is returned. On error, the return value is -1.
+ */
+
+ if (!GARTInit(screenNum) || acquiredScreen != screenNum)
+ return -1;
+
+ pages = (size / AGP_PAGE_SIZE);
+ if (size % AGP_PAGE_SIZE != 0)
+ pages++;
+
+ /* XXX check for pages == 0? */
+
+ alloc.pg_count = pages;
+ alloc.type = type;
+
+ if (ioctl(gartFd, AGPIOC_ALLOCATE, &alloc) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86AllocateGARTMemory: "
+ "allocation of %d pages failed\n\t(%s)\n", pages,
+ strerror(errno));
+ return -1;
+ }
+
+ if (physical)
+ *physical = alloc.physical;
+
+ return alloc.key;
+}
+
+Bool
+xf86DeallocateGARTMemory(int screenNum, int key)
+{
+ if (!GARTInit(screenNum) || acquiredScreen != screenNum)
+ return FALSE;
+
+ if (acquiredScreen != screenNum) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86UnbindGARTMemory: AGP not acquired by this screen\n");
+ return FALSE;
+ }
+
+#ifdef __linux__
+ if (ioctl(gartFd, AGPIOC_DEALLOCATE, (int *) (uintptr_t) key) != 0) {
+#else
+ if (ioctl(gartFd, AGPIOC_DEALLOCATE, &key) != 0) {
+#endif
+ xf86DrvMsg(screenNum, X_WARNING, "xf86DeAllocateGARTMemory: "
+ "deallocation gart memory with key %d failed\n\t(%s)\n",
+ key, strerror(errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* Bind GART memory with "key" at "offset" */
+Bool
+xf86BindGARTMemory(int screenNum, int key, unsigned long offset)
+{
+ struct _agp_bind bind;
+ int pageOffset;
+
+ if (!GARTInit(screenNum) || acquiredScreen != screenNum)
+ return FALSE;
+
+ if (acquiredScreen != screenNum) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86BindGARTMemory: AGP not acquired by this screen\n");
+ return FALSE;
+ }
+
+ if (offset % AGP_PAGE_SIZE != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: "
+ "offset (0x%lx) is not page-aligned (%d)\n",
+ offset, AGP_PAGE_SIZE);
+ return FALSE;
+ }
+ pageOffset = offset / AGP_PAGE_SIZE;
+
+ xf86DrvMsgVerb(screenNum, X_INFO, 3,
+ "xf86BindGARTMemory: bind key %d at 0x%08lx "
+ "(pgoffset %d)\n", key, offset, pageOffset);
+
+ bind.pg_start = pageOffset;
+ bind.key = key;
+
+ if (ioctl(gartFd, AGPIOC_BIND, &bind) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: "
+ "binding of gart memory with key %d\n"
+ "\tat offset 0x%lx failed (%s)\n",
+ key, offset, strerror(errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* Unbind GART memory with "key" */
+Bool
+xf86UnbindGARTMemory(int screenNum, int key)
+{
+ struct _agp_unbind unbind;
+
+ if (!GARTInit(screenNum) || acquiredScreen != screenNum)
+ return FALSE;
+
+ if (acquiredScreen != screenNum) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86UnbindGARTMemory: AGP not acquired by this screen\n");
+ return FALSE;
+ }
+
+ unbind.priority = 0;
+ unbind.key = key;
+
+ if (ioctl(gartFd, AGPIOC_UNBIND, &unbind) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86UnbindGARTMemory: "
+ "unbinding of gart memory with key %d "
+ "failed (%s)\n", key, strerror(errno));
+ return FALSE;
+ }
+
+ xf86DrvMsgVerb(screenNum, X_INFO, 3,
+ "xf86UnbindGARTMemory: unbind key %d\n", key);
+
+ return TRUE;
+}
+
+/* XXX Interface may change. */
+Bool
+xf86EnableAGP(int screenNum, CARD32 mode)
+{
+ agp_setup setup;
+
+ if (!GARTInit(screenNum) || acquiredScreen != screenNum)
+ return FALSE;
+
+ setup.agp_mode = mode;
+ if (ioctl(gartFd, AGPIOC_SETUP, &setup) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86EnableAGP: "
+ "AGPIOC_SETUP with mode %ld failed (%s)\n",
+ (unsigned long) mode, strerror(errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_apm.c b/xorg-server/hw/xfree86/os-support/linux/lnx_apm.c
index 54c698965..a37331e52 100644
--- a/xorg-server/hw/xfree86/os-support/linux/lnx_apm.c
+++ b/xorg-server/hw/xfree86/os-support/linux/lnx_apm.c
@@ -23,15 +23,15 @@ extern PMClose lnxACPIOpen(void);
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
-
+
#define APM_PROC "/proc/apm"
#define APM_DEVICE "/dev/apm_bios"
#ifndef APM_STANDBY_FAILED
-# define APM_STANDBY_FAILED 0xf000
+#define APM_STANDBY_FAILED 0xf000
#endif
#ifndef APM_SUSPEND_FAILED
-# define APM_SUSPEND_FAILED 0xf001
+#define APM_SUSPEND_FAILED 0xf001
#endif
static PMClose lnxAPMOpen(void);
@@ -42,23 +42,26 @@ static struct {
apm_event_t apmLinux;
pmEvent xf86;
} LinuxToXF86[] = {
- { APM_SYS_STANDBY, XF86_APM_SYS_STANDBY },
- { APM_SYS_SUSPEND, XF86_APM_SYS_SUSPEND },
- { APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME },
- { APM_CRITICAL_RESUME, XF86_APM_CRITICAL_RESUME },
- { APM_LOW_BATTERY, XF86_APM_LOW_BATTERY },
- { APM_POWER_STATUS_CHANGE, XF86_APM_POWER_STATUS_CHANGE },
- { APM_UPDATE_TIME, XF86_APM_UPDATE_TIME },
- { APM_CRITICAL_SUSPEND, XF86_APM_CRITICAL_SUSPEND },
- { APM_USER_STANDBY, XF86_APM_USER_STANDBY },
- { APM_USER_SUSPEND, XF86_APM_USER_SUSPEND },
- { APM_STANDBY_RESUME, XF86_APM_STANDBY_RESUME },
+ {
+ APM_SYS_STANDBY, XF86_APM_SYS_STANDBY}, {
+ APM_SYS_SUSPEND, XF86_APM_SYS_SUSPEND}, {
+ APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, {
+ APM_CRITICAL_RESUME, XF86_APM_CRITICAL_RESUME}, {
+ APM_LOW_BATTERY, XF86_APM_LOW_BATTERY}, {
+ APM_POWER_STATUS_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, {
+ APM_UPDATE_TIME, XF86_APM_UPDATE_TIME}, {
+ APM_CRITICAL_SUSPEND, XF86_APM_CRITICAL_SUSPEND}, {
+ APM_USER_STANDBY, XF86_APM_USER_STANDBY}, {
+ APM_USER_SUSPEND, XF86_APM_USER_SUSPEND}, {
+ APM_STANDBY_RESUME, XF86_APM_STANDBY_RESUME},
#if defined(APM_CAPABILITY_CHANGED)
- { APM_CAPABILITY_CHANGED, XF86_CAPABILITY_CHANGED },
+ {
+ APM_CAPABILITY_CHANGED, XF86_CAPABILITY_CHANGED},
#endif
#if 0
- { APM_STANDBY_FAILED, XF86_APM_STANDBY_FAILED },
- { APM_SUSPEND_FAILED, XF86_APM_SUSPEND_FAILED }
+ {
+ APM_STANDBY_FAILED, XF86_APM_STANDBY_FAILED}, {
+ APM_SUSPEND_FAILED, XF86_APM_SUSPEND_FAILED}
#endif
};
@@ -73,24 +76,24 @@ static struct {
* event is reasonable.
*/
static int
-lnxPMGetEventFromOs(int fd, pmEvent *events, int num)
+lnxPMGetEventFromOs(int fd, pmEvent * events, int num)
{
- int i,j,n;
+ int i, j, n;
apm_event_t linuxEvents[8];
- if ((n = read( fd, linuxEvents, num * sizeof(apm_event_t) )) == -1)
- return 0;
+ if ((n = read(fd, linuxEvents, num * sizeof(apm_event_t))) == -1)
+ return 0;
n /= sizeof(apm_event_t);
if (n > num)
- n = num;
+ n = num;
for (i = 0; i < n; i++) {
- for (j = 0; j < numApmEvents; j++)
- if (LinuxToXF86[j].apmLinux == linuxEvents[i]) {
- events[i] = LinuxToXF86[j].xf86;
- break;
- }
- if (j == numApmEvents)
- events[i] = XF86_APM_UNKNOWN;
+ for (j = 0; j < numApmEvents; j++)
+ if (LinuxToXF86[j].apmLinux == linuxEvents[i]) {
+ events[i] = LinuxToXF86[j].xf86;
+ break;
+ }
+ if (j == numApmEvents)
+ events[i] = XF86_APM_UNKNOWN;
}
return n;
}
@@ -101,55 +104,55 @@ lnxPMConfirmEventToOs(int fd, pmEvent event)
switch (event) {
case XF86_APM_SYS_STANDBY:
case XF86_APM_USER_STANDBY:
- if (ioctl( fd, APM_IOC_STANDBY, NULL ))
- return PM_FAILED;
- return PM_CONTINUE;
+ if (ioctl(fd, APM_IOC_STANDBY, NULL))
+ return PM_FAILED;
+ return PM_CONTINUE;
case XF86_APM_SYS_SUSPEND:
case XF86_APM_CRITICAL_SUSPEND:
case XF86_APM_USER_SUSPEND:
- if (ioctl( fd, APM_IOC_SUSPEND, NULL )) {
- /* I believe this is wrong (EE)
- EBUSY is sent when a device refuses to be suspended.
- In this case we still need to undo everything we have
- done to suspend ourselves or we will stay in suspended
- state forever. */
- if (errno == EBUSY)
- return PM_CONTINUE;
- else
- return PM_FAILED;
- }
- return PM_CONTINUE;
+ if (ioctl(fd, APM_IOC_SUSPEND, NULL)) {
+ /* I believe this is wrong (EE)
+ EBUSY is sent when a device refuses to be suspended.
+ In this case we still need to undo everything we have
+ done to suspend ourselves or we will stay in suspended
+ state forever. */
+ if (errno == EBUSY)
+ return PM_CONTINUE;
+ else
+ return PM_FAILED;
+ }
+ return PM_CONTINUE;
case XF86_APM_STANDBY_RESUME:
case XF86_APM_NORMAL_RESUME:
case XF86_APM_CRITICAL_RESUME:
case XF86_APM_STANDBY_FAILED:
case XF86_APM_SUSPEND_FAILED:
- return PM_CONTINUE;
+ return PM_CONTINUE;
default:
- return PM_NONE;
+ return PM_NONE;
}
}
-#endif // HAVE_APM
+#endif // HAVE_APM
PMClose
xf86OSPMOpen(void)
{
- PMClose ret = NULL;
+ PMClose ret = NULL;
#ifdef HAVE_ACPI
- /* Favour ACPI over APM, but only when enabled */
+ /* Favour ACPI over APM, but only when enabled */
- if (!xf86acpiDisableFlag)
- ret = lnxACPIOpen();
+ if (!xf86acpiDisableFlag)
+ ret = lnxACPIOpen();
- if (!ret)
+ if (!ret)
#endif
#ifdef HAVE_APM
- ret = lnxAPMOpen();
+ ret = lnxAPMOpen();
#endif
- return ret;
+ return ret;
}
#ifdef HAVE_APM
@@ -157,27 +160,27 @@ xf86OSPMOpen(void)
static PMClose
lnxAPMOpen(void)
{
- int fd, pfd;
+ int fd, pfd;
DebugF("APM: OSPMOpen called\n");
if (APMihPtr || !xf86Info.pmFlag)
- return NULL;
-
+ return NULL;
+
DebugF("APM: Opening device\n");
- if ((fd = open( APM_DEVICE, O_RDWR )) > -1) {
- if (access( APM_PROC, R_OK ) ||
- ((pfd = open( APM_PROC, O_RDONLY)) == -1)) {
- xf86MsgVerb(X_WARNING,3,"Cannot open APM (%s) (%s)\n",
- APM_PROC, strerror(errno));
- close(fd);
- return NULL;
- } else
- close(pfd);
- xf86PMGetEventFromOs = lnxPMGetEventFromOs;
- xf86PMConfirmEventToOs = lnxPMConfirmEventToOs;
- APMihPtr = xf86AddGeneralHandler(fd, xf86HandlePMEvents, NULL);
- xf86MsgVerb(X_INFO,3,"Open APM successful\n");
- return lnxCloseAPM;
+ if ((fd = open(APM_DEVICE, O_RDWR)) > -1) {
+ if (access(APM_PROC, R_OK) || ((pfd = open(APM_PROC, O_RDONLY)) == -1)) {
+ xf86MsgVerb(X_WARNING, 3, "Cannot open APM (%s) (%s)\n",
+ APM_PROC, strerror(errno));
+ close(fd);
+ return NULL;
+ }
+ else
+ close(pfd);
+ xf86PMGetEventFromOs = lnxPMGetEventFromOs;
+ xf86PMConfirmEventToOs = lnxPMConfirmEventToOs;
+ APMihPtr = xf86AddGeneralHandler(fd, xf86HandlePMEvents, NULL);
+ xf86MsgVerb(X_INFO, 3, "Open APM successful\n");
+ return lnxCloseAPM;
}
return NULL;
}
@@ -189,10 +192,10 @@ lnxCloseAPM(void)
DebugF("APM: Closing device\n");
if (APMihPtr) {
- fd = xf86RemoveGeneralHandler(APMihPtr);
- close(fd);
- APMihPtr = NULL;
+ fd = xf86RemoveGeneralHandler(APMihPtr);
+ close(fd);
+ APMihPtr = NULL;
}
}
-#endif // HAVE_APM
+#endif // HAVE_APM
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_axp.c b/xorg-server/hw/xfree86/os-support/linux/lnx_axp.c
index 10fd9e865..d65a3a487 100644
--- a/xorg-server/hw/xfree86/os-support/linux/lnx_axp.c
+++ b/xorg-server/hw/xfree86/os-support/linux/lnx_axp.c
@@ -9,93 +9,95 @@
axpDevice lnxGetAXP(void);
-typedef struct
- { char* sysName;
- char* sysVari;
- char* cpu;
- axpDevice sys; }
-AXP;
+typedef struct {
+ char *sysName;
+ char *sysVari;
+ char *cpu;
+ axpDevice sys;
+} AXP;
static AXP axpList[] = {
- { "Tsunami", NULL, NULL, TSUNAMI },
- { "Eiger", NULL, NULL, TSUNAMI },
- {"Noname", NULL, NULL, LCA },
- { "AlphaBook1", NULL, NULL, LCA },
- {"EB66", NULL, NULL, LCA},
- {"EB64+",NULL,NULL, APECS},
- {"Noritake",NULL,"EV5",CIA},
- {"Noritake",NULL,"EV56",CIA},
- {"Noritake",NULL,NULL,APECS},
- {"XL",NULL,NULL,APECS},
- {"Avanti",NULL,NULL,APECS},
- {"Mikasa",NULL,"EV5",CIA},
- {"Mikasa",NULL,"EV56",CIA},
- {"Mikasa",NULL,NULL,APECS},
- {"EB164","EB164",NULL,CIA},
- {"EB164","PC164", NULL,CIA},
- {"EB164","LX164",NULL, PYXIS},
- {"EB164","SX164",NULL, PYXIS},
- {"EB164","RX164",NULL, POLARIS},
- {"Alcor",NULL,NULL,CIA},
- {"Takara",NULL,NULL,CIA},
- {"Sable",NULL, "EV5",T2_GAMMA},
- {"Sable",NULL,"EV56",T2_GAMMA},
- {"Sable",NULL,NULL,T2},
- {"Rawhide",NULL,NULL,MCPCIA},
- {"Jensen",NULL,NULL,JENSEN},
- {"Miata",NULL,NULL,PYXIS_CIA},
- {"Ruffian",NULL,NULL,PYXIS_CIA},
- {"Nautilus",NULL,NULL,IRONGATE},
- {NULL,NULL,NULL,SYS_NONE}
+ {"Tsunami", NULL, NULL, TSUNAMI},
+ {"Eiger", NULL, NULL, TSUNAMI},
+ {"Noname", NULL, NULL, LCA},
+ {"AlphaBook1", NULL, NULL, LCA},
+ {"EB66", NULL, NULL, LCA},
+ {"EB64+", NULL, NULL, APECS},
+ {"Noritake", NULL, "EV5", CIA},
+ {"Noritake", NULL, "EV56", CIA},
+ {"Noritake", NULL, NULL, APECS},
+ {"XL", NULL, NULL, APECS},
+ {"Avanti", NULL, NULL, APECS},
+ {"Mikasa", NULL, "EV5", CIA},
+ {"Mikasa", NULL, "EV56", CIA},
+ {"Mikasa", NULL, NULL, APECS},
+ {"EB164", "EB164", NULL, CIA},
+ {"EB164", "PC164", NULL, CIA},
+ {"EB164", "LX164", NULL, PYXIS},
+ {"EB164", "SX164", NULL, PYXIS},
+ {"EB164", "RX164", NULL, POLARIS},
+ {"Alcor", NULL, NULL, CIA},
+ {"Takara", NULL, NULL, CIA},
+ {"Sable", NULL, "EV5", T2_GAMMA},
+ {"Sable", NULL, "EV56", T2_GAMMA},
+ {"Sable", NULL, NULL, T2},
+ {"Rawhide", NULL, NULL, MCPCIA},
+ {"Jensen", NULL, NULL, JENSEN},
+ {"Miata", NULL, NULL, PYXIS_CIA},
+ {"Ruffian", NULL, NULL, PYXIS_CIA},
+ {"Nautilus", NULL, NULL, IRONGATE},
+ {NULL, NULL, NULL, SYS_NONE}
};
-
axpDevice
lnxGetAXP(void)
{
- FILE *file;
- int count = 0;
- char res[256];
- char cpu[255];
- char systype[255];
- char sysvari[255];
- if (!(file = fopen("/proc/cpuinfo","r")))
- return SYS_NONE;
- do {
- if (!fgets(res,0xff,file)) return SYS_NONE;
- switch (count) {
- case 1:
- sscanf(res, "cpu model : %s",cpu);
- DebugF("CPU %s\n",cpu);
- break;
- case 5:
- sscanf(res, "system type : %s",systype);
- DebugF("system type : %s\n",systype);
- break;
- case 6:
- sscanf(res, "system variation : %s",sysvari);
- DebugF("system variation: %s\n",sysvari);
- break;
- }
- count++;
- } while (count < 8);
-
- fclose(file);
-
- count = 0;
-
- do {
- if (!axpList[count].sysName || !strcmp(axpList[count].sysName,systype)) {
- if (axpList[count].sysVari && strcmp(axpList[count].sysVari,sysvari)) {
- count++;
- continue;
- };
- if (axpList[count].cpu && strcmp(axpList[count].cpu,cpu)) {
- count++;
- continue;
- }
- return axpList[count].sys;
- }
- count++;
- } while (1);
+ FILE *file;
+ int count = 0;
+ char res[256];
+ char cpu[255];
+ char systype[255];
+ char sysvari[255];
+
+ if (!(file = fopen("/proc/cpuinfo", "r")))
+ return SYS_NONE;
+ do {
+ if (!fgets(res, 0xff, file))
+ return SYS_NONE;
+ switch (count) {
+ case 1:
+ sscanf(res, "cpu model : %s", cpu);
+ DebugF("CPU %s\n", cpu);
+ break;
+ case 5:
+ sscanf(res, "system type : %s", systype);
+ DebugF("system type : %s\n", systype);
+ break;
+ case 6:
+ sscanf(res, "system variation : %s", sysvari);
+ DebugF("system variation: %s\n", sysvari);
+ break;
+ }
+ count++;
+ } while (count < 8);
+
+ fclose(file);
+
+ count = 0;
+
+ do {
+ if (!axpList[count].sysName || !strcmp(axpList[count].sysName, systype)) {
+ if (axpList[count].sysVari &&
+ strcmp(axpList[count].sysVari, sysvari)) {
+ count++;
+ continue;
+ };
+ if (axpList[count].cpu && strcmp(axpList[count].cpu, cpu)) {
+ count++;
+ continue;
+ }
+ return axpList[count].sys;
+ }
+ count++;
+ } while (1);
}
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
index 2176985f9..68c296b0f 100644
--- a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
+++ b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
@@ -43,7 +43,7 @@ static int activeVT = -1;
static char vtname[11];
static struct termios tty_attr; /* tty state to restore */
-static int tty_mode; /* kbd mode to restore */
+static int tty_mode; /* kbd mode to restore */
static void
drain_console(int fd, void *closure)
@@ -61,11 +61,11 @@ switch_to(int vt, const char *from)
SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_ACTIVATE, vt));
if (ret < 0)
- FatalError("%s: VT_ACTIVATE failed: %s\n", from, strerror(errno));
+ FatalError("%s: VT_ACTIVATE failed: %s\n", from, strerror(errno));
SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_WAITACTIVE, vt));
if (ret < 0)
- FatalError("%s: VT_WAITACTIVE failed: %s\n", from, strerror(errno));
+ FatalError("%s: VT_WAITACTIVE failed: %s\n", from, strerror(errno));
}
void
@@ -80,171 +80,169 @@ xf86OpenConsole(void)
if (serverGeneration == 1) {
- /* when KeepTty check if we're run with euid==0 */
- if (KeepTty && geteuid() != 0)
- FatalError("xf86OpenConsole:"
- " Server must be suid root for option \"KeepTTY\"\n");
-
- /*
- * setup the virtual terminal manager
- */
- if (xf86Info.vtno != -1) {
- from = X_CMDLINE;
- } else {
-
- i=0;
- while (tty0[i] != NULL) {
- if ((fd = open(tty0[i],O_WRONLY,0)) >= 0)
- break;
- i++;
- }
-
- if (fd < 0)
- FatalError(
- "xf86OpenConsole: Cannot open /dev/tty0 (%s)\n",
- strerror(errno));
-
- if (xf86Info.ShareVTs)
- {
- SYSCALL(ret = ioctl(fd, VT_GETSTATE, &vts));
- if (ret < 0)
- FatalError("xf86OpenConsole: Cannot find the current"
- " VT (%s)\n", strerror(errno));
+ /* when KeepTty check if we're run with euid==0 */
+ if (KeepTty && geteuid() != 0)
+ FatalError("xf86OpenConsole:"
+ " Server must be suid root for option \"KeepTTY\"\n");
+
+ /*
+ * setup the virtual terminal manager
+ */
+ if (xf86Info.vtno != -1) {
+ from = X_CMDLINE;
+ }
+ else {
+
+ i = 0;
+ while (tty0[i] != NULL) {
+ if ((fd = open(tty0[i], O_WRONLY, 0)) >= 0)
+ break;
+ i++;
+ }
+
+ if (fd < 0)
+ FatalError("xf86OpenConsole: Cannot open /dev/tty0 (%s)\n",
+ strerror(errno));
+
+ if (xf86Info.ShareVTs) {
+ SYSCALL(ret = ioctl(fd, VT_GETSTATE, &vts));
+ if (ret < 0)
+ FatalError("xf86OpenConsole: Cannot find the current"
+ " VT (%s)\n", strerror(errno));
xf86Info.vtno = vts.v_active;
- } else {
- SYSCALL(ret = ioctl(fd, VT_OPENQRY, &xf86Info.vtno));
- if (ret < 0)
- FatalError("xf86OpenConsole: Cannot find a free VT: "
- "%s\n", strerror(errno));
- if (xf86Info.vtno == -1)
- FatalError("xf86OpenConsole: Cannot find a free VT\n");
- }
- close(fd);
- }
-
- xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
-
- if (!KeepTty) {
- pid_t ppid = getppid();
- pid_t ppgid;
- ppgid = getpgid(ppid);
-
- /*
- * change to parent process group that pgid != pid so
- * that setsid() doesn't fail and we become process
- * group leader
- */
- if (setpgid(0,ppgid) < 0)
- xf86Msg(X_WARNING, "xf86OpenConsole: setpgid failed: %s\n",
- strerror(errno));
-
- /* become process group leader */
- if ((setsid() < 0))
- xf86Msg(X_WARNING, "xf86OpenConsole: setsid failed: %s\n",
- strerror(errno));
- }
-
- i=0;
+ }
+ else {
+ SYSCALL(ret = ioctl(fd, VT_OPENQRY, &xf86Info.vtno));
+ if (ret < 0)
+ FatalError("xf86OpenConsole: Cannot find a free VT: "
+ "%s\n", strerror(errno));
+ if (xf86Info.vtno == -1)
+ FatalError("xf86OpenConsole: Cannot find a free VT\n");
+ }
+ close(fd);
+ }
+
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
+
+ if (!KeepTty) {
+ pid_t ppid = getppid();
+ pid_t ppgid;
+
+ ppgid = getpgid(ppid);
+
+ /*
+ * change to parent process group that pgid != pid so
+ * that setsid() doesn't fail and we become process
+ * group leader
+ */
+ if (setpgid(0, ppgid) < 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: setpgid failed: %s\n",
+ strerror(errno));
+
+ /* become process group leader */
+ if ((setsid() < 0))
+ xf86Msg(X_WARNING, "xf86OpenConsole: setsid failed: %s\n",
+ strerror(errno));
+ }
+
+ i = 0;
while (vcs[i] != NULL) {
- snprintf(vtname, sizeof(vtname), vcs[i], xf86Info.vtno); /* /dev/tty1-64 */
- if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) >= 0)
- break;
+ snprintf(vtname, sizeof(vtname), vcs[i], xf86Info.vtno); /* /dev/tty1-64 */
+ if ((xf86Info.consoleFd = open(vtname, O_RDWR | O_NDELAY, 0)) >= 0)
+ break;
i++;
}
- if (xf86Info.consoleFd < 0)
- FatalError("xf86OpenConsole: Cannot open virtual console"
- " %d (%s)\n", xf86Info.vtno, strerror(errno));
-
- /*
- * Linux doesn't switch to an active vt after the last close of a vt,
- * so we do this ourselves by remembering which is active now.
- */
- SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts));
- if (ret < 0)
- xf86Msg(X_WARNING,"xf86OpenConsole: VT_GETSTATE failed: %s\n",
- strerror(errno));
- else
- activeVT = vts.v_active;
+ if (xf86Info.consoleFd < 0)
+ FatalError("xf86OpenConsole: Cannot open virtual console"
+ " %d (%s)\n", xf86Info.vtno, strerror(errno));
+
+ /*
+ * Linux doesn't switch to an active vt after the last close of a vt,
+ * so we do this ourselves by remembering which is active now.
+ */
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts));
+ if (ret < 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_GETSTATE failed: %s\n",
+ strerror(errno));
+ else
+ activeVT = vts.v_active;
#if 0
- if (!KeepTty) {
- /*
- * Detach from the controlling tty to avoid char loss
- */
- if ((i = open("/dev/tty",O_RDWR)) >= 0) {
- SYSCALL(ioctl(i, TIOCNOTTY, 0));
- close(i);
- }
- }
+ if (!KeepTty) {
+ /*
+ * Detach from the controlling tty to avoid char loss
+ */
+ if ((i = open("/dev/tty", O_RDWR)) >= 0) {
+ SYSCALL(ioctl(i, TIOCNOTTY, 0));
+ close(i);
+ }
+ }
#endif
- if (!xf86Info.ShareVTs)
- {
+ if (!xf86Info.ShareVTs) {
struct termios nTty;
- /*
- * now get the VT. This _must_ succeed, or else fail completely.
- */
+ /*
+ * now get the VT. This _must_ succeed, or else fail completely.
+ */
switch_to(xf86Info.vtno, "xf86OpenConsole");
- SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_GETMODE, &VT));
- if (ret < 0)
- FatalError("xf86OpenConsole: VT_GETMODE failed %s\n",
- strerror(errno));
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_GETMODE, &VT));
+ if (ret < 0)
+ FatalError("xf86OpenConsole: VT_GETMODE failed %s\n",
+ strerror(errno));
- signal(SIGUSR1, xf86VTRequest);
+ signal(SIGUSR1, xf86VTRequest);
- VT.mode = VT_PROCESS;
- VT.relsig = SIGUSR1;
- VT.acqsig = SIGUSR1;
+ VT.mode = VT_PROCESS;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
- SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT));
- if (ret < 0)
- FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed: %s\n",
- strerror(errno));
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT));
+ if (ret < 0)
+ FatalError
+ ("xf86OpenConsole: VT_SETMODE VT_PROCESS failed: %s\n",
+ strerror(errno));
- SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS));
- if (ret < 0)
- FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed %s\n",
- strerror(errno));
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS));
+ if (ret < 0)
+ FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed %s\n",
+ strerror(errno));
tcgetattr(xf86Info.consoleFd, &tty_attr);
- SYSCALL(ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode));
+ SYSCALL(ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode));
#ifdef K_OFF
- /* disable kernel special keys and buffering */
- SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_OFF));
- if (ret < 0)
+ /* disable kernel special keys and buffering */
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_OFF));
+ if (ret < 0)
#endif
- {
- SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW));
- if (ret < 0)
- FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n",
- strerror(errno));
+ {
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW));
+ if (ret < 0)
+ FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n",
+ strerror(errno));
- /* need to keep the buffer clean, else the kernel gets angry */
- xf86SetConsoleHandler(drain_console, NULL);
- }
+ /* need to keep the buffer clean, else the kernel gets angry */
+ xf86SetConsoleHandler(drain_console, NULL);
+ }
nTty = tty_attr;
nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
nTty.c_oflag = 0;
nTty.c_cflag = CREAD | CS8;
nTty.c_lflag = 0;
- nTty.c_cc[VTIME]=0;
- nTty.c_cc[VMIN]=1;
+ nTty.c_cc[VTIME] = 0;
+ nTty.c_cc[VMIN] = 1;
cfsetispeed(&nTty, 9600);
cfsetospeed(&nTty, 9600);
tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
-
- /* we really should have a InitOSInputDevices() function instead
- * of Init?$#*&Device(). So I just place it here */
}
- } else { /* serverGeneration != 1 */
- if (!xf86Info.ShareVTs && xf86Info.autoVTSwitch)
- {
- /* now get the VT */
+ }
+ else { /* serverGeneration != 1 */
+ if (!xf86Info.ShareVTs && xf86Info.autoVTSwitch) {
+ /* now get the VT */
switch_to(xf86Info.vtno, "xf86OpenConsole");
}
}
@@ -253,7 +251,7 @@ xf86OpenConsole(void)
void
xf86CloseConsole(void)
{
- struct vt_mode VT;
+ struct vt_mode VT;
int ret;
if (xf86Info.ShareVTs) {
@@ -270,68 +268,64 @@ xf86CloseConsole(void)
/* Back to text mode ... */
SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT));
if (ret < 0)
- xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n",
- strerror(errno));
+ xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n",
+ strerror(errno));
SYSCALL(ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode));
tcsetattr(xf86Info.consoleFd, TCSANOW, &tty_attr);
SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_GETMODE, &VT));
if (ret < 0)
- xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETMODE failed: %s\n",
- strerror(errno));
+ xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETMODE failed: %s\n",
+ strerror(errno));
else {
- /* set dflt vt handling */
- VT.mode = VT_AUTO;
- SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT));
- if (ret < 0)
- xf86Msg(X_WARNING, "xf86CloseConsole: VT_SETMODE failed: %s\n",
- strerror(errno));
+ /* set dflt vt handling */
+ VT.mode = VT_AUTO;
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT));
+ if (ret < 0)
+ xf86Msg(X_WARNING, "xf86CloseConsole: VT_SETMODE failed: %s\n",
+ strerror(errno));
}
- if (xf86Info.autoVTSwitch)
- {
+ if (xf86Info.autoVTSwitch) {
/*
* Perform a switch back to the active VT when we were started
*/
if (activeVT >= 0) {
switch_to(activeVT, "xf86CloseConsole");
- activeVT = -1;
+ activeVT = -1;
}
}
- close(xf86Info.consoleFd); /* make the vt-manager happy */
+ close(xf86Info.consoleFd); /* make the vt-manager happy */
}
int
xf86ProcessArgument(int argc, char *argv[], int i)
{
- /*
- * Keep server from detaching from controlling tty. This is useful
- * when debugging (so the server can receive keyboard signals.
- */
- if (!strcmp(argv[i], "-keeptty"))
- {
- KeepTty = TRUE;
- return 1;
- }
-
- if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
- {
- if (sscanf(argv[i], "vt%2d", &xf86Info.vtno) == 0)
- {
- UseMsg();
- xf86Info.vtno = -1;
- return 0;
- }
- return 1;
- }
- return 0;
+ /*
+ * Keep server from detaching from controlling tty. This is useful
+ * when debugging (so the server can receive keyboard signals.
+ */
+ if (!strcmp(argv[i], "-keeptty")) {
+ KeepTty = TRUE;
+ return 1;
+ }
+
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't')) {
+ if (sscanf(argv[i], "vt%2d", &xf86Info.vtno) == 0) {
+ UseMsg();
+ xf86Info.vtno = -1;
+ return 0;
+ }
+ return 1;
+ }
+ return 0;
}
void
xf86UseMsg(void)
{
- ErrorF("vtXX use the specified VT number\n");
- ErrorF("-keeptty ");
- ErrorF("don't detach controlling tty (for debugging only)\n");
+ ErrorF("vtXX use the specified VT number\n");
+ ErrorF("-keeptty ");
+ ErrorF("don't detach controlling tty (for debugging only)\n");
}
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_video.c b/xorg-server/hw/xfree86/os-support/linux/lnx_video.c
index 0d91f7a52..3526a21d4 100644
--- a/xorg-server/hw/xfree86/os-support/linux/lnx_video.c
+++ b/xorg-server/hw/xfree86/os-support/linux/lnx_video.c
@@ -70,10 +70,10 @@ extern int iopl(int __level);
#endif
#ifdef __alpha__
-# define BUS_BASE bus_base
-#else
+#define BUS_BASE bus_base
+#else
#define BUS_BASE (0)
-#endif /* __alpha__ */
+#endif /* __alpha__ */
/***************************************************************************/
/* Video Memory Mapping section */
@@ -81,10 +81,11 @@ extern int iopl(int __level);
static pointer mapVidMem(int, unsigned long, unsigned long, int);
static void unmapVidMem(int, pointer, unsigned long);
-#if defined (__alpha__)
+
+#if defined (__alpha__)
extern void sethae(unsigned long hae);
-extern unsigned long _bus_base __P ((void)) __attribute__ ((const));
-extern unsigned long _bus_base_sparse __P ((void)) __attribute__ ((const));
+extern unsigned long _bus_base __P((void)) __attribute__ ((const));
+extern unsigned long _bus_base_sparse __P((void)) __attribute__ ((const));
static pointer mapVidMemSparse(int, unsigned long, unsigned long, int);
extern axpDevice lnxGetAXP(void);
@@ -105,9 +106,9 @@ static void undoWC(int, pointer);
/* The file desc for /proc/mtrr. Once opened, left opened, and the mtrr
driver will clean up when we exit. */
-#define MTRR_FD_UNOPENED (-1) /* We have yet to open /proc/mtrr */
-#define MTRR_FD_PROBLEM (-2) /* We tried to open /proc/mtrr, but had
- a problem. */
+#define MTRR_FD_UNOPENED (-1) /* We have yet to open /proc/mtrr */
+#define MTRR_FD_PROBLEM (-2) /* We tried to open /proc/mtrr, but had
+ a problem. */
static int mtrr_fd = MTRR_FD_UNOPENED;
/* Open /proc/mtrr. FALSE on failure. Will always fail on Linux 2.0,
@@ -116,29 +117,29 @@ static int mtrr_fd = MTRR_FD_UNOPENED;
static Bool
mtrr_open(int verbosity)
{
- /* Only report absence of /proc/mtrr once. */
- static Bool warned = FALSE;
-
- if (mtrr_fd == MTRR_FD_UNOPENED) {
- mtrr_fd = open("/proc/mtrr", O_WRONLY);
-
- if (mtrr_fd < 0)
- mtrr_fd = MTRR_FD_PROBLEM;
- }
-
- if (mtrr_fd == MTRR_FD_PROBLEM) {
- /* To make sure we only ever warn once, need to check
- verbosity outside xf86MsgVerb */
- if (!warned && verbosity <= xf86GetVerbosity()) {
- xf86MsgVerb(X_WARNING, verbosity,
- "System lacks support for changing MTRRs\n");
- warned = TRUE;
- }
-
- return FALSE;
- }
- else
- return TRUE;
+ /* Only report absence of /proc/mtrr once. */
+ static Bool warned = FALSE;
+
+ if (mtrr_fd == MTRR_FD_UNOPENED) {
+ mtrr_fd = open("/proc/mtrr", O_WRONLY);
+
+ if (mtrr_fd < 0)
+ mtrr_fd = MTRR_FD_PROBLEM;
+ }
+
+ if (mtrr_fd == MTRR_FD_PROBLEM) {
+ /* To make sure we only ever warn once, need to check
+ verbosity outside xf86MsgVerb */
+ if (!warned && verbosity <= xf86GetVerbosity()) {
+ xf86MsgVerb(X_WARNING, verbosity,
+ "System lacks support for changing MTRRs\n");
+ warned = TRUE;
+ }
+
+ return FALSE;
+ }
+ else
+ return TRUE;
}
/*
@@ -147,260 +148,257 @@ mtrr_open(int verbosity)
*/
struct mtrr_wc_region {
- struct mtrr_sentry sentry;
- Bool added; /* added WC or removed it */
- struct mtrr_wc_region * next;
+ struct mtrr_sentry sentry;
+ Bool added; /* added WC or removed it */
+ struct mtrr_wc_region *next;
};
-
static struct mtrr_wc_region *
mtrr_cull_wc_region(int screenNum, unsigned long base, unsigned long size,
- MessageType from)
+ MessageType from)
{
- /* Some BIOS writers thought that setting wc over the mmio
- region of a graphics devices was a good idea. Try to fix
- it. */
-
- struct mtrr_gentry gent;
- struct mtrr_wc_region *wcreturn = NULL, *wcr;
- int count, ret=0;
-
- /* Linux 2.0 users should not get a warning without -verbose */
- if (!mtrr_open(2))
- return NULL;
-
- for (gent.regnum = 0;
- ioctl(mtrr_fd, MTRRIOC_GET_ENTRY, &gent) >= 0;
- gent.regnum++) {
- if (gent.type != MTRR_TYPE_WRCOMB
- || gent.base + gent.size <= base
- || base + size <= gent.base)
- continue;
-
- /* Found an overlapping region. Delete it. */
-
- wcr = malloc(sizeof(*wcr));
- if (!wcr)
- return NULL;
- wcr->sentry.base = gent.base;
- wcr->sentry.size = gent.size;
- wcr->sentry.type = MTRR_TYPE_WRCOMB;
- wcr->added = FALSE;
-
- count = 3;
- while (count-- &&
- (ret = ioctl(mtrr_fd, MTRRIOC_KILL_ENTRY, &(wcr->sentry))) < 0);
-
- if (ret >= 0) {
- xf86DrvMsg(screenNum, from,
- "Removed MMIO write-combining range "
- "(0x%lx,0x%lx)\n",
- (unsigned long) gent.base, (unsigned long) gent.size);
- wcr->next = wcreturn;
- wcreturn = wcr;
- gent.regnum--;
- } else {
- free(wcr);
- xf86DrvMsgVerb(screenNum, X_WARNING, 0,
- "Failed to remove MMIO "
- "write-combining range (0x%lx,0x%lx)\n",
- gent.base, (unsigned long) gent.size);
- }
- }
- return wcreturn;
-}
+ /* Some BIOS writers thought that setting wc over the mmio
+ region of a graphics devices was a good idea. Try to fix
+ it. */
+ struct mtrr_gentry gent;
+ struct mtrr_wc_region *wcreturn = NULL, *wcr;
+ int count, ret = 0;
+
+ /* Linux 2.0 users should not get a warning without -verbose */
+ if (!mtrr_open(2))
+ return NULL;
+
+ for (gent.regnum = 0;
+ ioctl(mtrr_fd, MTRRIOC_GET_ENTRY, &gent) >= 0; gent.regnum++) {
+ if (gent.type != MTRR_TYPE_WRCOMB
+ || gent.base + gent.size <= base || base + size <= gent.base)
+ continue;
+
+ /* Found an overlapping region. Delete it. */
+
+ wcr = malloc(sizeof(*wcr));
+ if (!wcr)
+ return NULL;
+ wcr->sentry.base = gent.base;
+ wcr->sentry.size = gent.size;
+ wcr->sentry.type = MTRR_TYPE_WRCOMB;
+ wcr->added = FALSE;
+
+ count = 3;
+ while (count-- &&
+ (ret = ioctl(mtrr_fd, MTRRIOC_KILL_ENTRY, &(wcr->sentry))) < 0);
+
+ if (ret >= 0) {
+ xf86DrvMsg(screenNum, from,
+ "Removed MMIO write-combining range "
+ "(0x%lx,0x%lx)\n",
+ (unsigned long) gent.base, (unsigned long) gent.size);
+ wcr->next = wcreturn;
+ wcreturn = wcr;
+ gent.regnum--;
+ }
+ else {
+ free(wcr);
+ xf86DrvMsgVerb(screenNum, X_WARNING, 0,
+ "Failed to remove MMIO "
+ "write-combining range (0x%lx,0x%lx)\n",
+ gent.base, (unsigned long) gent.size);
+ }
+ }
+ return wcreturn;
+}
static struct mtrr_wc_region *
mtrr_remove_offending(int screenNum, unsigned long base, unsigned long size,
- MessageType from)
+ MessageType from)
{
struct mtrr_gentry gent;
struct mtrr_wc_region *wcreturn = NULL, **wcr;
if (!mtrr_open(2))
- return NULL;
+ return NULL;
wcr = &wcreturn;
- for (gent.regnum = 0;
- ioctl(mtrr_fd, MTRRIOC_GET_ENTRY, &gent) >= 0; gent.regnum++ ) {
- if (gent.type == MTRR_TYPE_WRCOMB
- && ((gent.base >= base && gent.base + gent.size < base + size) ||
- (gent.base > base && gent.base + gent.size <= base + size))) {
- *wcr = mtrr_cull_wc_region(screenNum, gent.base, gent.size, from);
- if (*wcr) gent.regnum--;
- while(*wcr) {
- wcr = &((*wcr)->next);
- }
- }
+ for (gent.regnum = 0;
+ ioctl(mtrr_fd, MTRRIOC_GET_ENTRY, &gent) >= 0; gent.regnum++) {
+ if (gent.type == MTRR_TYPE_WRCOMB
+ && ((gent.base >= base && gent.base + gent.size < base + size) ||
+ (gent.base > base && gent.base + gent.size <= base + size))) {
+ *wcr = mtrr_cull_wc_region(screenNum, gent.base, gent.size, from);
+ if (*wcr)
+ gent.regnum--;
+ while (*wcr) {
+ wcr = &((*wcr)->next);
+ }
+ }
}
return wcreturn;
}
-
static struct mtrr_wc_region *
mtrr_add_wc_region(int screenNum, unsigned long base, unsigned long size,
- MessageType from)
+ MessageType from)
{
- struct mtrr_wc_region **wcr, *wcreturn, *curwcr;
+ struct mtrr_wc_region **wcr, *wcreturn, *curwcr;
- /*
- * There can be only one....
- */
+ /*
+ * There can be only one....
+ */
- wcreturn = mtrr_remove_offending(screenNum, base, size, from);
- wcr = &wcreturn;
- while (*wcr) {
- wcr = &((*wcr)->next);
- }
+ wcreturn = mtrr_remove_offending(screenNum, base, size, from);
+ wcr = &wcreturn;
+ while (*wcr) {
+ wcr = &((*wcr)->next);
+ }
- /* Linux 2.0 should not warn, unless the user explicitly asks for
- WC. */
+ /* Linux 2.0 should not warn, unless the user explicitly asks for
+ WC. */
- if (!mtrr_open(from == X_CONFIG ? 0 : 2))
- return wcreturn;
+ if (!mtrr_open(from == X_CONFIG ? 0 : 2))
+ return wcreturn;
- *wcr = curwcr = malloc(sizeof(**wcr));
- if (!curwcr)
- return wcreturn;
+ *wcr = curwcr = malloc(sizeof(**wcr));
+ if (!curwcr)
+ return wcreturn;
- curwcr->sentry.base = base;
- curwcr->sentry.size = size;
- curwcr->sentry.type = MTRR_TYPE_WRCOMB;
- curwcr->added = TRUE;
- curwcr->next = NULL;
+ curwcr->sentry.base = base;
+ curwcr->sentry.size = size;
+ curwcr->sentry.type = MTRR_TYPE_WRCOMB;
+ curwcr->added = TRUE;
+ curwcr->next = NULL;
#if SPLIT_WC_REGIONS
- /*
- * Splits up the write-combining region if it is not aligned on a
- * size boundary.
- */
-
- {
- unsigned long lbase, d_size = 1;
- unsigned long n_size = size;
- unsigned long n_base = base;
-
- for (lbase = n_base, d_size = 1; !(lbase & 1);
- lbase = lbase >> 1, d_size <<= 1);
- while (d_size > n_size)
- d_size = d_size >> 1;
- DebugF("WC_BASE: 0x%lx WC_END: 0x%lx\n",base,base+d_size-1);
- n_base += d_size;
- n_size -= d_size;
- if (n_size) {
- xf86DrvMsgVerb(screenNum,X_INFO,3,"Splitting WC range: "
- "base: 0x%lx, size: 0x%lx\n",base,size);
- curwcr->next = mtrr_add_wc_region(screenNum, n_base, n_size,from);
- }
- curwcr->sentry.size = d_size;
- }
-
- /*****************************************************************/
-#endif /* SPLIT_WC_REGIONS */
-
- if (ioctl(mtrr_fd, MTRRIOC_ADD_ENTRY, &curwcr->sentry) >= 0) {
- /* Avoid printing on every VT switch */
- if (xf86ServerIsInitialising()) {
- xf86DrvMsg(screenNum, from,
- "Write-combining range (0x%lx,0x%lx)\n",
- base, size);
- }
- return wcreturn;
- }
- else {
- *wcr = curwcr->next;
- free(curwcr);
-
- /* Don't complain about the VGA region: MTRR fixed
- regions aren't currently supported, but might be in
- the future. */
- if ((unsigned long)base >= 0x100000) {
- xf86DrvMsgVerb(screenNum, X_WARNING, 0,
- "Failed to set up write-combining range "
- "(0x%lx,0x%lx)\n", base, size);
- }
- return wcreturn;
- }
+ /*
+ * Splits up the write-combining region if it is not aligned on a
+ * size boundary.
+ */
+
+ {
+ unsigned long lbase, d_size = 1;
+ unsigned long n_size = size;
+ unsigned long n_base = base;
+
+ for (lbase = n_base, d_size = 1; !(lbase & 1);
+ lbase = lbase >> 1, d_size <<= 1);
+ while (d_size > n_size)
+ d_size = d_size >> 1;
+ DebugF("WC_BASE: 0x%lx WC_END: 0x%lx\n", base, base + d_size - 1);
+ n_base += d_size;
+ n_size -= d_size;
+ if (n_size) {
+ xf86DrvMsgVerb(screenNum, X_INFO, 3, "Splitting WC range: "
+ "base: 0x%lx, size: 0x%lx\n", base, size);
+ curwcr->next = mtrr_add_wc_region(screenNum, n_base, n_size, from);
+ }
+ curwcr->sentry.size = d_size;
+ }
+
+ /*****************************************************************/
+#endif /* SPLIT_WC_REGIONS */
+
+ if (ioctl(mtrr_fd, MTRRIOC_ADD_ENTRY, &curwcr->sentry) >= 0) {
+ /* Avoid printing on every VT switch */
+ if (xf86ServerIsInitialising()) {
+ xf86DrvMsg(screenNum, from,
+ "Write-combining range (0x%lx,0x%lx)\n", base, size);
+ }
+ return wcreturn;
+ }
+ else {
+ *wcr = curwcr->next;
+ free(curwcr);
+
+ /* Don't complain about the VGA region: MTRR fixed
+ regions aren't currently supported, but might be in
+ the future. */
+ if ((unsigned long) base >= 0x100000) {
+ xf86DrvMsgVerb(screenNum, X_WARNING, 0,
+ "Failed to set up write-combining range "
+ "(0x%lx,0x%lx)\n", base, size);
+ }
+ return wcreturn;
+ }
}
static void
mtrr_undo_wc_region(int screenNum, struct mtrr_wc_region *wcr)
{
- struct mtrr_wc_region *p, *prev;
-
- if (mtrr_fd >= 0) {
- p = wcr;
- while (p) {
- if (p->added)
- ioctl(mtrr_fd, MTRRIOC_DEL_ENTRY, &p->sentry);
- prev = p;
- p = p->next;
- free(prev);
- }
- }
+ struct mtrr_wc_region *p, *prev;
+
+ if (mtrr_fd >= 0) {
+ p = wcr;
+ while (p) {
+ if (p->added)
+ ioctl(mtrr_fd, MTRRIOC_DEL_ENTRY, &p->sentry);
+ prev = p;
+ p = p->next;
+ free(prev);
+ }
+ }
}
static pointer
setWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
MessageType from)
{
- if (enable)
- return mtrr_add_wc_region(screenNum, base, size, from);
- else
- return mtrr_cull_wc_region(screenNum, base, size, from);
+ if (enable)
+ return mtrr_add_wc_region(screenNum, base, size, from);
+ else
+ return mtrr_cull_wc_region(screenNum, base, size, from);
}
static void
undoWC(int screenNum, pointer regioninfo)
{
- mtrr_undo_wc_region(screenNum, regioninfo);
+ mtrr_undo_wc_region(screenNum, regioninfo);
}
-#endif /* HAS_MTRR_SUPPORT */
+#endif /* HAS_MTRR_SUPPORT */
void
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
- pVidMem->linearSupported = TRUE;
+ pVidMem->linearSupported = TRUE;
#ifdef __alpha__
- if (axpSystem == -1) {
- axpSystem = lnxGetAXP();
- if ((needSparse = (_bus_base_sparse() > 0))) {
- hae_thresh = xf86AXPParams[axpSystem].hae_thresh;
- hae_mask = xf86AXPParams[axpSystem].hae_mask;
- }
- bus_base = _bus_base();
- }
- if (needSparse) {
- xf86Msg(X_INFO,"Machine needs sparse mapping\n");
- pVidMem->mapMem = mapVidMemSparse;
- pVidMem->unmapMem = unmapVidMemSparse;
- } else {
- xf86Msg(X_INFO,"Machine type has 8/16 bit access\n");
- pVidMem->mapMem = mapVidMem;
- pVidMem->unmapMem = unmapVidMem;
- }
+ if (axpSystem == -1) {
+ axpSystem = lnxGetAXP();
+ if ((needSparse = (_bus_base_sparse() > 0))) {
+ hae_thresh = xf86AXPParams[axpSystem].hae_thresh;
+ hae_mask = xf86AXPParams[axpSystem].hae_mask;
+ }
+ bus_base = _bus_base();
+ }
+ if (needSparse) {
+ xf86Msg(X_INFO, "Machine needs sparse mapping\n");
+ pVidMem->mapMem = mapVidMemSparse;
+ pVidMem->unmapMem = unmapVidMemSparse;
+ }
+ else {
+ xf86Msg(X_INFO, "Machine type has 8/16 bit access\n");
+ pVidMem->mapMem = mapVidMem;
+ pVidMem->unmapMem = unmapVidMem;
+ }
#else
- pVidMem->mapMem = mapVidMem;
- pVidMem->unmapMem = unmapVidMem;
-#endif /* __alpha__ */
-
+ pVidMem->mapMem = mapVidMem;
+ pVidMem->unmapMem = unmapVidMem;
+#endif /* __alpha__ */
#ifdef HAS_MTRR_SUPPORT
- pVidMem->setWC = setWC;
- pVidMem->undoWC = undoWC;
+ pVidMem->setWC = setWC;
+ pVidMem->undoWC = undoWC;
#endif
- pVidMem->initialised = TRUE;
+ pVidMem->initialised = TRUE;
}
#ifdef __sparc__
/* Basically, you simply cannot do this on Sparc. You have to do something portable
* like use /dev/fb* or mmap() on /proc/bus/pci/X/Y nodes. -DaveM
*/
-static pointer mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+static pointer
+mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
{
- return NULL;
+ return NULL;
}
#else
static pointer
@@ -408,14 +406,14 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
{
pointer base;
int fd;
- int mapflags = MAP_SHARED;
+ int mapflags = MAP_SHARED;
int prot;
memType realBase, alignOff;
realBase = Base & ~(getpagesize() - 1);
alignOff = Base - realBase;
DebugF("base: %lx, realBase: %lx, alignOff: %lx \n",
- Base,realBase,alignOff);
+ Base, realBase, alignOff);
#if defined(__ia64__) || defined(__arm__) || defined(__s390__)
#ifndef MAP_WRITECOMBINED
@@ -424,55 +422,52 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
#ifndef MAP_NONCACHED
#define MAP_NONCACHED 0x00020000
#endif
- if(flags & VIDMEM_FRAMEBUFFER)
- mapflags |= MAP_WRITECOMBINED;
+ if (flags & VIDMEM_FRAMEBUFFER)
+ mapflags |= MAP_WRITECOMBINED;
else
- mapflags |= MAP_NONCACHED;
+ mapflags |= MAP_NONCACHED;
#endif
#if 0
/* this will disappear when people upgrade their kernels */
fd = open(DEV_MEM,
- ((flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR) | O_SYNC);
+ ((flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR) | O_SYNC);
#else
fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
#endif
- if (fd < 0)
- {
- FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n",
- strerror(errno));
+ if (fd < 0) {
+ FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n",
+ strerror(errno));
}
if (flags & VIDMEM_READONLY)
- prot = PROT_READ;
+ prot = PROT_READ;
else
- prot = PROT_READ | PROT_WRITE;
+ prot = PROT_READ | PROT_WRITE;
/* This requires linux-0.99.pl10 or above */
- base = mmap((caddr_t)0, Size + alignOff, prot, mapflags, fd,
- (off_t)realBase + BUS_BASE);
+ base = mmap((caddr_t) 0, Size + alignOff, prot, mapflags, fd,
+ (off_t) realBase + BUS_BASE);
close(fd);
if (base == MAP_FAILED) {
FatalError("xf86MapVidMem: Could not mmap framebuffer"
- " (0x%08lx,0x%lx) (%s)\n", Base, Size,
- strerror(errno));
+ " (0x%08lx,0x%lx) (%s)\n", Base, Size, strerror(errno));
}
- DebugF("base: %lx aligned base: %lx\n",base, (char *)base + alignOff);
- return (char *)base + alignOff;
+ DebugF("base: %lx aligned base: %lx\n", base, (char *) base + alignOff);
+ return (char *) base + alignOff;
}
-#endif /* !(__sparc__) */
-
+#endif /* !(__sparc__) */
+
static void
unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
{
- uintptr_t alignOff = (uintptr_t)Base
- - ((uintptr_t)Base & ~(getpagesize() - 1));
+ uintptr_t alignOff = (uintptr_t) Base
+ - ((uintptr_t) Base & ~(getpagesize() - 1));
- DebugF("alignment offset: %lx\n", (unsigned long)alignOff);
- munmap((void *)((uintptr_t)Base - alignOff), (Size + alignOff));
+ DebugF("alignment offset: %lx\n", (unsigned long) alignOff);
+ munmap((void *) ((uintptr_t) Base - alignOff), (Size + alignOff));
}
-
/***************************************************************************/
/* I/O Permissions section */
/***************************************************************************/
@@ -490,68 +485,68 @@ Bool
xf86EnableIO(void)
{
#if defined(__powerpc__)
- int fd;
- unsigned int ioBase_phys;
+ int fd;
+ unsigned int ioBase_phys;
#endif
- if (ExtendedEnabled)
- return TRUE;
+ if (ExtendedEnabled)
+ return TRUE;
#if defined(__powerpc__)
- ioBase_phys = syscall(__NR_pciconfig_iobase, 2, 0, 0);
+ ioBase_phys = syscall(__NR_pciconfig_iobase, 2, 0, 0);
- fd = open("/dev/mem", O_RDWR);
- if (ioBase == NULL) {
- ioBase = (volatile unsigned char *)mmap(0, 0x20000,
- PROT_READ | PROT_WRITE, MAP_SHARED, fd,
- ioBase_phys);
+ fd = open("/dev/mem", O_RDWR);
+ if (ioBase == NULL) {
+ ioBase = (volatile unsigned char *) mmap(0, 0x20000,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, ioBase_phys);
/* Should this be fatal or just a warning? */
#if 0
- if (ioBase == MAP_FAILED) {
- xf86Msg(X_WARNING,
- "xf86EnableIOPorts: Failed to map iobase (%s)\n",
- strerror(errno));
- return FALSE;
- }
+ if (ioBase == MAP_FAILED) {
+ xf86Msg(X_WARNING,
+ "xf86EnableIOPorts: Failed to map iobase (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
#endif
- }
- close(fd);
+ }
+ close(fd);
#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__arm__) && !defined(__m32r__) && !defined(__nds32__)
- if (ioperm(0, 1024, 1) || iopl(3)) {
- if (errno == ENODEV)
- ErrorF("xf86EnableIOPorts: no I/O ports found\n");
- else
- FatalError("xf86EnableIOPorts: failed to set IOPL"
- " for I/O (%s)\n", strerror(errno));
- return FALSE;
- }
-# if !defined(__alpha__)
- /* XXX: this is actually not trapping anything because of iopl(3)
- * above */
- ioperm(0x40,4,0); /* trap access to the timer chip */
- ioperm(0x60,4,0); /* trap access to the keyboard controller */
-# endif
+ if (ioperm(0, 1024, 1) || iopl(3)) {
+ if (errno == ENODEV)
+ ErrorF("xf86EnableIOPorts: no I/O ports found\n");
+ else
+ FatalError("xf86EnableIOPorts: failed to set IOPL"
+ " for I/O (%s)\n", strerror(errno));
+ return FALSE;
+ }
+#if !defined(__alpha__)
+ /* XXX: this is actually not trapping anything because of iopl(3)
+ * above */
+ ioperm(0x40, 4, 0); /* trap access to the timer chip */
+ ioperm(0x60, 4, 0); /* trap access to the keyboard controller */
+#endif
#endif
- ExtendedEnabled = TRUE;
+ ExtendedEnabled = TRUE;
- return TRUE;
+ return TRUE;
}
void
xf86DisableIO(void)
{
- if (!ExtendedEnabled)
- return;
+ if (!ExtendedEnabled)
+ return;
#if defined(__powerpc__)
- munmap(ioBase, 0x20000);
- ioBase = NULL;
+ munmap(ioBase, 0x20000);
+ ioBase = NULL;
#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__arm__) && !defined(__s390__) && !defined(__m32r__) && !defined(__nds32__)
- iopl(0);
- ioperm(0, 1024, 0);
+ iopl(0);
+ ioperm(0, 1024, 0);
#endif
- ExtendedEnabled = FALSE;
+ ExtendedEnabled = FALSE;
- return;
+ return;
}
#if defined (__alpha__)
@@ -562,33 +557,33 @@ extern int readDense8(pointer Base, register unsigned long Offset);
extern int readDense16(pointer Base, register unsigned long Offset);
extern int readDense32(pointer Base, register unsigned long Offset);
extern void
-writeDenseNB8(int Value, pointer Base, register unsigned long Offset);
+ writeDenseNB8(int Value, pointer Base, register unsigned long Offset);
extern void
-writeDenseNB16(int Value, pointer Base, register unsigned long Offset);
+ writeDenseNB16(int Value, pointer Base, register unsigned long Offset);
extern void
-writeDenseNB32(int Value, pointer Base, register unsigned long Offset);
+ writeDenseNB32(int Value, pointer Base, register unsigned long Offset);
extern void
-writeDense8(int Value, pointer Base, register unsigned long Offset);
+ writeDense8(int Value, pointer Base, register unsigned long Offset);
extern void
-writeDense16(int Value, pointer Base, register unsigned long Offset);
+ writeDense16(int Value, pointer Base, register unsigned long Offset);
extern void
-writeDense32(int Value, pointer Base, register unsigned long Offset);
+ writeDense32(int Value, pointer Base, register unsigned long Offset);
static int readSparse8(pointer Base, register unsigned long Offset);
static int readSparse16(pointer Base, register unsigned long Offset);
static int readSparse32(pointer Base, register unsigned long Offset);
static void
-writeSparseNB8(int Value, pointer Base, register unsigned long Offset);
+ writeSparseNB8(int Value, pointer Base, register unsigned long Offset);
static void
-writeSparseNB16(int Value, pointer Base, register unsigned long Offset);
+ writeSparseNB16(int Value, pointer Base, register unsigned long Offset);
static void
-writeSparseNB32(int Value, pointer Base, register unsigned long Offset);
+ writeSparseNB32(int Value, pointer Base, register unsigned long Offset);
static void
-writeSparse8(int Value, pointer Base, register unsigned long Offset);
+ writeSparse8(int Value, pointer Base, register unsigned long Offset);
static void
-writeSparse16(int Value, pointer Base, register unsigned long Offset);
+ writeSparse16(int Value, pointer Base, register unsigned long Offset);
static void
-writeSparse32(int Value, pointer Base, register unsigned long Offset);
+ writeSparse32(int Value, pointer Base, register unsigned long Offset);
#define DENSE_BASE 0x2ff00000000UL
#define SPARSE_BASE 0x30000000000UL
@@ -596,7 +591,8 @@ writeSparse32(int Value, pointer Base, register unsigned long Offset);
static unsigned long msb_set = 0;
static pointer
-mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size,
+ int flags)
{
int fd, prot;
unsigned long ret, rets = 0;
@@ -604,43 +600,42 @@ mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags
static Bool was_here = FALSE;
if (!was_here) {
- was_here = TRUE;
-
- xf86WriteMmio8 = writeSparse8;
- xf86WriteMmio16 = writeSparse16;
- xf86WriteMmio32 = writeSparse32;
- xf86WriteMmioNB8 = writeSparseNB8;
- xf86WriteMmioNB16 = writeSparseNB16;
- xf86WriteMmioNB32 = writeSparseNB32;
- xf86ReadMmio8 = readSparse8;
- xf86ReadMmio16 = readSparse16;
- xf86ReadMmio32 = readSparse32;
+ was_here = TRUE;
+
+ xf86WriteMmio8 = writeSparse8;
+ xf86WriteMmio16 = writeSparse16;
+ xf86WriteMmio32 = writeSparse32;
+ xf86WriteMmioNB8 = writeSparseNB8;
+ xf86WriteMmioNB16 = writeSparseNB16;
+ xf86WriteMmioNB32 = writeSparseNB32;
+ xf86ReadMmio8 = readSparse8;
+ xf86ReadMmio16 = readSparse16;
+ xf86ReadMmio32 = readSparse32;
}
-
+
fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
if (fd < 0) {
FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n",
- strerror(errno));
+ strerror(errno));
}
#if 0
- xf86Msg(X_INFO,"mapVidMemSparse: try Base 0x%lx size 0x%lx flags 0x%x\n",
- Base, Size, flags);
+ xf86Msg(X_INFO, "mapVidMemSparse: try Base 0x%lx size 0x%lx flags 0x%x\n",
+ Base, Size, flags);
#endif
if (flags & VIDMEM_READONLY)
- prot = PROT_READ;
+ prot = PROT_READ;
else
- prot = PROT_READ | PROT_WRITE;
+ prot = PROT_READ | PROT_WRITE;
/* This requirers linux-0.99.pl10 or above */
/*
* Always do DENSE mmap, since read32/write32 currently require it.
*/
- ret = (unsigned long)mmap((caddr_t)(DENSE_BASE + Base), Size,
- prot, MAP_SHARED, fd,
- (off_t) (bus_base + Base));
+ ret = (unsigned long) mmap((caddr_t) (DENSE_BASE + Base), Size,
+ prot, MAP_SHARED, fd, (off_t) (bus_base + Base));
/*
* Do SPARSE mmap only when MMIO and not MMIO_32BIT, or FRAMEBUFFER
@@ -650,40 +645,36 @@ mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags
* bytes worth of pagetable (32 pages).
*/
if (((flags & VIDMEM_MMIO) && !(flags & VIDMEM_MMIO_32BIT)) ||
- ((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE)))
- {
- rets = (unsigned long)mmap((caddr_t)(SPARSE_BASE + (Base << 5)),
- Size << 5, prot, MAP_SHARED, fd,
- (off_t) _bus_base_sparse() + (Base << 5));
+ ((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE))) {
+ rets = (unsigned long) mmap((caddr_t) (SPARSE_BASE + (Base << 5)),
+ Size << 5, prot, MAP_SHARED, fd,
+ (off_t) _bus_base_sparse() + (Base << 5));
}
close(fd);
-
- if (ret == (unsigned long)MAP_FAILED) {
+
+ if (ret == (unsigned long) MAP_FAILED) {
FatalError("xf86MapVidMemSparse: Could not (dense) mmap fb (%s)\n",
- strerror(errno));
+ strerror(errno));
}
if (((flags & VIDMEM_MMIO) && !(flags & VIDMEM_MMIO_32BIT)) ||
- ((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE)))
- {
- if (rets == (unsigned long)MAP_FAILED ||
- rets != (SPARSE_BASE + (Base << 5)))
- {
- FatalError("mapVidMemSparse: Could not (sparse) mmap fb (%s)\n",
- strerror(errno));
- }
+ ((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE))) {
+ if (rets == (unsigned long) MAP_FAILED ||
+ rets != (SPARSE_BASE + (Base << 5))) {
+ FatalError("mapVidMemSparse: Could not (sparse) mmap fb (%s)\n",
+ strerror(errno));
+ }
}
#if 1
if (rets)
- xf86Msg(X_INFO,"mapVidMemSparse: mapped Base 0x%lx size 0x%lx"
- " to DENSE at 0x%lx and SPARSE at 0x%lx\n",
- Base, Size, ret, rets);
+ xf86Msg(X_INFO, "mapVidMemSparse: mapped Base 0x%lx size 0x%lx"
+ " to DENSE at 0x%lx and SPARSE at 0x%lx\n",
+ Base, Size, ret, rets);
else
- xf86Msg(X_INFO,"mapVidMemSparse: mapped Base 0x%lx size 0x%lx"
- " to DENSE only at 0x%lx\n",
- Base, Size, ret);
+ xf86Msg(X_INFO, "mapVidMemSparse: mapped Base 0x%lx size 0x%lx"
+ " to DENSE only at 0x%lx\n", Base, Size, ret);
#endif
return (pointer) ret;
@@ -692,16 +683,17 @@ mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags
static void
unmapVidMemSparse(int ScreenNum, pointer Base, unsigned long Size)
{
- unsigned long Offset = (unsigned long)Base - DENSE_BASE;
+ unsigned long Offset = (unsigned long) Base - DENSE_BASE;
+
#if 1
- xf86Msg(X_INFO,"unmapVidMemSparse: unmapping Base 0x%lx Size 0x%lx\n",
- Base, Size);
+ xf86Msg(X_INFO, "unmapVidMemSparse: unmapping Base 0x%lx Size 0x%lx\n",
+ Base, Size);
#endif
/* Unmap DENSE always. */
- munmap((caddr_t)Base, Size);
+ munmap((caddr_t) Base, Size);
/* Unmap SPARSE always, and ignore error in case we did not map it. */
- munmap((caddr_t)(SPARSE_BASE + (Offset << 5)), Size << 5);
+ munmap((caddr_t) (SPARSE_BASE + (Offset << 5)), Size << 5);
}
static int
@@ -711,15 +703,15 @@ readSparse8(pointer Base, register unsigned long Offset)
register unsigned long msb;
mem_barrier();
- Offset += (unsigned long)Base - DENSE_BASE;
+ Offset += (unsigned long) Base - DENSE_BASE;
shift = (Offset & 0x3) << 3;
if (Offset >= (hae_thresh)) {
msb = Offset & hae_mask;
Offset -= msb;
- if (msb_set != msb) {
- sethae(msb);
- msb_set = msb;
- }
+ if (msb_set != msb) {
+ sethae(msb);
+ msb_set = msb;
+ }
}
mem_barrier();
@@ -735,19 +727,19 @@ readSparse16(pointer Base, register unsigned long Offset)
register unsigned long msb;
mem_barrier();
- Offset += (unsigned long)Base - DENSE_BASE;
+ Offset += (unsigned long) Base - DENSE_BASE;
shift = (Offset & 0x2) << 3;
if (Offset >= hae_thresh) {
msb = Offset & hae_mask;
Offset -= msb;
- if (msb_set != msb) {
- sethae(msb);
- msb_set = msb;
- }
+ if (msb_set != msb) {
+ sethae(msb);
+ msb_set = msb;
+ }
}
mem_barrier();
- result = *(vuip)(SPARSE_BASE + (Offset<<5) + (1<<(5-2)));
+ result = *(vuip) (SPARSE_BASE + (Offset << 5) + (1 << (5 - 2)));
result >>= shift;
return 0xffffUL & result;
}
@@ -757,7 +749,7 @@ readSparse32(pointer Base, register unsigned long Offset)
{
/* NOTE: this is really using DENSE. */
mem_barrier();
- return *(vuip)((unsigned long)Base+(Offset));
+ return *(vuip) ((unsigned long) Base + (Offset));
}
static void
@@ -767,14 +759,14 @@ writeSparse8(int Value, pointer Base, register unsigned long Offset)
register unsigned int b = Value & 0xffU;
write_mem_barrier();
- Offset += (unsigned long)Base - DENSE_BASE;
+ Offset += (unsigned long) Base - DENSE_BASE;
if (Offset >= hae_thresh) {
msb = Offset & hae_mask;
- Offset -= msb;
- if (msb_set != msb) {
- sethae(msb);
- msb_set = msb;
- }
+ Offset -= msb;
+ if (msb_set != msb) {
+ sethae(msb);
+ msb_set = msb;
+ }
}
write_mem_barrier();
@@ -788,18 +780,18 @@ writeSparse16(int Value, pointer Base, register unsigned long Offset)
register unsigned int w = Value & 0xffffU;
write_mem_barrier();
- Offset += (unsigned long)Base - DENSE_BASE;
+ Offset += (unsigned long) Base - DENSE_BASE;
if (Offset >= hae_thresh) {
msb = Offset & hae_mask;
- Offset -= msb;
- if (msb_set != msb) {
- sethae(msb);
- msb_set = msb;
- }
+ Offset -= msb;
+ if (msb_set != msb) {
+ sethae(msb);
+ msb_set = msb;
+ }
}
write_mem_barrier();
- *(vuip)(SPARSE_BASE + (Offset<<5) + (1<<(5-2))) = w * 0x00010001;
+ *(vuip) (SPARSE_BASE + (Offset << 5) + (1 << (5 - 2))) = w * 0x00010001;
}
static void
@@ -807,7 +799,7 @@ writeSparse32(int Value, pointer Base, register unsigned long Offset)
{
/* NOTE: this is really using DENSE. */
write_mem_barrier();
- *(vuip)((unsigned long)Base + (Offset)) = Value;
+ *(vuip) ((unsigned long) Base + (Offset)) = Value;
return;
}
@@ -817,14 +809,14 @@ writeSparseNB8(int Value, pointer Base, register unsigned long Offset)
register unsigned long msb;
register unsigned int b = Value & 0xffU;
- Offset += (unsigned long)Base - DENSE_BASE;
+ Offset += (unsigned long) Base - DENSE_BASE;
if (Offset >= hae_thresh) {
msb = Offset & hae_mask;
- Offset -= msb;
- if (msb_set != msb) {
- sethae(msb);
- msb_set = msb;
- }
+ Offset -= msb;
+ if (msb_set != msb) {
+ sethae(msb);
+ msb_set = msb;
+ }
}
*(vuip) (SPARSE_BASE + (Offset << 5)) = b * 0x01010101;
}
@@ -835,43 +827,43 @@ writeSparseNB16(int Value, pointer Base, register unsigned long Offset)
register unsigned long msb;
register unsigned int w = Value & 0xffffU;
- Offset += (unsigned long)Base - DENSE_BASE;
+ Offset += (unsigned long) Base - DENSE_BASE;
if (Offset >= hae_thresh) {
msb = Offset & hae_mask;
- Offset -= msb;
- if (msb_set != msb) {
- sethae(msb);
- msb_set = msb;
- }
+ Offset -= msb;
+ if (msb_set != msb) {
+ sethae(msb);
+ msb_set = msb;
+ }
}
- *(vuip)(SPARSE_BASE+(Offset<<5)+(1<<(5-2))) = w * 0x00010001;
+ *(vuip) (SPARSE_BASE + (Offset << 5) + (1 << (5 - 2))) = w * 0x00010001;
}
static void
writeSparseNB32(int Value, pointer Base, register unsigned long Offset)
{
/* NOTE: this is really using DENSE. */
- *(vuip)((unsigned long)Base + (Offset)) = Value;
+ *(vuip) ((unsigned long) Base + (Offset)) = Value;
return;
}
-void (*xf86WriteMmio8)(int Value, pointer Base, unsigned long Offset)
- = writeDense8;
-void (*xf86WriteMmio16)(int Value, pointer Base, unsigned long Offset)
- = writeDense16;
-void (*xf86WriteMmio32)(int Value, pointer Base, unsigned long Offset)
- = writeDense32;
-void (*xf86WriteMmioNB8)(int Value, pointer Base, unsigned long Offset)
- = writeDenseNB8;
-void (*xf86WriteMmioNB16)(int Value, pointer Base, unsigned long Offset)
- = writeDenseNB16;
-void (*xf86WriteMmioNB32)(int Value, pointer Base, unsigned long Offset)
- = writeDenseNB32;
-int (*xf86ReadMmio8)(pointer Base, unsigned long Offset)
- = readDense8;
-int (*xf86ReadMmio16)(pointer Base, unsigned long Offset)
- = readDense16;
-int (*xf86ReadMmio32)(pointer Base, unsigned long Offset)
- = readDense32;
-
-#endif /* __alpha__ */
+void (*xf86WriteMmio8) (int Value, pointer Base, unsigned long Offset)
+ = writeDense8;
+void (*xf86WriteMmio16) (int Value, pointer Base, unsigned long Offset)
+ = writeDense16;
+void (*xf86WriteMmio32) (int Value, pointer Base, unsigned long Offset)
+ = writeDense32;
+void (*xf86WriteMmioNB8) (int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB8;
+void (*xf86WriteMmioNB16) (int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB16;
+void (*xf86WriteMmioNB32) (int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB32;
+int (*xf86ReadMmio8) (pointer Base, unsigned long Offset)
+ = readDense8;
+int (*xf86ReadMmio16) (pointer Base, unsigned long Offset)
+ = readDense16;
+int (*xf86ReadMmio32) (pointer Base, unsigned long Offset)
+ = readDense32;
+
+#endif /* __alpha__ */
diff --git a/xorg-server/hw/xfree86/os-support/misc/SlowBcopy.c b/xorg-server/hw/xfree86/os-support/misc/SlowBcopy.c
index 0021b5544..254748ff6 100644
--- a/xorg-server/hw/xfree86/os-support/misc/SlowBcopy.c
+++ b/xorg-server/hw/xfree86/os-support/misc/SlowBcopy.c
@@ -1,7 +1,7 @@
/*******************************************************************************
for Alpha Linux
*******************************************************************************/
-
+
/*
* Create a dependency that should be immune from the effect of register
* renaming as is commonly seen in superscalar processors. This should
@@ -10,7 +10,7 @@
*
* Slowbcopy(char *src, char *dst, int count)
*
- */
+ */
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
@@ -27,16 +27,16 @@ static int really_slow_bcopy;
void
xf86SetReallySlowBcopy(void)
{
- really_slow_bcopy = 1;
+ really_slow_bcopy = 1;
}
#if defined(__i386__) || defined(__amd64__)
-static void xf86_really_slow_bcopy(unsigned char *src, unsigned char *dst, int len)
+static void
+xf86_really_slow_bcopy(unsigned char *src, unsigned char *dst, int len)
{
- while(len--)
- {
- *dst++ = *src++;
- outb(0x80, 0x00);
+ while (len--) {
+ *dst++ = *src++;
+ outb(0x80, 0x00);
}
}
#endif
@@ -47,12 +47,12 @@ xf86SlowBcopy(unsigned char *src, unsigned char *dst, int len)
{
#if defined(__i386__) || defined(__amd64__)
if (really_slow_bcopy) {
- xf86_really_slow_bcopy(src, dst, len);
- return;
+ xf86_really_slow_bcopy(src, dst, len);
+ return;
}
#endif
- while(len--)
- *dst++ = *src++;
+ while (len--)
+ *dst++ = *src++;
}
#ifdef __alpha__
@@ -76,42 +76,41 @@ unsigned long _bus_base(void);
void
xf86SlowBCopyFromBus(unsigned char *src, unsigned char *dst, int count)
{
- if (useSparse())
- {
- unsigned long addr;
- long result;
-
- addr = (unsigned long) src;
- while (count) {
- result = *(volatile int *) addr;
- result >>= ((addr>>SPARSE) & 3) * 8;
- *dst++ = (unsigned char) (0xffUL & result);
- addr += 1<<SPARSE;
- count--;
- outb(0x80, 0x00);
- }
- }
- else
- xf86SlowBcopy(src, dst, count);
+ if (useSparse()) {
+ unsigned long addr;
+ long result;
+
+ addr = (unsigned long) src;
+ while (count) {
+ result = *(volatile int *) addr;
+ result >>= ((addr >> SPARSE) & 3) * 8;
+ *dst++ = (unsigned char) (0xffUL & result);
+ addr += 1 << SPARSE;
+ count--;
+ outb(0x80, 0x00);
+ }
+ }
+ else
+ xf86SlowBcopy(src, dst, count);
}
void
xf86SlowBCopyToBus(unsigned char *src, unsigned char *dst, int count)
{
- if (useSparse())
- {
- unsigned long addr;
-
- addr = (unsigned long) dst;
- while (count) {
- *(volatile unsigned int *) addr = (unsigned short)(*src) * 0x01010101;
- src++;
- addr += 1<<SPARSE;
- count--;
- outb(0x80, 0x00);
- }
- }
- else
- xf86SlowBcopy(src, dst, count);
+ if (useSparse()) {
+ unsigned long addr;
+
+ addr = (unsigned long) dst;
+ while (count) {
+ *(volatile unsigned int *) addr =
+ (unsigned short) (*src) * 0x01010101;
+ src++;
+ addr += 1 << SPARSE;
+ count--;
+ outb(0x80, 0x00);
+ }
+ }
+ else
+ xf86SlowBcopy(src, dst, count);
}
#endif
diff --git a/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c b/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c
index b7b35d9db..e000dc9c8 100644
--- a/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c
+++ b/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c
@@ -38,41 +38,39 @@
#ifndef __alpha__
int
xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
+ int Len)
{
- int fd;
- unsigned char *ptr;
- int psize;
- int mlen;
-
- if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
- {
- xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- return -1;
- }
- psize = getpagesize();
- Offset += Base & (psize - 1);
- Base &= ~(psize - 1);
- mlen = (Offset + Len + psize - 1) & ~(psize - 1);
- ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
- MAP_SHARED, fd, (off_t)Base);
- if (ptr == MAP_FAILED)
- {
- xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed (%s)\n",
- DEV_MEM, strerror(errno));
- close(fd);
- return -1;
- }
- DebugF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
- Base, ptr[0] | (ptr[1] << 8));
- (void)memcpy(Buf, (void *)(ptr + Offset), Len);
- (void)munmap((caddr_t)ptr, mlen);
- (void)close(fd);
- return Len;
+ int fd;
+ unsigned char *ptr;
+ int psize;
+ int mlen;
+
+ if ((fd = open(DEV_MEM, O_RDONLY)) < 0) {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ return -1;
+ }
+ psize = getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+ ptr = (unsigned char *) mmap((caddr_t) 0, mlen, PROT_READ,
+ MAP_SHARED, fd, (off_t) Base);
+ if (ptr == MAP_FAILED) {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed (%s)\n",
+ DEV_MEM, strerror(errno));
+ close(fd);
+ return -1;
+ }
+ DebugF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
+ Base, ptr[0] | (ptr[1] << 8));
+ (void) memcpy(Buf, (void *) (ptr + Offset), Len);
+ (void) munmap((caddr_t) ptr, mlen);
+ (void) close(fd);
+ return Len;
}
-#else /* __alpha__ */
+#else /* __alpha__ */
/*
* We trick "mmap" into mapping BUS memory for us via BUS_BASE,
@@ -88,50 +86,50 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
#ifdef linux
extern unsigned long _bus_base(void);
+
#define BUS_BASE _bus_base()
#else
extern u_int64_t dense_base(void);
+
#define BUS_BASE dense_base()
#endif
int
xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
+ int Len)
{
- caddr_t base;
- int fd;
- int psize;
- int mlen;
-
- if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
- {
- xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- return -1;
- }
-
- psize = getpagesize();
- Offset += Base & (psize - 1);
- Base &= ~(psize - 1);
- mlen = (Offset + Len + psize - 1) & ~(psize - 1);
- base = mmap((caddr_t)0, mlen, PROT_READ,
- MAP_SHARED, fd, (off_t)(Base + BUS_BASE));
-
- if (base == MAP_FAILED)
- {
- xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to mmap %s (%s)\n",
- DEV_MEM, strerror(errno));
- return -1;
- }
-
- xf86SlowBCopyFromBus((unsigned char *)(base+Offset), Buf, Len);
-
- munmap((caddr_t)base, mlen);
- close(fd);
- return Len;
+ caddr_t base;
+ int fd;
+ int psize;
+ int mlen;
+
+ if ((fd = open(DEV_MEM, O_RDONLY)) < 0) {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ return -1;
+ }
+
+ psize = getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+ base = mmap((caddr_t) 0, mlen, PROT_READ,
+ MAP_SHARED, fd, (off_t) (Base + BUS_BASE));
+
+ if (base == MAP_FAILED) {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to mmap %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ return -1;
+ }
+
+ xf86SlowBCopyFromBus((unsigned char *) (base + Offset), Buf, Len);
+
+ munmap((caddr_t) base, mlen);
+ close(fd);
+ return Len;
}
-#endif /* __alpha__ */
+#endif /* __alpha__ */
diff --git a/xorg-server/hw/xfree86/os-support/shared/kmod_noop.c b/xorg-server/hw/xfree86/os-support/shared/kmod_noop.c
index e86d7472f..0437bc564 100644
--- a/xorg-server/hw/xfree86/os-support/shared/kmod_noop.c
+++ b/xorg-server/hw/xfree86/os-support/shared/kmod_noop.c
@@ -31,8 +31,9 @@
#include "xf86_OSproc.h"
-int xf86LoadKernelModule(const char *pathname)
+int
+xf86LoadKernelModule(const char *pathname)
{
(void) pathname;
- return 0; /* failure */
+ return 0; /* failure */
}
diff --git a/xorg-server/hw/xfree86/os-support/shared/posix_tty.c b/xorg-server/hw/xfree86/os-support/shared/posix_tty.c
index cc12a31f2..ab3757a2a 100644
--- a/xorg-server/hw/xfree86/os-support/shared/posix_tty.c
+++ b/xorg-server/hw/xfree86/os-support/shared/posix_tty.c
@@ -61,458 +61,430 @@
#include "xf86Priv.h"
#include "xf86_OSlib.h"
-static int
-GetBaud (int baudrate)
+static int
+GetBaud(int baudrate)
{
#ifdef B300
- if (baudrate == 300)
- return B300;
+ if (baudrate == 300)
+ return B300;
#endif
#ifdef B1200
- if (baudrate == 1200)
- return B1200;
+ if (baudrate == 1200)
+ return B1200;
#endif
#ifdef B2400
- if (baudrate == 2400)
- return B2400;
+ if (baudrate == 2400)
+ return B2400;
#endif
#ifdef B4800
- if (baudrate == 4800)
- return B4800;
+ if (baudrate == 4800)
+ return B4800;
#endif
#ifdef B9600
- if (baudrate == 9600)
- return B9600;
+ if (baudrate == 9600)
+ return B9600;
#endif
#ifdef B19200
- if (baudrate == 19200)
- return B19200;
+ if (baudrate == 19200)
+ return B19200;
#endif
#ifdef B38400
- if (baudrate == 38400)
- return B38400;
+ if (baudrate == 38400)
+ return B38400;
#endif
#ifdef B57600
- if (baudrate == 57600)
- return B57600;
+ if (baudrate == 57600)
+ return B57600;
#endif
#ifdef B115200
- if (baudrate == 115200)
- return B115200;
+ if (baudrate == 115200)
+ return B115200;
#endif
#ifdef B230400
- if (baudrate == 230400)
- return B230400;
+ if (baudrate == 230400)
+ return B230400;
#endif
#ifdef B460800
- if (baudrate == 460800)
- return B460800;
+ if (baudrate == 460800)
+ return B460800;
#endif
- return 0;
+ return 0;
}
int
-xf86OpenSerial (XF86OptionPtr options)
+xf86OpenSerial(XF86OptionPtr options)
{
- struct termios t;
- int fd, i;
- char *dev;
-
- dev = xf86SetStrOption (options, "Device", NULL);
- if (!dev)
- {
- xf86Msg (X_ERROR, "xf86OpenSerial: No Device specified.\n");
- return -1;
- }
-
- SYSCALL (fd = open (dev, O_RDWR | O_NONBLOCK));
- if (fd == -1)
- {
- xf86Msg (X_ERROR,
- "xf86OpenSerial: Cannot open device %s\n\t%s.\n",
- dev, strerror (errno));
- free(dev);
- return -1;
- }
-
- if (!isatty (fd))
- {
- /* Allow non-tty devices to be opened. */
- free(dev);
- return fd;
- }
-
- /* set up default port parameters */
- SYSCALL (tcgetattr (fd, &t));
- t.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR\
- |IGNCR|ICRNL|IXON);
- t.c_oflag &= ~OPOST;
- t.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
- t.c_cflag &= ~(CSIZE|PARENB);
- t.c_cflag |= CS8|CLOCAL;
-
- cfsetispeed (&t, B9600);
- cfsetospeed (&t, B9600);
- t.c_cc[VMIN] = 1;
- t.c_cc[VTIME] = 0;
-
- SYSCALL (tcsetattr (fd, TCSANOW, &t));
-
- if (xf86SetSerial (fd, options) == -1)
- {
- SYSCALL (close (fd));
- free(dev);
- return -1;
- }
-
- SYSCALL (i = fcntl (fd, F_GETFL, 0));
- if (i == -1)
- {
- SYSCALL (close (fd));
- free(dev);
- return -1;
- }
- i &= ~O_NONBLOCK;
- SYSCALL (i = fcntl (fd, F_SETFL, i));
- if (i == -1)
- {
- SYSCALL (close (fd));
- free(dev);
- return -1;
- }
- free(dev);
- return fd;
+ struct termios t;
+ int fd, i;
+ char *dev;
+
+ dev = xf86SetStrOption(options, "Device", NULL);
+ if (!dev) {
+ xf86Msg(X_ERROR, "xf86OpenSerial: No Device specified.\n");
+ return -1;
+ }
+
+ SYSCALL(fd = open(dev, O_RDWR | O_NONBLOCK));
+ if (fd == -1) {
+ xf86Msg(X_ERROR,
+ "xf86OpenSerial: Cannot open device %s\n\t%s.\n",
+ dev, strerror(errno));
+ free(dev);
+ return -1;
+ }
+
+ if (!isatty(fd)) {
+ /* Allow non-tty devices to be opened. */
+ free(dev);
+ return fd;
+ }
+
+ /* set up default port parameters */
+ SYSCALL(tcgetattr(fd, &t));
+ t.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR
+ | IGNCR | ICRNL | IXON);
+ t.c_oflag &= ~OPOST;
+ t.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
+ t.c_cflag &= ~(CSIZE | PARENB);
+ t.c_cflag |= CS8 | CLOCAL;
+
+ cfsetispeed(&t, B9600);
+ cfsetospeed(&t, B9600);
+ t.c_cc[VMIN] = 1;
+ t.c_cc[VTIME] = 0;
+
+ SYSCALL(tcsetattr(fd, TCSANOW, &t));
+
+ if (xf86SetSerial(fd, options) == -1) {
+ SYSCALL(close(fd));
+ free(dev);
+ return -1;
+ }
+
+ SYSCALL(i = fcntl(fd, F_GETFL, 0));
+ if (i == -1) {
+ SYSCALL(close(fd));
+ free(dev);
+ return -1;
+ }
+ i &= ~O_NONBLOCK;
+ SYSCALL(i = fcntl(fd, F_SETFL, i));
+ if (i == -1) {
+ SYSCALL(close(fd));
+ free(dev);
+ return -1;
+ }
+ free(dev);
+ return fd;
}
int
-xf86SetSerial (int fd, XF86OptionPtr options)
+xf86SetSerial(int fd, XF86OptionPtr options)
{
- struct termios t;
- int val;
- const char *s;
- int baud, r;
-
- if (fd < 0)
- return -1;
-
- /* Don't try to set parameters for non-tty devices. */
- if (!isatty(fd))
- return 0;
-
- SYSCALL (tcgetattr (fd, &t));
-
- if ((val = xf86SetIntOption (options, "BaudRate", 0)))
- {
- if ((baud = GetBaud (val)))
- {
- cfsetispeed (&t, baud);
- cfsetospeed (&t, baud);
- }
- else
- {
- xf86Msg (X_ERROR,
- "Invalid Option BaudRate value: %d\n", val);
- return -1;
- }
- }
-
- if ((val = xf86SetIntOption (options, "StopBits", 0)))
- {
- switch (val)
- {
- case 1:
- t.c_cflag &= ~(CSTOPB);
- break;
- case 2:
- t.c_cflag |= CSTOPB;
- break;
- default:
- xf86Msg (X_ERROR,
- "Invalid Option StopBits value: %d\n", val);
- return -1;
- break;
- }
- }
-
- if ((val = xf86SetIntOption (options, "DataBits", 0)))
- {
- switch (val)
- {
- case 5:
- t.c_cflag &= ~(CSIZE);
- t.c_cflag |= CS5;
- break;
- case 6:
- t.c_cflag &= ~(CSIZE);
- t.c_cflag |= CS6;
- break;
- case 7:
- t.c_cflag &= ~(CSIZE);
- t.c_cflag |= CS7;
- break;
- case 8:
- t.c_cflag &= ~(CSIZE);
- t.c_cflag |= CS8;
- break;
- default:
- xf86Msg (X_ERROR,
- "Invalid Option DataBits value: %d\n", val);
- return -1;
- break;
- }
- }
-
- if ((s = xf86SetStrOption (options, "Parity", NULL)))
- {
- if (xf86NameCmp (s, "Odd") == 0)
- {
- t.c_cflag |= PARENB | PARODD;
- }
- else if (xf86NameCmp (s, "Even") == 0)
- {
- t.c_cflag |= PARENB;
- t.c_cflag &= ~(PARODD);
- }
- else if (xf86NameCmp (s, "None") == 0)
- {
- t.c_cflag &= ~(PARENB);
- }
- else
- {
- xf86Msg (X_ERROR, "Invalid Option Parity value: %s\n",
- s);
- return -1;
- }
- }
-
- if ((val = xf86SetIntOption (options, "Vmin", -1)) != -1)
- {
- t.c_cc[VMIN] = val;
- }
- if ((val = xf86SetIntOption (options, "Vtime", -1)) != -1)
- {
- t.c_cc[VTIME] = val;
- }
-
- if ((s = xf86SetStrOption (options, "FlowControl", NULL)))
- {
- xf86MarkOptionUsedByName (options, "FlowControl");
- if (xf86NameCmp (s, "Xoff") == 0)
- {
- t.c_iflag |= IXOFF;
- }
- else if (xf86NameCmp (s, "Xon") == 0)
- {
- t.c_iflag |= IXON;
- }
- else if (xf86NameCmp (s, "XonXoff") == 0)
- {
- t.c_iflag |= IXON|IXOFF;
- }
- else if (xf86NameCmp (s, "None") == 0)
- {
- t.c_iflag &= ~(IXON | IXOFF);
- }
- else
- {
- xf86Msg (X_ERROR,
- "Invalid Option FlowControl value: %s\n", s);
- return -1;
- }
- }
-
- if ((xf86SetBoolOption (options, "ClearDTR", FALSE)))
- {
+ struct termios t;
+ int val;
+ const char *s;
+ int baud, r;
+
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+ SYSCALL(tcgetattr(fd, &t));
+
+ if ((val = xf86SetIntOption(options, "BaudRate", 0))) {
+ if ((baud = GetBaud(val))) {
+ cfsetispeed(&t, baud);
+ cfsetospeed(&t, baud);
+ }
+ else {
+ xf86Msg(X_ERROR, "Invalid Option BaudRate value: %d\n", val);
+ return -1;
+ }
+ }
+
+ if ((val = xf86SetIntOption(options, "StopBits", 0))) {
+ switch (val) {
+ case 1:
+ t.c_cflag &= ~(CSTOPB);
+ break;
+ case 2:
+ t.c_cflag |= CSTOPB;
+ break;
+ default:
+ xf86Msg(X_ERROR, "Invalid Option StopBits value: %d\n", val);
+ return -1;
+ break;
+ }
+ }
+
+ if ((val = xf86SetIntOption(options, "DataBits", 0))) {
+ switch (val) {
+ case 5:
+ t.c_cflag &= ~(CSIZE);
+ t.c_cflag |= CS5;
+ break;
+ case 6:
+ t.c_cflag &= ~(CSIZE);
+ t.c_cflag |= CS6;
+ break;
+ case 7:
+ t.c_cflag &= ~(CSIZE);
+ t.c_cflag |= CS7;
+ break;
+ case 8:
+ t.c_cflag &= ~(CSIZE);
+ t.c_cflag |= CS8;
+ break;
+ default:
+ xf86Msg(X_ERROR, "Invalid Option DataBits value: %d\n", val);
+ return -1;
+ break;
+ }
+ }
+
+ if ((s = xf86SetStrOption(options, "Parity", NULL))) {
+ if (xf86NameCmp(s, "Odd") == 0) {
+ t.c_cflag |= PARENB | PARODD;
+ }
+ else if (xf86NameCmp(s, "Even") == 0) {
+ t.c_cflag |= PARENB;
+ t.c_cflag &= ~(PARODD);
+ }
+ else if (xf86NameCmp(s, "None") == 0) {
+ t.c_cflag &= ~(PARENB);
+ }
+ else {
+ xf86Msg(X_ERROR, "Invalid Option Parity value: %s\n", s);
+ return -1;
+ }
+ }
+
+ if ((val = xf86SetIntOption(options, "Vmin", -1)) != -1) {
+ t.c_cc[VMIN] = val;
+ }
+ if ((val = xf86SetIntOption(options, "Vtime", -1)) != -1) {
+ t.c_cc[VTIME] = val;
+ }
+
+ if ((s = xf86SetStrOption(options, "FlowControl", NULL))) {
+ xf86MarkOptionUsedByName(options, "FlowControl");
+ if (xf86NameCmp(s, "Xoff") == 0) {
+ t.c_iflag |= IXOFF;
+ }
+ else if (xf86NameCmp(s, "Xon") == 0) {
+ t.c_iflag |= IXON;
+ }
+ else if (xf86NameCmp(s, "XonXoff") == 0) {
+ t.c_iflag |= IXON | IXOFF;
+ }
+ else if (xf86NameCmp(s, "None") == 0) {
+ t.c_iflag &= ~(IXON | IXOFF);
+ }
+ else {
+ xf86Msg(X_ERROR, "Invalid Option FlowControl value: %s\n", s);
+ return -1;
+ }
+ }
+
+ if ((xf86SetBoolOption(options, "ClearDTR", FALSE))) {
#ifdef CLEARDTR_SUPPORT
-# if defined(TIOCMBIC)
- val = TIOCM_DTR;
- SYSCALL (ioctl(fd, TIOCMBIC, &val));
-# else
- SYSCALL (ioctl(fd, TIOCCDTR, NULL));
-# endif
+#if defined(TIOCMBIC)
+ val = TIOCM_DTR;
+ SYSCALL(ioctl(fd, TIOCMBIC, &val));
+#else
+ SYSCALL(ioctl(fd, TIOCCDTR, NULL));
+#endif
#else
- xf86Msg (X_WARNING,
- "Option ClearDTR not supported on this OS\n");
- return -1;
+ xf86Msg(X_WARNING, "Option ClearDTR not supported on this OS\n");
+ return -1;
#endif
- xf86MarkOptionUsedByName (options, "ClearDTR");
- }
-
- if ((xf86SetBoolOption (options, "ClearRTS", FALSE)))
- {
- xf86Msg (X_WARNING,
- "Option ClearRTS not supported on this OS\n");
- return -1;
- xf86MarkOptionUsedByName (options, "ClearRTS");
- }
-
- SYSCALL (r = tcsetattr (fd, TCSANOW, &t));
- return r;
+ xf86MarkOptionUsedByName(options, "ClearDTR");
+ }
+
+ if ((xf86SetBoolOption(options, "ClearRTS", FALSE))) {
+ xf86Msg(X_WARNING, "Option ClearRTS not supported on this OS\n");
+ return -1;
+ xf86MarkOptionUsedByName(options, "ClearRTS");
+ }
+
+ SYSCALL(r = tcsetattr(fd, TCSANOW, &t));
+ return r;
}
int
-xf86SetSerialSpeed (int fd, int speed)
+xf86SetSerialSpeed(int fd, int speed)
{
- struct termios t;
- int baud, r;
-
- if (fd < 0)
- return -1;
-
- /* Don't try to set parameters for non-tty devices. */
- if (!isatty(fd))
- return 0;
-
- SYSCALL (tcgetattr (fd, &t));
-
- if ((baud = GetBaud (speed)))
- {
- cfsetispeed (&t, baud);
- cfsetospeed (&t, baud);
- }
- else
- {
- xf86Msg (X_ERROR,
- "Invalid Option BaudRate value: %d\n", speed);
- return -1;
- }
-
- SYSCALL (r = tcsetattr (fd, TCSANOW, &t));
- return r;
+ struct termios t;
+ int baud, r;
+
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+ SYSCALL(tcgetattr(fd, &t));
+
+ if ((baud = GetBaud(speed))) {
+ cfsetispeed(&t, baud);
+ cfsetospeed(&t, baud);
+ }
+ else {
+ xf86Msg(X_ERROR, "Invalid Option BaudRate value: %d\n", speed);
+ return -1;
+ }
+
+ SYSCALL(r = tcsetattr(fd, TCSANOW, &t));
+ return r;
}
int
-xf86ReadSerial (int fd, void *buf, int count)
+xf86ReadSerial(int fd, void *buf, int count)
{
- int r;
- int i;
-
- SYSCALL (r = read (fd, buf, count));
- DebugF("ReadingSerial: 0x%x",
- (unsigned char)*(((unsigned char *)buf)));
- for (i = 1; i < r; i++)
- DebugF(", 0x%x",(unsigned char)*(((unsigned char *)buf) + i));
- DebugF("\n");
- return r;
+ int r;
+ int i;
+
+ SYSCALL(r = read(fd, buf, count));
+ DebugF("ReadingSerial: 0x%x", (unsigned char) *(((unsigned char *) buf)));
+ for (i = 1; i < r; i++)
+ DebugF(", 0x%x", (unsigned char) *(((unsigned char *) buf) + i));
+ DebugF("\n");
+ return r;
}
int
-xf86WriteSerial (int fd, const void *buf, int count)
+xf86WriteSerial(int fd, const void *buf, int count)
{
- int r;
- int i;
-
- DebugF("WritingSerial: 0x%x",(unsigned char)*(((unsigned char *)buf)));
- for (i = 1; i < count; i++)
- DebugF(", 0x%x",(unsigned char)*(((unsigned char *)buf) + i));
- DebugF("\n");
- SYSCALL (r = write (fd, buf, count));
- return r;
+ int r;
+ int i;
+
+ DebugF("WritingSerial: 0x%x", (unsigned char) *(((unsigned char *) buf)));
+ for (i = 1; i < count; i++)
+ DebugF(", 0x%x", (unsigned char) *(((unsigned char *) buf) + i));
+ DebugF("\n");
+ SYSCALL(r = write(fd, buf, count));
+ return r;
}
int
-xf86CloseSerial (int fd)
+xf86CloseSerial(int fd)
{
- int r;
+ int r;
- SYSCALL (r = close (fd));
- return r;
+ SYSCALL(r = close(fd));
+ return r;
}
int
-xf86WaitForInput (int fd, int timeout)
+xf86WaitForInput(int fd, int timeout)
{
- fd_set readfds;
- struct timeval to;
- int r;
-
- FD_ZERO(&readfds);
-
- if (fd >= 0) {
- FD_SET(fd, &readfds);
- }
-
- to.tv_sec = timeout / 1000000;
- to.tv_usec = timeout % 1000000;
-
- if (fd >= 0) {
- SYSCALL (r = select (FD_SETSIZE, &readfds, NULL, NULL, &to));
- }
- else {
- SYSCALL (r = select (FD_SETSIZE, NULL, NULL, NULL, &to));
- }
- xf86ErrorFVerb (9,"select returned %d\n", r);
- return r;
+ fd_set readfds;
+ struct timeval to;
+ int r;
+
+ FD_ZERO(&readfds);
+
+ if (fd >= 0) {
+ FD_SET(fd, &readfds);
+ }
+
+ to.tv_sec = timeout / 1000000;
+ to.tv_usec = timeout % 1000000;
+
+ if (fd >= 0) {
+ SYSCALL(r = select(FD_SETSIZE, &readfds, NULL, NULL, &to));
+ }
+ else {
+ SYSCALL(r = select(FD_SETSIZE, NULL, NULL, NULL, &to));
+ }
+ xf86ErrorFVerb(9, "select returned %d\n", r);
+ return r;
}
int
-xf86SerialSendBreak (int fd, int duration)
+xf86SerialSendBreak(int fd, int duration)
{
- int r;
+ int r;
+
+ SYSCALL(r = tcsendbreak(fd, duration));
+ return r;
- SYSCALL (r = tcsendbreak (fd, duration));
- return r;
-
}
int
xf86FlushInput(int fd)
{
- fd_set fds;
- struct timeval timeout;
- char c[4];
-
- DebugF("FlushingSerial\n");
- if (tcflush(fd, TCIFLUSH) == 0)
- return 0;
-
- timeout.tv_sec = 0;
- timeout.tv_usec = 0;
- FD_ZERO(&fds);
- FD_SET(fd, &fds);
- while (select(FD_SETSIZE, &fds, NULL, NULL, &timeout) > 0) {
- if (read(fd, &c, sizeof(c)) < 1)
- return 0;
- FD_ZERO(&fds);
- FD_SET(fd, &fds);
- }
- return 0;
+ fd_set fds;
+ struct timeval timeout;
+ char c[4];
+
+ DebugF("FlushingSerial\n");
+ if (tcflush(fd, TCIFLUSH) == 0)
+ return 0;
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 0;
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
+ while (select(FD_SETSIZE, &fds, NULL, NULL, &timeout) > 0) {
+ if (read(fd, &c, sizeof(c)) < 1)
+ return 0;
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
+ }
+ return 0;
}
static struct states {
- int xf;
- int os;
+ int xf;
+ int os;
} modemStates[] = {
#ifdef TIOCM_LE
- { XF86_M_LE, TIOCM_LE },
+ {
+ XF86_M_LE, TIOCM_LE},
#endif
#ifdef TIOCM_DTR
- { XF86_M_DTR, TIOCM_DTR },
+ {
+ XF86_M_DTR, TIOCM_DTR},
#endif
#ifdef TIOCM_RTS
- { XF86_M_RTS, TIOCM_RTS },
+ {
+ XF86_M_RTS, TIOCM_RTS},
#endif
#ifdef TIOCM_ST
- { XF86_M_ST, TIOCM_ST },
+ {
+ XF86_M_ST, TIOCM_ST},
#endif
#ifdef TIOCM_SR
- { XF86_M_SR, TIOCM_SR },
+ {
+ XF86_M_SR, TIOCM_SR},
#endif
#ifdef TIOCM_CTS
- { XF86_M_CTS, TIOCM_CTS },
+ {
+ XF86_M_CTS, TIOCM_CTS},
#endif
#ifdef TIOCM_CAR
- { XF86_M_CAR, TIOCM_CAR },
+ {
+ XF86_M_CAR, TIOCM_CAR},
#elif defined(TIOCM_CD)
- { XF86_M_CAR, TIOCM_CD },
+ {
+ XF86_M_CAR, TIOCM_CD},
#endif
#ifdef TIOCM_RNG
- { XF86_M_RNG, TIOCM_RNG },
+ {
+ XF86_M_RNG, TIOCM_RNG},
#elif defined(TIOCM_RI)
- { XF86_M_CAR, TIOCM_RI },
+ {
+ XF86_M_CAR, TIOCM_RI},
#endif
#ifdef TIOCM_DSR
- { XF86_M_DSR, TIOCM_DSR },
+ {
+ XF86_M_DSR, TIOCM_DSR},
#endif
};
@@ -521,35 +493,36 @@ static int numStates = sizeof(modemStates) / sizeof(modemStates[0]);
static int
xf2osState(int state)
{
- int i;
- int ret = 0;
+ int i;
+ int ret = 0;
- for (i = 0; i < numStates; i++)
- if (state & modemStates[i].xf)
- ret |= modemStates[i].os;
- return ret;
+ 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;
+ int i;
+ int ret = 0;
- for (i = 0; i < numStates; i++)
- if (state & modemStates[i].os)
- ret |= modemStates[i].xf;
- return ret;
+ 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;
+ int i;
+ int ret = 0;
+
+ for (i = 0; i < numStates; i++)
+ ret |= modemStates[i].os;
+ return ret;
}
static int osStateMask = 0;
@@ -557,99 +530,99 @@ static int osStateMask = 0;
int
xf86SetSerialModemState(int fd, int state)
{
- int ret;
- int s;
+ int ret;
+ int s;
- if (fd < 0)
- return -1;
+ if (fd < 0)
+ return -1;
- /* Don't try to set parameters for non-tty devices. */
- if (!isatty(fd))
- return 0;
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
#ifndef TIOCMGET
- return -1;
+ return -1;
#else
- if (!osStateMask)
- osStateMask = getOsStateMask();
-
- state = xf2osState(state);
- SYSCALL((ret = ioctl(fd, TIOCMGET, &s)));
- if (ret < 0)
- return -1;
- s &= ~osStateMask;
- s |= state;
- SYSCALL((ret = ioctl(fd, TIOCMSET, &s)));
- if (ret < 0)
- return -1;
- else
- return 0;
+ if (!osStateMask)
+ osStateMask = getOsStateMask();
+
+ state = xf2osState(state);
+ SYSCALL((ret = ioctl(fd, TIOCMGET, &s)));
+ if (ret < 0)
+ return -1;
+ s &= ~osStateMask;
+ s |= state;
+ SYSCALL((ret = ioctl(fd, TIOCMSET, &s)));
+ if (ret < 0)
+ return -1;
+ else
+ return 0;
#endif
}
int
xf86GetSerialModemState(int fd)
{
- int ret;
- int s;
+ int ret;
+ int s;
- if (fd < 0)
- return -1;
+ if (fd < 0)
+ return -1;
- /* Don't try to set parameters for non-tty devices. */
- if (!isatty(fd))
- return 0;
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
#ifndef TIOCMGET
- return -1;
+ return -1;
#else
- SYSCALL((ret = ioctl(fd, TIOCMGET, &s)));
- if (ret < 0)
- return -1;
- return os2xfState(s);
+ SYSCALL((ret = ioctl(fd, TIOCMGET, &s)));
+ if (ret < 0)
+ return -1;
+ return os2xfState(s);
#endif
}
int
xf86SerialModemSetBits(int fd, int bits)
{
- int ret;
- int s;
+ int ret;
+ int s;
- if (fd < 0)
- return -1;
+ if (fd < 0)
+ return -1;
- /* Don't try to set parameters for non-tty devices. */
- if (!isatty(fd))
- return 0;
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
#ifndef TIOCMGET
- return -1;
+ return -1;
#else
- s = xf2osState(bits);
- SYSCALL((ret = ioctl(fd, TIOCMBIS, &s)));
- return ret;
+ s = xf2osState(bits);
+ SYSCALL((ret = ioctl(fd, TIOCMBIS, &s)));
+ return ret;
#endif
}
int
xf86SerialModemClearBits(int fd, int bits)
{
- int ret;
- int s;
+ int ret;
+ int s;
- if (fd < 0)
- return -1;
+ if (fd < 0)
+ return -1;
- /* Don't try to set parameters for non-tty devices. */
- if (!isatty(fd))
- return 0;
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
#ifndef TIOCMGET
- return -1;
+ return -1;
#else
- s = xf2osState(bits);
- SYSCALL((ret = ioctl(fd, TIOCMBIC, &s)));
- return ret;
+ s = xf2osState(bits);
+ SYSCALL((ret = ioctl(fd, TIOCMBIC, &s)));
+ return ret;
#endif
}
diff --git a/xorg-server/hw/xfree86/os-support/shared/sigio.c b/xorg-server/hw/xfree86/os-support/shared/sigio.c
index ef04c1140..12ae8a480 100644
--- a/xorg-server/hw/xfree86/os-support/shared/sigio.c
+++ b/xorg-server/hw/xfree86/os-support/shared/sigio.c
@@ -1,309 +1,301 @@
-/* sigio.c -- Support for SIGIO handler installation and removal
- * Created: Thu Jun 3 15:39:18 1999 by faith@precisioninsight.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
- */
-/*
- * Copyright (c) 2002 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-# include <X11/X.h>
-# include "xf86.h"
-# include "xf86Priv.h"
-# include "xf86_OSlib.h"
-# include "inputstr.h"
-
-#ifdef HAVE_STROPTS_H
-# include <stropts.h>
-#endif
-
-#ifdef MAXDEVICES
-/* MAXDEVICES represents the maximimum number of input devices usable
- * at the same time plus one entry for DRM support.
- */
-# define MAX_FUNCS (MAXDEVICES + 1)
-#else
-# define MAX_FUNCS 16
-#endif
-
-typedef struct _xf86SigIOFunc {
- void (*f) (int, void *);
- int fd;
- void *closure;
-} Xf86SigIOFunc;
-
-static Xf86SigIOFunc xf86SigIOFuncs[MAX_FUNCS];
-static int xf86SigIOMax;
-static int xf86SigIOMaxFd;
-static fd_set xf86SigIOMask;
-
-/*
- * SIGIO gives no way of discovering which fd signalled, select
- * to discover
- */
-static void
-xf86SIGIO (int sig)
-{
- int i;
- fd_set ready;
- struct timeval to;
- int save_errno = errno; /* do not clobber the global errno */
- int r;
-
- ready = xf86SigIOMask;
- to.tv_sec = 0;
- to.tv_usec = 0;
- SYSCALL (r = select (xf86SigIOMaxFd, &ready, 0, 0, &to));
- for (i = 0; r > 0 && i < xf86SigIOMax; i++)
- if (xf86SigIOFuncs[i].f && FD_ISSET (xf86SigIOFuncs[i].fd, &ready))
- {
- (*xf86SigIOFuncs[i].f)(xf86SigIOFuncs[i].fd,
- xf86SigIOFuncs[i].closure);
- r--;
- }
- if (r > 0) {
- xf86Msg(X_ERROR, "SIGIO %d descriptors not handled\n", r);
- }
- /* restore global errno */
- errno = save_errno;
-}
-
-static int
-xf86IsPipe (int fd)
-{
- struct stat buf;
-
- if (fstat (fd, &buf) < 0)
- return 0;
- return S_ISFIFO(buf.st_mode);
-}
-
-int
-xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *closure)
-{
- struct sigaction sa;
- struct sigaction osa;
- int i;
- int blocked;
- int installed = FALSE;
-
- if (!xf86Info.useSIGIO)
- return 0;
-
- for (i = 0; i < MAX_FUNCS; i++)
- {
- if (!xf86SigIOFuncs[i].f)
- {
- if (xf86IsPipe (fd))
- return 0;
- blocked = xf86BlockSIGIO();
-#ifdef O_ASYNC
- if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_ASYNC) == -1) {
- xf86Msg(X_WARNING, "fcntl(%d, O_ASYNC): %s\n",
- fd, strerror(errno));
- } else {
- if (fcntl(fd, F_SETOWN, getpid()) == -1) {
- xf86Msg(X_WARNING, "fcntl(%d, F_SETOWN): %s\n",
- fd, strerror(errno));
- } else {
- installed = TRUE;
- }
- }
-#endif
-#ifdef I_SETSIG /* System V Streams - used on Solaris for input devices */
- if (!installed && isastream(fd)) {
- if (ioctl(fd, I_SETSIG, S_INPUT | S_ERROR | S_HANGUP) == -1) {
- xf86Msg(X_WARNING, "fcntl(%d, I_SETSIG): %s\n",
- fd, strerror(errno));
- } else {
- installed = TRUE;
- }
- }
-#endif
- if (!installed) {
- xf86UnblockSIGIO(blocked);
- return 0;
- }
- sigemptyset(&sa.sa_mask);
- sigaddset(&sa.sa_mask, SIGIO);
- sa.sa_flags = 0;
- sa.sa_handler = xf86SIGIO;
- sigaction(SIGIO, &sa, &osa);
- xf86SigIOFuncs[i].fd = fd;
- xf86SigIOFuncs[i].closure = closure;
- xf86SigIOFuncs[i].f = f;
- if (i >= xf86SigIOMax)
- xf86SigIOMax = i+1;
- if (fd >= xf86SigIOMaxFd)
- xf86SigIOMaxFd = fd + 1;
- FD_SET (fd, &xf86SigIOMask);
- xf86UnblockSIGIO(blocked);
- return 1;
- }
- /* Allow overwriting of the closure and callback */
- else if (xf86SigIOFuncs[i].fd == fd)
- {
- xf86SigIOFuncs[i].closure = closure;
- xf86SigIOFuncs[i].f = f;
- return 1;
- }
- }
- return 0;
-}
-
-int
-xf86RemoveSIGIOHandler(int fd)
-{
- struct sigaction sa;
- struct sigaction osa;
- int i;
- int max;
- int maxfd;
- int ret;
-
- if (!xf86Info.useSIGIO)
- return 0;
-
- max = 0;
- maxfd = -1;
- ret = 0;
- for (i = 0; i < MAX_FUNCS; i++)
- {
- if (xf86SigIOFuncs[i].f)
- {
- if (xf86SigIOFuncs[i].fd == fd)
- {
- xf86SigIOFuncs[i].f = 0;
- xf86SigIOFuncs[i].fd = 0;
- xf86SigIOFuncs[i].closure = 0;
- FD_CLR (fd, &xf86SigIOMask);
- ret = 1;
- }
- else
- {
- max = i + 1;
- if (xf86SigIOFuncs[i].fd >= maxfd)
- maxfd = xf86SigIOFuncs[i].fd + 1;
- }
- }
- }
- if (ret)
- {
-#ifdef O_ASYNC
- fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_ASYNC);
-#endif
-#ifdef I_SETSIG
- if (isastream(fd)) {
- if (ioctl(fd, I_SETSIG, 0) == -1) {
- xf86Msg(X_WARNING, "fcntl(%d, I_SETSIG, 0): %s\n",
- fd, strerror(errno));
- }
- }
-#endif
- xf86SigIOMax = max;
- xf86SigIOMaxFd = maxfd;
- if (!max)
- {
- sigemptyset(&sa.sa_mask);
- sigaddset(&sa.sa_mask, SIGIO);
- sa.sa_flags = 0;
- sa.sa_handler = SIG_IGN;
- sigaction(SIGIO, &sa, &osa);
- }
- }
- return ret;
-}
-
-int
-xf86BlockSIGIO (void)
-{
- sigset_t set, old;
- int ret;
-
- sigemptyset (&set);
- sigaddset (&set, SIGIO);
- sigprocmask (SIG_BLOCK, &set, &old);
- ret = sigismember (&old, SIGIO);
- return ret;
-}
-
-void
-xf86UnblockSIGIO (int wasset)
-{
- sigset_t set;
-
- if (!wasset)
- {
- sigemptyset (&set);
- sigaddset (&set, SIGIO);
- sigprocmask (SIG_UNBLOCK, &set, NULL);
- }
-}
-
-void
-xf86AssertBlockedSIGIO (char *where)
-{
- sigset_t set, old;
-
- sigemptyset (&set);
- sigprocmask (SIG_BLOCK, &set, &old);
- if (!sigismember (&old, SIGIO))
- xf86Msg (X_ERROR, "SIGIO not blocked at %s\n", where);
-}
-
-/* XXX This is a quick hack for the benefit of xf86SetSilkenMouse() */
-
-int
-xf86SIGIOSupported (void)
-{
- return 1;
-}
+/* sigio.c -- Support for SIGIO handler installation and removal
+ * Created: Thu Jun 3 15:39:18 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ */
+/*
+ * Copyright (c) 2002 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "inputstr.h"
+
+#ifdef HAVE_STROPTS_H
+#include <stropts.h>
+#endif
+
+#ifdef MAXDEVICES
+/* MAXDEVICES represents the maximimum number of input devices usable
+ * at the same time plus one entry for DRM support.
+ */
+#define MAX_FUNCS (MAXDEVICES + 1)
+#else
+#define MAX_FUNCS 16
+#endif
+
+typedef struct _xf86SigIOFunc {
+ void (*f) (int, void *);
+ int fd;
+ void *closure;
+} Xf86SigIOFunc;
+
+static Xf86SigIOFunc xf86SigIOFuncs[MAX_FUNCS];
+static int xf86SigIOMax;
+static int xf86SigIOMaxFd;
+static fd_set xf86SigIOMask;
+
+/*
+ * SIGIO gives no way of discovering which fd signalled, select
+ * to discover
+ */
+static void
+xf86SIGIO(int sig)
+{
+ int i;
+ fd_set ready;
+ struct timeval to;
+ int save_errno = errno; /* do not clobber the global errno */
+ int r;
+
+ ready = xf86SigIOMask;
+ to.tv_sec = 0;
+ to.tv_usec = 0;
+ SYSCALL(r = select(xf86SigIOMaxFd, &ready, 0, 0, &to));
+ for (i = 0; r > 0 && i < xf86SigIOMax; i++)
+ if (xf86SigIOFuncs[i].f && FD_ISSET(xf86SigIOFuncs[i].fd, &ready)) {
+ (*xf86SigIOFuncs[i].f) (xf86SigIOFuncs[i].fd,
+ xf86SigIOFuncs[i].closure);
+ r--;
+ }
+ if (r > 0) {
+ xf86Msg(X_ERROR, "SIGIO %d descriptors not handled\n", r);
+ }
+ /* restore global errno */
+ errno = save_errno;
+}
+
+static int
+xf86IsPipe(int fd)
+{
+ struct stat buf;
+
+ if (fstat(fd, &buf) < 0)
+ return 0;
+ return S_ISFIFO(buf.st_mode);
+}
+
+int
+xf86InstallSIGIOHandler(int fd, void (*f) (int, void *), void *closure)
+{
+ struct sigaction sa;
+ struct sigaction osa;
+ int i;
+ int blocked;
+ int installed = FALSE;
+
+ if (!xf86Info.useSIGIO)
+ return 0;
+
+ for (i = 0; i < MAX_FUNCS; i++) {
+ if (!xf86SigIOFuncs[i].f) {
+ if (xf86IsPipe(fd))
+ return 0;
+ blocked = xf86BlockSIGIO();
+#ifdef O_ASYNC
+ if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_ASYNC) == -1) {
+ xf86Msg(X_WARNING, "fcntl(%d, O_ASYNC): %s\n",
+ fd, strerror(errno));
+ }
+ else {
+ if (fcntl(fd, F_SETOWN, getpid()) == -1) {
+ xf86Msg(X_WARNING, "fcntl(%d, F_SETOWN): %s\n",
+ fd, strerror(errno));
+ }
+ else {
+ installed = TRUE;
+ }
+ }
+#endif
+#ifdef I_SETSIG /* System V Streams - used on Solaris for input devices */
+ if (!installed && isastream(fd)) {
+ if (ioctl(fd, I_SETSIG, S_INPUT | S_ERROR | S_HANGUP) == -1) {
+ xf86Msg(X_WARNING, "fcntl(%d, I_SETSIG): %s\n",
+ fd, strerror(errno));
+ }
+ else {
+ installed = TRUE;
+ }
+ }
+#endif
+ if (!installed) {
+ xf86UnblockSIGIO(blocked);
+ return 0;
+ }
+ sigemptyset(&sa.sa_mask);
+ sigaddset(&sa.sa_mask, SIGIO);
+ sa.sa_flags = 0;
+ sa.sa_handler = xf86SIGIO;
+ sigaction(SIGIO, &sa, &osa);
+ xf86SigIOFuncs[i].fd = fd;
+ xf86SigIOFuncs[i].closure = closure;
+ xf86SigIOFuncs[i].f = f;
+ if (i >= xf86SigIOMax)
+ xf86SigIOMax = i + 1;
+ if (fd >= xf86SigIOMaxFd)
+ xf86SigIOMaxFd = fd + 1;
+ FD_SET(fd, &xf86SigIOMask);
+ xf86UnblockSIGIO(blocked);
+ return 1;
+ }
+ /* Allow overwriting of the closure and callback */
+ else if (xf86SigIOFuncs[i].fd == fd) {
+ xf86SigIOFuncs[i].closure = closure;
+ xf86SigIOFuncs[i].f = f;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int
+xf86RemoveSIGIOHandler(int fd)
+{
+ struct sigaction sa;
+ struct sigaction osa;
+ int i;
+ int max;
+ int maxfd;
+ int ret;
+
+ if (!xf86Info.useSIGIO)
+ return 0;
+
+ max = 0;
+ maxfd = -1;
+ ret = 0;
+ for (i = 0; i < MAX_FUNCS; i++) {
+ if (xf86SigIOFuncs[i].f) {
+ if (xf86SigIOFuncs[i].fd == fd) {
+ xf86SigIOFuncs[i].f = 0;
+ xf86SigIOFuncs[i].fd = 0;
+ xf86SigIOFuncs[i].closure = 0;
+ FD_CLR(fd, &xf86SigIOMask);
+ ret = 1;
+ }
+ else {
+ max = i + 1;
+ if (xf86SigIOFuncs[i].fd >= maxfd)
+ maxfd = xf86SigIOFuncs[i].fd + 1;
+ }
+ }
+ }
+ if (ret) {
+#ifdef O_ASYNC
+ fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_ASYNC);
+#endif
+#ifdef I_SETSIG
+ if (isastream(fd)) {
+ if (ioctl(fd, I_SETSIG, 0) == -1) {
+ xf86Msg(X_WARNING, "fcntl(%d, I_SETSIG, 0): %s\n",
+ fd, strerror(errno));
+ }
+ }
+#endif
+ xf86SigIOMax = max;
+ xf86SigIOMaxFd = maxfd;
+ if (!max) {
+ sigemptyset(&sa.sa_mask);
+ sigaddset(&sa.sa_mask, SIGIO);
+ sa.sa_flags = 0;
+ sa.sa_handler = SIG_IGN;
+ sigaction(SIGIO, &sa, &osa);
+ }
+ }
+ return ret;
+}
+
+int
+xf86BlockSIGIO(void)
+{
+ sigset_t set, old;
+ int ret;
+
+ sigemptyset(&set);
+ sigaddset(&set, SIGIO);
+ sigprocmask(SIG_BLOCK, &set, &old);
+ ret = sigismember(&old, SIGIO);
+ return ret;
+}
+
+void
+xf86UnblockSIGIO(int wasset)
+{
+ sigset_t set;
+
+ if (!wasset) {
+ sigemptyset(&set);
+ sigaddset(&set, SIGIO);
+ sigprocmask(SIG_UNBLOCK, &set, NULL);
+ }
+}
+
+void
+xf86AssertBlockedSIGIO(char *where)
+{
+ sigset_t set, old;
+
+ sigemptyset(&set);
+ sigprocmask(SIG_BLOCK, &set, &old);
+ if (!sigismember(&old, SIGIO))
+ xf86Msg(X_ERROR, "SIGIO not blocked at %s\n", where);
+}
+
+/* XXX This is a quick hack for the benefit of xf86SetSilkenMouse() */
+
+int
+xf86SIGIOSupported(void)
+{
+ return 1;
+}
diff --git a/xorg-server/hw/xfree86/os-support/shared/vidmem.c b/xorg-server/hw/xfree86/os-support/shared/vidmem.c
index 54f6c6497..a7717d8f6 100644
--- a/xorg-server/hw/xfree86/os-support/shared/vidmem.c
+++ b/xorg-server/hw/xfree86/os-support/shared/vidmem.c
@@ -25,7 +25,6 @@
* authorization from the copyright holder(s) and author(s).
*/
-
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
@@ -51,240 +50,236 @@
*/
typedef struct {
- unsigned long size;
- pointer virtBase;
- pointer mtrrInfo;
+ unsigned long size;
+ pointer virtBase;
+ pointer mtrrInfo;
} MappingRec, *MappingPtr;
-
+
typedef struct {
- int numMappings;
- MappingPtr * mappings;
- Bool mtrrEnabled;
- MessageType mtrrFrom;
- Bool mtrrOptChecked;
- ScrnInfoPtr pScrn;
+ int numMappings;
+ MappingPtr *mappings;
+ Bool mtrrEnabled;
+ MessageType mtrrFrom;
+ Bool mtrrOptChecked;
+ ScrnInfoPtr pScrn;
} VidMapRec, *VidMapPtr;
static int vidMapIndex = -1;
#define VIDMAPPTR(p) ((VidMapPtr)((p)->privates[vidMapIndex].ptr))
-static VidMemInfo vidMemInfo = {FALSE, };
-static VidMapRec vidMapRec = {0, NULL, TRUE, X_DEFAULT, FALSE, NULL};
+static VidMemInfo vidMemInfo = { FALSE, };
+static VidMapRec vidMapRec = { 0, NULL, TRUE, X_DEFAULT, FALSE, NULL };
static VidMapPtr
getVidMapRec(int scrnIndex)
{
- VidMapPtr vp;
- ScrnInfoPtr pScrn;
+ VidMapPtr vp;
+ ScrnInfoPtr pScrn;
- if ((scrnIndex < 0) ||
- !(pScrn = xf86Screens[scrnIndex]))
- return &vidMapRec;
+ if ((scrnIndex < 0) || !(pScrn = xf86Screens[scrnIndex]))
+ return &vidMapRec;
- if (vidMapIndex < 0)
- vidMapIndex = xf86AllocateScrnInfoPrivateIndex();
+ if (vidMapIndex < 0)
+ vidMapIndex = xf86AllocateScrnInfoPrivateIndex();
- if (VIDMAPPTR(pScrn) != NULL)
- return VIDMAPPTR(pScrn);
+ if (VIDMAPPTR(pScrn) != NULL)
+ return VIDMAPPTR(pScrn);
- vp = pScrn->privates[vidMapIndex].ptr = xnfcalloc(sizeof(VidMapRec), 1);
- vp->mtrrEnabled = TRUE; /* default to enabled */
- vp->mtrrFrom = X_DEFAULT;
- vp->mtrrOptChecked = FALSE;
- vp->pScrn = pScrn;
- return vp;
+ vp = pScrn->privates[vidMapIndex].ptr = xnfcalloc(sizeof(VidMapRec), 1);
+ vp->mtrrEnabled = TRUE; /* default to enabled */
+ vp->mtrrFrom = X_DEFAULT;
+ vp->mtrrOptChecked = FALSE;
+ vp->pScrn = pScrn;
+ return vp;
}
static MappingPtr
newMapping(VidMapPtr vp)
{
- vp->mappings = xnfrealloc(vp->mappings, sizeof(MappingPtr) *
- (vp->numMappings + 1));
- vp->mappings[vp->numMappings] = xnfcalloc(sizeof(MappingRec), 1);
- return vp->mappings[vp->numMappings++];
+ vp->mappings = xnfrealloc(vp->mappings, sizeof(MappingPtr) *
+ (vp->numMappings + 1));
+ vp->mappings[vp->numMappings] = xnfcalloc(sizeof(MappingRec), 1);
+ return vp->mappings[vp->numMappings++];
}
static MappingPtr
findMapping(VidMapPtr vp, pointer vbase, unsigned long size)
{
- int i;
-
- for (i = 0; i < vp->numMappings; i++) {
- if (vp->mappings[i]->virtBase == vbase &&
- vp->mappings[i]->size == size)
- return vp->mappings[i];
- }
- return NULL;
+ int i;
+
+ for (i = 0; i < vp->numMappings; i++) {
+ if (vp->mappings[i]->virtBase == vbase && vp->mappings[i]->size == size)
+ return vp->mappings[i];
+ }
+ return NULL;
}
static void
removeMapping(VidMapPtr vp, MappingPtr mp)
{
- int i, found = 0;
-
- for (i = 0; i < vp->numMappings; i++) {
- if (vp->mappings[i] == mp) {
- found = 1;
- free(vp->mappings[i]);
- } else if (found) {
- vp->mappings[i - 1] = vp->mappings[i];
- }
- }
- vp->numMappings--;
- vp->mappings[vp->numMappings] = NULL;
+ int i, found = 0;
+
+ for (i = 0; i < vp->numMappings; i++) {
+ if (vp->mappings[i] == mp) {
+ found = 1;
+ free(vp->mappings[i]);
+ }
+ else if (found) {
+ vp->mappings[i - 1] = vp->mappings[i];
+ }
+ }
+ vp->numMappings--;
+ vp->mappings[vp->numMappings] = NULL;
}
enum { OPTION_MTRR };
-static const OptionInfoRec opts[] =
-{
- { OPTION_MTRR, "mtrr", OPTV_BOOLEAN, {0}, FALSE },
- { -1, NULL, OPTV_NONE, {0}, FALSE }
+
+static const OptionInfoRec opts[] = {
+ {OPTION_MTRR, "mtrr", OPTV_BOOLEAN, {0}, FALSE},
+ {-1, NULL, OPTV_NONE, {0}, FALSE}
};
static void
checkMtrrOption(VidMapPtr vp)
{
- if (!vp->mtrrOptChecked && vp->pScrn && vp->pScrn->options != NULL) {
- OptionInfoPtr options;
-
- options = xnfalloc(sizeof(opts));
- (void)memcpy(options, opts, sizeof(opts));
- xf86ProcessOptions(vp->pScrn->scrnIndex, vp->pScrn->options,
- options);
- if (xf86GetOptValBool(options, OPTION_MTRR, &vp->mtrrEnabled))
- vp->mtrrFrom = X_CONFIG;
- free(options);
- vp->mtrrOptChecked = TRUE;
- }
+ if (!vp->mtrrOptChecked && vp->pScrn && vp->pScrn->options != NULL) {
+ OptionInfoPtr options;
+
+ options = xnfalloc(sizeof(opts));
+ (void) memcpy(options, opts, sizeof(opts));
+ xf86ProcessOptions(vp->pScrn->scrnIndex, vp->pScrn->options, options);
+ if (xf86GetOptValBool(options, OPTION_MTRR, &vp->mtrrEnabled))
+ vp->mtrrFrom = X_CONFIG;
+ free(options);
+ vp->mtrrOptChecked = TRUE;
+ }
}
void
-xf86MakeNewMapping(int ScreenNum, int Flags, unsigned long Base, unsigned long Size, pointer Vbase)
+xf86MakeNewMapping(int ScreenNum, int Flags, unsigned long Base,
+ unsigned long Size, pointer Vbase)
{
- VidMapPtr vp;
- MappingPtr mp;
+ VidMapPtr vp;
+ MappingPtr mp;
- vp = getVidMapRec(ScreenNum);
- mp = newMapping(vp);
- mp->size = Size;
- mp->virtBase = Vbase;
+ vp = getVidMapRec(ScreenNum);
+ mp = newMapping(vp);
+ mp->size = Size;
+ mp->virtBase = Vbase;
}
void
xf86InitVidMem(void)
{
- if (!vidMemInfo.initialised) {
- memset(&vidMemInfo, 0, sizeof(VidMemInfo));
- xf86OSInitVidMem(&vidMemInfo);
- }
+ if (!vidMemInfo.initialised) {
+ memset(&vidMemInfo, 0, sizeof(VidMemInfo));
+ xf86OSInitVidMem(&vidMemInfo);
+ }
}
pointer
xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size)
{
- pointer vbase = NULL;
- VidMapPtr vp;
- MappingPtr mp;
-
- if (((Flags & VIDMEM_FRAMEBUFFER) &&
- (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT))))
- FatalError("Mapping memory with more than one type\n");
-
- xf86InitVidMem();
- if (!vidMemInfo.initialised || !vidMemInfo.mapMem)
- return NULL;
-
- vbase = vidMemInfo.mapMem(ScreenNum, Base, Size, Flags);
-
- if (!vbase || vbase == (pointer)-1)
- return NULL;
-
- vp = getVidMapRec(ScreenNum);
- mp = newMapping(vp);
- mp->size = Size;
- mp->virtBase = vbase;
-
- /*
- * Check the "mtrr" option even when MTRR isn't supported to avoid
- * warnings about unrecognised options.
- */
- checkMtrrOption(vp);
-
- if (vp->mtrrEnabled && vidMemInfo.setWC) {
- if (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT))
- mp->mtrrInfo =
- vidMemInfo.setWC(ScreenNum, Base, Size, FALSE,
- vp->mtrrFrom);
- else if (Flags & VIDMEM_FRAMEBUFFER)
- mp->mtrrInfo =
- vidMemInfo.setWC(ScreenNum, Base, Size, TRUE,
- vp->mtrrFrom);
- }
- return vbase;
+ pointer vbase = NULL;
+ VidMapPtr vp;
+ MappingPtr mp;
+
+ if (((Flags & VIDMEM_FRAMEBUFFER) &&
+ (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT))))
+ FatalError("Mapping memory with more than one type\n");
+
+ xf86InitVidMem();
+ if (!vidMemInfo.initialised || !vidMemInfo.mapMem)
+ return NULL;
+
+ vbase = vidMemInfo.mapMem(ScreenNum, Base, Size, Flags);
+
+ if (!vbase || vbase == (pointer) -1)
+ return NULL;
+
+ vp = getVidMapRec(ScreenNum);
+ mp = newMapping(vp);
+ mp->size = Size;
+ mp->virtBase = vbase;
+
+ /*
+ * Check the "mtrr" option even when MTRR isn't supported to avoid
+ * warnings about unrecognised options.
+ */
+ checkMtrrOption(vp);
+
+ if (vp->mtrrEnabled && vidMemInfo.setWC) {
+ if (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT))
+ mp->mtrrInfo =
+ vidMemInfo.setWC(ScreenNum, Base, Size, FALSE, vp->mtrrFrom);
+ else if (Flags & VIDMEM_FRAMEBUFFER)
+ mp->mtrrInfo =
+ vidMemInfo.setWC(ScreenNum, Base, Size, TRUE, vp->mtrrFrom);
+ }
+ return vbase;
}
void
xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
{
- VidMapPtr vp;
- MappingPtr mp;
-
- if (!vidMemInfo.initialised || !vidMemInfo.unmapMem) {
- xf86DrvMsg(ScreenNum, X_WARNING,
- "xf86UnMapVidMem() called before xf86MapVidMem()\n");
- return;
- }
-
- vp = getVidMapRec(ScreenNum);
- mp = findMapping(vp, Base, Size);
- if (!mp) {
- xf86DrvMsg(ScreenNum, X_WARNING,
- "xf86UnMapVidMem: cannot find region for [%p,0x%lx]\n",
- Base, Size);
- return;
- }
- if (vp->mtrrEnabled && vidMemInfo.undoWC && mp)
- vidMemInfo.undoWC(ScreenNum, mp->mtrrInfo);
-
- vidMemInfo.unmapMem(ScreenNum, Base, Size);
- removeMapping(vp, mp);
+ VidMapPtr vp;
+ MappingPtr mp;
+
+ if (!vidMemInfo.initialised || !vidMemInfo.unmapMem) {
+ xf86DrvMsg(ScreenNum, X_WARNING,
+ "xf86UnMapVidMem() called before xf86MapVidMem()\n");
+ return;
+ }
+
+ vp = getVidMapRec(ScreenNum);
+ mp = findMapping(vp, Base, Size);
+ if (!mp) {
+ xf86DrvMsg(ScreenNum, X_WARNING,
+ "xf86UnMapVidMem: cannot find region for [%p,0x%lx]\n",
+ Base, Size);
+ return;
+ }
+ if (vp->mtrrEnabled && vidMemInfo.undoWC && mp)
+ vidMemInfo.undoWC(ScreenNum, mp->mtrrInfo);
+
+ vidMemInfo.unmapMem(ScreenNum, Base, Size);
+ removeMapping(vp, mp);
}
Bool
xf86CheckMTRR(int ScreenNum)
{
- VidMapPtr vp = getVidMapRec(ScreenNum);
-
- /*
- * Check the "mtrr" option even when MTRR isn't supported to avoid
- * warnings about unrecognised options.
- */
- checkMtrrOption(vp);
-
- if (vp->mtrrEnabled && vidMemInfo.setWC)
- return TRUE;
-
- return FALSE;
+ VidMapPtr vp = getVidMapRec(ScreenNum);
+
+ /*
+ * Check the "mtrr" option even when MTRR isn't supported to avoid
+ * warnings about unrecognised options.
+ */
+ checkMtrrOption(vp);
+
+ if (vp->mtrrEnabled && vidMemInfo.setWC)
+ return TRUE;
+
+ return FALSE;
}
Bool
xf86LinearVidMem(void)
{
- xf86InitVidMem();
- return vidMemInfo.linearSupported;
+ xf86InitVidMem();
+ return vidMemInfo.linearSupported;
}
void
xf86MapReadSideEffects(int ScreenNum, int Flags, pointer base,
- unsigned long Size)
+ unsigned long Size)
{
- if (!(Flags & VIDMEM_READSIDEEFFECT))
- return;
+ if (!(Flags & VIDMEM_READSIDEEFFECT))
+ return;
- if (!vidMemInfo.initialised || !vidMemInfo.readSideEffects)
- return;
+ if (!vidMemInfo.initialised || !vidMemInfo.readSideEffects)
+ return;
- vidMemInfo.readSideEffects(ScreenNum, base, Size);
+ vidMemInfo.readSideEffects(ScreenNum, base, Size);
}
-
diff --git a/xorg-server/hw/xfree86/os-support/shared/xf86Axp.c b/xorg-server/hw/xfree86/os-support/shared/xf86Axp.c
index e6511dd43..5f2f3985e 100644
--- a/xorg-server/hw/xfree86/os-support/shared/xf86Axp.c
+++ b/xorg-server/hw/xfree86/os-support/shared/xf86Axp.c
@@ -31,19 +31,30 @@
#include "xf86Axp.h"
-axpParams xf86AXPParams[] = {
- {SYS_NONE, 0, 0, 0},
- {TSUNAMI, 0, 0, 0},
- {LCA, 1<<24,0xf8000000, 1UL << 32},
- {APECS, 1<<24,0xf8000000, 1UL << 32},
- {T2, 0,0xFC000000, 1UL << 31},
- {T2_GAMMA, 0,0xFC000000, 1UL << 31},
- {CIA, 0,0xE0000000, 1UL << 34},
- {MCPCIA, 0,0xf8000000, 1UL << 31},
- {JENSEN, 0, 0xE000000, 1UL << 32},
- {POLARIS, 0, 0, 0},
- {PYXIS, 0, 0, 0},
- {PYXIS_CIA, 0,0xE0000000, 1UL << 34},
- {IRONGATE, 0, 0, 0}
+axpParams xf86AXPParams[] = {
+ {SYS_NONE, 0, 0, 0}
+ ,
+ {TSUNAMI, 0, 0, 0}
+ ,
+ {LCA, 1 << 24, 0xf8000000, 1UL << 32}
+ ,
+ {APECS, 1 << 24, 0xf8000000, 1UL << 32}
+ ,
+ {T2, 0, 0xFC000000, 1UL << 31}
+ ,
+ {T2_GAMMA, 0, 0xFC000000, 1UL << 31}
+ ,
+ {CIA, 0, 0xE0000000, 1UL << 34}
+ ,
+ {MCPCIA, 0, 0xf8000000, 1UL << 31}
+ ,
+ {JENSEN, 0, 0xE000000, 1UL << 32}
+ ,
+ {POLARIS, 0, 0, 0}
+ ,
+ {PYXIS, 0, 0, 0}
+ ,
+ {PYXIS_CIA, 0, 0xE0000000, 1UL << 34}
+ ,
+ {IRONGATE, 0, 0, 0}
};
-
diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_VTsw.c b/xorg-server/hw/xfree86/os-support/solaris/sun_VTsw.c
index d145ac77b..573358b43 100644
--- a/xorg-server/hw/xfree86/os-support/solaris/sun_VTsw.c
+++ b/xorg-server/hw/xfree86/os-support/solaris/sun_VTsw.c
@@ -1,137 +1,134 @@
-/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#include <door.h>
-#include <sys/vtdaemon.h>
-
-/*
- * Handle the VT-switching interface for Solaris/OpenSolaris
- */
-
-static int xf86VTPruneDoor = 0;
-
-void
-xf86VTRelease(int sig)
-{
- if (xf86Info.vtPendingNum == -1)
- {
- xf86VTPruneDoor = 1;
- xf86Info.vtRequestsPending = TRUE;
- return;
- }
-
- ioctl(xf86Info.consoleFd, VT_RELDISP, 1);
- xf86Info.vtPendingNum = -1;
-
- return;
-}
-
-void
-xf86VTAcquire(int sig)
-{
- xf86Info.vtRequestsPending = TRUE;
- return;
-}
-
-Bool
-xf86VTSwitchPending(void)
-{
- return xf86Info.vtRequestsPending ? TRUE : FALSE;
-}
-
-Bool
-xf86VTSwitchAway(void)
-{
- int door_fd;
- vt_cmd_arg_t vt_door_arg;
- door_arg_t door_arg;
-
- xf86Info.vtRequestsPending = FALSE;
-
- if (xf86VTPruneDoor) {
- xf86VTPruneDoor = 0;
- ioctl(xf86Info.consoleFd, VT_RELDISP, 1);
- return TRUE;
- }
-
- vt_door_arg.vt_ev = VT_EV_HOTKEYS;
- vt_door_arg.vt_num = xf86Info.vtPendingNum;
- door_arg.data_ptr = (char *)&vt_door_arg;
- door_arg.data_size = sizeof (vt_cmd_arg_t);
- door_arg.rbuf = NULL;
- door_arg.rsize = 0;
- door_arg.desc_ptr = NULL;
- door_arg.desc_num = 0;
-
- if ((door_fd = open(VT_DAEMON_DOOR_FILE, O_RDONLY)) < 0)
- return FALSE;
-
- if (door_call(door_fd, &door_arg) != 0) {
- close(door_fd);
- return FALSE;
- }
-
- close(door_fd);
- return TRUE;
-}
-
-Bool
-xf86VTSwitchTo(void)
-{
- xf86Info.vtRequestsPending = FALSE;
- if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
- {
- return FALSE;
- }
- else
- {
- return TRUE;
- }
-}
-
-Bool
-xf86VTActivate(int vtno)
-{
- struct vt_stat state;
-
- if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &state) < 0)
- return FALSE;
-
- if ((state.v_state & (1 << vtno)) == 0)
- return FALSE;
-
- xf86Info.vtRequestsPending = TRUE;
- xf86Info.vtPendingNum = vtno;
-
- return TRUE;
-}
+/*
+ * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include <door.h>
+#include <sys/vtdaemon.h>
+
+/*
+ * Handle the VT-switching interface for Solaris/OpenSolaris
+ */
+
+static int xf86VTPruneDoor = 0;
+
+void
+xf86VTRelease(int sig)
+{
+ if (xf86Info.vtPendingNum == -1) {
+ xf86VTPruneDoor = 1;
+ xf86Info.vtRequestsPending = TRUE;
+ return;
+ }
+
+ ioctl(xf86Info.consoleFd, VT_RELDISP, 1);
+ xf86Info.vtPendingNum = -1;
+
+ return;
+}
+
+void
+xf86VTAcquire(int sig)
+{
+ xf86Info.vtRequestsPending = TRUE;
+ return;
+}
+
+Bool
+xf86VTSwitchPending(void)
+{
+ return xf86Info.vtRequestsPending ? TRUE : FALSE;
+}
+
+Bool
+xf86VTSwitchAway(void)
+{
+ int door_fd;
+ vt_cmd_arg_t vt_door_arg;
+ door_arg_t door_arg;
+
+ xf86Info.vtRequestsPending = FALSE;
+
+ if (xf86VTPruneDoor) {
+ xf86VTPruneDoor = 0;
+ ioctl(xf86Info.consoleFd, VT_RELDISP, 1);
+ return TRUE;
+ }
+
+ vt_door_arg.vt_ev = VT_EV_HOTKEYS;
+ vt_door_arg.vt_num = xf86Info.vtPendingNum;
+ door_arg.data_ptr = (char *) &vt_door_arg;
+ door_arg.data_size = sizeof(vt_cmd_arg_t);
+ door_arg.rbuf = NULL;
+ door_arg.rsize = 0;
+ door_arg.desc_ptr = NULL;
+ door_arg.desc_num = 0;
+
+ if ((door_fd = open(VT_DAEMON_DOOR_FILE, O_RDONLY)) < 0)
+ return FALSE;
+
+ if (door_call(door_fd, &door_arg) != 0) {
+ close(door_fd);
+ return FALSE;
+ }
+
+ close(door_fd);
+ return TRUE;
+}
+
+Bool
+xf86VTSwitchTo(void)
+{
+ xf86Info.vtRequestsPending = FALSE;
+ if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) {
+ return FALSE;
+ }
+ else {
+ return TRUE;
+ }
+}
+
+Bool
+xf86VTActivate(int vtno)
+{
+ struct vt_stat state;
+
+ if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &state) < 0)
+ return FALSE;
+
+ if ((state.v_state & (1 << vtno)) == 0)
+ return FALSE;
+
+ xf86Info.vtRequestsPending = TRUE;
+ xf86Info.vtPendingNum = vtno;
+
+ return TRUE;
+}
diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_apm.c b/xorg-server/hw/xfree86/os-support/solaris/sun_apm.c
index 7a5128ffb..4ff64649a 100644
--- a/xorg-server/hw/xfree86/os-support/solaris/sun_apm.c
+++ b/xorg-server/hw/xfree86/os-support/solaris/sun_apm.c
@@ -1,226 +1,227 @@
-/* Based on hw/xfree86/os-support/bsd/bsd_apm.c which bore no explicit
- * copyright notice, so is covered by the following notice:
- *
- * Copyright (C) 1994-2003 The XFree86 Project, Inc. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the XFree86 Project shall
- * not be used in advertising or otherwise to promote the sale, use or other
- * dealings in this Software without prior written authorization from the
- * XFree86 Project.
- */
-
-/* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "os.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#define XF86_OS_PRIVS
-#include "xf86_OSproc.h"
-#include "xf86_OSlib.h"
-
-#ifndef PLEASE_FIX_THIS
-#define APM_STANDBY_REQ 0xa01
-#define APM_SUSPEND_REQ 0xa02
-#define APM_NORMAL_RESUME 0xa03
-#define APM_CRIT_RESUME 0xa04
-#define APM_BATTERY_LOW 0xa05
-#define APM_POWER_CHANGE 0xa06
-#define APM_UPDATE_TIME 0xa07
-#define APM_CRIT_SUSPEND_REQ 0xa08
-#define APM_USER_STANDBY_REQ 0xa09
-#define APM_USER_SUSPEND_REQ 0xa0a
-#define APM_SYS_STANDBY_RESUME 0xa0b
-#define APM_IOC_NEXTEVENT 0xa0c
-#define APM_IOC_RESUME 0xa0d
-#define APM_IOC_SUSPEND 0xa0e
-#define APM_IOC_STANDBY 0xa0f
-#endif
-
-typedef struct apm_event_info
-{
- int type;
-} apm_event_info;
-
-/*
- This may be replaced with a better device name
- very soon...
-*/
-#define APM_DEVICE "/dev/srn"
-#define APM_DEVICE1 "/dev/apm"
-
-static pointer APMihPtr = NULL;
-static void sunCloseAPM(void);
-
-static struct {
- u_int apmBsd;
- pmEvent xf86;
-} sunToXF86Array [] = {
- { APM_STANDBY_REQ, XF86_APM_SYS_STANDBY },
- { APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND },
- { APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME },
- { APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME },
- { APM_BATTERY_LOW, XF86_APM_LOW_BATTERY },
- { APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE },
- { APM_UPDATE_TIME, XF86_APM_UPDATE_TIME },
- { APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND },
- { APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY },
- { APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND },
- { APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME },
-#ifdef APM_CAPABILITY_CHANGE
- { APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED },
-#endif
-};
-
-#define numApmEvents (sizeof(sunToXF86Array) / sizeof(sunToXF86Array[0]))
-
-static pmEvent
-sunToXF86(int type)
-{
- int i;
-
- for (i = 0; i < numApmEvents; i++) {
- if (type == sunToXF86Array[i].apmBsd) {
- return sunToXF86Array[i].xf86;
- }
- }
- return XF86_APM_UNKNOWN;
-}
-
-/*
- * APM events can be requested direclty from /dev/apm
- */
-static int
-sunPMGetEventFromOS(int fd, pmEvent *events, int num)
-{
- struct apm_event_info sunEvent;
- int i;
-
- for (i = 0; i < num; i++) {
-
- if (ioctl(fd, APM_IOC_NEXTEVENT, &sunEvent) < 0) {
- if (errno != EAGAIN) {
- xf86Msg(X_WARNING, "sunPMGetEventFromOS: APM_IOC_NEXTEVENT"
- " %s\n", strerror(errno));
- }
- break;
- }
- events[i] = sunToXF86(sunEvent.type);
- }
- xf86Msg(X_WARNING, "Got some events\n");
- return i;
-}
-
-static pmWait
-sunPMConfirmEventToOs(int fd, pmEvent event)
-{
- switch (event) {
-/* XXX: NOT CURRENTLY RETURNED FROM OS */
- case XF86_APM_SYS_STANDBY:
- case XF86_APM_USER_STANDBY:
- if (ioctl( fd, APM_IOC_STANDBY, NULL ) == 0)
- return PM_WAIT; /* should we stop the Xserver in standby, too? */
- else
- return PM_NONE;
- case XF86_APM_SYS_SUSPEND:
- case XF86_APM_CRITICAL_SUSPEND:
- case XF86_APM_USER_SUSPEND:
- xf86Msg(X_WARNING, "Got SUSPENDED\n");
- if (ioctl( fd, APM_IOC_SUSPEND, NULL ) == 0)
- return PM_CONTINUE;
- else {
- xf86Msg(X_WARNING, "sunPMConfirmEventToOs: APM_IOC_SUSPEND"
- " %s\n", strerror(errno));
- return PM_FAILED;
- }
- case XF86_APM_STANDBY_RESUME:
- case XF86_APM_NORMAL_RESUME:
- case XF86_APM_CRITICAL_RESUME:
- case XF86_APM_STANDBY_FAILED:
- case XF86_APM_SUSPEND_FAILED:
- xf86Msg(X_WARNING, "Got RESUME\n");
- if (ioctl( fd, APM_IOC_RESUME, NULL ) == 0)
- return PM_CONTINUE;
- else {
- xf86Msg(X_WARNING, "sunPMConfirmEventToOs: APM_IOC_RESUME"
- " %s\n", strerror(errno));
- return PM_FAILED;
- }
- default:
- return PM_NONE;
- }
-}
-
-PMClose
-xf86OSPMOpen(void)
-{
- int fd;
-
- if (APMihPtr || !xf86Info.pmFlag) {
- return NULL;
- }
-
- if ((fd = open(APM_DEVICE, O_RDWR)) == -1) {
- if ((fd = open(APM_DEVICE1, O_RDWR)) == -1) {
- return NULL;
- }
- }
- xf86PMGetEventFromOs = sunPMGetEventFromOS;
- xf86PMConfirmEventToOs = sunPMConfirmEventToOs;
- APMihPtr = xf86AddGeneralHandler(fd, xf86HandlePMEvents, NULL);
- return sunCloseAPM;
-}
-
-static void
-sunCloseAPM(void)
-{
- int fd;
-
- if (APMihPtr) {
- fd = xf86RemoveGeneralHandler(APMihPtr);
- close(fd);
- APMihPtr = NULL;
- }
-}
+/* Based on hw/xfree86/os-support/bsd/bsd_apm.c which bore no explicit
+ * copyright notice, so is covered by the following notice:
+ *
+ * Copyright (C) 1994-2003 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+/* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#define XF86_OS_PRIVS
+#include "xf86_OSproc.h"
+#include "xf86_OSlib.h"
+
+#ifndef PLEASE_FIX_THIS
+#define APM_STANDBY_REQ 0xa01
+#define APM_SUSPEND_REQ 0xa02
+#define APM_NORMAL_RESUME 0xa03
+#define APM_CRIT_RESUME 0xa04
+#define APM_BATTERY_LOW 0xa05
+#define APM_POWER_CHANGE 0xa06
+#define APM_UPDATE_TIME 0xa07
+#define APM_CRIT_SUSPEND_REQ 0xa08
+#define APM_USER_STANDBY_REQ 0xa09
+#define APM_USER_SUSPEND_REQ 0xa0a
+#define APM_SYS_STANDBY_RESUME 0xa0b
+#define APM_IOC_NEXTEVENT 0xa0c
+#define APM_IOC_RESUME 0xa0d
+#define APM_IOC_SUSPEND 0xa0e
+#define APM_IOC_STANDBY 0xa0f
+#endif
+
+typedef struct apm_event_info {
+ int type;
+} apm_event_info;
+
+/*
+ This may be replaced with a better device name
+ very soon...
+*/
+#define APM_DEVICE "/dev/srn"
+#define APM_DEVICE1 "/dev/apm"
+
+static pointer APMihPtr = NULL;
+static void sunCloseAPM(void);
+
+static struct {
+ u_int apmBsd;
+ pmEvent xf86;
+} sunToXF86Array[] = {
+ {
+ APM_STANDBY_REQ, XF86_APM_SYS_STANDBY}, {
+ APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND}, {
+ APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, {
+ APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME}, {
+ APM_BATTERY_LOW, XF86_APM_LOW_BATTERY}, {
+ APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, {
+ APM_UPDATE_TIME, XF86_APM_UPDATE_TIME}, {
+ APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND}, {
+ APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY}, {
+ APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND}, {
+ APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME},
+#ifdef APM_CAPABILITY_CHANGE
+ {
+ APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED},
+#endif
+};
+
+#define numApmEvents (sizeof(sunToXF86Array) / sizeof(sunToXF86Array[0]))
+
+static pmEvent
+sunToXF86(int type)
+{
+ int i;
+
+ for (i = 0; i < numApmEvents; i++) {
+ if (type == sunToXF86Array[i].apmBsd) {
+ return sunToXF86Array[i].xf86;
+ }
+ }
+ return XF86_APM_UNKNOWN;
+}
+
+/*
+ * APM events can be requested direclty from /dev/apm
+ */
+static int
+sunPMGetEventFromOS(int fd, pmEvent * events, int num)
+{
+ struct apm_event_info sunEvent;
+ int i;
+
+ for (i = 0; i < num; i++) {
+
+ if (ioctl(fd, APM_IOC_NEXTEVENT, &sunEvent) < 0) {
+ if (errno != EAGAIN) {
+ xf86Msg(X_WARNING, "sunPMGetEventFromOS: APM_IOC_NEXTEVENT"
+ " %s\n", strerror(errno));
+ }
+ break;
+ }
+ events[i] = sunToXF86(sunEvent.type);
+ }
+ xf86Msg(X_WARNING, "Got some events\n");
+ return i;
+}
+
+static pmWait
+sunPMConfirmEventToOs(int fd, pmEvent event)
+{
+ switch (event) {
+/* XXX: NOT CURRENTLY RETURNED FROM OS */
+ case XF86_APM_SYS_STANDBY:
+ case XF86_APM_USER_STANDBY:
+ if (ioctl(fd, APM_IOC_STANDBY, NULL) == 0)
+ return PM_WAIT; /* should we stop the Xserver in standby, too? */
+ else
+ return PM_NONE;
+ case XF86_APM_SYS_SUSPEND:
+ case XF86_APM_CRITICAL_SUSPEND:
+ case XF86_APM_USER_SUSPEND:
+ xf86Msg(X_WARNING, "Got SUSPENDED\n");
+ if (ioctl(fd, APM_IOC_SUSPEND, NULL) == 0)
+ return PM_CONTINUE;
+ else {
+ xf86Msg(X_WARNING, "sunPMConfirmEventToOs: APM_IOC_SUSPEND"
+ " %s\n", strerror(errno));
+ return PM_FAILED;
+ }
+ case XF86_APM_STANDBY_RESUME:
+ case XF86_APM_NORMAL_RESUME:
+ case XF86_APM_CRITICAL_RESUME:
+ case XF86_APM_STANDBY_FAILED:
+ case XF86_APM_SUSPEND_FAILED:
+ xf86Msg(X_WARNING, "Got RESUME\n");
+ if (ioctl(fd, APM_IOC_RESUME, NULL) == 0)
+ return PM_CONTINUE;
+ else {
+ xf86Msg(X_WARNING, "sunPMConfirmEventToOs: APM_IOC_RESUME"
+ " %s\n", strerror(errno));
+ return PM_FAILED;
+ }
+ default:
+ return PM_NONE;
+ }
+}
+
+PMClose
+xf86OSPMOpen(void)
+{
+ int fd;
+
+ if (APMihPtr || !xf86Info.pmFlag) {
+ return NULL;
+ }
+
+ if ((fd = open(APM_DEVICE, O_RDWR)) == -1) {
+ if ((fd = open(APM_DEVICE1, O_RDWR)) == -1) {
+ return NULL;
+ }
+ }
+ xf86PMGetEventFromOs = sunPMGetEventFromOS;
+ xf86PMConfirmEventToOs = sunPMConfirmEventToOs;
+ APMihPtr = xf86AddGeneralHandler(fd, xf86HandlePMEvents, NULL);
+ return sunCloseAPM;
+}
+
+static void
+sunCloseAPM(void)
+{
+ int fd;
+
+ if (APMihPtr) {
+ fd = xf86RemoveGeneralHandler(APMihPtr);
+ close(fd);
+ APMihPtr = NULL;
+ }
+}
diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_bell.c b/xorg-server/hw/xfree86/os-support/solaris/sun_bell.c
index 8cd4de25b..beb13d2e9 100644
--- a/xorg-server/hw/xfree86/os-support/solaris/sun_bell.c
+++ b/xorg-server/hw/xfree86/os-support/solaris/sun_bell.c
@@ -1,180 +1,183 @@
-/* Copyright (c) 2004-2005, Oracle and/or its affiliates. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <sys/audio.h>
-#include <sys/uio.h>
-#include <limits.h>
-#include <math.h>
-#include <poll.h>
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#define BELL_RATE 48000 /* Samples per second */
-#define BELL_HZ 50 /* Fraction of a second i.e. 1/x */
-#define BELL_MS (1000/BELL_HZ) /* MS */
-#define BELL_SAMPLES (BELL_RATE / BELL_HZ)
-#define BELL_MIN 3 /* Min # of repeats */
-
-#define AUDIO_DEVICE "/dev/audio"
-
-void
-xf86OSRingBell(int loudness, int pitch, int duration)
-{
- static short samples[BELL_SAMPLES];
- static short silence[BELL_SAMPLES]; /* "The Sound of Silence" */
- static int lastFreq;
- int cnt;
- int i;
- int written;
- int repeats;
- int freq;
- audio_info_t audioInfo;
- struct iovec iov[IOV_MAX];
- int iovcnt;
- double ampl, cyclen, phase;
- int audioFD;
-
- if ((loudness <= 0) || (pitch <= 0) || (duration <= 0)) {
- return;
- }
-
- lastFreq = 0;
- memset(silence, 0, sizeof(silence));
-
- audioFD = open(AUDIO_DEVICE, O_WRONLY | O_NONBLOCK);
- if (audioFD == -1) {
- xf86Msg(X_ERROR, "Bell: cannot open audio device \"%s\": %s\n",
- AUDIO_DEVICE, strerror(errno));
- return;
- }
-
- freq = pitch;
- freq = min(freq, (BELL_RATE / 2) - 1);
- freq = max(freq, 2 * BELL_HZ);
-
- /*
- * Ensure full waves per buffer
- */
- freq -= freq % BELL_HZ;
-
- if (freq != lastFreq) {
- lastFreq = freq;
- ampl = 16384.0;
-
- cyclen = (double) freq / (double) BELL_RATE;
- phase = 0.0;
-
- for (i = 0; i < BELL_SAMPLES; i++) {
- samples[i] = (short) (ampl * sin(2.0 * M_PI * phase));
- phase += cyclen;
- if (phase >= 1.0)
- phase -= 1.0;
- }
- }
-
- repeats = (duration + (BELL_MS / 2)) / BELL_MS;
- repeats = max(repeats, BELL_MIN);
-
- loudness = max(0, loudness);
- loudness = min(loudness, 100);
-
-#ifdef DEBUG
- ErrorF("BELL : freq %d volume %d duration %d repeats %d\n",
- freq, loudness, duration, repeats);
-#endif
-
- AUDIO_INITINFO(&audioInfo);
- audioInfo.play.encoding = AUDIO_ENCODING_LINEAR;
- audioInfo.play.sample_rate = BELL_RATE;
- audioInfo.play.channels = 2;
- audioInfo.play.precision = 16;
- audioInfo.play.gain = min(AUDIO_MAX_GAIN, AUDIO_MAX_GAIN * loudness / 100);
-
- if (ioctl(audioFD, AUDIO_SETINFO, &audioInfo) < 0){
- xf86Msg(X_ERROR,
- "Bell: AUDIO_SETINFO failed on audio device \"%s\": %s\n",
- AUDIO_DEVICE, strerror(errno));
- close(audioFD);
- return;
- }
-
- iovcnt = 0;
-
- for (cnt = 0; cnt <= repeats; cnt++) {
- if (cnt == repeats) {
- /* Insert a bit of silence so that multiple beeps are distinct and
- * not compressed into a single tone.
- */
- iov[iovcnt].iov_base = (char *) silence;
- iov[iovcnt++].iov_len = sizeof(silence);
- } else {
- iov[iovcnt].iov_base = (char *) samples;
- iov[iovcnt++].iov_len = sizeof(samples);
- }
- if ((iovcnt >= IOV_MAX) || (cnt == repeats)) {
- written = writev(audioFD, iov, iovcnt);
-
- if ((written < ((int)(sizeof(samples) * iovcnt)))) {
- /* audio buffer was full! */
-
- int naptime;
-
- if (written == -1) {
- if (errno != EAGAIN) {
- xf86Msg(X_ERROR,
- "Bell: writev failed on audio device \"%s\": %s\n",
- AUDIO_DEVICE, strerror(errno));
- close(audioFD);
- return;
- }
- i = iovcnt;
- } else {
- i = ((sizeof(samples) * iovcnt) - written)
- / sizeof(samples);
- }
- cnt -= i;
-
- /* sleep a little to allow audio buffer to drain */
- naptime = BELL_MS * i;
- poll(NULL, 0, naptime);
-
- i = ((sizeof(samples) * iovcnt) - written) % sizeof(samples);
- iovcnt = 0;
- if ((written != -1) && (i > 0)) {
- iov[iovcnt].iov_base = ((char *) samples) + i;
- iov[iovcnt++].iov_len = sizeof(samples) - i;
- }
- } else {
- iovcnt = 0;
- }
- }
- }
-
- close(audioFD);
- return;
-}
+/* Copyright (c) 2004-2005, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/audio.h>
+#include <sys/uio.h>
+#include <limits.h>
+#include <math.h>
+#include <poll.h>
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#define BELL_RATE 48000 /* Samples per second */
+#define BELL_HZ 50 /* Fraction of a second i.e. 1/x */
+#define BELL_MS (1000/BELL_HZ) /* MS */
+#define BELL_SAMPLES (BELL_RATE / BELL_HZ)
+#define BELL_MIN 3 /* Min # of repeats */
+
+#define AUDIO_DEVICE "/dev/audio"
+
+void
+xf86OSRingBell(int loudness, int pitch, int duration)
+{
+ static short samples[BELL_SAMPLES];
+ static short silence[BELL_SAMPLES]; /* "The Sound of Silence" */
+ static int lastFreq;
+ int cnt;
+ int i;
+ int written;
+ int repeats;
+ int freq;
+ audio_info_t audioInfo;
+ struct iovec iov[IOV_MAX];
+ int iovcnt;
+ double ampl, cyclen, phase;
+ int audioFD;
+
+ if ((loudness <= 0) || (pitch <= 0) || (duration <= 0)) {
+ return;
+ }
+
+ lastFreq = 0;
+ memset(silence, 0, sizeof(silence));
+
+ audioFD = open(AUDIO_DEVICE, O_WRONLY | O_NONBLOCK);
+ if (audioFD == -1) {
+ xf86Msg(X_ERROR, "Bell: cannot open audio device \"%s\": %s\n",
+ AUDIO_DEVICE, strerror(errno));
+ return;
+ }
+
+ freq = pitch;
+ freq = min(freq, (BELL_RATE / 2) - 1);
+ freq = max(freq, 2 * BELL_HZ);
+
+ /*
+ * Ensure full waves per buffer
+ */
+ freq -= freq % BELL_HZ;
+
+ if (freq != lastFreq) {
+ lastFreq = freq;
+ ampl = 16384.0;
+
+ cyclen = (double) freq / (double) BELL_RATE;
+ phase = 0.0;
+
+ for (i = 0; i < BELL_SAMPLES; i++) {
+ samples[i] = (short) (ampl * sin(2.0 * M_PI * phase));
+ phase += cyclen;
+ if (phase >= 1.0)
+ phase -= 1.0;
+ }
+ }
+
+ repeats = (duration + (BELL_MS / 2)) / BELL_MS;
+ repeats = max(repeats, BELL_MIN);
+
+ loudness = max(0, loudness);
+ loudness = min(loudness, 100);
+
+#ifdef DEBUG
+ ErrorF("BELL : freq %d volume %d duration %d repeats %d\n",
+ freq, loudness, duration, repeats);
+#endif
+
+ AUDIO_INITINFO(&audioInfo);
+ audioInfo.play.encoding = AUDIO_ENCODING_LINEAR;
+ audioInfo.play.sample_rate = BELL_RATE;
+ audioInfo.play.channels = 2;
+ audioInfo.play.precision = 16;
+ audioInfo.play.gain = min(AUDIO_MAX_GAIN, AUDIO_MAX_GAIN * loudness / 100);
+
+ if (ioctl(audioFD, AUDIO_SETINFO, &audioInfo) < 0) {
+ xf86Msg(X_ERROR,
+ "Bell: AUDIO_SETINFO failed on audio device \"%s\": %s\n",
+ AUDIO_DEVICE, strerror(errno));
+ close(audioFD);
+ return;
+ }
+
+ iovcnt = 0;
+
+ for (cnt = 0; cnt <= repeats; cnt++) {
+ if (cnt == repeats) {
+ /* Insert a bit of silence so that multiple beeps are distinct and
+ * not compressed into a single tone.
+ */
+ iov[iovcnt].iov_base = (char *) silence;
+ iov[iovcnt++].iov_len = sizeof(silence);
+ }
+ else {
+ iov[iovcnt].iov_base = (char *) samples;
+ iov[iovcnt++].iov_len = sizeof(samples);
+ }
+ if ((iovcnt >= IOV_MAX) || (cnt == repeats)) {
+ written = writev(audioFD, iov, iovcnt);
+
+ if ((written < ((int) (sizeof(samples) * iovcnt)))) {
+ /* audio buffer was full! */
+
+ int naptime;
+
+ if (written == -1) {
+ if (errno != EAGAIN) {
+ xf86Msg(X_ERROR,
+ "Bell: writev failed on audio device \"%s\": %s\n",
+ AUDIO_DEVICE, strerror(errno));
+ close(audioFD);
+ return;
+ }
+ i = iovcnt;
+ }
+ else {
+ i = ((sizeof(samples) * iovcnt) - written)
+ / sizeof(samples);
+ }
+ cnt -= i;
+
+ /* sleep a little to allow audio buffer to drain */
+ naptime = BELL_MS * i;
+ poll(NULL, 0, naptime);
+
+ i = ((sizeof(samples) * iovcnt) - written) % sizeof(samples);
+ iovcnt = 0;
+ if ((written != -1) && (i > 0)) {
+ iov[iovcnt].iov_base = ((char *) samples) + i;
+ iov[iovcnt++].iov_len = sizeof(samples) - i;
+ }
+ }
+ else {
+ iovcnt = 0;
+ }
+ }
+ }
+
+ close(audioFD);
+ return;
+}
diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_init.c b/xorg-server/hw/xfree86/os-support/solaris/sun_init.c
index 800fc1c3d..4b75a98ac 100644
--- a/xorg-server/hw/xfree86/os-support/solaris/sun_init.c
+++ b/xorg-server/hw/xfree86/os-support/solaris/sun_init.c
@@ -30,7 +30,7 @@
#include "xf86Priv.h"
#include "xf86_OSlib.h"
#ifdef HAVE_SYS_KD_H
-# include <sys/kd.h>
+#include <sys/kd.h>
#endif
/*
@@ -48,6 +48,7 @@
static Bool KeepTty = FALSE;
static Bool Protect0 = FALSE;
static Bool UseConsole = FALSE;
+
#ifdef HAS_USL_VTS
static int VTnum = -1;
static int xf86StartVT = -1;
@@ -71,18 +72,19 @@ switch_to(int vt, const char *from)
SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_ACTIVATE, vt));
if (ret != 0)
xf86Msg(X_WARNING, "%s: VT_ACTIVATE failed: %s\n",
- from, strerror(errno));
+ from, strerror(errno));
SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_WAITACTIVE, vt));
if (ret != 0)
xf86Msg(X_WARNING, "%s: VT_WAITACTIVE failed: %s\n",
- from, strerror(errno));
+ from, strerror(errno));
}
void
xf86OpenConsole(void)
{
int i;
+
#ifdef HAS_USL_VTS
int fd;
struct vt_mode VT;
@@ -90,209 +92,192 @@ xf86OpenConsole(void)
MessageType from = X_PROBED;
#endif
- if (serverGeneration == 1)
- {
- /* Check if we're run with euid==0 */
- if (geteuid() != 0)
- FatalError("xf86OpenConsole: Server must be suid root\n");
-
- /* Protect page 0 to help find NULL dereferencing */
- /* mprotect() doesn't seem to work */
- if (Protect0)
- {
- int fd = -1;
-
- if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0)
- {
- xf86Msg(X_WARNING,
- "xf86OpenConsole: cannot open /dev/zero (%s)\n",
- strerror(errno));
- }
- else
- {
- if (mmap(0, 0x1000, PROT_NONE,
- MAP_FIXED | MAP_SHARED, fd, 0) == MAP_FAILED)
- xf86Msg(X_WARNING,
- "xf86OpenConsole: failed to protect page 0 (%s)\n",
- strerror(errno));
-
- close(fd);
- }
- }
+ if (serverGeneration == 1) {
+ /* Check if we're run with euid==0 */
+ if (geteuid() != 0)
+ FatalError("xf86OpenConsole: Server must be suid root\n");
+
+ /* Protect page 0 to help find NULL dereferencing */
+ /* mprotect() doesn't seem to work */
+ if (Protect0) {
+ int fd = -1;
+
+ if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0) {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: cannot open /dev/zero (%s)\n",
+ strerror(errno));
+ }
+ else {
+ if (mmap(0, 0x1000, PROT_NONE,
+ MAP_FIXED | MAP_SHARED, fd, 0) == MAP_FAILED)
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: failed to protect page 0 (%s)\n",
+ strerror(errno));
+
+ close(fd);
+ }
+ }
#ifdef HAS_USL_VTS
- /*
- * Setup the virtual terminal manager
- */
- if ((fd = open("/dev/vt/0",O_RDWR,0)) == -1)
- {
- xf86ErrorF("xf86OpenConsole: Cannot open /dev/vt/0 (%s)\n",
- strerror(errno));
- vtEnabled = 0;
- }
- else
- {
- if (ioctl(fd, VT_ENABLED, &vtEnabled) < 0)
- {
- xf86ErrorF("xf86OpenConsole: VT_ENABLED failed (%s)\n",
- strerror(errno));
- vtEnabled = 0;
- }
- }
-#endif /* HAS_USL_VTS */
-
- if (UseConsole)
- {
- strlcpy(consoleDev, SOL_CONSOLE_DEV, sizeof(consoleDev));
+ /*
+ * Setup the virtual terminal manager
+ */
+ if ((fd = open("/dev/vt/0", O_RDWR, 0)) == -1) {
+ xf86ErrorF("xf86OpenConsole: Cannot open /dev/vt/0 (%s)\n",
+ strerror(errno));
+ vtEnabled = 0;
+ }
+ else {
+ if (ioctl(fd, VT_ENABLED, &vtEnabled) < 0) {
+ xf86ErrorF("xf86OpenConsole: VT_ENABLED failed (%s)\n",
+ strerror(errno));
+ vtEnabled = 0;
+ }
+ }
+#endif /* HAS_USL_VTS */
+
+ if (UseConsole) {
+ strlcpy(consoleDev, SOL_CONSOLE_DEV, sizeof(consoleDev));
#ifdef HAS_USL_VTS
- xf86Info.vtno = CONSOLE_VTNO;
-
- if (vtEnabled == 0)
- {
- xf86StartVT = 0;
- }
- else
- {
- if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0)
- FatalError("xf86OpenConsole: Cannot determine current VT\n");
- xf86StartVT = vtinfo.v_active;
- }
-#endif /* HAS_USL_VTS */
- goto OPENCONSOLE;
- }
+ xf86Info.vtno = CONSOLE_VTNO;
+
+ if (vtEnabled == 0) {
+ xf86StartVT = 0;
+ }
+ else {
+ if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0)
+ FatalError
+ ("xf86OpenConsole: Cannot determine current VT\n");
+ xf86StartVT = vtinfo.v_active;
+ }
+#endif /* HAS_USL_VTS */
+ goto OPENCONSOLE;
+ }
#ifdef HAS_USL_VTS
- if (vtEnabled == 0)
- {
- /* VT not enabled - kernel too old or Sparc platforms
- without visual_io support */
- xf86Msg(from, "VT infrastructure is not available\n");
-
- xf86StartVT = 0;
- xf86Info.vtno = 0;
- strlcpy(consoleDev, xf86SolarisFbDev, sizeof(consoleDev));
- goto OPENCONSOLE;
- }
-
- if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0)
- FatalError("xf86OpenConsole: Cannot determine current VT\n");
-
- xf86StartVT = vtinfo.v_active;
-
- if (VTnum != -1)
- {
- xf86Info.vtno = VTnum;
- from = X_CMDLINE;
- }
- else if (xf86Info.ShareVTs)
- {
- xf86Info.vtno = vtinfo.v_active;
- from = X_CMDLINE;
- }
- else
- {
- if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
- (xf86Info.vtno == -1))
- {
- FatalError("xf86OpenConsole: Cannot find a free VT\n");
- }
- }
-
- xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
- snprintf(consoleDev, PATH_MAX, "/dev/vt/%d", xf86Info.vtno);
-
- if (fd != -1)
- {
- close(fd);
- }
-
-#endif /* HAS_USL_VTS */
-
-OPENCONSOLE:
- if (!KeepTty)
- setpgrp();
-
- if (((xf86Info.consoleFd = open(consoleDev, O_RDWR | O_NDELAY, 0)) < 0))
- FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
- consoleDev, strerror(errno));
-
- /* Change ownership of the vt or console */
- chown(consoleDev, getuid(), getgid());
+ if (vtEnabled == 0) {
+ /* VT not enabled - kernel too old or Sparc platforms
+ without visual_io support */
+ xf86Msg(from, "VT infrastructure is not available\n");
+
+ xf86StartVT = 0;
+ xf86Info.vtno = 0;
+ strlcpy(consoleDev, xf86SolarisFbDev, sizeof(consoleDev));
+ goto OPENCONSOLE;
+ }
+
+ if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0)
+ FatalError("xf86OpenConsole: Cannot determine current VT\n");
+
+ xf86StartVT = vtinfo.v_active;
+
+ if (VTnum != -1) {
+ xf86Info.vtno = VTnum;
+ from = X_CMDLINE;
+ }
+ else if (xf86Info.ShareVTs) {
+ xf86Info.vtno = vtinfo.v_active;
+ from = X_CMDLINE;
+ }
+ else {
+ if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
+ (xf86Info.vtno == -1)) {
+ FatalError("xf86OpenConsole: Cannot find a free VT\n");
+ }
+ }
+
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
+ snprintf(consoleDev, PATH_MAX, "/dev/vt/%d", xf86Info.vtno);
+
+ if (fd != -1) {
+ close(fd);
+ }
+
+#endif /* HAS_USL_VTS */
+
+ OPENCONSOLE:
+ if (!KeepTty)
+ setpgrp();
+
+ if (((xf86Info.consoleFd = open(consoleDev, O_RDWR | O_NDELAY, 0)) < 0))
+ FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
+ consoleDev, strerror(errno));
+
+ /* Change ownership of the vt or console */
+ chown(consoleDev, getuid(), getgid());
#ifdef HAS_USL_VTS
- if (xf86Info.ShareVTs)
- return;
-
- if (vtEnabled)
- {
- /*
- * Now get the VT
- */
- switch_to(xf86Info.vtno, "xf86OpenConsole");
-
-#ifdef VT_SET_CONSUSER /* added in snv_139 */
- if (strcmp(display, "0") == 0)
- if (ioctl(xf86Info.consoleFd, VT_SET_CONSUSER) != 0)
- xf86Msg(X_WARNING,
- "xf86OpenConsole: VT_SET_CONSUSER failed\n");
+ if (xf86Info.ShareVTs)
+ return;
+
+ if (vtEnabled) {
+ /*
+ * Now get the VT
+ */
+ switch_to(xf86Info.vtno, "xf86OpenConsole");
+
+#ifdef VT_SET_CONSUSER /* added in snv_139 */
+ if (strcmp(display, "0") == 0)
+ if (ioctl(xf86Info.consoleFd, VT_SET_CONSUSER) != 0)
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: VT_SET_CONSUSER failed\n");
#endif
- if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
- FatalError("xf86OpenConsole: VT_GETMODE failed\n");
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
+ FatalError("xf86OpenConsole: VT_GETMODE failed\n");
- OsSignal(SIGUSR1, xf86VTAcquire);
- OsSignal(SIGUSR2, xf86VTRelease);
+ OsSignal(SIGUSR1, xf86VTAcquire);
+ OsSignal(SIGUSR2, xf86VTRelease);
- VT.mode = VT_PROCESS;
- VT.acqsig = SIGUSR1;
- VT.relsig = SIGUSR2;
+ VT.mode = VT_PROCESS;
+ VT.acqsig = SIGUSR1;
+ VT.relsig = SIGUSR2;
- if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
- FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
+ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
- if (ioctl(xf86Info.consoleFd, VT_SETDISPINFO, atoi(display)) < 0)
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_SETDISPINFO failed\n");
- }
+ if (ioctl(xf86Info.consoleFd, VT_SETDISPINFO, atoi(display)) < 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_SETDISPINFO failed\n");
+ }
#endif
#ifdef KDSETMODE
- SYSCALL(i = ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS));
- if (i < 0) {
- xf86Msg(X_WARNING,
- "xf86OpenConsole: KDSETMODE KD_GRAPHICS failed on %s (%s)\n",
- consoleDev, strerror(errno));
- }
+ SYSCALL(i = ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS));
+ if (i < 0) {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: KDSETMODE KD_GRAPHICS failed on %s (%s)\n",
+ consoleDev, strerror(errno));
+ }
#endif
}
- else /* serverGeneration != 1 */
- {
+ else { /* serverGeneration != 1 */
+
#ifdef HAS_USL_VTS
- if (vtEnabled && !xf86Info.ShareVTs)
- {
- /*
- * Now re-get the VT
- */
- if (xf86Info.autoVTSwitch)
- switch_to(xf86Info.vtno, "xf86OpenConsole");
-
-#ifdef VT_SET_CONSUSER /* added in snv_139 */
- if (strcmp(display, "0") == 0)
- if (ioctl(xf86Info.consoleFd, VT_SET_CONSUSER) != 0)
- xf86Msg(X_WARNING,
- "xf86OpenConsole: VT_SET_CONSUSER failed\n");
+ if (vtEnabled && !xf86Info.ShareVTs) {
+ /*
+ * Now re-get the VT
+ */
+ if (xf86Info.autoVTSwitch)
+ switch_to(xf86Info.vtno, "xf86OpenConsole");
+
+#ifdef VT_SET_CONSUSER /* added in snv_139 */
+ if (strcmp(display, "0") == 0)
+ if (ioctl(xf86Info.consoleFd, VT_SET_CONSUSER) != 0)
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: VT_SET_CONSUSER failed\n");
#endif
- /*
- * If the server doesn't have the VT when the reset occurs,
- * this is to make sure we don't continue until the activate
- * signal is received.
- */
- if (!xf86Screens[0]->vtSema)
- sleep(5);
- }
-#endif /* HAS_USL_VTS */
+ /*
+ * If the server doesn't have the VT when the reset occurs,
+ * this is to make sure we don't continue until the activate
+ * signal is received.
+ */
+ if (!xf86Screens[0]->vtSema)
+ sleep(5);
+ }
+#endif /* HAS_USL_VTS */
}
}
@@ -307,44 +292,47 @@ xf86CloseConsole(void)
#if !defined(__i386__) && !defined(__i386) && !defined(__x86)
if (!xf86DoConfigure) {
- int fd;
-
- /*
- * Wipe out framebuffer just like the non-SI Xsun server does. This
- * could be improved by saving framebuffer contents in
- * xf86OpenConsole() above and restoring them here. Also, it's unclear
- * at this point whether this should be done for all framebuffers in
- * the system, rather than only the console.
- */
- if ((fd = open(xf86SolarisFbDev, O_RDWR, 0)) < 0) {
- xf86Msg(X_WARNING,
- "xf86CloseConsole(): unable to open framebuffer (%s)\n",
- strerror(errno));
- } else {
- struct fbgattr fbattr;
-
- if ((ioctl(fd, FBIOGATTR, &fbattr) < 0) &&
- (ioctl(fd, FBIOGTYPE, &fbattr.fbtype) < 0)) {
- xf86Msg(X_WARNING,
- "xf86CloseConsole(): unable to retrieve framebuffer"
- " attributes (%s)\n", strerror(errno));
- } else {
- pointer fbdata;
-
- fbdata = mmap(NULL, fbattr.fbtype.fb_size,
- PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
- if (fbdata == MAP_FAILED) {
- xf86Msg(X_WARNING,
- "xf86CloseConsole(): unable to mmap framebuffer"
- " (%s)\n", strerror(errno));
- } else {
- memset(fbdata, 0, fbattr.fbtype.fb_size);
- munmap(fbdata, fbattr.fbtype.fb_size);
- }
- }
-
- close(fd);
- }
+ int fd;
+
+ /*
+ * Wipe out framebuffer just like the non-SI Xsun server does. This
+ * could be improved by saving framebuffer contents in
+ * xf86OpenConsole() above and restoring them here. Also, it's unclear
+ * at this point whether this should be done for all framebuffers in
+ * the system, rather than only the console.
+ */
+ if ((fd = open(xf86SolarisFbDev, O_RDWR, 0)) < 0) {
+ xf86Msg(X_WARNING,
+ "xf86CloseConsole(): unable to open framebuffer (%s)\n",
+ strerror(errno));
+ }
+ else {
+ struct fbgattr fbattr;
+
+ if ((ioctl(fd, FBIOGATTR, &fbattr) < 0) &&
+ (ioctl(fd, FBIOGTYPE, &fbattr.fbtype) < 0)) {
+ xf86Msg(X_WARNING,
+ "xf86CloseConsole(): unable to retrieve framebuffer"
+ " attributes (%s)\n", strerror(errno));
+ }
+ else {
+ pointer fbdata;
+
+ fbdata = mmap(NULL, fbattr.fbtype.fb_size,
+ PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (fbdata == MAP_FAILED) {
+ xf86Msg(X_WARNING,
+ "xf86CloseConsole(): unable to mmap framebuffer"
+ " (%s)\n", strerror(errno));
+ }
+ else {
+ memset(fbdata, 0, fbattr.fbtype.fb_size);
+ munmap(fbdata, fbattr.fbtype.fb_size);
+ }
+ }
+
+ close(fd);
+ }
}
#endif
@@ -355,19 +343,17 @@ xf86CloseConsole(void)
#endif
#ifdef HAS_USL_VTS
- if (vtEnabled)
- {
- if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
- {
- VT.mode = VT_AUTO; /* Set default vt handling */
- ioctl(xf86Info.consoleFd, VT_SETMODE, &VT);
- }
-
- /* Activate the VT that X was started on */
- if (xf86Info.autoVTSwitch)
- switch_to(xf86StartVT, "xf86CloseConsole");
+ if (vtEnabled) {
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) {
+ VT.mode = VT_AUTO; /* Set default vt handling */
+ ioctl(xf86Info.consoleFd, VT_SETMODE, &VT);
+ }
+
+ /* Activate the VT that X was started on */
+ if (xf86Info.autoVTSwitch)
+ switch_to(xf86StartVT, "xf86CloseConsole");
}
-#endif /* HAS_USL_VTS */
+#endif /* HAS_USL_VTS */
close(xf86Info.consoleFd);
}
@@ -379,58 +365,54 @@ xf86ProcessArgument(int argc, char **argv, int i)
* Keep server from detaching from controlling tty. This is useful when
* debugging, so the server can receive keyboard signals.
*/
- if (!strcmp(argv[i], "-keeptty"))
- {
- KeepTty = TRUE;
- return 1;
+ if (!strcmp(argv[i], "-keeptty")) {
+ KeepTty = TRUE;
+ return 1;
}
/*
* Undocumented flag to protect page 0 from read/write to help catch NULL
* pointer dereferences. This is purely a debugging flag.
*/
- if (!strcmp(argv[i], "-protect0"))
- {
- Protect0 = TRUE;
- return 1;
+ if (!strcmp(argv[i], "-protect0")) {
+ Protect0 = TRUE;
+ return 1;
}
/*
* Use /dev/console as the console device.
*/
- if (!strcmp(argv[i], "-C"))
- {
- UseConsole = TRUE;
- return 1;
+ if (!strcmp(argv[i], "-C")) {
+ UseConsole = TRUE;
+ return 1;
}
#ifdef HAS_USL_VTS
- if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
- {
- if (sscanf(argv[i], "vt%d", &VTnum) == 0)
- {
- UseMsg();
- VTnum = -1;
- return 0;
- }
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't')) {
+ if (sscanf(argv[i], "vt%d", &VTnum) == 0) {
+ UseMsg();
+ VTnum = -1;
+ return 0;
+ }
- return 1;
+ return 1;
}
-#endif /* HAS_USL_VTS */
+#endif /* HAS_USL_VTS */
if ((i + 1) < argc) {
- if (!strcmp(argv[i], "-dev")) {
- strlcpy(xf86SolarisFbDev, argv[i+1], sizeof(xf86SolarisFbDev));
- return 2;
- }
+ if (!strcmp(argv[i], "-dev")) {
+ strlcpy(xf86SolarisFbDev, argv[i + 1], sizeof(xf86SolarisFbDev));
+ return 2;
+ }
}
return 0;
}
-void xf86UseMsg(void)
+void
+xf86UseMsg(void)
{
#ifdef HAS_USL_VTS
ErrorF("vtX Use the specified VT number\n");
diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_vid.c b/xorg-server/hw/xfree86/os-support/solaris/sun_vid.c
index b7b7c0ed7..67ef17689 100644
--- a/xorg-server/hw/xfree86/os-support/solaris/sun_vid.c
+++ b/xorg-server/hw/xfree86/os-support/solaris/sun_vid.c
@@ -1,258 +1,247 @@
-/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
- * Copyright 1993 by David Wexelblat <dwex@goblin.org>
- * Copyright 1999 by David Holland <davidh@iquest.net>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that copyright
- * notice and this permission notice appear in supporting documentation, and
- * that the names of the copyright holders not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. The copyright holders make no representations
- * about the suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
- * SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- *
- */
-/* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <sys/types.h> /* get __x86 definition if not set by compiler */
-
-#if defined(__i386__) || defined(__i386) || defined(__x86)
-# define _NEED_SYSI86
-#endif
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
-#include <sys/mman.h>
-
-/***************************************************************************/
-/* Video Memory Mapping section */
-/***************************************************************************/
-
-static char *apertureDevName = NULL;
-static int apertureDevFD_ro = -1;
-static int apertureDevFD_rw = -1;
-
-static Bool
-solOpenAperture(void)
-{
- if (apertureDevName == NULL)
- {
- apertureDevName = "/dev/xsvc";
- if ((apertureDevFD_rw = open(apertureDevName, O_RDWR)) < 0)
- {
- xf86MsgVerb(X_WARNING, 0,
- "solOpenAperture: failed to open %s (%s)\n",
- apertureDevName, strerror(errno));
- apertureDevName = "/dev/fbs/aperture";
- apertureDevFD_rw = open(apertureDevName, O_RDWR);
- }
- apertureDevFD_ro = open(apertureDevName, O_RDONLY);
-
- if ((apertureDevFD_rw < 0) || (apertureDevFD_ro < 0))
- {
- xf86MsgVerb(X_WARNING, 0,
- "solOpenAperture: failed to open %s (%s)\n",
- apertureDevName, strerror(errno));
- xf86MsgVerb(X_WARNING, 0,
- "solOpenAperture: either /dev/fbs/aperture"
- " or /dev/xsvc required\n");
-
- apertureDevName = NULL;
-
- if (apertureDevFD_rw >= 0)
- {
- close(apertureDevFD_rw);
- }
- apertureDevFD_rw = -1;
-
- if (apertureDevFD_ro >= 0)
- {
- close(apertureDevFD_ro);
- }
- apertureDevFD_ro = -1;
-
- return FALSE;
- }
- }
- return TRUE;
-}
-
-static pointer
-solMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int Flags)
-{
- pointer base;
- int fd;
- int prot;
-
- if (Flags & VIDMEM_READONLY)
- {
- fd = apertureDevFD_ro;
- prot = PROT_READ;
- }
- else
- {
- fd = apertureDevFD_rw;
- prot = PROT_READ | PROT_WRITE;
- }
-
- if (fd < 0)
- {
- xf86DrvMsg(ScreenNum, X_ERROR,
- "solMapVidMem: failed to open %s (%s)\n",
- apertureDevName, strerror(errno));
- return NULL;
- }
-
- base = mmap(NULL, Size, prot, MAP_SHARED, fd, (off_t)Base);
-
- if (base == MAP_FAILED) {
- xf86DrvMsg(ScreenNum, X_ERROR,
- "solMapVidMem: failed to mmap %s (0x%08lx,0x%lx) (%s)\n",
- apertureDevName, Base, Size, strerror(errno));
- return NULL;
- }
-
- return base;
-}
-
-/* ARGSUSED */
-static void
-solUnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
-{
- if (munmap(Base, Size) != 0) {
- xf86DrvMsgVerb(ScreenNum, X_WARNING, 0,
- "solUnMapVidMem: failed to unmap %s"
- " (0x%p,0x%lx) (%s)\n",
- apertureDevName, Base, Size,
- strerror(errno));
- }
-}
-
-_X_HIDDEN void
-xf86OSInitVidMem(VidMemInfoPtr pVidMem)
-{
- pVidMem->linearSupported = solOpenAperture();
- if (pVidMem->linearSupported) {
- pVidMem->mapMem = solMapVidMem;
- pVidMem->unmapMem = solUnMapVidMem;
- } else {
- xf86MsgVerb(X_WARNING, 0,
- "xf86OSInitVidMem: linear memory access disabled\n");
- }
- pVidMem->initialised = TRUE;
-}
-
-/*
- * Read BIOS via mmap()ing physical memory.
- */
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
-{
- unsigned char *ptr;
- int psize;
- int mlen;
-
- psize = getpagesize();
- Offset += Base & (psize - 1);
- Base &= ~(psize - 1);
- mlen = (Offset + Len + psize - 1) & ~(psize - 1);
-
- if (solOpenAperture() == FALSE)
- {
- xf86Msg(X_WARNING,
- "xf86ReadBIOS: Failed to open aperture to read BIOS\n");
- return -1;
- }
-
- ptr = (unsigned char *)mmap(NULL, mlen, PROT_READ,
- MAP_SHARED, apertureDevFD_ro, (off_t)Base);
- if (ptr == MAP_FAILED)
- {
- xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed [0x%08lx, 0x%04x]\n",
- apertureDevName, Base, mlen);
- return -1;
- }
-
- (void)memcpy(Buf, (void *)(ptr + Offset), Len);
- if (munmap((caddr_t)ptr, mlen) != 0) {
- xf86MsgVerb(X_WARNING, 0,
- "xf86ReadBIOS: failed to unmap %s (0x%p,0x%x) (%s)\n",
- apertureDevName, ptr, mlen, strerror(errno));
- }
-
- return Len;
-}
-
-
-/***************************************************************************/
-/* I/O Permissions section */
-/***************************************************************************/
-
-#if defined(__i386__) || defined(__i386) || defined(__x86)
-static Bool ExtendedEnabled = FALSE;
-#endif
-
-Bool
-xf86EnableIO(void)
-{
-#if defined(__i386__) || defined(__i386) || defined(__x86)
- if (ExtendedEnabled)
- return TRUE;
-
- if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) {
- xf86Msg(X_WARNING, "xf86EnableIOPorts: Failed to set IOPL for I/O\n");
- return FALSE;
- }
- ExtendedEnabled = TRUE;
-#endif /* i386 */
- return TRUE;
-}
-
-void
-xf86DisableIO(void)
-{
-#if defined(__i386__) || defined(__i386) || defined(__x86)
- if(!ExtendedEnabled)
- return;
-
- sysi86(SI86V86, V86SC_IOPL, 0);
-
- ExtendedEnabled = FALSE;
-#endif /* i386 */
-}
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ * Copyright 1999 by David Holland <davidh@iquest.net>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the names of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
+ * SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ *
+ */
+/* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/types.h> /* get __x86 definition if not set by compiler */
+
+#if defined(__i386__) || defined(__i386) || defined(__x86)
+#define _NEED_SYSI86
+#endif
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+#include <sys/mman.h>
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+static char *apertureDevName = NULL;
+static int apertureDevFD_ro = -1;
+static int apertureDevFD_rw = -1;
+
+static Bool
+solOpenAperture(void)
+{
+ if (apertureDevName == NULL) {
+ apertureDevName = "/dev/xsvc";
+ if ((apertureDevFD_rw = open(apertureDevName, O_RDWR)) < 0) {
+ xf86MsgVerb(X_WARNING, 0,
+ "solOpenAperture: failed to open %s (%s)\n",
+ apertureDevName, strerror(errno));
+ apertureDevName = "/dev/fbs/aperture";
+ apertureDevFD_rw = open(apertureDevName, O_RDWR);
+ }
+ apertureDevFD_ro = open(apertureDevName, O_RDONLY);
+
+ if ((apertureDevFD_rw < 0) || (apertureDevFD_ro < 0)) {
+ xf86MsgVerb(X_WARNING, 0,
+ "solOpenAperture: failed to open %s (%s)\n",
+ apertureDevName, strerror(errno));
+ xf86MsgVerb(X_WARNING, 0,
+ "solOpenAperture: either /dev/fbs/aperture"
+ " or /dev/xsvc required\n");
+
+ apertureDevName = NULL;
+
+ if (apertureDevFD_rw >= 0) {
+ close(apertureDevFD_rw);
+ }
+ apertureDevFD_rw = -1;
+
+ if (apertureDevFD_ro >= 0) {
+ close(apertureDevFD_ro);
+ }
+ apertureDevFD_ro = -1;
+
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+static pointer
+solMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int Flags)
+{
+ pointer base;
+ int fd;
+ int prot;
+
+ if (Flags & VIDMEM_READONLY) {
+ fd = apertureDevFD_ro;
+ prot = PROT_READ;
+ }
+ else {
+ fd = apertureDevFD_rw;
+ prot = PROT_READ | PROT_WRITE;
+ }
+
+ if (fd < 0) {
+ xf86DrvMsg(ScreenNum, X_ERROR,
+ "solMapVidMem: failed to open %s (%s)\n",
+ apertureDevName, strerror(errno));
+ return NULL;
+ }
+
+ base = mmap(NULL, Size, prot, MAP_SHARED, fd, (off_t) Base);
+
+ if (base == MAP_FAILED) {
+ xf86DrvMsg(ScreenNum, X_ERROR,
+ "solMapVidMem: failed to mmap %s (0x%08lx,0x%lx) (%s)\n",
+ apertureDevName, Base, Size, strerror(errno));
+ return NULL;
+ }
+
+ return base;
+}
+
+/* ARGSUSED */
+static void
+solUnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ if (munmap(Base, Size) != 0) {
+ xf86DrvMsgVerb(ScreenNum, X_WARNING, 0,
+ "solUnMapVidMem: failed to unmap %s"
+ " (0x%p,0x%lx) (%s)\n",
+ apertureDevName, Base, Size, strerror(errno));
+ }
+}
+
+_X_HIDDEN void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ pVidMem->linearSupported = solOpenAperture();
+ if (pVidMem->linearSupported) {
+ pVidMem->mapMem = solMapVidMem;
+ pVidMem->unmapMem = solUnMapVidMem;
+ }
+ else {
+ xf86MsgVerb(X_WARNING, 0,
+ "xf86OSInitVidMem: linear memory access disabled\n");
+ }
+ pVidMem->initialised = TRUE;
+}
+
+/*
+ * Read BIOS via mmap()ing physical memory.
+ */
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ unsigned char *ptr;
+ int psize;
+ int mlen;
+
+ psize = getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+
+ if (solOpenAperture() == FALSE) {
+ xf86Msg(X_WARNING,
+ "xf86ReadBIOS: Failed to open aperture to read BIOS\n");
+ return -1;
+ }
+
+ ptr = (unsigned char *) mmap(NULL, mlen, PROT_READ,
+ MAP_SHARED, apertureDevFD_ro, (off_t) Base);
+ if (ptr == MAP_FAILED) {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed [0x%08lx, 0x%04x]\n",
+ apertureDevName, Base, mlen);
+ return -1;
+ }
+
+ (void) memcpy(Buf, (void *) (ptr + Offset), Len);
+ if (munmap((caddr_t) ptr, mlen) != 0) {
+ xf86MsgVerb(X_WARNING, 0,
+ "xf86ReadBIOS: failed to unmap %s (0x%p,0x%x) (%s)\n",
+ apertureDevName, ptr, mlen, strerror(errno));
+ }
+
+ return Len;
+}
+
+/***************************************************************************/
+/* I/O Permissions section */
+/***************************************************************************/
+
+#if defined(__i386__) || defined(__i386) || defined(__x86)
+static Bool ExtendedEnabled = FALSE;
+#endif
+
+Bool
+xf86EnableIO(void)
+{
+#if defined(__i386__) || defined(__i386) || defined(__x86)
+ if (ExtendedEnabled)
+ return TRUE;
+
+ if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) {
+ xf86Msg(X_WARNING, "xf86EnableIOPorts: Failed to set IOPL for I/O\n");
+ return FALSE;
+ }
+ ExtendedEnabled = TRUE;
+#endif /* i386 */
+ return TRUE;
+}
+
+void
+xf86DisableIO(void)
+{
+#if defined(__i386__) || defined(__i386) || defined(__x86)
+ if (!ExtendedEnabled)
+ return;
+
+ sysi86(SI86V86, V86SC_IOPL, 0);
+
+ ExtendedEnabled = FALSE;
+#endif /* i386 */
+}
diff --git a/xorg-server/hw/xfree86/os-support/xf86_OSproc.h b/xorg-server/hw/xfree86/os-support/xf86_OSproc.h
index 78ea6e660..e171146dd 100644
--- a/xorg-server/hw/xfree86/os-support/xf86_OSproc.h
+++ b/xorg-server/hw/xfree86/os-support/xf86_OSproc.h
@@ -64,7 +64,6 @@
*
*/
-
#ifndef _XF86_OSPROC_H
#define _XF86_OSPROC_H
@@ -72,7 +71,7 @@
* The actual prototypes have been pulled into this seperate file so
* that they can can be used without pulling in all of the OS specific
* stuff like sys/stat.h, etc. This casues problem for loadable modules.
- */
+ */
/*
* Flags for xf86MapVidMem(). Multiple flags can be or'd together. The
@@ -80,31 +79,31 @@
* enable write combining for memory marked only for framebuffer use.
*/
-#define VIDMEM_FRAMEBUFFER 0x01 /* memory for framebuffer use */
-#define VIDMEM_MMIO 0x02 /* memory for I/O use */
-#define VIDMEM_MMIO_32BIT 0x04 /* memory accesses >= 32bit */
-#define VIDMEM_READSIDEEFFECT 0x08 /* reads can have side-effects */
-#define VIDMEM_SPARSE 0x10 /* sparse mapping required
- * assumed when VIDMEM_MMIO is
- * set. May be used with
- * VIDMEM_FRAMEBUFFER) */
-#define VIDMEM_READONLY 0x20 /* read-only mapping
- * used when reading BIOS images
- * through xf86MapVidMem() */
+#define VIDMEM_FRAMEBUFFER 0x01 /* memory for framebuffer use */
+#define VIDMEM_MMIO 0x02 /* memory for I/O use */
+#define VIDMEM_MMIO_32BIT 0x04 /* memory accesses >= 32bit */
+#define VIDMEM_READSIDEEFFECT 0x08 /* reads can have side-effects */
+#define VIDMEM_SPARSE 0x10 /* sparse mapping required
+ * assumed when VIDMEM_MMIO is
+ * set. May be used with
+ * VIDMEM_FRAMEBUFFER) */
+#define VIDMEM_READONLY 0x20 /* read-only mapping
+ * used when reading BIOS images
+ * through xf86MapVidMem() */
/*
* OS-independent modem state flags for xf86SetSerialModemState() and
* xf86GetSerialModemState().
*/
-#define XF86_M_LE 0x001 /* line enable */
-#define XF86_M_DTR 0x002 /* data terminal ready */
-#define XF86_M_RTS 0x004 /* request to send */
-#define XF86_M_ST 0x008 /* secondary transmit */
-#define XF86_M_SR 0x010 /* secondary receive */
-#define XF86_M_CTS 0x020 /* clear to send */
-#define XF86_M_CAR 0x040 /* carrier detect */
-#define XF86_M_RNG 0x080 /* ring */
-#define XF86_M_DSR 0x100 /* data set ready */
+#define XF86_M_LE 0x001 /* line enable */
+#define XF86_M_DTR 0x002 /* data terminal ready */
+#define XF86_M_RTS 0x004 /* request to send */
+#define XF86_M_ST 0x008 /* secondary transmit */
+#define XF86_M_SR 0x010 /* secondary receive */
+#define XF86_M_CTS 0x020 /* clear to send */
+#define XF86_M_CAR 0x040 /* carrier detect */
+#define XF86_M_RNG 0x080 /* ring */
+#define XF86_M_DSR 0x100 /* data set ready */
#ifndef NO_OSLIB_PROTOTYPES
/*
@@ -133,12 +132,17 @@ _XFUNCPROTOBEGIN
/* public functions */
extern _X_EXPORT Bool xf86LinearVidMem(void);
extern _X_EXPORT _X_DEPRECATED Bool xf86CheckMTRR(int);
-extern _X_EXPORT _X_DEPRECATED pointer xf86MapVidMem(int, int, unsigned long, unsigned long);
-extern _X_EXPORT _X_DEPRECATED void xf86UnMapVidMem(int, pointer, unsigned long);
-extern _X_EXPORT _X_DEPRECATED void xf86MapReadSideEffects(int, int, pointer, unsigned long);
-extern _X_EXPORT int xf86ReadBIOS(unsigned long, unsigned long, unsigned char *, int);
+extern _X_EXPORT _X_DEPRECATED pointer xf86MapVidMem(int, int, unsigned long,
+ unsigned long);
+extern _X_EXPORT _X_DEPRECATED void xf86UnMapVidMem(int, pointer,
+ unsigned long);
+extern _X_EXPORT _X_DEPRECATED void xf86MapReadSideEffects(int, int, pointer,
+ unsigned long);
+extern _X_EXPORT int xf86ReadBIOS(unsigned long, unsigned long, unsigned char *,
+ int);
extern _X_EXPORT Bool xf86EnableIO(void);
extern _X_EXPORT void xf86DisableIO(void);
+
#ifdef __NetBSD__
extern _X_EXPORT void xf86SetTVOut(int);
extern _X_EXPORT void xf86SetRGBOut(void);
@@ -164,23 +168,24 @@ extern _X_EXPORT int xf86LoadKernelModule(const char *pathname);
/* AGP GART interface */
typedef struct _AgpInfo {
- CARD32 bridgeId;
- CARD32 agpMode;
- unsigned long base;
- unsigned long size;
- unsigned long totalPages;
- unsigned long systemPages;
- unsigned long usedPages;
+ CARD32 bridgeId;
+ CARD32 agpMode;
+ unsigned long base;
+ unsigned long size;
+ unsigned long totalPages;
+ unsigned long systemPages;
+ unsigned long usedPages;
} AgpInfo, *AgpInfoPtr;
extern _X_EXPORT Bool xf86AgpGARTSupported(void);
extern _X_EXPORT AgpInfoPtr xf86GetAGPInfo(int screenNum);
extern _X_EXPORT Bool xf86AcquireGART(int screenNum);
extern _X_EXPORT Bool xf86ReleaseGART(int screenNum);
-extern _X_EXPORT int xf86AllocateGARTMemory(int screenNum, unsigned long size, int type,
- unsigned long *physical);
+extern _X_EXPORT int xf86AllocateGARTMemory(int screenNum, unsigned long size,
+ int type, unsigned long *physical);
extern _X_EXPORT Bool xf86DeallocateGARTMemory(int screenNum, int key);
-extern _X_EXPORT Bool xf86BindGARTMemory(int screenNum, int key, unsigned long offset);
+extern _X_EXPORT Bool xf86BindGARTMemory(int screenNum, int key,
+ unsigned long offset);
extern _X_EXPORT Bool xf86UnbindGARTMemory(int screenNum, int key);
extern _X_EXPORT Bool xf86EnableAGP(int screenNum, CARD32 mode);
extern _X_EXPORT Bool xf86GARTCloseScreen(int screenNum);
@@ -189,15 +194,16 @@ extern _X_EXPORT Bool xf86GARTCloseScreen(int screenNum);
module. These routines are small, and the code if very POSIX-signal (or
OS-signal) specific, so it seemed better to provide more complex
wrappers than to wrap each individual function called. */
-extern _X_EXPORT int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *);
+extern _X_EXPORT int xf86InstallSIGIOHandler(int fd, void (*f) (int, void *),
+ void *);
extern _X_EXPORT int xf86RemoveSIGIOHandler(int fd);
-extern _X_EXPORT int xf86BlockSIGIO (void);
-extern _X_EXPORT void xf86UnblockSIGIO (int);
-extern _X_EXPORT void xf86AssertBlockedSIGIO (char *);
-extern _X_EXPORT Bool xf86SIGIOSupported (void);
+extern _X_EXPORT int xf86BlockSIGIO(void);
+extern _X_EXPORT void xf86UnblockSIGIO(int);
+extern _X_EXPORT void xf86AssertBlockedSIGIO(char *);
+extern _X_EXPORT Bool xf86SIGIOSupported(void);
#ifdef XF86_OS_PRIVS
-typedef void (*PMClose)(void);
+typedef void (*PMClose) (void);
extern _X_EXPORT void xf86OpenConsole(void);
extern _X_EXPORT void xf86CloseConsole(void);
extern _X_HIDDEN Bool xf86VTActivate(int vtno);
@@ -209,13 +215,12 @@ extern _X_EXPORT int xf86ProcessArgument(int, char **, int);
extern _X_EXPORT void xf86UseMsg(void);
extern _X_EXPORT PMClose xf86OSPMOpen(void);
-extern _X_EXPORT _X_DEPRECATED void xf86MakeNewMapping(int, int, unsigned long, unsigned long, pointer);
+extern _X_EXPORT _X_DEPRECATED void xf86MakeNewMapping(int, int, unsigned long,
+ unsigned long, pointer);
extern _X_EXPORT void xf86InitVidMem(void);
-#endif /* XF86_OS_PRIVS */
-
+#endif /* XF86_OS_PRIVS */
_XFUNCPROTOEND
-#endif /* NO_OSLIB_PROTOTYPES */
-
-#endif /* _XF86_OSPROC_H */
+#endif /* NO_OSLIB_PROTOTYPES */
+#endif /* _XF86_OSPROC_H */
diff --git a/xorg-server/hw/xfree86/parser/Configint.h b/xorg-server/hw/xfree86/parser/Configint.h
index 3f84ff0fa..81cc1fc59 100644
--- a/xorg-server/hw/xfree86/parser/Configint.h
+++ b/xorg-server/hw/xfree86/parser/Configint.h
@@ -52,7 +52,6 @@
* authorization from the copyright holder(s) and author(s).
*/
-
/*
* These definitions are used through out the configuration file parser, but
* they should not be visible outside of the parser.
@@ -73,14 +72,12 @@
typedef enum { PARSE_DECIMAL, PARSE_OCTAL, PARSE_HEX } ParserNumType;
-typedef struct
-{
- int num; /* returned number */
- char *str; /* private copy of the return-string */
- double realnum; /* returned number as a real */
- ParserNumType numType; /* used to enforce correct number formatting */
-}
-LexRec, *LexPtr;
+typedef struct {
+ int num; /* returned number */
+ char *str; /* private copy of the return-string */
+ double realnum; /* returned number as a real */
+ ParserNumType numType; /* used to enforce correct number formatting */
+} LexRec, *LexPtr;
#ifndef TRUE
#define TRUE 1
@@ -210,4 +207,4 @@ else\
#define OBSOLETE_MSG \
"Ignoring obsolete keyword \"%s\"."
-#endif /* _Configint_h_ */
+#endif /* _Configint_h_ */
diff --git a/xorg-server/hw/xfree86/parser/DRI.c b/xorg-server/hw/xfree86/parser/DRI.c
index 77846da2b..e8d26255f 100644
--- a/xorg-server/hw/xfree86/parser/DRI.c
+++ b/xorg-server/hw/xfree86/parser/DRI.c
@@ -37,87 +37,86 @@
extern LexRec val;
-static xf86ConfigSymTabRec DRITab[] =
-{
+static xf86ConfigSymTabRec DRITab[] = {
{ENDSECTION, "endsection"},
- {GROUP, "group"},
- {MODE, "mode"},
- {-1, ""},
+ {GROUP, "group"},
+ {MODE, "mode"},
+ {-1, ""},
};
#define CLEANUP xf86freeDRI
XF86ConfDRIPtr
-xf86parseDRISection (void)
+xf86parseDRISection(void)
{
int token;
- parsePrologue (XF86ConfDRIPtr, XF86ConfDRIRec);
+
+ parsePrologue(XF86ConfDRIPtr, XF86ConfDRIRec);
/* Zero is a valid value for this. */
ptr->dri_group = -1;
- while ((token = xf86getToken (DRITab)) != ENDSECTION) {
- switch (token)
- {
- case GROUP:
- if ((token = xf86getSubToken (&(ptr->dri_comment))) == STRING)
- ptr->dri_group_name = val.str;
- else if (token == NUMBER)
- ptr->dri_group = val.num;
- else
- Error (GROUP_MSG);
- break;
- case MODE:
- if (xf86getSubToken (&(ptr->dri_comment)) != NUMBER)
- Error (NUMBER_MSG, "Mode");
- if (val.numType != PARSE_OCTAL)
- Error (MUST_BE_OCTAL_MSG, val.num);
- ptr->dri_mode = val.num;
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG);
- break;
- case COMMENT:
- ptr->dri_comment = xf86addComment(ptr->dri_comment, val.str);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
+ while ((token = xf86getToken(DRITab)) != ENDSECTION) {
+ switch (token) {
+ case GROUP:
+ if ((token = xf86getSubToken(&(ptr->dri_comment))) == STRING)
+ ptr->dri_group_name = val.str;
+ else if (token == NUMBER)
+ ptr->dri_group = val.num;
+ else
+ Error(GROUP_MSG);
+ break;
+ case MODE:
+ if (xf86getSubToken(&(ptr->dri_comment)) != NUMBER)
+ Error(NUMBER_MSG, "Mode");
+ if (val.numType != PARSE_OCTAL)
+ Error(MUST_BE_OCTAL_MSG, val.num);
+ ptr->dri_mode = val.num;
+ break;
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG);
+ break;
+ case COMMENT:
+ ptr->dri_comment = xf86addComment(ptr->dri_comment, val.str);
+ break;
+ default:
+ Error(INVALID_KEYWORD_MSG, xf86tokenString());
+ break;
+ }
}
-
+
#ifdef DEBUG
ErrorF("DRI section parsed\n");
#endif
-
+
return ptr;
}
#undef CLEANUP
void
-xf86printDRISection (FILE * cf, XF86ConfDRIPtr ptr)
+xf86printDRISection(FILE * cf, XF86ConfDRIPtr ptr)
{
if (ptr == NULL)
- return;
-
- fprintf (cf, "Section \"DRI\"\n");
+ return;
+
+ fprintf(cf, "Section \"DRI\"\n");
if (ptr->dri_comment)
- fprintf (cf, "%s", ptr->dri_comment);
+ fprintf(cf, "%s", ptr->dri_comment);
if (ptr->dri_group_name)
- fprintf (cf, "\tGroup \"%s\"\n", 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);
+ fprintf(cf, "\tGroup %d\n", ptr->dri_group);
if (ptr->dri_mode)
- fprintf (cf, "\tMode 0%o\n", ptr->dri_mode);
- fprintf (cf, "EndSection\n\n");
+ fprintf(cf, "\tMode 0%o\n", ptr->dri_mode);
+ fprintf(cf, "EndSection\n\n");
}
void
-xf86freeDRI (XF86ConfDRIPtr ptr)
+xf86freeDRI(XF86ConfDRIPtr ptr)
{
if (ptr == NULL)
- return;
-
- TestFree (ptr->dri_comment);
- free (ptr);
+ return;
+
+ TestFree(ptr->dri_comment);
+ free(ptr);
}
diff --git a/xorg-server/hw/xfree86/parser/Device.c b/xorg-server/hw/xfree86/parser/Device.c
index d99dbf79d..f27b56fef 100644
--- a/xorg-server/hw/xfree86/parser/Device.c
+++ b/xorg-server/hw/xfree86/parser/Device.c
@@ -52,7 +52,6 @@
* authorization from the copyright holder(s) and author(s).
*/
-
/* View/edit this file with tab stops set to 4 */
#ifdef HAVE_XORG_CONFIG_H
@@ -66,306 +65,296 @@
extern LexRec val;
static
-xf86ConfigSymTabRec DeviceTab[] =
-{
- {ENDSECTION, "endsection"},
- {IDENTIFIER, "identifier"},
- {VENDOR, "vendorname"},
- {BOARD, "boardname"},
- {CHIPSET, "chipset"},
- {RAMDAC, "ramdac"},
- {DACSPEED, "dacspeed"},
- {CLOCKS, "clocks"},
- {OPTION, "option"},
- {VIDEORAM, "videoram"},
- {BIOSBASE, "biosbase"},
- {MEMBASE, "membase"},
- {IOBASE, "iobase"},
- {CLOCKCHIP, "clockchip"},
- {CHIPID, "chipid"},
- {CHIPREV, "chiprev"},
- {CARD, "card"},
- {DRIVER, "driver"},
- {BUSID, "busid"},
- {TEXTCLOCKFRQ, "textclockfreq"},
- {IRQ, "irq"},
- {SCREEN, "screen"},
- {-1, ""},
+xf86ConfigSymTabRec DeviceTab[] = {
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {VENDOR, "vendorname"},
+ {BOARD, "boardname"},
+ {CHIPSET, "chipset"},
+ {RAMDAC, "ramdac"},
+ {DACSPEED, "dacspeed"},
+ {CLOCKS, "clocks"},
+ {OPTION, "option"},
+ {VIDEORAM, "videoram"},
+ {BIOSBASE, "biosbase"},
+ {MEMBASE, "membase"},
+ {IOBASE, "iobase"},
+ {CLOCKCHIP, "clockchip"},
+ {CHIPID, "chipid"},
+ {CHIPREV, "chiprev"},
+ {CARD, "card"},
+ {DRIVER, "driver"},
+ {BUSID, "busid"},
+ {TEXTCLOCKFRQ, "textclockfreq"},
+ {IRQ, "irq"},
+ {SCREEN, "screen"},
+ {-1, ""},
};
#define CLEANUP xf86freeDeviceList
XF86ConfDevicePtr
-xf86parseDeviceSection (void)
+xf86parseDeviceSection(void)
{
- int i;
- int has_ident = FALSE;
- int token;
- parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)
+ int i;
+ int has_ident = FALSE;
+ int token;
+
+ parsePrologue(XF86ConfDevicePtr, XF86ConfDeviceRec)
- /* Zero is a valid value for these */
- ptr->dev_chipid = -1;
- ptr->dev_chiprev = -1;
- ptr->dev_irq = -1;
- while ((token = xf86getToken (DeviceTab)) != ENDSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->dev_comment = xf86addComment(ptr->dev_comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
- Error (QUOTE_MSG, "Identifier");
- if (has_ident == TRUE)
- Error (MULTIPLE_MSG, "Identifier");
- ptr->dev_identifier = val.str;
- has_ident = TRUE;
- break;
- case VENDOR:
- if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
- Error (QUOTE_MSG, "Vendor");
- ptr->dev_vendor = val.str;
- break;
- case BOARD:
- if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
- Error (QUOTE_MSG, "Board");
- ptr->dev_board = val.str;
- break;
- case CHIPSET:
- if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
- Error (QUOTE_MSG, "Chipset");
- ptr->dev_chipset = val.str;
- break;
- case CARD:
- if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
- Error (QUOTE_MSG, "Card");
- ptr->dev_card = val.str;
- break;
- case DRIVER:
- if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
- Error (QUOTE_MSG, "Driver");
- ptr->dev_driver = val.str;
- break;
- case RAMDAC:
- if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
- Error (QUOTE_MSG, "Ramdac");
- ptr->dev_ramdac = val.str;
- break;
- case DACSPEED:
- for (i = 0; i < CONF_MAXDACSPEEDS; i++)
- ptr->dev_dacSpeeds[i] = 0;
- if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
- {
- Error (DACSPEED_MSG, CONF_MAXDACSPEEDS);
- }
- else
- {
- ptr->dev_dacSpeeds[0] = (int) (val.realnum * 1000.0 + 0.5);
- for (i = 1; i < CONF_MAXDACSPEEDS; i++)
- {
- if (xf86getSubToken (&(ptr->dev_comment)) == NUMBER)
- ptr->dev_dacSpeeds[i] = (int)
- (val.realnum * 1000.0 + 0.5);
- else
- {
- xf86unGetToken (token);
- break;
- }
- }
- }
- break;
- case VIDEORAM:
- if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
- Error (NUMBER_MSG, "VideoRam");
- ptr->dev_videoram = val.num;
- break;
- case BIOSBASE:
- if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
- Error (NUMBER_MSG, "BIOSBase");
- ptr->dev_bios_base = val.num;
- break;
- case MEMBASE:
- if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
- Error (NUMBER_MSG, "MemBase");
- ptr->dev_mem_base = val.num;
- break;
- case IOBASE:
- if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
- Error (NUMBER_MSG, "IOBase");
- ptr->dev_io_base = val.num;
- break;
- case CLOCKCHIP:
- if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
- Error (QUOTE_MSG, "ClockChip");
- ptr->dev_clockchip = val.str;
- break;
- case CHIPID:
- if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
- Error (NUMBER_MSG, "ChipID");
- ptr->dev_chipid = val.num;
- break;
- case CHIPREV:
- if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
- Error (NUMBER_MSG, "ChipRev");
- ptr->dev_chiprev = val.num;
- break;
+ /* Zero is a valid value for these */
+ ptr->dev_chipid = -1;
+ ptr->dev_chiprev = -1;
+ ptr->dev_irq = -1;
+ while ((token = xf86getToken(DeviceTab)) != ENDSECTION) {
+ switch (token) {
+ case COMMENT:
+ ptr->dev_comment = xf86addComment(ptr->dev_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
+ Error(QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error(MULTIPLE_MSG, "Identifier");
+ ptr->dev_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case VENDOR:
+ if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
+ Error(QUOTE_MSG, "Vendor");
+ ptr->dev_vendor = val.str;
+ break;
+ case BOARD:
+ if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
+ Error(QUOTE_MSG, "Board");
+ ptr->dev_board = val.str;
+ break;
+ case CHIPSET:
+ if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
+ Error(QUOTE_MSG, "Chipset");
+ ptr->dev_chipset = val.str;
+ break;
+ case CARD:
+ if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
+ Error(QUOTE_MSG, "Card");
+ ptr->dev_card = val.str;
+ break;
+ case DRIVER:
+ if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
+ Error(QUOTE_MSG, "Driver");
+ ptr->dev_driver = val.str;
+ break;
+ case RAMDAC:
+ if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
+ Error(QUOTE_MSG, "Ramdac");
+ ptr->dev_ramdac = val.str;
+ break;
+ case DACSPEED:
+ for (i = 0; i < CONF_MAXDACSPEEDS; i++)
+ ptr->dev_dacSpeeds[i] = 0;
+ if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER) {
+ Error(DACSPEED_MSG, CONF_MAXDACSPEEDS);
+ }
+ else {
+ ptr->dev_dacSpeeds[0] = (int) (val.realnum * 1000.0 + 0.5);
+ for (i = 1; i < CONF_MAXDACSPEEDS; i++) {
+ if (xf86getSubToken(&(ptr->dev_comment)) == NUMBER)
+ ptr->dev_dacSpeeds[i] = (int)
+ (val.realnum * 1000.0 + 0.5);
+ else {
+ xf86unGetToken(token);
+ break;
+ }
+ }
+ }
+ break;
+ case VIDEORAM:
+ if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
+ Error(NUMBER_MSG, "VideoRam");
+ ptr->dev_videoram = val.num;
+ break;
+ case BIOSBASE:
+ if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
+ Error(NUMBER_MSG, "BIOSBase");
+ ptr->dev_bios_base = val.num;
+ break;
+ case MEMBASE:
+ if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
+ Error(NUMBER_MSG, "MemBase");
+ ptr->dev_mem_base = val.num;
+ break;
+ case IOBASE:
+ if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
+ Error(NUMBER_MSG, "IOBase");
+ ptr->dev_io_base = val.num;
+ break;
+ case CLOCKCHIP:
+ if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
+ Error(QUOTE_MSG, "ClockChip");
+ ptr->dev_clockchip = val.str;
+ break;
+ case CHIPID:
+ if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
+ Error(NUMBER_MSG, "ChipID");
+ ptr->dev_chipid = val.num;
+ break;
+ case CHIPREV:
+ if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
+ Error(NUMBER_MSG, "ChipRev");
+ ptr->dev_chiprev = val.num;
+ break;
- case CLOCKS:
- token = xf86getSubToken(&(ptr->dev_comment));
- for( i = ptr->dev_clocks;
- token == NUMBER && i < CONF_MAXCLOCKS; i++ ) {
- ptr->dev_clock[i] = (int)(val.realnum * 1000.0 + 0.5);
- token = xf86getSubToken(&(ptr->dev_comment));
- }
- ptr->dev_clocks = i;
- xf86unGetToken (token);
- break;
- case TEXTCLOCKFRQ:
- if ((token = xf86getSubToken(&(ptr->dev_comment))) != NUMBER)
- Error (NUMBER_MSG, "TextClockFreq");
- ptr->dev_textclockfreq = (int)(val.realnum * 1000.0 + 0.5);
- break;
- case OPTION:
- ptr->dev_option_lst = xf86parseOption(ptr->dev_option_lst);
- break;
- case BUSID:
- if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
- Error (QUOTE_MSG, "BusID");
- ptr->dev_busid = val.str;
- break;
- case IRQ:
- if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
- Error (QUOTE_MSG, "IRQ");
- ptr->dev_irq = val.num;
- break;
- case SCREEN:
- if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
- Error (NUMBER_MSG, "Screen");
- ptr->dev_screen = val.num;
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
+ case CLOCKS:
+ token = xf86getSubToken(&(ptr->dev_comment));
+ for (i = ptr->dev_clocks;
+ token == NUMBER && i < CONF_MAXCLOCKS; i++) {
+ ptr->dev_clock[i] = (int) (val.realnum * 1000.0 + 0.5);
+ token = xf86getSubToken(&(ptr->dev_comment));
+ }
+ ptr->dev_clocks = i;
+ xf86unGetToken(token);
+ break;
+ case TEXTCLOCKFRQ:
+ if ((token = xf86getSubToken(&(ptr->dev_comment))) != NUMBER)
+ Error(NUMBER_MSG, "TextClockFreq");
+ ptr->dev_textclockfreq = (int) (val.realnum * 1000.0 + 0.5);
+ break;
+ case OPTION:
+ ptr->dev_option_lst = xf86parseOption(ptr->dev_option_lst);
+ break;
+ case BUSID:
+ if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
+ Error(QUOTE_MSG, "BusID");
+ ptr->dev_busid = val.str;
+ break;
+ case IRQ:
+ if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
+ Error(QUOTE_MSG, "IRQ");
+ ptr->dev_irq = val.num;
+ break;
+ case SCREEN:
+ if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
+ Error(NUMBER_MSG, "Screen");
+ ptr->dev_screen = val.num;
+ break;
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG);
+ break;
+ default:
+ Error(INVALID_KEYWORD_MSG, xf86tokenString());
+ break;
+ }
+ }
- if (!has_ident)
- Error (NO_IDENT_MSG);
+ if (!has_ident)
+ Error(NO_IDENT_MSG);
#ifdef DEBUG
- printf ("Device section parsed\n");
+ printf("Device section parsed\n");
#endif
- return ptr;
+ return ptr;
}
#undef CLEANUP
void
-xf86printDeviceSection (FILE * cf, XF86ConfDevicePtr ptr)
+xf86printDeviceSection(FILE * cf, XF86ConfDevicePtr ptr)
{
- int i;
+ int i;
- while (ptr)
- {
- fprintf (cf, "Section \"Device\"\n");
- if (ptr->dev_comment)
- fprintf (cf, "%s", ptr->dev_comment);
- if (ptr->dev_identifier)
- fprintf (cf, "\tIdentifier \"%s\"\n", ptr->dev_identifier);
- if (ptr->dev_driver)
- fprintf (cf, "\tDriver \"%s\"\n", ptr->dev_driver);
- if (ptr->dev_vendor)
- fprintf (cf, "\tVendorName \"%s\"\n", ptr->dev_vendor);
- if (ptr->dev_board)
- fprintf (cf, "\tBoardName \"%s\"\n", ptr->dev_board);
- if (ptr->dev_chipset)
- fprintf (cf, "\tChipSet \"%s\"\n", ptr->dev_chipset);
- if (ptr->dev_card)
- fprintf (cf, "\tCard \"%s\"\n", ptr->dev_card);
- if (ptr->dev_ramdac)
- fprintf (cf, "\tRamDac \"%s\"\n", ptr->dev_ramdac);
- if (ptr->dev_dacSpeeds[0] > 0 ) {
- fprintf (cf, "\tDacSpeed ");
- for (i = 0; i < CONF_MAXDACSPEEDS
- && ptr->dev_dacSpeeds[i] > 0; i++ )
- fprintf (cf, "%g ", (double) (ptr->dev_dacSpeeds[i])/ 1000.0 );
- fprintf (cf, "\n");
- }
- if (ptr->dev_videoram)
- fprintf (cf, "\tVideoRam %d\n", ptr->dev_videoram);
- if (ptr->dev_bios_base)
- fprintf (cf, "\tBiosBase 0x%lx\n", ptr->dev_bios_base);
- if (ptr->dev_mem_base)
- fprintf (cf, "\tMemBase 0x%lx\n", ptr->dev_mem_base);
- if (ptr->dev_io_base)
- fprintf (cf, "\tIOBase 0x%lx\n", ptr->dev_io_base);
- if (ptr->dev_clockchip)
- fprintf (cf, "\tClockChip \"%s\"\n", ptr->dev_clockchip);
- if (ptr->dev_chipid != -1)
- fprintf (cf, "\tChipId 0x%x\n", ptr->dev_chipid);
- if (ptr->dev_chiprev != -1)
- fprintf (cf, "\tChipRev 0x%x\n", ptr->dev_chiprev);
+ while (ptr) {
+ fprintf(cf, "Section \"Device\"\n");
+ if (ptr->dev_comment)
+ fprintf(cf, "%s", ptr->dev_comment);
+ if (ptr->dev_identifier)
+ fprintf(cf, "\tIdentifier \"%s\"\n", ptr->dev_identifier);
+ if (ptr->dev_driver)
+ fprintf(cf, "\tDriver \"%s\"\n", ptr->dev_driver);
+ if (ptr->dev_vendor)
+ fprintf(cf, "\tVendorName \"%s\"\n", ptr->dev_vendor);
+ if (ptr->dev_board)
+ fprintf(cf, "\tBoardName \"%s\"\n", ptr->dev_board);
+ if (ptr->dev_chipset)
+ fprintf(cf, "\tChipSet \"%s\"\n", ptr->dev_chipset);
+ if (ptr->dev_card)
+ fprintf(cf, "\tCard \"%s\"\n", ptr->dev_card);
+ if (ptr->dev_ramdac)
+ fprintf(cf, "\tRamDac \"%s\"\n", ptr->dev_ramdac);
+ if (ptr->dev_dacSpeeds[0] > 0) {
+ fprintf(cf, "\tDacSpeed ");
+ for (i = 0; i < CONF_MAXDACSPEEDS && ptr->dev_dacSpeeds[i] > 0; i++)
+ fprintf(cf, "%g ", (double) (ptr->dev_dacSpeeds[i]) / 1000.0);
+ fprintf(cf, "\n");
+ }
+ if (ptr->dev_videoram)
+ fprintf(cf, "\tVideoRam %d\n", ptr->dev_videoram);
+ if (ptr->dev_bios_base)
+ fprintf(cf, "\tBiosBase 0x%lx\n", ptr->dev_bios_base);
+ if (ptr->dev_mem_base)
+ fprintf(cf, "\tMemBase 0x%lx\n", ptr->dev_mem_base);
+ if (ptr->dev_io_base)
+ fprintf(cf, "\tIOBase 0x%lx\n", ptr->dev_io_base);
+ if (ptr->dev_clockchip)
+ fprintf(cf, "\tClockChip \"%s\"\n", ptr->dev_clockchip);
+ if (ptr->dev_chipid != -1)
+ fprintf(cf, "\tChipId 0x%x\n", ptr->dev_chipid);
+ if (ptr->dev_chiprev != -1)
+ fprintf(cf, "\tChipRev 0x%x\n", ptr->dev_chiprev);
- xf86printOptionList(cf, ptr->dev_option_lst, 1);
- if (ptr->dev_clocks > 0 ) {
- fprintf (cf, "\tClocks ");
- for (i = 0; i < ptr->dev_clocks; i++ )
- fprintf (cf, "%.1f ", (double)ptr->dev_clock[i] / 1000.0 );
- fprintf (cf, "\n");
- }
- if (ptr->dev_textclockfreq) {
- fprintf (cf, "\tTextClockFreq %.1f\n",
- (double)ptr->dev_textclockfreq / 1000.0);
- }
- if (ptr->dev_busid)
- fprintf (cf, "\tBusID \"%s\"\n", ptr->dev_busid);
- if (ptr->dev_screen > 0)
- fprintf (cf, "\tScreen %d\n", ptr->dev_screen);
- if (ptr->dev_irq >= 0)
- fprintf (cf, "\tIRQ %d\n", ptr->dev_irq);
- fprintf (cf, "EndSection\n\n");
- ptr = ptr->list.next;
- }
+ xf86printOptionList(cf, ptr->dev_option_lst, 1);
+ if (ptr->dev_clocks > 0) {
+ fprintf(cf, "\tClocks ");
+ for (i = 0; i < ptr->dev_clocks; i++)
+ fprintf(cf, "%.1f ", (double) ptr->dev_clock[i] / 1000.0);
+ fprintf(cf, "\n");
+ }
+ if (ptr->dev_textclockfreq) {
+ fprintf(cf, "\tTextClockFreq %.1f\n",
+ (double) ptr->dev_textclockfreq / 1000.0);
+ }
+ if (ptr->dev_busid)
+ fprintf(cf, "\tBusID \"%s\"\n", ptr->dev_busid);
+ if (ptr->dev_screen > 0)
+ fprintf(cf, "\tScreen %d\n", ptr->dev_screen);
+ if (ptr->dev_irq >= 0)
+ fprintf(cf, "\tIRQ %d\n", ptr->dev_irq);
+ fprintf(cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
}
void
-xf86freeDeviceList (XF86ConfDevicePtr ptr)
+xf86freeDeviceList(XF86ConfDevicePtr ptr)
{
- XF86ConfDevicePtr prev;
+ XF86ConfDevicePtr prev;
- while (ptr)
- {
- TestFree (ptr->dev_identifier);
- TestFree (ptr->dev_vendor);
- TestFree (ptr->dev_board);
- TestFree (ptr->dev_chipset);
- TestFree (ptr->dev_card);
- TestFree (ptr->dev_driver);
- TestFree (ptr->dev_ramdac);
- TestFree (ptr->dev_clockchip);
- TestFree (ptr->dev_comment);
- xf86optionListFree (ptr->dev_option_lst);
+ while (ptr) {
+ TestFree(ptr->dev_identifier);
+ TestFree(ptr->dev_vendor);
+ TestFree(ptr->dev_board);
+ TestFree(ptr->dev_chipset);
+ TestFree(ptr->dev_card);
+ TestFree(ptr->dev_driver);
+ TestFree(ptr->dev_ramdac);
+ TestFree(ptr->dev_clockchip);
+ TestFree(ptr->dev_comment);
+ xf86optionListFree(ptr->dev_option_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
+ prev = ptr;
+ ptr = ptr->list.next;
+ free(prev);
+ }
}
XF86ConfDevicePtr
-xf86findDevice (const char *ident, XF86ConfDevicePtr p)
+xf86findDevice(const char *ident, XF86ConfDevicePtr p)
{
- while (p)
- {
- if (xf86nameCompare (ident, p->dev_identifier) == 0)
- return p;
+ while (p) {
+ if (xf86nameCompare(ident, p->dev_identifier) == 0)
+ return p;
- p = p->list.next;
- }
- return NULL;
+ p = p->list.next;
+ }
+ return NULL;
}
diff --git a/xorg-server/hw/xfree86/parser/Extensions.c b/xorg-server/hw/xfree86/parser/Extensions.c
index 662f5260c..ec0bda4c0 100644
--- a/xorg-server/hw/xfree86/parser/Extensions.c
+++ b/xorg-server/hw/xfree86/parser/Extensions.c
@@ -41,37 +41,37 @@
extern LexRec val;
-static xf86ConfigSymTabRec ExtensionsTab[] =
-{
+static xf86ConfigSymTabRec ExtensionsTab[] = {
{ENDSECTION, "endsection"},
- {OPTION, "option"},
- {-1, ""},
+ {OPTION, "option"},
+ {-1, ""},
};
#define CLEANUP xf86freeExtensions
XF86ConfExtensionsPtr
-xf86parseExtensionsSection (void)
+xf86parseExtensionsSection(void)
{
int token;
- parsePrologue (XF86ConfExtensionsPtr, XF86ConfExtensionsRec);
-
- while ((token = xf86getToken (ExtensionsTab)) != ENDSECTION) {
- switch (token) {
- case OPTION:
- ptr->ext_option_lst = xf86parseOption(ptr->ext_option_lst);
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG);
- break;
- case COMMENT:
- ptr->extensions_comment =
- xf86addComment(ptr->extensions_comment, val.str);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
+
+ parsePrologue(XF86ConfExtensionsPtr, XF86ConfExtensionsRec);
+
+ while ((token = xf86getToken(ExtensionsTab)) != ENDSECTION) {
+ switch (token) {
+ case OPTION:
+ ptr->ext_option_lst = xf86parseOption(ptr->ext_option_lst);
+ break;
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG);
+ break;
+ case COMMENT:
+ ptr->extensions_comment =
+ xf86addComment(ptr->extensions_comment, val.str);
+ break;
+ default:
+ Error(INVALID_KEYWORD_MSG, xf86tokenString());
+ break;
+ }
}
#ifdef DEBUG
@@ -84,28 +84,28 @@ xf86parseExtensionsSection (void)
#undef CLEANUP
void
-xf86printExtensionsSection (FILE * cf, XF86ConfExtensionsPtr ptr)
+xf86printExtensionsSection(FILE * cf, XF86ConfExtensionsPtr ptr)
{
XF86OptionPtr p;
if (ptr == NULL || ptr->ext_option_lst == NULL)
- return;
+ return;
p = ptr->ext_option_lst;
- fprintf (cf, "Section \"Extensions\"\n");
+ fprintf(cf, "Section \"Extensions\"\n");
if (ptr->extensions_comment)
- fprintf (cf, "%s", ptr->extensions_comment);
+ fprintf(cf, "%s", ptr->extensions_comment);
xf86printOptionList(cf, p, 1);
- fprintf (cf, "EndSection\n\n");
+ fprintf(cf, "EndSection\n\n");
}
void
-xf86freeExtensions (XF86ConfExtensionsPtr ptr)
+xf86freeExtensions(XF86ConfExtensionsPtr ptr)
{
if (ptr == NULL)
- return;
+ return;
- xf86optionListFree (ptr->ext_option_lst);
- TestFree (ptr->extensions_comment);
- free (ptr);
+ xf86optionListFree(ptr->ext_option_lst);
+ TestFree(ptr->extensions_comment);
+ free(ptr);
}
diff --git a/xorg-server/hw/xfree86/parser/Files.c b/xorg-server/hw/xfree86/parser/Files.c
index a95be9ee2..d8152c008 100644
--- a/xorg-server/hw/xfree86/parser/Files.c
+++ b/xorg-server/hw/xfree86/parser/Files.c
@@ -51,7 +51,6 @@
* authorization from the copyright holder(s) and author(s).
*/
-
/* View/edit this file with tab stops set to 4 */
#ifdef HAVE_XORG_CONFIG_H
@@ -65,181 +64,169 @@
extern LexRec val;
-static xf86ConfigSymTabRec FilesTab[] =
-{
- {ENDSECTION, "endsection"},
- {FONTPATH, "fontpath"},
- {MODULEPATH, "modulepath"},
- {LOGFILEPATH, "logfile"},
- {XKBDIR, "xkbdir"},
- /* Obsolete keywords that aren't used but shouldn't cause errors: */
- {OBSOLETE_TOKEN, "rgbpath"},
- {OBSOLETE_TOKEN, "inputdevices"},
- {-1, ""},
+static xf86ConfigSymTabRec FilesTab[] = {
+ {ENDSECTION, "endsection"},
+ {FONTPATH, "fontpath"},
+ {MODULEPATH, "modulepath"},
+ {LOGFILEPATH, "logfile"},
+ {XKBDIR, "xkbdir"},
+ /* Obsolete keywords that aren't used but shouldn't cause errors: */
+ {OBSOLETE_TOKEN, "rgbpath"},
+ {OBSOLETE_TOKEN, "inputdevices"},
+ {-1, ""},
};
#define CLEANUP xf86freeFiles
XF86ConfFilesPtr
-xf86parseFilesSection (void)
+xf86parseFilesSection(void)
{
- int i, j;
- int k, l;
- char *str;
- int token;
- parsePrologue (XF86ConfFilesPtr, XF86ConfFilesRec)
-
- while ((token = xf86getToken (FilesTab)) != ENDSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->file_comment = xf86addComment(ptr->file_comment, val.str);
- break;
- case FONTPATH:
- if (xf86getSubToken (&(ptr->file_comment)) != STRING)
- Error (QUOTE_MSG, "FontPath");
- j = FALSE;
- str = val.str;
- if (ptr->file_fontpath == NULL)
- {
- ptr->file_fontpath = malloc (1);
- ptr->file_fontpath[0] = '\0';
- i = strlen (str) + 1;
- }
- else
- {
- i = strlen (ptr->file_fontpath) + strlen (str) + 1;
- if (ptr->file_fontpath[strlen (ptr->file_fontpath) - 1] != ',')
- {
- i++;
- j = TRUE;
- }
- }
- ptr->file_fontpath =
- realloc (ptr->file_fontpath, i);
- if (j)
- strcat (ptr->file_fontpath, ",");
-
- strcat (ptr->file_fontpath, str);
- free (val.str);
- break;
- case MODULEPATH:
- if (xf86getSubToken (&(ptr->file_comment)) != STRING)
- Error (QUOTE_MSG, "ModulePath");
- l = FALSE;
- str = val.str;
- if (ptr->file_modulepath == NULL)
- {
- ptr->file_modulepath = malloc (1);
- ptr->file_modulepath[0] = '\0';
- k = strlen (str) + 1;
- }
- else
- {
- k = strlen (ptr->file_modulepath) + strlen (str) + 1;
- if (ptr->file_modulepath[strlen (ptr->file_modulepath) - 1] != ',')
- {
- k++;
- l = TRUE;
- }
- }
- ptr->file_modulepath = realloc (ptr->file_modulepath, k);
- if (l)
- strcat (ptr->file_modulepath, ",");
-
- strcat (ptr->file_modulepath, str);
- free (val.str);
- break;
- case LOGFILEPATH:
- if (xf86getSubToken (&(ptr->file_comment)) != STRING)
- Error (QUOTE_MSG, "LogFile");
- ptr->file_logfile = val.str;
- break;
- case XKBDIR:
- if (xf86getSubToken (&(ptr->file_xkbdir)) != STRING)
- Error (QUOTE_MSG, "XkbDir");
- ptr->file_xkbdir = val.str;
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG);
- break;
- case OBSOLETE_TOKEN:
- xf86parseError (OBSOLETE_MSG, xf86tokenString ());
- xf86getSubToken (&(ptr->file_comment));
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
+ int i, j;
+ int k, l;
+ char *str;
+ int token;
+
+ parsePrologue(XF86ConfFilesPtr, XF86ConfFilesRec)
+
+ while ((token = xf86getToken(FilesTab)) != ENDSECTION) {
+ switch (token) {
+ case COMMENT:
+ ptr->file_comment = xf86addComment(ptr->file_comment, val.str);
+ break;
+ case FONTPATH:
+ if (xf86getSubToken(&(ptr->file_comment)) != STRING)
+ Error(QUOTE_MSG, "FontPath");
+ j = FALSE;
+ str = val.str;
+ if (ptr->file_fontpath == NULL) {
+ ptr->file_fontpath = malloc(1);
+ ptr->file_fontpath[0] = '\0';
+ i = strlen(str) + 1;
+ }
+ else {
+ i = strlen(ptr->file_fontpath) + strlen(str) + 1;
+ if (ptr->file_fontpath[strlen(ptr->file_fontpath) - 1] != ',') {
+ i++;
+ j = TRUE;
+ }
+ }
+ ptr->file_fontpath = realloc(ptr->file_fontpath, i);
+ if (j)
+ strcat(ptr->file_fontpath, ",");
+
+ strcat(ptr->file_fontpath, str);
+ free(val.str);
+ break;
+ case MODULEPATH:
+ if (xf86getSubToken(&(ptr->file_comment)) != STRING)
+ Error(QUOTE_MSG, "ModulePath");
+ l = FALSE;
+ str = val.str;
+ if (ptr->file_modulepath == NULL) {
+ ptr->file_modulepath = malloc(1);
+ ptr->file_modulepath[0] = '\0';
+ k = strlen(str) + 1;
+ }
+ else {
+ k = strlen(ptr->file_modulepath) + strlen(str) + 1;
+ if (ptr->file_modulepath[strlen(ptr->file_modulepath) - 1] !=
+ ',') {
+ k++;
+ l = TRUE;
+ }
+ }
+ ptr->file_modulepath = realloc(ptr->file_modulepath, k);
+ if (l)
+ strcat(ptr->file_modulepath, ",");
+
+ strcat(ptr->file_modulepath, str);
+ free(val.str);
+ break;
+ case LOGFILEPATH:
+ if (xf86getSubToken(&(ptr->file_comment)) != STRING)
+ Error(QUOTE_MSG, "LogFile");
+ ptr->file_logfile = val.str;
+ break;
+ case XKBDIR:
+ if (xf86getSubToken(&(ptr->file_xkbdir)) != STRING)
+ Error(QUOTE_MSG, "XkbDir");
+ ptr->file_xkbdir = val.str;
+ break;
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG);
+ break;
+ case OBSOLETE_TOKEN:
+ xf86parseError(OBSOLETE_MSG, xf86tokenString());
+ xf86getSubToken(&(ptr->file_comment));
+ break;
+ default:
+ Error(INVALID_KEYWORD_MSG, xf86tokenString());
+ break;
+ }
+ }
#ifdef DEBUG
- printf ("File section parsed\n");
+ printf("File section parsed\n");
#endif
- return ptr;
+ return ptr;
}
#undef CLEANUP
void
-xf86printFileSection (FILE * cf, XF86ConfFilesPtr ptr)
+xf86printFileSection(FILE * cf, XF86ConfFilesPtr ptr)
{
- char *p, *s;
-
- if (ptr == NULL)
- return;
-
- if (ptr->file_comment)
- fprintf (cf, "%s", ptr->file_comment);
- if (ptr->file_logfile)
- fprintf (cf, "\tLogFile \"%s\"\n", ptr->file_logfile);
- if (ptr->file_modulepath)
- {
- s = ptr->file_modulepath;
- p = index (s, ',');
- while (p)
- {
- *p = '\000';
- fprintf (cf, "\tModulePath \"%s\"\n", s);
- *p = ',';
- s = p;
- s++;
- p = index (s, ',');
- }
- fprintf (cf, "\tModulePath \"%s\"\n", s);
- }
- if (ptr->file_fontpath)
- {
- s = ptr->file_fontpath;
- p = index (s, ',');
- while (p)
- {
- *p = '\000';
- fprintf (cf, "\tFontPath \"%s\"\n", s);
- *p = ',';
- s = p;
- s++;
- p = index (s, ',');
- }
- fprintf (cf, "\tFontPath \"%s\"\n", s);
- }
- if (ptr->file_xkbdir)
- fprintf (cf, "\tXkbDir \"%s\"\n", ptr->file_xkbdir);
+ char *p, *s;
+
+ if (ptr == NULL)
+ return;
+
+ if (ptr->file_comment)
+ fprintf(cf, "%s", ptr->file_comment);
+ if (ptr->file_logfile)
+ fprintf(cf, "\tLogFile \"%s\"\n", ptr->file_logfile);
+ if (ptr->file_modulepath) {
+ s = ptr->file_modulepath;
+ p = index(s, ',');
+ while (p) {
+ *p = '\000';
+ fprintf(cf, "\tModulePath \"%s\"\n", s);
+ *p = ',';
+ s = p;
+ s++;
+ p = index(s, ',');
+ }
+ fprintf(cf, "\tModulePath \"%s\"\n", s);
+ }
+ if (ptr->file_fontpath) {
+ s = ptr->file_fontpath;
+ p = index(s, ',');
+ while (p) {
+ *p = '\000';
+ fprintf(cf, "\tFontPath \"%s\"\n", s);
+ *p = ',';
+ s = p;
+ s++;
+ p = index(s, ',');
+ }
+ fprintf(cf, "\tFontPath \"%s\"\n", s);
+ }
+ if (ptr->file_xkbdir)
+ fprintf(cf, "\tXkbDir \"%s\"\n", ptr->file_xkbdir);
}
void
-xf86freeFiles (XF86ConfFilesPtr p)
+xf86freeFiles(XF86ConfFilesPtr p)
{
- if (p == NULL)
- return;
+ if (p == NULL)
+ return;
- TestFree (p->file_logfile);
- TestFree (p->file_modulepath);
- TestFree (p->file_fontpath);
- TestFree (p->file_comment);
- TestFree (p->file_xkbdir);
+ TestFree(p->file_logfile);
+ TestFree(p->file_modulepath);
+ TestFree(p->file_fontpath);
+ TestFree(p->file_comment);
+ TestFree(p->file_xkbdir);
- free (p);
+ free(p);
}
diff --git a/xorg-server/hw/xfree86/parser/Flags.c b/xorg-server/hw/xfree86/parser/Flags.c
index c2a04062c..29a60a2e1 100644
--- a/xorg-server/hw/xfree86/parser/Flags.c
+++ b/xorg-server/hw/xfree86/parser/Flags.c
@@ -51,7 +51,6 @@
* authorization from the copyright holder(s) and author(s).
*/
-
/* View/edit this file with tab stops set to 4 */
#ifdef HAVE_XORG_CONFIG_H
@@ -67,242 +66,239 @@
extern LexRec val;
-static xf86ConfigSymTabRec ServerFlagsTab[] =
-{
- {ENDSECTION, "endsection"},
- {NOTRAPSIGNALS, "notrapsignals"},
- {DONTZAP, "dontzap"},
- {DONTZOOM, "dontzoom"},
- {DISABLEVIDMODE, "disablevidmodeextension"},
- {ALLOWNONLOCAL, "allownonlocalxvidtune"},
- {DISABLEMODINDEV, "disablemodindev"},
- {MODINDEVALLOWNONLOCAL, "allownonlocalmodindev"},
- {ALLOWMOUSEOPENFAIL, "allowmouseopenfail"},
- {OPTION, "option"},
- {BLANKTIME, "blanktime"},
- {STANDBYTIME, "standbytime"},
- {SUSPENDTIME, "suspendtime"},
- {OFFTIME, "offtime"},
- {DEFAULTLAYOUT, "defaultserverlayout"},
- {-1, ""},
+static xf86ConfigSymTabRec ServerFlagsTab[] = {
+ {ENDSECTION, "endsection"},
+ {NOTRAPSIGNALS, "notrapsignals"},
+ {DONTZAP, "dontzap"},
+ {DONTZOOM, "dontzoom"},
+ {DISABLEVIDMODE, "disablevidmodeextension"},
+ {ALLOWNONLOCAL, "allownonlocalxvidtune"},
+ {DISABLEMODINDEV, "disablemodindev"},
+ {MODINDEVALLOWNONLOCAL, "allownonlocalmodindev"},
+ {ALLOWMOUSEOPENFAIL, "allowmouseopenfail"},
+ {OPTION, "option"},
+ {BLANKTIME, "blanktime"},
+ {STANDBYTIME, "standbytime"},
+ {SUSPENDTIME, "suspendtime"},
+ {OFFTIME, "offtime"},
+ {DEFAULTLAYOUT, "defaultserverlayout"},
+ {-1, ""},
};
#define CLEANUP xf86freeFlags
XF86ConfFlagsPtr
-xf86parseFlagsSection (void)
+xf86parseFlagsSection(void)
{
- int token;
- parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec)
-
- while ((token = xf86getToken (ServerFlagsTab)) != ENDSECTION)
- {
- int hasvalue = FALSE;
- int strvalue = FALSE;
- int tokentype;
- switch (token)
- {
- case COMMENT:
- ptr->flg_comment = xf86addComment(ptr->flg_comment, val.str);
- break;
- /*
- * these old keywords are turned into standard generic options.
- * we fall through here on purpose
- */
- case DEFAULTLAYOUT:
- strvalue = TRUE;
- case BLANKTIME:
- case STANDBYTIME:
- case SUSPENDTIME:
- case OFFTIME:
- hasvalue = TRUE;
- case NOTRAPSIGNALS:
- case DONTZAP:
- case DONTZOOM:
- case DISABLEVIDMODE:
- case ALLOWNONLOCAL:
- case DISABLEMODINDEV:
- case MODINDEVALLOWNONLOCAL:
- case ALLOWMOUSEOPENFAIL:
- {
- int i = 0;
- while (ServerFlagsTab[i].token != -1)
- {
- char *tmp;
-
- if (ServerFlagsTab[i].token == token)
- {
- char *valstr = NULL;
- tmp = strdup (ServerFlagsTab[i].name);
- if (hasvalue)
- {
- tokentype = xf86getSubToken(&(ptr->flg_comment));
- if (strvalue) {
- if (tokentype != STRING)
- Error (QUOTE_MSG, tmp);
- valstr = val.str;
- } else {
- if (tokentype != NUMBER)
- Error (NUMBER_MSG, tmp);
- if (asprintf(&valstr, "%d", val.num) == -1)
- valstr = NULL;
- }
- }
- ptr->flg_option_lst = xf86addNewOption
- (ptr->flg_option_lst, tmp, valstr);
- }
- i++;
- }
- }
- break;
- case OPTION:
- ptr->flg_option_lst = xf86parseOption(ptr->flg_option_lst);
- break;
-
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
+ int token;
+
+ parsePrologue(XF86ConfFlagsPtr, XF86ConfFlagsRec)
+
+ while ((token = xf86getToken(ServerFlagsTab)) != ENDSECTION) {
+ int hasvalue = FALSE;
+ int strvalue = FALSE;
+ int tokentype;
+
+ switch (token) {
+ case COMMENT:
+ ptr->flg_comment = xf86addComment(ptr->flg_comment, val.str);
+ break;
+ /*
+ * these old keywords are turned into standard generic options.
+ * we fall through here on purpose
+ */
+ case DEFAULTLAYOUT:
+ strvalue = TRUE;
+ case BLANKTIME:
+ case STANDBYTIME:
+ case SUSPENDTIME:
+ case OFFTIME:
+ hasvalue = TRUE;
+ case NOTRAPSIGNALS:
+ case DONTZAP:
+ case DONTZOOM:
+ case DISABLEVIDMODE:
+ case ALLOWNONLOCAL:
+ case DISABLEMODINDEV:
+ case MODINDEVALLOWNONLOCAL:
+ case ALLOWMOUSEOPENFAIL:
+ {
+ int i = 0;
+
+ while (ServerFlagsTab[i].token != -1) {
+ char *tmp;
+
+ if (ServerFlagsTab[i].token == token) {
+ char *valstr = NULL;
+
+ tmp = strdup(ServerFlagsTab[i].name);
+ if (hasvalue) {
+ tokentype = xf86getSubToken(&(ptr->flg_comment));
+ if (strvalue) {
+ if (tokentype != STRING)
+ Error(QUOTE_MSG, tmp);
+ valstr = val.str;
+ }
+ else {
+ if (tokentype != NUMBER)
+ Error(NUMBER_MSG, tmp);
+ if (asprintf(&valstr, "%d", val.num) == -1)
+ valstr = NULL;
+ }
+ }
+ ptr->flg_option_lst = xf86addNewOption
+ (ptr->flg_option_lst, tmp, valstr);
+ }
+ i++;
+ }
+ }
+ break;
+ case OPTION:
+ ptr->flg_option_lst = xf86parseOption(ptr->flg_option_lst);
+ break;
+
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG);
+ break;
+ default:
+ Error(INVALID_KEYWORD_MSG, xf86tokenString());
+ break;
+ }
+ }
#ifdef DEBUG
- printf ("Flags section parsed\n");
+ printf("Flags section parsed\n");
#endif
- return ptr;
+ return ptr;
}
#undef CLEANUP
void
-xf86printServerFlagsSection (FILE * f, XF86ConfFlagsPtr flags)
+xf86printServerFlagsSection(FILE * f, XF86ConfFlagsPtr flags)
{
- XF86OptionPtr p;
-
- if ((!flags) || (!flags->flg_option_lst))
- return;
- p = flags->flg_option_lst;
- fprintf (f, "Section \"ServerFlags\"\n");
- if (flags->flg_comment)
- fprintf (f, "%s", flags->flg_comment);
- xf86printOptionList(f, p, 1);
- fprintf (f, "EndSection\n\n");
+ XF86OptionPtr p;
+
+ if ((!flags) || (!flags->flg_option_lst))
+ return;
+ p = flags->flg_option_lst;
+ fprintf(f, "Section \"ServerFlags\"\n");
+ if (flags->flg_comment)
+ fprintf(f, "%s", flags->flg_comment);
+ xf86printOptionList(f, p, 1);
+ fprintf(f, "EndSection\n\n");
}
static XF86OptionPtr
-addNewOption2 (XF86OptionPtr head, char *name, char *val, int used)
+addNewOption2(XF86OptionPtr head, char *name, char *val, int used)
{
- XF86OptionPtr new, old = NULL;
-
- /* Don't allow duplicates, free old strings */
- if (head != NULL && (old = xf86findOption(head, name)) != NULL) {
- new = old;
- free(new->opt_name);
- free(new->opt_val);
- }
- else
- new = calloc (1, sizeof (*new));
- new->opt_name = name;
- new->opt_val = val;
- new->opt_used = used;
-
- if (old)
- return head;
- return ((XF86OptionPtr) xf86addListItem ((glp) head, (glp) new));
+ XF86OptionPtr new, old = NULL;
+
+ /* Don't allow duplicates, free old strings */
+ if (head != NULL && (old = xf86findOption(head, name)) != NULL) {
+ new = old;
+ free(new->opt_name);
+ free(new->opt_val);
+ }
+ else
+ new = calloc(1, sizeof(*new));
+ new->opt_name = name;
+ new->opt_val = val;
+ new->opt_used = used;
+
+ if (old)
+ return head;
+ return ((XF86OptionPtr) xf86addListItem((glp) head, (glp) new));
}
XF86OptionPtr
-xf86addNewOption (XF86OptionPtr head, char *name, char *val)
+xf86addNewOption(XF86OptionPtr head, char *name, char *val)
{
- return addNewOption2(head, name, val, 0);
+ return addNewOption2(head, name, val, 0);
}
void
-xf86freeFlags (XF86ConfFlagsPtr flags)
+xf86freeFlags(XF86ConfFlagsPtr flags)
{
- if (flags == NULL)
- return;
- xf86optionListFree (flags->flg_option_lst);
- TestFree(flags->flg_comment);
- free (flags);
+ if (flags == NULL)
+ return;
+ xf86optionListFree(flags->flg_option_lst);
+ TestFree(flags->flg_comment);
+ free(flags);
}
XF86OptionPtr
-xf86optionListDup (XF86OptionPtr opt)
+xf86optionListDup(XF86OptionPtr opt)
{
- XF86OptionPtr newopt = NULL;
- char *val;
-
- while (opt)
- {
- val = opt->opt_val ? strdup(opt->opt_val) : NULL;
- newopt = xf86addNewOption(newopt, strdup(opt->opt_name), val);
- newopt->opt_used = opt->opt_used;
- if (opt->opt_comment)
- newopt->opt_comment = strdup(opt->opt_comment);
- opt = opt->list.next;
- }
- return newopt;
+ XF86OptionPtr newopt = NULL;
+ char *val;
+
+ while (opt) {
+ val = opt->opt_val ? strdup(opt->opt_val) : NULL;
+ newopt = xf86addNewOption(newopt, strdup(opt->opt_name), val);
+ newopt->opt_used = opt->opt_used;
+ if (opt->opt_comment)
+ newopt->opt_comment = strdup(opt->opt_comment);
+ opt = opt->list.next;
+ }
+ return newopt;
}
void
-xf86optionListFree (XF86OptionPtr opt)
+xf86optionListFree(XF86OptionPtr opt)
{
- XF86OptionPtr prev;
-
- while (opt)
- {
- TestFree (opt->opt_name);
- TestFree (opt->opt_val);
- TestFree (opt->opt_comment);
- prev = opt;
- opt = opt->list.next;
- free (prev);
- }
+ XF86OptionPtr prev;
+
+ while (opt) {
+ TestFree(opt->opt_name);
+ TestFree(opt->opt_val);
+ TestFree(opt->opt_comment);
+ prev = opt;
+ opt = opt->list.next;
+ free(prev);
+ }
}
char *
xf86optionName(XF86OptionPtr opt)
{
- if (opt)
- return opt->opt_name;
- return 0;
+ if (opt)
+ return opt->opt_name;
+ return 0;
}
char *
xf86optionValue(XF86OptionPtr opt)
{
- if (opt)
- return opt->opt_val;
- return 0;
+ if (opt)
+ return opt->opt_val;
+ return 0;
}
XF86OptionPtr
xf86newOption(char *name, char *value)
{
- XF86OptionPtr opt;
+ XF86OptionPtr opt;
- opt = calloc(1, sizeof (*opt));
- if (!opt)
- return NULL;
+ opt = calloc(1, sizeof(*opt));
+ if (!opt)
+ return NULL;
- opt->opt_used = 0;
- opt->list.next = 0;
- opt->opt_name = name;
- opt->opt_val = value;
+ opt->opt_used = 0;
+ opt->list.next = 0;
+ opt->opt_name = name;
+ opt->opt_val = value;
- return opt;
+ return opt;
}
XF86OptionPtr
xf86nextOption(XF86OptionPtr list)
{
- if (!list)
- return NULL;
- return list->list.next;
+ if (!list)
+ return NULL;
+ return list->list.next;
}
/*
@@ -312,15 +308,14 @@ xf86nextOption(XF86OptionPtr list)
*/
XF86OptionPtr
-xf86findOption (XF86OptionPtr list, const char *name)
+xf86findOption(XF86OptionPtr list, const char *name)
{
- while (list)
- {
- if (xf86nameCompare (list->opt_name, name) == 0)
- return list;
- list = list->list.next;
- }
- return NULL;
+ while (list) {
+ if (xf86nameCompare(list->opt_name, name) == 0)
+ return list;
+ list = list->list.next;
+ }
+ return NULL;
}
/*
@@ -331,45 +326,41 @@ xf86findOption (XF86OptionPtr list, const char *name)
*/
const char *
-xf86findOptionValue (XF86OptionPtr list, const char *name)
+xf86findOptionValue(XF86OptionPtr list, const char *name)
{
- XF86OptionPtr p = xf86findOption (list, name);
-
- if (p)
- {
- if (p->opt_val)
- return p->opt_val;
- else
- return "";
- }
- return NULL;
+ XF86OptionPtr p = xf86findOption(list, name);
+
+ if (p) {
+ if (p->opt_val)
+ return p->opt_val;
+ else
+ return "";
+ }
+ return NULL;
}
XF86OptionPtr
-xf86optionListCreate( const char **options, int count, int used )
+xf86optionListCreate(const char **options, int count, int used)
{
- XF86OptionPtr p = NULL;
- char *t1, *t2;
- int i;
-
- if (count == -1)
- {
- for (count = 0; options[count]; count++)
- ;
- }
- if( (count % 2) != 0 )
- {
- fprintf( stderr, "xf86optionListCreate: count must be an even number.\n" );
- return NULL;
- }
- for (i = 0; i < count; i += 2)
- {
- t1 = strdup(options[i]);
- t2 = strdup(options[i + 1]);
- p = addNewOption2 (p, t1, t2, used);
- }
-
- return p;
+ XF86OptionPtr p = NULL;
+ char *t1, *t2;
+ int i;
+
+ if (count == -1) {
+ for (count = 0; options[count]; count++);
+ }
+ if ((count % 2) != 0) {
+ fprintf(stderr,
+ "xf86optionListCreate: count must be an even number.\n");
+ return NULL;
+ }
+ for (i = 0; i < count; i += 2) {
+ t1 = strdup(options[i]);
+ t2 = strdup(options[i + 1]);
+ p = addNewOption2(p, t1, t2, used);
+ }
+
+ return p;
}
/* the 2 given lists are merged. If an option with the same name is present in
@@ -378,128 +369,130 @@ xf86optionListCreate( const char **options, int count, int used )
* are freed, and the original lists are no longer guaranteed to be complete.
*/
XF86OptionPtr
-xf86optionListMerge (XF86OptionPtr head, XF86OptionPtr tail)
+xf86optionListMerge(XF86OptionPtr head, XF86OptionPtr tail)
{
- XF86OptionPtr a, b, ap = NULL, bp = NULL;
-
- a = tail;
- b = head;
- while (tail && b) {
- if (xf86nameCompare (a->opt_name, b->opt_name) == 0) {
- if (b == head)
- head = a;
- else
- bp->list.next = a;
- if (a == tail)
- tail = a->list.next;
- else
- ap->list.next = a->list.next;
- a->list.next = b->list.next;
- b->list.next = NULL;
- xf86optionListFree (b);
- b = a->list.next;
- bp = a;
- a = tail;
- ap = NULL;
- } else {
- ap = a;
- if (!(a = a->list.next)) {
- a = tail;
- bp = b;
- b = b->list.next;
- ap = NULL;
- }
- }
- }
-
- if (head) {
- for (a = head; a->list.next; a = a->list.next)
- ;
- a->list.next = tail;
- } else
- head = tail;
-
- return head;
+ XF86OptionPtr a, b, ap = NULL, bp = NULL;
+
+ a = tail;
+ b = head;
+ while (tail && b) {
+ if (xf86nameCompare(a->opt_name, b->opt_name) == 0) {
+ if (b == head)
+ head = a;
+ else
+ bp->list.next = a;
+ if (a == tail)
+ tail = a->list.next;
+ else
+ ap->list.next = a->list.next;
+ a->list.next = b->list.next;
+ b->list.next = NULL;
+ xf86optionListFree(b);
+ b = a->list.next;
+ bp = a;
+ a = tail;
+ ap = NULL;
+ }
+ else {
+ ap = a;
+ if (!(a = a->list.next)) {
+ a = tail;
+ bp = b;
+ b = b->list.next;
+ ap = NULL;
+ }
+ }
+ }
+
+ if (head) {
+ for (a = head; a->list.next; a = a->list.next);
+ a->list.next = tail;
+ }
+ else
+ head = tail;
+
+ return head;
}
char *
xf86uLongToString(unsigned long i)
{
- char *s;
+ char *s;
- if (asprintf(&s, "%lu", i) == -1)
- return NULL;
- return s;
+ if (asprintf(&s, "%lu", i) == -1)
+ return NULL;
+ return s;
}
XF86OptionPtr
xf86parseOption(XF86OptionPtr head)
{
- XF86OptionPtr option, cnew, old;
- char *name, *comment = NULL;
- int token;
-
- if ((token = xf86getSubToken(&comment)) != STRING) {
- xf86parseError(BAD_OPTION_MSG);
- free(comment);
- return head;
- }
-
- name = val.str;
- if ((token = xf86getSubToken(&comment)) == STRING) {
- option = xf86newOption(name, val.str);
- option->opt_comment = comment;
- if ((token = xf86getToken(NULL)) == COMMENT)
- option->opt_comment = xf86addComment(option->opt_comment, val.str);
- else
- xf86unGetToken(token);
- }
- else {
- option = xf86newOption(name, NULL);
- option->opt_comment = comment;
- if (token == COMMENT)
- option->opt_comment = xf86addComment(option->opt_comment, val.str);
- else
- xf86unGetToken(token);
- }
-
- old = NULL;
-
- /* Don't allow duplicates */
- if (head != NULL && (old = xf86findOption(head, name)) != NULL) {
- cnew = old;
- free(option->opt_name);
- TestFree(option->opt_val);
- TestFree(option->opt_comment);
- free(option);
- }
- else
- cnew = option;
-
- if (old == NULL)
- return ((XF86OptionPtr)xf86addListItem((glp)head, (glp)cnew));
-
- return head;
+ XF86OptionPtr option, cnew, old;
+ char *name, *comment = NULL;
+ int token;
+
+ if ((token = xf86getSubToken(&comment)) != STRING) {
+ xf86parseError(BAD_OPTION_MSG);
+ free(comment);
+ return head;
+ }
+
+ name = val.str;
+ if ((token = xf86getSubToken(&comment)) == STRING) {
+ option = xf86newOption(name, val.str);
+ option->opt_comment = comment;
+ if ((token = xf86getToken(NULL)) == COMMENT)
+ option->opt_comment = xf86addComment(option->opt_comment, val.str);
+ else
+ xf86unGetToken(token);
+ }
+ else {
+ option = xf86newOption(name, NULL);
+ option->opt_comment = comment;
+ if (token == COMMENT)
+ option->opt_comment = xf86addComment(option->opt_comment, val.str);
+ else
+ xf86unGetToken(token);
+ }
+
+ old = NULL;
+
+ /* Don't allow duplicates */
+ if (head != NULL && (old = xf86findOption(head, name)) != NULL) {
+ cnew = old;
+ free(option->opt_name);
+ TestFree(option->opt_val);
+ TestFree(option->opt_comment);
+ free(option);
+ }
+ else
+ cnew = option;
+
+ if (old == NULL)
+ return ((XF86OptionPtr) xf86addListItem((glp) head, (glp) cnew));
+
+ return head;
}
void
-xf86printOptionList(FILE *fp, XF86OptionPtr list, int tabs)
+xf86printOptionList(FILE * fp, XF86OptionPtr list, int tabs)
{
- int i;
-
- if (!list)
- return;
- while (list) {
- for (i = 0; i < tabs; i++)
- fputc('\t', fp);
- if (list->opt_val)
- fprintf(fp, "Option \"%s\" \"%s\"", list->opt_name, list->opt_val);
- else
- fprintf(fp, "Option \"%s\"", list->opt_name);
- if (list->opt_comment)
- fprintf(fp, "%s", list->opt_comment);
- else
- fputc('\n', fp);
- list = list->list.next;
- }
+ int i;
+
+ if (!list)
+ return;
+ while (list) {
+ for (i = 0; i < tabs; i++)
+ fputc('\t', fp);
+ if (list->opt_val)
+ fprintf(fp, "Option \"%s\" \"%s\"", list->opt_name,
+ list->opt_val);
+ else
+ fprintf(fp, "Option \"%s\"", list->opt_name);
+ if (list->opt_comment)
+ fprintf(fp, "%s", list->opt_comment);
+ else
+ fputc('\n', fp);
+ list = list->list.next;
+ }
}
diff --git a/xorg-server/hw/xfree86/parser/Input.c b/xorg-server/hw/xfree86/parser/Input.c
index e6037732a..6e0073437 100644
--- a/xorg-server/hw/xfree86/parser/Input.c
+++ b/xorg-server/hw/xfree86/parser/Input.c
@@ -52,7 +52,6 @@
* authorization from the copyright holder(s) and author(s).
*/
-
/* View/edit this file with tab stops set to 4 */
#ifdef HAVE_XORG_CONFIG_H
@@ -67,147 +66,141 @@
extern LexRec val;
static
-xf86ConfigSymTabRec InputTab[] =
-{
- {ENDSECTION, "endsection"},
- {IDENTIFIER, "identifier"},
- {OPTION, "option"},
- {DRIVER, "driver"},
- {-1, ""},
+xf86ConfigSymTabRec InputTab[] = {
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {OPTION, "option"},
+ {DRIVER, "driver"},
+ {-1, ""},
};
#define CLEANUP xf86freeInputList
XF86ConfInputPtr
-xf86parseInputSection (void)
+xf86parseInputSection(void)
{
- int has_ident = FALSE;
- int token;
- parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
-
- while ((token = xf86getToken (InputTab)) != ENDSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
- Error (QUOTE_MSG, "Identifier");
- if (has_ident == TRUE)
- Error (MULTIPLE_MSG, "Identifier");
- ptr->inp_identifier = val.str;
- has_ident = TRUE;
- break;
- case DRIVER:
- if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
- Error (QUOTE_MSG, "Driver");
- if (strcmp(val.str, "keyboard") == 0) {
- ptr->inp_driver = strdup("kbd");
- free(val.str);
- }
- else
- ptr->inp_driver = val.str;
- break;
- case OPTION:
- ptr->inp_option_lst = xf86parseOption(ptr->inp_option_lst);
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
-
- if (!has_ident)
- Error (NO_IDENT_MSG);
+ int has_ident = FALSE;
+ int token;
+
+ parsePrologue(XF86ConfInputPtr, XF86ConfInputRec)
+
+ while ((token = xf86getToken(InputTab)) != ENDSECTION) {
+ switch (token) {
+ case COMMENT:
+ ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken(&(ptr->inp_comment)) != STRING)
+ Error(QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error(MULTIPLE_MSG, "Identifier");
+ ptr->inp_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case DRIVER:
+ if (xf86getSubToken(&(ptr->inp_comment)) != STRING)
+ Error(QUOTE_MSG, "Driver");
+ if (strcmp(val.str, "keyboard") == 0) {
+ ptr->inp_driver = strdup("kbd");
+ free(val.str);
+ }
+ else
+ ptr->inp_driver = val.str;
+ break;
+ case OPTION:
+ ptr->inp_option_lst = xf86parseOption(ptr->inp_option_lst);
+ break;
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG);
+ break;
+ default:
+ Error(INVALID_KEYWORD_MSG, xf86tokenString());
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error(NO_IDENT_MSG);
#ifdef DEBUG
- printf ("InputDevice section parsed\n");
+ printf("InputDevice section parsed\n");
#endif
- return ptr;
+ return ptr;
}
#undef CLEANUP
void
-xf86printInputSection (FILE * cf, XF86ConfInputPtr ptr)
+xf86printInputSection(FILE * cf, XF86ConfInputPtr ptr)
{
- while (ptr)
- {
- fprintf (cf, "Section \"InputDevice\"\n");
- if (ptr->inp_comment)
- fprintf (cf, "%s", ptr->inp_comment);
- if (ptr->inp_identifier)
- fprintf (cf, "\tIdentifier \"%s\"\n", ptr->inp_identifier);
- if (ptr->inp_driver)
- fprintf (cf, "\tDriver \"%s\"\n", ptr->inp_driver);
- xf86printOptionList(cf, ptr->inp_option_lst, 1);
- fprintf (cf, "EndSection\n\n");
- ptr = ptr->list.next;
- }
+ while (ptr) {
+ fprintf(cf, "Section \"InputDevice\"\n");
+ if (ptr->inp_comment)
+ fprintf(cf, "%s", ptr->inp_comment);
+ if (ptr->inp_identifier)
+ fprintf(cf, "\tIdentifier \"%s\"\n", ptr->inp_identifier);
+ if (ptr->inp_driver)
+ fprintf(cf, "\tDriver \"%s\"\n", ptr->inp_driver);
+ xf86printOptionList(cf, ptr->inp_option_lst, 1);
+ fprintf(cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
}
void
-xf86freeInputList (XF86ConfInputPtr ptr)
+xf86freeInputList(XF86ConfInputPtr ptr)
{
- XF86ConfInputPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->inp_identifier);
- TestFree (ptr->inp_driver);
- TestFree (ptr->inp_comment);
- xf86optionListFree (ptr->inp_option_lst);
-
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
+ XF86ConfInputPtr prev;
+
+ while (ptr) {
+ TestFree(ptr->inp_identifier);
+ TestFree(ptr->inp_driver);
+ TestFree(ptr->inp_comment);
+ xf86optionListFree(ptr->inp_option_lst);
+
+ prev = ptr;
+ ptr = ptr->list.next;
+ free(prev);
+ }
}
int
-xf86validateInput (XF86ConfigPtr p)
+xf86validateInput(XF86ConfigPtr p)
{
- XF86ConfInputPtr input = p->conf_input_lst;
-
- while (input) {
- if (!input->inp_driver) {
- xf86validationError (UNDEFINED_INPUTDRIVER_MSG, input->inp_identifier);
- return FALSE;
- }
- input = input->list.next;
- }
- return TRUE;
+ XF86ConfInputPtr input = p->conf_input_lst;
+
+ while (input) {
+ if (!input->inp_driver) {
+ xf86validationError(UNDEFINED_INPUTDRIVER_MSG,
+ input->inp_identifier);
+ return FALSE;
+ }
+ input = input->list.next;
+ }
+ return TRUE;
}
XF86ConfInputPtr
-xf86findInput (const char *ident, XF86ConfInputPtr p)
+xf86findInput(const char *ident, XF86ConfInputPtr p)
{
- while (p)
- {
- if (xf86nameCompare (ident, p->inp_identifier) == 0)
- return p;
-
- p = p->list.next;
- }
- return NULL;
+ while (p) {
+ if (xf86nameCompare(ident, p->inp_identifier) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
}
XF86ConfInputPtr
-xf86findInputByDriver (const char *driver, XF86ConfInputPtr p)
+xf86findInputByDriver(const char *driver, XF86ConfInputPtr p)
{
- while (p)
- {
- if (xf86nameCompare (driver, p->inp_driver) == 0)
- return p;
-
- p = p->list.next;
- }
- return NULL;
-}
+ while (p) {
+ if (xf86nameCompare(driver, p->inp_driver) == 0)
+ return p;
+ p = p->list.next;
+ }
+ return NULL;
+}
diff --git a/xorg-server/hw/xfree86/parser/InputClass.c b/xorg-server/hw/xfree86/parser/InputClass.c
index c25117c1a..8493685cd 100644
--- a/xorg-server/hw/xfree86/parser/InputClass.c
+++ b/xorg-server/hw/xfree86/parser/InputClass.c
@@ -38,8 +38,7 @@
extern LexRec val;
static
-xf86ConfigSymTabRec InputClassTab[] =
-{
+xf86ConfigSymTabRec InputClassTab[] = {
{ENDSECTION, "endsection"},
{IDENTIFIER, "identifier"},
{OPTION, "option"},
@@ -86,8 +85,8 @@ xf86parseInputClassSection(void)
parsePrologue(XF86ConfInputClassPtr, XF86ConfInputClassRec)
- /* Initialize MatchGroup lists */
- xorg_list_init(&ptr->match_product);
+ /* Initialize MatchGroup lists */
+ xorg_list_init(&ptr->match_product);
xorg_list_init(&ptr->match_vendor);
xorg_list_init(&ptr->match_device);
xorg_list_init(&ptr->match_os);
@@ -147,8 +146,7 @@ xf86parseInputClassSection(void)
case MATCH_OS:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchOS");
- add_group_entry(&ptr->match_os,
- xstrtokenize(val.str, TOKEN_SEP));
+ add_group_entry(&ptr->match_os, xstrtokenize(val.str, TOKEN_SEP));
free(val.str);
break;
case MATCH_PNPID:
@@ -175,8 +173,7 @@ xf86parseInputClassSection(void)
case MATCH_TAG:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchTag");
- add_group_entry(&ptr->match_tag,
- xstrtokenize(val.str, TOKEN_SEP));
+ add_group_entry(&ptr->match_tag, xstrtokenize(val.str, TOKEN_SEP));
free(val.str);
break;
case MATCH_LAYOUT:
@@ -216,8 +213,7 @@ xf86parseInputClassSection(void)
case MATCH_IS_TABLET:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchIsTablet");
- ptr->is_tablet.set = xf86getBoolValue(&ptr->is_tablet.val,
- val.str);
+ ptr->is_tablet.set = xf86getBoolValue(&ptr->is_tablet.val, val.str);
free(val.str);
if (!ptr->is_tablet.set)
Error(BOOL_MSG, "MatchIsTablet");
@@ -244,7 +240,7 @@ xf86parseInputClassSection(void)
Error(UNEXPECTED_EOF_MSG);
break;
default:
- Error(INVALID_KEYWORD_MSG, xf86tokenString ());
+ Error(INVALID_KEYWORD_MSG, xf86tokenString());
break;
}
}
@@ -260,10 +256,10 @@ xf86parseInputClassSection(void)
}
void
-xf86printInputClassSection (FILE * cf, XF86ConfInputClassPtr ptr)
+xf86printInputClassSection(FILE * cf, XF86ConfInputClassPtr ptr)
{
const xf86MatchGroup *group;
- char * const *cur;
+ char *const *cur;
while (ptr) {
fprintf(cf, "Section \"InputClass\"\n");
@@ -363,7 +359,7 @@ xf86printInputClassSection (FILE * cf, XF86ConfInputClassPtr ptr)
}
void
-xf86freeInputClassList (XF86ConfInputClassPtr ptr)
+xf86freeInputClassList(XF86ConfInputClassPtr ptr)
{
XF86ConfInputClassPtr prev;
diff --git a/xorg-server/hw/xfree86/parser/Layout.c b/xorg-server/hw/xfree86/parser/Layout.c
index 7dd4ebfc6..bd33d6dfc 100644
--- a/xorg-server/hw/xfree86/parser/Layout.c
+++ b/xorg-server/hw/xfree86/parser/Layout.c
@@ -52,7 +52,6 @@
* authorization from the copyright holder(s) and author(s).
*/
-
/* View/edit this file with tab stops set to 4 */
#ifdef HAVE_XORG_CONFIG_H
@@ -66,377 +65,363 @@
#include "optionstr.h"
/* Needed for auto server layout */
-extern int xf86CheckBoolOption(void* optlist, const char *name, int deflt);
+extern int xf86CheckBoolOption(void *optlist, const char *name, int deflt);
extern LexRec val;
-static xf86ConfigSymTabRec LayoutTab[] =
-{
- {ENDSECTION, "endsection"},
- {SCREEN, "screen"},
- {IDENTIFIER, "identifier"},
- {INACTIVE, "inactive"},
- {INPUTDEVICE, "inputdevice"},
- {OPTION, "option"},
- {-1, ""},
+static xf86ConfigSymTabRec LayoutTab[] = {
+ {ENDSECTION, "endsection"},
+ {SCREEN, "screen"},
+ {IDENTIFIER, "identifier"},
+ {INACTIVE, "inactive"},
+ {INPUTDEVICE, "inputdevice"},
+ {OPTION, "option"},
+ {-1, ""},
};
-static xf86ConfigSymTabRec AdjTab[] =
-{
- {RIGHTOF, "rightof"},
- {LEFTOF, "leftof"},
- {ABOVE, "above"},
- {BELOW, "below"},
- {RELATIVE, "relative"},
- {ABSOLUTE, "absolute"},
- {-1, ""},
+static xf86ConfigSymTabRec AdjTab[] = {
+ {RIGHTOF, "rightof"},
+ {LEFTOF, "leftof"},
+ {ABOVE, "above"},
+ {BELOW, "below"},
+ {RELATIVE, "relative"},
+ {ABSOLUTE, "absolute"},
+ {-1, ""},
};
#define CLEANUP xf86freeLayoutList
XF86ConfLayoutPtr
-xf86parseLayoutSection (void)
+xf86parseLayoutSection(void)
{
- int has_ident = FALSE;
- int token;
- parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec)
-
- while ((token = xf86getToken (LayoutTab)) != ENDSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->lay_comment = xf86addComment(ptr->lay_comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING)
- Error (QUOTE_MSG, "Identifier");
- if (has_ident == TRUE)
- Error (MULTIPLE_MSG, "Identifier");
- ptr->lay_identifier = val.str;
- has_ident = TRUE;
- break;
- case INACTIVE:
- {
- XF86ConfInactivePtr iptr;
-
- iptr = calloc (1, sizeof (XF86ConfInactiveRec));
- iptr->list.next = NULL;
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
- free (iptr);
- Error (INACTIVE_MSG);
- }
- iptr->inactive_device_str = val.str;
- ptr->lay_inactive_lst = (XF86ConfInactivePtr)
- xf86addListItem ((glp) ptr->lay_inactive_lst, (glp) iptr);
- }
- break;
- case SCREEN:
- {
- XF86ConfAdjacencyPtr aptr;
- int absKeyword = 0;
-
- aptr = calloc (1, sizeof (XF86ConfAdjacencyRec));
- aptr->list.next = NULL;
- aptr->adj_scrnum = -1;
- aptr->adj_where = CONF_ADJ_OBSOLETE;
- aptr->adj_x = 0;
- aptr->adj_y = 0;
- aptr->adj_refscreen = NULL;
- if ((token = xf86getSubToken (&(ptr->lay_comment))) == NUMBER)
- aptr->adj_scrnum = val.num;
- else
- xf86unGetToken (token);
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token != STRING) {
- free(aptr);
- Error (SCREEN_MSG);
- }
- aptr->adj_screen_str = val.str;
-
- token = xf86getSubTokenWithTab(&(ptr->lay_comment), AdjTab);
- switch (token)
- {
- case RIGHTOF:
- aptr->adj_where = CONF_ADJ_RIGHTOF;
- break;
- case LEFTOF:
- aptr->adj_where = CONF_ADJ_LEFTOF;
- break;
- case ABOVE:
- aptr->adj_where = CONF_ADJ_ABOVE;
- break;
- case BELOW:
- aptr->adj_where = CONF_ADJ_BELOW;
- break;
- case RELATIVE:
- aptr->adj_where = CONF_ADJ_RELATIVE;
- break;
- case ABSOLUTE:
- aptr->adj_where = CONF_ADJ_ABSOLUTE;
- absKeyword = 1;
- break;
- case EOF_TOKEN:
- free(aptr);
- Error (UNEXPECTED_EOF_MSG);
- break;
- default:
- xf86unGetToken (token);
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token == STRING)
- aptr->adj_where = CONF_ADJ_OBSOLETE;
- else
- aptr->adj_where = CONF_ADJ_ABSOLUTE;
- }
- switch (aptr->adj_where)
- {
- case CONF_ADJ_ABSOLUTE:
- if (absKeyword)
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token == NUMBER)
- {
- aptr->adj_x = val.num;
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token != NUMBER) {
- free(aptr);
- Error(INVALID_SCR_MSG);
- }
- aptr->adj_y = val.num;
- } else {
- if (absKeyword) {
- free(aptr);
- Error(INVALID_SCR_MSG);
- } else
- xf86unGetToken (token);
- }
- break;
- case CONF_ADJ_RIGHTOF:
- case CONF_ADJ_LEFTOF:
- case CONF_ADJ_ABOVE:
- case CONF_ADJ_BELOW:
- case CONF_ADJ_RELATIVE:
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token != STRING) {
- free(aptr);
- Error(INVALID_SCR_MSG);
- }
- aptr->adj_refscreen = val.str;
- if (aptr->adj_where == CONF_ADJ_RELATIVE)
- {
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token != NUMBER) {
- free(aptr);
- Error(INVALID_SCR_MSG);
- }
- aptr->adj_x = val.num;
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token != NUMBER) {
- free(aptr);
- Error(INVALID_SCR_MSG);
- }
- aptr->adj_y = val.num;
- }
- break;
- case CONF_ADJ_OBSOLETE:
- /* top */
- aptr->adj_top_str = val.str;
-
- /* bottom */
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
- free(aptr);
- Error (SCREEN_MSG);
- }
- aptr->adj_bottom_str = val.str;
-
- /* left */
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
- free(aptr);
- Error (SCREEN_MSG);
- }
- aptr->adj_left_str = val.str;
-
- /* right */
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
- free(aptr);
- Error (SCREEN_MSG);
- }
- aptr->adj_right_str = val.str;
-
- }
- ptr->lay_adjacency_lst = (XF86ConfAdjacencyPtr)
- xf86addListItem ((glp) ptr->lay_adjacency_lst, (glp) aptr);
- }
- break;
- case INPUTDEVICE:
- {
- XF86ConfInputrefPtr iptr;
-
- iptr = calloc (1, sizeof (XF86ConfInputrefRec));
- iptr->list.next = NULL;
- iptr->iref_option_lst = NULL;
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
- free(iptr);
- Error (INPUTDEV_MSG);
- }
- iptr->iref_inputdev_str = val.str;
- while ((token = xf86getSubToken (&(ptr->lay_comment))) == STRING)
- {
- iptr->iref_option_lst =
- xf86addNewOption (iptr->iref_option_lst, val.str, NULL);
- }
- xf86unGetToken (token);
- ptr->lay_input_lst = (XF86ConfInputrefPtr)
- xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
- }
- break;
- case OPTION:
- ptr->lay_option_lst = xf86parseOption(ptr->lay_option_lst);
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
-
- if (!has_ident)
- Error (NO_IDENT_MSG);
+ int has_ident = FALSE;
+ int token;
+
+ parsePrologue(XF86ConfLayoutPtr, XF86ConfLayoutRec)
+
+ while ((token = xf86getToken(LayoutTab)) != ENDSECTION) {
+ switch (token) {
+ case COMMENT:
+ ptr->lay_comment = xf86addComment(ptr->lay_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken(&(ptr->lay_comment)) != STRING)
+ Error(QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error(MULTIPLE_MSG, "Identifier");
+ ptr->lay_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case INACTIVE:
+ {
+ XF86ConfInactivePtr iptr;
+
+ iptr = calloc(1, sizeof(XF86ConfInactiveRec));
+ iptr->list.next = NULL;
+ if (xf86getSubToken(&(ptr->lay_comment)) != STRING) {
+ free(iptr);
+ Error(INACTIVE_MSG);
+ }
+ iptr->inactive_device_str = val.str;
+ ptr->lay_inactive_lst = (XF86ConfInactivePtr)
+ xf86addListItem((glp) ptr->lay_inactive_lst, (glp) iptr);
+ }
+ break;
+ case SCREEN:
+ {
+ XF86ConfAdjacencyPtr aptr;
+ int absKeyword = 0;
+
+ aptr = calloc(1, sizeof(XF86ConfAdjacencyRec));
+ aptr->list.next = NULL;
+ aptr->adj_scrnum = -1;
+ aptr->adj_where = CONF_ADJ_OBSOLETE;
+ aptr->adj_x = 0;
+ aptr->adj_y = 0;
+ aptr->adj_refscreen = NULL;
+ if ((token = xf86getSubToken(&(ptr->lay_comment))) == NUMBER)
+ aptr->adj_scrnum = val.num;
+ else
+ xf86unGetToken(token);
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != STRING) {
+ free(aptr);
+ Error(SCREEN_MSG);
+ }
+ aptr->adj_screen_str = val.str;
+
+ token = xf86getSubTokenWithTab(&(ptr->lay_comment), AdjTab);
+ switch (token) {
+ case RIGHTOF:
+ aptr->adj_where = CONF_ADJ_RIGHTOF;
+ break;
+ case LEFTOF:
+ aptr->adj_where = CONF_ADJ_LEFTOF;
+ break;
+ case ABOVE:
+ aptr->adj_where = CONF_ADJ_ABOVE;
+ break;
+ case BELOW:
+ aptr->adj_where = CONF_ADJ_BELOW;
+ break;
+ case RELATIVE:
+ aptr->adj_where = CONF_ADJ_RELATIVE;
+ break;
+ case ABSOLUTE:
+ aptr->adj_where = CONF_ADJ_ABSOLUTE;
+ absKeyword = 1;
+ break;
+ case EOF_TOKEN:
+ free(aptr);
+ Error(UNEXPECTED_EOF_MSG);
+ break;
+ default:
+ xf86unGetToken(token);
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token == STRING)
+ aptr->adj_where = CONF_ADJ_OBSOLETE;
+ else
+ aptr->adj_where = CONF_ADJ_ABSOLUTE;
+ }
+ switch (aptr->adj_where) {
+ case CONF_ADJ_ABSOLUTE:
+ if (absKeyword)
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token == NUMBER) {
+ aptr->adj_x = val.num;
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != NUMBER) {
+ free(aptr);
+ Error(INVALID_SCR_MSG);
+ }
+ aptr->adj_y = val.num;
+ }
+ else {
+ if (absKeyword) {
+ free(aptr);
+ Error(INVALID_SCR_MSG);
+ }
+ else
+ xf86unGetToken(token);
+ }
+ break;
+ case CONF_ADJ_RIGHTOF:
+ case CONF_ADJ_LEFTOF:
+ case CONF_ADJ_ABOVE:
+ case CONF_ADJ_BELOW:
+ case CONF_ADJ_RELATIVE:
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != STRING) {
+ free(aptr);
+ Error(INVALID_SCR_MSG);
+ }
+ aptr->adj_refscreen = val.str;
+ if (aptr->adj_where == CONF_ADJ_RELATIVE) {
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != NUMBER) {
+ free(aptr);
+ Error(INVALID_SCR_MSG);
+ }
+ aptr->adj_x = val.num;
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != NUMBER) {
+ free(aptr);
+ Error(INVALID_SCR_MSG);
+ }
+ aptr->adj_y = val.num;
+ }
+ break;
+ case CONF_ADJ_OBSOLETE:
+ /* top */
+ aptr->adj_top_str = val.str;
+
+ /* bottom */
+ if (xf86getSubToken(&(ptr->lay_comment)) != STRING) {
+ free(aptr);
+ Error(SCREEN_MSG);
+ }
+ aptr->adj_bottom_str = val.str;
+
+ /* left */
+ if (xf86getSubToken(&(ptr->lay_comment)) != STRING) {
+ free(aptr);
+ Error(SCREEN_MSG);
+ }
+ aptr->adj_left_str = val.str;
+
+ /* right */
+ if (xf86getSubToken(&(ptr->lay_comment)) != STRING) {
+ free(aptr);
+ Error(SCREEN_MSG);
+ }
+ aptr->adj_right_str = val.str;
+
+ }
+ ptr->lay_adjacency_lst = (XF86ConfAdjacencyPtr)
+ xf86addListItem((glp) ptr->lay_adjacency_lst, (glp) aptr);
+ }
+ break;
+ case INPUTDEVICE:
+ {
+ XF86ConfInputrefPtr iptr;
+
+ iptr = calloc(1, sizeof(XF86ConfInputrefRec));
+ iptr->list.next = NULL;
+ iptr->iref_option_lst = NULL;
+ if (xf86getSubToken(&(ptr->lay_comment)) != STRING) {
+ free(iptr);
+ Error(INPUTDEV_MSG);
+ }
+ iptr->iref_inputdev_str = val.str;
+ while ((token = xf86getSubToken(&(ptr->lay_comment))) == STRING) {
+ iptr->iref_option_lst =
+ xf86addNewOption(iptr->iref_option_lst, val.str, NULL);
+ }
+ xf86unGetToken(token);
+ ptr->lay_input_lst = (XF86ConfInputrefPtr)
+ xf86addListItem((glp) ptr->lay_input_lst, (glp) iptr);
+ }
+ break;
+ case OPTION:
+ ptr->lay_option_lst = xf86parseOption(ptr->lay_option_lst);
+ break;
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG);
+ break;
+ default:
+ Error(INVALID_KEYWORD_MSG, xf86tokenString());
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error(NO_IDENT_MSG);
#ifdef DEBUG
- printf ("Layout section parsed\n");
+ printf("Layout section parsed\n");
#endif
- return ptr;
+ return ptr;
}
#undef CLEANUP
void
-xf86printLayoutSection (FILE * cf, XF86ConfLayoutPtr ptr)
+xf86printLayoutSection(FILE * cf, XF86ConfLayoutPtr ptr)
{
- XF86ConfAdjacencyPtr aptr;
- XF86ConfInactivePtr iptr;
- XF86ConfInputrefPtr inptr;
- XF86OptionPtr optr;
-
- while (ptr)
- {
- fprintf (cf, "Section \"ServerLayout\"\n");
- if (ptr->lay_comment)
- fprintf (cf, "%s", ptr->lay_comment);
- if (ptr->lay_identifier)
- fprintf (cf, "\tIdentifier \"%s\"\n", ptr->lay_identifier);
-
- for (aptr = ptr->lay_adjacency_lst; aptr; aptr = aptr->list.next)
- {
- fprintf (cf, "\tScreen ");
- if (aptr->adj_scrnum >= 0)
- fprintf (cf, "%2d", aptr->adj_scrnum);
- else
- fprintf (cf, " ");
- fprintf (cf, " \"%s\"", aptr->adj_screen_str);
- switch(aptr->adj_where)
- {
- case CONF_ADJ_OBSOLETE:
- fprintf (cf, " \"%s\"", aptr->adj_top_str);
- fprintf (cf, " \"%s\"", aptr->adj_bottom_str);
- fprintf (cf, " \"%s\"", aptr->adj_right_str);
- fprintf (cf, " \"%s\"\n", aptr->adj_left_str);
- break;
- case CONF_ADJ_ABSOLUTE:
- if (aptr->adj_x != -1)
- fprintf (cf, " %d %d\n", aptr->adj_x, aptr->adj_y);
- else
- fprintf (cf, "\n");
- break;
- case CONF_ADJ_RIGHTOF:
- fprintf (cf, " RightOf \"%s\"\n", aptr->adj_refscreen);
- break;
- case CONF_ADJ_LEFTOF:
- fprintf (cf, " LeftOf \"%s\"\n", aptr->adj_refscreen);
- break;
- case CONF_ADJ_ABOVE:
- fprintf (cf, " Above \"%s\"\n", aptr->adj_refscreen);
- break;
- case CONF_ADJ_BELOW:
- fprintf (cf, " Below \"%s\"\n", aptr->adj_refscreen);
- break;
- case CONF_ADJ_RELATIVE:
- fprintf (cf, " Relative \"%s\" %d %d\n", aptr->adj_refscreen,
- aptr->adj_x, aptr->adj_y);
- break;
- }
- }
- for (iptr = ptr->lay_inactive_lst; iptr; iptr = iptr->list.next)
- fprintf (cf, "\tInactive \"%s\"\n", iptr->inactive_device_str);
- for (inptr = ptr->lay_input_lst; inptr; inptr = inptr->list.next)
- {
- fprintf (cf, "\tInputDevice \"%s\"", inptr->iref_inputdev_str);
- for (optr = inptr->iref_option_lst; optr; optr = optr->list.next)
- {
- fprintf(cf, " \"%s\"", optr->opt_name);
- }
- fprintf(cf, "\n");
- }
- xf86printOptionList(cf, ptr->lay_option_lst, 1);
- fprintf (cf, "EndSection\n\n");
- ptr = ptr->list.next;
- }
+ XF86ConfAdjacencyPtr aptr;
+ XF86ConfInactivePtr iptr;
+ XF86ConfInputrefPtr inptr;
+ XF86OptionPtr optr;
+
+ while (ptr) {
+ fprintf(cf, "Section \"ServerLayout\"\n");
+ if (ptr->lay_comment)
+ fprintf(cf, "%s", ptr->lay_comment);
+ if (ptr->lay_identifier)
+ fprintf(cf, "\tIdentifier \"%s\"\n", ptr->lay_identifier);
+
+ for (aptr = ptr->lay_adjacency_lst; aptr; aptr = aptr->list.next) {
+ fprintf(cf, "\tScreen ");
+ if (aptr->adj_scrnum >= 0)
+ fprintf(cf, "%2d", aptr->adj_scrnum);
+ else
+ fprintf(cf, " ");
+ fprintf(cf, " \"%s\"", aptr->adj_screen_str);
+ switch (aptr->adj_where) {
+ case CONF_ADJ_OBSOLETE:
+ fprintf(cf, " \"%s\"", aptr->adj_top_str);
+ fprintf(cf, " \"%s\"", aptr->adj_bottom_str);
+ fprintf(cf, " \"%s\"", aptr->adj_right_str);
+ fprintf(cf, " \"%s\"\n", aptr->adj_left_str);
+ break;
+ case CONF_ADJ_ABSOLUTE:
+ if (aptr->adj_x != -1)
+ fprintf(cf, " %d %d\n", aptr->adj_x, aptr->adj_y);
+ else
+ fprintf(cf, "\n");
+ break;
+ case CONF_ADJ_RIGHTOF:
+ fprintf(cf, " RightOf \"%s\"\n", aptr->adj_refscreen);
+ break;
+ case CONF_ADJ_LEFTOF:
+ fprintf(cf, " LeftOf \"%s\"\n", aptr->adj_refscreen);
+ break;
+ case CONF_ADJ_ABOVE:
+ fprintf(cf, " Above \"%s\"\n", aptr->adj_refscreen);
+ break;
+ case CONF_ADJ_BELOW:
+ fprintf(cf, " Below \"%s\"\n", aptr->adj_refscreen);
+ break;
+ case CONF_ADJ_RELATIVE:
+ fprintf(cf, " Relative \"%s\" %d %d\n", aptr->adj_refscreen,
+ aptr->adj_x, aptr->adj_y);
+ break;
+ }
+ }
+ for (iptr = ptr->lay_inactive_lst; iptr; iptr = iptr->list.next)
+ fprintf(cf, "\tInactive \"%s\"\n", iptr->inactive_device_str);
+ for (inptr = ptr->lay_input_lst; inptr; inptr = inptr->list.next) {
+ fprintf(cf, "\tInputDevice \"%s\"", inptr->iref_inputdev_str);
+ for (optr = inptr->iref_option_lst; optr; optr = optr->list.next) {
+ fprintf(cf, " \"%s\"", optr->opt_name);
+ }
+ fprintf(cf, "\n");
+ }
+ xf86printOptionList(cf, ptr->lay_option_lst, 1);
+ fprintf(cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
}
static void
-xf86freeAdjacencyList (XF86ConfAdjacencyPtr ptr)
+xf86freeAdjacencyList(XF86ConfAdjacencyPtr ptr)
{
- XF86ConfAdjacencyPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->adj_screen_str);
- TestFree (ptr->adj_top_str);
- TestFree (ptr->adj_bottom_str);
- TestFree (ptr->adj_left_str);
- TestFree (ptr->adj_right_str);
-
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
+ XF86ConfAdjacencyPtr prev;
+
+ while (ptr) {
+ TestFree(ptr->adj_screen_str);
+ TestFree(ptr->adj_top_str);
+ TestFree(ptr->adj_bottom_str);
+ TestFree(ptr->adj_left_str);
+ TestFree(ptr->adj_right_str);
+
+ prev = ptr;
+ ptr = ptr->list.next;
+ free(prev);
+ }
}
static void
-xf86freeInputrefList (XF86ConfInputrefPtr ptr)
+xf86freeInputrefList(XF86ConfInputrefPtr ptr)
{
- XF86ConfInputrefPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->iref_inputdev_str);
- xf86optionListFree (ptr->iref_option_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
+ XF86ConfInputrefPtr prev;
+
+ while (ptr) {
+ TestFree(ptr->iref_inputdev_str);
+ xf86optionListFree(ptr->iref_option_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free(prev);
+ }
}
void
-xf86freeLayoutList (XF86ConfLayoutPtr ptr)
+xf86freeLayoutList(XF86ConfLayoutPtr ptr)
{
- XF86ConfLayoutPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->lay_identifier);
- TestFree (ptr->lay_comment);
- xf86freeAdjacencyList (ptr->lay_adjacency_lst);
- xf86freeInputrefList (ptr->lay_input_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
+ XF86ConfLayoutPtr prev;
+
+ while (ptr) {
+ TestFree(ptr->lay_identifier);
+ TestFree(ptr->lay_comment);
+ xf86freeAdjacencyList(ptr->lay_adjacency_lst);
+ xf86freeInputrefList(ptr->lay_input_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free(prev);
+ }
}
int
@@ -447,112 +432,103 @@ xf86layoutAddInputDevices(XF86ConfigPtr config, XF86ConfLayoutPtr layout)
XF86ConfInputrefPtr inptr;
/* add all AutoServerLayout devices to the server layout */
- while (input)
- {
- if (xf86CheckBoolOption(input->inp_option_lst, "AutoServerLayout", FALSE))
- {
- XF86ConfInputrefPtr iref = layout->lay_input_lst;
-
- /* avoid duplicates if referenced but lists AutoServerLayout too */
- while (iref)
- {
- if (strcmp(iref->iref_inputdev_str, input->inp_identifier) == 0)
- break;
- iref = iref->list.next;
- }
-
- if (!iref)
- {
- XF86ConfInputrefPtr iptr;
- iptr = calloc(1, sizeof(XF86ConfInputrefRec));
- iptr->iref_inputdev_str = input->inp_identifier;
- layout->lay_input_lst = (XF86ConfInputrefPtr)
- xf86addListItem((glp)layout->lay_input_lst, (glp)iptr);
- count++;
- }
- }
- input = input->list.next;
+ while (input) {
+ if (xf86CheckBoolOption
+ (input->inp_option_lst, "AutoServerLayout", FALSE)) {
+ XF86ConfInputrefPtr iref = layout->lay_input_lst;
+
+ /* avoid duplicates if referenced but lists AutoServerLayout too */
+ while (iref) {
+ if (strcmp(iref->iref_inputdev_str, input->inp_identifier) == 0)
+ break;
+ iref = iref->list.next;
+ }
+
+ if (!iref) {
+ XF86ConfInputrefPtr iptr;
+
+ iptr = calloc(1, sizeof(XF86ConfInputrefRec));
+ iptr->iref_inputdev_str = input->inp_identifier;
+ layout->lay_input_lst = (XF86ConfInputrefPtr)
+ xf86addListItem((glp) layout->lay_input_lst, (glp) iptr);
+ count++;
+ }
+ }
+ input = input->list.next;
}
inptr = layout->lay_input_lst;
- while (inptr)
- {
- input = xf86findInput (inptr->iref_inputdev_str,
- config->conf_input_lst);
- if (!input)
- {
- xf86validationError (UNDEFINED_INPUT_MSG,
- inptr->iref_inputdev_str, layout->lay_identifier);
- return -1;
- }
- else
- inptr->iref_inputdev = input;
- inptr = inptr->list.next;
+ while (inptr) {
+ input = xf86findInput(inptr->iref_inputdev_str, config->conf_input_lst);
+ if (!input) {
+ xf86validationError(UNDEFINED_INPUT_MSG,
+ inptr->iref_inputdev_str,
+ layout->lay_identifier);
+ return -1;
+ }
+ else
+ inptr->iref_inputdev = input;
+ inptr = inptr->list.next;
}
return count;
}
int
-xf86validateLayout (XF86ConfigPtr p)
+xf86validateLayout(XF86ConfigPtr p)
{
- XF86ConfLayoutPtr layout = p->conf_layout_lst;
- XF86ConfAdjacencyPtr adj;
- XF86ConfInactivePtr iptr;
- XF86ConfScreenPtr screen;
- XF86ConfDevicePtr device;
-
- while (layout)
- {
- adj = layout->lay_adjacency_lst;
- while (adj)
- {
- /* the first one can't be "" but all others can */
- screen = xf86findScreen (adj->adj_screen_str, p->conf_screen_lst);
- if (!screen)
- {
- xf86validationError (UNDEFINED_SCREEN_MSG,
- adj->adj_screen_str, layout->lay_identifier);
- return FALSE;
- }
- else
- adj->adj_screen = screen;
-
- adj = adj->list.next;
- }
- iptr = layout->lay_inactive_lst;
- while (iptr)
- {
- device = xf86findDevice (iptr->inactive_device_str,
- p->conf_device_lst);
- if (!device)
- {
- xf86validationError (UNDEFINED_DEVICE_LAY_MSG,
- iptr->inactive_device_str, layout->lay_identifier);
- return FALSE;
- }
- else
- iptr->inactive_device = device;
- iptr = iptr->list.next;
- }
-
- if (xf86layoutAddInputDevices(p, layout) == -1)
- return FALSE;
-
- layout = layout->list.next;
- }
- return TRUE;
+ XF86ConfLayoutPtr layout = p->conf_layout_lst;
+ XF86ConfAdjacencyPtr adj;
+ XF86ConfInactivePtr iptr;
+ XF86ConfScreenPtr screen;
+ XF86ConfDevicePtr device;
+
+ while (layout) {
+ adj = layout->lay_adjacency_lst;
+ while (adj) {
+ /* the first one can't be "" but all others can */
+ screen = xf86findScreen(adj->adj_screen_str, p->conf_screen_lst);
+ if (!screen) {
+ xf86validationError(UNDEFINED_SCREEN_MSG,
+ adj->adj_screen_str,
+ layout->lay_identifier);
+ return FALSE;
+ }
+ else
+ adj->adj_screen = screen;
+
+ adj = adj->list.next;
+ }
+ iptr = layout->lay_inactive_lst;
+ while (iptr) {
+ device = xf86findDevice(iptr->inactive_device_str,
+ p->conf_device_lst);
+ if (!device) {
+ xf86validationError(UNDEFINED_DEVICE_LAY_MSG,
+ iptr->inactive_device_str,
+ layout->lay_identifier);
+ return FALSE;
+ }
+ else
+ iptr->inactive_device = device;
+ iptr = iptr->list.next;
+ }
+
+ if (xf86layoutAddInputDevices(p, layout) == -1)
+ return FALSE;
+
+ layout = layout->list.next;
+ }
+ return TRUE;
}
XF86ConfLayoutPtr
-xf86findLayout (const char *name, XF86ConfLayoutPtr list)
+xf86findLayout(const char *name, XF86ConfLayoutPtr list)
{
- while (list)
- {
- if (xf86nameCompare (list->lay_identifier, name) == 0)
- return list;
- list = list->list.next;
- }
- return NULL;
+ while (list) {
+ if (xf86nameCompare(list->lay_identifier, name) == 0)
+ return list;
+ list = list->list.next;
+ }
+ return NULL;
}
-
diff --git a/xorg-server/hw/xfree86/parser/Module.c b/xorg-server/hw/xfree86/parser/Module.c
index 3c4cefc18..1c458ae6c 100644
--- a/xorg-server/hw/xfree86/parser/Module.c
+++ b/xorg-server/hw/xfree86/parser/Module.c
@@ -52,7 +52,6 @@
* authorization from the copyright holder(s) and author(s).
*/
-
/* View/edit this file with tab stops set to 4 */
#ifdef HAVE_XORG_CONFIG_H
@@ -65,215 +64,207 @@
extern LexRec val;
-static xf86ConfigSymTabRec SubModuleTab[] =
-{
- {ENDSUBSECTION, "endsubsection"},
- {OPTION, "option"},
- {-1, ""},
+static xf86ConfigSymTabRec SubModuleTab[] = {
+ {ENDSUBSECTION, "endsubsection"},
+ {OPTION, "option"},
+ {-1, ""},
};
-static xf86ConfigSymTabRec ModuleTab[] =
-{
- {ENDSECTION, "endsection"},
- {LOAD, "load"},
- {DISABLE, "disable"},
- {LOAD_DRIVER, "loaddriver"},
- {SUBSECTION, "subsection"},
- {-1, ""},
+static xf86ConfigSymTabRec ModuleTab[] = {
+ {ENDSECTION, "endsection"},
+ {LOAD, "load"},
+ {DISABLE, "disable"},
+ {LOAD_DRIVER, "loaddriver"},
+ {SUBSECTION, "subsection"},
+ {-1, ""},
};
#define CLEANUP xf86freeModules
static XF86LoadPtr
-xf86parseModuleSubSection (XF86LoadPtr head, char *name)
+xf86parseModuleSubSection(XF86LoadPtr head, char *name)
{
- int token;
- parsePrologue (XF86LoadPtr, XF86LoadRec)
+ int token;
- ptr->load_name = name;
- ptr->load_type = XF86_LOAD_MODULE;
- ptr->ignore = 0;
- ptr->load_opt = NULL;
- ptr->list.next = NULL;
+ parsePrologue(XF86LoadPtr, XF86LoadRec)
- while ((token = xf86getToken (SubModuleTab)) != ENDSUBSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->load_comment = xf86addComment(ptr->load_comment, val.str);
- break;
- case OPTION:
- ptr->load_opt = xf86parseOption(ptr->load_opt);
- break;
- case EOF_TOKEN:
- xf86parseError (UNEXPECTED_EOF_MSG);
- free(ptr);
- return NULL;
- default:
- xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ());
- free(ptr);
- return NULL;
- break;
- }
+ ptr->load_name = name;
+ ptr->load_type = XF86_LOAD_MODULE;
+ ptr->ignore = 0;
+ ptr->load_opt = NULL;
+ ptr->list.next = NULL;
- }
+ while ((token = xf86getToken(SubModuleTab)) != ENDSUBSECTION) {
+ switch (token) {
+ case COMMENT:
+ ptr->load_comment = xf86addComment(ptr->load_comment, val.str);
+ break;
+ case OPTION:
+ ptr->load_opt = xf86parseOption(ptr->load_opt);
+ break;
+ case EOF_TOKEN:
+ xf86parseError(UNEXPECTED_EOF_MSG);
+ free(ptr);
+ return NULL;
+ default:
+ xf86parseError(INVALID_KEYWORD_MSG, xf86tokenString());
+ free(ptr);
+ return NULL;
+ break;
+ }
- return ((XF86LoadPtr) xf86addListItem ((glp) head, (glp) ptr));
+ }
+
+ return ((XF86LoadPtr) xf86addListItem((glp) head, (glp) ptr));
}
XF86ConfModulePtr
-xf86parseModuleSection (void)
+xf86parseModuleSection(void)
{
- int token;
- parsePrologue (XF86ConfModulePtr, XF86ConfModuleRec)
+ int token;
+
+ parsePrologue(XF86ConfModulePtr, XF86ConfModuleRec)
- while ((token = xf86getToken (ModuleTab)) != ENDSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->mod_comment = xf86addComment(ptr->mod_comment, val.str);
- break;
- case LOAD:
- if (xf86getSubToken (&(ptr->mod_comment)) != STRING)
- Error (QUOTE_MSG, "Load");
- ptr->mod_load_lst =
- xf86addNewLoadDirective (ptr->mod_load_lst, val.str,
- XF86_LOAD_MODULE, NULL);
- break;
- case DISABLE:
- if (xf86getSubToken (&(ptr->mod_comment)) != STRING)
- Error (QUOTE_MSG, "Disable");
- ptr->mod_disable_lst =
- xf86addNewLoadDirective (ptr->mod_disable_lst, val.str,
- XF86_DISABLE_MODULE, NULL);
- break;
- case LOAD_DRIVER:
- if (xf86getSubToken (&(ptr->mod_comment)) != STRING)
- Error (QUOTE_MSG, "LoadDriver");
- ptr->mod_load_lst =
- xf86addNewLoadDirective (ptr->mod_load_lst, val.str,
- XF86_LOAD_DRIVER, NULL);
- break;
- case SUBSECTION:
- if (xf86getSubToken (&(ptr->mod_comment)) != STRING)
- Error (QUOTE_MSG, "SubSection");
- ptr->mod_load_lst =
- xf86parseModuleSubSection (ptr->mod_load_lst, val.str);
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
+ while ((token = xf86getToken(ModuleTab)) != ENDSECTION) {
+ switch (token) {
+ case COMMENT:
+ ptr->mod_comment = xf86addComment(ptr->mod_comment, val.str);
+ break;
+ case LOAD:
+ if (xf86getSubToken(&(ptr->mod_comment)) != STRING)
+ Error(QUOTE_MSG, "Load");
+ ptr->mod_load_lst =
+ xf86addNewLoadDirective(ptr->mod_load_lst, val.str,
+ XF86_LOAD_MODULE, NULL);
+ break;
+ case DISABLE:
+ if (xf86getSubToken(&(ptr->mod_comment)) != STRING)
+ Error(QUOTE_MSG, "Disable");
+ ptr->mod_disable_lst =
+ xf86addNewLoadDirective(ptr->mod_disable_lst, val.str,
+ XF86_DISABLE_MODULE, NULL);
+ break;
+ case LOAD_DRIVER:
+ if (xf86getSubToken(&(ptr->mod_comment)) != STRING)
+ Error(QUOTE_MSG, "LoadDriver");
+ ptr->mod_load_lst =
+ xf86addNewLoadDirective(ptr->mod_load_lst, val.str,
+ XF86_LOAD_DRIVER, NULL);
+ break;
+ case SUBSECTION:
+ if (xf86getSubToken(&(ptr->mod_comment)) != STRING)
+ Error(QUOTE_MSG, "SubSection");
+ ptr->mod_load_lst =
+ xf86parseModuleSubSection(ptr->mod_load_lst, val.str);
+ break;
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG);
+ break;
+ default:
+ Error(INVALID_KEYWORD_MSG, xf86tokenString());
+ break;
+ }
+ }
#ifdef DEBUG
- printf ("Module section parsed\n");
+ printf("Module section parsed\n");
#endif
- return ptr;
+ return ptr;
}
#undef CLEANUP
void
-xf86printModuleSection (FILE * cf, XF86ConfModulePtr ptr)
+xf86printModuleSection(FILE * cf, XF86ConfModulePtr ptr)
{
- XF86LoadPtr lptr;
+ XF86LoadPtr lptr;
- if (ptr == NULL)
- return;
+ if (ptr == NULL)
+ return;
- if (ptr->mod_comment)
- fprintf(cf, "%s", ptr->mod_comment);
- for (lptr = ptr->mod_load_lst; lptr; lptr = lptr->list.next)
- {
- switch (lptr->load_type)
- {
- case XF86_LOAD_MODULE:
- if( lptr->load_opt == NULL ) {
- fprintf (cf, "\tLoad \"%s\"", lptr->load_name);
- if (lptr->load_comment)
- fprintf(cf, "%s", lptr->load_comment);
- else
- fputc('\n', cf);
- }
- else
- {
- fprintf (cf, "\tSubSection \"%s\"\n", lptr->load_name);
- if (lptr->load_comment)
- fprintf(cf, "%s", lptr->load_comment);
- xf86printOptionList(cf, lptr->load_opt, 2);
- fprintf (cf, "\tEndSubSection\n");
- }
- break;
- case XF86_LOAD_DRIVER:
- fprintf (cf, "\tLoadDriver \"%s\"", lptr->load_name);
- if (lptr->load_comment)
- fprintf(cf, "%s", lptr->load_comment);
- else
- fputc('\n', cf);
- break;
+ if (ptr->mod_comment)
+ fprintf(cf, "%s", ptr->mod_comment);
+ for (lptr = ptr->mod_load_lst; lptr; lptr = lptr->list.next) {
+ switch (lptr->load_type) {
+ case XF86_LOAD_MODULE:
+ if (lptr->load_opt == NULL) {
+ fprintf(cf, "\tLoad \"%s\"", lptr->load_name);
+ if (lptr->load_comment)
+ fprintf(cf, "%s", lptr->load_comment);
+ else
+ fputc('\n', cf);
+ }
+ else {
+ fprintf(cf, "\tSubSection \"%s\"\n", lptr->load_name);
+ if (lptr->load_comment)
+ fprintf(cf, "%s", lptr->load_comment);
+ xf86printOptionList(cf, lptr->load_opt, 2);
+ fprintf(cf, "\tEndSubSection\n");
+ }
+ break;
+ case XF86_LOAD_DRIVER:
+ fprintf(cf, "\tLoadDriver \"%s\"", lptr->load_name);
+ if (lptr->load_comment)
+ fprintf(cf, "%s", lptr->load_comment);
+ else
+ fputc('\n', cf);
+ break;
#if 0
- default:
- fprintf (cf, "#\tUnknown type \"%s\"\n", lptr->load_name);
- break;
+ default:
+ fprintf(cf, "#\tUnknown type \"%s\"\n", lptr->load_name);
+ break;
#endif
- }
- }
+ }
+ }
}
XF86LoadPtr
-xf86addNewLoadDirective (XF86LoadPtr head, char *name, int type, XF86OptionPtr opts)
+xf86addNewLoadDirective(XF86LoadPtr head, char *name, int type,
+ XF86OptionPtr opts)
{
- XF86LoadPtr new;
- int token;
+ XF86LoadPtr new;
+ int token;
- new = calloc (1, sizeof (XF86LoadRec));
- new->load_name = name;
- new->load_type = type;
- new->load_opt = opts;
- new->ignore = 0;
- new->list.next = NULL;
+ new = calloc(1, sizeof(XF86LoadRec));
+ new->load_name = name;
+ new->load_type = type;
+ new->load_opt = opts;
+ new->ignore = 0;
+ new->list.next = NULL;
- if ((token = xf86getToken(NULL)) == COMMENT)
- new->load_comment = xf86addComment(new->load_comment, val.str);
- else
- xf86unGetToken(token);
+ if ((token = xf86getToken(NULL)) == COMMENT)
+ new->load_comment = xf86addComment(new->load_comment, val.str);
+ else
+ xf86unGetToken(token);
- return ((XF86LoadPtr) xf86addListItem ((glp) head, (glp) new));
+ return ((XF86LoadPtr) xf86addListItem((glp) head, (glp) new));
}
void
-xf86freeModules (XF86ConfModulePtr ptr)
+xf86freeModules(XF86ConfModulePtr ptr)
{
- XF86LoadPtr lptr;
- XF86LoadPtr prev;
+ XF86LoadPtr lptr;
+ XF86LoadPtr prev;
- if (ptr == NULL)
- return;
- lptr = ptr->mod_load_lst;
- while (lptr)
- {
- TestFree (lptr->load_name);
- TestFree (lptr->load_comment);
- prev = lptr;
- lptr = lptr->list.next;
- free (prev);
- }
- lptr = ptr->mod_disable_lst;
- while (lptr)
- {
- TestFree (lptr->load_name);
- TestFree (lptr->load_comment);
- prev = lptr;
- lptr = lptr->list.next;
- free (prev);
- }
- TestFree (ptr->mod_comment);
- free (ptr);
+ if (ptr == NULL)
+ return;
+ lptr = ptr->mod_load_lst;
+ while (lptr) {
+ TestFree(lptr->load_name);
+ TestFree(lptr->load_comment);
+ prev = lptr;
+ lptr = lptr->list.next;
+ free(prev);
+ }
+ lptr = ptr->mod_disable_lst;
+ while (lptr) {
+ TestFree(lptr->load_name);
+ TestFree(lptr->load_comment);
+ prev = lptr;
+ lptr = lptr->list.next;
+ free(prev);
+ }
+ TestFree(ptr->mod_comment);
+ free(ptr);
}
diff --git a/xorg-server/hw/xfree86/parser/Monitor.c b/xorg-server/hw/xfree86/parser/Monitor.c
index 52c55007e..b237dfb32 100644
--- a/xorg-server/hw/xfree86/parser/Monitor.c
+++ b/xorg-server/hw/xfree86/parser/Monitor.c
@@ -52,7 +52,6 @@
* authorization from the copyright holder(s) and author(s).
*/
-
/* View/edit this file with tab stops set to 4 */
#ifdef HAVE_XORG_CONFIG_H
@@ -65,348 +64,340 @@
extern LexRec val;
-static xf86ConfigSymTabRec MonitorTab[] =
-{
- {ENDSECTION, "endsection"},
- {IDENTIFIER, "identifier"},
- {VENDOR, "vendorname"},
- {MODEL, "modelname"},
- {USEMODES, "usemodes"},
- {MODELINE, "modeline"},
- {DISPLAYSIZE, "displaysize"},
- {HORIZSYNC, "horizsync"},
- {VERTREFRESH, "vertrefresh"},
- {MODE, "mode"},
- {GAMMA, "gamma"},
- {OPTION, "option"},
- {-1, ""},
+static xf86ConfigSymTabRec MonitorTab[] = {
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {VENDOR, "vendorname"},
+ {MODEL, "modelname"},
+ {USEMODES, "usemodes"},
+ {MODELINE, "modeline"},
+ {DISPLAYSIZE, "displaysize"},
+ {HORIZSYNC, "horizsync"},
+ {VERTREFRESH, "vertrefresh"},
+ {MODE, "mode"},
+ {GAMMA, "gamma"},
+ {OPTION, "option"},
+ {-1, ""},
};
-static xf86ConfigSymTabRec ModesTab[] =
-{
- {ENDSECTION, "endsection"},
- {IDENTIFIER, "identifier"},
- {MODELINE, "modeline"},
- {MODE, "mode"},
- {-1, ""},
+static xf86ConfigSymTabRec ModesTab[] = {
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {MODELINE, "modeline"},
+ {MODE, "mode"},
+ {-1, ""},
};
-static xf86ConfigSymTabRec TimingTab[] =
-{
- {TT_INTERLACE, "interlace"},
- {TT_PHSYNC, "+hsync"},
- {TT_NHSYNC, "-hsync"},
- {TT_PVSYNC, "+vsync"},
- {TT_NVSYNC, "-vsync"},
- {TT_CSYNC, "composite"},
- {TT_PCSYNC, "+csync"},
- {TT_NCSYNC, "-csync"},
- {TT_DBLSCAN, "doublescan"},
- {TT_HSKEW, "hskew"},
- {TT_BCAST, "bcast"},
- {TT_VSCAN, "vscan"},
- {-1, ""},
+static xf86ConfigSymTabRec TimingTab[] = {
+ {TT_INTERLACE, "interlace"},
+ {TT_PHSYNC, "+hsync"},
+ {TT_NHSYNC, "-hsync"},
+ {TT_PVSYNC, "+vsync"},
+ {TT_NVSYNC, "-vsync"},
+ {TT_CSYNC, "composite"},
+ {TT_PCSYNC, "+csync"},
+ {TT_NCSYNC, "-csync"},
+ {TT_DBLSCAN, "doublescan"},
+ {TT_HSKEW, "hskew"},
+ {TT_BCAST, "bcast"},
+ {TT_VSCAN, "vscan"},
+ {-1, ""},
};
-static xf86ConfigSymTabRec ModeTab[] =
-{
- {DOTCLOCK, "dotclock"},
- {HTIMINGS, "htimings"},
- {VTIMINGS, "vtimings"},
- {FLAGS, "flags"},
- {HSKEW, "hskew"},
- {BCAST, "bcast"},
- {VSCAN, "vscan"},
- {ENDMODE, "endmode"},
- {-1, ""},
+static xf86ConfigSymTabRec ModeTab[] = {
+ {DOTCLOCK, "dotclock"},
+ {HTIMINGS, "htimings"},
+ {VTIMINGS, "vtimings"},
+ {FLAGS, "flags"},
+ {HSKEW, "hskew"},
+ {BCAST, "bcast"},
+ {VSCAN, "vscan"},
+ {ENDMODE, "endmode"},
+ {-1, ""},
};
#define CLEANUP xf86freeModeLineList
static void
-xf86freeModeLineList (XF86ConfModeLinePtr ptr)
+xf86freeModeLineList(XF86ConfModeLinePtr ptr)
{
- XF86ConfModeLinePtr prev;
- while (ptr)
- {
- TestFree (ptr->ml_identifier);
- TestFree (ptr->ml_comment);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
+ XF86ConfModeLinePtr prev;
+
+ while (ptr) {
+ TestFree(ptr->ml_identifier);
+ TestFree(ptr->ml_comment);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free(prev);
+ }
}
static XF86ConfModeLinePtr
-xf86parseModeLine (void)
+xf86parseModeLine(void)
{
- int token;
- parsePrologue (XF86ConfModeLinePtr, XF86ConfModeLineRec)
-
- /* Identifier */
- if (xf86getSubToken (&(ptr->ml_comment)) != STRING)
- Error ("ModeLine identifier expected");
- ptr->ml_identifier = val.str;
-
- /* DotClock */
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("ModeLine dotclock expected");
- ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5);
-
- /* HDisplay */
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("ModeLine Hdisplay expected");
- ptr->ml_hdisplay = val.num;
-
- /* HSyncStart */
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("ModeLine HSyncStart expected");
- ptr->ml_hsyncstart = val.num;
-
- /* HSyncEnd */
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("ModeLine HSyncEnd expected");
- ptr->ml_hsyncend = val.num;
-
- /* HTotal */
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("ModeLine HTotal expected");
- ptr->ml_htotal = val.num;
-
- /* VDisplay */
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("ModeLine Vdisplay expected");
- ptr->ml_vdisplay = val.num;
-
- /* VSyncStart */
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("ModeLine VSyncStart expected");
- ptr->ml_vsyncstart = val.num;
-
- /* VSyncEnd */
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("ModeLine VSyncEnd expected");
- ptr->ml_vsyncend = val.num;
-
- /* VTotal */
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("ModeLine VTotal expected");
- ptr->ml_vtotal = val.num;
-
- token = xf86getSubTokenWithTab (&(ptr->ml_comment), TimingTab);
- while ((token == TT_INTERLACE) || (token == TT_PHSYNC) ||
- (token == TT_NHSYNC) || (token == TT_PVSYNC) ||
- (token == TT_NVSYNC) || (token == TT_CSYNC) ||
- (token == TT_PCSYNC) || (token == TT_NCSYNC) ||
- (token == TT_DBLSCAN) || (token == TT_HSKEW) ||
- (token == TT_VSCAN) || (token == TT_BCAST))
- {
- switch (token)
- {
-
- case TT_INTERLACE:
- ptr->ml_flags |= XF86CONF_INTERLACE;
- break;
- case TT_PHSYNC:
- ptr->ml_flags |= XF86CONF_PHSYNC;
- break;
- case TT_NHSYNC:
- ptr->ml_flags |= XF86CONF_NHSYNC;
- break;
- case TT_PVSYNC:
- ptr->ml_flags |= XF86CONF_PVSYNC;
- break;
- case TT_NVSYNC:
- ptr->ml_flags |= XF86CONF_NVSYNC;
- break;
- case TT_CSYNC:
- ptr->ml_flags |= XF86CONF_CSYNC;
- break;
- case TT_PCSYNC:
- ptr->ml_flags |= XF86CONF_PCSYNC;
- break;
- case TT_NCSYNC:
- ptr->ml_flags |= XF86CONF_NCSYNC;
- break;
- case TT_DBLSCAN:
- ptr->ml_flags |= XF86CONF_DBLSCAN;
- break;
- case TT_HSKEW:
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error (NUMBER_MSG, "Hskew");
- ptr->ml_hskew = val.num;
- ptr->ml_flags |= XF86CONF_HSKEW;
- break;
- case TT_BCAST:
- ptr->ml_flags |= XF86CONF_BCAST;
- break;
- case TT_VSCAN:
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error (NUMBER_MSG, "Vscan");
- ptr->ml_vscan = val.num;
- ptr->ml_flags |= XF86CONF_VSCAN;
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- token = xf86getSubTokenWithTab (&(ptr->ml_comment), TimingTab);
- }
- xf86unGetToken (token);
+ int token;
+
+ parsePrologue(XF86ConfModeLinePtr, XF86ConfModeLineRec)
+
+ /* Identifier */
+ if (xf86getSubToken(&(ptr->ml_comment)) != STRING)
+ Error("ModeLine identifier expected");
+ ptr->ml_identifier = val.str;
+
+ /* DotClock */
+ if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
+ Error("ModeLine dotclock expected");
+ ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5);
+
+ /* HDisplay */
+ if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
+ Error("ModeLine Hdisplay expected");
+ ptr->ml_hdisplay = val.num;
+
+ /* HSyncStart */
+ if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
+ Error("ModeLine HSyncStart expected");
+ ptr->ml_hsyncstart = val.num;
+
+ /* HSyncEnd */
+ if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
+ Error("ModeLine HSyncEnd expected");
+ ptr->ml_hsyncend = val.num;
+
+ /* HTotal */
+ if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
+ Error("ModeLine HTotal expected");
+ ptr->ml_htotal = val.num;
+
+ /* VDisplay */
+ if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
+ Error("ModeLine Vdisplay expected");
+ ptr->ml_vdisplay = val.num;
+
+ /* VSyncStart */
+ if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
+ Error("ModeLine VSyncStart expected");
+ ptr->ml_vsyncstart = val.num;
+
+ /* VSyncEnd */
+ if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
+ Error("ModeLine VSyncEnd expected");
+ ptr->ml_vsyncend = val.num;
+
+ /* VTotal */
+ if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
+ Error("ModeLine VTotal expected");
+ ptr->ml_vtotal = val.num;
+
+ token = xf86getSubTokenWithTab(&(ptr->ml_comment), TimingTab);
+ while ((token == TT_INTERLACE) || (token == TT_PHSYNC) ||
+ (token == TT_NHSYNC) || (token == TT_PVSYNC) ||
+ (token == TT_NVSYNC) || (token == TT_CSYNC) ||
+ (token == TT_PCSYNC) || (token == TT_NCSYNC) ||
+ (token == TT_DBLSCAN) || (token == TT_HSKEW) ||
+ (token == TT_VSCAN) || (token == TT_BCAST)) {
+ switch (token) {
+
+ case TT_INTERLACE:
+ ptr->ml_flags |= XF86CONF_INTERLACE;
+ break;
+ case TT_PHSYNC:
+ ptr->ml_flags |= XF86CONF_PHSYNC;
+ break;
+ case TT_NHSYNC:
+ ptr->ml_flags |= XF86CONF_NHSYNC;
+ break;
+ case TT_PVSYNC:
+ ptr->ml_flags |= XF86CONF_PVSYNC;
+ break;
+ case TT_NVSYNC:
+ ptr->ml_flags |= XF86CONF_NVSYNC;
+ break;
+ case TT_CSYNC:
+ ptr->ml_flags |= XF86CONF_CSYNC;
+ break;
+ case TT_PCSYNC:
+ ptr->ml_flags |= XF86CONF_PCSYNC;
+ break;
+ case TT_NCSYNC:
+ ptr->ml_flags |= XF86CONF_NCSYNC;
+ break;
+ case TT_DBLSCAN:
+ ptr->ml_flags |= XF86CONF_DBLSCAN;
+ break;
+ case TT_HSKEW:
+ if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
+ Error(NUMBER_MSG, "Hskew");
+ ptr->ml_hskew = val.num;
+ ptr->ml_flags |= XF86CONF_HSKEW;
+ break;
+ case TT_BCAST:
+ ptr->ml_flags |= XF86CONF_BCAST;
+ break;
+ case TT_VSCAN:
+ if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
+ Error(NUMBER_MSG, "Vscan");
+ ptr->ml_vscan = val.num;
+ ptr->ml_flags |= XF86CONF_VSCAN;
+ break;
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG);
+ break;
+ default:
+ Error(INVALID_KEYWORD_MSG, xf86tokenString());
+ break;
+ }
+ token = xf86getSubTokenWithTab(&(ptr->ml_comment), TimingTab);
+ }
+ xf86unGetToken(token);
#ifdef DEBUG
- printf ("ModeLine parsed\n");
+ printf("ModeLine parsed\n");
#endif
- return ptr;
+ return ptr;
}
static XF86ConfModeLinePtr
-xf86parseVerboseMode (void)
+xf86parseVerboseMode(void)
{
- int token, token2;
- int had_dotclock = 0, had_htimings = 0, had_vtimings = 0;
- parsePrologue (XF86ConfModeLinePtr, XF86ConfModeLineRec)
-
- if (xf86getSubToken (&(ptr->ml_comment)) != STRING)
- Error ("Mode name expected");
- ptr->ml_identifier = val.str;
- while ((token = xf86getToken (ModeTab)) != ENDMODE)
- {
- switch (token)
- {
- case COMMENT:
- ptr->ml_comment = xf86addComment(ptr->ml_comment, val.str);
- break;
- case DOTCLOCK:
- if ((token = xf86getSubToken (&(ptr->ml_comment))) != NUMBER)
- Error (NUMBER_MSG, "DotClock");
- ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5);
- had_dotclock = 1;
- break;
- case HTIMINGS:
- if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
- ptr->ml_hdisplay = val.num;
- else
- Error ("Horizontal display expected");
-
- if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
- ptr->ml_hsyncstart = val.num;
- else
- Error ("Horizontal sync start expected");
-
- if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
- ptr->ml_hsyncend = val.num;
- else
- Error ("Horizontal sync end expected");
-
- if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
- ptr->ml_htotal = val.num;
- else
- Error ("Horizontal total expected");
- had_htimings = 1;
- break;
- case VTIMINGS:
- if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
- ptr->ml_vdisplay = val.num;
- else
- Error ("Vertical display expected");
-
- if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
- ptr->ml_vsyncstart = val.num;
- else
- Error ("Vertical sync start expected");
-
- if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
- ptr->ml_vsyncend = val.num;
- else
- Error ("Vertical sync end expected");
-
- if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
- ptr->ml_vtotal = val.num;
- else
- Error ("Vertical total expected");
- had_vtimings = 1;
- break;
- case FLAGS:
- token = xf86getSubToken (&(ptr->ml_comment));
- if (token != STRING)
- Error (QUOTE_MSG, "Flags");
- while (token == STRING)
- {
- token2 = xf86getStringToken (TimingTab);
- switch (token2)
- {
- case TT_INTERLACE:
- ptr->ml_flags |= XF86CONF_INTERLACE;
- break;
- case TT_PHSYNC:
- ptr->ml_flags |= XF86CONF_PHSYNC;
- break;
- case TT_NHSYNC:
- ptr->ml_flags |= XF86CONF_NHSYNC;
- break;
- case TT_PVSYNC:
- ptr->ml_flags |= XF86CONF_PVSYNC;
- break;
- case TT_NVSYNC:
- ptr->ml_flags |= XF86CONF_NVSYNC;
- break;
- case TT_CSYNC:
- ptr->ml_flags |= XF86CONF_CSYNC;
- break;
- case TT_PCSYNC:
- ptr->ml_flags |= XF86CONF_PCSYNC;
- break;
- case TT_NCSYNC:
- ptr->ml_flags |= XF86CONF_NCSYNC;
- break;
- case TT_DBLSCAN:
- ptr->ml_flags |= XF86CONF_DBLSCAN;
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG);
- break;
- default:
- Error ("Unknown flag string");
- break;
- }
- token = xf86getSubToken (&(ptr->ml_comment));
- }
- xf86unGetToken (token);
- break;
- case HSKEW:
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("Horizontal skew expected");
- ptr->ml_flags |= XF86CONF_HSKEW;
- ptr->ml_hskew = val.num;
- break;
- case VSCAN:
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("Vertical scan count expected");
- ptr->ml_flags |= XF86CONF_VSCAN;
- ptr->ml_vscan = val.num;
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG);
- break;
- default:
- Error ("Unexepcted token in verbose \"Mode\" entry\n");
- }
- }
- if (!had_dotclock)
- Error ("the dotclock is missing");
- if (!had_htimings)
- Error ("the horizontal timings are missing");
- if (!had_vtimings)
- Error ("the vertical timings are missing");
+ int token, token2;
+ int had_dotclock = 0, had_htimings = 0, had_vtimings = 0;
+
+ parsePrologue(XF86ConfModeLinePtr, XF86ConfModeLineRec)
+
+ if (xf86getSubToken(&(ptr->ml_comment)) != STRING)
+ Error("Mode name expected");
+ ptr->ml_identifier = val.str;
+ while ((token = xf86getToken(ModeTab)) != ENDMODE) {
+ switch (token) {
+ case COMMENT:
+ ptr->ml_comment = xf86addComment(ptr->ml_comment, val.str);
+ break;
+ case DOTCLOCK:
+ if ((token = xf86getSubToken(&(ptr->ml_comment))) != NUMBER)
+ Error(NUMBER_MSG, "DotClock");
+ ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5);
+ had_dotclock = 1;
+ break;
+ case HTIMINGS:
+ if (xf86getSubToken(&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_hdisplay = val.num;
+ else
+ Error("Horizontal display expected");
+
+ if (xf86getSubToken(&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_hsyncstart = val.num;
+ else
+ Error("Horizontal sync start expected");
+
+ if (xf86getSubToken(&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_hsyncend = val.num;
+ else
+ Error("Horizontal sync end expected");
+
+ if (xf86getSubToken(&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_htotal = val.num;
+ else
+ Error("Horizontal total expected");
+ had_htimings = 1;
+ break;
+ case VTIMINGS:
+ if (xf86getSubToken(&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_vdisplay = val.num;
+ else
+ Error("Vertical display expected");
+
+ if (xf86getSubToken(&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_vsyncstart = val.num;
+ else
+ Error("Vertical sync start expected");
+
+ if (xf86getSubToken(&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_vsyncend = val.num;
+ else
+ Error("Vertical sync end expected");
+
+ if (xf86getSubToken(&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_vtotal = val.num;
+ else
+ Error("Vertical total expected");
+ had_vtimings = 1;
+ break;
+ case FLAGS:
+ token = xf86getSubToken(&(ptr->ml_comment));
+ if (token != STRING)
+ Error(QUOTE_MSG, "Flags");
+ while (token == STRING) {
+ token2 = xf86getStringToken(TimingTab);
+ switch (token2) {
+ case TT_INTERLACE:
+ ptr->ml_flags |= XF86CONF_INTERLACE;
+ break;
+ case TT_PHSYNC:
+ ptr->ml_flags |= XF86CONF_PHSYNC;
+ break;
+ case TT_NHSYNC:
+ ptr->ml_flags |= XF86CONF_NHSYNC;
+ break;
+ case TT_PVSYNC:
+ ptr->ml_flags |= XF86CONF_PVSYNC;
+ break;
+ case TT_NVSYNC:
+ ptr->ml_flags |= XF86CONF_NVSYNC;
+ break;
+ case TT_CSYNC:
+ ptr->ml_flags |= XF86CONF_CSYNC;
+ break;
+ case TT_PCSYNC:
+ ptr->ml_flags |= XF86CONF_PCSYNC;
+ break;
+ case TT_NCSYNC:
+ ptr->ml_flags |= XF86CONF_NCSYNC;
+ break;
+ case TT_DBLSCAN:
+ ptr->ml_flags |= XF86CONF_DBLSCAN;
+ break;
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG);
+ break;
+ default:
+ Error("Unknown flag string");
+ break;
+ }
+ token = xf86getSubToken(&(ptr->ml_comment));
+ }
+ xf86unGetToken(token);
+ break;
+ case HSKEW:
+ if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
+ Error("Horizontal skew expected");
+ ptr->ml_flags |= XF86CONF_HSKEW;
+ ptr->ml_hskew = val.num;
+ break;
+ case VSCAN:
+ if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
+ Error("Vertical scan count expected");
+ ptr->ml_flags |= XF86CONF_VSCAN;
+ ptr->ml_vscan = val.num;
+ break;
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG);
+ break;
+ default:
+ Error("Unexepcted token in verbose \"Mode\" entry\n");
+ }
+ }
+ if (!had_dotclock)
+ Error("the dotclock is missing");
+ if (!had_htimings)
+ Error("the horizontal timings are missing");
+ if (!had_vtimings)
+ Error("the vertical timings are missing");
#ifdef DEBUG
- printf ("Verbose Mode parsed\n");
+ printf("Verbose Mode parsed\n");
#endif
- return ptr;
+ return ptr;
}
#undef CLEANUP
@@ -414,484 +405,460 @@ xf86parseVerboseMode (void)
#define CLEANUP xf86freeMonitorList
XF86ConfMonitorPtr
-xf86parseMonitorSection (void)
+xf86parseMonitorSection(void)
{
- int has_ident = FALSE;
- int token;
- parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
-
- while ((token = xf86getToken (MonitorTab)) != ENDSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->mon_comment = xf86addComment(ptr->mon_comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken (&(ptr->mon_comment)) != STRING)
- Error (QUOTE_MSG, "Identifier");
- if (has_ident == TRUE)
- Error (MULTIPLE_MSG, "Identifier");
- ptr->mon_identifier = val.str;
- has_ident = TRUE;
- break;
- case VENDOR:
- if (xf86getSubToken (&(ptr->mon_comment)) != STRING)
- Error (QUOTE_MSG, "Vendor");
- ptr->mon_vendor = val.str;
- break;
- case MODEL:
- if (xf86getSubToken (&(ptr->mon_comment)) != STRING)
- Error (QUOTE_MSG, "ModelName");
- ptr->mon_modelname = val.str;
- break;
- case MODE:
- HANDLE_LIST (mon_modeline_lst, xf86parseVerboseMode,
- XF86ConfModeLinePtr);
- break;
- case MODELINE:
- HANDLE_LIST (mon_modeline_lst, xf86parseModeLine,
- XF86ConfModeLinePtr);
- break;
- case DISPLAYSIZE:
- if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
- Error (DISPLAYSIZE_MSG);
- ptr->mon_width = val.realnum;
- if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
- Error (DISPLAYSIZE_MSG);
- ptr->mon_height = val.realnum;
- break;
-
- case HORIZSYNC:
- if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
- Error (HORIZSYNC_MSG);
- do {
- if (ptr->mon_n_hsync >= CONF_MAX_HSYNC)
- Error ("Sorry. Too many horizontal sync intervals.");
- ptr->mon_hsync[ptr->mon_n_hsync].lo = val.realnum;
- switch (token = xf86getSubToken (&(ptr->mon_comment)))
- {
- case COMMA:
- ptr->mon_hsync[ptr->mon_n_hsync].hi =
- ptr->mon_hsync[ptr->mon_n_hsync].lo;
- break;
- case DASH:
- if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER ||
- (float)val.realnum < ptr->mon_hsync[ptr->mon_n_hsync].lo)
- Error (HORIZSYNC_MSG);
- ptr->mon_hsync[ptr->mon_n_hsync].hi = val.realnum;
- if ((token = xf86getSubToken (&(ptr->mon_comment))) == COMMA)
- break;
- ptr->mon_n_hsync++;
- goto HorizDone;
- default:
- /* We cannot currently know if a '\n' was found,
- * or this is a real error
- */
- ptr->mon_hsync[ptr->mon_n_hsync].hi =
- ptr->mon_hsync[ptr->mon_n_hsync].lo;
- ptr->mon_n_hsync++;
- goto HorizDone;
- }
- ptr->mon_n_hsync++;
- } while ((token = xf86getSubToken (&(ptr->mon_comment))) == NUMBER);
-HorizDone:
- xf86unGetToken (token);
- break;
-
- case VERTREFRESH:
- if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
- Error (VERTREFRESH_MSG);
- do {
- ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo = val.realnum;
- switch (token = xf86getSubToken (&(ptr->mon_comment)))
- {
- case COMMA:
- ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi =
- ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo;
- break;
- case DASH:
- if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER ||
- (float)val.realnum < ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo)
- Error (VERTREFRESH_MSG);
- ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = val.realnum;
- if ((token = xf86getSubToken (&(ptr->mon_comment))) == COMMA)
- break;
- ptr->mon_n_vrefresh++;
- goto VertDone;
- default:
- /* We cannot currently know if a '\n' was found,
- * or this is a real error
- */
- ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi =
- ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo;
- ptr->mon_n_vrefresh++;
- goto VertDone;
- }
- if (ptr->mon_n_vrefresh >= CONF_MAX_VREFRESH)
- Error ("Sorry. Too many vertical refresh intervals.");
- ptr->mon_n_vrefresh++;
- } while ((token = xf86getSubToken (&(ptr->mon_comment))) == NUMBER);
-VertDone:
- xf86unGetToken (token);
- break;
-
- case GAMMA:
- if( xf86getSubToken (&(ptr->mon_comment)) != NUMBER )
- {
- Error (INVALID_GAMMA_MSG);
- }
- else
- {
- ptr->mon_gamma_red = ptr->mon_gamma_green =
- ptr->mon_gamma_blue = val.realnum;
- if( xf86getSubToken (&(ptr->mon_comment)) == NUMBER )
- {
- ptr->mon_gamma_green = val.realnum;
- if( xf86getSubToken (&(ptr->mon_comment)) == NUMBER )
- {
- ptr->mon_gamma_blue = val.realnum;
- }
- else
- {
- Error (INVALID_GAMMA_MSG);
- }
- }
- else
- xf86unGetToken (token);
- }
- break;
- case OPTION:
- ptr->mon_option_lst = xf86parseOption(ptr->mon_option_lst);
- break;
- case USEMODES:
- {
- XF86ConfModesLinkPtr mptr;
-
- if ((token = xf86getSubToken (&(ptr->mon_comment))) != STRING)
- Error (QUOTE_MSG, "UseModes");
-
- /* add to the end of the list of modes sections
- referenced here */
- mptr = calloc (1, sizeof (XF86ConfModesLinkRec));
- mptr->list.next = NULL;
- mptr->ml_modes_str = val.str;
- mptr->ml_modes = NULL;
- ptr->mon_modes_sect_lst = (XF86ConfModesLinkPtr)
- xf86addListItem((GenericListPtr)ptr->mon_modes_sect_lst,
- (GenericListPtr)mptr);
- }
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG);
- break;
- default:
- xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ());
- CLEANUP (ptr);
- return NULL;
- break;
- }
- }
-
- if (!has_ident)
- Error (NO_IDENT_MSG);
+ int has_ident = FALSE;
+ int token;
+
+ parsePrologue(XF86ConfMonitorPtr, XF86ConfMonitorRec)
+
+ while ((token = xf86getToken(MonitorTab)) != ENDSECTION) {
+ switch (token) {
+ case COMMENT:
+ ptr->mon_comment = xf86addComment(ptr->mon_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken(&(ptr->mon_comment)) != STRING)
+ Error(QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error(MULTIPLE_MSG, "Identifier");
+ ptr->mon_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case VENDOR:
+ if (xf86getSubToken(&(ptr->mon_comment)) != STRING)
+ Error(QUOTE_MSG, "Vendor");
+ ptr->mon_vendor = val.str;
+ break;
+ case MODEL:
+ if (xf86getSubToken(&(ptr->mon_comment)) != STRING)
+ Error(QUOTE_MSG, "ModelName");
+ ptr->mon_modelname = val.str;
+ break;
+ case MODE:
+ HANDLE_LIST(mon_modeline_lst, xf86parseVerboseMode,
+ XF86ConfModeLinePtr);
+ break;
+ case MODELINE:
+ HANDLE_LIST(mon_modeline_lst, xf86parseModeLine,
+ XF86ConfModeLinePtr);
+ break;
+ case DISPLAYSIZE:
+ if (xf86getSubToken(&(ptr->mon_comment)) != NUMBER)
+ Error(DISPLAYSIZE_MSG);
+ ptr->mon_width = val.realnum;
+ if (xf86getSubToken(&(ptr->mon_comment)) != NUMBER)
+ Error(DISPLAYSIZE_MSG);
+ ptr->mon_height = val.realnum;
+ break;
+
+ case HORIZSYNC:
+ if (xf86getSubToken(&(ptr->mon_comment)) != NUMBER)
+ Error(HORIZSYNC_MSG);
+ do {
+ if (ptr->mon_n_hsync >= CONF_MAX_HSYNC)
+ Error("Sorry. Too many horizontal sync intervals.");
+ ptr->mon_hsync[ptr->mon_n_hsync].lo = val.realnum;
+ switch (token = xf86getSubToken(&(ptr->mon_comment))) {
+ case COMMA:
+ ptr->mon_hsync[ptr->mon_n_hsync].hi =
+ ptr->mon_hsync[ptr->mon_n_hsync].lo;
+ break;
+ case DASH:
+ if (xf86getSubToken(&(ptr->mon_comment)) != NUMBER ||
+ (float) val.realnum <
+ ptr->mon_hsync[ptr->mon_n_hsync].lo)
+ Error(HORIZSYNC_MSG);
+ ptr->mon_hsync[ptr->mon_n_hsync].hi = val.realnum;
+ if ((token = xf86getSubToken(&(ptr->mon_comment))) == COMMA)
+ break;
+ ptr->mon_n_hsync++;
+ goto HorizDone;
+ default:
+ /* We cannot currently know if a '\n' was found,
+ * or this is a real error
+ */
+ ptr->mon_hsync[ptr->mon_n_hsync].hi =
+ ptr->mon_hsync[ptr->mon_n_hsync].lo;
+ ptr->mon_n_hsync++;
+ goto HorizDone;
+ }
+ ptr->mon_n_hsync++;
+ } while ((token = xf86getSubToken(&(ptr->mon_comment))) == NUMBER);
+ HorizDone:
+ xf86unGetToken(token);
+ break;
+
+ case VERTREFRESH:
+ if (xf86getSubToken(&(ptr->mon_comment)) != NUMBER)
+ Error(VERTREFRESH_MSG);
+ do {
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo = val.realnum;
+ switch (token = xf86getSubToken(&(ptr->mon_comment))) {
+ case COMMA:
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi =
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo;
+ break;
+ case DASH:
+ if (xf86getSubToken(&(ptr->mon_comment)) != NUMBER ||
+ (float) val.realnum <
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo)
+ Error(VERTREFRESH_MSG);
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = val.realnum;
+ if ((token = xf86getSubToken(&(ptr->mon_comment))) == COMMA)
+ break;
+ ptr->mon_n_vrefresh++;
+ goto VertDone;
+ default:
+ /* We cannot currently know if a '\n' was found,
+ * or this is a real error
+ */
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi =
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo;
+ ptr->mon_n_vrefresh++;
+ goto VertDone;
+ }
+ if (ptr->mon_n_vrefresh >= CONF_MAX_VREFRESH)
+ Error("Sorry. Too many vertical refresh intervals.");
+ ptr->mon_n_vrefresh++;
+ } while ((token = xf86getSubToken(&(ptr->mon_comment))) == NUMBER);
+ VertDone:
+ xf86unGetToken(token);
+ break;
+
+ case GAMMA:
+ if (xf86getSubToken(&(ptr->mon_comment)) != NUMBER) {
+ Error(INVALID_GAMMA_MSG);
+ }
+ else {
+ ptr->mon_gamma_red = ptr->mon_gamma_green =
+ ptr->mon_gamma_blue = val.realnum;
+ if (xf86getSubToken(&(ptr->mon_comment)) == NUMBER) {
+ ptr->mon_gamma_green = val.realnum;
+ if (xf86getSubToken(&(ptr->mon_comment)) == NUMBER) {
+ ptr->mon_gamma_blue = val.realnum;
+ }
+ else {
+ Error(INVALID_GAMMA_MSG);
+ }
+ }
+ else
+ xf86unGetToken(token);
+ }
+ break;
+ case OPTION:
+ ptr->mon_option_lst = xf86parseOption(ptr->mon_option_lst);
+ break;
+ case USEMODES:
+ {
+ XF86ConfModesLinkPtr mptr;
+
+ if ((token = xf86getSubToken(&(ptr->mon_comment))) != STRING)
+ Error(QUOTE_MSG, "UseModes");
+
+ /* add to the end of the list of modes sections
+ referenced here */
+ mptr = calloc(1, sizeof(XF86ConfModesLinkRec));
+ mptr->list.next = NULL;
+ mptr->ml_modes_str = val.str;
+ mptr->ml_modes = NULL;
+ ptr->mon_modes_sect_lst = (XF86ConfModesLinkPtr)
+ xf86addListItem((GenericListPtr) ptr->mon_modes_sect_lst,
+ (GenericListPtr) mptr);
+ }
+ break;
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG);
+ break;
+ default:
+ xf86parseError(INVALID_KEYWORD_MSG, xf86tokenString());
+ CLEANUP(ptr);
+ return NULL;
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error(NO_IDENT_MSG);
#ifdef DEBUG
- printf ("Monitor section parsed\n");
+ printf("Monitor section parsed\n");
#endif
- return ptr;
+ return ptr;
}
#undef CLEANUP
#define CLEANUP xf86freeModesList
XF86ConfModesPtr
-xf86parseModesSection (void)
+xf86parseModesSection(void)
{
- int has_ident = FALSE;
- int token;
- parsePrologue (XF86ConfModesPtr, XF86ConfModesRec)
-
- while ((token = xf86getToken (ModesTab)) != ENDSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->modes_comment = xf86addComment(ptr->modes_comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken (&(ptr->modes_comment)) != STRING)
- Error (QUOTE_MSG, "Identifier");
- if (has_ident == TRUE)
- Error (MULTIPLE_MSG, "Identifier");
- ptr->modes_identifier = val.str;
- has_ident = TRUE;
- break;
- case MODE:
- HANDLE_LIST (mon_modeline_lst, xf86parseVerboseMode,
- XF86ConfModeLinePtr);
- break;
- case MODELINE:
- HANDLE_LIST (mon_modeline_lst, xf86parseModeLine,
- XF86ConfModeLinePtr);
- break;
- default:
- xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ());
- CLEANUP (ptr);
- return NULL;
- break;
- }
- }
-
- if (!has_ident)
- Error (NO_IDENT_MSG);
+ int has_ident = FALSE;
+ int token;
+
+ parsePrologue(XF86ConfModesPtr, XF86ConfModesRec)
+
+ while ((token = xf86getToken(ModesTab)) != ENDSECTION) {
+ switch (token) {
+ case COMMENT:
+ ptr->modes_comment = xf86addComment(ptr->modes_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken(&(ptr->modes_comment)) != STRING)
+ Error(QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error(MULTIPLE_MSG, "Identifier");
+ ptr->modes_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case MODE:
+ HANDLE_LIST(mon_modeline_lst, xf86parseVerboseMode,
+ XF86ConfModeLinePtr);
+ break;
+ case MODELINE:
+ HANDLE_LIST(mon_modeline_lst, xf86parseModeLine,
+ XF86ConfModeLinePtr);
+ break;
+ default:
+ xf86parseError(INVALID_KEYWORD_MSG, xf86tokenString());
+ CLEANUP(ptr);
+ return NULL;
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error(NO_IDENT_MSG);
#ifdef DEBUG
- printf ("Modes section parsed\n");
+ printf("Modes section parsed\n");
#endif
- return ptr;
+ return ptr;
}
#undef CLEANUP
void
-xf86printMonitorSection (FILE * cf, XF86ConfMonitorPtr ptr)
+xf86printMonitorSection(FILE * cf, XF86ConfMonitorPtr ptr)
{
- int i;
- XF86ConfModeLinePtr mlptr;
- XF86ConfModesLinkPtr mptr;
-
- while (ptr)
- {
- mptr = ptr->mon_modes_sect_lst;
- fprintf (cf, "Section \"Monitor\"\n");
- if (ptr->mon_comment)
- fprintf (cf, "%s", ptr->mon_comment);
- if (ptr->mon_identifier)
- fprintf (cf, "\tIdentifier \"%s\"\n", ptr->mon_identifier);
- if (ptr->mon_vendor)
- fprintf (cf, "\tVendorName \"%s\"\n", ptr->mon_vendor);
- if (ptr->mon_modelname)
- fprintf (cf, "\tModelName \"%s\"\n", ptr->mon_modelname);
- while (mptr) {
- fprintf (cf, "\tUseModes \"%s\"\n", mptr->ml_modes_str);
- mptr = mptr->list.next;
- }
- if (ptr->mon_width)
- fprintf (cf, "\tDisplaySize %d\t%d\n",
- ptr->mon_width,
- ptr->mon_height);
- for (i = 0; i < ptr->mon_n_hsync; i++)
- {
- fprintf (cf, "\tHorizSync %2.1f - %2.1f\n",
- ptr->mon_hsync[i].lo,
- ptr->mon_hsync[i].hi);
- }
- for (i = 0; i < ptr->mon_n_vrefresh; i++)
- {
- fprintf (cf, "\tVertRefresh %2.1f - %2.1f\n",
- ptr->mon_vrefresh[i].lo,
- ptr->mon_vrefresh[i].hi);
- }
- if (ptr->mon_gamma_red) {
- if (ptr->mon_gamma_red == ptr->mon_gamma_green
- && ptr->mon_gamma_red == ptr->mon_gamma_blue)
- {
- fprintf (cf, "\tGamma %.4g\n",
- ptr->mon_gamma_red);
- } else {
- fprintf (cf, "\tGamma %.4g %.4g %.4g\n",
- ptr->mon_gamma_red,
- ptr->mon_gamma_green,
- ptr->mon_gamma_blue);
- }
- }
- for (mlptr = ptr->mon_modeline_lst; mlptr; mlptr = mlptr->list.next)
- {
- fprintf (cf, "\tModeLine \"%s\" %2.1f ",
- mlptr->ml_identifier, mlptr->ml_clock / 1000.0);
- fprintf (cf, "%d %d %d %d %d %d %d %d",
- mlptr->ml_hdisplay, mlptr->ml_hsyncstart,
- mlptr->ml_hsyncend, mlptr->ml_htotal,
- mlptr->ml_vdisplay, mlptr->ml_vsyncstart,
- mlptr->ml_vsyncend, mlptr->ml_vtotal);
- if (mlptr->ml_flags & XF86CONF_PHSYNC)
- fprintf (cf, " +hsync");
- if (mlptr->ml_flags & XF86CONF_NHSYNC)
- fprintf (cf, " -hsync");
- if (mlptr->ml_flags & XF86CONF_PVSYNC)
- fprintf (cf, " +vsync");
- if (mlptr->ml_flags & XF86CONF_NVSYNC)
- fprintf (cf, " -vsync");
- if (mlptr->ml_flags & XF86CONF_INTERLACE)
- fprintf (cf, " interlace");
- if (mlptr->ml_flags & XF86CONF_CSYNC)
- fprintf (cf, " composite");
- if (mlptr->ml_flags & XF86CONF_PCSYNC)
- fprintf (cf, " +csync");
- if (mlptr->ml_flags & XF86CONF_NCSYNC)
- fprintf (cf, " -csync");
- if (mlptr->ml_flags & XF86CONF_DBLSCAN)
- fprintf (cf, " doublescan");
- if (mlptr->ml_flags & XF86CONF_HSKEW)
- fprintf (cf, " hskew %d", mlptr->ml_hskew);
- if (mlptr->ml_flags & XF86CONF_BCAST)
- fprintf (cf, " bcast");
- fprintf (cf, "\n");
- }
- xf86printOptionList(cf, ptr->mon_option_lst, 1);
- fprintf (cf, "EndSection\n\n");
- ptr = ptr->list.next;
- }
+ int i;
+ XF86ConfModeLinePtr mlptr;
+ XF86ConfModesLinkPtr mptr;
+
+ while (ptr) {
+ mptr = ptr->mon_modes_sect_lst;
+ fprintf(cf, "Section \"Monitor\"\n");
+ if (ptr->mon_comment)
+ fprintf(cf, "%s", ptr->mon_comment);
+ if (ptr->mon_identifier)
+ fprintf(cf, "\tIdentifier \"%s\"\n", ptr->mon_identifier);
+ if (ptr->mon_vendor)
+ fprintf(cf, "\tVendorName \"%s\"\n", ptr->mon_vendor);
+ if (ptr->mon_modelname)
+ fprintf(cf, "\tModelName \"%s\"\n", ptr->mon_modelname);
+ while (mptr) {
+ fprintf(cf, "\tUseModes \"%s\"\n", mptr->ml_modes_str);
+ mptr = mptr->list.next;
+ }
+ if (ptr->mon_width)
+ fprintf(cf, "\tDisplaySize %d\t%d\n",
+ ptr->mon_width, ptr->mon_height);
+ for (i = 0; i < ptr->mon_n_hsync; i++) {
+ fprintf(cf, "\tHorizSync %2.1f - %2.1f\n",
+ ptr->mon_hsync[i].lo, ptr->mon_hsync[i].hi);
+ }
+ for (i = 0; i < ptr->mon_n_vrefresh; i++) {
+ fprintf(cf, "\tVertRefresh %2.1f - %2.1f\n",
+ ptr->mon_vrefresh[i].lo, ptr->mon_vrefresh[i].hi);
+ }
+ if (ptr->mon_gamma_red) {
+ if (ptr->mon_gamma_red == ptr->mon_gamma_green
+ && ptr->mon_gamma_red == ptr->mon_gamma_blue) {
+ fprintf(cf, "\tGamma %.4g\n", ptr->mon_gamma_red);
+ }
+ else {
+ fprintf(cf, "\tGamma %.4g %.4g %.4g\n",
+ ptr->mon_gamma_red,
+ ptr->mon_gamma_green, ptr->mon_gamma_blue);
+ }
+ }
+ for (mlptr = ptr->mon_modeline_lst; mlptr; mlptr = mlptr->list.next) {
+ fprintf(cf, "\tModeLine \"%s\" %2.1f ",
+ mlptr->ml_identifier, mlptr->ml_clock / 1000.0);
+ fprintf(cf, "%d %d %d %d %d %d %d %d",
+ mlptr->ml_hdisplay, mlptr->ml_hsyncstart,
+ mlptr->ml_hsyncend, mlptr->ml_htotal,
+ mlptr->ml_vdisplay, mlptr->ml_vsyncstart,
+ mlptr->ml_vsyncend, mlptr->ml_vtotal);
+ if (mlptr->ml_flags & XF86CONF_PHSYNC)
+ fprintf(cf, " +hsync");
+ if (mlptr->ml_flags & XF86CONF_NHSYNC)
+ fprintf(cf, " -hsync");
+ if (mlptr->ml_flags & XF86CONF_PVSYNC)
+ fprintf(cf, " +vsync");
+ if (mlptr->ml_flags & XF86CONF_NVSYNC)
+ fprintf(cf, " -vsync");
+ if (mlptr->ml_flags & XF86CONF_INTERLACE)
+ fprintf(cf, " interlace");
+ if (mlptr->ml_flags & XF86CONF_CSYNC)
+ fprintf(cf, " composite");
+ if (mlptr->ml_flags & XF86CONF_PCSYNC)
+ fprintf(cf, " +csync");
+ if (mlptr->ml_flags & XF86CONF_NCSYNC)
+ fprintf(cf, " -csync");
+ if (mlptr->ml_flags & XF86CONF_DBLSCAN)
+ fprintf(cf, " doublescan");
+ if (mlptr->ml_flags & XF86CONF_HSKEW)
+ fprintf(cf, " hskew %d", mlptr->ml_hskew);
+ if (mlptr->ml_flags & XF86CONF_BCAST)
+ fprintf(cf, " bcast");
+ fprintf(cf, "\n");
+ }
+ xf86printOptionList(cf, ptr->mon_option_lst, 1);
+ fprintf(cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
}
void
-xf86printModesSection (FILE * cf, XF86ConfModesPtr ptr)
+xf86printModesSection(FILE * cf, XF86ConfModesPtr ptr)
{
- XF86ConfModeLinePtr mlptr;
-
- while (ptr)
- {
- fprintf (cf, "Section \"Modes\"\n");
- if (ptr->modes_comment)
- fprintf (cf, "%s", ptr->modes_comment);
- if (ptr->modes_identifier)
- fprintf (cf, "\tIdentifier \"%s\"\n", ptr->modes_identifier);
- for (mlptr = ptr->mon_modeline_lst; mlptr; mlptr = mlptr->list.next)
- {
- fprintf (cf, "\tModeLine \"%s\" %2.1f ",
- mlptr->ml_identifier, mlptr->ml_clock / 1000.0);
- fprintf (cf, "%d %d %d %d %d %d %d %d",
- mlptr->ml_hdisplay, mlptr->ml_hsyncstart,
- mlptr->ml_hsyncend, mlptr->ml_htotal,
- mlptr->ml_vdisplay, mlptr->ml_vsyncstart,
- mlptr->ml_vsyncend, mlptr->ml_vtotal);
- if (mlptr->ml_flags & XF86CONF_PHSYNC)
- fprintf (cf, " +hsync");
- if (mlptr->ml_flags & XF86CONF_NHSYNC)
- fprintf (cf, " -hsync");
- if (mlptr->ml_flags & XF86CONF_PVSYNC)
- fprintf (cf, " +vsync");
- if (mlptr->ml_flags & XF86CONF_NVSYNC)
- fprintf (cf, " -vsync");
- if (mlptr->ml_flags & XF86CONF_INTERLACE)
- fprintf (cf, " interlace");
- if (mlptr->ml_flags & XF86CONF_CSYNC)
- fprintf (cf, " composite");
- if (mlptr->ml_flags & XF86CONF_PCSYNC)
- fprintf (cf, " +csync");
- if (mlptr->ml_flags & XF86CONF_NCSYNC)
- fprintf (cf, " -csync");
- if (mlptr->ml_flags & XF86CONF_DBLSCAN)
- fprintf (cf, " doublescan");
- if (mlptr->ml_flags & XF86CONF_HSKEW)
- fprintf (cf, " hskew %d", mlptr->ml_hskew);
- if (mlptr->ml_flags & XF86CONF_VSCAN)
- fprintf (cf, " vscan %d", mlptr->ml_vscan);
- if (mlptr->ml_flags & XF86CONF_BCAST)
- fprintf (cf, " bcast");
- if (mlptr->ml_comment)
- fprintf (cf, "%s", mlptr->ml_comment);
- else
- fprintf (cf, "\n");
- }
- fprintf (cf, "EndSection\n\n");
- ptr = ptr->list.next;
- }
+ XF86ConfModeLinePtr mlptr;
+
+ while (ptr) {
+ fprintf(cf, "Section \"Modes\"\n");
+ if (ptr->modes_comment)
+ fprintf(cf, "%s", ptr->modes_comment);
+ if (ptr->modes_identifier)
+ fprintf(cf, "\tIdentifier \"%s\"\n", ptr->modes_identifier);
+ for (mlptr = ptr->mon_modeline_lst; mlptr; mlptr = mlptr->list.next) {
+ fprintf(cf, "\tModeLine \"%s\" %2.1f ",
+ mlptr->ml_identifier, mlptr->ml_clock / 1000.0);
+ fprintf(cf, "%d %d %d %d %d %d %d %d",
+ mlptr->ml_hdisplay, mlptr->ml_hsyncstart,
+ mlptr->ml_hsyncend, mlptr->ml_htotal,
+ mlptr->ml_vdisplay, mlptr->ml_vsyncstart,
+ mlptr->ml_vsyncend, mlptr->ml_vtotal);
+ if (mlptr->ml_flags & XF86CONF_PHSYNC)
+ fprintf(cf, " +hsync");
+ if (mlptr->ml_flags & XF86CONF_NHSYNC)
+ fprintf(cf, " -hsync");
+ if (mlptr->ml_flags & XF86CONF_PVSYNC)
+ fprintf(cf, " +vsync");
+ if (mlptr->ml_flags & XF86CONF_NVSYNC)
+ fprintf(cf, " -vsync");
+ if (mlptr->ml_flags & XF86CONF_INTERLACE)
+ fprintf(cf, " interlace");
+ if (mlptr->ml_flags & XF86CONF_CSYNC)
+ fprintf(cf, " composite");
+ if (mlptr->ml_flags & XF86CONF_PCSYNC)
+ fprintf(cf, " +csync");
+ if (mlptr->ml_flags & XF86CONF_NCSYNC)
+ fprintf(cf, " -csync");
+ if (mlptr->ml_flags & XF86CONF_DBLSCAN)
+ fprintf(cf, " doublescan");
+ if (mlptr->ml_flags & XF86CONF_HSKEW)
+ fprintf(cf, " hskew %d", mlptr->ml_hskew);
+ if (mlptr->ml_flags & XF86CONF_VSCAN)
+ fprintf(cf, " vscan %d", mlptr->ml_vscan);
+ if (mlptr->ml_flags & XF86CONF_BCAST)
+ fprintf(cf, " bcast");
+ if (mlptr->ml_comment)
+ fprintf(cf, "%s", mlptr->ml_comment);
+ else
+ fprintf(cf, "\n");
+ }
+ fprintf(cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
}
void
-xf86freeMonitorList (XF86ConfMonitorPtr ptr)
+xf86freeMonitorList(XF86ConfMonitorPtr ptr)
{
- XF86ConfMonitorPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->mon_identifier);
- TestFree (ptr->mon_vendor);
- TestFree (ptr->mon_modelname);
- TestFree (ptr->mon_comment);
- xf86optionListFree (ptr->mon_option_lst);
- xf86freeModeLineList (ptr->mon_modeline_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
+ XF86ConfMonitorPtr prev;
+
+ while (ptr) {
+ TestFree(ptr->mon_identifier);
+ TestFree(ptr->mon_vendor);
+ TestFree(ptr->mon_modelname);
+ TestFree(ptr->mon_comment);
+ xf86optionListFree(ptr->mon_option_lst);
+ xf86freeModeLineList(ptr->mon_modeline_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free(prev);
+ }
}
void
-xf86freeModesList (XF86ConfModesPtr ptr)
+xf86freeModesList(XF86ConfModesPtr ptr)
{
- XF86ConfModesPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->modes_identifier);
- TestFree (ptr->modes_comment);
- xf86freeModeLineList (ptr->mon_modeline_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
+ XF86ConfModesPtr prev;
+
+ while (ptr) {
+ TestFree(ptr->modes_identifier);
+ TestFree(ptr->modes_comment);
+ xf86freeModeLineList(ptr->mon_modeline_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free(prev);
+ }
}
XF86ConfMonitorPtr
-xf86findMonitor (const char *ident, XF86ConfMonitorPtr p)
+xf86findMonitor(const char *ident, XF86ConfMonitorPtr p)
{
- while (p)
- {
- if (xf86nameCompare (ident, p->mon_identifier) == 0)
- return p;
-
- p = p->list.next;
- }
- return NULL;
+ while (p) {
+ if (xf86nameCompare(ident, p->mon_identifier) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
}
XF86ConfModesPtr
-xf86findModes (const char *ident, XF86ConfModesPtr p)
+xf86findModes(const char *ident, XF86ConfModesPtr p)
{
- while (p)
- {
- if (xf86nameCompare (ident, p->modes_identifier) == 0)
- return p;
-
- p = p->list.next;
- }
- return NULL;
+ while (p) {
+ if (xf86nameCompare(ident, p->modes_identifier) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
}
XF86ConfModeLinePtr
-xf86findModeLine (const char *ident, XF86ConfModeLinePtr p)
+xf86findModeLine(const char *ident, XF86ConfModeLinePtr p)
{
- while (p)
- {
- if (xf86nameCompare (ident, p->ml_identifier) == 0)
- return p;
-
- p = p->list.next;
- }
- return NULL;
+ while (p) {
+ if (xf86nameCompare(ident, p->ml_identifier) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
}
int
-xf86validateMonitor (XF86ConfigPtr p, XF86ConfScreenPtr screen)
+xf86validateMonitor(XF86ConfigPtr p, XF86ConfScreenPtr screen)
{
- XF86ConfMonitorPtr monitor = screen->scrn_monitor;
- XF86ConfModesLinkPtr modeslnk = monitor->mon_modes_sect_lst;
- XF86ConfModesPtr modes;
- while(modeslnk)
- {
- modes = xf86findModes (modeslnk->ml_modes_str, p->conf_modes_lst);
- if (!modes)
- {
- xf86validationError (UNDEFINED_MODES_MSG,
- modeslnk->ml_modes_str,
- screen->scrn_identifier);
- return FALSE;
- }
- modeslnk->ml_modes = modes;
- modeslnk = modeslnk->list.next;
- }
- return TRUE;
+ XF86ConfMonitorPtr monitor = screen->scrn_monitor;
+ XF86ConfModesLinkPtr modeslnk = monitor->mon_modes_sect_lst;
+ XF86ConfModesPtr modes;
+
+ while (modeslnk) {
+ modes = xf86findModes(modeslnk->ml_modes_str, p->conf_modes_lst);
+ if (!modes) {
+ xf86validationError(UNDEFINED_MODES_MSG,
+ modeslnk->ml_modes_str,
+ screen->scrn_identifier);
+ return FALSE;
+ }
+ modeslnk->ml_modes = modes;
+ modeslnk = modeslnk->list.next;
+ }
+ return TRUE;
}
diff --git a/xorg-server/hw/xfree86/parser/Pointer.c b/xorg-server/hw/xfree86/parser/Pointer.c
index 4edbf74d9..cdbc09c1a 100644
--- a/xorg-server/hw/xfree86/parser/Pointer.c
+++ b/xorg-server/hw/xfree86/parser/Pointer.c
@@ -52,7 +52,6 @@
* authorization from the copyright holder(s) and author(s).
*/
-
/* View/edit this file with tab stops set to 4 */
#ifdef HAVE_XORG_CONFIG_H
@@ -66,168 +65,161 @@
extern LexRec val;
-static xf86ConfigSymTabRec PointerTab[] =
-{
- {PROTOCOL, "protocol"},
- {EMULATE3, "emulate3buttons"},
- {EM3TIMEOUT, "emulate3timeout"},
- {ENDSUBSECTION, "endsubsection"},
- {ENDSECTION, "endsection"},
- {PDEVICE, "device"},
- {PDEVICE, "port"},
- {BAUDRATE, "baudrate"},
- {SAMPLERATE, "samplerate"},
- {CLEARDTR, "cleardtr"},
- {CLEARRTS, "clearrts"},
- {CHORDMIDDLE, "chordmiddle"},
- {PRESOLUTION, "resolution"},
- {DEVICE_NAME, "devicename"},
- {ALWAYSCORE, "alwayscore"},
- {PBUTTONS, "buttons"},
- {ZAXISMAPPING, "zaxismapping"},
- {-1, ""},
+static xf86ConfigSymTabRec PointerTab[] = {
+ {PROTOCOL, "protocol"},
+ {EMULATE3, "emulate3buttons"},
+ {EM3TIMEOUT, "emulate3timeout"},
+ {ENDSUBSECTION, "endsubsection"},
+ {ENDSECTION, "endsection"},
+ {PDEVICE, "device"},
+ {PDEVICE, "port"},
+ {BAUDRATE, "baudrate"},
+ {SAMPLERATE, "samplerate"},
+ {CLEARDTR, "cleardtr"},
+ {CLEARRTS, "clearrts"},
+ {CHORDMIDDLE, "chordmiddle"},
+ {PRESOLUTION, "resolution"},
+ {DEVICE_NAME, "devicename"},
+ {ALWAYSCORE, "alwayscore"},
+ {PBUTTONS, "buttons"},
+ {ZAXISMAPPING, "zaxismapping"},
+ {-1, ""},
};
-static xf86ConfigSymTabRec ZMapTab[] =
-{
- {XAXIS, "x"},
- {YAXIS, "y"},
- {-1, ""},
+static xf86ConfigSymTabRec ZMapTab[] = {
+ {XAXIS, "x"},
+ {YAXIS, "y"},
+ {-1, ""},
};
#define CLEANUP xf86freeInputList
XF86ConfInputPtr
-xf86parsePointerSection (void)
+xf86parsePointerSection(void)
{
- char *s;
- unsigned long val1;
- int token;
- parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
+ char *s;
+ unsigned long val1;
+ int token;
- while ((token = xf86getToken (PointerTab)) != ENDSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str);
- break;
- case PROTOCOL:
- if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
- Error (QUOTE_MSG, "Protocol");
- ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
- strdup("Protocol"),
- val.str);
- break;
- case PDEVICE:
- if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
- Error (QUOTE_MSG, "Device");
- ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
- strdup("Device"),
- val.str);
- break;
- case EMULATE3:
- ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
- strdup("Emulate3Buttons"),
- NULL);
- break;
- case EM3TIMEOUT:
- if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0)
- Error (POSITIVE_INT_MSG, "Emulate3Timeout");
- s = xf86uLongToString(val.num);
- ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
- strdup("Emulate3Timeout"),
- s);
- break;
- case CHORDMIDDLE:
- ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
- strdup("ChordMiddle"),
- NULL);
- break;
- case PBUTTONS:
- if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0)
- Error (POSITIVE_INT_MSG, "Buttons");
- s = xf86uLongToString(val.num);
- ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
- strdup("Buttons"), s);
- break;
- case BAUDRATE:
- if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0)
- Error (POSITIVE_INT_MSG, "BaudRate");
- s = xf86uLongToString(val.num);
- ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
- strdup("BaudRate"), s);
- break;
- case SAMPLERATE:
- if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0)
- Error (POSITIVE_INT_MSG, "SampleRate");
- s = xf86uLongToString(val.num);
- ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
- strdup("SampleRate"), s);
- break;
- case PRESOLUTION:
- if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0)
- Error (POSITIVE_INT_MSG, "Resolution");
- s = xf86uLongToString(val.num);
- ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
- strdup("Resolution"), s);
- break;
- case CLEARDTR:
- ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
- strdup("ClearDTR"), NULL);
- break;
- case CLEARRTS:
- ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
- strdup("ClearRTS"), NULL);
- break;
- case ZAXISMAPPING:
- switch (xf86getToken(ZMapTab)) {
- case NUMBER:
- if (val.num < 0)
- Error (ZAXISMAPPING_MSG);
- val1 = val.num;
- if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0) {
- Error (ZAXISMAPPING_MSG);
- }
- if (asprintf(&s, "%lu %u", val1, val.num) == -1)
- s = NULL;
- break;
- case XAXIS:
- s = strdup("x");
- break;
- case YAXIS:
- s = strdup("y");
- break;
- default:
- Error (ZAXISMAPPING_MSG);
- break;
- }
- ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
- strdup("ZAxisMapping"),
- s);
- break;
- case ALWAYSCORE:
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
+ parsePrologue(XF86ConfInputPtr, XF86ConfInputRec)
- ptr->inp_identifier = strdup(CONF_IMPLICIT_POINTER);
- ptr->inp_driver = strdup("mouse");
- ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
- strdup("CorePointer"), NULL);
+ while ((token = xf86getToken(PointerTab)) != ENDSECTION) {
+ switch (token) {
+ case COMMENT:
+ ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str);
+ break;
+ case PROTOCOL:
+ if (xf86getSubToken(&(ptr->inp_comment)) != STRING)
+ Error(QUOTE_MSG, "Protocol");
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ strdup("Protocol"), val.str);
+ break;
+ case PDEVICE:
+ if (xf86getSubToken(&(ptr->inp_comment)) != STRING)
+ Error(QUOTE_MSG, "Device");
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ strdup("Device"), val.str);
+ break;
+ case EMULATE3:
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ strdup("Emulate3Buttons"),
+ NULL);
+ break;
+ case EM3TIMEOUT:
+ if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || val.num < 0)
+ Error(POSITIVE_INT_MSG, "Emulate3Timeout");
+ s = xf86uLongToString(val.num);
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ strdup("Emulate3Timeout"),
+ s);
+ break;
+ case CHORDMIDDLE:
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ strdup("ChordMiddle"), NULL);
+ break;
+ case PBUTTONS:
+ if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || val.num < 0)
+ Error(POSITIVE_INT_MSG, "Buttons");
+ s = xf86uLongToString(val.num);
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ strdup("Buttons"), s);
+ break;
+ case BAUDRATE:
+ if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || val.num < 0)
+ Error(POSITIVE_INT_MSG, "BaudRate");
+ s = xf86uLongToString(val.num);
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ strdup("BaudRate"), s);
+ break;
+ case SAMPLERATE:
+ if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || val.num < 0)
+ Error(POSITIVE_INT_MSG, "SampleRate");
+ s = xf86uLongToString(val.num);
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ strdup("SampleRate"), s);
+ break;
+ case PRESOLUTION:
+ if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || val.num < 0)
+ Error(POSITIVE_INT_MSG, "Resolution");
+ s = xf86uLongToString(val.num);
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ strdup("Resolution"), s);
+ break;
+ case CLEARDTR:
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ strdup("ClearDTR"), NULL);
+ break;
+ case CLEARRTS:
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ strdup("ClearRTS"), NULL);
+ break;
+ case ZAXISMAPPING:
+ switch (xf86getToken(ZMapTab)) {
+ case NUMBER:
+ if (val.num < 0)
+ Error(ZAXISMAPPING_MSG);
+ val1 = val.num;
+ if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER ||
+ val.num < 0) {
+ Error(ZAXISMAPPING_MSG);
+ }
+ if (asprintf(&s, "%lu %u", val1, val.num) == -1)
+ s = NULL;
+ break;
+ case XAXIS:
+ s = strdup("x");
+ break;
+ case YAXIS:
+ s = strdup("y");
+ break;
+ default:
+ Error(ZAXISMAPPING_MSG);
+ break;
+ }
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ strdup("ZAxisMapping"), s);
+ break;
+ case ALWAYSCORE:
+ break;
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG);
+ break;
+ default:
+ Error(INVALID_KEYWORD_MSG, xf86tokenString());
+ break;
+ }
+ }
+
+ ptr->inp_identifier = strdup(CONF_IMPLICIT_POINTER);
+ ptr->inp_driver = strdup("mouse");
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ strdup("CorePointer"), NULL);
#ifdef DEBUG
- printf ("Pointer section parsed\n");
+ printf("Pointer section parsed\n");
#endif
- return ptr;
+ return ptr;
}
#undef CLEANUP
-
diff --git a/xorg-server/hw/xfree86/parser/Screen.c b/xorg-server/hw/xfree86/parser/Screen.c
index 2ca2c570d..71778d88d 100644
--- a/xorg-server/hw/xfree86/parser/Screen.c
+++ b/xorg-server/hw/xfree86/parser/Screen.c
@@ -52,7 +52,6 @@
* authorization from the copyright holder(s) and author(s).
*/
-
/* View/edit this file with tab stops set to 4 */
#ifdef HAVE_XORG_CONFIG_H
@@ -65,505 +64,480 @@
extern LexRec val;
-static xf86ConfigSymTabRec DisplayTab[] =
-{
- {ENDSUBSECTION, "endsubsection"},
- {MODES, "modes"},
- {VIEWPORT, "viewport"},
- {VIRTUAL, "virtual"},
- {VISUAL, "visual"},
- {BLACK_TOK, "black"},
- {WHITE_TOK, "white"},
- {DEPTH, "depth"},
- {BPP, "fbbpp"},
- {WEIGHT, "weight"},
- {OPTION, "option"},
- {-1, ""},
+static xf86ConfigSymTabRec DisplayTab[] = {
+ {ENDSUBSECTION, "endsubsection"},
+ {MODES, "modes"},
+ {VIEWPORT, "viewport"},
+ {VIRTUAL, "virtual"},
+ {VISUAL, "visual"},
+ {BLACK_TOK, "black"},
+ {WHITE_TOK, "white"},
+ {DEPTH, "depth"},
+ {BPP, "fbbpp"},
+ {WEIGHT, "weight"},
+ {OPTION, "option"},
+ {-1, ""},
};
#define CLEANUP xf86freeDisplayList
static XF86ConfDisplayPtr
-xf86parseDisplaySubSection (void)
+xf86parseDisplaySubSection(void)
{
- int token;
- parsePrologue (XF86ConfDisplayPtr, XF86ConfDisplayRec)
-
- ptr->disp_black.red = ptr->disp_black.green = ptr->disp_black.blue = -1;
- ptr->disp_white.red = ptr->disp_white.green = ptr->disp_white.blue = -1;
- ptr->disp_frameX0 = ptr->disp_frameY0 = -1;
- while ((token = xf86getToken (DisplayTab)) != ENDSUBSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->disp_comment = xf86addComment(ptr->disp_comment, val.str);
- break;
- case VIEWPORT:
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (VIEWPORT_MSG);
- ptr->disp_frameX0 = val.num;
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (VIEWPORT_MSG);
- ptr->disp_frameY0 = val.num;
- break;
- case VIRTUAL:
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (VIRTUAL_MSG);
- ptr->disp_virtualX = val.num;
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (VIRTUAL_MSG);
- ptr->disp_virtualY = val.num;
- break;
- case DEPTH:
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (NUMBER_MSG, "Display");
- ptr->disp_depth = val.num;
- break;
- case BPP:
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (NUMBER_MSG, "Display");
- ptr->disp_bpp = val.num;
- break;
- case VISUAL:
- if (xf86getSubToken (&(ptr->disp_comment)) != STRING)
- Error (QUOTE_MSG, "Display");
- ptr->disp_visual = val.str;
- break;
- case WEIGHT:
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (WEIGHT_MSG);
- ptr->disp_weight.red = val.num;
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (WEIGHT_MSG);
- ptr->disp_weight.green = val.num;
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (WEIGHT_MSG);
- ptr->disp_weight.blue = val.num;
- break;
- case BLACK_TOK:
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (BLACK_MSG);
- ptr->disp_black.red = val.num;
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (BLACK_MSG);
- ptr->disp_black.green = val.num;
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (BLACK_MSG);
- ptr->disp_black.blue = val.num;
- break;
- case WHITE_TOK:
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (WHITE_MSG);
- ptr->disp_white.red = val.num;
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (WHITE_MSG);
- ptr->disp_white.green = val.num;
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (WHITE_MSG);
- ptr->disp_white.blue = val.num;
- break;
- case MODES:
- {
- XF86ModePtr mptr;
-
- while ((token = xf86getSubTokenWithTab (&(ptr->disp_comment), DisplayTab)) == STRING)
- {
- mptr = calloc (1, sizeof (XF86ModeRec));
- mptr->mode_name = val.str;
- mptr->list.next = NULL;
- ptr->disp_mode_lst = (XF86ModePtr)
- xf86addListItem ((glp) ptr->disp_mode_lst, (glp) mptr);
- }
- xf86unGetToken (token);
- }
- break;
- case OPTION:
- ptr->disp_option_lst = xf86parseOption(ptr->disp_option_lst);
- break;
-
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
+ int token;
+
+ parsePrologue(XF86ConfDisplayPtr, XF86ConfDisplayRec)
+
+ ptr->disp_black.red = ptr->disp_black.green = ptr->disp_black.blue = -1;
+ ptr->disp_white.red = ptr->disp_white.green = ptr->disp_white.blue = -1;
+ ptr->disp_frameX0 = ptr->disp_frameY0 = -1;
+ while ((token = xf86getToken(DisplayTab)) != ENDSUBSECTION) {
+ switch (token) {
+ case COMMENT:
+ ptr->disp_comment = xf86addComment(ptr->disp_comment, val.str);
+ break;
+ case VIEWPORT:
+ if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
+ Error(VIEWPORT_MSG);
+ ptr->disp_frameX0 = val.num;
+ if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
+ Error(VIEWPORT_MSG);
+ ptr->disp_frameY0 = val.num;
+ break;
+ case VIRTUAL:
+ if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
+ Error(VIRTUAL_MSG);
+ ptr->disp_virtualX = val.num;
+ if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
+ Error(VIRTUAL_MSG);
+ ptr->disp_virtualY = val.num;
+ break;
+ case DEPTH:
+ if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
+ Error(NUMBER_MSG, "Display");
+ ptr->disp_depth = val.num;
+ break;
+ case BPP:
+ if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
+ Error(NUMBER_MSG, "Display");
+ ptr->disp_bpp = val.num;
+ break;
+ case VISUAL:
+ if (xf86getSubToken(&(ptr->disp_comment)) != STRING)
+ Error(QUOTE_MSG, "Display");
+ ptr->disp_visual = val.str;
+ break;
+ case WEIGHT:
+ if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
+ Error(WEIGHT_MSG);
+ ptr->disp_weight.red = val.num;
+ if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
+ Error(WEIGHT_MSG);
+ ptr->disp_weight.green = val.num;
+ if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
+ Error(WEIGHT_MSG);
+ ptr->disp_weight.blue = val.num;
+ break;
+ case BLACK_TOK:
+ if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
+ Error(BLACK_MSG);
+ ptr->disp_black.red = val.num;
+ if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
+ Error(BLACK_MSG);
+ ptr->disp_black.green = val.num;
+ if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
+ Error(BLACK_MSG);
+ ptr->disp_black.blue = val.num;
+ break;
+ case WHITE_TOK:
+ if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
+ Error(WHITE_MSG);
+ ptr->disp_white.red = val.num;
+ if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
+ Error(WHITE_MSG);
+ ptr->disp_white.green = val.num;
+ if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
+ Error(WHITE_MSG);
+ ptr->disp_white.blue = val.num;
+ break;
+ case MODES:
+ {
+ XF86ModePtr mptr;
+
+ while ((token =
+ xf86getSubTokenWithTab(&(ptr->disp_comment),
+ DisplayTab)) == STRING) {
+ mptr = calloc(1, sizeof(XF86ModeRec));
+ mptr->mode_name = val.str;
+ mptr->list.next = NULL;
+ ptr->disp_mode_lst = (XF86ModePtr)
+ xf86addListItem((glp) ptr->disp_mode_lst, (glp) mptr);
+ }
+ xf86unGetToken(token);
+ }
+ break;
+ case OPTION:
+ ptr->disp_option_lst = xf86parseOption(ptr->disp_option_lst);
+ break;
+
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG);
+ break;
+ default:
+ Error(INVALID_KEYWORD_MSG, xf86tokenString());
+ break;
+ }
+ }
#ifdef DEBUG
- printf ("Display subsection parsed\n");
+ printf("Display subsection parsed\n");
#endif
- return ptr;
+ return ptr;
}
#undef CLEANUP
-static xf86ConfigSymTabRec ScreenTab[] =
-{
- {ENDSECTION, "endsection"},
- {IDENTIFIER, "identifier"},
- {OBSDRIVER, "driver"},
- {MDEVICE, "device"},
- {MONITOR, "monitor"},
- {VIDEOADAPTOR, "videoadaptor"},
- {SCREENNO, "screenno"},
- {SUBSECTION, "subsection"},
- {DEFAULTDEPTH, "defaultcolordepth"},
- {DEFAULTDEPTH, "defaultdepth"},
- {DEFAULTBPP, "defaultbpp"},
- {DEFAULTFBBPP, "defaultfbbpp"},
- {VIRTUAL, "virtual"},
- {OPTION, "option"},
- {-1, ""},
+static xf86ConfigSymTabRec ScreenTab[] = {
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {OBSDRIVER, "driver"},
+ {MDEVICE, "device"},
+ {MONITOR, "monitor"},
+ {VIDEOADAPTOR, "videoadaptor"},
+ {SCREENNO, "screenno"},
+ {SUBSECTION, "subsection"},
+ {DEFAULTDEPTH, "defaultcolordepth"},
+ {DEFAULTDEPTH, "defaultdepth"},
+ {DEFAULTBPP, "defaultbpp"},
+ {DEFAULTFBBPP, "defaultfbbpp"},
+ {VIRTUAL, "virtual"},
+ {OPTION, "option"},
+ {-1, ""},
};
#define CLEANUP xf86freeScreenList
XF86ConfScreenPtr
-xf86parseScreenSection (void)
+xf86parseScreenSection(void)
{
- int has_ident = FALSE;
- int has_driver= FALSE;
- int token;
-
- parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec)
-
- while ((token = xf86getToken (ScreenTab)) != ENDSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->scrn_comment = xf86addComment(ptr->scrn_comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
- Error (QUOTE_MSG, "Identifier");
- ptr->scrn_identifier = val.str;
- if (has_ident || has_driver)
- Error (ONLY_ONE_MSG,"Identifier or Driver");
- has_ident = TRUE;
- break;
- case OBSDRIVER:
- if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
- Error (QUOTE_MSG, "Driver");
- ptr->scrn_obso_driver = val.str;
- if (has_ident || has_driver)
- Error (ONLY_ONE_MSG,"Identifier or Driver");
- has_driver = TRUE;
- break;
- case DEFAULTDEPTH:
- if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
- Error (NUMBER_MSG, "DefaultDepth");
- ptr->scrn_defaultdepth = val.num;
- break;
- case DEFAULTBPP:
- if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
- Error (NUMBER_MSG, "DefaultBPP");
- ptr->scrn_defaultbpp = val.num;
- break;
- case DEFAULTFBBPP:
- if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
- Error (NUMBER_MSG, "DefaultFbBPP");
- ptr->scrn_defaultfbbpp = val.num;
- break;
- case MDEVICE:
- if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
- Error (QUOTE_MSG, "Device");
- ptr->scrn_device_str = val.str;
- break;
- case MONITOR:
- if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
- Error (QUOTE_MSG, "Monitor");
- ptr->scrn_monitor_str = val.str;
- break;
- case VIDEOADAPTOR:
- {
- XF86ConfAdaptorLinkPtr aptr;
-
- if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
- Error (QUOTE_MSG, "VideoAdaptor");
-
- /* Don't allow duplicates */
- for (aptr = ptr->scrn_adaptor_lst; aptr;
- aptr = (XF86ConfAdaptorLinkPtr) aptr->list.next)
- if (xf86nameCompare (val.str, aptr->al_adaptor_str) == 0)
- break;
-
- if (aptr == NULL)
- {
- aptr = calloc (1, sizeof (XF86ConfAdaptorLinkRec));
- aptr->list.next = NULL;
- aptr->al_adaptor_str = val.str;
- ptr->scrn_adaptor_lst = (XF86ConfAdaptorLinkPtr)
- xf86addListItem ((glp) ptr->scrn_adaptor_lst, (glp) aptr);
- }
- }
- break;
- case VIRTUAL:
- if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
- Error (VIRTUAL_MSG);
- ptr->scrn_virtualX = val.num;
- if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
- Error (VIRTUAL_MSG);
- ptr->scrn_virtualY = val.num;
- break;
- case OPTION:
- ptr->scrn_option_lst = xf86parseOption(ptr->scrn_option_lst);
- break;
- case SUBSECTION:
- if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
- Error (QUOTE_MSG, "SubSection");
- {
- free(val.str);
- HANDLE_LIST (scrn_display_lst, xf86parseDisplaySubSection,
- XF86ConfDisplayPtr);
- }
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
-
- if (!has_ident && !has_driver)
- Error (NO_IDENT_MSG);
+ int has_ident = FALSE;
+ int has_driver = FALSE;
+ int token;
+
+ parsePrologue(XF86ConfScreenPtr, XF86ConfScreenRec)
+
+ while ((token = xf86getToken(ScreenTab)) != ENDSECTION) {
+ switch (token) {
+ case COMMENT:
+ ptr->scrn_comment = xf86addComment(ptr->scrn_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
+ Error(QUOTE_MSG, "Identifier");
+ ptr->scrn_identifier = val.str;
+ if (has_ident || has_driver)
+ Error(ONLY_ONE_MSG, "Identifier or Driver");
+ has_ident = TRUE;
+ break;
+ case OBSDRIVER:
+ if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
+ Error(QUOTE_MSG, "Driver");
+ ptr->scrn_obso_driver = val.str;
+ if (has_ident || has_driver)
+ Error(ONLY_ONE_MSG, "Identifier or Driver");
+ has_driver = TRUE;
+ break;
+ case DEFAULTDEPTH:
+ if (xf86getSubToken(&(ptr->scrn_comment)) != NUMBER)
+ Error(NUMBER_MSG, "DefaultDepth");
+ ptr->scrn_defaultdepth = val.num;
+ break;
+ case DEFAULTBPP:
+ if (xf86getSubToken(&(ptr->scrn_comment)) != NUMBER)
+ Error(NUMBER_MSG, "DefaultBPP");
+ ptr->scrn_defaultbpp = val.num;
+ break;
+ case DEFAULTFBBPP:
+ if (xf86getSubToken(&(ptr->scrn_comment)) != NUMBER)
+ Error(NUMBER_MSG, "DefaultFbBPP");
+ ptr->scrn_defaultfbbpp = val.num;
+ break;
+ case MDEVICE:
+ if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
+ Error(QUOTE_MSG, "Device");
+ ptr->scrn_device_str = val.str;
+ break;
+ case MONITOR:
+ if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
+ Error(QUOTE_MSG, "Monitor");
+ ptr->scrn_monitor_str = val.str;
+ break;
+ case VIDEOADAPTOR:
+ {
+ XF86ConfAdaptorLinkPtr aptr;
+
+ if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
+ Error(QUOTE_MSG, "VideoAdaptor");
+
+ /* Don't allow duplicates */
+ for (aptr = ptr->scrn_adaptor_lst; aptr;
+ aptr = (XF86ConfAdaptorLinkPtr) aptr->list.next)
+ if (xf86nameCompare(val.str, aptr->al_adaptor_str) == 0)
+ break;
+
+ if (aptr == NULL) {
+ aptr = calloc(1, sizeof(XF86ConfAdaptorLinkRec));
+ aptr->list.next = NULL;
+ aptr->al_adaptor_str = val.str;
+ ptr->scrn_adaptor_lst = (XF86ConfAdaptorLinkPtr)
+ xf86addListItem((glp) ptr->scrn_adaptor_lst, (glp) aptr);
+ }
+ }
+ break;
+ case VIRTUAL:
+ if (xf86getSubToken(&(ptr->scrn_comment)) != NUMBER)
+ Error(VIRTUAL_MSG);
+ ptr->scrn_virtualX = val.num;
+ if (xf86getSubToken(&(ptr->scrn_comment)) != NUMBER)
+ Error(VIRTUAL_MSG);
+ ptr->scrn_virtualY = val.num;
+ break;
+ case OPTION:
+ ptr->scrn_option_lst = xf86parseOption(ptr->scrn_option_lst);
+ break;
+ case SUBSECTION:
+ if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
+ Error(QUOTE_MSG, "SubSection");
+ {
+ free(val.str);
+ HANDLE_LIST(scrn_display_lst, xf86parseDisplaySubSection,
+ XF86ConfDisplayPtr);
+ }
+ break;
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG);
+ break;
+ default:
+ Error(INVALID_KEYWORD_MSG, xf86tokenString());
+ break;
+ }
+ }
+
+ if (!has_ident && !has_driver)
+ Error(NO_IDENT_MSG);
#ifdef DEBUG
- printf ("Screen section parsed\n");
+ printf("Screen section parsed\n");
#endif
- return ptr;
+ return ptr;
}
void
-xf86printScreenSection (FILE * cf, XF86ConfScreenPtr ptr)
+xf86printScreenSection(FILE * cf, XF86ConfScreenPtr ptr)
{
- XF86ConfAdaptorLinkPtr aptr;
- XF86ConfDisplayPtr dptr;
- XF86ModePtr mptr;
-
- while (ptr)
- {
- fprintf (cf, "Section \"Screen\"\n");
- if (ptr->scrn_comment)
- fprintf (cf, "%s", ptr->scrn_comment);
- if (ptr->scrn_identifier)
- fprintf (cf, "\tIdentifier \"%s\"\n", ptr->scrn_identifier);
- if (ptr->scrn_obso_driver)
- fprintf (cf, "\tDriver \"%s\"\n", ptr->scrn_obso_driver);
- if (ptr->scrn_device_str)
- fprintf (cf, "\tDevice \"%s\"\n", ptr->scrn_device_str);
- if (ptr->scrn_monitor_str)
- fprintf (cf, "\tMonitor \"%s\"\n", ptr->scrn_monitor_str);
- if (ptr->scrn_defaultdepth)
- fprintf (cf, "\tDefaultDepth %d\n",
- ptr->scrn_defaultdepth);
- if (ptr->scrn_defaultbpp)
- fprintf (cf, "\tDefaultBPP %d\n",
- ptr->scrn_defaultbpp);
- if (ptr->scrn_defaultfbbpp)
- fprintf (cf, "\tDefaultFbBPP %d\n",
- ptr->scrn_defaultfbbpp);
- xf86printOptionList(cf, ptr->scrn_option_lst, 1);
- for (aptr = ptr->scrn_adaptor_lst; aptr; aptr = aptr->list.next)
- {
- fprintf (cf, "\tVideoAdaptor \"%s\"\n", aptr->al_adaptor_str);
- }
- if (ptr->scrn_virtualX && ptr->scrn_virtualY)
- fprintf (cf, "\tVirtual %d %d\n",
- ptr->scrn_virtualX,
- ptr->scrn_virtualY);
- for (dptr = ptr->scrn_display_lst; dptr; dptr = dptr->list.next)
- {
- fprintf (cf, "\tSubSection \"Display\"\n");
- if (dptr->disp_comment)
- fprintf (cf, "%s", dptr->disp_comment);
- if (dptr->disp_frameX0 >= 0 || dptr->disp_frameY0 >= 0)
- {
- fprintf (cf, "\t\tViewport %d %d\n",
- dptr->disp_frameX0, dptr->disp_frameY0);
- }
- if (dptr->disp_virtualX != 0 || dptr->disp_virtualY != 0)
- {
- fprintf (cf, "\t\tVirtual %d %d\n",
- dptr->disp_virtualX, dptr->disp_virtualY);
- }
- if (dptr->disp_depth)
- {
- fprintf (cf, "\t\tDepth %d\n", dptr->disp_depth);
- }
- if (dptr->disp_bpp)
- {
- fprintf (cf, "\t\tFbBPP %d\n", dptr->disp_bpp);
- }
- if (dptr->disp_visual)
- {
- fprintf (cf, "\t\tVisual \"%s\"\n", dptr->disp_visual);
- }
- if (dptr->disp_weight.red != 0)
- {
- fprintf (cf, "\t\tWeight %d %d %d\n",
- dptr->disp_weight.red, dptr->disp_weight.green, dptr->disp_weight.blue);
- }
- if (dptr->disp_black.red != -1)
- {
- fprintf (cf, "\t\tBlack 0x%04x 0x%04x 0x%04x\n",
- dptr->disp_black.red, dptr->disp_black.green, dptr->disp_black.blue);
- }
- if (dptr->disp_white.red != -1)
- {
- fprintf (cf, "\t\tWhite 0x%04x 0x%04x 0x%04x\n",
- dptr->disp_white.red, dptr->disp_white.green, dptr->disp_white.blue);
- }
- if (dptr->disp_mode_lst)
- {
- fprintf (cf, "\t\tModes ");
- }
- for (mptr = dptr->disp_mode_lst; mptr; mptr = mptr->list.next)
- {
- fprintf (cf, " \"%s\"", mptr->mode_name);
- }
- if (dptr->disp_mode_lst)
- {
- fprintf (cf, "\n");
- }
- xf86printOptionList(cf, dptr->disp_option_lst, 2);
- fprintf (cf, "\tEndSubSection\n");
- }
- fprintf (cf, "EndSection\n\n");
- ptr = ptr->list.next;
- }
+ XF86ConfAdaptorLinkPtr aptr;
+ XF86ConfDisplayPtr dptr;
+ XF86ModePtr mptr;
+
+ while (ptr) {
+ fprintf(cf, "Section \"Screen\"\n");
+ if (ptr->scrn_comment)
+ fprintf(cf, "%s", ptr->scrn_comment);
+ if (ptr->scrn_identifier)
+ fprintf(cf, "\tIdentifier \"%s\"\n", ptr->scrn_identifier);
+ if (ptr->scrn_obso_driver)
+ fprintf(cf, "\tDriver \"%s\"\n", ptr->scrn_obso_driver);
+ if (ptr->scrn_device_str)
+ fprintf(cf, "\tDevice \"%s\"\n", ptr->scrn_device_str);
+ if (ptr->scrn_monitor_str)
+ fprintf(cf, "\tMonitor \"%s\"\n", ptr->scrn_monitor_str);
+ if (ptr->scrn_defaultdepth)
+ fprintf(cf, "\tDefaultDepth %d\n", ptr->scrn_defaultdepth);
+ if (ptr->scrn_defaultbpp)
+ fprintf(cf, "\tDefaultBPP %d\n", ptr->scrn_defaultbpp);
+ if (ptr->scrn_defaultfbbpp)
+ fprintf(cf, "\tDefaultFbBPP %d\n", ptr->scrn_defaultfbbpp);
+ xf86printOptionList(cf, ptr->scrn_option_lst, 1);
+ for (aptr = ptr->scrn_adaptor_lst; aptr; aptr = aptr->list.next) {
+ fprintf(cf, "\tVideoAdaptor \"%s\"\n", aptr->al_adaptor_str);
+ }
+ if (ptr->scrn_virtualX && ptr->scrn_virtualY)
+ fprintf(cf, "\tVirtual %d %d\n",
+ ptr->scrn_virtualX, ptr->scrn_virtualY);
+ for (dptr = ptr->scrn_display_lst; dptr; dptr = dptr->list.next) {
+ fprintf(cf, "\tSubSection \"Display\"\n");
+ if (dptr->disp_comment)
+ fprintf(cf, "%s", dptr->disp_comment);
+ if (dptr->disp_frameX0 >= 0 || dptr->disp_frameY0 >= 0) {
+ fprintf(cf, "\t\tViewport %d %d\n",
+ dptr->disp_frameX0, dptr->disp_frameY0);
+ }
+ if (dptr->disp_virtualX != 0 || dptr->disp_virtualY != 0) {
+ fprintf(cf, "\t\tVirtual %d %d\n",
+ dptr->disp_virtualX, dptr->disp_virtualY);
+ }
+ if (dptr->disp_depth) {
+ fprintf(cf, "\t\tDepth %d\n", dptr->disp_depth);
+ }
+ if (dptr->disp_bpp) {
+ fprintf(cf, "\t\tFbBPP %d\n", dptr->disp_bpp);
+ }
+ if (dptr->disp_visual) {
+ fprintf(cf, "\t\tVisual \"%s\"\n", dptr->disp_visual);
+ }
+ if (dptr->disp_weight.red != 0) {
+ fprintf(cf, "\t\tWeight %d %d %d\n",
+ dptr->disp_weight.red, dptr->disp_weight.green,
+ dptr->disp_weight.blue);
+ }
+ if (dptr->disp_black.red != -1) {
+ fprintf(cf, "\t\tBlack 0x%04x 0x%04x 0x%04x\n",
+ dptr->disp_black.red, dptr->disp_black.green,
+ dptr->disp_black.blue);
+ }
+ if (dptr->disp_white.red != -1) {
+ fprintf(cf, "\t\tWhite 0x%04x 0x%04x 0x%04x\n",
+ dptr->disp_white.red, dptr->disp_white.green,
+ dptr->disp_white.blue);
+ }
+ if (dptr->disp_mode_lst) {
+ fprintf(cf, "\t\tModes ");
+ }
+ for (mptr = dptr->disp_mode_lst; mptr; mptr = mptr->list.next) {
+ fprintf(cf, " \"%s\"", mptr->mode_name);
+ }
+ if (dptr->disp_mode_lst) {
+ fprintf(cf, "\n");
+ }
+ xf86printOptionList(cf, dptr->disp_option_lst, 2);
+ fprintf(cf, "\tEndSubSection\n");
+ }
+ fprintf(cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
}
void
-xf86freeScreenList (XF86ConfScreenPtr ptr)
+xf86freeScreenList(XF86ConfScreenPtr ptr)
{
- XF86ConfScreenPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->scrn_identifier);
- TestFree (ptr->scrn_monitor_str);
- TestFree (ptr->scrn_device_str);
- TestFree (ptr->scrn_comment);
- xf86optionListFree (ptr->scrn_option_lst);
- xf86freeAdaptorLinkList (ptr->scrn_adaptor_lst);
- xf86freeDisplayList (ptr->scrn_display_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
+ XF86ConfScreenPtr prev;
+
+ while (ptr) {
+ TestFree(ptr->scrn_identifier);
+ TestFree(ptr->scrn_monitor_str);
+ TestFree(ptr->scrn_device_str);
+ TestFree(ptr->scrn_comment);
+ xf86optionListFree(ptr->scrn_option_lst);
+ xf86freeAdaptorLinkList(ptr->scrn_adaptor_lst);
+ xf86freeDisplayList(ptr->scrn_display_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free(prev);
+ }
}
void
-xf86freeAdaptorLinkList (XF86ConfAdaptorLinkPtr ptr)
+xf86freeAdaptorLinkList(XF86ConfAdaptorLinkPtr ptr)
{
- XF86ConfAdaptorLinkPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->al_adaptor_str);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
+ XF86ConfAdaptorLinkPtr prev;
+
+ while (ptr) {
+ TestFree(ptr->al_adaptor_str);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free(prev);
+ }
}
void
-xf86freeDisplayList (XF86ConfDisplayPtr ptr)
+xf86freeDisplayList(XF86ConfDisplayPtr ptr)
{
- XF86ConfDisplayPtr prev;
-
- while (ptr)
- {
- xf86freeModeList (ptr->disp_mode_lst);
- xf86optionListFree (ptr->disp_option_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
+ XF86ConfDisplayPtr prev;
+
+ while (ptr) {
+ xf86freeModeList(ptr->disp_mode_lst);
+ xf86optionListFree(ptr->disp_option_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free(prev);
+ }
}
void
-xf86freeModeList (XF86ModePtr ptr)
+xf86freeModeList(XF86ModePtr ptr)
{
- XF86ModePtr prev;
-
- while (ptr)
- {
- TestFree (ptr->mode_name);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
+ XF86ModePtr prev;
+
+ while (ptr) {
+ TestFree(ptr->mode_name);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free(prev);
+ }
}
int
-xf86validateScreen (XF86ConfigPtr p)
+xf86validateScreen(XF86ConfigPtr p)
{
- XF86ConfScreenPtr screen = p->conf_screen_lst;
- XF86ConfMonitorPtr monitor;
- XF86ConfAdaptorLinkPtr adaptor;
-
- while (screen)
- {
- if (screen->scrn_obso_driver && !screen->scrn_identifier)
- screen->scrn_identifier = screen->scrn_obso_driver;
-
- monitor = xf86findMonitor (screen->scrn_monitor_str, p->conf_monitor_lst);
- if (screen->scrn_monitor_str)
- {
- if (monitor)
- {
- screen->scrn_monitor = monitor;
- if (!xf86validateMonitor(p, screen))
- return FALSE;
- }
- }
-
- screen->scrn_device= xf86findDevice (screen->scrn_device_str, p->conf_device_lst);
-
- adaptor = screen->scrn_adaptor_lst;
- while (adaptor)
- {
- adaptor->al_adaptor = xf86findVideoAdaptor (adaptor->al_adaptor_str, p->conf_videoadaptor_lst);
- if (!adaptor->al_adaptor)
- {
- xf86validationError (UNDEFINED_ADAPTOR_MSG, adaptor->al_adaptor_str, screen->scrn_identifier);
- return FALSE;
- }
- else if (adaptor->al_adaptor->va_fwdref)
- {
- xf86validationError (ADAPTOR_REF_TWICE_MSG, adaptor->al_adaptor_str,
- adaptor->al_adaptor->va_fwdref);
- return FALSE;
- }
-
- adaptor->al_adaptor->va_fwdref = strdup(screen->scrn_identifier);
- adaptor = adaptor->list.next;
- }
-
- screen = screen->list.next;
- }
-
- return TRUE;
+ XF86ConfScreenPtr screen = p->conf_screen_lst;
+ XF86ConfMonitorPtr monitor;
+ XF86ConfAdaptorLinkPtr adaptor;
+
+ while (screen) {
+ if (screen->scrn_obso_driver && !screen->scrn_identifier)
+ screen->scrn_identifier = screen->scrn_obso_driver;
+
+ monitor =
+ xf86findMonitor(screen->scrn_monitor_str, p->conf_monitor_lst);
+ if (screen->scrn_monitor_str) {
+ if (monitor) {
+ screen->scrn_monitor = monitor;
+ if (!xf86validateMonitor(p, screen))
+ return FALSE;
+ }
+ }
+
+ screen->scrn_device =
+ xf86findDevice(screen->scrn_device_str, p->conf_device_lst);
+
+ adaptor = screen->scrn_adaptor_lst;
+ while (adaptor) {
+ adaptor->al_adaptor =
+ xf86findVideoAdaptor(adaptor->al_adaptor_str,
+ p->conf_videoadaptor_lst);
+ if (!adaptor->al_adaptor) {
+ xf86validationError(UNDEFINED_ADAPTOR_MSG,
+ adaptor->al_adaptor_str,
+ screen->scrn_identifier);
+ return FALSE;
+ }
+ else if (adaptor->al_adaptor->va_fwdref) {
+ xf86validationError(ADAPTOR_REF_TWICE_MSG,
+ adaptor->al_adaptor_str,
+ adaptor->al_adaptor->va_fwdref);
+ return FALSE;
+ }
+
+ adaptor->al_adaptor->va_fwdref = strdup(screen->scrn_identifier);
+ adaptor = adaptor->list.next;
+ }
+
+ screen = screen->list.next;
+ }
+
+ return TRUE;
}
XF86ConfScreenPtr
-xf86findScreen (const char *ident, XF86ConfScreenPtr p)
+xf86findScreen(const char *ident, XF86ConfScreenPtr p)
{
- while (p)
- {
- if (xf86nameCompare (ident, p->scrn_identifier) == 0)
- return p;
-
- p = p->list.next;
- }
- return NULL;
-}
+ while (p) {
+ if (xf86nameCompare(ident, p->scrn_identifier) == 0)
+ return p;
+ p = p->list.next;
+ }
+ return NULL;
+}
diff --git a/xorg-server/hw/xfree86/parser/Vendor.c b/xorg-server/hw/xfree86/parser/Vendor.c
index d61f0a052..b4e2165b0 100644
--- a/xorg-server/hw/xfree86/parser/Vendor.c
+++ b/xorg-server/hw/xfree86/parser/Vendor.c
@@ -52,7 +52,6 @@
* authorization from the copyright holder(s) and author(s).
*/
-
/* View/edit this file with tab stops set to 4 */
#ifdef HAVE_XORG_CONFIG_H
@@ -65,180 +64,173 @@
extern LexRec val;
-static xf86ConfigSymTabRec VendorSubTab[] =
-{
- {ENDSUBSECTION, "endsubsection"},
- {IDENTIFIER, "identifier"},
- {OPTION, "option"},
- {-1, ""},
+static xf86ConfigSymTabRec VendorSubTab[] = {
+ {ENDSUBSECTION, "endsubsection"},
+ {IDENTIFIER, "identifier"},
+ {OPTION, "option"},
+ {-1, ""},
};
#define CLEANUP xf86freeVendorSubList
static XF86ConfVendSubPtr
-xf86parseVendorSubSection (void)
+xf86parseVendorSubSection(void)
{
- int has_ident = FALSE;
- int token;
- parsePrologue (XF86ConfVendSubPtr, XF86ConfVendSubRec)
-
- while ((token = xf86getToken (VendorSubTab)) != ENDSUBSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->vs_comment = xf86addComment(ptr->vs_comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken (&(ptr->vs_comment)))
- Error (QUOTE_MSG, "Identifier");
- if (has_ident == TRUE)
- Error (MULTIPLE_MSG, "Identifier");
- ptr->vs_identifier = val.str;
- has_ident = TRUE;
- break;
- case OPTION:
- ptr->vs_option_lst = xf86parseOption(ptr->vs_option_lst);
- break;
-
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
+ int has_ident = FALSE;
+ int token;
+
+ parsePrologue(XF86ConfVendSubPtr, XF86ConfVendSubRec)
+
+ while ((token = xf86getToken(VendorSubTab)) != ENDSUBSECTION) {
+ switch (token) {
+ case COMMENT:
+ ptr->vs_comment = xf86addComment(ptr->vs_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken(&(ptr->vs_comment)))
+ Error(QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error(MULTIPLE_MSG, "Identifier");
+ ptr->vs_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case OPTION:
+ ptr->vs_option_lst = xf86parseOption(ptr->vs_option_lst);
+ break;
+
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG);
+ break;
+ default:
+ Error(INVALID_KEYWORD_MSG, xf86tokenString());
+ break;
+ }
+ }
#ifdef DEBUG
- printf ("Vendor subsection parsed\n");
+ printf("Vendor subsection parsed\n");
#endif
- return ptr;
+ return ptr;
}
#undef CLEANUP
-static xf86ConfigSymTabRec VendorTab[] =
-{
- {ENDSECTION, "endsection"},
- {IDENTIFIER, "identifier"},
- {OPTION, "option"},
- {SUBSECTION, "subsection"},
- {-1, ""},
+static xf86ConfigSymTabRec VendorTab[] = {
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {OPTION, "option"},
+ {SUBSECTION, "subsection"},
+ {-1, ""},
};
#define CLEANUP xf86freeVendorList
XF86ConfVendorPtr
-xf86parseVendorSection (void)
+xf86parseVendorSection(void)
{
- int has_ident = FALSE;
- int token;
- parsePrologue (XF86ConfVendorPtr, XF86ConfVendorRec)
-
- while ((token = xf86getToken (VendorTab)) != ENDSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->vnd_comment = xf86addComment(ptr->vnd_comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken (&(ptr->vnd_comment)) != STRING)
- Error (QUOTE_MSG, "Identifier");
- if (has_ident == TRUE)
- Error (MULTIPLE_MSG, "Identifier");
- ptr->vnd_identifier = val.str;
- has_ident = TRUE;
- break;
- case OPTION:
- ptr->vnd_option_lst = xf86parseOption(ptr->vnd_option_lst);
- break;
- case SUBSECTION:
- if (xf86getSubToken (&(ptr->vnd_comment)) != STRING)
- Error (QUOTE_MSG, "SubSection");
- {
- HANDLE_LIST (vnd_sub_lst, xf86parseVendorSubSection,
- XF86ConfVendSubPtr);
- }
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
-
- }
-
- if (!has_ident)
- Error (NO_IDENT_MSG);
+ int has_ident = FALSE;
+ int token;
+
+ parsePrologue(XF86ConfVendorPtr, XF86ConfVendorRec)
+
+ while ((token = xf86getToken(VendorTab)) != ENDSECTION) {
+ switch (token) {
+ case COMMENT:
+ ptr->vnd_comment = xf86addComment(ptr->vnd_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken(&(ptr->vnd_comment)) != STRING)
+ Error(QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error(MULTIPLE_MSG, "Identifier");
+ ptr->vnd_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case OPTION:
+ ptr->vnd_option_lst = xf86parseOption(ptr->vnd_option_lst);
+ break;
+ case SUBSECTION:
+ if (xf86getSubToken(&(ptr->vnd_comment)) != STRING)
+ Error(QUOTE_MSG, "SubSection");
+ {
+ HANDLE_LIST(vnd_sub_lst, xf86parseVendorSubSection,
+ XF86ConfVendSubPtr);
+ }
+ break;
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG);
+ break;
+ default:
+ Error(INVALID_KEYWORD_MSG, xf86tokenString());
+ break;
+ }
+
+ }
+
+ if (!has_ident)
+ Error(NO_IDENT_MSG);
#ifdef DEBUG
- printf ("Vendor section parsed\n");
+ printf("Vendor section parsed\n");
#endif
- return ptr;
+ return ptr;
}
#undef CLEANUP
void
-xf86printVendorSection (FILE * cf, XF86ConfVendorPtr ptr)
+xf86printVendorSection(FILE * cf, XF86ConfVendorPtr ptr)
{
- XF86ConfVendSubPtr pptr;
-
- while (ptr)
- {
- fprintf (cf, "Section \"Vendor\"\n");
- if (ptr->vnd_comment)
- fprintf (cf, "%s", ptr->vnd_comment);
- if (ptr->vnd_identifier)
- fprintf (cf, "\tIdentifier \"%s\"\n", ptr->vnd_identifier);
-
- xf86printOptionList(cf, ptr->vnd_option_lst, 1);
- for (pptr = ptr->vnd_sub_lst; pptr; pptr = pptr->list.next)
- {
- fprintf (cf, "\tSubSection \"Vendor\"\n");
- if (pptr->vs_comment)
- fprintf (cf, "%s", pptr->vs_comment);
- if (pptr->vs_identifier)
- fprintf (cf, "\t\tIdentifier \"%s\"\n", pptr->vs_identifier);
- xf86printOptionList(cf, pptr->vs_option_lst, 2);
- fprintf (cf, "\tEndSubSection\n");
- }
- fprintf (cf, "EndSection\n\n");
- ptr = ptr->list.next;
- }
+ XF86ConfVendSubPtr pptr;
+
+ while (ptr) {
+ fprintf(cf, "Section \"Vendor\"\n");
+ if (ptr->vnd_comment)
+ fprintf(cf, "%s", ptr->vnd_comment);
+ if (ptr->vnd_identifier)
+ fprintf(cf, "\tIdentifier \"%s\"\n", ptr->vnd_identifier);
+
+ xf86printOptionList(cf, ptr->vnd_option_lst, 1);
+ for (pptr = ptr->vnd_sub_lst; pptr; pptr = pptr->list.next) {
+ fprintf(cf, "\tSubSection \"Vendor\"\n");
+ if (pptr->vs_comment)
+ fprintf(cf, "%s", pptr->vs_comment);
+ if (pptr->vs_identifier)
+ fprintf(cf, "\t\tIdentifier \"%s\"\n", pptr->vs_identifier);
+ xf86printOptionList(cf, pptr->vs_option_lst, 2);
+ fprintf(cf, "\tEndSubSection\n");
+ }
+ fprintf(cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
}
void
-xf86freeVendorList (XF86ConfVendorPtr p)
+xf86freeVendorList(XF86ConfVendorPtr p)
{
- if (p == NULL)
- return;
- xf86freeVendorSubList (p->vnd_sub_lst);
- TestFree (p->vnd_identifier);
- TestFree (p->vnd_comment);
- xf86optionListFree (p->vnd_option_lst);
- free (p);
+ if (p == NULL)
+ return;
+ xf86freeVendorSubList(p->vnd_sub_lst);
+ TestFree(p->vnd_identifier);
+ TestFree(p->vnd_comment);
+ xf86optionListFree(p->vnd_option_lst);
+ free(p);
}
void
-xf86freeVendorSubList (XF86ConfVendSubPtr ptr)
+xf86freeVendorSubList(XF86ConfVendSubPtr ptr)
{
- XF86ConfVendSubPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->vs_identifier);
- TestFree (ptr->vs_name);
- TestFree (ptr->vs_comment);
- xf86optionListFree (ptr->vs_option_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
+ XF86ConfVendSubPtr prev;
+
+ while (ptr) {
+ TestFree(ptr->vs_identifier);
+ TestFree(ptr->vs_name);
+ TestFree(ptr->vs_comment);
+ xf86optionListFree(ptr->vs_option_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free(prev);
+ }
}
diff --git a/xorg-server/hw/xfree86/parser/Video.c b/xorg-server/hw/xfree86/parser/Video.c
index 19a5418b1..fc1f1e544 100644
--- a/xorg-server/hw/xfree86/parser/Video.c
+++ b/xorg-server/hw/xfree86/parser/Video.c
@@ -64,233 +64,223 @@
extern LexRec val;
-static xf86ConfigSymTabRec VideoPortTab[] =
-{
- {ENDSUBSECTION, "endsubsection"},
- {IDENTIFIER, "identifier"},
- {OPTION, "option"},
- {-1, ""},
+static xf86ConfigSymTabRec VideoPortTab[] = {
+ {ENDSUBSECTION, "endsubsection"},
+ {IDENTIFIER, "identifier"},
+ {OPTION, "option"},
+ {-1, ""},
};
#define CLEANUP xf86freeVideoPortList
static void
-xf86freeVideoPortList (XF86ConfVideoPortPtr ptr)
+xf86freeVideoPortList(XF86ConfVideoPortPtr ptr)
{
- XF86ConfVideoPortPtr prev;
+ XF86ConfVideoPortPtr prev;
- while (ptr)
- {
- TestFree (ptr->vp_identifier);
- TestFree (ptr->vp_comment);
- xf86optionListFree (ptr->vp_option_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
+ while (ptr) {
+ TestFree(ptr->vp_identifier);
+ TestFree(ptr->vp_comment);
+ xf86optionListFree(ptr->vp_option_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free(prev);
+ }
}
static XF86ConfVideoPortPtr
-xf86parseVideoPortSubSection (void)
+xf86parseVideoPortSubSection(void)
{
- int has_ident = FALSE;
- int token;
- parsePrologue (XF86ConfVideoPortPtr, XF86ConfVideoPortRec)
+ int has_ident = FALSE;
+ int token;
+
+ parsePrologue(XF86ConfVideoPortPtr, XF86ConfVideoPortRec)
- while ((token = xf86getToken (VideoPortTab)) != ENDSUBSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->vp_comment = xf86addComment(ptr->vp_comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken (&(ptr->vp_comment)) != STRING)
- Error (QUOTE_MSG, "Identifier");
- if (has_ident == TRUE)
- Error (MULTIPLE_MSG, "Identifier");
- ptr->vp_identifier = val.str;
- has_ident = TRUE;
- break;
- case OPTION:
- ptr->vp_option_lst = xf86parseOption(ptr->vp_option_lst);
- break;
+ while ((token = xf86getToken(VideoPortTab)) != ENDSUBSECTION) {
+ switch (token) {
+ case COMMENT:
+ ptr->vp_comment = xf86addComment(ptr->vp_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken(&(ptr->vp_comment)) != STRING)
+ Error(QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error(MULTIPLE_MSG, "Identifier");
+ ptr->vp_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case OPTION:
+ ptr->vp_option_lst = xf86parseOption(ptr->vp_option_lst);
+ break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG);
+ break;
+ default:
+ Error(INVALID_KEYWORD_MSG, xf86tokenString());
+ break;
+ }
+ }
#ifdef DEBUG
- printf ("VideoPort subsection parsed\n");
+ printf("VideoPort subsection parsed\n");
#endif
- return ptr;
+ return ptr;
}
#undef CLEANUP
-static xf86ConfigSymTabRec VideoAdaptorTab[] =
-{
- {ENDSECTION, "endsection"},
- {IDENTIFIER, "identifier"},
- {VENDOR, "vendorname"},
- {BOARD, "boardname"},
- {BUSID, "busid"},
- {DRIVER, "driver"},
- {OPTION, "option"},
- {SUBSECTION, "subsection"},
- {-1, ""},
+static xf86ConfigSymTabRec VideoAdaptorTab[] = {
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {VENDOR, "vendorname"},
+ {BOARD, "boardname"},
+ {BUSID, "busid"},
+ {DRIVER, "driver"},
+ {OPTION, "option"},
+ {SUBSECTION, "subsection"},
+ {-1, ""},
};
#define CLEANUP xf86freeVideoAdaptorList
XF86ConfVideoAdaptorPtr
-xf86parseVideoAdaptorSection (void)
+xf86parseVideoAdaptorSection(void)
{
- int has_ident = FALSE;
- int token;
+ int has_ident = FALSE;
+ int token;
- parsePrologue (XF86ConfVideoAdaptorPtr, XF86ConfVideoAdaptorRec)
+ parsePrologue(XF86ConfVideoAdaptorPtr, XF86ConfVideoAdaptorRec)
- while ((token = xf86getToken (VideoAdaptorTab)) != ENDSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->va_comment = xf86addComment(ptr->va_comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken (&(ptr->va_comment)) != STRING)
- Error (QUOTE_MSG, "Identifier");
- ptr->va_identifier = val.str;
- if (has_ident == TRUE)
- Error (MULTIPLE_MSG, "Identifier");
- has_ident = TRUE;
- break;
- case VENDOR:
- if (xf86getSubToken (&(ptr->va_comment)) != STRING)
- Error (QUOTE_MSG, "Vendor");
- ptr->va_vendor = val.str;
- break;
- case BOARD:
- if (xf86getSubToken (&(ptr->va_comment)) != STRING)
- Error (QUOTE_MSG, "Board");
- ptr->va_board = val.str;
- break;
- case BUSID:
- if (xf86getSubToken (&(ptr->va_comment)) != STRING)
- Error (QUOTE_MSG, "BusID");
- ptr->va_busid = val.str;
- break;
- case DRIVER:
- if (xf86getSubToken (&(ptr->va_comment)) != STRING)
- Error (QUOTE_MSG, "Driver");
- ptr->va_driver = val.str;
- break;
- case OPTION:
- ptr->va_option_lst = xf86parseOption(ptr->va_option_lst);
- break;
- case SUBSECTION:
- if (xf86getSubToken (&(ptr->va_comment)) != STRING)
- Error (QUOTE_MSG, "SubSection");
- {
- HANDLE_LIST (va_port_lst, xf86parseVideoPortSubSection,
- XF86ConfVideoPortPtr);
- }
- break;
+ while ((token = xf86getToken(VideoAdaptorTab)) != ENDSECTION) {
+ switch (token) {
+ case COMMENT:
+ ptr->va_comment = xf86addComment(ptr->va_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken(&(ptr->va_comment)) != STRING)
+ Error(QUOTE_MSG, "Identifier");
+ ptr->va_identifier = val.str;
+ if (has_ident == TRUE)
+ Error(MULTIPLE_MSG, "Identifier");
+ has_ident = TRUE;
+ break;
+ case VENDOR:
+ if (xf86getSubToken(&(ptr->va_comment)) != STRING)
+ Error(QUOTE_MSG, "Vendor");
+ ptr->va_vendor = val.str;
+ break;
+ case BOARD:
+ if (xf86getSubToken(&(ptr->va_comment)) != STRING)
+ Error(QUOTE_MSG, "Board");
+ ptr->va_board = val.str;
+ break;
+ case BUSID:
+ if (xf86getSubToken(&(ptr->va_comment)) != STRING)
+ Error(QUOTE_MSG, "BusID");
+ ptr->va_busid = val.str;
+ break;
+ case DRIVER:
+ if (xf86getSubToken(&(ptr->va_comment)) != STRING)
+ Error(QUOTE_MSG, "Driver");
+ ptr->va_driver = val.str;
+ break;
+ case OPTION:
+ ptr->va_option_lst = xf86parseOption(ptr->va_option_lst);
+ break;
+ case SUBSECTION:
+ if (xf86getSubToken(&(ptr->va_comment)) != STRING)
+ Error(QUOTE_MSG, "SubSection");
+ {
+ HANDLE_LIST(va_port_lst, xf86parseVideoPortSubSection,
+ XF86ConfVideoPortPtr);
+ }
+ break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG);
+ break;
+ default:
+ Error(INVALID_KEYWORD_MSG, xf86tokenString());
+ break;
+ }
+ }
- if (!has_ident)
- Error (NO_IDENT_MSG);
+ if (!has_ident)
+ Error(NO_IDENT_MSG);
#ifdef DEBUG
- printf ("VideoAdaptor section parsed\n");
+ printf("VideoAdaptor section parsed\n");
#endif
- return ptr;
+ return ptr;
}
void
-xf86printVideoAdaptorSection (FILE * cf, XF86ConfVideoAdaptorPtr ptr)
+xf86printVideoAdaptorSection(FILE * cf, XF86ConfVideoAdaptorPtr ptr)
{
- XF86ConfVideoPortPtr pptr;
+ XF86ConfVideoPortPtr pptr;
- while (ptr)
- {
- fprintf (cf, "Section \"VideoAdaptor\"\n");
- if (ptr->va_comment)
- fprintf (cf, "%s", ptr->va_comment);
- if (ptr->va_identifier)
- fprintf (cf, "\tIdentifier \"%s\"\n", ptr->va_identifier);
- if (ptr->va_vendor)
- fprintf (cf, "\tVendorName \"%s\"\n", ptr->va_vendor);
- if (ptr->va_board)
- fprintf (cf, "\tBoardName \"%s\"\n", ptr->va_board);
- if (ptr->va_busid)
- fprintf (cf, "\tBusID \"%s\"\n", ptr->va_busid);
- if (ptr->va_driver)
- fprintf (cf, "\tDriver \"%s\"\n", ptr->va_driver);
- xf86printOptionList(cf, ptr->va_option_lst, 1);
- for (pptr = ptr->va_port_lst; pptr; pptr = pptr->list.next)
- {
- fprintf (cf, "\tSubSection \"VideoPort\"\n");
- if (pptr->vp_comment)
- fprintf (cf, "%s", pptr->vp_comment);
- if (pptr->vp_identifier)
- fprintf (cf, "\t\tIdentifier \"%s\"\n", pptr->vp_identifier);
- xf86printOptionList(cf, pptr->vp_option_lst, 2);
- fprintf (cf, "\tEndSubSection\n");
- }
- fprintf (cf, "EndSection\n\n");
- ptr = ptr->list.next;
- }
+ while (ptr) {
+ fprintf(cf, "Section \"VideoAdaptor\"\n");
+ if (ptr->va_comment)
+ fprintf(cf, "%s", ptr->va_comment);
+ if (ptr->va_identifier)
+ fprintf(cf, "\tIdentifier \"%s\"\n", ptr->va_identifier);
+ if (ptr->va_vendor)
+ fprintf(cf, "\tVendorName \"%s\"\n", ptr->va_vendor);
+ if (ptr->va_board)
+ fprintf(cf, "\tBoardName \"%s\"\n", ptr->va_board);
+ if (ptr->va_busid)
+ fprintf(cf, "\tBusID \"%s\"\n", ptr->va_busid);
+ if (ptr->va_driver)
+ fprintf(cf, "\tDriver \"%s\"\n", ptr->va_driver);
+ xf86printOptionList(cf, ptr->va_option_lst, 1);
+ for (pptr = ptr->va_port_lst; pptr; pptr = pptr->list.next) {
+ fprintf(cf, "\tSubSection \"VideoPort\"\n");
+ if (pptr->vp_comment)
+ fprintf(cf, "%s", pptr->vp_comment);
+ if (pptr->vp_identifier)
+ fprintf(cf, "\t\tIdentifier \"%s\"\n", pptr->vp_identifier);
+ xf86printOptionList(cf, pptr->vp_option_lst, 2);
+ fprintf(cf, "\tEndSubSection\n");
+ }
+ fprintf(cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
}
void
-xf86freeVideoAdaptorList (XF86ConfVideoAdaptorPtr ptr)
+xf86freeVideoAdaptorList(XF86ConfVideoAdaptorPtr ptr)
{
- XF86ConfVideoAdaptorPtr prev;
+ XF86ConfVideoAdaptorPtr prev;
- while (ptr)
- {
- TestFree (ptr->va_identifier);
- TestFree (ptr->va_vendor);
- TestFree (ptr->va_board);
- TestFree (ptr->va_busid);
- TestFree (ptr->va_driver);
- TestFree (ptr->va_fwdref);
- TestFree (ptr->va_comment);
- xf86freeVideoPortList (ptr->va_port_lst);
- xf86optionListFree (ptr->va_option_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
+ while (ptr) {
+ TestFree(ptr->va_identifier);
+ TestFree(ptr->va_vendor);
+ TestFree(ptr->va_board);
+ TestFree(ptr->va_busid);
+ TestFree(ptr->va_driver);
+ TestFree(ptr->va_fwdref);
+ TestFree(ptr->va_comment);
+ xf86freeVideoPortList(ptr->va_port_lst);
+ xf86optionListFree(ptr->va_option_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free(prev);
+ }
}
XF86ConfVideoAdaptorPtr
-xf86findVideoAdaptor (const char *ident, XF86ConfVideoAdaptorPtr p)
+xf86findVideoAdaptor(const char *ident, XF86ConfVideoAdaptorPtr p)
{
- while (p)
- {
- if (xf86nameCompare (ident, p->va_identifier) == 0)
- return p;
+ while (p) {
+ if (xf86nameCompare(ident, p->va_identifier) == 0)
+ return p;
- p = p->list.next;
- }
- return NULL;
+ p = p->list.next;
+ }
+ return NULL;
}
diff --git a/xorg-server/hw/xfree86/parser/configProcs.h b/xorg-server/hw/xfree86/parser/configProcs.h
index d67acc698..1250f3922 100644
--- a/xorg-server/hw/xfree86/parser/configProcs.h
+++ b/xorg-server/hw/xfree86/parser/configProcs.h
@@ -32,82 +32,110 @@
/* Device.c */
XF86ConfDevicePtr xf86parseDeviceSection(void);
-void xf86printDeviceSection(FILE *cf, XF86ConfDevicePtr ptr);
+void xf86printDeviceSection(FILE * cf, XF86ConfDevicePtr ptr);
void xf86freeDeviceList(XF86ConfDevicePtr ptr);
int xf86validateDevice(XF86ConfigPtr p);
+
/* Files.c */
XF86ConfFilesPtr xf86parseFilesSection(void);
-void xf86printFileSection(FILE *cf, XF86ConfFilesPtr ptr);
+void xf86printFileSection(FILE * cf, XF86ConfFilesPtr ptr);
void xf86freeFiles(XF86ConfFilesPtr p);
+
/* Flags.c */
XF86ConfFlagsPtr xf86parseFlagsSection(void);
-void xf86printServerFlagsSection(FILE *f, XF86ConfFlagsPtr flags);
+void xf86printServerFlagsSection(FILE * f, XF86ConfFlagsPtr flags);
void xf86freeFlags(XF86ConfFlagsPtr flags);
+
/* Input.c */
XF86ConfInputPtr xf86parseInputSection(void);
-void xf86printInputSection(FILE *f, XF86ConfInputPtr ptr);
+void xf86printInputSection(FILE * f, XF86ConfInputPtr ptr);
void xf86freeInputList(XF86ConfInputPtr ptr);
-int xf86validateInput (XF86ConfigPtr p);
+int xf86validateInput(XF86ConfigPtr p);
+
/* InputClass.c */
XF86ConfInputClassPtr xf86parseInputClassSection(void);
-void xf86printInputClassSection(FILE *f, XF86ConfInputClassPtr ptr);
+void xf86printInputClassSection(FILE * f, XF86ConfInputClassPtr ptr);
void xf86freeInputClassList(XF86ConfInputClassPtr ptr);
+
/* Layout.c */
XF86ConfLayoutPtr xf86parseLayoutSection(void);
-void xf86printLayoutSection(FILE *cf, XF86ConfLayoutPtr ptr);
+void xf86printLayoutSection(FILE * cf, XF86ConfLayoutPtr ptr);
void xf86freeLayoutList(XF86ConfLayoutPtr ptr);
int xf86validateLayout(XF86ConfigPtr p);
+
/* Module.c */
XF86ConfModulePtr xf86parseModuleSection(void);
-void xf86printModuleSection(FILE *cf, XF86ConfModulePtr ptr);
-extern _X_EXPORT XF86LoadPtr xf86addNewLoadDirective(XF86LoadPtr head, char *name, int type, XF86OptionPtr opts);
+void xf86printModuleSection(FILE * cf, XF86ConfModulePtr ptr);
+extern _X_EXPORT XF86LoadPtr xf86addNewLoadDirective(XF86LoadPtr head,
+ char *name, int type,
+ XF86OptionPtr opts);
void xf86freeModules(XF86ConfModulePtr ptr);
+
/* Monitor.c */
XF86ConfMonitorPtr xf86parseMonitorSection(void);
XF86ConfModesPtr xf86parseModesSection(void);
-void xf86printMonitorSection(FILE *cf, XF86ConfMonitorPtr ptr);
-void xf86printModesSection(FILE *cf, XF86ConfModesPtr ptr);
+void xf86printMonitorSection(FILE * cf, XF86ConfMonitorPtr ptr);
+void xf86printModesSection(FILE * cf, XF86ConfModesPtr ptr);
extern _X_EXPORT void xf86freeMonitorList(XF86ConfMonitorPtr ptr);
void xf86freeModesList(XF86ConfModesPtr ptr);
int xf86validateMonitor(XF86ConfigPtr p, XF86ConfScreenPtr screen);
+
/* Pointer.c */
XF86ConfInputPtr xf86parsePointerSection(void);
+
/* Screen.c */
XF86ConfScreenPtr xf86parseScreenSection(void);
-void xf86printScreenSection(FILE *cf, XF86ConfScreenPtr ptr);
+void xf86printScreenSection(FILE * cf, XF86ConfScreenPtr ptr);
extern _X_EXPORT void xf86freeScreenList(XF86ConfScreenPtr ptr);
void xf86freeAdaptorLinkList(XF86ConfAdaptorLinkPtr ptr);
void xf86freeDisplayList(XF86ConfDisplayPtr ptr);
void xf86freeModeList(XF86ModePtr ptr);
int xf86validateScreen(XF86ConfigPtr p);
+
/* Vendor.c */
XF86ConfVendorPtr xf86parseVendorSection(void);
void xf86freeVendorList(XF86ConfVendorPtr p);
void xf86printVendorSection(FILE * cf, XF86ConfVendorPtr ptr);
-void xf86freeVendorSubList (XF86ConfVendSubPtr ptr);
+void xf86freeVendorSubList(XF86ConfVendSubPtr ptr);
+
/* Video.c */
XF86ConfVideoAdaptorPtr xf86parseVideoAdaptorSection(void);
-void xf86printVideoAdaptorSection(FILE *cf, XF86ConfVideoAdaptorPtr ptr);
+void xf86printVideoAdaptorSection(FILE * cf, XF86ConfVideoAdaptorPtr ptr);
void xf86freeVideoAdaptorList(XF86ConfVideoAdaptorPtr ptr);
+
/* scan.c */
-int xf86getToken(xf86ConfigSymTabRec *tab);
+int xf86getToken(xf86ConfigSymTabRec * tab);
int xf86getSubToken(char **comment);
-int xf86getSubTokenWithTab(char **comment, xf86ConfigSymTabRec *tab);
+int xf86getSubTokenWithTab(char **comment, xf86ConfigSymTabRec * tab);
void xf86unGetToken(int token);
char *xf86tokenString(void);
-void xf86parseError(const char *format, ...) _X_ATTRIBUTE_PRINTF(1,2);
-void xf86validationError(const char *format, ...) _X_ATTRIBUTE_PRINTF(1,2);
-void xf86setSection(const char *section);
-int xf86getStringToken(xf86ConfigSymTabRec *tab);
+void
+xf86parseError(const char *format, ...)
+_X_ATTRIBUTE_PRINTF(1, 2);
+void
+xf86validationError(const char *format, ...)
+_X_ATTRIBUTE_PRINTF(1, 2);
+void
+xf86setSection(const char *section);
+int
+xf86getStringToken(xf86ConfigSymTabRec * tab);
+
/* write.c */
/* DRI.c */
-XF86ConfDRIPtr xf86parseDRISection (void);
-void xf86printDRISection (FILE * cf, XF86ConfDRIPtr ptr);
-void xf86freeDRI (XF86ConfDRIPtr ptr);
+XF86ConfDRIPtr
+xf86parseDRISection(void);
+void
+xf86printDRISection(FILE * cf, XF86ConfDRIPtr ptr);
+void
+xf86freeDRI(XF86ConfDRIPtr ptr);
+
/* Extensions.c */
-XF86ConfExtensionsPtr xf86parseExtensionsSection (void);
-void xf86printExtensionsSection (FILE * cf, XF86ConfExtensionsPtr ptr);
-void xf86freeExtensions (XF86ConfExtensionsPtr ptr);
+XF86ConfExtensionsPtr
+xf86parseExtensionsSection(void);
+void
+xf86printExtensionsSection(FILE * cf, XF86ConfExtensionsPtr ptr);
+void
+xf86freeExtensions(XF86ConfExtensionsPtr ptr);
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
@@ -115,6 +143,8 @@ void xf86freeExtensions (XF86ConfExtensionsPtr ptr);
#ifndef IN_XSERVER
/* Externally provided functions */
-void ErrorF(const char *f, ...);
-void VErrorF(const char *f, va_list args);
+void
+ErrorF(const char *f, ...);
+void
+VErrorF(const char *f, va_list args);
#endif
diff --git a/xorg-server/hw/xfree86/parser/read.c b/xorg-server/hw/xfree86/parser/read.c
index 715626c53..eef873e89 100644
--- a/xorg-server/hw/xfree86/parser/read.c
+++ b/xorg-server/hw/xfree86/parser/read.c
@@ -1,318 +1,292 @@
-/*
- *
- * Copyright (c) 1997 Metro Link Incorporated
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- *
- */
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-/* View/edit this file with tab stops set to 4 */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "Configint.h"
-
-extern LexRec val;
-
-static xf86ConfigSymTabRec TopLevelTab[] =
-{
- {SECTION, "section"},
- {-1, ""},
-};
-
-#define CLEANUP xf86freeConfig
-
-/*
- * This function resolves name references and reports errors if the named
- * objects cannot be found.
- */
-static int
-xf86validateConfig (XF86ConfigPtr p)
-{
- if (!xf86validateScreen (p))
- return FALSE;
- if (!xf86validateInput (p))
- return FALSE;
- if (!xf86validateLayout (p))
- return FALSE;
-
- return TRUE;
-}
-
-XF86ConfigPtr
-xf86readConfigFile (void)
-{
- int token;
- XF86ConfigPtr ptr = NULL;
-
- if ((ptr = calloc (1, sizeof (XF86ConfigRec))) == NULL)
- {
- return NULL;
- }
-
- while ((token = xf86getToken (TopLevelTab)) != EOF_TOKEN)
- {
- switch (token)
- {
- case COMMENT:
- ptr->conf_comment = xf86addComment(ptr->conf_comment, val.str);
- break;
- case SECTION:
- if (xf86getSubToken (&(ptr->conf_comment)) != STRING)
- {
- xf86parseError (QUOTE_MSG, "Section");
- CLEANUP (ptr);
- return NULL;
- }
- xf86setSection (val.str);
- if (xf86nameCompare (val.str, "files") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_RETURN (conf_files, xf86parseFilesSection ());
- }
- else if (xf86nameCompare (val.str, "serverflags") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_RETURN (conf_flags, xf86parseFlagsSection ());
- }
- else if (xf86nameCompare (val.str, "pointer") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_input_lst, xf86parsePointerSection,
- XF86ConfInputPtr);
- }
- else if (xf86nameCompare (val.str, "videoadaptor") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_videoadaptor_lst, xf86parseVideoAdaptorSection,
- XF86ConfVideoAdaptorPtr);
- }
- else if (xf86nameCompare (val.str, "device") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_device_lst, xf86parseDeviceSection,
- XF86ConfDevicePtr);
- }
- else if (xf86nameCompare (val.str, "monitor") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_monitor_lst, xf86parseMonitorSection,
- XF86ConfMonitorPtr);
- }
- else if (xf86nameCompare (val.str, "modes") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_modes_lst, xf86parseModesSection,
- XF86ConfModesPtr);
- }
- else if (xf86nameCompare (val.str, "screen") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_screen_lst, xf86parseScreenSection,
- XF86ConfScreenPtr);
- }
- else if (xf86nameCompare(val.str, "inputdevice") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_input_lst, xf86parseInputSection,
- XF86ConfInputPtr);
- }
- else if (xf86nameCompare(val.str, "inputclass") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_inputclass_lst,
- xf86parseInputClassSection,
- XF86ConfInputClassPtr);
- }
- else if (xf86nameCompare (val.str, "module") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_RETURN (conf_modules, xf86parseModuleSection ());
- }
- else if (xf86nameCompare (val.str, "serverlayout") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_layout_lst, xf86parseLayoutSection,
- XF86ConfLayoutPtr);
- }
- else if (xf86nameCompare (val.str, "vendor") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_vendor_lst, xf86parseVendorSection,
- XF86ConfVendorPtr);
- }
- else if (xf86nameCompare (val.str, "dri") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_RETURN (conf_dri, xf86parseDRISection ());
- }
- else if (xf86nameCompare (val.str, "extensions") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_RETURN (conf_extensions, xf86parseExtensionsSection ());
- }
- else
- {
- free(val.str);
- val.str = NULL;
- Error (INVALID_SECTION_MSG, xf86tokenString ());
- }
- break;
- default:
- free(val.str);
- val.str = NULL;
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- }
- }
-
- if (xf86validateConfig (ptr))
- return ptr;
- else
- {
- CLEANUP (ptr);
- return NULL;
- }
-}
-
-#undef CLEANUP
-
-/*
- * adds an item to the end of the linked list. Any record whose first field
- * is a GenericListRec can be cast to this type and used with this function.
- * A pointer to the head of the list is returned to handle the addition of
- * the first item.
- */
-GenericListPtr
-xf86addListItem (GenericListPtr head, GenericListPtr new)
-{
- GenericListPtr p = head;
- GenericListPtr last = NULL;
-
- while (p)
- {
- last = p;
- p = p->next;
- }
-
- if (last)
- {
- last->next = new;
- return head;
- }
- else
- return new;
-}
-
-/*
- * Test if one chained list contains the other.
- * In this case both list have the same endpoint (provided they don't loop)
- */
-int
-xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2)
-{
- GenericListPtr p = list_1;
- GenericListPtr last_1 = NULL, last_2 = NULL;
-
- while (p) {
- last_1 = p;
- p = p->next;
- }
-
- p = list_2;
- while (p) {
- last_2 = p;
- p = p->next;
- }
-
- return (!(last_1 == last_2));
-}
-
-void
-xf86freeConfig (XF86ConfigPtr p)
-{
- if (p == NULL)
- return;
-
- xf86freeFiles (p->conf_files);
- xf86freeModules (p->conf_modules);
- xf86freeFlags (p->conf_flags);
- xf86freeMonitorList (p->conf_monitor_lst);
- xf86freeModesList (p->conf_modes_lst);
- xf86freeVideoAdaptorList (p->conf_videoadaptor_lst);
- xf86freeDeviceList (p->conf_device_lst);
- xf86freeScreenList (p->conf_screen_lst);
- xf86freeLayoutList (p->conf_layout_lst);
- xf86freeInputList (p->conf_input_lst);
- xf86freeVendorList (p->conf_vendor_lst);
- xf86freeDRI (p->conf_dri);
- xf86freeExtensions (p->conf_extensions);
- TestFree(p->conf_comment);
-
- free (p);
-}
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec TopLevelTab[] = {
+ {SECTION, "section"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeConfig
+
+/*
+ * This function resolves name references and reports errors if the named
+ * objects cannot be found.
+ */
+static int
+xf86validateConfig(XF86ConfigPtr p)
+{
+ if (!xf86validateScreen(p))
+ return FALSE;
+ if (!xf86validateInput(p))
+ return FALSE;
+ if (!xf86validateLayout(p))
+ return FALSE;
+
+ return TRUE;
+}
+
+XF86ConfigPtr
+xf86readConfigFile(void)
+{
+ int token;
+ XF86ConfigPtr ptr = NULL;
+
+ if ((ptr = calloc(1, sizeof(XF86ConfigRec))) == NULL) {
+ return NULL;
+ }
+
+ while ((token = xf86getToken(TopLevelTab)) != EOF_TOKEN) {
+ switch (token) {
+ case COMMENT:
+ ptr->conf_comment = xf86addComment(ptr->conf_comment, val.str);
+ break;
+ case SECTION:
+ if (xf86getSubToken(&(ptr->conf_comment)) != STRING) {
+ xf86parseError(QUOTE_MSG, "Section");
+ CLEANUP(ptr);
+ return NULL;
+ }
+ xf86setSection(val.str);
+ if (xf86nameCompare(val.str, "files") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_RETURN(conf_files, xf86parseFilesSection());
+ }
+ else if (xf86nameCompare(val.str, "serverflags") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_RETURN(conf_flags, xf86parseFlagsSection());
+ }
+ else if (xf86nameCompare(val.str, "pointer") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST(conf_input_lst, xf86parsePointerSection,
+ XF86ConfInputPtr);
+ }
+ else if (xf86nameCompare(val.str, "videoadaptor") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST(conf_videoadaptor_lst, xf86parseVideoAdaptorSection,
+ XF86ConfVideoAdaptorPtr);
+ }
+ else if (xf86nameCompare(val.str, "device") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST(conf_device_lst, xf86parseDeviceSection,
+ XF86ConfDevicePtr);
+ }
+ else if (xf86nameCompare(val.str, "monitor") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST(conf_monitor_lst, xf86parseMonitorSection,
+ XF86ConfMonitorPtr);
+ }
+ else if (xf86nameCompare(val.str, "modes") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST(conf_modes_lst, xf86parseModesSection,
+ XF86ConfModesPtr);
+ }
+ else if (xf86nameCompare(val.str, "screen") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST(conf_screen_lst, xf86parseScreenSection,
+ XF86ConfScreenPtr);
+ }
+ else if (xf86nameCompare(val.str, "inputdevice") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST(conf_input_lst, xf86parseInputSection,
+ XF86ConfInputPtr);
+ }
+ else if (xf86nameCompare(val.str, "inputclass") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST(conf_inputclass_lst,
+ xf86parseInputClassSection, XF86ConfInputClassPtr);
+ }
+ else if (xf86nameCompare(val.str, "module") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_RETURN(conf_modules, xf86parseModuleSection());
+ }
+ else if (xf86nameCompare(val.str, "serverlayout") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST(conf_layout_lst, xf86parseLayoutSection,
+ XF86ConfLayoutPtr);
+ }
+ else if (xf86nameCompare(val.str, "vendor") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST(conf_vendor_lst, xf86parseVendorSection,
+ XF86ConfVendorPtr);
+ }
+ else if (xf86nameCompare(val.str, "dri") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_RETURN(conf_dri, xf86parseDRISection());
+ }
+ else if (xf86nameCompare(val.str, "extensions") == 0) {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_RETURN(conf_extensions, xf86parseExtensionsSection());
+ }
+ else {
+ free(val.str);
+ val.str = NULL;
+ Error(INVALID_SECTION_MSG, xf86tokenString());
+ }
+ break;
+ default:
+ free(val.str);
+ val.str = NULL;
+ Error(INVALID_KEYWORD_MSG, xf86tokenString());
+ }
+ }
+
+ if (xf86validateConfig(ptr))
+ return ptr;
+ else {
+ CLEANUP(ptr);
+ return NULL;
+ }
+}
+
+#undef CLEANUP
+
+/*
+ * adds an item to the end of the linked list. Any record whose first field
+ * is a GenericListRec can be cast to this type and used with this function.
+ * A pointer to the head of the list is returned to handle the addition of
+ * the first item.
+ */
+GenericListPtr
+xf86addListItem(GenericListPtr head, GenericListPtr new)
+{
+ GenericListPtr p = head;
+ GenericListPtr last = NULL;
+
+ while (p) {
+ last = p;
+ p = p->next;
+ }
+
+ if (last) {
+ last->next = new;
+ return head;
+ }
+ else
+ return new;
+}
+
+/*
+ * Test if one chained list contains the other.
+ * In this case both list have the same endpoint (provided they don't loop)
+ */
+int
+xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2)
+{
+ GenericListPtr p = list_1;
+ GenericListPtr last_1 = NULL, last_2 = NULL;
+
+ while (p) {
+ last_1 = p;
+ p = p->next;
+ }
+
+ p = list_2;
+ while (p) {
+ last_2 = p;
+ p = p->next;
+ }
+
+ return (!(last_1 == last_2));
+}
+
+void
+xf86freeConfig(XF86ConfigPtr p)
+{
+ if (p == NULL)
+ return;
+
+ xf86freeFiles(p->conf_files);
+ xf86freeModules(p->conf_modules);
+ xf86freeFlags(p->conf_flags);
+ xf86freeMonitorList(p->conf_monitor_lst);
+ xf86freeModesList(p->conf_modes_lst);
+ xf86freeVideoAdaptorList(p->conf_videoadaptor_lst);
+ xf86freeDeviceList(p->conf_device_lst);
+ xf86freeScreenList(p->conf_screen_lst);
+ xf86freeLayoutList(p->conf_layout_lst);
+ xf86freeInputList(p->conf_input_lst);
+ xf86freeVendorList(p->conf_vendor_lst);
+ xf86freeDRI(p->conf_dri);
+ xf86freeExtensions(p->conf_extensions);
+ TestFree(p->conf_comment);
+
+ free(p);
+}
diff --git a/xorg-server/hw/xfree86/parser/scan.c b/xorg-server/hw/xfree86/parser/scan.c
index 156bc299a..795da615f 100644
--- a/xorg-server/hw/xfree86/parser/scan.c
+++ b/xorg-server/hw/xfree86/parser/scan.c
@@ -51,7 +51,6 @@
* authorization from the copyright holder(s) and author(s).
*/
-
/* View/edit this file with tab stops set to 4 */
#ifdef HAVE_XORG_CONFIG_H
@@ -75,11 +74,11 @@
#define _POSIX_SOURCE
#include <limits.h>
#undef _POSIX_SOURCE
-#endif /* _POSIX_SOURCE */
+#endif /* _POSIX_SOURCE */
#if !defined(MAXHOSTNAMELEN)
#define MAXHOSTNAMELEN 32
-#endif /* !MAXHOSTNAMELEN */
+#endif /* !MAXHOSTNAMELEN */
/* For PATH_MAX */
#include "misc.h"
@@ -90,22 +89,22 @@
#define CONFIG_BUF_LEN 1024
#define CONFIG_MAX_FILES 64
-static int StringToToken (const char *, xf86ConfigSymTabRec *);
+static int StringToToken(const char *, xf86ConfigSymTabRec *);
static struct {
- FILE *file;
- char *path;
+ FILE *file;
+ char *path;
} configFiles[CONFIG_MAX_FILES];
static const char **builtinConfig = NULL;
static int builtinIndex = 0;
-static int configPos = 0; /* current readers position */
-static int configLineNo = 0; /* linenumber */
-static char *configBuf, *configRBuf; /* buffer for lines */
-static char *configSection = NULL; /* name of current section being parsed */
-static int numFiles = 0; /* number of config files */
-static int curFileIndex = 0; /* index of current config file */
+static int configPos = 0; /* current readers position */
+static int configLineNo = 0; /* linenumber */
+static char *configBuf, *configRBuf; /* buffer for lines */
+static char *configSection = NULL; /* name of current section being parsed */
+static int numFiles = 0; /* number of config files */
+static int curFileIndex = 0; /* index of current config file */
static int pushToken = LOCK_TOKEN;
-static int eol_seen = 0; /* private state to handle comments */
+static int eol_seen = 0; /* private state to handle comments */
LexRec val;
/*
@@ -119,123 +118,129 @@ LexRec val;
* support that.
*/
-static char*
+static char *
xf86getNextLine(void)
{
- static int configBufLen = CONFIG_BUF_LEN;
- char *tmpConfigBuf, *tmpConfigRBuf;
- int c, i, pos = 0, eolFound = 0;
- char *ret = NULL;
+ static int configBufLen = CONFIG_BUF_LEN;
+ char *tmpConfigBuf, *tmpConfigRBuf;
+ int c, i, pos = 0, eolFound = 0;
+ char *ret = NULL;
- /*
- * reallocate the string if it was grown last time (i.e., is no
- * longer CONFIG_BUF_LEN); we malloc the new strings first, so
- * that if either of the mallocs fail, we can fall back on the
- * existing buffer allocations
- */
+ /*
+ * reallocate the string if it was grown last time (i.e., is no
+ * longer CONFIG_BUF_LEN); we malloc the new strings first, so
+ * that if either of the mallocs fail, we can fall back on the
+ * existing buffer allocations
+ */
- if (configBufLen != CONFIG_BUF_LEN) {
+ if (configBufLen != CONFIG_BUF_LEN) {
- tmpConfigBuf = malloc(CONFIG_BUF_LEN);
- tmpConfigRBuf = malloc(CONFIG_BUF_LEN);
+ tmpConfigBuf = malloc(CONFIG_BUF_LEN);
+ tmpConfigRBuf = malloc(CONFIG_BUF_LEN);
- if (!tmpConfigBuf || !tmpConfigRBuf) {
+ if (!tmpConfigBuf || !tmpConfigRBuf) {
- /*
- * at least one of the mallocs failed; keep the old buffers
- * and free any partial allocations
- */
+ /*
+ * at least one of the mallocs failed; keep the old buffers
+ * and free any partial allocations
+ */
- free(tmpConfigBuf);
- free(tmpConfigRBuf);
+ free(tmpConfigBuf);
+ free(tmpConfigRBuf);
- } else {
+ }
+ else {
- /*
- * malloc succeeded; free the old buffers and use the new
- * buffers
- */
+ /*
+ * malloc succeeded; free the old buffers and use the new
+ * buffers
+ */
- configBufLen = CONFIG_BUF_LEN;
+ configBufLen = CONFIG_BUF_LEN;
- free(configBuf);
- free(configRBuf);
+ free(configBuf);
+ free(configRBuf);
- configBuf = tmpConfigBuf;
- configRBuf = tmpConfigRBuf;
- }
- }
+ configBuf = tmpConfigBuf;
+ configRBuf = tmpConfigRBuf;
+ }
+ }
- /* read in another block of chars */
+ /* read in another block of chars */
- do {
- ret = fgets(configBuf + pos, configBufLen - pos - 1,
- configFiles[curFileIndex].file);
+ do {
+ ret = fgets(configBuf + pos, configBufLen - pos - 1,
+ configFiles[curFileIndex].file);
- if (!ret) {
- /*
- * if the file doesn't end in a newline, add one
- * and trigger another read
- */
- if (pos != 0) {
- strcpy(&configBuf[pos], "\n");
- ret = configBuf;
- } else
- break;
- }
+ if (!ret) {
+ /*
+ * if the file doesn't end in a newline, add one
+ * and trigger another read
+ */
+ if (pos != 0) {
+ strcpy(&configBuf[pos], "\n");
+ ret = configBuf;
+ }
+ else
+ break;
+ }
- /* search for EOL in the new block of chars */
+ /* search for EOL in the new block of chars */
- for (i = pos; i < (configBufLen - 1); i++) {
- c = configBuf[i];
+ for (i = pos; i < (configBufLen - 1); i++) {
+ c = configBuf[i];
- if (c == '\0') break;
+ if (c == '\0')
+ break;
- if ((c == '\n') || (c == '\r')) {
- eolFound = 1;
- break;
- }
- }
+ if ((c == '\n') || (c == '\r')) {
+ eolFound = 1;
+ break;
+ }
+ }
- /*
- * if we didn't find EOL, then grow the string and
- * read in more
- */
+ /*
+ * if we didn't find EOL, then grow the string and
+ * read in more
+ */
- if (!eolFound) {
+ if (!eolFound) {
- tmpConfigBuf = realloc(configBuf, configBufLen + CONFIG_BUF_LEN);
- tmpConfigRBuf = realloc(configRBuf, configBufLen + CONFIG_BUF_LEN);
+ tmpConfigBuf = realloc(configBuf, configBufLen + CONFIG_BUF_LEN);
+ tmpConfigRBuf = realloc(configRBuf, configBufLen + CONFIG_BUF_LEN);
- if (!tmpConfigBuf || !tmpConfigRBuf) {
+ if (!tmpConfigBuf || !tmpConfigRBuf) {
- /*
- * at least one of the reallocations failed; use the
- * new allocation that succeeded, but we have to
- * fallback to the previous configBufLen size and use
- * the string we have, even though we don't have an
- * EOL
- */
+ /*
+ * at least one of the reallocations failed; use the
+ * new allocation that succeeded, but we have to
+ * fallback to the previous configBufLen size and use
+ * the string we have, even though we don't have an
+ * EOL
+ */
- if (tmpConfigBuf) configBuf = tmpConfigBuf;
- if (tmpConfigRBuf) configRBuf = tmpConfigRBuf;
+ if (tmpConfigBuf)
+ configBuf = tmpConfigBuf;
+ if (tmpConfigRBuf)
+ configRBuf = tmpConfigRBuf;
- break;
+ break;
- } else {
+ }
+ else {
- /* reallocation succeeded */
+ /* reallocation succeeded */
- configBuf = tmpConfigBuf;
- configRBuf = tmpConfigRBuf;
- pos = i;
- configBufLen += CONFIG_BUF_LEN;
- }
- }
+ configBuf = tmpConfigBuf;
+ configRBuf = tmpConfigRBuf;
+ pos = i;
+ configBufLen += CONFIG_BUF_LEN;
+ }
+ }
- } while (!eolFound);
+ } while (!eolFound);
- return ret;
+ return ret;
}
/*
@@ -244,295 +249,278 @@ xf86getNextLine(void)
* pushToken.
*/
int
-xf86getToken (xf86ConfigSymTabRec * tab)
+xf86getToken(xf86ConfigSymTabRec * tab)
{
- int c, i;
-
- /*
- * First check whether pushToken has a different value than LOCK_TOKEN.
- * In this case rBuf[] contains a valid STRING/TOKEN/NUMBER. But in the
- * oth * case the next token must be read from the input.
- */
- if (pushToken == EOF_TOKEN)
- return EOF_TOKEN;
- else if (pushToken == LOCK_TOKEN)
- {
- /*
- * eol_seen is only set for the first token after a newline.
- */
- eol_seen = 0;
-
- c = configBuf[configPos];
-
- /*
- * Get start of next Token. EOF is handled,
- * whitespaces are skipped.
- */
-
-again:
- if (!c)
- {
- char *ret;
- if (numFiles > 0)
- ret = xf86getNextLine();
- else {
- if (builtinConfig[builtinIndex] == NULL)
- ret = NULL;
- else {
- strlcpy(configBuf,
- builtinConfig[builtinIndex],
- CONFIG_BUF_LEN);
- ret = configBuf;
- builtinIndex++;
- }
- }
- if (ret == NULL)
- {
- /*
- * if necessary, move to the next file and
- * read the first line
- */
- if (curFileIndex + 1 < numFiles) {
- curFileIndex++;
- configLineNo = 0;
- goto again;
- }
- else
- return pushToken = EOF_TOKEN;
- }
- configLineNo++;
- configPos = 0;
- eol_seen = 1;
- }
-
- i = 0;
- for (;;) {
- c = configBuf[configPos++];
- configRBuf[i++] = c;
- switch (c) {
- case ' ':
- case '\t':
- case '\r':
- continue;
- case '\n':
- i = 0;
- continue;
- }
- break;
- }
- if (c == '\0')
- goto again;
-
- if (c == '#')
- {
- do
- {
- configRBuf[i++] = (c = configBuf[configPos++]);
- }
- while ((c != '\n') && (c != '\r') && (c != '\0'));
- configRBuf[i] = '\0';
- /* XXX no private copy.
- * Use xf86addComment when setting a comment.
- */
- val.str = configRBuf;
- return COMMENT;
- }
-
- /* GJA -- handle '-' and ',' * Be careful: "-hsync" is a keyword. */
- else if ((c == ',') && !isalpha (configBuf[configPos]))
- {
- return COMMA;
- }
- else if ((c == '-') && !isalpha (configBuf[configPos]))
- {
- return DASH;
- }
-
- /*
- * Numbers are returned immediately ...
- */
- if (isdigit (c))
- {
- int base;
-
- if (c == '0')
- if ((configBuf[configPos] == 'x') ||
- (configBuf[configPos] == 'X'))
- {
- base = 16;
- val.numType = PARSE_HEX;
- }
- else
- {
- base = 8;
- val.numType = PARSE_OCTAL;
- }
- else
- {
- base = 10;
- val.numType = PARSE_DECIMAL;
- }
-
- configRBuf[0] = c;
- i = 1;
- while (isdigit (c = configBuf[configPos++]) ||
- (c == '.') || (c == 'x') || (c == 'X') ||
- ((base == 16) && (((c >= 'a') && (c <= 'f')) ||
- ((c >= 'A') && (c <= 'F')))))
- configRBuf[i++] = c;
- configPos--; /* GJA -- one too far */
- configRBuf[i] = '\0';
- val.num = strtoul (configRBuf, NULL, 0);
- val.realnum = atof (configRBuf);
- return NUMBER;
- }
-
- /*
- * All Strings START with a \" ...
- */
- else if (c == '\"')
- {
- i = -1;
- do
- {
- configRBuf[++i] = (c = configBuf[configPos++]);
- }
- while ((c != '\"') && (c != '\n') && (c != '\r') && (c != '\0'));
- configRBuf[i] = '\0';
- val.str = malloc (strlen (configRBuf) + 1);
- strcpy (val.str, configRBuf); /* private copy ! */
- return STRING;
- }
-
- /*
- * ... and now we MUST have a valid token. The search is
- * handled later along with the pushed tokens.
- */
- else
- {
- configRBuf[0] = c;
- i = 0;
- do
- {
- configRBuf[++i] = (c = configBuf[configPos++]);
- }
- while ((c != ' ') && (c != '\t') && (c != '\n') && (c != '\r') && (c != '\0') && (c != '#'));
- --configPos;
- configRBuf[i] = '\0';
- i = 0;
- }
-
- }
- else
- {
-
- /*
- * Here we deal with pushed tokens. Reinitialize pushToken again. If
- * the pushed token was NUMBER || STRING return them again ...
- */
- int temp = pushToken;
- pushToken = LOCK_TOKEN;
-
- if (temp == COMMA || temp == DASH)
- return temp;
- if (temp == NUMBER || temp == STRING)
- return temp;
- }
-
- /*
- * Joop, at last we have to lookup the token ...
- */
- if (tab)
- {
- i = 0;
- while (tab[i].token != -1)
- if (xf86nameCompare (configRBuf, tab[i].name) == 0)
- return tab[i].token;
- else
- i++;
- }
-
- return ERROR_TOKEN; /* Error catcher */
+ int c, i;
+
+ /*
+ * First check whether pushToken has a different value than LOCK_TOKEN.
+ * In this case rBuf[] contains a valid STRING/TOKEN/NUMBER. But in the
+ * oth * case the next token must be read from the input.
+ */
+ if (pushToken == EOF_TOKEN)
+ return EOF_TOKEN;
+ else if (pushToken == LOCK_TOKEN) {
+ /*
+ * eol_seen is only set for the first token after a newline.
+ */
+ eol_seen = 0;
+
+ c = configBuf[configPos];
+
+ /*
+ * Get start of next Token. EOF is handled,
+ * whitespaces are skipped.
+ */
+
+ again:
+ if (!c) {
+ char *ret;
+
+ if (numFiles > 0)
+ ret = xf86getNextLine();
+ else {
+ if (builtinConfig[builtinIndex] == NULL)
+ ret = NULL;
+ else {
+ strlcpy(configBuf,
+ builtinConfig[builtinIndex], CONFIG_BUF_LEN);
+ ret = configBuf;
+ builtinIndex++;
+ }
+ }
+ if (ret == NULL) {
+ /*
+ * if necessary, move to the next file and
+ * read the first line
+ */
+ if (curFileIndex + 1 < numFiles) {
+ curFileIndex++;
+ configLineNo = 0;
+ goto again;
+ }
+ else
+ return pushToken = EOF_TOKEN;
+ }
+ configLineNo++;
+ configPos = 0;
+ eol_seen = 1;
+ }
+
+ i = 0;
+ for (;;) {
+ c = configBuf[configPos++];
+ configRBuf[i++] = c;
+ switch (c) {
+ case ' ':
+ case '\t':
+ case '\r':
+ continue;
+ case '\n':
+ i = 0;
+ continue;
+ }
+ break;
+ }
+ if (c == '\0')
+ goto again;
+
+ if (c == '#') {
+ do {
+ configRBuf[i++] = (c = configBuf[configPos++]);
+ }
+ while ((c != '\n') && (c != '\r') && (c != '\0'));
+ configRBuf[i] = '\0';
+ /* XXX no private copy.
+ * Use xf86addComment when setting a comment.
+ */
+ val.str = configRBuf;
+ return COMMENT;
+ }
+
+ /* GJA -- handle '-' and ',' * Be careful: "-hsync" is a keyword. */
+ else if ((c == ',') && !isalpha(configBuf[configPos])) {
+ return COMMA;
+ }
+ else if ((c == '-') && !isalpha(configBuf[configPos])) {
+ return DASH;
+ }
+
+ /*
+ * Numbers are returned immediately ...
+ */
+ if (isdigit(c)) {
+ int base;
+
+ if (c == '0')
+ if ((configBuf[configPos] == 'x') ||
+ (configBuf[configPos] == 'X')) {
+ base = 16;
+ val.numType = PARSE_HEX;
+ }
+ else {
+ base = 8;
+ val.numType = PARSE_OCTAL;
+ }
+ else {
+ base = 10;
+ val.numType = PARSE_DECIMAL;
+ }
+
+ configRBuf[0] = c;
+ i = 1;
+ while (isdigit(c = configBuf[configPos++]) ||
+ (c == '.') || (c == 'x') || (c == 'X') ||
+ ((base == 16) && (((c >= 'a') && (c <= 'f')) ||
+ ((c >= 'A') && (c <= 'F')))))
+ configRBuf[i++] = c;
+ configPos--; /* GJA -- one too far */
+ configRBuf[i] = '\0';
+ val.num = strtoul(configRBuf, NULL, 0);
+ val.realnum = atof(configRBuf);
+ return NUMBER;
+ }
+
+ /*
+ * All Strings START with a \" ...
+ */
+ else if (c == '\"') {
+ i = -1;
+ do {
+ configRBuf[++i] = (c = configBuf[configPos++]);
+ }
+ while ((c != '\"') && (c != '\n') && (c != '\r') && (c != '\0'));
+ configRBuf[i] = '\0';
+ val.str = malloc(strlen(configRBuf) + 1);
+ strcpy(val.str, configRBuf); /* private copy ! */
+ return STRING;
+ }
+
+ /*
+ * ... and now we MUST have a valid token. The search is
+ * handled later along with the pushed tokens.
+ */
+ else {
+ configRBuf[0] = c;
+ i = 0;
+ do {
+ configRBuf[++i] = (c = configBuf[configPos++]);
+ }
+ while ((c != ' ') && (c != '\t') && (c != '\n') && (c != '\r') &&
+ (c != '\0') && (c != '#'));
+ --configPos;
+ configRBuf[i] = '\0';
+ i = 0;
+ }
+
+ }
+ else {
+
+ /*
+ * Here we deal with pushed tokens. Reinitialize pushToken again. If
+ * the pushed token was NUMBER || STRING return them again ...
+ */
+ int temp = pushToken;
+
+ pushToken = LOCK_TOKEN;
+
+ if (temp == COMMA || temp == DASH)
+ return temp;
+ if (temp == NUMBER || temp == STRING)
+ return temp;
+ }
+
+ /*
+ * Joop, at last we have to lookup the token ...
+ */
+ if (tab) {
+ i = 0;
+ while (tab[i].token != -1)
+ if (xf86nameCompare(configRBuf, tab[i].name) == 0)
+ return tab[i].token;
+ else
+ i++;
+ }
+
+ return ERROR_TOKEN; /* Error catcher */
}
int
-xf86getSubToken (char **comment)
+xf86getSubToken(char **comment)
{
- int token;
-
- for (;;) {
- token = xf86getToken(NULL);
- if (token == COMMENT) {
- if (comment)
- *comment = xf86addComment(*comment, val.str);
- }
- else
- return token;
- }
- /*NOTREACHED*/
-}
+ int token;
+
+ for (;;) {
+ token = xf86getToken(NULL);
+ if (token == COMMENT) {
+ if (comment)
+ *comment = xf86addComment(*comment, val.str);
+ }
+ else
+ return token;
+ }
+ /*NOTREACHED*/}
int
-xf86getSubTokenWithTab (char **comment, xf86ConfigSymTabRec *tab)
+xf86getSubTokenWithTab(char **comment, xf86ConfigSymTabRec * tab)
{
- int token;
-
- for (;;) {
- token = xf86getToken(tab);
- if (token == COMMENT) {
- if (comment)
- *comment = xf86addComment(*comment, val.str);
- }
- else
- return token;
- }
- /*NOTREACHED*/
-}
+ int token;
+
+ for (;;) {
+ token = xf86getToken(tab);
+ if (token == COMMENT) {
+ if (comment)
+ *comment = xf86addComment(*comment, val.str);
+ }
+ else
+ return token;
+ }
+ /*NOTREACHED*/}
void
-xf86unGetToken (int token)
+xf86unGetToken(int token)
{
- pushToken = token;
+ pushToken = token;
}
char *
-xf86tokenString (void)
+xf86tokenString(void)
{
- return configRBuf;
+ return configRBuf;
}
int
xf86pathIsAbsolute(const char *path)
{
- if (path && path[0] == '/')
- return 1;
- return 0;
+ if (path && path[0] == '/')
+ return 1;
+ return 0;
}
/* A path is "safe" if it is relative and if it contains no ".." elements. */
int
xf86pathIsSafe(const char *path)
{
- if (xf86pathIsAbsolute(path))
- return 0;
+ if (xf86pathIsAbsolute(path))
+ return 0;
- /* Compare with ".." */
- if (!strcmp(path, ".."))
- return 0;
+ /* Compare with ".." */
+ if (!strcmp(path, ".."))
+ return 0;
- /* Look for leading "../" */
- if (!strncmp(path, "../", 3))
- return 0;
+ /* Look for leading "../" */
+ if (!strncmp(path, "../", 3))
+ return 0;
- /* Look for trailing "/.." */
- if ((strlen(path) > 3) && !strcmp(path + strlen(path) - 3, "/.."))
- return 0;
+ /* Look for trailing "/.." */
+ if ((strlen(path) > 3) && !strcmp(path + strlen(path) - 3, "/.."))
+ return 0;
- /* Look for "/../" */
- if (strstr(path, "/../"))
- return 0;
+ /* Look for "/../" */
+ if (strstr(path, "/../"))
+ return 0;
- return 1;
+ return 1;
}
/*
@@ -596,129 +584,136 @@ xf86pathIsSafe(const char *path)
static char *
DoSubstitution(const char *template, const char *cmdline, const char *projroot,
- int *cmdlineUsed, int *envUsed,
- const char *XConfigFile)
+ int *cmdlineUsed, int *envUsed, const char *XConfigFile)
{
- char *result;
- int i, l;
- static const char *env = NULL;
- static char *hostname = NULL;
-
- if (!template)
- return NULL;
-
- if (cmdlineUsed)
- *cmdlineUsed = 0;
- if (envUsed)
- *envUsed = 0;
-
- result = malloc(PATH_MAX + 1);
- l = 0;
- for (i = 0; template[i]; i++) {
- if (template[i] != '%') {
- result[l++] = template[i];
- CHECK_LENGTH;
- } else {
- switch (template[++i]) {
- case 'A':
- if (cmdline && xf86pathIsAbsolute(cmdline)) {
- APPEND_STR(cmdline);
- if (cmdlineUsed)
- *cmdlineUsed = 1;
- } else
- BAIL_OUT;
- break;
- case 'R':
- if (cmdline && !xf86pathIsAbsolute(cmdline)) {
- APPEND_STR(cmdline);
- if (cmdlineUsed)
- *cmdlineUsed = 1;
- } else
- BAIL_OUT;
- break;
- case 'S':
- if (cmdline && xf86pathIsSafe(cmdline)) {
- APPEND_STR(cmdline);
- if (cmdlineUsed)
- *cmdlineUsed = 1;
- } else
- BAIL_OUT;
- break;
- case 'X':
- APPEND_STR(XConfigFile);
- break;
- case 'H':
- if (!hostname) {
- if ((hostname = malloc(MAXHOSTNAMELEN + 1))) {
- if (gethostname(hostname, MAXHOSTNAMELEN) == 0) {
- hostname[MAXHOSTNAMELEN] = '\0';
- } else {
- free(hostname);
- hostname = NULL;
- }
- }
- }
- if (hostname)
- APPEND_STR(hostname);
- break;
- case 'E':
- if (!env)
- env = getenv(XCONFENV);
- if (env && xf86pathIsAbsolute(env)) {
- APPEND_STR(env);
- if (envUsed)
- *envUsed = 1;
- } else
- BAIL_OUT;
- break;
- case 'F':
- if (!env)
- env = getenv(XCONFENV);
- if (env && !xf86pathIsAbsolute(env)) {
- APPEND_STR(env);
- if (envUsed)
- *envUsed = 1;
- } else
- BAIL_OUT;
- break;
- case 'G':
- if (!env)
- env = getenv(XCONFENV);
- if (env && xf86pathIsSafe(env)) {
- APPEND_STR(env);
- if (envUsed)
- *envUsed = 1;
- } else
- BAIL_OUT;
- break;
- case 'P':
- if (projroot && xf86pathIsAbsolute(projroot))
- APPEND_STR(projroot);
- else
- BAIL_OUT;
- break;
- case 'C':
- APPEND_STR(SYSCONFDIR);
- break;
- case 'D':
- APPEND_STR(DATADIR);
- break;
- case '%':
- result[l++] = '%';
- CHECK_LENGTH;
- break;
- default:
- fprintf(stderr, "invalid escape %%%c found in path template\n",
- template[i]);
- BAIL_OUT;
- break;
- }
- }
- }
+ char *result;
+ int i, l;
+ static const char *env = NULL;
+ static char *hostname = NULL;
+
+ if (!template)
+ return NULL;
+
+ if (cmdlineUsed)
+ *cmdlineUsed = 0;
+ if (envUsed)
+ *envUsed = 0;
+
+ result = malloc(PATH_MAX + 1);
+ l = 0;
+ for (i = 0; template[i]; i++) {
+ if (template[i] != '%') {
+ result[l++] = template[i];
+ CHECK_LENGTH;
+ }
+ else {
+ switch (template[++i]) {
+ case 'A':
+ if (cmdline && xf86pathIsAbsolute(cmdline)) {
+ APPEND_STR(cmdline);
+ if (cmdlineUsed)
+ *cmdlineUsed = 1;
+ }
+ else
+ BAIL_OUT;
+ break;
+ case 'R':
+ if (cmdline && !xf86pathIsAbsolute(cmdline)) {
+ APPEND_STR(cmdline);
+ if (cmdlineUsed)
+ *cmdlineUsed = 1;
+ }
+ else
+ BAIL_OUT;
+ break;
+ case 'S':
+ if (cmdline && xf86pathIsSafe(cmdline)) {
+ APPEND_STR(cmdline);
+ if (cmdlineUsed)
+ *cmdlineUsed = 1;
+ }
+ else
+ BAIL_OUT;
+ break;
+ case 'X':
+ APPEND_STR(XConfigFile);
+ break;
+ case 'H':
+ if (!hostname) {
+ if ((hostname = malloc(MAXHOSTNAMELEN + 1))) {
+ if (gethostname(hostname, MAXHOSTNAMELEN) == 0) {
+ hostname[MAXHOSTNAMELEN] = '\0';
+ }
+ else {
+ free(hostname);
+ hostname = NULL;
+ }
+ }
+ }
+ if (hostname)
+ APPEND_STR(hostname);
+ break;
+ case 'E':
+ if (!env)
+ env = getenv(XCONFENV);
+ if (env && xf86pathIsAbsolute(env)) {
+ APPEND_STR(env);
+ if (envUsed)
+ *envUsed = 1;
+ }
+ else
+ BAIL_OUT;
+ break;
+ case 'F':
+ if (!env)
+ env = getenv(XCONFENV);
+ if (env && !xf86pathIsAbsolute(env)) {
+ APPEND_STR(env);
+ if (envUsed)
+ *envUsed = 1;
+ }
+ else
+ BAIL_OUT;
+ break;
+ case 'G':
+ if (!env)
+ env = getenv(XCONFENV);
+ if (env && xf86pathIsSafe(env)) {
+ APPEND_STR(env);
+ if (envUsed)
+ *envUsed = 1;
+ }
+ else
+ BAIL_OUT;
+ break;
+ case 'P':
+ if (projroot && xf86pathIsAbsolute(projroot))
+ APPEND_STR(projroot);
+ else
+ BAIL_OUT;
+ break;
+ case 'C':
+ APPEND_STR(SYSCONFDIR);
+ break;
+ case 'D':
+ APPEND_STR(DATADIR);
+ break;
+ case '%':
+ result[l++] = '%';
+ CHECK_LENGTH;
+ break;
+ default:
+ fprintf(stderr, "invalid escape %%%c found in path template\n",
+ template[i]);
+ BAIL_OUT;
+ break;
+ }
+ }
+ }
#ifdef DEBUG
- fprintf(stderr, "Converted `%s' to `%s'\n", template, result);
+ fprintf(stderr, "Converted `%s' to `%s'\n", template, result);
#endif
- return result;
+ return result;
}
/*
@@ -726,40 +721,40 @@ DoSubstitution(const char *template, const char *cmdline, const char *projroot,
*/
static char *
OpenConfigFile(const char *path, const char *cmdline, const char *projroot,
- const char *confname)
+ const char *confname)
{
- char *filepath = NULL;
- char *pathcopy;
- const char *template;
- int cmdlineUsed = 0;
- FILE *file = NULL;
-
- pathcopy = strdup(path);
- for (template = strtok(pathcopy, ","); template && !file;
- template = strtok(NULL, ",")) {
- filepath = DoSubstitution(template, cmdline, projroot,
- &cmdlineUsed, NULL, confname);
- if (!filepath)
- continue;
- if (cmdline && !cmdlineUsed) {
- free(filepath);
- filepath = NULL;
- continue;
- }
- file = fopen(filepath, "r");
- if (!file) {
- free(filepath);
- filepath = NULL;
- }
- }
-
- free(pathcopy);
- if (file) {
- configFiles[numFiles].file = file;
- configFiles[numFiles].path = strdup(filepath);
- numFiles++;
- }
- return filepath;
+ char *filepath = NULL;
+ char *pathcopy;
+ const char *template;
+ int cmdlineUsed = 0;
+ FILE *file = NULL;
+
+ pathcopy = strdup(path);
+ for (template = strtok(pathcopy, ","); template && !file;
+ template = strtok(NULL, ",")) {
+ filepath = DoSubstitution(template, cmdline, projroot,
+ &cmdlineUsed, NULL, confname);
+ if (!filepath)
+ continue;
+ if (cmdline && !cmdlineUsed) {
+ free(filepath);
+ filepath = NULL;
+ continue;
+ }
+ file = fopen(filepath, "r");
+ if (!file) {
+ free(filepath);
+ filepath = NULL;
+ }
+ }
+
+ free(pathcopy);
+ if (file) {
+ configFiles[numFiles].file = file;
+ configFiles[numFiles].path = strdup(filepath);
+ numFiles++;
+ }
+ return filepath;
}
/*
@@ -769,56 +764,54 @@ OpenConfigFile(const char *path, const char *cmdline, const char *projroot,
static int
ConfigFilter(const struct dirent *de)
{
- const char *name = de->d_name;
- size_t len;
- size_t suflen = strlen(XCONFIGSUFFIX);
-
- if (!name || name[0] == '.')
- return 0;
- len = strlen(name);
- if(len <= suflen)
- return 0;
- if (strcmp(&name[len-suflen], XCONFIGSUFFIX) != 0)
- return 0;
- return 1;
+ const char *name = de->d_name;
+ size_t len;
+ size_t suflen = strlen(XCONFIGSUFFIX);
+
+ if (!name || name[0] == '.')
+ return 0;
+ len = strlen(name);
+ if (len <= suflen)
+ return 0;
+ if (strcmp(&name[len - suflen], XCONFIGSUFFIX) != 0)
+ return 0;
+ return 1;
}
static Bool
AddConfigDirFiles(const char *dirpath, struct dirent **list, int num)
{
- int i;
- Bool openedFile = FALSE;
- Bool warnOnce = FALSE;
-
- for (i = 0; i < num; i++) {
- char *path;
- FILE *file;
-
- if (numFiles >= CONFIG_MAX_FILES) {
- if (!warnOnce) {
- ErrorF("Maximum number of configuration "
- "files opened\n");
- warnOnce = TRUE;
- }
- continue;
- }
-
- path = malloc(PATH_MAX + 1);
- snprintf(path, PATH_MAX + 1, "%s/%s", dirpath,
- list[i]->d_name);
- file = fopen(path, "r");
- if (!file) {
- free(path);
- continue;
- }
- openedFile = TRUE;
-
- configFiles[numFiles].file = file;
- configFiles[numFiles].path = path;
- numFiles++;
- }
-
- return openedFile;
+ int i;
+ Bool openedFile = FALSE;
+ Bool warnOnce = FALSE;
+
+ for (i = 0; i < num; i++) {
+ char *path;
+ FILE *file;
+
+ if (numFiles >= CONFIG_MAX_FILES) {
+ if (!warnOnce) {
+ ErrorF("Maximum number of configuration " "files opened\n");
+ warnOnce = TRUE;
+ }
+ continue;
+ }
+
+ path = malloc(PATH_MAX + 1);
+ snprintf(path, PATH_MAX + 1, "%s/%s", dirpath, list[i]->d_name);
+ file = fopen(path, "r");
+ if (!file) {
+ free(path);
+ continue;
+ }
+ openedFile = TRUE;
+
+ configFiles[numFiles].file = file;
+ configFiles[numFiles].path = path;
+ numFiles++;
+ }
+
+ return openedFile;
}
/*
@@ -827,47 +820,47 @@ AddConfigDirFiles(const char *dirpath, struct dirent **list, int num)
*/
static char *
OpenConfigDir(const char *path, const char *cmdline, const char *projroot,
- const char *confname)
+ const char *confname)
{
- char *dirpath, *pathcopy;
- const char *template;
- Bool found = FALSE;
- int cmdlineUsed = 0;
-
- pathcopy = strdup(path);
- for (template = strtok(pathcopy, ","); template && !found;
- template = strtok(NULL, ",")) {
- struct dirent **list = NULL;
- int num;
-
- dirpath = DoSubstitution(template, cmdline, projroot,
- &cmdlineUsed, NULL, confname);
- if (!dirpath)
- continue;
- if (cmdline && !cmdlineUsed) {
- free(dirpath);
- dirpath = NULL;
- continue;
- }
-
- /* match files named *.conf */
- num = scandir(dirpath, &list, ConfigFilter, alphasort);
- if (num < 0) {
- list = NULL;
- num = 0;
- }
- found = AddConfigDirFiles(dirpath, list, num);
- if (!found) {
- free(dirpath);
- dirpath = NULL;
- }
- while (num--)
- free(list[num]);
- free(list);
- }
-
- free(pathcopy);
- return dirpath;
+ char *dirpath, *pathcopy;
+ const char *template;
+ Bool found = FALSE;
+ int cmdlineUsed = 0;
+
+ pathcopy = strdup(path);
+ for (template = strtok(pathcopy, ","); template && !found;
+ template = strtok(NULL, ",")) {
+ struct dirent **list = NULL;
+ int num;
+
+ dirpath = DoSubstitution(template, cmdline, projroot,
+ &cmdlineUsed, NULL, confname);
+ if (!dirpath)
+ continue;
+ if (cmdline && !cmdlineUsed) {
+ free(dirpath);
+ dirpath = NULL;
+ continue;
+ }
+
+ /* match files named *.conf */
+ num = scandir(dirpath, &list, ConfigFilter, alphasort);
+ if (num < 0) {
+ list = NULL;
+ num = 0;
+ }
+ found = AddConfigDirFiles(dirpath, list, num);
+ if (!found) {
+ free(dirpath);
+ dirpath = NULL;
+ }
+ while (num--)
+ free(list[num]);
+ free(list);
+ }
+
+ free(pathcopy);
+ return dirpath;
}
/*
@@ -876,14 +869,14 @@ OpenConfigDir(const char *path, const char *cmdline, const char *projroot,
void
xf86initConfigFiles(void)
{
- curFileIndex = 0;
- configPos = 0;
- configLineNo = 0;
- pushToken = LOCK_TOKEN;
-
- configBuf = malloc(CONFIG_BUF_LEN);
- configRBuf = malloc(CONFIG_BUF_LEN);
- configBuf[0] = '\0'; /* sanity ... */
+ curFileIndex = 0;
+ configPos = 0;
+ configLineNo = 0;
+ pushToken = LOCK_TOKEN;
+
+ configBuf = malloc(CONFIG_BUF_LEN);
+ configRBuf = malloc(CONFIG_BUF_LEN);
+ configBuf[0] = '\0'; /* sanity ... */
}
/*
@@ -922,13 +915,13 @@ xf86initConfigFiles(void)
char *
xf86openConfigFile(const char *path, const char *cmdline, const char *projroot)
{
- if (!path || !path[0])
- path = DEFAULT_CONF_PATH;
- if (!projroot || !projroot[0])
- projroot = PROJECTROOT;
+ if (!path || !path[0])
+ path = DEFAULT_CONF_PATH;
+ if (!projroot || !projroot[0])
+ projroot = PROJECTROOT;
- /* Search for a config file */
- return OpenConfigFile(path, cmdline, projroot, XCONFIGFILE);
+ /* Search for a config file */
+ return OpenConfigFile(path, cmdline, projroot, XCONFIGFILE);
}
/*
@@ -949,82 +942,82 @@ xf86openConfigFile(const char *path, const char *cmdline, const char *projroot)
*/
char *
xf86openConfigDirFiles(const char *path, const char *cmdline,
- const char *projroot)
+ const char *projroot)
{
- if (!path || !path[0])
- path = DEFAULT_CONF_PATH;
- if (!projroot || !projroot[0])
- projroot = PROJECTROOT;
+ if (!path || !path[0])
+ path = DEFAULT_CONF_PATH;
+ if (!projroot || !projroot[0])
+ projroot = PROJECTROOT;
- /* Search for the multiconf directory */
- return OpenConfigDir(path, cmdline, projroot, XCONFIGDIR);
+ /* Search for the multiconf directory */
+ return OpenConfigDir(path, cmdline, projroot, XCONFIGDIR);
}
void
-xf86closeConfigFile (void)
+xf86closeConfigFile(void)
{
- int i;
-
- free (configRBuf);
- configRBuf = NULL;
- free (configBuf);
- configBuf = NULL;
-
- if (numFiles == 0) {
- builtinConfig = NULL;
- builtinIndex = 0;
- }
- for (i = 0; i < numFiles; i++) {
- fclose(configFiles[i].file);
- configFiles[i].file = NULL;
- free(configFiles[i].path);
- configFiles[i].path = NULL;
- }
- numFiles = 0;
+ int i;
+
+ free(configRBuf);
+ configRBuf = NULL;
+ free(configBuf);
+ configBuf = NULL;
+
+ if (numFiles == 0) {
+ builtinConfig = NULL;
+ builtinIndex = 0;
+ }
+ for (i = 0; i < numFiles; i++) {
+ fclose(configFiles[i].file);
+ configFiles[i].file = NULL;
+ free(configFiles[i].path);
+ configFiles[i].path = NULL;
+ }
+ numFiles = 0;
}
void
xf86setBuiltinConfig(const char *config[])
{
- builtinConfig = config;
+ builtinConfig = config;
}
void
-xf86parseError (const char *format,...)
+xf86parseError(const char *format, ...)
{
- va_list ap;
- const char *filename = numFiles ? configFiles[curFileIndex].path
- : "<builtin configuration>";
+ va_list ap;
+ const char *filename = numFiles ? configFiles[curFileIndex].path
+ : "<builtin configuration>";
- ErrorF ("Parse error on line %d of section %s in file %s\n\t",
- configLineNo, configSection, filename);
- va_start (ap, format);
- VErrorF (format, ap);
- va_end (ap);
+ ErrorF("Parse error on line %d of section %s in file %s\n\t",
+ configLineNo, configSection, filename);
+ va_start(ap, format);
+ VErrorF(format, ap);
+ va_end(ap);
- ErrorF ("\n");
+ ErrorF("\n");
}
void
-xf86validationError (const char *format,...)
+xf86validationError(const char *format, ...)
{
- va_list ap;
- const char *filename = numFiles ? configFiles[curFileIndex].path
- : "<builtin configuration>";
+ va_list ap;
+ const char *filename = numFiles ? configFiles[curFileIndex].path
+ : "<builtin configuration>";
- ErrorF ("Data incomplete in file %s\n\t", filename);
- va_start (ap, format);
- VErrorF (format, ap);
- va_end (ap);
+ ErrorF("Data incomplete in file %s\n\t", filename);
+ va_start(ap, format);
+ VErrorF(format, ap);
+ va_end(ap);
- ErrorF ("\n");
+ ErrorF("\n");
}
void
-xf86setSection (const char *section)
+xf86setSection(const char *section)
{
- free(configSection);
- configSection = strdup(section);
+ free(configSection);
+ configSection = strdup(section);
}
/*
@@ -1032,145 +1025,143 @@ xf86setSection (const char *section)
* Lookup a string if it is actually a token in disguise.
*/
int
-xf86getStringToken (xf86ConfigSymTabRec * tab)
+xf86getStringToken(xf86ConfigSymTabRec * tab)
{
- return StringToToken (val.str, tab);
+ return StringToToken(val.str, tab);
}
static int
-StringToToken (const char *str, xf86ConfigSymTabRec * tab)
+StringToToken(const char *str, xf86ConfigSymTabRec * tab)
{
- int i;
-
- for (i = 0; tab[i].token != -1; i++)
- {
- if (!xf86nameCompare (tab[i].name, str))
- return tab[i].token;
- }
- return ERROR_TOKEN;
-}
+ int i;
+ for (i = 0; tab[i].token != -1; i++) {
+ if (!xf86nameCompare(tab[i].name, str))
+ return tab[i].token;
+ }
+ return ERROR_TOKEN;
+}
/*
* Compare two names. The characters '_', ' ', and '\t' are ignored
* in the comparison.
*/
int
-xf86nameCompare (const char *s1, const char *s2)
+xf86nameCompare(const char *s1, const char *s2)
{
- char c1, c2;
-
- if (!s1 || *s1 == 0) {
- if (!s2 || *s2 == 0)
- return 0;
- else
- return 1;
- }
-
- while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
- s1++;
- while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
- s2++;
- c1 = (isupper (*s1) ? tolower (*s1) : *s1);
- c2 = (isupper (*s2) ? tolower (*s2) : *s2);
- while (c1 == c2)
- {
- if (c1 == '\0')
- return 0;
- s1++;
- s2++;
- while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
- s1++;
- while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
- s2++;
- c1 = (isupper (*s1) ? tolower (*s1) : *s1);
- c2 = (isupper (*s2) ? tolower (*s2) : *s2);
- }
- return c1 - c2;
+ char c1, c2;
+
+ if (!s1 || *s1 == 0) {
+ if (!s2 || *s2 == 0)
+ return 0;
+ else
+ return 1;
+ }
+
+ while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
+ s1++;
+ while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
+ s2++;
+ c1 = (isupper(*s1) ? tolower(*s1) : *s1);
+ c2 = (isupper(*s2) ? tolower(*s2) : *s2);
+ while (c1 == c2) {
+ if (c1 == '\0')
+ return 0;
+ s1++;
+ s2++;
+ while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
+ s1++;
+ while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
+ s2++;
+ c1 = (isupper(*s1) ? tolower(*s1) : *s1);
+ c2 = (isupper(*s2) ? tolower(*s2) : *s2);
+ }
+ return c1 - c2;
}
char *
xf86addComment(char *cur, char *add)
{
- char *str;
- int len, curlen, iscomment, hasnewline = 0, insnewline, endnewline;
-
- if (add == NULL || add[0] == '\0')
- return cur;
-
- if (cur) {
- curlen = strlen(cur);
- if (curlen)
- hasnewline = cur[curlen - 1] == '\n';
- eol_seen = 0;
- }
- else
- curlen = 0;
-
- str = add;
- iscomment = 0;
- while (*str) {
- if (*str != ' ' && *str != '\t')
- break;
- ++str;
- }
- iscomment = (*str == '#');
-
- len = strlen(add);
- endnewline = add[len - 1] == '\n';
-
- insnewline = eol_seen || (curlen && !hasnewline);
- if (insnewline)
- len++;
- if (!iscomment)
- len++;
- if (!endnewline)
- len++;
-
- /* Allocate + 1 char for '\0' terminator. */
- str = realloc(cur, curlen + len + 1);
- if (!str)
- return cur;
-
- cur = str;
-
- if (insnewline)
- cur[curlen++] = '\n';
- if (!iscomment)
- cur[curlen++] = '#';
- strcpy(cur + curlen, add);
- if (!endnewline)
- strcat(cur, "\n");
-
- return cur;
+ char *str;
+ int len, curlen, iscomment, hasnewline = 0, insnewline, endnewline;
+
+ if (add == NULL || add[0] == '\0')
+ return cur;
+
+ if (cur) {
+ curlen = strlen(cur);
+ if (curlen)
+ hasnewline = cur[curlen - 1] == '\n';
+ eol_seen = 0;
+ }
+ else
+ curlen = 0;
+
+ str = add;
+ iscomment = 0;
+ while (*str) {
+ if (*str != ' ' && *str != '\t')
+ break;
+ ++str;
+ }
+ iscomment = (*str == '#');
+
+ len = strlen(add);
+ endnewline = add[len - 1] == '\n';
+
+ insnewline = eol_seen || (curlen && !hasnewline);
+ if (insnewline)
+ len++;
+ if (!iscomment)
+ len++;
+ if (!endnewline)
+ len++;
+
+ /* Allocate + 1 char for '\0' terminator. */
+ str = realloc(cur, curlen + len + 1);
+ if (!str)
+ return cur;
+
+ cur = str;
+
+ if (insnewline)
+ cur[curlen++] = '\n';
+ if (!iscomment)
+ cur[curlen++] = '#';
+ strcpy(cur + curlen, add);
+ if (!endnewline)
+ strcat(cur, "\n");
+
+ return cur;
}
Bool
xf86getBoolValue(Bool *val, const char *str)
{
- if (!val || !str)
- return FALSE;
- if (*str == '\0') {
- *val = TRUE;
- } else {
- if (xf86nameCompare(str, "1") == 0)
- *val = TRUE;
- else if (xf86nameCompare(str, "on") == 0)
- *val = TRUE;
- else if (xf86nameCompare(str, "true") == 0)
- *val = TRUE;
- else if (xf86nameCompare(str, "yes") == 0)
- *val = TRUE;
- else if (xf86nameCompare(str, "0") == 0)
- *val = FALSE;
- else if (xf86nameCompare(str, "off") == 0)
- *val = FALSE;
- else if (xf86nameCompare(str, "false") == 0)
- *val = FALSE;
- else if (xf86nameCompare(str, "no") == 0)
- *val = FALSE;
- else
- return FALSE;
- }
- return TRUE;
+ if (!val || !str)
+ return FALSE;
+ if (*str == '\0') {
+ *val = TRUE;
+ }
+ else {
+ if (xf86nameCompare(str, "1") == 0)
+ *val = TRUE;
+ else if (xf86nameCompare(str, "on") == 0)
+ *val = TRUE;
+ else if (xf86nameCompare(str, "true") == 0)
+ *val = TRUE;
+ else if (xf86nameCompare(str, "yes") == 0)
+ *val = TRUE;
+ else if (xf86nameCompare(str, "0") == 0)
+ *val = FALSE;
+ else if (xf86nameCompare(str, "off") == 0)
+ *val = FALSE;
+ else if (xf86nameCompare(str, "false") == 0)
+ *val = FALSE;
+ else if (xf86nameCompare(str, "no") == 0)
+ *val = FALSE;
+ else
+ return FALSE;
+ }
+ return TRUE;
}
diff --git a/xorg-server/hw/xfree86/parser/write.c b/xorg-server/hw/xfree86/parser/write.c
index fe51ee7f5..c001c3d51 100644
--- a/xorg-server/hw/xfree86/parser/write.c
+++ b/xorg-server/hw/xfree86/parser/write.c
@@ -1,216 +1,205 @@
-/*
- * Copyright (c) 1997 Metro Link Incorporated
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- *
- */
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-/* View/edit this file with tab stops set to 4 */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "Configint.h"
-
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <signal.h>
-#include <errno.h>
-
-#if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED)
-#define HAS_SAVED_IDS_AND_SETEUID
-#endif
-#if defined(WIN32)
-#define HAS_NO_UIDS
-#endif
-
-#ifdef HAS_NO_UIDS
-#define doWriteConfigFile xf86writeConfigFile
-#define Local /**/
-#else
-#define Local static
-#endif
-
-Local int
-doWriteConfigFile (const char *filename, XF86ConfigPtr cptr)
-{
- FILE *cf;
-
- if ((cf = fopen (filename, "w")) == NULL)
- {
- return 0;
- }
-
- if (cptr->conf_comment)
- fprintf (cf, "%s\n", cptr->conf_comment);
-
- xf86printLayoutSection (cf, cptr->conf_layout_lst);
-
- if (cptr->conf_files != NULL)
- {
- fprintf (cf, "Section \"Files\"\n");
- xf86printFileSection (cf, cptr->conf_files);
- fprintf (cf, "EndSection\n\n");
- }
-
- if (cptr->conf_modules != NULL)
- {
- fprintf (cf, "Section \"Module\"\n");
- xf86printModuleSection (cf, cptr->conf_modules);
- fprintf (cf, "EndSection\n\n");
- }
-
- xf86printVendorSection (cf, cptr->conf_vendor_lst);
-
- xf86printServerFlagsSection (cf, cptr->conf_flags);
-
- xf86printInputSection (cf, cptr->conf_input_lst);
-
- xf86printInputClassSection (cf, cptr->conf_inputclass_lst);
-
- xf86printVideoAdaptorSection (cf, cptr->conf_videoadaptor_lst);
-
- xf86printModesSection (cf, cptr->conf_modes_lst);
-
- xf86printMonitorSection (cf, cptr->conf_monitor_lst);
-
- xf86printDeviceSection (cf, cptr->conf_device_lst);
-
- xf86printScreenSection (cf, cptr->conf_screen_lst);
-
- xf86printDRISection (cf, cptr->conf_dri);
-
- xf86printExtensionsSection (cf, cptr->conf_extensions);
-
- fclose(cf);
- return 1;
-}
-
-#ifndef HAS_NO_UIDS
-
-int
-xf86writeConfigFile (const char *filename, XF86ConfigPtr cptr)
-{
- int ret;
-
-#if !defined(HAS_SAVED_IDS_AND_SETEUID)
- int pid, p;
- int status;
- void (*csig)(int);
-#else
- int ruid, euid;
-#endif
-
- if (getuid() != geteuid())
- {
-
-#if !defined(HAS_SAVED_IDS_AND_SETEUID)
- /* Need to fork to change ruid without loosing euid */
- csig = signal(SIGCHLD, SIG_DFL);
- switch ((pid = fork()))
- {
- case -1:
- ErrorF("xf86writeConfigFile(): fork failed (%s)\n",
- strerror(errno));
- return 0;
- case 0: /* child */
- if (setuid(getuid()) == -1)
- FatalError("xf86writeConfigFile(): "
- "setuid failed(%s)\n",
- strerror(errno));
- ret = doWriteConfigFile(filename, cptr);
- exit(ret);
- break;
- default: /* parent */
- do
- {
- p = waitpid(pid, &status, 0);
- } while (p == -1 && errno == EINTR);
- }
- signal(SIGCHLD, csig);
- if (p != -1 && WIFEXITED(status) && WEXITSTATUS(status) == 0)
- return 1; /* success */
- else
- return 0;
-
-#else /* HAS_SAVED_IDS_AND_SETEUID */
-
- ruid = getuid();
- euid = geteuid();
-
- if (seteuid(ruid) == -1)
- {
- ErrorF("xf86writeConfigFile(): seteuid(%d) failed (%s)\n",
- ruid, strerror(errno));
- return 0;
- }
- ret = doWriteConfigFile(filename, cptr);
-
- if (seteuid(euid) == -1)
- {
- ErrorF("xf86writeConfigFile(): seteuid(%d) failed (%s)\n",
- euid, strerror(errno));
- }
- return ret;
-
-#endif /* HAS_SAVED_IDS_AND_SETEUID */
-
- }
- else
- {
- return doWriteConfigFile(filename, cptr);
- }
-}
-
-#endif /* !HAS_NO_UIDS */
+/*
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <signal.h>
+#include <errno.h>
+
+#if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED)
+#define HAS_SAVED_IDS_AND_SETEUID
+#endif
+#if defined(WIN32)
+#define HAS_NO_UIDS
+#endif
+
+#ifdef HAS_NO_UIDS
+#define doWriteConfigFile xf86writeConfigFile
+#define Local /**/
+#else
+#define Local static
+#endif
+
+Local int
+doWriteConfigFile(const char *filename, XF86ConfigPtr cptr)
+{
+ FILE *cf;
+
+ if ((cf = fopen(filename, "w")) == NULL) {
+ return 0;
+ }
+
+ if (cptr->conf_comment)
+ fprintf(cf, "%s\n", cptr->conf_comment);
+
+ xf86printLayoutSection(cf, cptr->conf_layout_lst);
+
+ if (cptr->conf_files != NULL) {
+ fprintf(cf, "Section \"Files\"\n");
+ xf86printFileSection(cf, cptr->conf_files);
+ fprintf(cf, "EndSection\n\n");
+ }
+
+ if (cptr->conf_modules != NULL) {
+ fprintf(cf, "Section \"Module\"\n");
+ xf86printModuleSection(cf, cptr->conf_modules);
+ fprintf(cf, "EndSection\n\n");
+ }
+
+ xf86printVendorSection(cf, cptr->conf_vendor_lst);
+
+ xf86printServerFlagsSection(cf, cptr->conf_flags);
+
+ xf86printInputSection(cf, cptr->conf_input_lst);
+
+ xf86printInputClassSection(cf, cptr->conf_inputclass_lst);
+
+ xf86printVideoAdaptorSection(cf, cptr->conf_videoadaptor_lst);
+
+ xf86printModesSection(cf, cptr->conf_modes_lst);
+
+ xf86printMonitorSection(cf, cptr->conf_monitor_lst);
+
+ xf86printDeviceSection(cf, cptr->conf_device_lst);
+
+ xf86printScreenSection(cf, cptr->conf_screen_lst);
+
+ xf86printDRISection(cf, cptr->conf_dri);
+
+ xf86printExtensionsSection(cf, cptr->conf_extensions);
+
+ fclose(cf);
+ return 1;
+}
+
+#ifndef HAS_NO_UIDS
+
+int
+xf86writeConfigFile(const char *filename, XF86ConfigPtr cptr)
+{
+ int ret;
+
+#if !defined(HAS_SAVED_IDS_AND_SETEUID)
+ int pid, p;
+ int status;
+ void (*csig) (int);
+#else
+ int ruid, euid;
+#endif
+
+ if (getuid() != geteuid()) {
+
+#if !defined(HAS_SAVED_IDS_AND_SETEUID)
+ /* Need to fork to change ruid without loosing euid */
+ csig = signal(SIGCHLD, SIG_DFL);
+ switch ((pid = fork())) {
+ case -1:
+ ErrorF("xf86writeConfigFile(): fork failed (%s)\n",
+ strerror(errno));
+ return 0;
+ case 0: /* child */
+ if (setuid(getuid()) == -1)
+ FatalError("xf86writeConfigFile(): "
+ "setuid failed(%s)\n", strerror(errno));
+ ret = doWriteConfigFile(filename, cptr);
+ exit(ret);
+ break;
+ default: /* parent */
+ do {
+ p = waitpid(pid, &status, 0);
+ } while (p == -1 && errno == EINTR);
+ }
+ signal(SIGCHLD, csig);
+ if (p != -1 && WIFEXITED(status) && WEXITSTATUS(status) == 0)
+ return 1; /* success */
+ else
+ return 0;
+
+#else /* HAS_SAVED_IDS_AND_SETEUID */
+
+ ruid = getuid();
+ euid = geteuid();
+
+ if (seteuid(ruid) == -1) {
+ ErrorF("xf86writeConfigFile(): seteuid(%d) failed (%s)\n",
+ ruid, strerror(errno));
+ return 0;
+ }
+ ret = doWriteConfigFile(filename, cptr);
+
+ if (seteuid(euid) == -1) {
+ ErrorF("xf86writeConfigFile(): seteuid(%d) failed (%s)\n",
+ euid, strerror(errno));
+ }
+ return ret;
+
+#endif /* HAS_SAVED_IDS_AND_SETEUID */
+
+ }
+ else {
+ return doWriteConfigFile(filename, cptr);
+ }
+}
+
+#endif /* !HAS_NO_UIDS */
diff --git a/xorg-server/hw/xfree86/parser/xf86Optrec.h b/xorg-server/hw/xfree86/parser/xf86Optrec.h
index b8e9d6192..ea0cb1329 100644
--- a/xorg-server/hw/xfree86/parser/xf86Optrec.h
+++ b/xorg-server/hw/xfree86/parser/xf86Optrec.h
@@ -52,7 +52,6 @@
* authorization from the copyright holder(s) and author(s).
*/
-
/*
* This file contains the Option Record that is passed between the Parser,
* and Module setup procs.
@@ -69,21 +68,26 @@
#include <X11/Xfuncproto.h>
-extern _X_EXPORT XF86OptionPtr xf86addNewOption(XF86OptionPtr head, char *name, char *val);
+extern _X_EXPORT XF86OptionPtr xf86addNewOption(XF86OptionPtr head, char *name,
+ char *val);
extern _X_EXPORT XF86OptionPtr xf86optionListDup(XF86OptionPtr opt);
extern _X_EXPORT void xf86optionListFree(XF86OptionPtr opt);
extern _X_EXPORT char *xf86optionName(XF86OptionPtr opt);
extern _X_EXPORT char *xf86optionValue(XF86OptionPtr opt);
extern _X_EXPORT XF86OptionPtr xf86newOption(char *name, char *value);
extern _X_EXPORT XF86OptionPtr xf86nextOption(XF86OptionPtr list);
-extern _X_EXPORT XF86OptionPtr xf86findOption(XF86OptionPtr list, const char *name);
-extern _X_EXPORT const char *xf86findOptionValue(XF86OptionPtr list, const char *name);
-extern _X_EXPORT XF86OptionPtr xf86optionListCreate(const char **options, int count, int used);
-extern _X_EXPORT XF86OptionPtr xf86optionListMerge(XF86OptionPtr head, XF86OptionPtr tail);
-extern _X_EXPORT int xf86nameCompare (const char *s1, const char *s2);
+extern _X_EXPORT XF86OptionPtr xf86findOption(XF86OptionPtr list,
+ const char *name);
+extern _X_EXPORT const char *xf86findOptionValue(XF86OptionPtr list,
+ const char *name);
+extern _X_EXPORT XF86OptionPtr xf86optionListCreate(const char **options,
+ int count, int used);
+extern _X_EXPORT XF86OptionPtr xf86optionListMerge(XF86OptionPtr head,
+ XF86OptionPtr tail);
+extern _X_EXPORT int xf86nameCompare(const char *s1, const char *s2);
extern _X_EXPORT char *xf86uLongToString(unsigned long i);
extern _X_EXPORT XF86OptionPtr xf86parseOption(XF86OptionPtr head);
-extern _X_EXPORT void xf86printOptionList(FILE *fp, XF86OptionPtr list, int tabs);
-
+extern _X_EXPORT void xf86printOptionList(FILE * fp, XF86OptionPtr list,
+ int tabs);
-#endif /* _xf86Optrec_h_ */
+#endif /* _xf86Optrec_h_ */
diff --git a/xorg-server/hw/xfree86/parser/xf86Parser.h b/xorg-server/hw/xfree86/parser/xf86Parser.h
index beac35404..e7210e811 100644
--- a/xorg-server/hw/xfree86/parser/xf86Parser.h
+++ b/xorg-server/hw/xfree86/parser/xf86Parser.h
@@ -52,7 +52,6 @@
* authorization from the copyright holder(s) and author(s).
*/
-
/*
* This file contains the external interfaces for the XFree86 configuration
* file parser.
@@ -70,39 +69,33 @@
#define HAVE_PARSER_DECLS
-typedef struct
-{
- char *file_logfile;
- char *file_modulepath;
- char *file_fontpath;
- char *file_comment;
- char *file_xkbdir;
-}
-XF86ConfFilesRec, *XF86ConfFilesPtr;
+typedef struct {
+ char *file_logfile;
+ char *file_modulepath;
+ char *file_fontpath;
+ char *file_comment;
+ char *file_xkbdir;
+} XF86ConfFilesRec, *XF86ConfFilesPtr;
/* Values for load_type */
#define XF86_LOAD_MODULE 0
#define XF86_LOAD_DRIVER 1
#define XF86_DISABLE_MODULE 2
-typedef struct
-{
- GenericListRec list;
- int load_type;
- char *load_name;
- XF86OptionPtr load_opt;
- char *load_comment;
- int ignore;
-}
-XF86LoadRec, *XF86LoadPtr;
-
-typedef struct
-{
- XF86LoadPtr mod_load_lst;
+typedef struct {
+ GenericListRec list;
+ int load_type;
+ char *load_name;
+ XF86OptionPtr load_opt;
+ char *load_comment;
+ int ignore;
+} XF86LoadRec, *XF86LoadPtr;
+
+typedef struct {
+ XF86LoadPtr mod_load_lst;
XF86LoadPtr mod_disable_lst;
- char *mod_comment;
-}
-XF86ConfModuleRec, *XF86ConfModulePtr;
+ char *mod_comment;
+} XF86ConfModuleRec, *XF86ConfModulePtr;
#define CONF_IMPLICIT_KEYBOARD "Implicit Core Keyboard"
@@ -117,258 +110,220 @@ XF86ConfModuleRec, *XF86ConfModulePtr;
#define XF86CONF_CSYNC 0x0040
#define XF86CONF_PCSYNC 0x0080
#define XF86CONF_NCSYNC 0x0100
-#define XF86CONF_HSKEW 0x0200 /* hskew provided */
+#define XF86CONF_HSKEW 0x0200 /* hskew provided */
#define XF86CONF_BCAST 0x0400
#define XF86CONF_VSCAN 0x1000
-typedef struct
-{
- GenericListRec list;
- char *ml_identifier;
- int ml_clock;
- int ml_hdisplay;
- int ml_hsyncstart;
- int ml_hsyncend;
- int ml_htotal;
- int ml_vdisplay;
- int ml_vsyncstart;
- int ml_vsyncend;
- int ml_vtotal;
- int ml_vscan;
- int ml_flags;
- int ml_hskew;
- char *ml_comment;
-}
-XF86ConfModeLineRec, *XF86ConfModeLinePtr;
-
-typedef struct
-{
- GenericListRec list;
- char *vp_identifier;
- XF86OptionPtr vp_option_lst;
- char *vp_comment;
-}
-XF86ConfVideoPortRec, *XF86ConfVideoPortPtr;
-
-typedef struct
-{
- GenericListRec list;
- char *va_identifier;
- char *va_vendor;
- char *va_board;
- char *va_busid;
- char *va_driver;
- XF86OptionPtr va_option_lst;
- XF86ConfVideoPortPtr va_port_lst;
- char *va_fwdref;
- char *va_comment;
-}
-XF86ConfVideoAdaptorRec, *XF86ConfVideoAdaptorPtr;
+typedef struct {
+ GenericListRec list;
+ char *ml_identifier;
+ int ml_clock;
+ int ml_hdisplay;
+ int ml_hsyncstart;
+ int ml_hsyncend;
+ int ml_htotal;
+ int ml_vdisplay;
+ int ml_vsyncstart;
+ int ml_vsyncend;
+ int ml_vtotal;
+ int ml_vscan;
+ int ml_flags;
+ int ml_hskew;
+ char *ml_comment;
+} XF86ConfModeLineRec, *XF86ConfModeLinePtr;
+
+typedef struct {
+ GenericListRec list;
+ char *vp_identifier;
+ XF86OptionPtr vp_option_lst;
+ char *vp_comment;
+} XF86ConfVideoPortRec, *XF86ConfVideoPortPtr;
+
+typedef struct {
+ GenericListRec list;
+ char *va_identifier;
+ char *va_vendor;
+ char *va_board;
+ char *va_busid;
+ char *va_driver;
+ XF86OptionPtr va_option_lst;
+ XF86ConfVideoPortPtr va_port_lst;
+ char *va_fwdref;
+ char *va_comment;
+} XF86ConfVideoAdaptorRec, *XF86ConfVideoAdaptorPtr;
#define CONF_MAX_HSYNC 8
#define CONF_MAX_VREFRESH 8
-typedef struct
-{
- float hi, lo;
-}
-parser_range;
-
-typedef struct
-{
- int red, green, blue;
-}
-parser_rgb;
-
-typedef struct
-{
- GenericListRec list;
- char *modes_identifier;
- XF86ConfModeLinePtr mon_modeline_lst;
- char *modes_comment;
-}
-XF86ConfModesRec, *XF86ConfModesPtr;
-
-typedef struct
-{
- GenericListRec list;
- char *ml_modes_str;
- XF86ConfModesPtr ml_modes;
-}
-XF86ConfModesLinkRec, *XF86ConfModesLinkPtr;
-
-typedef struct
-{
- GenericListRec list;
- char *mon_identifier;
- char *mon_vendor;
- char *mon_modelname;
- int mon_width; /* in mm */
- int mon_height; /* in mm */
- XF86ConfModeLinePtr mon_modeline_lst;
- int mon_n_hsync;
- parser_range mon_hsync[CONF_MAX_HSYNC];
- int mon_n_vrefresh;
- parser_range mon_vrefresh[CONF_MAX_VREFRESH];
- float mon_gamma_red;
- float mon_gamma_green;
- float mon_gamma_blue;
- XF86OptionPtr mon_option_lst;
- XF86ConfModesLinkPtr mon_modes_sect_lst;
- char *mon_comment;
-}
-XF86ConfMonitorRec, *XF86ConfMonitorPtr;
+typedef struct {
+ float hi, lo;
+} parser_range;
+
+typedef struct {
+ int red, green, blue;
+} parser_rgb;
+
+typedef struct {
+ GenericListRec list;
+ char *modes_identifier;
+ XF86ConfModeLinePtr mon_modeline_lst;
+ char *modes_comment;
+} XF86ConfModesRec, *XF86ConfModesPtr;
+
+typedef struct {
+ GenericListRec list;
+ char *ml_modes_str;
+ XF86ConfModesPtr ml_modes;
+} XF86ConfModesLinkRec, *XF86ConfModesLinkPtr;
+
+typedef struct {
+ GenericListRec list;
+ char *mon_identifier;
+ char *mon_vendor;
+ char *mon_modelname;
+ int mon_width; /* in mm */
+ int mon_height; /* in mm */
+ XF86ConfModeLinePtr mon_modeline_lst;
+ int mon_n_hsync;
+ parser_range mon_hsync[CONF_MAX_HSYNC];
+ int mon_n_vrefresh;
+ parser_range mon_vrefresh[CONF_MAX_VREFRESH];
+ float mon_gamma_red;
+ float mon_gamma_green;
+ float mon_gamma_blue;
+ XF86OptionPtr mon_option_lst;
+ XF86ConfModesLinkPtr mon_modes_sect_lst;
+ char *mon_comment;
+} XF86ConfMonitorRec, *XF86ConfMonitorPtr;
#define CONF_MAXDACSPEEDS 4
#define CONF_MAXCLOCKS 128
-typedef struct
-{
- GenericListRec list;
- char *dev_identifier;
- char *dev_vendor;
- char *dev_board;
- char *dev_chipset;
- char *dev_busid;
- char *dev_card;
- char *dev_driver;
- char *dev_ramdac;
- int dev_dacSpeeds[CONF_MAXDACSPEEDS];
- int dev_videoram;
- int dev_textclockfreq;
- unsigned long dev_bios_base;
- unsigned long dev_mem_base;
- unsigned long dev_io_base;
- char *dev_clockchip;
- int dev_clocks;
- int dev_clock[CONF_MAXCLOCKS];
- int dev_chipid;
- int dev_chiprev;
- int dev_irq;
- int dev_screen;
- XF86OptionPtr dev_option_lst;
- char *dev_comment;
-}
-XF86ConfDeviceRec, *XF86ConfDevicePtr;
-
-typedef struct
-{
- GenericListRec list;
- char *mode_name;
-}
-XF86ModeRec, *XF86ModePtr;
-
-typedef struct
-{
- GenericListRec list;
- int disp_frameX0;
- int disp_frameY0;
- int disp_virtualX;
- int disp_virtualY;
- int disp_depth;
- int disp_bpp;
- char *disp_visual;
- parser_rgb disp_weight;
- parser_rgb disp_black;
- parser_rgb disp_white;
- XF86ModePtr disp_mode_lst;
- XF86OptionPtr disp_option_lst;
- char *disp_comment;
-}
-XF86ConfDisplayRec, *XF86ConfDisplayPtr;
-
-typedef struct
-{
- XF86OptionPtr flg_option_lst;
- char *flg_comment;
-}
-XF86ConfFlagsRec, *XF86ConfFlagsPtr;
-
-typedef struct
-{
- GenericListRec list;
- char *al_adaptor_str;
- XF86ConfVideoAdaptorPtr al_adaptor;
-}
-XF86ConfAdaptorLinkRec, *XF86ConfAdaptorLinkPtr;
-
-typedef struct
-{
- GenericListRec list;
- char *scrn_identifier;
- char *scrn_obso_driver;
- int scrn_defaultdepth;
- int scrn_defaultbpp;
- int scrn_defaultfbbpp;
- char *scrn_monitor_str;
- XF86ConfMonitorPtr scrn_monitor;
- char *scrn_device_str;
- XF86ConfDevicePtr scrn_device;
- XF86ConfAdaptorLinkPtr scrn_adaptor_lst;
- XF86ConfDisplayPtr scrn_display_lst;
- XF86OptionPtr scrn_option_lst;
- char *scrn_comment;
- int scrn_virtualX, scrn_virtualY;
-}
-XF86ConfScreenRec, *XF86ConfScreenPtr;
-
-typedef struct
-{
- GenericListRec list;
- char *inp_identifier;
- char *inp_driver;
- XF86OptionPtr inp_option_lst;
- char *inp_comment;
-}
-XF86ConfInputRec, *XF86ConfInputPtr;
-
-typedef struct
-{
- GenericListRec list;
- XF86ConfInputPtr iref_inputdev;
- char *iref_inputdev_str;
- XF86OptionPtr iref_option_lst;
-}
-XF86ConfInputrefRec, *XF86ConfInputrefPtr;
-
-typedef struct
-{
- Bool set;
- Bool val;
-}
-xf86TriState;
-
-typedef struct
-{
- struct xorg_list entry;
- char **values;
-}
-xf86MatchGroup;
-
-typedef struct
-{
- GenericListRec list;
- char *identifier;
- char *driver;
- struct xorg_list match_product;
- struct xorg_list match_vendor;
- struct xorg_list match_device;
- struct xorg_list match_os;
- struct xorg_list match_pnpid;
- struct xorg_list match_usbid;
- struct xorg_list match_driver;
- struct xorg_list match_tag;
- struct xorg_list match_layout;
- xf86TriState is_keyboard;
- xf86TriState is_pointer;
- xf86TriState is_joystick;
- xf86TriState is_tablet;
- xf86TriState is_touchpad;
- xf86TriState is_touchscreen;
- XF86OptionPtr option_lst;
- char *comment;
-}
-XF86ConfInputClassRec, *XF86ConfInputClassPtr;
+typedef struct {
+ GenericListRec list;
+ char *dev_identifier;
+ char *dev_vendor;
+ char *dev_board;
+ char *dev_chipset;
+ char *dev_busid;
+ char *dev_card;
+ char *dev_driver;
+ char *dev_ramdac;
+ int dev_dacSpeeds[CONF_MAXDACSPEEDS];
+ int dev_videoram;
+ int dev_textclockfreq;
+ unsigned long dev_bios_base;
+ unsigned long dev_mem_base;
+ unsigned long dev_io_base;
+ char *dev_clockchip;
+ int dev_clocks;
+ int dev_clock[CONF_MAXCLOCKS];
+ int dev_chipid;
+ int dev_chiprev;
+ int dev_irq;
+ int dev_screen;
+ XF86OptionPtr dev_option_lst;
+ char *dev_comment;
+} XF86ConfDeviceRec, *XF86ConfDevicePtr;
+
+typedef struct {
+ GenericListRec list;
+ char *mode_name;
+} XF86ModeRec, *XF86ModePtr;
+
+typedef struct {
+ GenericListRec list;
+ int disp_frameX0;
+ int disp_frameY0;
+ int disp_virtualX;
+ int disp_virtualY;
+ int disp_depth;
+ int disp_bpp;
+ char *disp_visual;
+ parser_rgb disp_weight;
+ parser_rgb disp_black;
+ parser_rgb disp_white;
+ XF86ModePtr disp_mode_lst;
+ XF86OptionPtr disp_option_lst;
+ char *disp_comment;
+} XF86ConfDisplayRec, *XF86ConfDisplayPtr;
+
+typedef struct {
+ XF86OptionPtr flg_option_lst;
+ char *flg_comment;
+} XF86ConfFlagsRec, *XF86ConfFlagsPtr;
+
+typedef struct {
+ GenericListRec list;
+ char *al_adaptor_str;
+ XF86ConfVideoAdaptorPtr al_adaptor;
+} XF86ConfAdaptorLinkRec, *XF86ConfAdaptorLinkPtr;
+
+typedef struct {
+ GenericListRec list;
+ char *scrn_identifier;
+ char *scrn_obso_driver;
+ int scrn_defaultdepth;
+ int scrn_defaultbpp;
+ int scrn_defaultfbbpp;
+ char *scrn_monitor_str;
+ XF86ConfMonitorPtr scrn_monitor;
+ char *scrn_device_str;
+ XF86ConfDevicePtr scrn_device;
+ XF86ConfAdaptorLinkPtr scrn_adaptor_lst;
+ XF86ConfDisplayPtr scrn_display_lst;
+ XF86OptionPtr scrn_option_lst;
+ char *scrn_comment;
+ int scrn_virtualX, scrn_virtualY;
+} XF86ConfScreenRec, *XF86ConfScreenPtr;
+
+typedef struct {
+ GenericListRec list;
+ char *inp_identifier;
+ char *inp_driver;
+ XF86OptionPtr inp_option_lst;
+ char *inp_comment;
+} XF86ConfInputRec, *XF86ConfInputPtr;
+
+typedef struct {
+ GenericListRec list;
+ XF86ConfInputPtr iref_inputdev;
+ char *iref_inputdev_str;
+ XF86OptionPtr iref_option_lst;
+} XF86ConfInputrefRec, *XF86ConfInputrefPtr;
+
+typedef struct {
+ Bool set;
+ Bool val;
+} xf86TriState;
+
+typedef struct {
+ struct xorg_list entry;
+ char **values;
+} xf86MatchGroup;
+
+typedef struct {
+ GenericListRec list;
+ char *identifier;
+ char *driver;
+ struct xorg_list match_product;
+ struct xorg_list match_vendor;
+ struct xorg_list match_device;
+ struct xorg_list match_os;
+ struct xorg_list match_pnpid;
+ struct xorg_list match_usbid;
+ struct xorg_list match_driver;
+ struct xorg_list match_tag;
+ struct xorg_list match_layout;
+ xf86TriState is_keyboard;
+ xf86TriState is_pointer;
+ xf86TriState is_joystick;
+ xf86TriState is_tablet;
+ xf86TriState is_touchpad;
+ xf86TriState is_touchscreen;
+ XF86OptionPtr option_lst;
+ char *comment;
+} XF86ConfInputClassRec, *XF86ConfInputClassPtr;
/* Values for adj_where */
#define CONF_ADJ_OBSOLETE -1
@@ -379,141 +334,135 @@ XF86ConfInputClassRec, *XF86ConfInputClassPtr;
#define CONF_ADJ_BELOW 4
#define CONF_ADJ_RELATIVE 5
-typedef struct
-{
- GenericListRec list;
- int adj_scrnum;
- XF86ConfScreenPtr adj_screen;
- char *adj_screen_str;
- XF86ConfScreenPtr adj_top;
- char *adj_top_str;
- XF86ConfScreenPtr adj_bottom;
- char *adj_bottom_str;
- XF86ConfScreenPtr adj_left;
- char *adj_left_str;
- XF86ConfScreenPtr adj_right;
- char *adj_right_str;
- int adj_where;
- int adj_x;
- int adj_y;
- char *adj_refscreen;
-}
-XF86ConfAdjacencyRec, *XF86ConfAdjacencyPtr;
-
-typedef struct
-{
- GenericListRec list;
- char *inactive_device_str;
- XF86ConfDevicePtr inactive_device;
-}
-XF86ConfInactiveRec, *XF86ConfInactivePtr;
-
-typedef struct
-{
- GenericListRec list;
- char *lay_identifier;
- XF86ConfAdjacencyPtr lay_adjacency_lst;
- XF86ConfInactivePtr lay_inactive_lst;
- XF86ConfInputrefPtr lay_input_lst;
- XF86OptionPtr lay_option_lst;
- char *lay_comment;
-}
-XF86ConfLayoutRec, *XF86ConfLayoutPtr;
-
-typedef struct
-{
- GenericListRec list;
- char *vs_name;
- char *vs_identifier;
- XF86OptionPtr vs_option_lst;
- char *vs_comment;
-}
-XF86ConfVendSubRec, *XF86ConfVendSubPtr;
-
-typedef struct
-{
- GenericListRec list;
- char *vnd_identifier;
- XF86OptionPtr vnd_option_lst;
- XF86ConfVendSubPtr vnd_sub_lst;
- char *vnd_comment;
-}
-XF86ConfVendorRec, *XF86ConfVendorPtr;
-
-typedef struct
-{
- char *dri_group_name;
- int dri_group;
- int dri_mode;
- char *dri_comment;
-}
-XF86ConfDRIRec, *XF86ConfDRIPtr;
-
-typedef struct
-{
- XF86OptionPtr ext_option_lst;
- char *extensions_comment;
-}
-XF86ConfExtensionsRec, *XF86ConfExtensionsPtr;
-
-typedef struct
-{
- XF86ConfFilesPtr conf_files;
- XF86ConfModulePtr conf_modules;
- XF86ConfFlagsPtr conf_flags;
- XF86ConfVideoAdaptorPtr conf_videoadaptor_lst;
- XF86ConfModesPtr conf_modes_lst;
- XF86ConfMonitorPtr conf_monitor_lst;
- XF86ConfDevicePtr conf_device_lst;
- XF86ConfScreenPtr conf_screen_lst;
- XF86ConfInputPtr conf_input_lst;
- XF86ConfInputClassPtr conf_inputclass_lst;
- XF86ConfLayoutPtr conf_layout_lst;
- XF86ConfVendorPtr conf_vendor_lst;
- XF86ConfDRIPtr conf_dri;
- XF86ConfExtensionsPtr conf_extensions;
- char *conf_comment;
-}
-XF86ConfigRec, *XF86ConfigPtr;
-
-typedef struct
-{
- int token; /* id of the token */
- const char *name; /* pointer to the LOWERCASED name */
-}
-xf86ConfigSymTabRec, *xf86ConfigSymTabPtr;
+typedef struct {
+ GenericListRec list;
+ int adj_scrnum;
+ XF86ConfScreenPtr adj_screen;
+ char *adj_screen_str;
+ XF86ConfScreenPtr adj_top;
+ char *adj_top_str;
+ XF86ConfScreenPtr adj_bottom;
+ char *adj_bottom_str;
+ XF86ConfScreenPtr adj_left;
+ char *adj_left_str;
+ XF86ConfScreenPtr adj_right;
+ char *adj_right_str;
+ int adj_where;
+ int adj_x;
+ int adj_y;
+ char *adj_refscreen;
+} XF86ConfAdjacencyRec, *XF86ConfAdjacencyPtr;
+
+typedef struct {
+ GenericListRec list;
+ char *inactive_device_str;
+ XF86ConfDevicePtr inactive_device;
+} XF86ConfInactiveRec, *XF86ConfInactivePtr;
+
+typedef struct {
+ GenericListRec list;
+ char *lay_identifier;
+ XF86ConfAdjacencyPtr lay_adjacency_lst;
+ XF86ConfInactivePtr lay_inactive_lst;
+ XF86ConfInputrefPtr lay_input_lst;
+ XF86OptionPtr lay_option_lst;
+ char *lay_comment;
+} XF86ConfLayoutRec, *XF86ConfLayoutPtr;
+
+typedef struct {
+ GenericListRec list;
+ char *vs_name;
+ char *vs_identifier;
+ XF86OptionPtr vs_option_lst;
+ char *vs_comment;
+} XF86ConfVendSubRec, *XF86ConfVendSubPtr;
+
+typedef struct {
+ GenericListRec list;
+ char *vnd_identifier;
+ XF86OptionPtr vnd_option_lst;
+ XF86ConfVendSubPtr vnd_sub_lst;
+ char *vnd_comment;
+} XF86ConfVendorRec, *XF86ConfVendorPtr;
+
+typedef struct {
+ char *dri_group_name;
+ int dri_group;
+ int dri_mode;
+ char *dri_comment;
+} XF86ConfDRIRec, *XF86ConfDRIPtr;
+
+typedef struct {
+ XF86OptionPtr ext_option_lst;
+ char *extensions_comment;
+} XF86ConfExtensionsRec, *XF86ConfExtensionsPtr;
+
+typedef struct {
+ XF86ConfFilesPtr conf_files;
+ XF86ConfModulePtr conf_modules;
+ XF86ConfFlagsPtr conf_flags;
+ XF86ConfVideoAdaptorPtr conf_videoadaptor_lst;
+ XF86ConfModesPtr conf_modes_lst;
+ XF86ConfMonitorPtr conf_monitor_lst;
+ XF86ConfDevicePtr conf_device_lst;
+ XF86ConfScreenPtr conf_screen_lst;
+ XF86ConfInputPtr conf_input_lst;
+ XF86ConfInputClassPtr conf_inputclass_lst;
+ XF86ConfLayoutPtr conf_layout_lst;
+ XF86ConfVendorPtr conf_vendor_lst;
+ XF86ConfDRIPtr conf_dri;
+ XF86ConfExtensionsPtr conf_extensions;
+ char *conf_comment;
+} XF86ConfigRec, *XF86ConfigPtr;
+
+typedef struct {
+ int token; /* id of the token */
+ const char *name; /* pointer to the LOWERCASED name */
+} xf86ConfigSymTabRec, *xf86ConfigSymTabPtr;
/*
* prototypes for public functions
*/
extern void xf86initConfigFiles(void);
extern char *xf86openConfigFile(const char *path, const char *cmdline,
- const char *projroot);
+ const char *projroot);
extern char *xf86openConfigDirFiles(const char *path, const char *cmdline,
- const char *projroot);
+ const char *projroot);
extern void xf86setBuiltinConfig(const char *config[]);
extern XF86ConfigPtr xf86readConfigFile(void);
extern void xf86closeConfigFile(void);
extern void xf86freeConfig(XF86ConfigPtr p);
extern int xf86writeConfigFile(const char *, XF86ConfigPtr);
-extern _X_EXPORT XF86ConfDevicePtr xf86findDevice(const char *ident, XF86ConfDevicePtr p);
-extern _X_EXPORT XF86ConfLayoutPtr xf86findLayout(const char *name, XF86ConfLayoutPtr list);
-extern _X_EXPORT XF86ConfMonitorPtr xf86findMonitor(const char *ident, XF86ConfMonitorPtr p);
-extern _X_EXPORT XF86ConfModesPtr xf86findModes(const char *ident, XF86ConfModesPtr p);
-extern _X_EXPORT XF86ConfModeLinePtr xf86findModeLine(const char *ident, XF86ConfModeLinePtr p);
-extern _X_EXPORT XF86ConfScreenPtr xf86findScreen(const char *ident, XF86ConfScreenPtr p);
-extern _X_EXPORT XF86ConfInputPtr xf86findInput(const char *ident, XF86ConfInputPtr p);
-extern _X_EXPORT XF86ConfInputPtr xf86findInputByDriver(const char *driver, XF86ConfInputPtr p);
+extern _X_EXPORT XF86ConfDevicePtr xf86findDevice(const char *ident,
+ XF86ConfDevicePtr p);
+extern _X_EXPORT XF86ConfLayoutPtr xf86findLayout(const char *name,
+ XF86ConfLayoutPtr list);
+extern _X_EXPORT XF86ConfMonitorPtr xf86findMonitor(const char *ident,
+ XF86ConfMonitorPtr p);
+extern _X_EXPORT XF86ConfModesPtr xf86findModes(const char *ident,
+ XF86ConfModesPtr p);
+extern _X_EXPORT XF86ConfModeLinePtr xf86findModeLine(const char *ident,
+ XF86ConfModeLinePtr p);
+extern _X_EXPORT XF86ConfScreenPtr xf86findScreen(const char *ident,
+ XF86ConfScreenPtr p);
+extern _X_EXPORT XF86ConfInputPtr xf86findInput(const char *ident,
+ XF86ConfInputPtr p);
+extern _X_EXPORT XF86ConfInputPtr xf86findInputByDriver(const char *driver,
+ XF86ConfInputPtr p);
extern _X_EXPORT XF86ConfVideoAdaptorPtr xf86findVideoAdaptor(const char *ident,
- XF86ConfVideoAdaptorPtr p);
-extern int xf86layoutAddInputDevices(XF86ConfigPtr config, XF86ConfLayoutPtr layout);
+ XF86ConfVideoAdaptorPtr
+ p);
+extern int xf86layoutAddInputDevices(XF86ConfigPtr config,
+ XF86ConfLayoutPtr layout);
-extern _X_EXPORT GenericListPtr xf86addListItem(GenericListPtr head, GenericListPtr c_new);
-extern _X_EXPORT int xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2);
+extern _X_EXPORT GenericListPtr xf86addListItem(GenericListPtr head,
+ GenericListPtr c_new);
+extern _X_EXPORT int xf86itemNotSublist(GenericListPtr list_1,
+ GenericListPtr list_2);
extern _X_EXPORT int xf86pathIsAbsolute(const char *path);
extern _X_EXPORT int xf86pathIsSafe(const char *path);
extern _X_EXPORT char *xf86addComment(char *cur, char *add);
extern _X_EXPORT Bool xf86getBoolValue(Bool *val, const char *str);
-#endif /* _xf86Parser_h_ */
+#endif /* _xf86Parser_h_ */
diff --git a/xorg-server/hw/xfree86/ramdac/BT.c b/xorg-server/hw/xfree86/ramdac/BT.c
index 5aa27a1f8..533344513 100644
--- a/xorg-server/hw/xfree86/ramdac/BT.c
+++ b/xorg-server/hw/xfree86/ramdac/BT.c
@@ -37,36 +37,37 @@
void
BTramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
- RamDacRegRecPtr ramdacReg)
+ RamDacRegRecPtr ramdacReg)
{
- int i;
-
- /* Here we pass a short, so that we can evaluate a mask too */
- /* So that the mask is the high byte and the data the low byte */
- /* Just the command/status registers */
- for (i=0x06;i<0x0A;i++)
- (*ramdacPtr->WriteDAC)
- (pScrn, i, (ramdacReg->DacRegs[i] & 0xFF00) >> 8,
- ramdacReg->DacRegs[i]);
+ int i;
+
+ /* Here we pass a short, so that we can evaluate a mask too */
+ /* So that the mask is the high byte and the data the low byte */
+ /* Just the command/status registers */
+ for (i = 0x06; i < 0x0A; i++)
+ (*ramdacPtr->WriteDAC)
+ (pScrn, i, (ramdacReg->DacRegs[i] & 0xFF00) >> 8,
+ ramdacReg->DacRegs[i]);
}
void
-BTramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
- RamDacRegRecPtr ramdacReg)
+BTramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
+ RamDacRegRecPtr ramdacReg)
{
- int i;
-
- (*ramdacPtr->ReadAddress)(pScrn, 0); /* Start at index 0 */
- for (i=0;i<768;i++)
- ramdacReg->DAC[i] = (*ramdacPtr->ReadData)(pScrn);
-
- /* Just the command/status registers */
- for (i=0x06;i<0x0A;i++)
- ramdacReg->DacRegs[i] = (*ramdacPtr->ReadDAC)(pScrn, i);
+ int i;
+
+ (*ramdacPtr->ReadAddress) (pScrn, 0); /* Start at index 0 */
+ for (i = 0; i < 768; i++)
+ ramdacReg->DAC[i] = (*ramdacPtr->ReadData) (pScrn);
+
+ /* Just the command/status registers */
+ for (i = 0x06; i < 0x0A; i++)
+ ramdacReg->DacRegs[i] = (*ramdacPtr->ReadDAC) (pScrn, i);
}
RamDacHelperRecPtr
-BTramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs/*, RamDacRecPtr ramdacPtr*/)
+BTramdacProbe(ScrnInfoPtr pScrn,
+ RamDacSupportedInfoRecPtr ramdacs /*, RamDacRecPtr ramdacPtr */ )
{
RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
Bool RamDacIsSupported = FALSE;
@@ -75,65 +76,66 @@ BTramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs/*, RamDacRecP
int i, status, cmd0;
/* Save COMMAND Register 0 */
- cmd0 = (*ramdacPtr->ReadDAC)(pScrn, BT_COMMAND_REG_0);
+ cmd0 = (*ramdacPtr->ReadDAC) (pScrn, BT_COMMAND_REG_0);
/* Ensure were going to access the STATUS Register on next read */
- (*ramdacPtr->WriteDAC)(pScrn, BT_COMMAND_REG_0, 0x7F, 0x00);
+ (*ramdacPtr->WriteDAC) (pScrn, BT_COMMAND_REG_0, 0x7F, 0x00);
- status = (*ramdacPtr->ReadDAC)(pScrn, BT_STATUS_REG);
+ status = (*ramdacPtr->ReadDAC) (pScrn, BT_STATUS_REG);
switch (status) {
- case 0x40:
- BTramdac_ID = ATT20C504_RAMDAC;
- break;
- case 0xD0:
- BTramdac_ID = ATT20C505_RAMDAC;
- break;
- default:
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "Unknown BT RAMDAC type (0x%x), assuming BT485\n",
- status);
- case 0x80:
- case 0x90:
- case 0xA0:
- case 0xB0:
- case 0x28: /* This is for the DEC TGA - Questionable ? */
- BTramdac_ID = BT485_RAMDAC;
- break;
+ case 0x40:
+ BTramdac_ID = ATT20C504_RAMDAC;
+ break;
+ case 0xD0:
+ BTramdac_ID = ATT20C505_RAMDAC;
+ break;
+ default:
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Unknown BT RAMDAC type (0x%x), assuming BT485\n", status);
+ case 0x80:
+ case 0x90:
+ case 0xA0:
+ case 0xB0:
+ case 0x28: /* This is for the DEC TGA - Questionable ? */
+ BTramdac_ID = BT485_RAMDAC;
+ break;
}
/* Restore COMMAND Register 0 */
- (*ramdacPtr->WriteDAC)(pScrn, BT_COMMAND_REG_0, 0x00, cmd0);
+ (*ramdacPtr->WriteDAC) (pScrn, BT_COMMAND_REG_0, 0x00, cmd0);
if (BTramdac_ID == -1) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "Cannot determine BT RAMDAC type, aborting\n");
- return NULL;
- } else {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "Attached RAMDAC is %s\n", BTramdacDeviceInfo[BTramdac_ID&0xFFFF].DeviceName);
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Cannot determine BT RAMDAC type, aborting\n");
+ return NULL;
+ }
+ else {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Attached RAMDAC is %s\n",
+ BTramdacDeviceInfo[BTramdac_ID & 0xFFFF].DeviceName);
}
- for (i=0;ramdacs[i].token != -1;i++) {
- if (ramdacs[i].token == BTramdac_ID)
- RamDacIsSupported = TRUE;
+ for (i = 0; ramdacs[i].token != -1; i++) {
+ if (ramdacs[i].token == BTramdac_ID)
+ RamDacIsSupported = TRUE;
}
if (!RamDacIsSupported) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "This BT RAMDAC is NOT supported by this driver, aborting\n");
- return NULL;
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "This BT RAMDAC is NOT supported by this driver, aborting\n");
+ return NULL;
}
ramdacHelperPtr = RamDacHelperCreateInfoRec();
- switch(BTramdac_ID) {
- case BT485_RAMDAC:
- ramdacHelperPtr->SetBpp = BTramdacSetBpp;
- break;
+ switch (BTramdac_ID) {
+ case BT485_RAMDAC:
+ ramdacHelperPtr->SetBpp = BTramdacSetBpp;
+ break;
}
ramdacPtr->RamDacType = BTramdac_ID;
ramdacHelperPtr->RamDacType = BTramdac_ID;
ramdacHelperPtr->Save = BTramdacSave;
ramdacHelperPtr->Restore = BTramdacRestore;
-
+
return ramdacHelperPtr;
}
@@ -143,23 +145,23 @@ BTramdacSetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
/* We need to deal with Direct Colour visuals for 8bpp and other
* good stuff for colours */
switch (pScrn->bitsPerPixel) {
- case 32:
- ramdacReg->DacRegs[BT_COMMAND_REG_1] = 0x10;
- break;
- case 24:
- ramdacReg->DacRegs[BT_COMMAND_REG_1] = 0x10;
- break;
- case 16:
- ramdacReg->DacRegs[BT_COMMAND_REG_1] = 0x38;
- break;
- case 15:
- ramdacReg->DacRegs[BT_COMMAND_REG_1] = 0x30;
- break;
- case 8:
- ramdacReg->DacRegs[BT_COMMAND_REG_1] = 0x40;
- break;
- case 4:
- ramdacReg->DacRegs[BT_COMMAND_REG_1] = 0x60;
- break;
+ case 32:
+ ramdacReg->DacRegs[BT_COMMAND_REG_1] = 0x10;
+ break;
+ case 24:
+ ramdacReg->DacRegs[BT_COMMAND_REG_1] = 0x10;
+ break;
+ case 16:
+ ramdacReg->DacRegs[BT_COMMAND_REG_1] = 0x38;
+ break;
+ case 15:
+ ramdacReg->DacRegs[BT_COMMAND_REG_1] = 0x30;
+ break;
+ case 8:
+ ramdacReg->DacRegs[BT_COMMAND_REG_1] = 0x40;
+ break;
+ case 4:
+ ramdacReg->DacRegs[BT_COMMAND_REG_1] = 0x60;
+ break;
}
}
diff --git a/xorg-server/hw/xfree86/ramdac/BT.h b/xorg-server/hw/xfree86/ramdac/BT.h
index 35d0bdbd9..6eeaf5db7 100644
--- a/xorg-server/hw/xfree86/ramdac/BT.h
+++ b/xorg-server/hw/xfree86/ramdac/BT.h
@@ -1,10 +1,15 @@
#include "xf86RamDac.h"
-extern _X_EXPORT RamDacHelperRecPtr BTramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs);
-extern _X_EXPORT void BTramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr RamDacRec, RamDacRegRecPtr RamDacRegRec);
-extern _X_EXPORT void BTramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr RamDacRec, RamDacRegRecPtr RamDacRegRec);
-extern _X_EXPORT void BTramdacSetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr RamDacRegRec);
+extern _X_EXPORT RamDacHelperRecPtr BTramdacProbe(ScrnInfoPtr pScrn,
+ RamDacSupportedInfoRecPtr
+ ramdacs);
+extern _X_EXPORT void BTramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr RamDacRec,
+ RamDacRegRecPtr RamDacRegRec);
+extern _X_EXPORT void BTramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr RamDacRec,
+ RamDacRegRecPtr RamDacRegRec);
+extern _X_EXPORT void BTramdacSetBpp(ScrnInfoPtr pScrn,
+ RamDacRegRecPtr RamDacRegRec);
#define ATT20C504_RAMDAC (VENDOR_BT << 16) | 0x00
#define ATT20C505_RAMDAC (VENDOR_BT << 16) | 0x01
@@ -15,7 +20,7 @@ extern _X_EXPORT void BTramdacSetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr RamDacRe
*/
#define BT_WRITE_ADDR 0x00
-#define BT_RAMDAC_DATA 0x01
+#define BT_RAMDAC_DATA 0x01
#define BT_PIXEL_MASK 0x02
#define BT_READ_ADDR 0x03
#define BT_CURS_WR_ADDR 0x04
diff --git a/xorg-server/hw/xfree86/ramdac/IBM.c b/xorg-server/hw/xfree86/ramdac/IBM.c
index 3a477d7be..bc716231a 100644
--- a/xorg-server/hw/xfree86/ramdac/IBM.c
+++ b/xorg-server/hw/xfree86/ramdac/IBM.c
@@ -1,639 +1,643 @@
-/*
- * Copyright 1998 by Alan Hourihane, Wigan, England.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Alan Hourihane not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Alan Hourihane makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
- *
- * IBM RAMDAC routines.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include "xf86Cursor.h"
-
-#define INIT_IBM_RAMDAC_INFO
-#include "IBMPriv.h"
-#include "xf86RamDacPriv.h"
-
-#define INITIALFREQERR 100000
-
-unsigned long
-IBMramdac640CalculateMNPCForClock(
- unsigned long RefClock, /* In 100Hz units */
- unsigned long ReqClock, /* In 100Hz units */
- char IsPixClock, /* boolean, is this the pixel or the sys clock */
- unsigned long MinClock, /* Min VCO rating */
- unsigned long MaxClock, /* Max VCO rating */
- unsigned long *rM, /* M Out */
- unsigned long *rN, /* N Out */
- unsigned long *rP, /* Min P In, P Out */
- unsigned long *rC /* C Out */
-)
-{
- unsigned long M, N, P, iP = *rP;
- unsigned long IntRef, VCO, Clock;
- long freqErr, lowestFreqErr = INITIALFREQERR;
- unsigned long ActualClock = 0;
-
- for (N = 0; N <= 63; N++)
- {
- IntRef = RefClock / (N + 1);
- if (IntRef < 10000)
- break; /* IntRef needs to be >= 1MHz */
- for (M = 2; M <= 127; M++)
- {
- VCO = IntRef * (M + 1);
- if ((VCO < MinClock) || (VCO > MaxClock))
- continue;
- for (P = iP; P <= 4; P++)
- {
- if (P != 0)
- Clock = (RefClock * (M + 1)) / ((N + 1) * 2 * P);
- else
- Clock = (RefClock * (M + 1)) / (N + 1);
-
- freqErr = (Clock - ReqClock);
-
- if (freqErr < 0)
- {
- /* PixelClock gets rounded up always so monitor reports
- correct frequency. */
- if (IsPixClock)
- continue;
- freqErr = -freqErr;
- }
-
- if (freqErr < lowestFreqErr)
- {
- *rM = M;
- *rN = N;
- *rP = P;
- *rC = (VCO <= 1280000 ? 1 : 2);
- ActualClock = Clock;
-
- lowestFreqErr = freqErr;
- /* Return if we found an exact match */
- if (freqErr == 0)
- return ActualClock;
- }
- }
- }
- }
-
- return ActualClock;
-}
-
-unsigned long
-IBMramdac526CalculateMNPCForClock(
- unsigned long RefClock, /* In 100Hz units */
- unsigned long ReqClock, /* In 100Hz units */
- char IsPixClock, /* boolean, is this the pixel or the sys clock */
- unsigned long MinClock, /* Min VCO rating */
- unsigned long MaxClock, /* Max VCO rating */
- unsigned long *rM, /* M Out */
- unsigned long *rN, /* N Out */
- unsigned long *rP, /* Min P In, P Out */
- unsigned long *rC /* C Out */
-)
-{
- unsigned long M, N, P, iP = *rP;
- unsigned long IntRef, VCO, Clock;
- long freqErr, lowestFreqErr = INITIALFREQERR;
- unsigned long ActualClock = 0;
-
- for (N = 0; N <= 63; N++)
- {
- IntRef = RefClock / (N + 1);
- if (IntRef < 10000)
- break; /* IntRef needs to be >= 1MHz */
- for (M = 0; M <= 63; M++)
- {
- VCO = IntRef * (M + 1);
- if ((VCO < MinClock) || (VCO > MaxClock))
- continue;
- for (P = iP; P <= 4; P++)
- {
- if (P)
- Clock = (RefClock * (M + 1)) / ((N + 1) * 2 * P);
- else
- Clock = VCO;
-
- freqErr = (Clock - ReqClock);
-
- if (freqErr < 0)
- {
- /* PixelClock gets rounded up always so monitor reports
- correct frequency. */
- if (IsPixClock)
- continue;
- freqErr = -freqErr;
- }
-
- if (freqErr < lowestFreqErr)
- {
- *rM = M;
- *rN = N;
- *rP = P;
- *rC = (VCO <= 1280000 ? 1 : 2);
- ActualClock = Clock;
-
- lowestFreqErr = freqErr;
- /* Return if we found an exact match */
- if (freqErr == 0)
- return ActualClock;
- }
- }
- }
- }
-
- return ActualClock;
-}
-
-void
-IBMramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
- RamDacRegRecPtr ramdacReg)
-{
- int i, maxreg, dacreg;
-
- switch (ramdacPtr->RamDacType) {
- case IBM640_RAMDAC:
- maxreg = 0x300;
- dacreg = 1024;
- break;
- default:
- maxreg = 0x100;
- dacreg = 768;
- break;
- }
-
- /* Here we pass a short, so that we can evaluate a mask too */
- /* So that the mask is the high byte and the data the low byte */
- for (i=0;i<maxreg;i++)
- (*ramdacPtr->WriteDAC)
- (pScrn, i, (ramdacReg->DacRegs[i] & 0xFF00) >> 8,
- ramdacReg->DacRegs[i]);
-
- (*ramdacPtr->WriteAddress)(pScrn, 0);
- for (i=0;i<dacreg;i++)
- (*ramdacPtr->WriteData)(pScrn, ramdacReg->DAC[i]);
-}
-
-void
-IBMramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
- RamDacRegRecPtr ramdacReg)
-{
- int i, maxreg, dacreg;
-
- switch (ramdacPtr->RamDacType) {
- case IBM640_RAMDAC:
- maxreg = 0x300;
- dacreg = 1024;
- break;
- default:
- maxreg = 0x100;
- dacreg = 768;
- break;
- }
-
- (*ramdacPtr->ReadAddress)(pScrn, 0);
- for (i=0;i<dacreg;i++)
- ramdacReg->DAC[i] = (*ramdacPtr->ReadData)(pScrn);
-
- for (i=0;i<maxreg;i++)
- ramdacReg->DacRegs[i] = (*ramdacPtr->ReadDAC)(pScrn, i);
-}
-
-RamDacHelperRecPtr
-IBMramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs/* , RamDacRecPtr ramdacPtr*/)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
- RamDacHelperRecPtr ramdacHelperPtr = NULL;
- Bool RamDacIsSupported = FALSE;
- int IBMramdac_ID = -1;
- int i;
- unsigned char id, rev, id2, rev2;
-
- /* read ID and revision */
- rev = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_rev);
- id = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_id);
-
- /* check if ID and revision are read only */
- (*ramdacPtr->WriteDAC)(pScrn, ~rev, 0, IBMRGB_rev);
- (*ramdacPtr->WriteDAC)(pScrn, ~id, 0, IBMRGB_id);
- rev2 = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_rev);
- id2 = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_id);
-
- switch (id) {
- case 0x30:
- if (rev == 0xc0) IBMramdac_ID = IBM624_RAMDAC;
- if (rev == 0x80) IBMramdac_ID = IBM624DB_RAMDAC;
- break;
- case 0x12:
- if (rev == 0x1c) IBMramdac_ID = IBM640_RAMDAC;
- break;
- case 0x01:
- IBMramdac_ID = IBM525_RAMDAC;
- break;
- case 0x02:
- if (rev == 0xf0) IBMramdac_ID = IBM524_RAMDAC;
- if (rev == 0xe0) IBMramdac_ID = IBM524A_RAMDAC;
- if (rev == 0xc0) IBMramdac_ID = IBM526_RAMDAC;
- if (rev == 0x80) IBMramdac_ID = IBM526DB_RAMDAC;
- break;
- }
-
- if (id == 1 || id == 2) {
- if (id == id2 && rev == rev2) { /* IBM RGB52x found */
- /* check for 128bit VRAM -> RGB528 */
- if (((*ramdacPtr->ReadDAC)(pScrn, IBMRGB_misc1) & 0x03) == 0x03) {
- IBMramdac_ID = IBM528_RAMDAC; /* 128bit DAC found */
- if (rev == 0xe0)
- IBMramdac_ID = IBM528A_RAMDAC;
- }
- }
- }
-
- (*ramdacPtr->WriteDAC)(pScrn, rev, 0, IBMRGB_rev);
- (*ramdacPtr->WriteDAC)(pScrn, id, 0, IBMRGB_id);
-
- if (IBMramdac_ID == -1) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "Cannot determine IBM RAMDAC type, aborting\n");
- return NULL;
- } else {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "Attached RAMDAC is %s\n", IBMramdacDeviceInfo[IBMramdac_ID&0xFFFF].DeviceName);
- }
-
- for (i=0;ramdacs[i].token != -1;i++) {
- if (ramdacs[i].token == IBMramdac_ID)
- RamDacIsSupported = TRUE;
- }
-
- if (!RamDacIsSupported) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "This IBM RAMDAC is NOT supported by this driver, aborting\n");
- return NULL;
- }
-
- ramdacHelperPtr = RamDacHelperCreateInfoRec();
- switch (IBMramdac_ID) {
- case IBM526_RAMDAC:
- case IBM526DB_RAMDAC:
- ramdacHelperPtr->SetBpp = IBMramdac526SetBpp;
- ramdacHelperPtr->HWCursorInit = IBMramdac526HWCursorInit;
- break;
- case IBM640_RAMDAC:
- ramdacHelperPtr->SetBpp = IBMramdac640SetBpp;
- ramdacHelperPtr->HWCursorInit = IBMramdac640HWCursorInit;
- break;
- }
- ramdacPtr->RamDacType = IBMramdac_ID;
- ramdacHelperPtr->RamDacType = IBMramdac_ID;
- ramdacHelperPtr->Save = IBMramdacSave;
- ramdacHelperPtr->Restore = IBMramdacRestore;
-
- return ramdacHelperPtr;
-}
-
-void
-IBMramdac526SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
-{
- ramdacReg->DacRegs[IBMRGB_key_control] = 0x00; /* Disable Chroma Key */
-
- switch (pScrn->bitsPerPixel) {
- case 32:
- ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_32BPP;
- ramdacReg->DacRegs[IBMRGB_32bpp] = B32_DCOL_DIRECT;
- ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_16bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
- if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
- ramdacReg->DacRegs[IBMRGB_key_control] = 0x01; /* Enable Key */
- ramdacReg->DacRegs[IBMRGB_key] = 0xFF;
- ramdacReg->DacRegs[IBMRGB_key_mask] = 0xFF;
- }
- break;
- case 24:
- ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_24BPP;
- ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_24bpp] = B24_DCOL_DIRECT;
- ramdacReg->DacRegs[IBMRGB_16bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
- break;
- case 16:
- if (pScrn->depth == 16) {
- ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_16BPP;
- ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_16bpp] = B16_DCOL_DIRECT|B16_LINEAR |
- B16_CONTIGUOUS | B16_565;
- ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
- } else {
- ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_16BPP;
- ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_16bpp] = B16_DCOL_DIRECT|B16_LINEAR |
- B16_CONTIGUOUS | B16_555;
- ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
- }
- break;
- case 8:
- ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_8BPP;
- ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_16bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_8bpp] = B8_DCOL_INDIRECT;
- break;
- case 4:
- ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_4BPP;
- ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_16bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
- }
-}
-
-IBMramdac526SetBppProc *IBMramdac526SetBppWeak(void) {
- return IBMramdac526SetBpp;
-}
-
-void
-IBMramdac640SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
-{
- unsigned char bpp = 0x00;
- unsigned char overlaybpp = 0x00;
- unsigned char offset = 0x00;
- unsigned char dispcont = 0x44;
-
- ramdacReg->DacRegs[RGB640_SER_WID_03_00] = 0x00;
- ramdacReg->DacRegs[RGB640_SER_WID_07_04] = 0x00;
- ramdacReg->DacRegs[RGB640_DIAGS] = 0x07;
-
- switch (pScrn->depth) {
- case 8:
- ramdacReg->DacRegs[RGB640_SER_07_00] = 0x00;
- ramdacReg->DacRegs[RGB640_SER_15_08] = 0x00;
- ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00;
- ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00;
- ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_16_1; /*16:1 Mux*/
- ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */
- bpp = 0x03;
- break;
- case 15:
- ramdacReg->DacRegs[RGB640_SER_07_00] = 0x10;
- ramdacReg->DacRegs[RGB640_SER_15_08] = 0x11;
- ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00;
- ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00;
- ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_8_1; /* 8:1 Mux*/
- ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */
- bpp = 0x0E;
- break;
- case 16:
- ramdacReg->DacRegs[RGB640_SER_07_00] = 0x10;
- ramdacReg->DacRegs[RGB640_SER_15_08] = 0x11;
- ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00;
- ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00;
- ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_8_1; /* 8:1 Mux*/
- ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */
- bpp = 0x05;
- break;
- case 24:
- ramdacReg->DacRegs[RGB640_SER_07_00] = 0x30;
- ramdacReg->DacRegs[RGB640_SER_15_08] = 0x31;
- ramdacReg->DacRegs[RGB640_SER_23_16] = 0x32;
- ramdacReg->DacRegs[RGB640_SER_31_24] = 0x33;
- ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_4_1; /* 4:1 Mux*/
- ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */
- bpp = 0x09;
- if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
- ramdacReg->DacRegs[RGB640_SER_WID_07_04] = 0x04;
- ramdacReg->DacRegs[RGB640_CHROMA_KEY0] = 0xFF;
- ramdacReg->DacRegs[RGB640_CHROMA_MASK0] = 0xFF;
- offset = 0x04;
- overlaybpp = 0x04;
- dispcont = 0x48;
- }
- break;
- case 30: /* 10 bit dac */
- ramdacReg->DacRegs[RGB640_SER_07_00] = 0x30;
- ramdacReg->DacRegs[RGB640_SER_15_08] = 0x31;
- ramdacReg->DacRegs[RGB640_SER_23_16] = 0x32;
- ramdacReg->DacRegs[RGB640_SER_31_24] = 0x33;
- ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_4_1; /* 4:1 Mux*/
- ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PSIZE10 |
- IBM640_PCLK_8; /* pll / 8 */
- bpp = 0x0D;
- break;
- }
-
- {
- int i;
- for (i=0x100;i<0x140;i+=4) {
- /* Initialize FrameBuffer Window Attribute Table */
- ramdacReg->DacRegs[i+0] = bpp;
- ramdacReg->DacRegs[i+1] = offset;
- ramdacReg->DacRegs[i+2] = 0x00;
- ramdacReg->DacRegs[i+3] = 0x00;
- /* Initialize Overlay Window Attribute Table */
- ramdacReg->DacRegs[i+0x100] = overlaybpp;
- ramdacReg->DacRegs[i+0x101] = 0x00;
- ramdacReg->DacRegs[i+0x102] = 0x00;
- ramdacReg->DacRegs[i+0x103] = dispcont;
- }
- }
-}
-
-static void
-IBMramdac526ShowCursor(ScrnInfoPtr pScrn)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- /* Enable cursor - X11 mode */
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs, 0x00, 0x07);
-}
-
-static void
-IBMramdac640ShowCursor(ScrnInfoPtr pScrn)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- /* Enable cursor - mode2 (x11 mode) */
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURSOR_CONTROL, 0x00, 0x0B);
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CROSSHAIR_CONTROL, 0x00, 0x00);
-}
-
-static void
-IBMramdac526HideCursor(ScrnInfoPtr pScrn)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- /* Disable cursor - X11 mode */
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs, 0x00, 0x24);
-}
-
-static void
-IBMramdac640HideCursor(ScrnInfoPtr pScrn)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- /* Disable cursor - mode2 (x11 mode) */
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURSOR_CONTROL, 0x00, 0x08);
-}
-
-static void
-IBMramdac526SetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- x += 64;
- y += 64;
-
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_hot_x, 0x00, 0x3f);
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_hot_y, 0x00, 0x3f);
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_xl, 0x00, x & 0xff);
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_xh, 0x00, (x>>8) & 0xf);
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_yl, 0x00, y & 0xff);
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_yh, 0x00, (y>>8) & 0xf);
-}
-
-static void
-IBMramdac640SetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- x += 64;
- y += 64;
-
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_OFFSETX, 0x00, 0x3f);
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_OFFSETY, 0x00, 0x3f);
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_X_LOW, 0x00, x & 0xff);
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_X_HIGH, 0x00, (x>>8) & 0xf);
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_Y_LOW, 0x00, y & 0xff);
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_Y_HIGH, 0x00, (y>>8) & 0xf);
-}
-
-static void
-IBMramdac526SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col1_r, 0x00, bg >> 16);
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col1_g, 0x00, bg >> 8);
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col1_b, 0x00, bg);
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col2_r, 0x00, fg >> 16);
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col2_g, 0x00, fg >> 8);
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col2_b, 0x00, fg);
-}
-
-static void
-IBMramdac640SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_COL0, 0x00, 0);
- (*ramdacPtr->WriteData)(pScrn, fg>>16);
- (*ramdacPtr->WriteData)(pScrn, fg>>8);
- (*ramdacPtr->WriteData)(pScrn, fg);
- (*ramdacPtr->WriteData)(pScrn, bg>>16);
- (*ramdacPtr->WriteData)(pScrn, bg>>8);
- (*ramdacPtr->WriteData)(pScrn, bg);
- (*ramdacPtr->WriteData)(pScrn, fg>>16);
- (*ramdacPtr->WriteData)(pScrn, fg>>8);
- (*ramdacPtr->WriteData)(pScrn, fg);
- (*ramdacPtr->WriteData)(pScrn, bg>>16);
- (*ramdacPtr->WriteData)(pScrn, bg>>8);
- (*ramdacPtr->WriteData)(pScrn, bg);
-}
-
-static void
-IBMramdac526LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
- int i;
- /*
- * Output the cursor data. The realize function has put the planes into
- * their correct order, so we can just blast this out.
- */
- for (i = 0; i < 1024; i++)
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_array + i, 0x00, (*src++));
-}
-
-static void
-IBMramdac640LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
- int i;
- /*
- * Output the cursor data. The realize function has put the planes into
- * their correct order, so we can just blast this out.
- */
- for (i = 0; i < 1024; i++)
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_WRITE + i, 0x00, (*src++));
-}
-
-static Bool
-IBMramdac526UseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
-{
- return TRUE;
-}
-
-static Bool
-IBMramdac640UseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
-{
- return TRUE;
-}
-
-void
-IBMramdac526HWCursorInit(xf86CursorInfoPtr infoPtr)
-{
- infoPtr->MaxWidth = 64;
- infoPtr->MaxHeight = 64;
- infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
- HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
- HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1;
- infoPtr->SetCursorColors = IBMramdac526SetCursorColors;
- infoPtr->SetCursorPosition = IBMramdac526SetCursorPosition;
- infoPtr->LoadCursorImage = IBMramdac526LoadCursorImage;
- infoPtr->HideCursor = IBMramdac526HideCursor;
- infoPtr->ShowCursor = IBMramdac526ShowCursor;
- infoPtr->UseHWCursor = IBMramdac526UseHWCursor;
-}
-
-void
-IBMramdac640HWCursorInit(xf86CursorInfoPtr infoPtr)
-{
- infoPtr->MaxWidth = 64;
- infoPtr->MaxHeight = 64;
- infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
- HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
- HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1;
- infoPtr->SetCursorColors = IBMramdac640SetCursorColors;
- infoPtr->SetCursorPosition = IBMramdac640SetCursorPosition;
- infoPtr->LoadCursorImage = IBMramdac640LoadCursorImage;
- infoPtr->HideCursor = IBMramdac640HideCursor;
- infoPtr->ShowCursor = IBMramdac640ShowCursor;
- infoPtr->UseHWCursor = IBMramdac640UseHWCursor;
-}
+/*
+ * Copyright 1998 by Alan Hourihane, Wigan, England.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
+ *
+ * IBM RAMDAC routines.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include "xf86Cursor.h"
+
+#define INIT_IBM_RAMDAC_INFO
+#include "IBMPriv.h"
+#include "xf86RamDacPriv.h"
+
+#define INITIALFREQERR 100000
+
+unsigned long
+IBMramdac640CalculateMNPCForClock(unsigned long RefClock, /* In 100Hz units */
+ unsigned long ReqClock, /* In 100Hz units */
+ char IsPixClock, /* boolean, is this the pixel or the sys clock */
+ unsigned long MinClock, /* Min VCO rating */
+ unsigned long MaxClock, /* Max VCO rating */
+ unsigned long *rM, /* M Out */
+ unsigned long *rN, /* N Out */
+ unsigned long *rP, /* Min P In, P Out */
+ unsigned long *rC /* C Out */
+ )
+{
+ unsigned long M, N, P, iP = *rP;
+ unsigned long IntRef, VCO, Clock;
+ long freqErr, lowestFreqErr = INITIALFREQERR;
+ unsigned long ActualClock = 0;
+
+ for (N = 0; N <= 63; N++) {
+ IntRef = RefClock / (N + 1);
+ if (IntRef < 10000)
+ break; /* IntRef needs to be >= 1MHz */
+ for (M = 2; M <= 127; M++) {
+ VCO = IntRef * (M + 1);
+ if ((VCO < MinClock) || (VCO > MaxClock))
+ continue;
+ for (P = iP; P <= 4; P++) {
+ if (P != 0)
+ Clock = (RefClock * (M + 1)) / ((N + 1) * 2 * P);
+ else
+ Clock = (RefClock * (M + 1)) / (N + 1);
+
+ freqErr = (Clock - ReqClock);
+
+ if (freqErr < 0) {
+ /* PixelClock gets rounded up always so monitor reports
+ correct frequency. */
+ if (IsPixClock)
+ continue;
+ freqErr = -freqErr;
+ }
+
+ if (freqErr < lowestFreqErr) {
+ *rM = M;
+ *rN = N;
+ *rP = P;
+ *rC = (VCO <= 1280000 ? 1 : 2);
+ ActualClock = Clock;
+
+ lowestFreqErr = freqErr;
+ /* Return if we found an exact match */
+ if (freqErr == 0)
+ return ActualClock;
+ }
+ }
+ }
+ }
+
+ return ActualClock;
+}
+
+unsigned long
+IBMramdac526CalculateMNPCForClock(unsigned long RefClock, /* In 100Hz units */
+ unsigned long ReqClock, /* In 100Hz units */
+ char IsPixClock, /* boolean, is this the pixel or the sys clock */
+ unsigned long MinClock, /* Min VCO rating */
+ unsigned long MaxClock, /* Max VCO rating */
+ unsigned long *rM, /* M Out */
+ unsigned long *rN, /* N Out */
+ unsigned long *rP, /* Min P In, P Out */
+ unsigned long *rC /* C Out */
+ )
+{
+ unsigned long M, N, P, iP = *rP;
+ unsigned long IntRef, VCO, Clock;
+ long freqErr, lowestFreqErr = INITIALFREQERR;
+ unsigned long ActualClock = 0;
+
+ for (N = 0; N <= 63; N++) {
+ IntRef = RefClock / (N + 1);
+ if (IntRef < 10000)
+ break; /* IntRef needs to be >= 1MHz */
+ for (M = 0; M <= 63; M++) {
+ VCO = IntRef * (M + 1);
+ if ((VCO < MinClock) || (VCO > MaxClock))
+ continue;
+ for (P = iP; P <= 4; P++) {
+ if (P)
+ Clock = (RefClock * (M + 1)) / ((N + 1) * 2 * P);
+ else
+ Clock = VCO;
+
+ freqErr = (Clock - ReqClock);
+
+ if (freqErr < 0) {
+ /* PixelClock gets rounded up always so monitor reports
+ correct frequency. */
+ if (IsPixClock)
+ continue;
+ freqErr = -freqErr;
+ }
+
+ if (freqErr < lowestFreqErr) {
+ *rM = M;
+ *rN = N;
+ *rP = P;
+ *rC = (VCO <= 1280000 ? 1 : 2);
+ ActualClock = Clock;
+
+ lowestFreqErr = freqErr;
+ /* Return if we found an exact match */
+ if (freqErr == 0)
+ return ActualClock;
+ }
+ }
+ }
+ }
+
+ return ActualClock;
+}
+
+void
+IBMramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
+ RamDacRegRecPtr ramdacReg)
+{
+ int i, maxreg, dacreg;
+
+ switch (ramdacPtr->RamDacType) {
+ case IBM640_RAMDAC:
+ maxreg = 0x300;
+ dacreg = 1024;
+ break;
+ default:
+ maxreg = 0x100;
+ dacreg = 768;
+ break;
+ }
+
+ /* Here we pass a short, so that we can evaluate a mask too */
+ /* So that the mask is the high byte and the data the low byte */
+ for (i = 0; i < maxreg; i++)
+ (*ramdacPtr->WriteDAC)
+ (pScrn, i, (ramdacReg->DacRegs[i] & 0xFF00) >> 8,
+ ramdacReg->DacRegs[i]);
+
+ (*ramdacPtr->WriteAddress) (pScrn, 0);
+ for (i = 0; i < dacreg; i++)
+ (*ramdacPtr->WriteData) (pScrn, ramdacReg->DAC[i]);
+}
+
+void
+IBMramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
+ RamDacRegRecPtr ramdacReg)
+{
+ int i, maxreg, dacreg;
+
+ switch (ramdacPtr->RamDacType) {
+ case IBM640_RAMDAC:
+ maxreg = 0x300;
+ dacreg = 1024;
+ break;
+ default:
+ maxreg = 0x100;
+ dacreg = 768;
+ break;
+ }
+
+ (*ramdacPtr->ReadAddress) (pScrn, 0);
+ for (i = 0; i < dacreg; i++)
+ ramdacReg->DAC[i] = (*ramdacPtr->ReadData) (pScrn);
+
+ for (i = 0; i < maxreg; i++)
+ ramdacReg->DacRegs[i] = (*ramdacPtr->ReadDAC) (pScrn, i);
+}
+
+RamDacHelperRecPtr
+IBMramdacProbe(ScrnInfoPtr pScrn,
+ RamDacSupportedInfoRecPtr ramdacs /* , RamDacRecPtr ramdacPtr */
+ )
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+ RamDacHelperRecPtr ramdacHelperPtr = NULL;
+ Bool RamDacIsSupported = FALSE;
+ int IBMramdac_ID = -1;
+ int i;
+ unsigned char id, rev, id2, rev2;
+
+ /* read ID and revision */
+ rev = (*ramdacPtr->ReadDAC) (pScrn, IBMRGB_rev);
+ id = (*ramdacPtr->ReadDAC) (pScrn, IBMRGB_id);
+
+ /* check if ID and revision are read only */
+ (*ramdacPtr->WriteDAC) (pScrn, ~rev, 0, IBMRGB_rev);
+ (*ramdacPtr->WriteDAC) (pScrn, ~id, 0, IBMRGB_id);
+ rev2 = (*ramdacPtr->ReadDAC) (pScrn, IBMRGB_rev);
+ id2 = (*ramdacPtr->ReadDAC) (pScrn, IBMRGB_id);
+
+ switch (id) {
+ case 0x30:
+ if (rev == 0xc0)
+ IBMramdac_ID = IBM624_RAMDAC;
+ if (rev == 0x80)
+ IBMramdac_ID = IBM624DB_RAMDAC;
+ break;
+ case 0x12:
+ if (rev == 0x1c)
+ IBMramdac_ID = IBM640_RAMDAC;
+ break;
+ case 0x01:
+ IBMramdac_ID = IBM525_RAMDAC;
+ break;
+ case 0x02:
+ if (rev == 0xf0)
+ IBMramdac_ID = IBM524_RAMDAC;
+ if (rev == 0xe0)
+ IBMramdac_ID = IBM524A_RAMDAC;
+ if (rev == 0xc0)
+ IBMramdac_ID = IBM526_RAMDAC;
+ if (rev == 0x80)
+ IBMramdac_ID = IBM526DB_RAMDAC;
+ break;
+ }
+
+ if (id == 1 || id == 2) {
+ if (id == id2 && rev == rev2) { /* IBM RGB52x found */
+ /* check for 128bit VRAM -> RGB528 */
+ if (((*ramdacPtr->ReadDAC) (pScrn, IBMRGB_misc1) & 0x03) == 0x03) {
+ IBMramdac_ID = IBM528_RAMDAC; /* 128bit DAC found */
+ if (rev == 0xe0)
+ IBMramdac_ID = IBM528A_RAMDAC;
+ }
+ }
+ }
+
+ (*ramdacPtr->WriteDAC) (pScrn, rev, 0, IBMRGB_rev);
+ (*ramdacPtr->WriteDAC) (pScrn, id, 0, IBMRGB_id);
+
+ if (IBMramdac_ID == -1) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Cannot determine IBM RAMDAC type, aborting\n");
+ return NULL;
+ }
+ else {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Attached RAMDAC is %s\n",
+ IBMramdacDeviceInfo[IBMramdac_ID & 0xFFFF].DeviceName);
+ }
+
+ for (i = 0; ramdacs[i].token != -1; i++) {
+ if (ramdacs[i].token == IBMramdac_ID)
+ RamDacIsSupported = TRUE;
+ }
+
+ if (!RamDacIsSupported) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "This IBM RAMDAC is NOT supported by this driver, aborting\n");
+ return NULL;
+ }
+
+ ramdacHelperPtr = RamDacHelperCreateInfoRec();
+ switch (IBMramdac_ID) {
+ case IBM526_RAMDAC:
+ case IBM526DB_RAMDAC:
+ ramdacHelperPtr->SetBpp = IBMramdac526SetBpp;
+ ramdacHelperPtr->HWCursorInit = IBMramdac526HWCursorInit;
+ break;
+ case IBM640_RAMDAC:
+ ramdacHelperPtr->SetBpp = IBMramdac640SetBpp;
+ ramdacHelperPtr->HWCursorInit = IBMramdac640HWCursorInit;
+ break;
+ }
+ ramdacPtr->RamDacType = IBMramdac_ID;
+ ramdacHelperPtr->RamDacType = IBMramdac_ID;
+ ramdacHelperPtr->Save = IBMramdacSave;
+ ramdacHelperPtr->Restore = IBMramdacRestore;
+
+ return ramdacHelperPtr;
+}
+
+void
+IBMramdac526SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
+{
+ ramdacReg->DacRegs[IBMRGB_key_control] = 0x00; /* Disable Chroma Key */
+
+ switch (pScrn->bitsPerPixel) {
+ case 32:
+ ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_32BPP;
+ ramdacReg->DacRegs[IBMRGB_32bpp] = B32_DCOL_DIRECT;
+ ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_16bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
+ if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
+ ramdacReg->DacRegs[IBMRGB_key_control] = 0x01; /* Enable Key */
+ ramdacReg->DacRegs[IBMRGB_key] = 0xFF;
+ ramdacReg->DacRegs[IBMRGB_key_mask] = 0xFF;
+ }
+ break;
+ case 24:
+ ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_24BPP;
+ ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_24bpp] = B24_DCOL_DIRECT;
+ ramdacReg->DacRegs[IBMRGB_16bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
+ break;
+ case 16:
+ if (pScrn->depth == 16) {
+ ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_16BPP;
+ ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_16bpp] = B16_DCOL_DIRECT | B16_LINEAR |
+ B16_CONTIGUOUS | B16_565;
+ ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
+ }
+ else {
+ ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_16BPP;
+ ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_16bpp] = B16_DCOL_DIRECT | B16_LINEAR |
+ B16_CONTIGUOUS | B16_555;
+ ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
+ }
+ break;
+ case 8:
+ ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_8BPP;
+ ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_16bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_8bpp] = B8_DCOL_INDIRECT;
+ break;
+ case 4:
+ ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_4BPP;
+ ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_16bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
+ }
+}
+
+IBMramdac526SetBppProc *
+IBMramdac526SetBppWeak(void)
+{
+ return IBMramdac526SetBpp;
+}
+
+void
+IBMramdac640SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
+{
+ unsigned char bpp = 0x00;
+ unsigned char overlaybpp = 0x00;
+ unsigned char offset = 0x00;
+ unsigned char dispcont = 0x44;
+
+ ramdacReg->DacRegs[RGB640_SER_WID_03_00] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_WID_07_04] = 0x00;
+ ramdacReg->DacRegs[RGB640_DIAGS] = 0x07;
+
+ switch (pScrn->depth) {
+ case 8:
+ ramdacReg->DacRegs[RGB640_SER_07_00] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_15_08] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_16_1; /*16:1 Mux */
+ ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */
+ bpp = 0x03;
+ break;
+ case 15:
+ ramdacReg->DacRegs[RGB640_SER_07_00] = 0x10;
+ ramdacReg->DacRegs[RGB640_SER_15_08] = 0x11;
+ ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_8_1; /* 8:1 Mux */
+ ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */
+ bpp = 0x0E;
+ break;
+ case 16:
+ ramdacReg->DacRegs[RGB640_SER_07_00] = 0x10;
+ ramdacReg->DacRegs[RGB640_SER_15_08] = 0x11;
+ ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_8_1; /* 8:1 Mux */
+ ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */
+ bpp = 0x05;
+ break;
+ case 24:
+ ramdacReg->DacRegs[RGB640_SER_07_00] = 0x30;
+ ramdacReg->DacRegs[RGB640_SER_15_08] = 0x31;
+ ramdacReg->DacRegs[RGB640_SER_23_16] = 0x32;
+ ramdacReg->DacRegs[RGB640_SER_31_24] = 0x33;
+ ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_4_1; /* 4:1 Mux */
+ ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */
+ bpp = 0x09;
+ if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
+ ramdacReg->DacRegs[RGB640_SER_WID_07_04] = 0x04;
+ ramdacReg->DacRegs[RGB640_CHROMA_KEY0] = 0xFF;
+ ramdacReg->DacRegs[RGB640_CHROMA_MASK0] = 0xFF;
+ offset = 0x04;
+ overlaybpp = 0x04;
+ dispcont = 0x48;
+ }
+ break;
+ case 30: /* 10 bit dac */
+ ramdacReg->DacRegs[RGB640_SER_07_00] = 0x30;
+ ramdacReg->DacRegs[RGB640_SER_15_08] = 0x31;
+ ramdacReg->DacRegs[RGB640_SER_23_16] = 0x32;
+ ramdacReg->DacRegs[RGB640_SER_31_24] = 0x33;
+ ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_4_1; /* 4:1 Mux */
+ ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PSIZE10 | IBM640_PCLK_8; /* pll / 8 */
+ bpp = 0x0D;
+ break;
+ }
+
+ {
+ int i;
+
+ for (i = 0x100; i < 0x140; i += 4) {
+ /* Initialize FrameBuffer Window Attribute Table */
+ ramdacReg->DacRegs[i + 0] = bpp;
+ ramdacReg->DacRegs[i + 1] = offset;
+ ramdacReg->DacRegs[i + 2] = 0x00;
+ ramdacReg->DacRegs[i + 3] = 0x00;
+ /* Initialize Overlay Window Attribute Table */
+ ramdacReg->DacRegs[i + 0x100] = overlaybpp;
+ ramdacReg->DacRegs[i + 0x101] = 0x00;
+ ramdacReg->DacRegs[i + 0x102] = 0x00;
+ ramdacReg->DacRegs[i + 0x103] = dispcont;
+ }
+ }
+}
+
+static void
+IBMramdac526ShowCursor(ScrnInfoPtr pScrn)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Enable cursor - X11 mode */
+ (*ramdacPtr->WriteDAC) (pScrn, IBMRGB_curs, 0x00, 0x07);
+}
+
+static void
+IBMramdac640ShowCursor(ScrnInfoPtr pScrn)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Enable cursor - mode2 (x11 mode) */
+ (*ramdacPtr->WriteDAC) (pScrn, RGB640_CURSOR_CONTROL, 0x00, 0x0B);
+ (*ramdacPtr->WriteDAC) (pScrn, RGB640_CROSSHAIR_CONTROL, 0x00, 0x00);
+}
+
+static void
+IBMramdac526HideCursor(ScrnInfoPtr pScrn)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Disable cursor - X11 mode */
+ (*ramdacPtr->WriteDAC) (pScrn, IBMRGB_curs, 0x00, 0x24);
+}
+
+static void
+IBMramdac640HideCursor(ScrnInfoPtr pScrn)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Disable cursor - mode2 (x11 mode) */
+ (*ramdacPtr->WriteDAC) (pScrn, RGB640_CURSOR_CONTROL, 0x00, 0x08);
+}
+
+static void
+IBMramdac526SetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ x += 64;
+ y += 64;
+
+ (*ramdacPtr->WriteDAC) (pScrn, IBMRGB_curs_hot_x, 0x00, 0x3f);
+ (*ramdacPtr->WriteDAC) (pScrn, IBMRGB_curs_hot_y, 0x00, 0x3f);
+ (*ramdacPtr->WriteDAC) (pScrn, IBMRGB_curs_xl, 0x00, x & 0xff);
+ (*ramdacPtr->WriteDAC) (pScrn, IBMRGB_curs_xh, 0x00, (x >> 8) & 0xf);
+ (*ramdacPtr->WriteDAC) (pScrn, IBMRGB_curs_yl, 0x00, y & 0xff);
+ (*ramdacPtr->WriteDAC) (pScrn, IBMRGB_curs_yh, 0x00, (y >> 8) & 0xf);
+}
+
+static void
+IBMramdac640SetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ x += 64;
+ y += 64;
+
+ (*ramdacPtr->WriteDAC) (pScrn, RGB640_CURS_OFFSETX, 0x00, 0x3f);
+ (*ramdacPtr->WriteDAC) (pScrn, RGB640_CURS_OFFSETY, 0x00, 0x3f);
+ (*ramdacPtr->WriteDAC) (pScrn, RGB640_CURS_X_LOW, 0x00, x & 0xff);
+ (*ramdacPtr->WriteDAC) (pScrn, RGB640_CURS_X_HIGH, 0x00, (x >> 8) & 0xf);
+ (*ramdacPtr->WriteDAC) (pScrn, RGB640_CURS_Y_LOW, 0x00, y & 0xff);
+ (*ramdacPtr->WriteDAC) (pScrn, RGB640_CURS_Y_HIGH, 0x00, (y >> 8) & 0xf);
+}
+
+static void
+IBMramdac526SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ (*ramdacPtr->WriteDAC) (pScrn, IBMRGB_curs_col1_r, 0x00, bg >> 16);
+ (*ramdacPtr->WriteDAC) (pScrn, IBMRGB_curs_col1_g, 0x00, bg >> 8);
+ (*ramdacPtr->WriteDAC) (pScrn, IBMRGB_curs_col1_b, 0x00, bg);
+ (*ramdacPtr->WriteDAC) (pScrn, IBMRGB_curs_col2_r, 0x00, fg >> 16);
+ (*ramdacPtr->WriteDAC) (pScrn, IBMRGB_curs_col2_g, 0x00, fg >> 8);
+ (*ramdacPtr->WriteDAC) (pScrn, IBMRGB_curs_col2_b, 0x00, fg);
+}
+
+static void
+IBMramdac640SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ (*ramdacPtr->WriteDAC) (pScrn, RGB640_CURS_COL0, 0x00, 0);
+ (*ramdacPtr->WriteData) (pScrn, fg >> 16);
+ (*ramdacPtr->WriteData) (pScrn, fg >> 8);
+ (*ramdacPtr->WriteData) (pScrn, fg);
+ (*ramdacPtr->WriteData) (pScrn, bg >> 16);
+ (*ramdacPtr->WriteData) (pScrn, bg >> 8);
+ (*ramdacPtr->WriteData) (pScrn, bg);
+ (*ramdacPtr->WriteData) (pScrn, fg >> 16);
+ (*ramdacPtr->WriteData) (pScrn, fg >> 8);
+ (*ramdacPtr->WriteData) (pScrn, fg);
+ (*ramdacPtr->WriteData) (pScrn, bg >> 16);
+ (*ramdacPtr->WriteData) (pScrn, bg >> 8);
+ (*ramdacPtr->WriteData) (pScrn, bg);
+}
+
+static void
+IBMramdac526LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+ int i;
+
+ /*
+ * Output the cursor data. The realize function has put the planes into
+ * their correct order, so we can just blast this out.
+ */
+ for (i = 0; i < 1024; i++)
+ (*ramdacPtr->WriteDAC) (pScrn, IBMRGB_curs_array + i, 0x00, (*src++));
+}
+
+static void
+IBMramdac640LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+ int i;
+
+ /*
+ * Output the cursor data. The realize function has put the planes into
+ * their correct order, so we can just blast this out.
+ */
+ for (i = 0; i < 1024; i++)
+ (*ramdacPtr->WriteDAC) (pScrn, RGB640_CURS_WRITE + i, 0x00, (*src++));
+}
+
+static Bool
+IBMramdac526UseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
+{
+ return TRUE;
+}
+
+static Bool
+IBMramdac640UseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
+{
+ return TRUE;
+}
+
+void
+IBMramdac526HWCursorInit(xf86CursorInfoPtr infoPtr)
+{
+ infoPtr->MaxWidth = 64;
+ infoPtr->MaxHeight = 64;
+ infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
+ HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
+ HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1;
+ infoPtr->SetCursorColors = IBMramdac526SetCursorColors;
+ infoPtr->SetCursorPosition = IBMramdac526SetCursorPosition;
+ infoPtr->LoadCursorImage = IBMramdac526LoadCursorImage;
+ infoPtr->HideCursor = IBMramdac526HideCursor;
+ infoPtr->ShowCursor = IBMramdac526ShowCursor;
+ infoPtr->UseHWCursor = IBMramdac526UseHWCursor;
+}
+
+void
+IBMramdac640HWCursorInit(xf86CursorInfoPtr infoPtr)
+{
+ infoPtr->MaxWidth = 64;
+ infoPtr->MaxHeight = 64;
+ infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
+ HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
+ HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1;
+ infoPtr->SetCursorColors = IBMramdac640SetCursorColors;
+ infoPtr->SetCursorPosition = IBMramdac640SetCursorPosition;
+ infoPtr->LoadCursorImage = IBMramdac640LoadCursorImage;
+ infoPtr->HideCursor = IBMramdac640HideCursor;
+ infoPtr->ShowCursor = IBMramdac640ShowCursor;
+ infoPtr->UseHWCursor = IBMramdac640UseHWCursor;
+}
diff --git a/xorg-server/hw/xfree86/ramdac/IBM.h b/xorg-server/hw/xfree86/ramdac/IBM.h
index 6fa18b219..986be2f48 100644
--- a/xorg-server/hw/xfree86/ramdac/IBM.h
+++ b/xorg-server/hw/xfree86/ramdac/IBM.h
@@ -1,19 +1,54 @@
#include <xf86RamDac.h>
-extern _X_EXPORT RamDacHelperRecPtr IBMramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs);
-extern _X_EXPORT void IBMramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr RamDacRec, RamDacRegRecPtr RamDacRegRec);
-extern _X_EXPORT void IBMramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr RamDacRec, RamDacRegRecPtr RamDacRegRec);
-extern _X_EXPORT void IBMramdac526SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr RamDacRegRec);
-extern _X_EXPORT void IBMramdac640SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr RamDacRegRec);
-extern _X_EXPORT unsigned long IBMramdac526CalculateMNPCForClock(unsigned long RefClock,
- unsigned long ReqClock, char IsPixClock, unsigned long MinClock,
- unsigned long MaxClock, unsigned long *rM, unsigned long *rN,
- unsigned long *rP, unsigned long *rC);
-extern _X_EXPORT unsigned long IBMramdac640CalculateMNPCForClock(unsigned long RefClock,
- unsigned long ReqClock, char IsPixClock, unsigned long MinClock,
- unsigned long MaxClock, unsigned long *rM, unsigned long *rN,
- unsigned long *rP, unsigned long *rC);
+extern _X_EXPORT RamDacHelperRecPtr IBMramdacProbe(ScrnInfoPtr pScrn,
+ RamDacSupportedInfoRecPtr
+ ramdacs);
+extern _X_EXPORT void IBMramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr RamDacRec,
+ RamDacRegRecPtr RamDacRegRec);
+extern _X_EXPORT void IBMramdacRestore(ScrnInfoPtr pScrn,
+ RamDacRecPtr RamDacRec,
+ RamDacRegRecPtr RamDacRegRec);
+extern _X_EXPORT void IBMramdac526SetBpp(ScrnInfoPtr pScrn,
+ RamDacRegRecPtr RamDacRegRec);
+extern _X_EXPORT void IBMramdac640SetBpp(ScrnInfoPtr pScrn,
+ RamDacRegRecPtr RamDacRegRec);
+extern _X_EXPORT unsigned long IBMramdac526CalculateMNPCForClock(unsigned long
+ RefClock,
+ unsigned long
+ ReqClock,
+ char
+ IsPixClock,
+ unsigned long
+ MinClock,
+ unsigned long
+ MaxClock,
+ unsigned long
+ *rM,
+ unsigned long
+ *rN,
+ unsigned long
+ *rP,
+ unsigned long
+ *rC);
+extern _X_EXPORT unsigned long IBMramdac640CalculateMNPCForClock(unsigned long
+ RefClock,
+ unsigned long
+ ReqClock,
+ char
+ IsPixClock,
+ unsigned long
+ MinClock,
+ unsigned long
+ MaxClock,
+ unsigned long
+ *rM,
+ unsigned long
+ *rN,
+ unsigned long
+ *rP,
+ unsigned long
+ *rC);
extern _X_EXPORT void IBMramdac526HWCursorInit(xf86CursorInfoPtr infoPtr);
extern _X_EXPORT void IBMramdac640HWCursorInit(xf86CursorInfoPtr infoPtr);
@@ -46,7 +81,7 @@ extern _X_EXPORT IBMramdac526SetBppProc *IBMramdac526SetBppWeak(void);
#define IBMRGB_pwr_mgmt 0x05
#define IBMRGB_dac_op 0x06
#define IBMRGB_pal_ctrl 0x07
-#define IBMRGB_sysclk 0x08 /* not RGB525 */
+#define IBMRGB_sysclk 0x08 /* not RGB525 */
#define IBMRGB_pix_fmt 0x0a
#define IBMRGB_8bpp 0x0b
#define IBMRGB_16bpp 0x0c
@@ -55,8 +90,8 @@ extern _X_EXPORT IBMramdac526SetBppProc *IBMramdac526SetBppWeak(void);
#define IBMRGB_pll_ctrl1 0x10
#define IBMRGB_pll_ctrl2 0x11
#define IBMRGB_pll_ref_div_fix 0x14
-#define IBMRGB_sysclk_ref_div 0x15 /* not RGB525 */
-#define IBMRGB_sysclk_vco_div 0x16 /* not RGB525 */
+#define IBMRGB_sysclk_ref_div 0x15 /* not RGB525 */
+#define IBMRGB_sysclk_vco_div 0x16 /* not RGB525 */
/* #define IBMRGB_f0 0x20 */
#define IBMRGB_sysclk_n 0x15
@@ -105,7 +140,7 @@ extern _X_EXPORT IBMramdac526SetBppProc *IBMramdac526SetBppWeak(void);
#define IBMRGB_misc1 0x70
#define IBMRGB_misc2 0x71
#define IBMRGB_misc3 0x72
-#define IBMRGB_misc4 0x73 /* not RGB525 */
+#define IBMRGB_misc4 0x73 /* not RGB525 */
#define IBMRGB_key_control 0x78
#define IBMRGB_dac_sense 0x82
#define IBMRGB_misr_r 0x84
@@ -119,9 +154,7 @@ extern _X_EXPORT IBMramdac526SetBppProc *IBMramdac526SetBppWeak(void);
#define IBMRGB_vram_mask_3 0x93
#define IBMRGB_curs_array 0x100
-
-
-/* Constants rgb525.h */
+/* Constants rgb525.h */
/* RGB525_REVISION_LEVEL */
#define RGB525_PRODUCT_REV_LEVEL 0xf0
diff --git a/xorg-server/hw/xfree86/ramdac/TI.c b/xorg-server/hw/xfree86/ramdac/TI.c
index f189fed25..393b774d4 100644
--- a/xorg-server/hw/xfree86/ramdac/TI.c
+++ b/xorg-server/hw/xfree86/ramdac/TI.c
@@ -1,717 +1,725 @@
-/*
- * Copyright 1998 by Alan Hourihane, Wigan, England.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Alan Hourihane not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Alan Hourihane makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
- *
- * Modified from IBM.c to support TI RAMDAC routines
- * by Jens Owen, <jens@tungstengraphics.com>.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include "xf86Cursor.h"
-
-#define INIT_TI_RAMDAC_INFO
-#include "TIPriv.h"
-#include "xf86RamDacPriv.h"
-
-/* The following values are in kHz */
-#define TI_MIN_VCO_FREQ 110000
-#define TI_MAX_VCO_FREQ 220000
-
-unsigned long
-TIramdacCalculateMNPForClock(
- unsigned long RefClock, /* In 100Hz units */
- unsigned long ReqClock, /* In 100Hz units */
- char IsPixClock, /* boolean, is this the pixel or the sys clock */
- unsigned long MinClock, /* Min VCO rating */
- unsigned long MaxClock, /* Max VCO rating */
- unsigned long *rM, /* M Out */
- unsigned long *rN, /* N Out */
- unsigned long *rP /* Min P In, P Out */
-)
-{
- unsigned long n, p;
- unsigned long best_m = 0, best_n = 0;
- double VCO, IntRef = (double)RefClock;
- double m_err, inc_m, calc_m;
- unsigned long ActualClock;
-
- /* Make sure that MinClock <= ReqClock <= MaxClock */
- if ( ReqClock < MinClock)
- ReqClock = MinClock;
- if ( ReqClock > MaxClock )
- ReqClock = MaxClock;
-
- /*
- * ActualClock = VCO / 2 ^ p
- * Choose p so that TI_MIN_VCO_FREQ <= VCO <= TI_MAX_VCO_FREQ
- * Note that since TI_MAX_VCO_FREQ = 2 * TI_MIN_VCO_FREQ
- * we don't have to bother checking for this maximum limit.
- */
- VCO = (double)ReqClock;
- for ( p = 0; p < 3 && VCO < TI_MIN_VCO_FREQ; ( p )++ )
- VCO *= 2.0;
-
- /*
- * We avoid doing multiplications by ( 65 - n ),
- * and add an increment instead - this keeps any error small.
- */
- inc_m = VCO / ( IntRef * 8.0 );
-
- /* Initial value of calc_m for the loop */
- calc_m = inc_m + inc_m + inc_m;
-
- /* Initial amount of error for an integer - impossibly large */
- m_err = 2.0;
-
- /* Search for the closest INTEGER value of ( 65 - m ) */
- for ( n = 3; n <= 25; ( n )++, calc_m += inc_m ) {
-
- /* Ignore values of ( 65 - m ) which we can't use */
- if ( calc_m < 3.0 || calc_m > 64.0 )
- continue;
-
- /*
- * Pick the closest INTEGER (has smallest fractional part).
- * The optimizer should clean this up for us.
- */
- if (( calc_m - ( int ) calc_m ) < m_err ) {
- m_err = calc_m - ( int ) calc_m;
- best_m = ( int ) calc_m;
- best_n = n;
- }
- }
-
- /* 65 - ( 65 - x ) = x */
- *rM = 65 - best_m;
- *rN = 65 - best_n;
- *rP = p;
-
- /* Now all the calculations can be completed */
- VCO = 8.0 * IntRef * best_m / best_n;
- ActualClock = VCO / ( 1 << p );
-
- DebugF( "f_out=%ld f_vco=%.1f n=%d m=%d p=%d\n",
- ActualClock, VCO, *rN, *rM, *rP);
-
- return ActualClock;
-}
-
-void
-TIramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
- RamDacRegRecPtr ramdacReg)
-{
- int i;
- unsigned long status;
-
- /* Here we pass a short, so that we can evaluate a mask too
- * So that the mask is the high byte and the data the low byte
- * Order is important
- */
- TIRESTORE(TIDAC_latch_ctrl);
- TIRESTORE(TIDAC_true_color_ctrl);
- TIRESTORE(TIDAC_multiplex_ctrl);
- TIRESTORE(TIDAC_clock_select);
- TIRESTORE(TIDAC_palette_page);
- TIRESTORE(TIDAC_general_ctrl);
- TIRESTORE(TIDAC_misc_ctrl);
- /* 0x2A & 0x2B are reserved */
- TIRESTORE(TIDAC_key_over_low);
- TIRESTORE(TIDAC_key_over_high);
- TIRESTORE(TIDAC_key_red_low);
- TIRESTORE(TIDAC_key_red_high);
- TIRESTORE(TIDAC_key_green_low);
- TIRESTORE(TIDAC_key_green_high);
- TIRESTORE(TIDAC_key_blue_low);
- TIRESTORE(TIDAC_key_blue_high);
- TIRESTORE(TIDAC_key_ctrl);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_clock_ctrl, 0, 0x30);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_clock_ctrl, 0, 0x38);
- TIRESTORE(TIDAC_clock_ctrl);
- TIRESTORE(TIDAC_sense_test);
- TIRESTORE(TIDAC_ind_curs_ctrl);
-
- /* only restore clocks if they were valid to begin with */
-
- if (ramdacReg->DacRegs[TIDAC_PIXEL_VALID]) {
- /* Reset pixel clock */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0, 0x3c);
-
- /* Restore N, M & P values for pixel clocks */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0,
- ramdacReg->DacRegs[TIDAC_PIXEL_N]);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0,
- ramdacReg->DacRegs[TIDAC_PIXEL_M]);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0,
- ramdacReg->DacRegs[TIDAC_PIXEL_P]);
-
- /* wait for pixel clock to lock */
- i = 1000000;
- do {
- status = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data);
- } while ((!(status & 0x40)) && (--i));
- if (!(status & 0x40)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Pixel clock setup timed out\n");
- return;
- }
- }
-
- if (ramdacReg->DacRegs[TIDAC_LOOP_VALID]) {
- /* Reset loop clock */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0, 0x70);
-
- /* Restore N, M & P values for pixel clocks */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0,
- ramdacReg->DacRegs[TIDAC_LOOP_N]);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0,
- ramdacReg->DacRegs[TIDAC_LOOP_M]);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0,
- ramdacReg->DacRegs[TIDAC_LOOP_P]);
-
- /* wait for loop clock to lock */
- i = 1000000;
- do {
- status = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data);
- } while ((!(status & 0x40)) && (--i));
- if (!(status & 0x40)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Loop clock setup timed out\n");
- return;
- }
- }
-
- /* restore palette */
- (*ramdacPtr->WriteAddress)(pScrn, 0);
-#ifndef NOT_DONE
- for (i=0;i<768;i++)
- (*ramdacPtr->WriteData)(pScrn, ramdacReg->DAC[i]);
-#else
- (*ramdacPtr->WriteData)(pScrn, 0);
- (*ramdacPtr->WriteData)(pScrn, 0);
- (*ramdacPtr->WriteData)(pScrn, 0);
- for (i=0;i<765;i++)
- (*ramdacPtr->WriteData)(pScrn, 0xff);
-#endif
-}
-
-void
-TIramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
- RamDacRegRecPtr ramdacReg)
-{
- int i;
-
- (*ramdacPtr->ReadAddress)(pScrn, 0);
- for (i=0;i<768;i++)
- ramdacReg->DAC[i] = (*ramdacPtr->ReadData)(pScrn);
-
- /* Read back N,M and P values for pixel clock */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0);
- ramdacReg->DacRegs[TIDAC_PIXEL_N] =
- (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x11);
- ramdacReg->DacRegs[TIDAC_PIXEL_M] =
- (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22);
- ramdacReg->DacRegs[TIDAC_PIXEL_P] =
- (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data);
-
- /* Read back N,M and P values for loop clock */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0);
- ramdacReg->DacRegs[TIDAC_LOOP_N] =
- (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x11);
- ramdacReg->DacRegs[TIDAC_LOOP_M] =
- (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22);
- ramdacReg->DacRegs[TIDAC_LOOP_P] =
- (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data);
-
- /* Order is important */
- TISAVE(TIDAC_latch_ctrl);
- TISAVE(TIDAC_true_color_ctrl);
- TISAVE(TIDAC_multiplex_ctrl);
- TISAVE(TIDAC_clock_select);
- TISAVE(TIDAC_palette_page);
- TISAVE(TIDAC_general_ctrl);
- TISAVE(TIDAC_misc_ctrl);
- /* 0x2A & 0x2B are reserved */
- TISAVE(TIDAC_key_over_low);
- TISAVE(TIDAC_key_over_high);
- TISAVE(TIDAC_key_red_low);
- TISAVE(TIDAC_key_red_high);
- TISAVE(TIDAC_key_green_low);
- TISAVE(TIDAC_key_green_high);
- TISAVE(TIDAC_key_blue_low);
- TISAVE(TIDAC_key_blue_high);
- TISAVE(TIDAC_key_ctrl);
- TISAVE(TIDAC_clock_ctrl);
- TISAVE(TIDAC_sense_test);
- TISAVE(TIDAC_ind_curs_ctrl);
-}
-
-RamDacHelperRecPtr
-TIramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
- RamDacHelperRecPtr ramdacHelperPtr = NULL;
- Bool RamDacIsSupported = FALSE;
- int TIramdac_ID = -1;
- int i;
- unsigned char id, rev, rev2, id2;
-
- /* read ID and revision */
- rev = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_rev);
- id = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_id);
-
- /* check if ID and revision are read only */
- (*ramdacPtr->WriteDAC)(pScrn, ~rev, 0, TIDAC_rev);
- (*ramdacPtr->WriteDAC)(pScrn, ~id, 0, TIDAC_id);
- rev2 = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_rev);
- id2 = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_id);
-
- switch (id) {
- case TIDAC_TVP_3030_ID:
- if (id == id2 && rev == rev2) /* check for READ ONLY */
- TIramdac_ID = TI3030_RAMDAC;
- break;
- case TIDAC_TVP_3026_ID:
- if (id == id2 && rev == rev2) /* check for READ ONLY */
- TIramdac_ID = TI3026_RAMDAC;
- break;
- }
-
- (*ramdacPtr->WriteDAC)(pScrn, rev, 0, TIDAC_rev);
- (*ramdacPtr->WriteDAC)(pScrn, id, 0, TIDAC_id);
-
- if (TIramdac_ID == -1) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "Cannot determine TI RAMDAC type, aborting\n");
- return NULL;
- } else {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "Attached RAMDAC is %s\n", TIramdacDeviceInfo[TIramdac_ID&0xFFFF].DeviceName);
- }
-
- for (i=0;ramdacs[i].token != -1;i++) {
- if (ramdacs[i].token == TIramdac_ID)
- RamDacIsSupported = TRUE;
- }
-
- if (!RamDacIsSupported) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "This TI RAMDAC is NOT supported by this driver, aborting\n");
- return NULL;
- }
-
- ramdacHelperPtr = RamDacHelperCreateInfoRec();
- switch (TIramdac_ID) {
- case TI3030_RAMDAC:
- ramdacHelperPtr->SetBpp = TIramdac3030SetBpp;
- ramdacHelperPtr->HWCursorInit = TIramdacHWCursorInit;
- break;
- case TI3026_RAMDAC:
- ramdacHelperPtr->SetBpp = TIramdac3026SetBpp;
- ramdacHelperPtr->HWCursorInit = TIramdacHWCursorInit;
- break;
- }
- ramdacPtr->RamDacType = TIramdac_ID;
- ramdacHelperPtr->RamDacType = TIramdac_ID;
- ramdacHelperPtr->Save = TIramdacSave;
- ramdacHelperPtr->Restore = TIramdacRestore;
-
- return ramdacHelperPtr;
-}
-
-void
-TIramdac3026SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
-{
- switch (pScrn->bitsPerPixel) {
- case 32:
- /* order is important */
- ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x46;
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x5c;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
- ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
- ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C;
- /* 0x2A & 0x2B are reserved */
- ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
- ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
- if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x06;
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C;
- ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x01;
- }
- ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
- break;
- case 24:
- /* order is important */
- ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x56;
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x58;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x25;
- ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
- ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
- /* 0x2A & 0x2B are reserved */
- ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
- ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
- ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
- break;
- case 16:
- /* order is important */
-#if 0
- /* Matrox driver uses this */
- ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x07;
-#else
- ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
-#endif
- if (pScrn->depth == 16) {
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x45;
- } else {
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x44;
- }
-#if 0
- /* Matrox driver uses this */
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x50;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x15;
- ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
- ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
-#else
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x54;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
- ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
- ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
-#endif
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
- /* 0x2A & 0x2B are reserved */
- ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
- ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
- ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
- break;
- case 8:
- /* order is important */
- ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x80;
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x4c;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
- ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
- ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x1C;
- /* 0x2A & 0x2B are reserved */
- ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_low] = 0x00;
- ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
- ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x00;
- ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
- ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
- break;
- }
-}
-
-void
-TIramdac3030SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
-{
- switch (pScrn->bitsPerPixel) {
- case 32:
- /* order is important */
- ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x46;
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x5D;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
- ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
- ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C;
- /* 0x2A & 0x2B are reserved */
- ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
- ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
- if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x06;
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C;
- ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x01;
- }
- ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
- break;
- case 24:
- /* order is important */
- ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x56;
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x58;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x25;
- ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
- ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
- /* 0x2A & 0x2B are reserved */
- ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
- ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
- ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
- break;
- case 16:
- /* order is important */
-#if 0
- /* Matrox driver uses this */
- ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x07;
-#else
- ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
-#endif
- if (pScrn->depth == 16) {
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x45;
- } else {
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x44;
- }
-#if 0
- /* Matrox driver uses this */
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x50;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x15;
- ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
- ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
-#else
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x55;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x85;
- ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
- ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
-#endif
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
- /* 0x2A & 0x2B are reserved */
- ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
- ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
- ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
- break;
- case 8:
- /* order is important */
- ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x80;
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x4d;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
- ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
- ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x1C;
- /* 0x2A & 0x2B are reserved */
- ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_low] = 0x00;
- ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
- ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x00;
- ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
- ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
- break;
- }
-}
-
-static void
-TIramdacShowCursor(ScrnInfoPtr pScrn)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- /* Enable cursor - X11 mode */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0, 0x03);
-}
-
-static void
-TIramdacHideCursor(ScrnInfoPtr pScrn)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- /* Disable cursor - X11 mode */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0, 0x00);
-}
-
-static void
-TIramdacSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- x += 64;
- y += 64;
-
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_XLOW, 0, x & 0xff);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_XHIGH, 0, (x >> 8) & 0x0f);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_YLOW, 0, y & 0xff);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_YHIGH, 0, (y >> 8) & 0x0f);
-}
-
-static void
-TIramdacSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- /* Background color */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_WRITE_ADDR, 0, 1);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((bg&0x00ff0000) >> 16));
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((bg&0x0000ff00) >> 8));
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, (bg&0x000000ff) );
-
- /* Foreground color */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_WRITE_ADDR, 0, 2);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((fg&0x00ff0000) >> 16));
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((fg&0x0000ff00) >> 8));
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, (fg&0x000000ff) );
-}
-
-static void
-TIramdacLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
- int i = 1024;
-
- /* reset A9,A8 */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0, 0x00);
- /* reset cursor RAM load address A7..A0 */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_INDEX, 0x00, 0x00);
-
- while(i--) {
- /* NOT_DONE: might need a delay here */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_RAM_DATA, 0, *(src++));
- }
-}
-
-static Bool
-TIramdacUseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
-{
- return TRUE;
-}
-
-void
-TIramdacHWCursorInit(xf86CursorInfoPtr infoPtr)
-{
- infoPtr->MaxWidth = 64;
- infoPtr->MaxHeight = 64;
- infoPtr->Flags = HARDWARE_CURSOR_BIT_ORDER_MSBFIRST |
- HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
- HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED;
- infoPtr->SetCursorColors = TIramdacSetCursorColors;
- infoPtr->SetCursorPosition = TIramdacSetCursorPosition;
- infoPtr->LoadCursorImage = TIramdacLoadCursorImage;
- infoPtr->HideCursor = TIramdacHideCursor;
- infoPtr->ShowCursor = TIramdacShowCursor;
- infoPtr->UseHWCursor = TIramdacUseHWCursor;
-}
-
-void TIramdacLoadPalette(
- ScrnInfoPtr pScrn,
- int numColors,
- int *indices,
- LOCO *colors,
- VisualPtr pVisual
-){
- RamDacRecPtr hwp = RAMDACSCRPTR(pScrn);
- int i, index, shift;
-
- if (pScrn->depth == 16) {
- for(i = 0; i < numColors; i++) {
- index = indices[i];
- (*hwp->WriteAddress)(pScrn, index << 2);
- (*hwp->WriteData)(pScrn, colors[index >> 1].red);
- (*hwp->WriteData)(pScrn, colors[index].green);
- (*hwp->WriteData)(pScrn, colors[index >> 1].blue);
-
- if(index <= 31) {
- (*hwp->WriteAddress)(pScrn, index << 3);
- (*hwp->WriteData)(pScrn, colors[index].red);
- (*hwp->WriteData)(pScrn, colors[(index << 1) + 1].green);
- (*hwp->WriteData)(pScrn, colors[index].blue);
- }
- }
-} else {
- shift = (pScrn->depth == 15) ? 3 : 0;
-
- for(i = 0; i < numColors; i++) {
- index = indices[i];
- (*hwp->WriteAddress)(pScrn, index << shift);
- (*hwp->WriteData)(pScrn, colors[index].red);
- (*hwp->WriteData)(pScrn, colors[index].green);
- (*hwp->WriteData)(pScrn, colors[index].blue);
- }
-}
-}
-
-TIramdacLoadPaletteProc *TIramdacLoadPaletteWeak(void) {
- return TIramdacLoadPalette;
-}
+/*
+ * Copyright 1998 by Alan Hourihane, Wigan, England.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
+ *
+ * Modified from IBM.c to support TI RAMDAC routines
+ * by Jens Owen, <jens@tungstengraphics.com>.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include "xf86Cursor.h"
+
+#define INIT_TI_RAMDAC_INFO
+#include "TIPriv.h"
+#include "xf86RamDacPriv.h"
+
+/* The following values are in kHz */
+#define TI_MIN_VCO_FREQ 110000
+#define TI_MAX_VCO_FREQ 220000
+
+unsigned long
+TIramdacCalculateMNPForClock(unsigned long RefClock, /* In 100Hz units */
+ unsigned long ReqClock, /* In 100Hz units */
+ char IsPixClock, /* boolean, is this the pixel or the sys clock */
+ unsigned long MinClock, /* Min VCO rating */
+ unsigned long MaxClock, /* Max VCO rating */
+ unsigned long *rM, /* M Out */
+ unsigned long *rN, /* N Out */
+ unsigned long *rP /* Min P In, P Out */
+ )
+{
+ unsigned long n, p;
+ unsigned long best_m = 0, best_n = 0;
+ double VCO, IntRef = (double) RefClock;
+ double m_err, inc_m, calc_m;
+ unsigned long ActualClock;
+
+ /* Make sure that MinClock <= ReqClock <= MaxClock */
+ if (ReqClock < MinClock)
+ ReqClock = MinClock;
+ if (ReqClock > MaxClock)
+ ReqClock = MaxClock;
+
+ /*
+ * ActualClock = VCO / 2 ^ p
+ * Choose p so that TI_MIN_VCO_FREQ <= VCO <= TI_MAX_VCO_FREQ
+ * Note that since TI_MAX_VCO_FREQ = 2 * TI_MIN_VCO_FREQ
+ * we don't have to bother checking for this maximum limit.
+ */
+ VCO = (double) ReqClock;
+ for (p = 0; p < 3 && VCO < TI_MIN_VCO_FREQ; (p)++)
+ VCO *= 2.0;
+
+ /*
+ * We avoid doing multiplications by ( 65 - n ),
+ * and add an increment instead - this keeps any error small.
+ */
+ inc_m = VCO / (IntRef * 8.0);
+
+ /* Initial value of calc_m for the loop */
+ calc_m = inc_m + inc_m + inc_m;
+
+ /* Initial amount of error for an integer - impossibly large */
+ m_err = 2.0;
+
+ /* Search for the closest INTEGER value of ( 65 - m ) */
+ for (n = 3; n <= 25; (n)++, calc_m += inc_m) {
+
+ /* Ignore values of ( 65 - m ) which we can't use */
+ if (calc_m < 3.0 || calc_m > 64.0)
+ continue;
+
+ /*
+ * Pick the closest INTEGER (has smallest fractional part).
+ * The optimizer should clean this up for us.
+ */
+ if ((calc_m - (int) calc_m) < m_err) {
+ m_err = calc_m - (int) calc_m;
+ best_m = (int) calc_m;
+ best_n = n;
+ }
+ }
+
+ /* 65 - ( 65 - x ) = x */
+ *rM = 65 - best_m;
+ *rN = 65 - best_n;
+ *rP = p;
+
+ /* Now all the calculations can be completed */
+ VCO = 8.0 * IntRef * best_m / best_n;
+ ActualClock = VCO / (1 << p);
+
+ DebugF("f_out=%ld f_vco=%.1f n=%d m=%d p=%d\n",
+ ActualClock, VCO, *rN, *rM, *rP);
+
+ return ActualClock;
+}
+
+void
+TIramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
+ RamDacRegRecPtr ramdacReg)
+{
+ int i;
+ unsigned long status;
+
+ /* Here we pass a short, so that we can evaluate a mask too
+ * So that the mask is the high byte and the data the low byte
+ * Order is important
+ */
+ TIRESTORE(TIDAC_latch_ctrl);
+ TIRESTORE(TIDAC_true_color_ctrl);
+ TIRESTORE(TIDAC_multiplex_ctrl);
+ TIRESTORE(TIDAC_clock_select);
+ TIRESTORE(TIDAC_palette_page);
+ TIRESTORE(TIDAC_general_ctrl);
+ TIRESTORE(TIDAC_misc_ctrl);
+ /* 0x2A & 0x2B are reserved */
+ TIRESTORE(TIDAC_key_over_low);
+ TIRESTORE(TIDAC_key_over_high);
+ TIRESTORE(TIDAC_key_red_low);
+ TIRESTORE(TIDAC_key_red_high);
+ TIRESTORE(TIDAC_key_green_low);
+ TIRESTORE(TIDAC_key_green_high);
+ TIRESTORE(TIDAC_key_blue_low);
+ TIRESTORE(TIDAC_key_blue_high);
+ TIRESTORE(TIDAC_key_ctrl);
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_clock_ctrl, 0, 0x30);
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_clock_ctrl, 0, 0x38);
+ TIRESTORE(TIDAC_clock_ctrl);
+ TIRESTORE(TIDAC_sense_test);
+ TIRESTORE(TIDAC_ind_curs_ctrl);
+
+ /* only restore clocks if they were valid to begin with */
+
+ if (ramdacReg->DacRegs[TIDAC_PIXEL_VALID]) {
+ /* Reset pixel clock */
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_pll_addr, 0, 0x22);
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_pll_pixel_data, 0, 0x3c);
+
+ /* Restore N, M & P values for pixel clocks */
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_pll_addr, 0, 0);
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_pll_pixel_data, 0,
+ ramdacReg->DacRegs[TIDAC_PIXEL_N]);
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_pll_pixel_data, 0,
+ ramdacReg->DacRegs[TIDAC_PIXEL_M]);
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_pll_pixel_data, 0,
+ ramdacReg->DacRegs[TIDAC_PIXEL_P]);
+
+ /* wait for pixel clock to lock */
+ i = 1000000;
+ do {
+ status = (*ramdacPtr->ReadDAC) (pScrn, TIDAC_pll_pixel_data);
+ } while ((!(status & 0x40)) && (--i));
+ if (!(status & 0x40)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Pixel clock setup timed out\n");
+ return;
+ }
+ }
+
+ if (ramdacReg->DacRegs[TIDAC_LOOP_VALID]) {
+ /* Reset loop clock */
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_pll_addr, 0, 0x22);
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_pll_loop_data, 0, 0x70);
+
+ /* Restore N, M & P values for pixel clocks */
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_pll_addr, 0, 0);
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_pll_loop_data, 0,
+ ramdacReg->DacRegs[TIDAC_LOOP_N]);
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_pll_loop_data, 0,
+ ramdacReg->DacRegs[TIDAC_LOOP_M]);
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_pll_loop_data, 0,
+ ramdacReg->DacRegs[TIDAC_LOOP_P]);
+
+ /* wait for loop clock to lock */
+ i = 1000000;
+ do {
+ status = (*ramdacPtr->ReadDAC) (pScrn, TIDAC_pll_loop_data);
+ } while ((!(status & 0x40)) && (--i));
+ if (!(status & 0x40)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Loop clock setup timed out\n");
+ return;
+ }
+ }
+
+ /* restore palette */
+ (*ramdacPtr->WriteAddress) (pScrn, 0);
+#ifndef NOT_DONE
+ for (i = 0; i < 768; i++)
+ (*ramdacPtr->WriteData) (pScrn, ramdacReg->DAC[i]);
+#else
+ (*ramdacPtr->WriteData) (pScrn, 0);
+ (*ramdacPtr->WriteData) (pScrn, 0);
+ (*ramdacPtr->WriteData) (pScrn, 0);
+ for (i = 0; i < 765; i++)
+ (*ramdacPtr->WriteData) (pScrn, 0xff);
+#endif
+}
+
+void
+TIramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
+ RamDacRegRecPtr ramdacReg)
+{
+ int i;
+
+ (*ramdacPtr->ReadAddress) (pScrn, 0);
+ for (i = 0; i < 768; i++)
+ ramdacReg->DAC[i] = (*ramdacPtr->ReadData) (pScrn);
+
+ /* Read back N,M and P values for pixel clock */
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_pll_addr, 0, 0);
+ ramdacReg->DacRegs[TIDAC_PIXEL_N] =
+ (*ramdacPtr->ReadDAC) (pScrn, TIDAC_pll_pixel_data);
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_pll_addr, 0, 0x11);
+ ramdacReg->DacRegs[TIDAC_PIXEL_M] =
+ (*ramdacPtr->ReadDAC) (pScrn, TIDAC_pll_pixel_data);
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_pll_addr, 0, 0x22);
+ ramdacReg->DacRegs[TIDAC_PIXEL_P] =
+ (*ramdacPtr->ReadDAC) (pScrn, TIDAC_pll_pixel_data);
+
+ /* Read back N,M and P values for loop clock */
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_pll_addr, 0, 0);
+ ramdacReg->DacRegs[TIDAC_LOOP_N] =
+ (*ramdacPtr->ReadDAC) (pScrn, TIDAC_pll_loop_data);
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_pll_addr, 0, 0x11);
+ ramdacReg->DacRegs[TIDAC_LOOP_M] =
+ (*ramdacPtr->ReadDAC) (pScrn, TIDAC_pll_loop_data);
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_pll_addr, 0, 0x22);
+ ramdacReg->DacRegs[TIDAC_LOOP_P] =
+ (*ramdacPtr->ReadDAC) (pScrn, TIDAC_pll_loop_data);
+
+ /* Order is important */
+ TISAVE(TIDAC_latch_ctrl);
+ TISAVE(TIDAC_true_color_ctrl);
+ TISAVE(TIDAC_multiplex_ctrl);
+ TISAVE(TIDAC_clock_select);
+ TISAVE(TIDAC_palette_page);
+ TISAVE(TIDAC_general_ctrl);
+ TISAVE(TIDAC_misc_ctrl);
+ /* 0x2A & 0x2B are reserved */
+ TISAVE(TIDAC_key_over_low);
+ TISAVE(TIDAC_key_over_high);
+ TISAVE(TIDAC_key_red_low);
+ TISAVE(TIDAC_key_red_high);
+ TISAVE(TIDAC_key_green_low);
+ TISAVE(TIDAC_key_green_high);
+ TISAVE(TIDAC_key_blue_low);
+ TISAVE(TIDAC_key_blue_high);
+ TISAVE(TIDAC_key_ctrl);
+ TISAVE(TIDAC_clock_ctrl);
+ TISAVE(TIDAC_sense_test);
+ TISAVE(TIDAC_ind_curs_ctrl);
+}
+
+RamDacHelperRecPtr
+TIramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+ RamDacHelperRecPtr ramdacHelperPtr = NULL;
+ Bool RamDacIsSupported = FALSE;
+ int TIramdac_ID = -1;
+ int i;
+ unsigned char id, rev, rev2, id2;
+
+ /* read ID and revision */
+ rev = (*ramdacPtr->ReadDAC) (pScrn, TIDAC_rev);
+ id = (*ramdacPtr->ReadDAC) (pScrn, TIDAC_id);
+
+ /* check if ID and revision are read only */
+ (*ramdacPtr->WriteDAC) (pScrn, ~rev, 0, TIDAC_rev);
+ (*ramdacPtr->WriteDAC) (pScrn, ~id, 0, TIDAC_id);
+ rev2 = (*ramdacPtr->ReadDAC) (pScrn, TIDAC_rev);
+ id2 = (*ramdacPtr->ReadDAC) (pScrn, TIDAC_id);
+
+ switch (id) {
+ case TIDAC_TVP_3030_ID:
+ if (id == id2 && rev == rev2) /* check for READ ONLY */
+ TIramdac_ID = TI3030_RAMDAC;
+ break;
+ case TIDAC_TVP_3026_ID:
+ if (id == id2 && rev == rev2) /* check for READ ONLY */
+ TIramdac_ID = TI3026_RAMDAC;
+ break;
+ }
+
+ (*ramdacPtr->WriteDAC) (pScrn, rev, 0, TIDAC_rev);
+ (*ramdacPtr->WriteDAC) (pScrn, id, 0, TIDAC_id);
+
+ if (TIramdac_ID == -1) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Cannot determine TI RAMDAC type, aborting\n");
+ return NULL;
+ }
+ else {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Attached RAMDAC is %s\n",
+ TIramdacDeviceInfo[TIramdac_ID & 0xFFFF].DeviceName);
+ }
+
+ for (i = 0; ramdacs[i].token != -1; i++) {
+ if (ramdacs[i].token == TIramdac_ID)
+ RamDacIsSupported = TRUE;
+ }
+
+ if (!RamDacIsSupported) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "This TI RAMDAC is NOT supported by this driver, aborting\n");
+ return NULL;
+ }
+
+ ramdacHelperPtr = RamDacHelperCreateInfoRec();
+ switch (TIramdac_ID) {
+ case TI3030_RAMDAC:
+ ramdacHelperPtr->SetBpp = TIramdac3030SetBpp;
+ ramdacHelperPtr->HWCursorInit = TIramdacHWCursorInit;
+ break;
+ case TI3026_RAMDAC:
+ ramdacHelperPtr->SetBpp = TIramdac3026SetBpp;
+ ramdacHelperPtr->HWCursorInit = TIramdacHWCursorInit;
+ break;
+ }
+ ramdacPtr->RamDacType = TIramdac_ID;
+ ramdacHelperPtr->RamDacType = TIramdac_ID;
+ ramdacHelperPtr->Save = TIramdacSave;
+ ramdacHelperPtr->Restore = TIramdacRestore;
+
+ return ramdacHelperPtr;
+}
+
+void
+TIramdac3026SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
+{
+ switch (pScrn->bitsPerPixel) {
+ case 32:
+ /* order is important */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x46;
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x5c;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x01;
+ }
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ case 24:
+ /* order is important */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x56;
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x58;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x25;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ case 16:
+ /* order is important */
+#if 0
+ /* Matrox driver uses this */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x07;
+#else
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+#endif
+ if (pScrn->depth == 16) {
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x45;
+ }
+ else {
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x44;
+ }
+#if 0
+ /* Matrox driver uses this */
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x50;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x15;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
+#else
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x54;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
+#endif
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ case 8:
+ /* order is important */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x80;
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x4c;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x1C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x00;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ }
+}
+
+void
+TIramdac3030SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
+{
+ switch (pScrn->bitsPerPixel) {
+ case 32:
+ /* order is important */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x46;
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x5D;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x01;
+ }
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ case 24:
+ /* order is important */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x56;
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x58;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x25;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ case 16:
+ /* order is important */
+#if 0
+ /* Matrox driver uses this */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x07;
+#else
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+#endif
+ if (pScrn->depth == 16) {
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x45;
+ }
+ else {
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x44;
+ }
+#if 0
+ /* Matrox driver uses this */
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x50;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x15;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
+#else
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x55;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x85;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
+#endif
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ case 8:
+ /* order is important */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x80;
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x4d;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x1C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x00;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ }
+}
+
+static void
+TIramdacShowCursor(ScrnInfoPtr pScrn)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Enable cursor - X11 mode */
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_ind_curs_ctrl, 0, 0x03);
+}
+
+static void
+TIramdacHideCursor(ScrnInfoPtr pScrn)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Disable cursor - X11 mode */
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_ind_curs_ctrl, 0, 0x00);
+}
+
+static void
+TIramdacSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ x += 64;
+ y += 64;
+
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_CURS_XLOW, 0, x & 0xff);
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_CURS_XHIGH, 0, (x >> 8) & 0x0f);
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_CURS_YLOW, 0, y & 0xff);
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_CURS_YHIGH, 0, (y >> 8) & 0x0f);
+}
+
+static void
+TIramdacSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Background color */
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_CURS_WRITE_ADDR, 0, 1);
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_CURS_COLOR, 0,
+ ((bg & 0x00ff0000) >> 16));
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_CURS_COLOR, 0,
+ ((bg & 0x0000ff00) >> 8));
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_CURS_COLOR, 0, (bg & 0x000000ff));
+
+ /* Foreground color */
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_CURS_WRITE_ADDR, 0, 2);
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_CURS_COLOR, 0,
+ ((fg & 0x00ff0000) >> 16));
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_CURS_COLOR, 0,
+ ((fg & 0x0000ff00) >> 8));
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_CURS_COLOR, 0, (fg & 0x000000ff));
+}
+
+static void
+TIramdacLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+ int i = 1024;
+
+ /* reset A9,A8 */
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_ind_curs_ctrl, 0, 0x00);
+ /* reset cursor RAM load address A7..A0 */
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_INDEX, 0x00, 0x00);
+
+ while (i--) {
+ /* NOT_DONE: might need a delay here */
+ (*ramdacPtr->WriteDAC) (pScrn, TIDAC_CURS_RAM_DATA, 0, *(src++));
+ }
+}
+
+static Bool
+TIramdacUseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
+{
+ return TRUE;
+}
+
+void
+TIramdacHWCursorInit(xf86CursorInfoPtr infoPtr)
+{
+ infoPtr->MaxWidth = 64;
+ infoPtr->MaxHeight = 64;
+ infoPtr->Flags = HARDWARE_CURSOR_BIT_ORDER_MSBFIRST |
+ HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
+ HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED;
+ infoPtr->SetCursorColors = TIramdacSetCursorColors;
+ infoPtr->SetCursorPosition = TIramdacSetCursorPosition;
+ infoPtr->LoadCursorImage = TIramdacLoadCursorImage;
+ infoPtr->HideCursor = TIramdacHideCursor;
+ infoPtr->ShowCursor = TIramdacShowCursor;
+ infoPtr->UseHWCursor = TIramdacUseHWCursor;
+}
+
+void
+TIramdacLoadPalette(ScrnInfoPtr pScrn,
+ int numColors,
+ int *indices, LOCO * colors, VisualPtr pVisual)
+{
+ RamDacRecPtr hwp = RAMDACSCRPTR(pScrn);
+ int i, index, shift;
+
+ if (pScrn->depth == 16) {
+ for (i = 0; i < numColors; i++) {
+ index = indices[i];
+ (*hwp->WriteAddress) (pScrn, index << 2);
+ (*hwp->WriteData) (pScrn, colors[index >> 1].red);
+ (*hwp->WriteData) (pScrn, colors[index].green);
+ (*hwp->WriteData) (pScrn, colors[index >> 1].blue);
+
+ if (index <= 31) {
+ (*hwp->WriteAddress) (pScrn, index << 3);
+ (*hwp->WriteData) (pScrn, colors[index].red);
+ (*hwp->WriteData) (pScrn, colors[(index << 1) + 1].green);
+ (*hwp->WriteData) (pScrn, colors[index].blue);
+ }
+ }
+ }
+ else {
+ shift = (pScrn->depth == 15) ? 3 : 0;
+
+ for (i = 0; i < numColors; i++) {
+ index = indices[i];
+ (*hwp->WriteAddress) (pScrn, index << shift);
+ (*hwp->WriteData) (pScrn, colors[index].red);
+ (*hwp->WriteData) (pScrn, colors[index].green);
+ (*hwp->WriteData) (pScrn, colors[index].blue);
+ }
+ }
+}
+
+TIramdacLoadPaletteProc *
+TIramdacLoadPaletteWeak(void)
+{
+ return TIramdacLoadPalette;
+}
diff --git a/xorg-server/hw/xfree86/ramdac/TI.h b/xorg-server/hw/xfree86/ramdac/TI.h
index f5499f903..3969ee71d 100644
--- a/xorg-server/hw/xfree86/ramdac/TI.h
+++ b/xorg-server/hw/xfree86/ramdac/TI.h
@@ -1,21 +1,36 @@
#include <xf86RamDac.h>
-extern _X_EXPORT unsigned long TIramdacCalculateMNPForClock(unsigned long RefClock,
- unsigned long ReqClock, char IsPixClock, unsigned long MinClock,
- unsigned long MaxClock, unsigned long *rM, unsigned long *rN,
- unsigned long *rP);
-extern _X_EXPORT RamDacHelperRecPtr TIramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs);
-extern _X_EXPORT void TIramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr RamDacRec, RamDacRegRecPtr RamDacRegRec);
-extern _X_EXPORT void TIramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr RamDacRec, RamDacRegRecPtr RamDacRegRec);
-extern _X_EXPORT void TIramdac3026SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr RamDacRegRec);
-extern _X_EXPORT void TIramdac3030SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr RamDacRegRec);
+extern _X_EXPORT unsigned long TIramdacCalculateMNPForClock(unsigned long
+ RefClock,
+ unsigned long
+ ReqClock,
+ char IsPixClock,
+ unsigned long
+ MinClock,
+ unsigned long
+ MaxClock,
+ unsigned long *rM,
+ unsigned long *rN,
+ unsigned long *rP);
+extern _X_EXPORT RamDacHelperRecPtr TIramdacProbe(ScrnInfoPtr pScrn,
+ RamDacSupportedInfoRecPtr
+ ramdacs);
+extern _X_EXPORT void TIramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr RamDacRec,
+ RamDacRegRecPtr RamDacRegRec);
+extern _X_EXPORT void TIramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr RamDacRec,
+ RamDacRegRecPtr RamDacRegRec);
+extern _X_EXPORT void TIramdac3026SetBpp(ScrnInfoPtr pScrn,
+ RamDacRegRecPtr RamDacRegRec);
+extern _X_EXPORT void TIramdac3030SetBpp(ScrnInfoPtr pScrn,
+ RamDacRegRecPtr RamDacRegRec);
extern _X_EXPORT void TIramdacHWCursorInit(xf86CursorInfoPtr infoPtr);
-extern _X_EXPORT void TIramdacLoadPalette( ScrnInfoPtr pScrn, int numColors, int *indices,
- LOCO *colors, VisualPtr pVisual);
+extern _X_EXPORT void TIramdacLoadPalette(ScrnInfoPtr pScrn, int numColors,
+ int *indices, LOCO * colors,
+ VisualPtr pVisual);
typedef void TIramdacLoadPaletteProc(ScrnInfoPtr, int, int *, LOCO *,
- VisualPtr);
+ VisualPtr);
extern _X_EXPORT TIramdacLoadPaletteProc *TIramdacLoadPaletteWeak(void);
#define TI3030_RAMDAC (VENDOR_TI << 16) | 0x00
@@ -86,6 +101,6 @@ extern _X_EXPORT TIramdacLoadPaletteProc *TIramdacLoadPaletteWeak(void);
#define TIDAC_sw_reset 0xff
-/* Constants */
+/* Constants */
#define TIDAC_TVP_3026_ID 0x26
#define TIDAC_TVP_3030_ID 0x30
diff --git a/xorg-server/hw/xfree86/ramdac/xf86Cursor.c b/xorg-server/hw/xfree86/ramdac/xf86Cursor.c
index 1e0f7e0b7..678d2be5c 100644
--- a/xorg-server/hw/xfree86/ramdac/xf86Cursor.c
+++ b/xorg-server/hw/xfree86/ramdac/xf86Cursor.c
@@ -30,46 +30,44 @@ static Bool xf86DeviceCursorInitialize(DeviceIntPtr, ScreenPtr);
static void xf86DeviceCursorCleanup(DeviceIntPtr, ScreenPtr);
static miPointerSpriteFuncRec xf86CursorSpriteFuncs = {
- xf86CursorRealizeCursor,
- xf86CursorUnrealizeCursor,
- xf86CursorSetCursor,
- xf86CursorMoveCursor,
- xf86DeviceCursorInitialize,
- xf86DeviceCursorCleanup
+ xf86CursorRealizeCursor,
+ xf86CursorUnrealizeCursor,
+ xf86CursorSetCursor,
+ xf86CursorMoveCursor,
+ xf86DeviceCursorInitialize,
+ xf86DeviceCursorCleanup
};
/* Screen functions */
static void xf86CursorInstallColormap(ColormapPtr);
-static void xf86CursorRecolorCursor(DeviceIntPtr pDev, ScreenPtr, CursorPtr, Bool);
+static void xf86CursorRecolorCursor(DeviceIntPtr pDev, ScreenPtr, CursorPtr,
+ Bool);
static Bool xf86CursorCloseScreen(int, ScreenPtr);
-static void xf86CursorQueryBestSize(int, unsigned short*, unsigned short*,
- ScreenPtr);
+static void xf86CursorQueryBestSize(int, unsigned short *, unsigned short *,
+ ScreenPtr);
/* ScrnInfoRec functions */
static void xf86CursorEnableDisableFBAccess(int, Bool);
-static Bool xf86CursorSwitchMode(int, DisplayModePtr,int);
+static Bool xf86CursorSwitchMode(int, DisplayModePtr, int);
Bool
-xf86InitCursor(
- ScreenPtr pScreen,
- xf86CursorInfoPtr infoPtr
-)
+xf86InitCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
xf86CursorScreenPtr ScreenPriv;
miPointerScreenPtr PointPriv;
if (!xf86InitHardwareCursor(pScreen, infoPtr))
- return FALSE;
+ return FALSE;
if (!dixRegisterPrivateKey(&xf86CursorScreenKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
+ return FALSE;
ScreenPriv = calloc(1, sizeof(xf86CursorScreenRec));
if (!ScreenPriv)
- return FALSE;
+ return FALSE;
dixSetPrivate(&pScreen->devPrivates, xf86CursorScreenKey, ScreenPriv);
@@ -88,31 +86,31 @@ xf86InitCursor(
pScreen->RecolorCursor = xf86CursorRecolorCursor;
if ((infoPtr->pScrn->bitsPerPixel == 8) &&
- !(infoPtr->Flags & HARDWARE_CURSOR_TRUECOLOR_AT_8BPP)) {
- ScreenPriv->InstallColormap = pScreen->InstallColormap;
- pScreen->InstallColormap = xf86CursorInstallColormap;
- ScreenPriv->PalettedCursor = TRUE;
+ !(infoPtr->Flags & HARDWARE_CURSOR_TRUECOLOR_AT_8BPP)) {
+ ScreenPriv->InstallColormap = pScreen->InstallColormap;
+ pScreen->InstallColormap = xf86CursorInstallColormap;
+ ScreenPriv->PalettedCursor = TRUE;
}
PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
ScreenPriv->showTransparent = PointPriv->showTransparent;
if (infoPtr->Flags & HARDWARE_CURSOR_SHOW_TRANSPARENT)
- PointPriv->showTransparent = TRUE;
+ PointPriv->showTransparent = TRUE;
else
- PointPriv->showTransparent = FALSE;
+ PointPriv->showTransparent = FALSE;
ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
PointPriv->spriteFuncs = &xf86CursorSpriteFuncs;
ScreenPriv->EnableDisableFBAccess = pScrn->EnableDisableFBAccess;
ScreenPriv->SwitchMode = pScrn->SwitchMode;
-
+
ScreenPriv->ForceHWCursorCount = 0;
ScreenPriv->HWCursorForced = FALSE;
pScrn->EnableDisableFBAccess = xf86CursorEnableDisableFBAccess;
if (pScrn->SwitchMode)
- pScrn->SwitchMode = xf86CursorSwitchMode;
+ pScrn->SwitchMode = xf86CursorSwitchMode;
return TRUE;
}
@@ -123,22 +121,24 @@ static Bool
xf86CursorCloseScreen(int i, ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, miPointerScreenKey);
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
+ miPointerScreenPtr PointPriv =
+ (miPointerScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ miPointerScreenKey);
+ xf86CursorScreenPtr ScreenPriv =
+ (xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86CursorScreenKey);
if (ScreenPriv->isUp && pScrn->vtSema)
- xf86SetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y);
+ xf86SetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y);
if (ScreenPriv->CurrentCursor)
- FreeCursor(ScreenPriv->CurrentCursor, None);
+ FreeCursor(ScreenPriv->CurrentCursor, None);
pScreen->CloseScreen = ScreenPriv->CloseScreen;
pScreen->QueryBestSize = ScreenPriv->QueryBestSize;
pScreen->RecolorCursor = ScreenPriv->RecolorCursor;
if (ScreenPriv->InstallColormap)
- pScreen->InstallColormap = ScreenPriv->InstallColormap;
+ pScreen->InstallColormap = ScreenPriv->InstallColormap;
PointPriv->spriteFuncs = ScreenPriv->spriteFuncs;
PointPriv->showTransparent = ScreenPriv->showTransparent;
@@ -149,92 +149,90 @@ xf86CursorCloseScreen(int i, ScreenPtr pScreen)
free(ScreenPriv->transparentData);
free(ScreenPriv);
- return (*pScreen->CloseScreen)(i, pScreen);
+ return (*pScreen->CloseScreen) (i, pScreen);
}
static void
-xf86CursorQueryBestSize(
- int class,
- unsigned short *width,
- unsigned short *height,
- ScreenPtr pScreen)
+xf86CursorQueryBestSize(int class,
+ unsigned short *width,
+ unsigned short *height, ScreenPtr pScreen)
{
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
+ xf86CursorScreenPtr ScreenPriv =
+ (xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86CursorScreenKey);
if (class == CursorShape) {
- if(*width > ScreenPriv->CursorInfoPtr->MaxWidth)
- *width = ScreenPriv->CursorInfoPtr->MaxWidth;
- if(*height > ScreenPriv->CursorInfoPtr->MaxHeight)
- *height = ScreenPriv->CursorInfoPtr->MaxHeight;
- } else
- (*ScreenPriv->QueryBestSize)(class, width, height, pScreen);
+ if (*width > ScreenPriv->CursorInfoPtr->MaxWidth)
+ *width = ScreenPriv->CursorInfoPtr->MaxWidth;
+ if (*height > ScreenPriv->CursorInfoPtr->MaxHeight)
+ *height = ScreenPriv->CursorInfoPtr->MaxHeight;
+ }
+ else
+ (*ScreenPriv->QueryBestSize) (class, width, height, pScreen);
}
static void
xf86CursorInstallColormap(ColormapPtr pMap)
{
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pMap->pScreen->devPrivates, xf86CursorScreenKey);
+ xf86CursorScreenPtr ScreenPriv =
+ (xf86CursorScreenPtr) dixLookupPrivate(&pMap->pScreen->devPrivates,
+ xf86CursorScreenKey);
ScreenPriv->pInstalledMap = pMap;
- (*ScreenPriv->InstallColormap)(pMap);
+ (*ScreenPriv->InstallColormap) (pMap);
}
static void
-xf86CursorRecolorCursor(
- DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCurs,
- Bool displayed)
+xf86CursorRecolorCursor(DeviceIntPtr pDev,
+ ScreenPtr pScreen, CursorPtr pCurs, Bool displayed)
{
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
+ xf86CursorScreenPtr ScreenPriv =
+ (xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86CursorScreenKey);
if (!displayed)
- return;
+ return;
if (ScreenPriv->SWCursor)
- (*ScreenPriv->RecolorCursor)(pDev, pScreen, pCurs, displayed);
+ (*ScreenPriv->RecolorCursor) (pDev, pScreen, pCurs, displayed);
else
- xf86RecolorCursor(pScreen, pCurs, displayed);
+ xf86RecolorCursor(pScreen, pCurs, displayed);
}
/***** ScrnInfoRec functions *********/
static void
-xf86CursorEnableDisableFBAccess(
- int index,
- Bool enable)
+xf86CursorEnableDisableFBAccess(int index, Bool enable)
{
DeviceIntPtr pDev = inputInfo.pointer;
ScreenPtr pScreen = screenInfo.screens[index];
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
+ xf86CursorScreenPtr ScreenPriv =
+ (xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86CursorScreenKey);
if (!enable && ScreenPriv->CurrentCursor != NullCursor) {
CursorPtr currentCursor = ScreenPriv->CurrentCursor;
+
xf86CursorSetCursor(pDev, pScreen, NullCursor, ScreenPriv->x,
- ScreenPriv->y);
+ ScreenPriv->y);
ScreenPriv->isUp = FALSE;
- ScreenPriv->SWCursor = TRUE;
- ScreenPriv->SavedCursor = currentCursor;
+ ScreenPriv->SWCursor = TRUE;
+ ScreenPriv->SavedCursor = currentCursor;
}
if (ScreenPriv->EnableDisableFBAccess)
- (*ScreenPriv->EnableDisableFBAccess)(index, enable);
-
- if (enable && ScreenPriv->SavedCursor)
- {
- /*
- * Re-set current cursor so drivers can react to FB access having been
- * temporarily disabled.
- */
- xf86CursorSetCursor(pDev, pScreen, ScreenPriv->SavedCursor,
- ScreenPriv->x, ScreenPriv->y);
- ScreenPriv->SavedCursor = NULL;
+ (*ScreenPriv->EnableDisableFBAccess) (index, enable);
+
+ if (enable && ScreenPriv->SavedCursor) {
+ /*
+ * Re-set current cursor so drivers can react to FB access having been
+ * temporarily disabled.
+ */
+ xf86CursorSetCursor(pDev, pScreen, ScreenPriv->SavedCursor,
+ ScreenPriv->x, ScreenPriv->y);
+ ScreenPriv->SavedCursor = NULL;
}
}
@@ -243,15 +241,16 @@ xf86CursorSwitchMode(int index, DisplayModePtr mode, int flags)
{
Bool ret;
ScreenPtr pScreen = screenInfo.screens[index];
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
+ xf86CursorScreenPtr ScreenPriv =
+ (xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86CursorScreenKey);
if (ScreenPriv->isUp) {
- xf86SetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y);
- ScreenPriv->isUp = FALSE;
+ xf86SetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y);
+ ScreenPriv->isUp = FALSE;
}
- ret = (*ScreenPriv->SwitchMode)(index, mode, flags);
+ ret = (*ScreenPriv->SwitchMode) (index, mode, flags);
/*
* Cannot restore cursor here because the new frame[XY][01] haven't been
@@ -259,7 +258,7 @@ xf86CursorSwitchMode(int index, DisplayModePtr mode, int flags)
* ensure the cursor is repainted by miPointerWarpCursor().
*/
ScreenPriv->CursorToRestore = ScreenPriv->CurrentCursor;
- miPointerSetWaitForUpdate(pScreen, FALSE); /* Force cursor repaint */
+ miPointerSetWaitForUpdate(pScreen, FALSE); /* Force cursor repaint */
return ret;
}
@@ -269,90 +268,107 @@ xf86CursorSwitchMode(int index, DisplayModePtr mode, int flags)
static Bool
xf86CursorRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs)
{
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
+ xf86CursorScreenPtr ScreenPriv =
+ (xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86CursorScreenKey);
if (pCurs->refcnt <= 1)
- dixSetScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen, NULL);
+ dixSetScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen,
+ NULL);
- return (*ScreenPriv->spriteFuncs->RealizeCursor)(pDev, pScreen, pCurs);
+ return (*ScreenPriv->spriteFuncs->RealizeCursor) (pDev, pScreen, pCurs);
}
static Bool
-xf86CursorUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
- CursorPtr pCurs)
+xf86CursorUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs)
{
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
+ xf86CursorScreenPtr ScreenPriv =
+ (xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86CursorScreenKey);
if (pCurs->refcnt <= 1) {
- free(dixLookupScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen));
- dixSetScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen, NULL);
+ free(dixLookupScreenPrivate
+ (&pCurs->devPrivates, CursorScreenKey, pScreen));
+ dixSetScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen,
+ NULL);
}
- return (*ScreenPriv->spriteFuncs->UnrealizeCursor)(pDev, pScreen, pCurs);
+ return (*ScreenPriv->spriteFuncs->UnrealizeCursor) (pDev, pScreen, pCurs);
}
static void
-xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs,
+xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs,
int x, int y)
{
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
+ xf86CursorScreenPtr ScreenPriv =
+ (xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86CursorScreenKey);
xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
- if (pCurs == NullCursor) { /* means we're supposed to remove the cursor */
+ if (pCurs == NullCursor) { /* means we're supposed to remove the cursor */
if (ScreenPriv->SWCursor ||
!(GetMaster(pDev, MASTER_POINTER) == inputInfo.pointer))
- (*ScreenPriv->spriteFuncs->SetCursor)(pDev, pScreen, NullCursor, x, y);
+ (*ScreenPriv->spriteFuncs->SetCursor) (pDev, pScreen, NullCursor, x,
+ y);
else if (ScreenPriv->isUp) {
xf86SetCursor(pScreen, NullCursor, x, y);
ScreenPriv->isUp = FALSE;
}
- if (ScreenPriv->CurrentCursor)
- FreeCursor(ScreenPriv->CurrentCursor, None);
+ if (ScreenPriv->CurrentCursor)
+ FreeCursor(ScreenPriv->CurrentCursor, None);
ScreenPriv->CurrentCursor = NullCursor;
return;
}
/* only update for VCP, otherwise we get cursor jumps when removing a
sprite. The second cursor is never HW rendered anyway. */
- if (GetMaster(pDev, MASTER_POINTER) == inputInfo.pointer)
- {
- pCurs->refcnt++;
- if (ScreenPriv->CurrentCursor)
- FreeCursor(ScreenPriv->CurrentCursor, None);
- ScreenPriv->CurrentCursor = pCurs;
- ScreenPriv->x = x;
- ScreenPriv->y = y;
- ScreenPriv->CursorToRestore = NULL;
- ScreenPriv->HotX = pCurs->bits->xhot;
- ScreenPriv->HotY = pCurs->bits->yhot;
+ if (GetMaster(pDev, MASTER_POINTER) == inputInfo.pointer) {
+ pCurs->refcnt++;
+ if (ScreenPriv->CurrentCursor)
+ FreeCursor(ScreenPriv->CurrentCursor, None);
+ ScreenPriv->CurrentCursor = pCurs;
+ ScreenPriv->x = x;
+ ScreenPriv->y = y;
+ ScreenPriv->CursorToRestore = NULL;
+ ScreenPriv->HotX = pCurs->bits->xhot;
+ ScreenPriv->HotY = pCurs->bits->yhot;
if (!infoPtr->pScrn->vtSema)
ScreenPriv->SavedCursor = pCurs;
- if (infoPtr->pScrn->vtSema && (ScreenPriv->ForceHWCursorCount || ((
+ if (infoPtr->pScrn->vtSema && (ScreenPriv->ForceHWCursorCount || ((
#ifdef ARGB_CURSOR
- pCurs->bits->argb && infoPtr->UseHWCursorARGB &&
- (*infoPtr->UseHWCursorARGB) (pScreen, pCurs) ) || (
- pCurs->bits->argb == 0 &&
+ pCurs->
+ bits->
+ argb
+ &&
+ infoPtr->
+ UseHWCursorARGB
+ &&
+ (*infoPtr->
+ UseHWCursorARGB)
+ (pScreen,
+ pCurs))
+ ||
+ (pCurs->
+ bits->
+ argb
+ == 0
+ &&
#endif
- (pCurs->bits->height <= infoPtr->MaxHeight) &&
- (pCurs->bits->width <= infoPtr->MaxWidth) &&
- (!infoPtr->UseHWCursor || (*infoPtr->UseHWCursor)(pScreen, pCurs))))))
- {
+ (pCurs->bits->height <= infoPtr->MaxHeight) && (pCurs->bits->width <= infoPtr->MaxWidth) && (!infoPtr->UseHWCursor || (*infoPtr->UseHWCursor) (pScreen, pCurs)))))) {
- if (ScreenPriv->SWCursor) /* remove the SW cursor */
- (*ScreenPriv->spriteFuncs->SetCursor)(pDev, pScreen, NullCursor, x, y);
+ if (ScreenPriv->SWCursor) /* remove the SW cursor */
+ (*ScreenPriv->spriteFuncs->SetCursor) (pDev, pScreen,
+ NullCursor, x, y);
- xf86SetCursor(pScreen, pCurs, x, y);
- ScreenPriv->SWCursor = FALSE;
- ScreenPriv->isUp = TRUE;
+ xf86SetCursor(pScreen, pCurs, x, y);
+ ScreenPriv->SWCursor = FALSE;
+ ScreenPriv->isUp = TRUE;
- miPointerSetWaitForUpdate(pScreen, !infoPtr->pScrn->silkenMouse);
- return;
- }
+ miPointerSetWaitForUpdate(pScreen, !infoPtr->pScrn->silkenMouse);
+ return;
+ }
miPointerSetWaitForUpdate(pScreen, TRUE);
@@ -360,7 +376,8 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs,
/* Remove the HW cursor, or make it transparent */
if (infoPtr->Flags & HARDWARE_CURSOR_SHOW_TRANSPARENT) {
xf86SetTransparentCursor(pScreen);
- } else {
+ }
+ else {
xf86SetCursor(pScreen, NullCursor, x, y);
ScreenPriv->isUp = FALSE;
}
@@ -372,63 +389,61 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs,
}
if (pCurs->bits->emptyMask && !ScreenPriv->showTransparent)
- pCurs = NullCursor;
+ pCurs = NullCursor;
- (*ScreenPriv->spriteFuncs->SetCursor)(pDev, pScreen, pCurs, x, y);
+ (*ScreenPriv->spriteFuncs->SetCursor) (pDev, pScreen, pCurs, x, y);
}
static void
xf86CursorMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
{
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
+ xf86CursorScreenPtr ScreenPriv =
+ (xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86CursorScreenKey);
/* only update coordinate state for first sprite, otherwise we get jumps
when removing a sprite. The second sprite is never HW rendered anyway */
- if (GetMaster(pDev, MASTER_POINTER) == inputInfo.pointer)
- {
- ScreenPriv->x = x;
- ScreenPriv->y = y;
+ if (GetMaster(pDev, MASTER_POINTER) == inputInfo.pointer) {
+ ScreenPriv->x = x;
+ ScreenPriv->y = y;
if (ScreenPriv->CursorToRestore)
- xf86CursorSetCursor(pDev, pScreen, ScreenPriv->CursorToRestore, x, y);
+ xf86CursorSetCursor(pDev, pScreen, ScreenPriv->CursorToRestore, x,
+ y);
else if (ScreenPriv->SWCursor)
- (*ScreenPriv->spriteFuncs->MoveCursor)(pDev, pScreen, x, y);
+ (*ScreenPriv->spriteFuncs->MoveCursor) (pDev, pScreen, x, y);
else if (ScreenPriv->isUp)
xf86MoveCursor(pScreen, x, y);
- } else
- (*ScreenPriv->spriteFuncs->MoveCursor)(pDev, pScreen, x, y);
+ }
+ else
+ (*ScreenPriv->spriteFuncs->MoveCursor) (pDev, pScreen, x, y);
}
void
-xf86ForceHWCursor (ScreenPtr pScreen, Bool on)
+xf86ForceHWCursor(ScreenPtr pScreen, Bool on)
{
DeviceIntPtr pDev = inputInfo.pointer;
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
-
- if (on)
- {
- if (ScreenPriv->ForceHWCursorCount++ == 0)
- {
- if (ScreenPriv->SWCursor && ScreenPriv->CurrentCursor)
- {
- ScreenPriv->HWCursorForced = TRUE;
- xf86CursorSetCursor (pDev, pScreen, ScreenPriv->CurrentCursor,
- ScreenPriv->x, ScreenPriv->y);
- }
- else
- ScreenPriv->HWCursorForced = FALSE;
- }
+ xf86CursorScreenPtr ScreenPriv =
+ (xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86CursorScreenKey);
+
+ if (on) {
+ if (ScreenPriv->ForceHWCursorCount++ == 0) {
+ if (ScreenPriv->SWCursor && ScreenPriv->CurrentCursor) {
+ ScreenPriv->HWCursorForced = TRUE;
+ xf86CursorSetCursor(pDev, pScreen, ScreenPriv->CurrentCursor,
+ ScreenPriv->x, ScreenPriv->y);
+ }
+ else
+ ScreenPriv->HWCursorForced = FALSE;
+ }
}
- else
- {
- if (--ScreenPriv->ForceHWCursorCount == 0)
- {
- if (ScreenPriv->HWCursorForced && ScreenPriv->CurrentCursor)
- xf86CursorSetCursor (pDev, pScreen, ScreenPriv->CurrentCursor,
- ScreenPriv->x, ScreenPriv->y);
- }
+ else {
+ if (--ScreenPriv->ForceHWCursorCount == 0) {
+ if (ScreenPriv->HWCursorForced && ScreenPriv->CurrentCursor)
+ xf86CursorSetCursor(pDev, pScreen, ScreenPriv->CurrentCursor,
+ ScreenPriv->x, ScreenPriv->y);
+ }
}
}
@@ -451,11 +466,12 @@ static Bool
xf86DeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
{
int ret;
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
+ xf86CursorScreenPtr ScreenPriv =
+ (xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86CursorScreenKey);
/* Init SW cursor */
- ret = (*ScreenPriv->spriteFuncs->DeviceCursorInitialize)(pDev, pScreen);
+ ret = (*ScreenPriv->spriteFuncs->DeviceCursorInitialize) (pDev, pScreen);
return ret;
}
@@ -466,10 +482,10 @@ xf86DeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
static void
xf86DeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
{
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
+ xf86CursorScreenPtr ScreenPriv =
+ (xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86CursorScreenKey);
- /* Clean up SW cursor */
- (*ScreenPriv->spriteFuncs->DeviceCursorCleanup)(pDev, pScreen);
+ /* Clean up SW cursor */
+ (*ScreenPriv->spriteFuncs->DeviceCursorCleanup) (pDev, pScreen);
}
-
diff --git a/xorg-server/hw/xfree86/ramdac/xf86Cursor.h b/xorg-server/hw/xfree86/ramdac/xf86Cursor.h
index 3f3618b59..5658e7b30 100644
--- a/xorg-server/hw/xfree86/ramdac/xf86Cursor.h
+++ b/xorg-server/hw/xfree86/ramdac/xf86Cursor.h
@@ -10,13 +10,13 @@ typedef struct _xf86CursorInfoRec {
int Flags;
int MaxWidth;
int MaxHeight;
- void (*SetCursorColors)(ScrnInfoPtr pScrn, int bg, int fg);
- void (*SetCursorPosition)(ScrnInfoPtr pScrn, int x, int y);
- void (*LoadCursorImage)(ScrnInfoPtr pScrn, unsigned char *bits);
- void (*HideCursor)(ScrnInfoPtr pScrn);
- void (*ShowCursor)(ScrnInfoPtr pScrn);
- unsigned char* (*RealizeCursor)(struct _xf86CursorInfoRec *, CursorPtr);
- Bool (*UseHWCursor)(ScreenPtr, CursorPtr);
+ void (*SetCursorColors) (ScrnInfoPtr pScrn, int bg, int fg);
+ void (*SetCursorPosition) (ScrnInfoPtr pScrn, int x, int y);
+ void (*LoadCursorImage) (ScrnInfoPtr pScrn, unsigned char *bits);
+ void (*HideCursor) (ScrnInfoPtr pScrn);
+ void (*ShowCursor) (ScrnInfoPtr pScrn);
+ unsigned char *(*RealizeCursor) (struct _xf86CursorInfoRec *, CursorPtr);
+ Bool (*UseHWCursor) (ScreenPtr, CursorPtr);
#ifdef ARGB_CURSOR
Bool (*UseHWCursorARGB) (ScreenPtr, CursorPtr);
@@ -25,10 +25,11 @@ typedef struct _xf86CursorInfoRec {
} xf86CursorInfoRec, *xf86CursorInfoPtr;
-extern _X_EXPORT Bool xf86InitCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr);
+extern _X_EXPORT Bool xf86InitCursor(ScreenPtr pScreen,
+ xf86CursorInfoPtr infoPtr);
extern _X_EXPORT xf86CursorInfoPtr xf86CreateCursorInfoRec(void);
extern _X_EXPORT void xf86DestroyCursorInfoRec(xf86CursorInfoPtr);
-extern _X_EXPORT void xf86ForceHWCursor (ScreenPtr pScreen, Bool on);
+extern _X_EXPORT void xf86ForceHWCursor(ScreenPtr pScreen, Bool on);
#define HARDWARE_CURSOR_INVERT_MASK 0x00000001
#define HARDWARE_CURSOR_AND_SOURCE_WITH_MASK 0x00000002
@@ -48,4 +49,4 @@ extern _X_EXPORT void xf86ForceHWCursor (ScreenPtr pScreen, Bool on);
#define HARDWARE_CURSOR_ARGB 0x00004000
#endif
-#endif /* _XF86CURSOR_H */
+#endif /* _XF86CURSOR_H */
diff --git a/xorg-server/hw/xfree86/ramdac/xf86HWCurs.c b/xorg-server/hw/xfree86/ramdac/xf86HWCurs.c
index f9b09fc9a..95721490a 100644
--- a/xorg-server/hw/xfree86/ramdac/xf86HWCurs.c
+++ b/xorg-server/hw/xfree86/ramdac/xf86HWCurs.c
@@ -39,18 +39,18 @@ static CARD64 xf86CARD64ReverseBits(CARD64 w);
static CARD64
xf86CARD64ReverseBits(CARD64 w)
{
- unsigned char *p = (unsigned char *)&w;
-
- p[0] = byte_reversed[p[0]];
- p[1] = byte_reversed[p[1]];
- p[2] = byte_reversed[p[2]];
- p[3] = byte_reversed[p[3]];
- p[4] = byte_reversed[p[4]];
- p[5] = byte_reversed[p[5]];
- p[6] = byte_reversed[p[6]];
- p[7] = byte_reversed[p[7]];
-
- return w;
+ unsigned char *p = (unsigned char *) &w;
+
+ p[0] = byte_reversed[p[0]];
+ p[1] = byte_reversed[p[1]];
+ p[2] = byte_reversed[p[2]];
+ p[3] = byte_reversed[p[3]];
+ p[4] = byte_reversed[p[4]];
+ p[5] = byte_reversed[p[5]];
+ p[6] = byte_reversed[p[6]];
+ p[7] = byte_reversed[p[7]];
+
+ return w;
}
#endif
@@ -61,48 +61,48 @@ xf86CARD64ReverseBits(CARD64 w)
#define CUR_LOG2_BITMAP_PAD LOG2_BITMAP_PAD
#define REVERSE_BIT_ORDER(w) xf86ReverseBitOrder(w)
-#endif /* BITMAP_SCANLINE_PAD == 64 */
+#endif /* BITMAP_SCANLINE_PAD == 64 */
-static unsigned char* RealizeCursorInterleave0(xf86CursorInfoPtr, CursorPtr);
-static unsigned char* RealizeCursorInterleave1(xf86CursorInfoPtr, CursorPtr);
-static unsigned char* RealizeCursorInterleave8(xf86CursorInfoPtr, CursorPtr);
-static unsigned char* RealizeCursorInterleave16(xf86CursorInfoPtr, CursorPtr);
-static unsigned char* RealizeCursorInterleave32(xf86CursorInfoPtr, CursorPtr);
-static unsigned char* RealizeCursorInterleave64(xf86CursorInfoPtr, CursorPtr);
+static unsigned char *RealizeCursorInterleave0(xf86CursorInfoPtr, CursorPtr);
+static unsigned char *RealizeCursorInterleave1(xf86CursorInfoPtr, CursorPtr);
+static unsigned char *RealizeCursorInterleave8(xf86CursorInfoPtr, CursorPtr);
+static unsigned char *RealizeCursorInterleave16(xf86CursorInfoPtr, CursorPtr);
+static unsigned char *RealizeCursorInterleave32(xf86CursorInfoPtr, CursorPtr);
+static unsigned char *RealizeCursorInterleave64(xf86CursorInfoPtr, CursorPtr);
Bool
xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr)
{
if ((infoPtr->MaxWidth <= 0) || (infoPtr->MaxHeight <= 0))
- return FALSE;
+ return FALSE;
/* These are required for now */
if (!infoPtr->SetCursorPosition ||
- !infoPtr->LoadCursorImage ||
- !infoPtr->HideCursor ||
- !infoPtr->ShowCursor ||
- !infoPtr->SetCursorColors)
- return FALSE;
+ !infoPtr->LoadCursorImage ||
+ !infoPtr->HideCursor ||
+ !infoPtr->ShowCursor || !infoPtr->SetCursorColors)
+ return FALSE;
if (infoPtr->RealizeCursor) {
- /* Don't overwrite a driver provided Realize Cursor function */
- } else
- if (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 & infoPtr->Flags) {
- infoPtr->RealizeCursor = RealizeCursorInterleave1;
- } else
- if (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8 & infoPtr->Flags) {
- infoPtr->RealizeCursor = RealizeCursorInterleave8;
- } else
- if (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16 & infoPtr->Flags) {
- infoPtr->RealizeCursor = RealizeCursorInterleave16;
- } else
- if (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32 & infoPtr->Flags) {
- infoPtr->RealizeCursor = RealizeCursorInterleave32;
- } else
- if (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 & infoPtr->Flags) {
- infoPtr->RealizeCursor = RealizeCursorInterleave64;
- } else { /* not interleaved */
- infoPtr->RealizeCursor = RealizeCursorInterleave0;
+ /* Don't overwrite a driver provided Realize Cursor function */
+ }
+ else if (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 & infoPtr->Flags) {
+ infoPtr->RealizeCursor = RealizeCursorInterleave1;
+ }
+ else if (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8 & infoPtr->Flags) {
+ infoPtr->RealizeCursor = RealizeCursorInterleave8;
+ }
+ else if (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16 & infoPtr->Flags) {
+ infoPtr->RealizeCursor = RealizeCursorInterleave16;
+ }
+ else if (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32 & infoPtr->Flags) {
+ infoPtr->RealizeCursor = RealizeCursorInterleave32;
+ }
+ else if (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 & infoPtr->Flags) {
+ infoPtr->RealizeCursor = RealizeCursorInterleave64;
+ }
+ else { /* not interleaved */
+ infoPtr->RealizeCursor = RealizeCursorInterleave0;
}
infoPtr->pScrn = xf86Screens[pScreen->myNum];
@@ -113,17 +113,19 @@ xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr)
void
xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
{
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
+ xf86CursorScreenPtr ScreenPriv =
+ (xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86CursorScreenKey);
xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
unsigned char *bits;
if (pCurs == NullCursor) {
- (*infoPtr->HideCursor)(infoPtr->pScrn);
- return;
+ (*infoPtr->HideCursor) (infoPtr->pScrn);
+ return;
}
- bits = dixLookupScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen);
+ bits =
+ dixLookupScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen);
x -= infoPtr->pScrn->frameX0 + ScreenPriv->HotX;
y -= infoPtr->pScrn->frameY0 + ScreenPriv->HotY;
@@ -131,68 +133,72 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
#ifdef ARGB_CURSOR
if (!pCurs->bits->argb || !infoPtr->LoadCursorARGB)
#endif
- if (!bits) {
- bits = (*infoPtr->RealizeCursor)(infoPtr, pCurs);
- dixSetScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen, bits);
- }
+ if (!bits) {
+ bits = (*infoPtr->RealizeCursor) (infoPtr, pCurs);
+ dixSetScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen,
+ bits);
+ }
if (!(infoPtr->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN))
- (*infoPtr->HideCursor)(infoPtr->pScrn);
+ (*infoPtr->HideCursor) (infoPtr->pScrn);
#ifdef ARGB_CURSOR
if (pCurs->bits->argb && infoPtr->LoadCursorARGB)
- (*infoPtr->LoadCursorARGB) (infoPtr->pScrn, pCurs);
+ (*infoPtr->LoadCursorARGB) (infoPtr->pScrn, pCurs);
else
#endif
if (bits)
- (*infoPtr->LoadCursorImage)(infoPtr->pScrn, bits);
+ (*infoPtr->LoadCursorImage) (infoPtr->pScrn, bits);
xf86RecolorCursor(pScreen, pCurs, 1);
- (*infoPtr->SetCursorPosition)(infoPtr->pScrn, x, y);
+ (*infoPtr->SetCursorPosition) (infoPtr->pScrn, x, y);
- (*infoPtr->ShowCursor)(infoPtr->pScrn);
+ (*infoPtr->ShowCursor) (infoPtr->pScrn);
}
void
xf86SetTransparentCursor(ScreenPtr pScreen)
{
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
+ xf86CursorScreenPtr ScreenPriv =
+ (xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86CursorScreenKey);
xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
if (!ScreenPriv->transparentData)
- ScreenPriv->transparentData =
- (*infoPtr->RealizeCursor)(infoPtr, NullCursor);
+ ScreenPriv->transparentData =
+ (*infoPtr->RealizeCursor) (infoPtr, NullCursor);
if (!(infoPtr->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN))
- (*infoPtr->HideCursor)(infoPtr->pScrn);
+ (*infoPtr->HideCursor) (infoPtr->pScrn);
if (ScreenPriv->transparentData)
- (*infoPtr->LoadCursorImage)(infoPtr->pScrn,
- ScreenPriv->transparentData);
+ (*infoPtr->LoadCursorImage) (infoPtr->pScrn,
+ ScreenPriv->transparentData);
- (*infoPtr->ShowCursor)(infoPtr->pScrn);
+ (*infoPtr->ShowCursor) (infoPtr->pScrn);
}
void
xf86MoveCursor(ScreenPtr pScreen, int x, int y)
{
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
+ xf86CursorScreenPtr ScreenPriv =
+ (xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86CursorScreenKey);
xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
x -= infoPtr->pScrn->frameX0 + ScreenPriv->HotX;
y -= infoPtr->pScrn->frameY0 + ScreenPriv->HotY;
- (*infoPtr->SetCursorPosition)(infoPtr->pScrn, x, y);
+ (*infoPtr->SetCursorPosition) (infoPtr->pScrn, x, y);
}
void
xf86RecolorCursor(ScreenPtr pScreen, CursorPtr pCurs, Bool displayed)
{
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
+ xf86CursorScreenPtr ScreenPriv =
+ (xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
+ xf86CursorScreenKey);
xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
#ifdef ARGB_CURSOR
@@ -203,38 +209,39 @@ xf86RecolorCursor(ScreenPtr pScreen, CursorPtr pCurs, Bool displayed)
#endif
if (ScreenPriv->PalettedCursor) {
- xColorItem sourceColor, maskColor;
- ColormapPtr pmap = ScreenPriv->pInstalledMap;
-
- if (!pmap)
- return;
-
- sourceColor.red = pCurs->foreRed;
- sourceColor.green = pCurs->foreGreen;
- sourceColor.blue = pCurs->foreBlue;
- FakeAllocColor(pmap, &sourceColor);
- maskColor.red = pCurs->backRed;
- maskColor.green = pCurs->backGreen;
- maskColor.blue = pCurs->backBlue;
- FakeAllocColor(pmap, &maskColor);
- FakeFreeColor(pmap, sourceColor.pixel);
- FakeFreeColor(pmap, maskColor.pixel);
- (*infoPtr->SetCursorColors)(infoPtr->pScrn,
- maskColor.pixel, sourceColor.pixel);
- } else { /* Pass colors in 8-8-8 RGB format */
- (*infoPtr->SetCursorColors)(infoPtr->pScrn,
- (pCurs->backBlue >> 8) |
- ((pCurs->backGreen >> 8) << 8) |
- ((pCurs->backRed >> 8) << 16),
- (pCurs->foreBlue >> 8) |
- ((pCurs->foreGreen >> 8) << 8) |
- ((pCurs->foreRed >> 8) << 16)
- );
+ xColorItem sourceColor, maskColor;
+ ColormapPtr pmap = ScreenPriv->pInstalledMap;
+
+ if (!pmap)
+ return;
+
+ sourceColor.red = pCurs->foreRed;
+ sourceColor.green = pCurs->foreGreen;
+ sourceColor.blue = pCurs->foreBlue;
+ FakeAllocColor(pmap, &sourceColor);
+ maskColor.red = pCurs->backRed;
+ maskColor.green = pCurs->backGreen;
+ maskColor.blue = pCurs->backBlue;
+ FakeAllocColor(pmap, &maskColor);
+ FakeFreeColor(pmap, sourceColor.pixel);
+ FakeFreeColor(pmap, maskColor.pixel);
+ (*infoPtr->SetCursorColors) (infoPtr->pScrn,
+ maskColor.pixel, sourceColor.pixel);
+ }
+ else { /* Pass colors in 8-8-8 RGB format */
+ (*infoPtr->SetCursorColors) (infoPtr->pScrn,
+ (pCurs->backBlue >> 8) |
+ ((pCurs->backGreen >> 8) << 8) |
+ ((pCurs->backRed >> 8) << 16),
+ (pCurs->foreBlue >> 8) |
+ ((pCurs->foreGreen >> 8) << 8) |
+ ((pCurs->foreRed >> 8) << 16)
+ );
}
}
/* These functions assume that MaxWidth is a multiple of 32 */
-static unsigned char*
+static unsigned char *
RealizeCursorInterleave0(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
{
@@ -243,75 +250,83 @@ RealizeCursorInterleave0(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
unsigned char *mem;
int size = (infoPtr->MaxWidth * infoPtr->MaxHeight) >> 2;
int SrcPitch, DstPitch, Pitch, y, x;
+
/* how many words are in the source or mask */
int words = size / (CUR_BITMAP_SCANLINE_PAD / 4);
-
if (!(mem = calloc(1, size)))
- return NULL;
+ return NULL;
if (pCurs == NullCursor) {
- if (infoPtr->Flags & HARDWARE_CURSOR_INVERT_MASK) {
- DstM = (SCANLINE*)mem;
- if (!(infoPtr->Flags & HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK))
- DstM += words;
- memset(DstM, -1, words * sizeof(SCANLINE));
- }
- return mem;
+ if (infoPtr->Flags & HARDWARE_CURSOR_INVERT_MASK) {
+ DstM = (SCANLINE *) mem;
+ if (!(infoPtr->Flags & HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK))
+ DstM += words;
+ memset(DstM, -1, words * sizeof(SCANLINE));
+ }
+ return mem;
}
/* SrcPitch == the number of scanlines wide the cursor image is */
SrcPitch = (pCurs->bits->width + (BITMAP_SCANLINE_PAD - 1)) >>
- CUR_LOG2_BITMAP_PAD;
+ CUR_LOG2_BITMAP_PAD;
/* DstPitch is the width of the hw cursor in scanlines */
DstPitch = infoPtr->MaxWidth >> CUR_LOG2_BITMAP_PAD;
Pitch = SrcPitch < DstPitch ? SrcPitch : DstPitch;
- SrcS = (SCANLINE*)pCurs->bits->source;
- SrcM = (SCANLINE*)pCurs->bits->mask;
- DstS = (SCANLINE*)mem;
+ SrcS = (SCANLINE *) pCurs->bits->source;
+ SrcM = (SCANLINE *) pCurs->bits->mask;
+ DstS = (SCANLINE *) mem;
DstM = DstS + words;
if (infoPtr->Flags & HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK) {
- SCANLINE *tmp;
- tmp = DstS; DstS = DstM; DstM = tmp;
+ SCANLINE *tmp;
+
+ tmp = DstS;
+ DstS = DstM;
+ DstM = tmp;
}
if (infoPtr->Flags & HARDWARE_CURSOR_AND_SOURCE_WITH_MASK) {
- for(y = pCurs->bits->height, pSrc = DstS, pMsk = DstM;
- y--;
- pSrc+=DstPitch, pMsk+=DstPitch, SrcS+=SrcPitch, SrcM+=SrcPitch) {
- for(x = 0; x < Pitch; x++) {
- pSrc[x] = SrcS[x] & SrcM[x];
- pMsk[x] = SrcM[x];
- }
- }
- } else {
- for(y = pCurs->bits->height, pSrc = DstS, pMsk = DstM;
- y--;
- pSrc+=DstPitch, pMsk+=DstPitch, SrcS+=SrcPitch, SrcM+=SrcPitch) {
- for(x = 0; x < Pitch; x++) {
- pSrc[x] = SrcS[x];
- pMsk[x] = SrcM[x];
- }
- }
+ for (y = pCurs->bits->height, pSrc = DstS, pMsk = DstM;
+ y--;
+ pSrc += DstPitch, pMsk += DstPitch, SrcS += SrcPitch, SrcM +=
+ SrcPitch) {
+ for (x = 0; x < Pitch; x++) {
+ pSrc[x] = SrcS[x] & SrcM[x];
+ pMsk[x] = SrcM[x];
+ }
+ }
+ }
+ else {
+ for (y = pCurs->bits->height, pSrc = DstS, pMsk = DstM;
+ y--;
+ pSrc += DstPitch, pMsk += DstPitch, SrcS += SrcPitch, SrcM +=
+ SrcPitch) {
+ for (x = 0; x < Pitch; x++) {
+ pSrc[x] = SrcS[x];
+ pMsk[x] = SrcM[x];
+ }
+ }
}
if (infoPtr->Flags & HARDWARE_CURSOR_NIBBLE_SWAPPED) {
- int count = size;
- unsigned char* pntr1 = (unsigned char *)DstS;
- unsigned char* pntr2 = (unsigned char *)DstM;
- unsigned char a, b;
- while (count) {
-
- a = *pntr1;
- b = *pntr2;
- *pntr1 = ((a & 0xF0) >> 4) | ((a & 0x0F) << 4);
- *pntr2 = ((b & 0xF0) >> 4) | ((b & 0x0F) << 4);
- pntr1++; pntr2++;
- count-=2;
- }
+ int count = size;
+ unsigned char *pntr1 = (unsigned char *) DstS;
+ unsigned char *pntr2 = (unsigned char *) DstM;
+ unsigned char a, b;
+
+ while (count) {
+
+ a = *pntr1;
+ b = *pntr2;
+ *pntr1 = ((a & 0xF0) >> 4) | ((a & 0x0F) << 4);
+ *pntr2 = ((b & 0xF0) >> 4) | ((b & 0x0F) << 4);
+ pntr1++;
+ pntr2++;
+ count -= 2;
+ }
}
/*
@@ -319,29 +334,29 @@ RealizeCursorInterleave0(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
* out entire source mask.
*/
if (infoPtr->Flags & HARDWARE_CURSOR_INVERT_MASK) {
- int count = words;
- SCANLINE* pntr = DstM;
- while (count--) {
- *pntr = ~(*pntr);
- pntr++;
- }
+ int count = words;
+ SCANLINE *pntr = DstM;
+
+ while (count--) {
+ *pntr = ~(*pntr);
+ pntr++;
+ }
}
if (infoPtr->Flags & HARDWARE_CURSOR_BIT_ORDER_MSBFIRST) {
- for(y = pCurs->bits->height, pSrc = DstS, pMsk = DstM;
- y--;
- pSrc+=DstPitch, pMsk+=DstPitch) {
- for(x = 0; x < Pitch; x++) {
- pSrc[x] = REVERSE_BIT_ORDER(pSrc[x]);
- pMsk[x] = REVERSE_BIT_ORDER(pMsk[x]);
- }
- }
+ for (y = pCurs->bits->height, pSrc = DstS, pMsk = DstM;
+ y--; pSrc += DstPitch, pMsk += DstPitch) {
+ for (x = 0; x < Pitch; x++) {
+ pSrc[x] = REVERSE_BIT_ORDER(pSrc[x]);
+ pMsk[x] = REVERSE_BIT_ORDER(pMsk[x]);
+ }
+ }
}
return mem;
}
-static unsigned char*
+static unsigned char *
RealizeCursorInterleave1(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
{
unsigned char *DstS, *DstM;
@@ -352,30 +367,30 @@ RealizeCursorInterleave1(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
/* Realize the cursor without interleaving */
if (!(mem2 = RealizeCursorInterleave0(infoPtr, pCurs)))
- return NULL;
+ return NULL;
if (!(mem = calloc(1, size))) {
- free(mem2);
- return NULL;
+ free(mem2);
+ return NULL;
}
- /* 1 bit interleave */
+ /* 1 bit interleave */
DstS = mem2;
DstM = DstS + (size >> 1);
pntr = mem;
count = size;
while (count) {
- *pntr++ = ((*DstS&0x01) ) | ((*DstM&0x01) << 1) |
- ((*DstS&0x02) << 1) | ((*DstM&0x02) << 2) |
- ((*DstS&0x04) << 2) | ((*DstM&0x04) << 3) |
- ((*DstS&0x08) << 3) | ((*DstM&0x08) << 4);
- *pntr++ = ((*DstS&0x10) >> 4) | ((*DstM&0x10) >> 3) |
- ((*DstS&0x20) >> 3) | ((*DstM&0x20) >> 2) |
- ((*DstS&0x40) >> 2) | ((*DstM&0x40) >> 1) |
- ((*DstS&0x80) >> 1) | ((*DstM&0x80) );
- DstS++;
- DstM++;
- count-=2;
+ *pntr++ = ((*DstS & 0x01)) | ((*DstM & 0x01) << 1) |
+ ((*DstS & 0x02) << 1) | ((*DstM & 0x02) << 2) |
+ ((*DstS & 0x04) << 2) | ((*DstM & 0x04) << 3) |
+ ((*DstS & 0x08) << 3) | ((*DstM & 0x08) << 4);
+ *pntr++ = ((*DstS & 0x10) >> 4) | ((*DstM & 0x10) >> 3) |
+ ((*DstS & 0x20) >> 3) | ((*DstM & 0x20) >> 2) |
+ ((*DstS & 0x40) >> 2) | ((*DstM & 0x40) >> 1) |
+ ((*DstS & 0x80) >> 1) | ((*DstM & 0x80));
+ DstS++;
+ DstM++;
+ count -= 2;
}
/* Free the uninterleaved cursor */
@@ -384,7 +399,7 @@ RealizeCursorInterleave1(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
return mem;
}
-static unsigned char*
+static unsigned char *
RealizeCursorInterleave8(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
{
unsigned char *DstS, *DstM;
@@ -395,11 +410,11 @@ RealizeCursorInterleave8(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
/* Realize the cursor without interleaving */
if (!(mem2 = RealizeCursorInterleave0(infoPtr, pCurs)))
- return NULL;
+ return NULL;
if (!(mem = calloc(1, size))) {
- free(mem2);
- return NULL;
+ free(mem2);
+ return NULL;
}
/* 8 bit interleave */
@@ -408,9 +423,9 @@ RealizeCursorInterleave8(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
pntr = mem;
count = size;
while (count) {
- *pntr++ = *DstS++;
- *pntr++ = *DstM++;
- count-=2;
+ *pntr++ = *DstS++;
+ *pntr++ = *DstM++;
+ count -= 2;
}
/* Free the uninterleaved cursor */
@@ -419,7 +434,7 @@ RealizeCursorInterleave8(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
return mem;
}
-static unsigned char*
+static unsigned char *
RealizeCursorInterleave16(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
{
unsigned short *DstS, *DstM;
@@ -430,22 +445,22 @@ RealizeCursorInterleave16(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
/* Realize the cursor without interleaving */
if (!(mem2 = RealizeCursorInterleave0(infoPtr, pCurs)))
- return NULL;
+ return NULL;
if (!(mem = calloc(1, size))) {
- free(mem2);
- return NULL;
+ free(mem2);
+ return NULL;
}
/* 16 bit interleave */
- DstS = (pointer)mem2;
+ DstS = (pointer) mem2;
DstM = DstS + (size >> 2);
- pntr = (pointer)mem;
+ pntr = (pointer) mem;
count = (size >> 1);
while (count) {
- *pntr++ = *DstS++;
- *pntr++ = *DstM++;
- count-=2;
+ *pntr++ = *DstS++;
+ *pntr++ = *DstM++;
+ count -= 2;
}
/* Free the uninterleaved cursor */
@@ -454,7 +469,7 @@ RealizeCursorInterleave16(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
return mem;
}
-static unsigned char*
+static unsigned char *
RealizeCursorInterleave32(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
{
CARD32 *DstS, *DstM;
@@ -465,22 +480,22 @@ RealizeCursorInterleave32(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
/* Realize the cursor without interleaving */
if (!(mem2 = RealizeCursorInterleave0(infoPtr, pCurs)))
- return NULL;
+ return NULL;
if (!(mem = calloc(1, size))) {
- free(mem2);
- return NULL;
+ free(mem2);
+ return NULL;
}
/* 32 bit interleave */
- DstS = (pointer)mem2;
+ DstS = (pointer) mem2;
DstM = DstS + (size >> 3);
- pntr = (pointer)mem;
+ pntr = (pointer) mem;
count = (size >> 2);
while (count) {
- *pntr++ = *DstS++;
- *pntr++ = *DstM++;
- count-=2;
+ *pntr++ = *DstS++;
+ *pntr++ = *DstM++;
+ count -= 2;
}
/* Free the uninterleaved cursor */
@@ -489,7 +504,7 @@ RealizeCursorInterleave32(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
return mem;
}
-static unsigned char*
+static unsigned char *
RealizeCursorInterleave64(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
{
CARD32 *DstS, *DstM;
@@ -500,24 +515,24 @@ RealizeCursorInterleave64(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
/* Realize the cursor without interleaving */
if (!(mem2 = RealizeCursorInterleave0(infoPtr, pCurs)))
- return NULL;
+ return NULL;
if (!(mem = calloc(1, size))) {
- free(mem2);
- return NULL;
+ free(mem2);
+ return NULL;
}
/* 64 bit interleave */
- DstS = (pointer)mem2;
+ DstS = (pointer) mem2;
DstM = DstS + (size >> 3);
- pntr = (pointer)mem;
+ pntr = (pointer) mem;
count = (size >> 2);
while (count) {
- *pntr++ = *DstS++;
- *pntr++ = *DstS++;
- *pntr++ = *DstM++;
- *pntr++ = *DstM++;
- count-=4;
+ *pntr++ = *DstS++;
+ *pntr++ = *DstS++;
+ *pntr++ = *DstM++;
+ *pntr++ = *DstM++;
+ count -= 4;
}
/* Free the uninterleaved cursor */
diff --git a/xorg-server/hw/xfree86/ramdac/xf86RamDac.h b/xorg-server/hw/xfree86/ramdac/xf86RamDac.h
index 4a3900b93..50a659a22 100644
--- a/xorg-server/hw/xfree86/ramdac/xf86RamDac.h
+++ b/xorg-server/hw/xfree86/ramdac/xf86RamDac.h
@@ -16,96 +16,63 @@ typedef struct _RamDacRegRec {
* and they seem o.k
* Then we allocate 768 entries for the DAC too. IBM640 needs 1024 -FIXME
*/
- unsigned short DacRegs[0x400]; /* register set */
- unsigned char DAC[0x300]; /* colour map */
+ unsigned short DacRegs[0x400]; /* register set */
+ unsigned char DAC[0x300]; /* colour map */
Bool Overlay;
} RamDacRegRec, *RamDacRegRecPtr;
typedef struct _RamDacHWRegRec {
- RamDacRegRec SavedReg;
- RamDacRegRec ModeReg;
+ RamDacRegRec SavedReg;
+ RamDacRegRec ModeReg;
} RamDacHWRec, *RamDacHWRecPtr;
typedef struct _RamDacRec {
CARD32 RamDacType;
- void (*LoadPalette)(
- ScrnInfoPtr pScrn,
- int numColors,
- int *indices,
- LOCO *colors,
- VisualPtr pVisual
- );
-
- unsigned char (*ReadDAC)(
- ScrnInfoPtr pScrn,
- CARD32
- );
-
- void (*WriteDAC)(
- ScrnInfoPtr pScrn,
- CARD32,
- unsigned char,
- unsigned char
- );
-
- void (*WriteAddress)(
- ScrnInfoPtr pScrn,
- CARD32
- );
-
- void (*WriteData)(
- ScrnInfoPtr pScrn,
- unsigned char
- );
-
- void (*ReadAddress)(
- ScrnInfoPtr pScrn,
- CARD32
- );
-
- unsigned char (*ReadData)(
- ScrnInfoPtr pScrn
- );
+ void (*LoadPalette) (ScrnInfoPtr pScrn,
+ int numColors,
+ int *indices, LOCO * colors, VisualPtr pVisual);
+
+ unsigned char (*ReadDAC) (ScrnInfoPtr pScrn, CARD32);
+
+ void (*WriteDAC) (ScrnInfoPtr pScrn, CARD32, unsigned char, unsigned char);
+
+ void (*WriteAddress) (ScrnInfoPtr pScrn, CARD32);
+
+ void (*WriteData) (ScrnInfoPtr pScrn, unsigned char);
+
+ void (*ReadAddress) (ScrnInfoPtr pScrn, CARD32);
+
+ unsigned char (*ReadData) (ScrnInfoPtr pScrn);
} RamDacRec, *RamDacRecPtr;
typedef struct _RamDacHelperRec {
CARD32 RamDacType;
- void (*Restore)(
- ScrnInfoPtr pScrn,
- RamDacRecPtr ramdacPtr,
- RamDacRegRecPtr ramdacReg
- );
-
- void (*Save)(
- ScrnInfoPtr pScrn,
- RamDacRecPtr ramdacPtr,
- RamDacRegRecPtr ramdacReg
- );
-
- void (*SetBpp)(
- ScrnInfoPtr pScrn,
- RamDacRegRecPtr ramdacReg
- );
-
- void (*HWCursorInit)(
- xf86CursorInfoPtr infoPtr
- );
+ void (*Restore) (ScrnInfoPtr pScrn,
+ RamDacRecPtr ramdacPtr, RamDacRegRecPtr ramdacReg);
+
+ void (*Save) (ScrnInfoPtr pScrn,
+ RamDacRecPtr ramdacPtr, RamDacRegRecPtr ramdacReg);
+
+ void (*SetBpp) (ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg);
+
+ void (*HWCursorInit) (xf86CursorInfoPtr infoPtr);
} RamDacHelperRec, *RamDacHelperRecPtr;
#define RAMDACHWPTR(p) ((RamDacHWRecPtr)((p)->privates[RamDacGetHWIndex()].ptr))
typedef struct _RamdacScreenRec {
- RamDacRecPtr RamDacRec;
+ RamDacRecPtr RamDacRec;
} RamDacScreenRec, *RamDacScreenRecPtr;
+
#define RAMDACSCRPTR(p) ((RamDacScreenRecPtr)((p)->privates[RamDacGetScreenIndex()].ptr))->RamDacRec
extern _X_EXPORT int RamDacHWPrivateIndex;
extern _X_EXPORT int RamDacScreenPrivateIndex;
typedef struct {
- int token;
+ int token;
} RamDacSupportedInfoRec, *RamDacSupportedInfoRecPtr;
extern _X_EXPORT RamDacRecPtr RamDacCreateInfoRec(void);
@@ -113,9 +80,9 @@ extern _X_EXPORT RamDacHelperRecPtr RamDacHelperCreateInfoRec(void);
extern _X_EXPORT void RamDacDestroyInfoRec(RamDacRecPtr RamDacRec);
extern _X_EXPORT void RamDacHelperDestroyInfoRec(RamDacHelperRecPtr RamDacRec);
extern _X_EXPORT Bool RamDacInit(ScrnInfoPtr pScrn, RamDacRecPtr RamDacRec);
-extern _X_EXPORT Bool RamDacHandleColormaps(ScreenPtr pScreen, int maxColors, int sigRGBbits,
- unsigned int flags);
+extern _X_EXPORT Bool RamDacHandleColormaps(ScreenPtr pScreen, int maxColors,
+ int sigRGBbits, unsigned int flags);
extern _X_EXPORT void RamDacFreeRec(ScrnInfoPtr pScrn);
-extern _X_EXPORT int RamDacGetHWIndex(void);
+extern _X_EXPORT int RamDacGetHWIndex(void);
-#endif /* _XF86RAMDAC_H */
+#endif /* _XF86RAMDAC_H */
diff --git a/xorg-server/hw/xfree86/sdksyms.sh b/xorg-server/hw/xfree86/sdksyms.sh
index 9034f3829..40ea7c8da 100644
--- a/xorg-server/hw/xfree86/sdksyms.sh
+++ b/xorg-server/hw/xfree86/sdksyms.sh
@@ -364,7 +364,7 @@ BEGIN {
# skip attribute, if any
while ($n ~ /^(__attribute__|__global)/ ||
# skip modifiers, if any
- $n ~ /^\*?(unsigned|const|volatile|struct)$/ ||
+ $n ~ /^\*?(unsigned|const|volatile|struct|_X_EXPORT)$/ ||
# skip pointer
$n ~ /^[a-zA-Z0-9_]*\*$/)
n++;
@@ -395,6 +395,9 @@ BEGIN {
if ($n == "" || $n ~ /^\*+$/) {
getline;
n = 1;
+ # indent may have inserted a blank link
+ if ($0 == "")
+ getline;
}
# dont modify $0 or $n
diff --git a/xorg-server/hw/xfree86/shadowfb/sfbmodule.c b/xorg-server/hw/xfree86/shadowfb/sfbmodule.c
index ec37a1f8f..c20efc071 100644
--- a/xorg-server/hw/xfree86/shadowfb/sfbmodule.c
+++ b/xorg-server/hw/xfree86/shadowfb/sfbmodule.c
@@ -4,18 +4,17 @@
#include "xf86Module.h"
-static XF86ModuleVersionInfo VersRec =
-{
- "shadowfb",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 0, 0,
- ABI_CLASS_ANSIC, /* Only need the ansic layer */
- ABI_ANSIC_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0} /* signature, to be patched into the file by a tool */
+static XF86ModuleVersionInfo VersRec = {
+ "shadowfb",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_ANSIC, /* Only need the ansic layer */
+ ABI_ANSIC_VERSION,
+ MOD_CLASS_NONE,
+ {0, 0, 0, 0} /* signature, to be patched into the file by a tool */
};
_X_EXPORT XF86ModuleData shadowfbModuleData = { &VersRec, NULL, NULL };
diff --git a/xorg-server/hw/xfree86/shadowfb/shadow.c b/xorg-server/hw/xfree86/shadowfb/shadow.c
index 26b92b5d6..714dd141a 100644
--- a/xorg-server/hw/xfree86/shadowfb/shadow.c
+++ b/xorg-server/hw/xfree86/shadowfb/shadow.c
@@ -1,1681 +1,1641 @@
-/*
- Copyright (C) 1999. The XFree86 Project Inc.
-
- Written by Mark Vojkovich (mvojkovi@ucsd.edu)
-
- Pre-fb-write callbacks and RENDER support - Nolan Leake (nolan@vmware.com)
-*/
-
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "pixmapstr.h"
-#include "input.h"
-#include <X11/fonts/font.h>
-#include "mi.h"
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "gcstruct.h"
-#include "dixfontstr.h"
-#include <X11/fonts/fontstruct.h>
-#include "xf86.h"
-#include "xf86str.h"
-#include "shadowfb.h"
-
-# include "picturestr.h"
-
-static Bool ShadowCloseScreen (int i, ScreenPtr pScreen);
-static void ShadowCopyWindow(
- WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgn
-);
-static Bool ShadowCreateGC(GCPtr pGC);
-
-static Bool ShadowEnterVT(int index, int flags);
-static void ShadowLeaveVT(int index, int flags);
-
-static void ShadowComposite(
- CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst,
- CARD16 width,
- CARD16 height
-);
-
-
-typedef struct {
- ScrnInfoPtr pScrn;
- RefreshAreaFuncPtr preRefresh;
- RefreshAreaFuncPtr postRefresh;
- CloseScreenProcPtr CloseScreen;
- CopyWindowProcPtr CopyWindow;
- CreateGCProcPtr CreateGC;
- ModifyPixmapHeaderProcPtr ModifyPixmapHeader;
- CompositeProcPtr Composite;
- Bool (*EnterVT)(int, int);
- void (*LeaveVT)(int, int);
- Bool vtSema;
-} ShadowScreenRec, *ShadowScreenPtr;
-
-typedef struct {
- GCOps *ops;
- GCFuncs *funcs;
-} ShadowGCRec, *ShadowGCPtr;
-
-static DevPrivateKeyRec ShadowScreenKeyRec;
-#define ShadowScreenKey (&ShadowScreenKeyRec)
-
-static DevPrivateKeyRec ShadowGCKeyRec;
-#define ShadowGCKey (&ShadowGCKeyRec)
-
-#define GET_SCREEN_PRIVATE(pScreen) \
- (ShadowScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, ShadowScreenKey)
-#define GET_GC_PRIVATE(pGC) \
- (ShadowGCPtr)dixLookupPrivate(&(pGC)->devPrivates, ShadowGCKey)
-
-#define SHADOW_GC_FUNC_PROLOGUE(pGC)\
- ShadowGCPtr pGCPriv = GET_GC_PRIVATE(pGC);\
- (pGC)->funcs = pGCPriv->funcs;\
- if(pGCPriv->ops)\
- (pGC)->ops = pGCPriv->ops
-
-#define SHADOW_GC_FUNC_EPILOGUE(pGC)\
- pGCPriv->funcs = (pGC)->funcs;\
- (pGC)->funcs = &ShadowGCFuncs;\
- if(pGCPriv->ops) {\
- pGCPriv->ops = (pGC)->ops;\
- (pGC)->ops = &ShadowGCOps;\
- }
-
-#define SHADOW_GC_OP_PROLOGUE(pGC)\
- ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pGC->pScreen); \
- ShadowGCPtr pGCPriv = GET_GC_PRIVATE(pGC);\
- GCFuncs *oldFuncs = pGC->funcs;\
- pGC->funcs = pGCPriv->funcs;\
- pGC->ops = pGCPriv->ops
-
-
-#define SHADOW_GC_OP_EPILOGUE(pGC)\
- pGCPriv->ops = pGC->ops;\
- pGC->funcs = oldFuncs;\
- pGC->ops = &ShadowGCOps
-
-#define IS_VISIBLE(pWin) (pPriv->vtSema && \
- (((WindowPtr)pWin)->visibility != VisibilityFullyObscured))
-
-#define TRIM_BOX(box, pGC) { \
- BoxPtr extents = &pGC->pCompositeClip->extents;\
- if(box.x1 < extents->x1) box.x1 = extents->x1; \
- if(box.x2 > extents->x2) box.x2 = extents->x2; \
- if(box.y1 < extents->y1) box.y1 = extents->y1; \
- if(box.y2 > extents->y2) box.y2 = extents->y2; \
- }
-
-#define TRANSLATE_BOX(box, pDraw) { \
- box.x1 += pDraw->x; \
- box.x2 += pDraw->x; \
- box.y1 += pDraw->y; \
- box.y2 += pDraw->y; \
- }
-
-#define TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC) { \
- TRANSLATE_BOX(box, pDraw); \
- TRIM_BOX(box, pGC); \
- }
-
-#define BOX_NOT_EMPTY(box) \
- (((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0))
-
-
-
-Bool
-ShadowFBInit2 (
- ScreenPtr pScreen,
- RefreshAreaFuncPtr preRefreshArea,
- RefreshAreaFuncPtr postRefreshArea
-){
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- ShadowScreenPtr pPriv;
- PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
-
- if(!preRefreshArea && !postRefreshArea) return FALSE;
-
- if (!dixRegisterPrivateKey(&ShadowScreenKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
-
- if(!dixRegisterPrivateKey(&ShadowGCKeyRec, PRIVATE_GC, sizeof(ShadowGCRec)))
- return FALSE;
-
- if(!(pPriv = (ShadowScreenPtr)malloc(sizeof(ShadowScreenRec))))
- return FALSE;
-
- dixSetPrivate(&pScreen->devPrivates, ShadowScreenKey, pPriv);
-
- pPriv->pScrn = pScrn;
- pPriv->preRefresh = preRefreshArea;
- pPriv->postRefresh = postRefreshArea;
- pPriv->vtSema = TRUE;
-
- pPriv->CloseScreen = pScreen->CloseScreen;
- pPriv->CopyWindow = pScreen->CopyWindow;
- pPriv->CreateGC = pScreen->CreateGC;
- pPriv->ModifyPixmapHeader = pScreen->ModifyPixmapHeader;
-
- pPriv->EnterVT = pScrn->EnterVT;
- pPriv->LeaveVT = pScrn->LeaveVT;
-
- pScreen->CloseScreen = ShadowCloseScreen;
- pScreen->CopyWindow = ShadowCopyWindow;
- pScreen->CreateGC = ShadowCreateGC;
-
- pScrn->EnterVT = ShadowEnterVT;
- pScrn->LeaveVT = ShadowLeaveVT;
-
- if(ps) {
- pPriv->Composite = ps->Composite;
- ps->Composite = ShadowComposite;
- }
-
- return TRUE;
-}
-
-Bool
-ShadowFBInit (
- ScreenPtr pScreen,
- RefreshAreaFuncPtr refreshArea
-){
- return ShadowFBInit2(pScreen, NULL, refreshArea);
-}
-
-/**********************************************************/
-
-static Bool
-ShadowEnterVT(int index, int flags)
-{
- ScrnInfoPtr pScrn = xf86Screens[index];
- Bool ret;
- ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScrn->pScreen);
-
- pScrn->EnterVT = pPriv->EnterVT;
- ret = (*pPriv->EnterVT)(index, flags);
- pPriv->EnterVT = pScrn->EnterVT;
- pScrn->EnterVT = ShadowEnterVT;
- if(ret) {
- pPriv->vtSema = TRUE;
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-ShadowLeaveVT(int index, int flags)
-{
- ScrnInfoPtr pScrn = xf86Screens[index];
- ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(xf86Screens[index]->pScreen);
-
- pPriv->vtSema = FALSE;
-
- pScrn->LeaveVT = pPriv->LeaveVT;
- (*pPriv->LeaveVT)(index, flags);
- pPriv->LeaveVT = pScrn->LeaveVT;
- pScrn->LeaveVT = ShadowLeaveVT;
-}
-
-/**********************************************************/
-
-
-static Bool
-ShadowCloseScreen (int i, ScreenPtr pScreen)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen);
- PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
-
- pScreen->CloseScreen = pPriv->CloseScreen;
- pScreen->CopyWindow = pPriv->CopyWindow;
- pScreen->CreateGC = pPriv->CreateGC;
- pScreen->ModifyPixmapHeader = pPriv->ModifyPixmapHeader;
-
- pScrn->EnterVT = pPriv->EnterVT;
- pScrn->LeaveVT = pPriv->LeaveVT;
-
- if(ps) {
- ps->Composite = pPriv->Composite;
- }
-
- free((pointer)pPriv);
-
- return (*pScreen->CloseScreen) (i, pScreen);
-}
-
-static void
-ShadowCopyWindow(
- WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgn
-){
- ScreenPtr pScreen = pWin->drawable.pScreen;
- ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen);
- int num = 0;
- RegionRec rgnDst;
-
- if (pPriv->vtSema) {
- RegionNull(&rgnDst);
- RegionCopy(&rgnDst, prgn);
-
- RegionTranslate(&rgnDst,
- pWin->drawable.x - ptOldOrg.x,
- pWin->drawable.y - ptOldOrg.y);
- RegionIntersect(&rgnDst, &pWin->borderClip, &rgnDst);
- if ((num = RegionNumRects(&rgnDst))) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, num, RegionRects(&rgnDst));
- } else {
- RegionUninit(&rgnDst);
- }
- }
-
- pScreen->CopyWindow = pPriv->CopyWindow;
- (*pScreen->CopyWindow) (pWin, ptOldOrg, prgn);
- pScreen->CopyWindow = ShadowCopyWindow;
-
- if (num) {
- if (pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, num, RegionRects(&rgnDst));
- RegionUninit(&rgnDst);
- }
-}
-
-static void
-ShadowComposite(
- CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst,
- CARD16 width,
- CARD16 height
-){
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen);
- PictureScreenPtr ps = GetPictureScreen(pScreen);
- BoxRec box;
- BoxPtr extents;
- Bool boxNotEmpty = FALSE;
-
- if (pPriv->vtSema
- && pDst->pDrawable->type == DRAWABLE_WINDOW) {
-
- box.x1 = pDst->pDrawable->x + xDst;
- box.y1 = pDst->pDrawable->y + yDst;
- box.x2 = box.x1 + width;
- box.y2 = box.y1 + height;
-
- extents = &pDst->pCompositeClip->extents;
- if(box.x1 < extents->x1) box.x1 = extents->x1;
- if(box.x2 > extents->x2) box.x2 = extents->x2;
- if(box.y1 < extents->y1) box.y1 = extents->y1;
- if(box.y2 > extents->y2) box.y2 = extents->y2;
-
- if (BOX_NOT_EMPTY(box)) {
- if (pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
- }
-
- ps->Composite = pPriv->Composite;
- (*ps->Composite)(op, pSrc, pMask, pDst, xSrc, ySrc,
- xMask, yMask, xDst, yDst, width, height);
- ps->Composite = ShadowComposite;
-
- if (pPriv->postRefresh && boxNotEmpty) {
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
- }
-}
-
-/**********************************************************/
-
-static void ShadowValidateGC(GCPtr, unsigned long, DrawablePtr);
-static void ShadowChangeGC(GCPtr, unsigned long);
-static void ShadowCopyGC(GCPtr, unsigned long, GCPtr);
-static void ShadowDestroyGC(GCPtr);
-static void ShadowChangeClip(GCPtr, int, pointer, int);
-static void ShadowDestroyClip(GCPtr);
-static void ShadowCopyClip(GCPtr, GCPtr);
-
-GCFuncs ShadowGCFuncs = {
- ShadowValidateGC, ShadowChangeGC, ShadowCopyGC, ShadowDestroyGC,
- ShadowChangeClip, ShadowDestroyClip, ShadowCopyClip
-};
-
-
-extern GCOps ShadowGCOps;
-
-static Bool
-ShadowCreateGC(GCPtr pGC)
-{
- ScreenPtr pScreen = pGC->pScreen;
- ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen);
- ShadowGCPtr pGCPriv = GET_GC_PRIVATE(pGC);
- Bool ret;
-
- pScreen->CreateGC = pPriv->CreateGC;
- if((ret = (*pScreen->CreateGC) (pGC))) {
- pGCPriv->ops = NULL;
- pGCPriv->funcs = pGC->funcs;
- pGC->funcs = &ShadowGCFuncs;
- }
- pScreen->CreateGC = ShadowCreateGC;
-
- return ret;
-}
-
-
-static void
-ShadowValidateGC(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw
-){
- SHADOW_GC_FUNC_PROLOGUE (pGC);
- (*pGC->funcs->ValidateGC)(pGC, changes, pDraw);
- if(pDraw->type == DRAWABLE_WINDOW)
- pGCPriv->ops = pGC->ops; /* just so it's not NULL */
- else
- pGCPriv->ops = NULL;
- SHADOW_GC_FUNC_EPILOGUE (pGC);
-}
-
-
-static void
-ShadowDestroyGC(GCPtr pGC)
-{
- SHADOW_GC_FUNC_PROLOGUE (pGC);
- (*pGC->funcs->DestroyGC)(pGC);
- SHADOW_GC_FUNC_EPILOGUE (pGC);
-}
-
-static void
-ShadowChangeGC (
- GCPtr pGC,
- unsigned long mask
-){
- SHADOW_GC_FUNC_PROLOGUE (pGC);
- (*pGC->funcs->ChangeGC) (pGC, mask);
- SHADOW_GC_FUNC_EPILOGUE (pGC);
-}
-
-static void
-ShadowCopyGC (
- GCPtr pGCSrc,
- unsigned long mask,
- GCPtr pGCDst
-){
- SHADOW_GC_FUNC_PROLOGUE (pGCDst);
- (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
- SHADOW_GC_FUNC_EPILOGUE (pGCDst);
-}
-
-static void
-ShadowChangeClip (
- GCPtr pGC,
- int type,
- pointer pvalue,
- int nrects
-){
- SHADOW_GC_FUNC_PROLOGUE (pGC);
- (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
- SHADOW_GC_FUNC_EPILOGUE (pGC);
-}
-
-static void
-ShadowCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
-{
- SHADOW_GC_FUNC_PROLOGUE (pgcDst);
- (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
- SHADOW_GC_FUNC_EPILOGUE (pgcDst);
-}
-
-static void
-ShadowDestroyClip(GCPtr pGC)
-{
- SHADOW_GC_FUNC_PROLOGUE (pGC);
- (* pGC->funcs->DestroyClip)(pGC);
- SHADOW_GC_FUNC_EPILOGUE (pGC);
-}
-
-
-
-
-/**********************************************************/
-
-
-static void
-ShadowFillSpans(
- DrawablePtr pDraw,
- GC *pGC,
- int nInit,
- DDXPointPtr pptInit,
- int *pwidthInit,
- int fSorted
-){
- SHADOW_GC_OP_PROLOGUE(pGC);
-
- if(IS_VISIBLE(pDraw) && nInit) {
- DDXPointPtr ppt = pptInit;
- int *pwidth = pwidthInit;
- int i = nInit;
- BoxRec box;
- Bool boxNotEmpty = FALSE;
-
- box.x1 = ppt->x;
- box.x2 = box.x1 + *pwidth;
- box.y2 = box.y1 = ppt->y;
-
- while(--i) {
- ppt++;
- pwidth++;
- if(box.x1 > ppt->x) box.x1 = ppt->x;
- if(box.x2 < (ppt->x + *pwidth))
- box.x2 = ppt->x + *pwidth;
- if(box.y1 > ppt->y) box.y1 = ppt->y;
- else if(box.y2 < ppt->y) box.y2 = ppt->y;
- }
-
- box.y2++;
-
- if(!pGC->miTranslate) {
- TRANSLATE_BOX(box, pDraw);
- }
- TRIM_BOX(box, pGC);
-
- if(BOX_NOT_EMPTY(box)) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
-
- (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
-
- if(boxNotEmpty && pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
- } else
- (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
-
- SHADOW_GC_OP_EPILOGUE(pGC);
-}
-
-static void
-ShadowSetSpans(
- DrawablePtr pDraw,
- GCPtr pGC,
- char *pcharsrc,
- DDXPointPtr pptInit,
- int *pwidthInit,
- int nspans,
- int fSorted
-){
- SHADOW_GC_OP_PROLOGUE(pGC);
-
- if(IS_VISIBLE(pDraw) && nspans) {
- DDXPointPtr ppt = pptInit;
- int *pwidth = pwidthInit;
- int i = nspans;
- BoxRec box;
- Bool boxNotEmpty = FALSE;
-
- box.x1 = ppt->x;
- box.x2 = box.x1 + *pwidth;
- box.y2 = box.y1 = ppt->y;
-
- while(--i) {
- ppt++;
- pwidth++;
- if(box.x1 > ppt->x) box.x1 = ppt->x;
- if(box.x2 < (ppt->x + *pwidth))
- box.x2 = ppt->x + *pwidth;
- if(box.y1 > ppt->y) box.y1 = ppt->y;
- else if(box.y2 < ppt->y) box.y2 = ppt->y;
- }
-
- box.y2++;
-
- if(!pGC->miTranslate) {
- TRANSLATE_BOX(box, pDraw);
- }
- TRIM_BOX(box, pGC);
-
- if(BOX_NOT_EMPTY(box)) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
-
- (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, pptInit,
- pwidthInit, nspans, fSorted);
-
- if(boxNotEmpty && pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
- } else
- (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, pptInit,
- pwidthInit, nspans, fSorted);
-
- SHADOW_GC_OP_EPILOGUE(pGC);
-}
-
-static void
-ShadowPutImage(
- DrawablePtr pDraw,
- GCPtr pGC,
- int depth,
- int x, int y, int w, int h,
- int leftPad,
- int format,
- char *pImage
-){
- BoxRec box;
- Bool boxNotEmpty = FALSE;
-
- SHADOW_GC_OP_PROLOGUE(pGC);
-
- if(IS_VISIBLE(pDraw)) {
- box.x1 = x + pDraw->x;
- box.x2 = box.x1 + w;
- box.y1 = y + pDraw->y;
- box.y2 = box.y1 + h;
-
- TRIM_BOX(box, pGC);
- if(BOX_NOT_EMPTY(box)) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
- }
-
- (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h,
- leftPad, format, pImage);
-
- if(boxNotEmpty && pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
-
- SHADOW_GC_OP_EPILOGUE(pGC);
-
-}
-
-static RegionPtr
-ShadowCopyArea(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GC *pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty
-){
- RegionPtr ret;
- BoxRec box;
- Bool boxNotEmpty = FALSE;
-
- SHADOW_GC_OP_PROLOGUE(pGC);
-
- if(IS_VISIBLE(pDst)) {
- box.x1 = dstx + pDst->x;
- box.x2 = box.x1 + width;
- box.y1 = dsty + pDst->y;
- box.y2 = box.y1 + height;
-
- TRIM_BOX(box, pGC);
- if(BOX_NOT_EMPTY(box)) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
- }
-
- ret = (*pGC->ops->CopyArea)(pSrc, pDst,
- pGC, srcx, srcy, width, height, dstx, dsty);
-
- if(boxNotEmpty && pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
-
- SHADOW_GC_OP_EPILOGUE(pGC);
-
- return ret;
-}
-
-static RegionPtr
-ShadowCopyPlane(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GCPtr pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty,
- unsigned long bitPlane
-){
- RegionPtr ret;
- BoxRec box;
- Bool boxNotEmpty = FALSE;
-
- SHADOW_GC_OP_PROLOGUE(pGC);
-
- if(IS_VISIBLE(pDst)) {
- box.x1 = dstx + pDst->x;
- box.x2 = box.x1 + width;
- box.y1 = dsty + pDst->y;
- box.y2 = box.y1 + height;
-
- TRIM_BOX(box, pGC);
- if(BOX_NOT_EMPTY(box)) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
- }
-
- ret = (*pGC->ops->CopyPlane)(pSrc, pDst,
- pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
-
- if(boxNotEmpty && pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
-
- SHADOW_GC_OP_EPILOGUE(pGC);
-
- return ret;
-}
-
-static void
-ShadowPolyPoint(
- DrawablePtr pDraw,
- GCPtr pGC,
- int mode,
- int nptInit,
- xPoint *pptInit
-){
- BoxRec box;
- Bool boxNotEmpty = FALSE;
-
- SHADOW_GC_OP_PROLOGUE(pGC);
-
- if(IS_VISIBLE(pDraw) && nptInit) {
- xPoint *ppt = pptInit;
- int npt = nptInit;
-
- box.x2 = box.x1 = pptInit->x;
- box.y2 = box.y1 = pptInit->y;
-
- /* this could be slow if the points were spread out */
-
- while(--npt) {
- ppt++;
- if(box.x1 > ppt->x) box.x1 = ppt->x;
- else if(box.x2 < ppt->x) box.x2 = ppt->x;
- if(box.y1 > ppt->y) box.y1 = ppt->y;
- else if(box.y2 < ppt->y) box.y2 = ppt->y;
- }
-
- box.x2++;
- box.y2++;
-
- TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
- if(BOX_NOT_EMPTY(box)) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
- }
-
- (*pGC->ops->PolyPoint)(pDraw, pGC, mode, nptInit, pptInit);
-
- if(boxNotEmpty && pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
-
- SHADOW_GC_OP_EPILOGUE(pGC);
-}
-
-static void
-ShadowPolylines(
- DrawablePtr pDraw,
- GCPtr pGC,
- int mode,
- int nptInit,
- DDXPointPtr pptInit
-){
- BoxRec box;
- Bool boxNotEmpty = FALSE;
-
- SHADOW_GC_OP_PROLOGUE(pGC);
-
- if(IS_VISIBLE(pDraw) && nptInit) {
- DDXPointPtr ppt = pptInit;
- int npt = nptInit;
- int extra = pGC->lineWidth >> 1;
-
- box.x2 = box.x1 = pptInit->x;
- box.y2 = box.y1 = pptInit->y;
-
- if(npt > 1) {
- if(pGC->joinStyle == JoinMiter)
- extra = 6 * pGC->lineWidth;
- else if(pGC->capStyle == CapProjecting)
- extra = pGC->lineWidth;
- }
-
- if(mode == CoordModePrevious) {
- int x = box.x1;
- int y = box.y1;
- while(--npt) {
- ppt++;
- x += ppt->x;
- y += ppt->y;
- if(box.x1 > x) box.x1 = x;
- else if(box.x2 < x) box.x2 = x;
- if(box.y1 > y) box.y1 = y;
- else if(box.y2 < y) box.y2 = y;
- }
- } else {
- while(--npt) {
- ppt++;
- if(box.x1 > ppt->x) box.x1 = ppt->x;
- else if(box.x2 < ppt->x) box.x2 = ppt->x;
- if(box.y1 > ppt->y) box.y1 = ppt->y;
- else if(box.y2 < ppt->y) box.y2 = ppt->y;
- }
- }
-
- box.x2++;
- box.y2++;
-
- if(extra) {
- box.x1 -= extra;
- box.x2 += extra;
- box.y1 -= extra;
- box.y2 += extra;
- }
-
- TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
- if(BOX_NOT_EMPTY(box)) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
- }
-
- (*pGC->ops->Polylines)(pDraw, pGC, mode, nptInit, pptInit);
-
- if(boxNotEmpty && pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
-
- SHADOW_GC_OP_EPILOGUE(pGC);
-}
-
-static void
-ShadowPolySegment(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nsegInit,
- xSegment *pSegInit
-){
- BoxRec box;
- Bool boxNotEmpty = FALSE;
-
- SHADOW_GC_OP_PROLOGUE(pGC);
-
- if(IS_VISIBLE(pDraw) && nsegInit) {
- int extra = pGC->lineWidth;
- xSegment *pSeg = pSegInit;
- int nseg = nsegInit;
-
- if(pGC->capStyle != CapProjecting)
- extra >>= 1;
-
- if(pSeg->x2 > pSeg->x1) {
- box.x1 = pSeg->x1;
- box.x2 = pSeg->x2;
- } else {
- box.x2 = pSeg->x1;
- box.x1 = pSeg->x2;
- }
-
- if(pSeg->y2 > pSeg->y1) {
- box.y1 = pSeg->y1;
- box.y2 = pSeg->y2;
- } else {
- box.y2 = pSeg->y1;
- box.y1 = pSeg->y2;
- }
-
- while(--nseg) {
- pSeg++;
- if(pSeg->x2 > pSeg->x1) {
- if(pSeg->x1 < box.x1) box.x1 = pSeg->x1;
- if(pSeg->x2 > box.x2) box.x2 = pSeg->x2;
- } else {
- if(pSeg->x2 < box.x1) box.x1 = pSeg->x2;
- if(pSeg->x1 > box.x2) box.x2 = pSeg->x1;
- }
- if(pSeg->y2 > pSeg->y1) {
- if(pSeg->y1 < box.y1) box.y1 = pSeg->y1;
- if(pSeg->y2 > box.y2) box.y2 = pSeg->y2;
- } else {
- if(pSeg->y2 < box.y1) box.y1 = pSeg->y2;
- if(pSeg->y1 > box.y2) box.y2 = pSeg->y1;
- }
- }
-
- box.x2++;
- box.y2++;
-
- if(extra) {
- box.x1 -= extra;
- box.x2 += extra;
- box.y1 -= extra;
- box.y2 += extra;
- }
-
- TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
- if(BOX_NOT_EMPTY(box)) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
- }
-
- (*pGC->ops->PolySegment)(pDraw, pGC, nsegInit, pSegInit);
-
- if(boxNotEmpty && pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
-
- SHADOW_GC_OP_EPILOGUE(pGC);
-}
-
-static void
-ShadowPolyRectangle(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nRectsInit,
- xRectangle *pRectsInit
-){
- BoxRec box;
- BoxPtr pBoxInit = NULL;
- Bool boxNotEmpty = FALSE;
- int num = 0;
-
- SHADOW_GC_OP_PROLOGUE(pGC);
-
- if(IS_VISIBLE(pDraw) && nRectsInit) {
- xRectangle *pRects = pRectsInit;
- int nRects = nRectsInit;
-
- if(nRects >= 32) {
- int extra = pGC->lineWidth >> 1;
-
- box.x1 = pRects->x;
- box.x2 = box.x1 + pRects->width;
- box.y1 = pRects->y;
- box.y2 = box.y1 + pRects->height;
-
- while(--nRects) {
- pRects++;
- if(box.x1 > pRects->x) box.x1 = pRects->x;
- if(box.x2 < (pRects->x + pRects->width))
- box.x2 = pRects->x + pRects->width;
- if(box.y1 > pRects->y) box.y1 = pRects->y;
- if(box.y2 < (pRects->y + pRects->height))
- box.y2 = pRects->y + pRects->height;
- }
-
- if(extra) {
- box.x1 -= extra;
- box.x2 += extra;
- box.y1 -= extra;
- box.y2 += extra;
- }
-
- box.x2++;
- box.y2++;
-
- TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
- if(BOX_NOT_EMPTY(box)) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
- } else {
- BoxPtr pbox;
- int offset1, offset2, offset3;
-
- offset2 = pGC->lineWidth;
- if(!offset2) offset2 = 1;
- offset1 = offset2 >> 1;
- offset3 = offset2 - offset1;
-
- pBoxInit = (BoxPtr)malloc(nRects * 4 * sizeof(BoxRec));
- pbox = pBoxInit;
-
- while(nRects--) {
- pbox->x1 = pRects->x - offset1;
- pbox->y1 = pRects->y - offset1;
- pbox->x2 = pbox->x1 + pRects->width + offset2;
- pbox->y2 = pbox->y1 + offset2;
- TRIM_AND_TRANSLATE_BOX((*pbox), pDraw, pGC);
- if(BOX_NOT_EMPTY((*pbox))) {
- num++;
- pbox++;
- }
-
- pbox->x1 = pRects->x - offset1;
- pbox->y1 = pRects->y + offset3;
- pbox->x2 = pbox->x1 + offset2;
- pbox->y2 = pbox->y1 + pRects->height - offset2;
- TRIM_AND_TRANSLATE_BOX((*pbox), pDraw, pGC);
- if(BOX_NOT_EMPTY((*pbox))) {
- num++;
- pbox++;
- }
-
- pbox->x1 = pRects->x + pRects->width - offset1;
- pbox->y1 = pRects->y + offset3;
- pbox->x2 = pbox->x1 + offset2;
- pbox->y2 = pbox->y1 + pRects->height - offset2;
- TRIM_AND_TRANSLATE_BOX((*pbox), pDraw, pGC);
- if(BOX_NOT_EMPTY((*pbox))) {
- num++;
- pbox++;
- }
-
- pbox->x1 = pRects->x - offset1;
- pbox->y1 = pRects->y + pRects->height - offset1;
- pbox->x2 = pbox->x1 + pRects->width + offset2;
- pbox->y2 = pbox->y1 + offset2;
- TRIM_AND_TRANSLATE_BOX((*pbox), pDraw, pGC);
- if(BOX_NOT_EMPTY((*pbox))) {
- num++;
- pbox++;
- }
-
- pRects++;
- }
-
- if(num) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, num, pBoxInit);
- } else {
- free(pBoxInit);
- }
- }
- }
-
- (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit);
-
- if(boxNotEmpty && pPriv->postRefresh) {
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
- } else if(num) {
- if(pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, num, pBoxInit);
- free(pBoxInit);
- }
-
- SHADOW_GC_OP_EPILOGUE(pGC);
-
-}
-
-static void
-ShadowPolyArc(
- DrawablePtr pDraw,
- GCPtr pGC,
- int narcsInit,
- xArc *parcsInit
-){
- BoxRec box;
- Bool boxNotEmpty = FALSE;
-
- SHADOW_GC_OP_PROLOGUE(pGC);
-
- if(IS_VISIBLE(pDraw) && narcsInit) {
- int narcs = narcsInit;
- xArc *parcs = parcsInit;
- int extra = pGC->lineWidth >> 1;
-
- box.x1 = parcs->x;
- box.x2 = box.x1 + parcs->width;
- box.y1 = parcs->y;
- box.y2 = box.y1 + parcs->height;
-
- /* should I break these up instead ? */
-
- while(--narcs) {
- parcs++;
- if(box.x1 > parcs->x) box.x1 = parcs->x;
- if(box.x2 < (parcs->x + parcs->width))
- box.x2 = parcs->x + parcs->width;
- if(box.y1 > parcs->y) box.y1 = parcs->y;
- if(box.y2 < (parcs->y + parcs->height))
- box.y2 = parcs->y + parcs->height;
- }
-
- if(extra) {
- box.x1 -= extra;
- box.x2 += extra;
- box.y1 -= extra;
- box.y2 += extra;
- }
-
- box.x2++;
- box.y2++;
-
- TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
- if(BOX_NOT_EMPTY(box)) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
- }
-
- (*pGC->ops->PolyArc)(pDraw, pGC, narcsInit, parcsInit);
-
- if(boxNotEmpty && pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
-
- SHADOW_GC_OP_EPILOGUE(pGC);
-
-}
-
-static void
-ShadowFillPolygon(
- DrawablePtr pDraw,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr pptInit
-){
- SHADOW_GC_OP_PROLOGUE(pGC);
-
- if(IS_VISIBLE(pDraw) && (count > 2)) {
- DDXPointPtr ppt = pptInit;
- int i = count;
- BoxRec box;
- Bool boxNotEmpty = FALSE;
-
- box.x2 = box.x1 = ppt->x;
- box.y2 = box.y1 = ppt->y;
-
- if(mode != CoordModeOrigin) {
- int x = box.x1;
- int y = box.y1;
- while(--i) {
- ppt++;
- x += ppt->x;
- y += ppt->y;
- if(box.x1 > x) box.x1 = x;
- else if(box.x2 < x) box.x2 = x;
- if(box.y1 > y) box.y1 = y;
- else if(box.y2 < y) box.y2 = y;
- }
- } else {
- while(--i) {
- ppt++;
- if(box.x1 > ppt->x) box.x1 = ppt->x;
- else if(box.x2 < ppt->x) box.x2 = ppt->x;
- if(box.y1 > ppt->y) box.y1 = ppt->y;
- else if(box.y2 < ppt->y) box.y2 = ppt->y;
- }
- }
-
- box.x2++;
- box.y2++;
-
- TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
- if(BOX_NOT_EMPTY(box)) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
-
- (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, pptInit);
-
- if(boxNotEmpty && pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
- } else
- (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, pptInit);
-
- SHADOW_GC_OP_EPILOGUE(pGC);
-}
-
-
-static void
-ShadowPolyFillRect(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nRectsInit,
- xRectangle *pRectsInit
-){
- SHADOW_GC_OP_PROLOGUE(pGC);
-
- if(IS_VISIBLE(pDraw) && nRectsInit) {
- BoxRec box;
- Bool boxNotEmpty = FALSE;
- xRectangle *pRects = pRectsInit;
- int nRects = nRectsInit;
-
- box.x1 = pRects->x;
- box.x2 = box.x1 + pRects->width;
- box.y1 = pRects->y;
- box.y2 = box.y1 + pRects->height;
-
- while(--nRects) {
- pRects++;
- if(box.x1 > pRects->x) box.x1 = pRects->x;
- if(box.x2 < (pRects->x + pRects->width))
- box.x2 = pRects->x + pRects->width;
- if(box.y1 > pRects->y) box.y1 = pRects->y;
- if(box.y2 < (pRects->y + pRects->height))
- box.y2 = pRects->y + pRects->height;
- }
-
- /* cfb messes with the pRectsInit so we have to do our
- calculations first */
-
- TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
- if(BOX_NOT_EMPTY(box)) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
-
- (*pGC->ops->PolyFillRect)(pDraw, pGC, nRectsInit, pRectsInit);
-
- if(boxNotEmpty && pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
- } else
- (*pGC->ops->PolyFillRect)(pDraw, pGC, nRectsInit, pRectsInit);
-
- SHADOW_GC_OP_EPILOGUE(pGC);
-}
-
-
-static void
-ShadowPolyFillArc(
- DrawablePtr pDraw,
- GCPtr pGC,
- int narcsInit,
- xArc *parcsInit
-){
- BoxRec box;
- Bool boxNotEmpty = FALSE;
-
- SHADOW_GC_OP_PROLOGUE(pGC);
-
- if(IS_VISIBLE(pDraw) && narcsInit) {
- xArc *parcs = parcsInit;
- int narcs = narcsInit;
-
- box.x1 = parcs->x;
- box.x2 = box.x1 + parcs->width;
- box.y1 = parcs->y;
- box.y2 = box.y1 + parcs->height;
-
- /* should I break these up instead ? */
-
- while(--narcs) {
- parcs++;
- if(box.x1 > parcs->x) box.x1 = parcs->x;
- if(box.x2 < (parcs->x + parcs->width))
- box.x2 = parcs->x + parcs->width;
- if(box.y1 > parcs->y) box.y1 = parcs->y;
- if(box.y2 < (parcs->y + parcs->height))
- box.y2 = parcs->y + parcs->height;
- }
-
- TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
- if(BOX_NOT_EMPTY(box)) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
- }
-
- (*pGC->ops->PolyFillArc)(pDraw, pGC, narcsInit, parcsInit);
-
- if(boxNotEmpty && pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
-
- SHADOW_GC_OP_EPILOGUE(pGC);
-}
-
-static void
-ShadowTextExtent(FontPtr pFont, int count, char* chars,
- FontEncoding fontEncoding, BoxPtr box)
-{
- unsigned long n, i;
- int w;
- CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */
-
- GetGlyphs(pFont, (unsigned long)count, (unsigned char *)chars,
- fontEncoding, &n, charinfo);
- w = 0;
- for (i=0; i < n; i++) {
- w += charinfo[i]->metrics.characterWidth;
- }
- if (i) {
- w += charinfo[i - 1]->metrics.rightSideBearing;
- }
-
- box->x1 = 0;
- if (n) {
- if (charinfo[0]->metrics.leftSideBearing < 0) {
- box->x1 = charinfo[0]->metrics.leftSideBearing;
- }
- }
- box->x2 = w;
- box->y1 = -FONTMAXBOUNDS(pFont,ascent);
- box->y2 = FONTMAXBOUNDS(pFont,descent);
-}
-
-
-
-static void
-ShadowFontToBox(BoxPtr BB, DrawablePtr pDrawable, GCPtr pGC, int x, int y,
- int count, char *chars, int wide)
-{
- FontPtr pFont;
-
- pFont = pGC->font;
- if (pFont->info.constantWidth) {
- int ascent, descent, left, right = 0;
-
- ascent = max(pFont->info.fontAscent, pFont->info.maxbounds.ascent);
- descent = max(pFont->info.fontDescent, pFont->info.maxbounds.descent);
- left = pFont->info.maxbounds.leftSideBearing;
- if (count > 0) {
- right = (count - 1) * pFont->info.maxbounds.characterWidth;
- }
- right += pFont->info.maxbounds.rightSideBearing;
- BB->x1 =
- max(pDrawable->x + x - left,
- RegionExtents(&((WindowPtr) pDrawable)->winSize)->x1);
- BB->y1 =
- max(pDrawable->y + y - ascent,
- RegionExtents(&((WindowPtr) pDrawable)->winSize)->y1);
- BB->x2 =
- min(pDrawable->x + x + right,
- RegionExtents(&((WindowPtr) pDrawable)->winSize)->x2);
- BB->y2 =
- min(pDrawable->y + y + descent,
- RegionExtents(&((WindowPtr) pDrawable)->winSize)->y2);
- } else {
- ShadowTextExtent(pFont, count, chars, wide ? (FONTLASTROW(pFont) == 0)
- ? Linear16Bit : TwoD16Bit : Linear8Bit, BB);
- BB->x1 =
- max(pDrawable->x + x + BB->x1,
- RegionExtents(&((WindowPtr) pDrawable)->winSize)->x1);
- BB->y1 =
- max(pDrawable->y + y + BB->y1,
- RegionExtents(&((WindowPtr) pDrawable)->winSize)->y1);
- BB->x2 =
- min(pDrawable->x + x + BB->x2,
- RegionExtents(&((WindowPtr) pDrawable)->winSize)->x2);
- BB->y2 =
- min(pDrawable->y + y + BB->y2,
- RegionExtents(&((WindowPtr) pDrawable)->winSize)->y2);
- }
-}
-
-static int
-ShadowPolyText8(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- char *chars
-){
- int width;
- BoxRec box;
- Bool boxNotEmpty = FALSE;
-
- SHADOW_GC_OP_PROLOGUE(pGC);
-
- if(IS_VISIBLE(pDraw)) {
- ShadowFontToBox(&box, pDraw, pGC, x, y, count, chars, 0);
-
- TRIM_BOX(box, pGC);
- if(BOX_NOT_EMPTY(box)) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
- }
-
- width = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars);
-
- if(boxNotEmpty && pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
-
- SHADOW_GC_OP_EPILOGUE(pGC);
-
- return width;
-}
-
-static int
-ShadowPolyText16(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- unsigned short *chars
-){
- int width;
- BoxRec box;
- Bool boxNotEmpty = FALSE;
-
- SHADOW_GC_OP_PROLOGUE(pGC);
-
- if(IS_VISIBLE(pDraw)) {
- ShadowFontToBox(&box, pDraw, pGC, x, y, count, (char*)chars, 1);
-
- TRIM_BOX(box, pGC);
- if(BOX_NOT_EMPTY(box)) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
- }
-
- width = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars);
-
- if(boxNotEmpty && pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
-
- SHADOW_GC_OP_EPILOGUE(pGC);
-
- return width;
-}
-
-static void
-ShadowImageText8(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- char *chars
-){
- BoxRec box;
- Bool boxNotEmpty = FALSE;
- SHADOW_GC_OP_PROLOGUE(pGC);
-
- if(IS_VISIBLE(pDraw) && count) {
- int top, bot, Min, Max;
-
- top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
- bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
-
- Min = count * FONTMINBOUNDS(pGC->font, characterWidth);
- if(Min > 0) Min = 0;
- Max = count * FONTMAXBOUNDS(pGC->font, characterWidth);
- if(Max < 0) Max = 0;
-
- /* ugh */
- box.x1 = pDraw->x + x + Min +
- FONTMINBOUNDS(pGC->font, leftSideBearing);
- box.x2 = pDraw->x + x + Max +
- FONTMAXBOUNDS(pGC->font, rightSideBearing);
-
- box.y1 = pDraw->y + y - top;
- box.y2 = pDraw->y + y + bot;
-
- TRIM_BOX(box, pGC);
- if(BOX_NOT_EMPTY(box)) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
- }
-
- (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars);
-
- if(boxNotEmpty && pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
-
- SHADOW_GC_OP_EPILOGUE(pGC);
-}
-static void
-ShadowImageText16(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- unsigned short *chars
-){
- BoxRec box;
- Bool boxNotEmpty = FALSE;
- SHADOW_GC_OP_PROLOGUE(pGC);
-
- if(IS_VISIBLE(pDraw) && count) {
- int top, bot, Min, Max;
-
- top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
- bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
-
- Min = count * FONTMINBOUNDS(pGC->font, characterWidth);
- if(Min > 0) Min = 0;
- Max = count * FONTMAXBOUNDS(pGC->font, characterWidth);
- if(Max < 0) Max = 0;
-
- /* ugh */
- box.x1 = pDraw->x + x + Min +
- FONTMINBOUNDS(pGC->font, leftSideBearing);
- box.x2 = pDraw->x + x + Max +
- FONTMAXBOUNDS(pGC->font, rightSideBearing);
-
- box.y1 = pDraw->y + y - top;
- box.y2 = pDraw->y + y + bot;
-
- TRIM_BOX(box, pGC);
- if(BOX_NOT_EMPTY(box)) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
- }
-
- (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars);
-
- if(boxNotEmpty && pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
-
- SHADOW_GC_OP_EPILOGUE(pGC);
-}
-
-
-static void
-ShadowImageGlyphBlt(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- unsigned int nglyphInit,
- CharInfoPtr *ppciInit,
- pointer pglyphBase
-){
- BoxRec box;
- Bool boxNotEmpty = FALSE;
- SHADOW_GC_OP_PROLOGUE(pGC);
-
- if(IS_VISIBLE(pDraw) && nglyphInit) {
- CharInfoPtr *ppci = ppciInit;
- unsigned int nglyph = nglyphInit;
- int top, bot, width = 0;
-
- top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
- bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
-
- box.x1 = ppci[0]->metrics.leftSideBearing;
- if(box.x1 > 0) box.x1 = 0;
- box.x2 = ppci[nglyph - 1]->metrics.rightSideBearing -
- ppci[nglyph - 1]->metrics.characterWidth;
- if(box.x2 < 0) box.x2 = 0;
-
- box.x2 += pDraw->x + x;
- box.x1 += pDraw->x + x;
-
- while(nglyph--) {
- width += (*ppci)->metrics.characterWidth;
- ppci++;
- }
-
- if(width > 0)
- box.x2 += width;
- else
- box.x1 += width;
-
- box.y1 = pDraw->y + y - top;
- box.y2 = pDraw->y + y + bot;
-
- TRIM_BOX(box, pGC);
- if(BOX_NOT_EMPTY(box)) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
- }
-
- (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, x, y, nglyphInit,
- ppciInit, pglyphBase);
-
- if(boxNotEmpty && pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
-
- SHADOW_GC_OP_EPILOGUE(pGC);
-}
-
-static void
-ShadowPolyGlyphBlt(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- unsigned int nglyphInit,
- CharInfoPtr *ppciInit,
- pointer pglyphBase
-){
- BoxRec box;
- Bool boxNotEmpty = FALSE;
-
- SHADOW_GC_OP_PROLOGUE(pGC);
-
- if(IS_VISIBLE(pDraw) && nglyphInit) {
- CharInfoPtr *ppci = ppciInit;
- unsigned int nglyph = nglyphInit;
-
- /* ugh */
- box.x1 = pDraw->x + x + ppci[0]->metrics.leftSideBearing;
- box.x2 = pDraw->x + x + ppci[nglyph - 1]->metrics.rightSideBearing;
-
- if(nglyph > 1) {
- int width = 0;
-
- while(--nglyph) {
- width += (*ppci)->metrics.characterWidth;
- ppci++;
- }
-
- if(width > 0) box.x2 += width;
- else box.x1 += width;
- }
-
- box.y1 = pDraw->y + y - FONTMAXBOUNDS(pGC->font, ascent);
- box.y2 = pDraw->y + y + FONTMAXBOUNDS(pGC->font, descent);
-
- TRIM_BOX(box, pGC);
- if(BOX_NOT_EMPTY(box)) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
- }
-
- (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, x, y, nglyphInit,
- ppciInit, pglyphBase);
-
- if(boxNotEmpty && pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
-
- SHADOW_GC_OP_EPILOGUE(pGC);
-}
-
-static void
-ShadowPushPixels(
- GCPtr pGC,
- PixmapPtr pBitMap,
- DrawablePtr pDraw,
- int dx, int dy, int xOrg, int yOrg
-){
- BoxRec box;
- Bool boxNotEmpty = FALSE;
-
- SHADOW_GC_OP_PROLOGUE(pGC);
-
- if(IS_VISIBLE(pDraw)) {
- box.x1 = xOrg;
- box.y1 = yOrg;
-
- if(!pGC->miTranslate) {
- box.x1 += pDraw->x;
- box.y1 += pDraw->y;
- }
-
- box.x2 = box.x1 + dx;
- box.y2 = box.y1 + dy;
-
- TRIM_BOX(box, pGC);
- if(BOX_NOT_EMPTY(box)) {
- if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
- boxNotEmpty = TRUE;
- }
- }
-
- (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
-
- if(boxNotEmpty && pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
-
- SHADOW_GC_OP_EPILOGUE(pGC);
-}
-
-
-GCOps ShadowGCOps = {
- ShadowFillSpans, ShadowSetSpans,
- ShadowPutImage, ShadowCopyArea,
- ShadowCopyPlane, ShadowPolyPoint,
- ShadowPolylines, ShadowPolySegment,
- ShadowPolyRectangle, ShadowPolyArc,
- ShadowFillPolygon, ShadowPolyFillRect,
- ShadowPolyFillArc, ShadowPolyText8,
- ShadowPolyText16, ShadowImageText8,
- ShadowImageText16, ShadowImageGlyphBlt,
- ShadowPolyGlyphBlt, ShadowPushPixels,
-};
-
+/*
+ Copyright (C) 1999. The XFree86 Project Inc.
+
+ Written by Mark Vojkovich (mvojkovi@ucsd.edu)
+
+ Pre-fb-write callbacks and RENDER support - Nolan Leake (nolan@vmware.com)
+*/
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "pixmapstr.h"
+#include "input.h"
+#include <X11/fonts/font.h>
+#include "mi.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "gcstruct.h"
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "xf86.h"
+#include "xf86str.h"
+#include "shadowfb.h"
+
+#include "picturestr.h"
+
+static Bool ShadowCloseScreen(int i, ScreenPtr pScreen);
+static void ShadowCopyWindow(WindowPtr pWin,
+ DDXPointRec ptOldOrg, RegionPtr prgn);
+static Bool ShadowCreateGC(GCPtr pGC);
+
+static Bool ShadowEnterVT(int index, int flags);
+static void ShadowLeaveVT(int index, int flags);
+
+static void ShadowComposite(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst, CARD16 width, CARD16 height);
+
+typedef struct {
+ ScrnInfoPtr pScrn;
+ RefreshAreaFuncPtr preRefresh;
+ RefreshAreaFuncPtr postRefresh;
+ CloseScreenProcPtr CloseScreen;
+ CopyWindowProcPtr CopyWindow;
+ CreateGCProcPtr CreateGC;
+ ModifyPixmapHeaderProcPtr ModifyPixmapHeader;
+ CompositeProcPtr Composite;
+ Bool (*EnterVT) (int, int);
+ void (*LeaveVT) (int, int);
+ Bool vtSema;
+} ShadowScreenRec, *ShadowScreenPtr;
+
+typedef struct {
+ GCOps *ops;
+ GCFuncs *funcs;
+} ShadowGCRec, *ShadowGCPtr;
+
+static DevPrivateKeyRec ShadowScreenKeyRec;
+
+#define ShadowScreenKey (&ShadowScreenKeyRec)
+
+static DevPrivateKeyRec ShadowGCKeyRec;
+
+#define ShadowGCKey (&ShadowGCKeyRec)
+
+#define GET_SCREEN_PRIVATE(pScreen) \
+ (ShadowScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, ShadowScreenKey)
+#define GET_GC_PRIVATE(pGC) \
+ (ShadowGCPtr)dixLookupPrivate(&(pGC)->devPrivates, ShadowGCKey)
+
+#define SHADOW_GC_FUNC_PROLOGUE(pGC)\
+ ShadowGCPtr pGCPriv = GET_GC_PRIVATE(pGC);\
+ (pGC)->funcs = pGCPriv->funcs;\
+ if(pGCPriv->ops)\
+ (pGC)->ops = pGCPriv->ops
+
+#define SHADOW_GC_FUNC_EPILOGUE(pGC)\
+ pGCPriv->funcs = (pGC)->funcs;\
+ (pGC)->funcs = &ShadowGCFuncs;\
+ if(pGCPriv->ops) {\
+ pGCPriv->ops = (pGC)->ops;\
+ (pGC)->ops = &ShadowGCOps;\
+ }
+
+#define SHADOW_GC_OP_PROLOGUE(pGC)\
+ ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pGC->pScreen); \
+ ShadowGCPtr pGCPriv = GET_GC_PRIVATE(pGC);\
+ GCFuncs *oldFuncs = pGC->funcs;\
+ pGC->funcs = pGCPriv->funcs;\
+ pGC->ops = pGCPriv->ops
+
+#define SHADOW_GC_OP_EPILOGUE(pGC)\
+ pGCPriv->ops = pGC->ops;\
+ pGC->funcs = oldFuncs;\
+ pGC->ops = &ShadowGCOps
+
+#define IS_VISIBLE(pWin) (pPriv->vtSema && \
+ (((WindowPtr)pWin)->visibility != VisibilityFullyObscured))
+
+#define TRIM_BOX(box, pGC) { \
+ BoxPtr extents = &pGC->pCompositeClip->extents;\
+ if(box.x1 < extents->x1) box.x1 = extents->x1; \
+ if(box.x2 > extents->x2) box.x2 = extents->x2; \
+ if(box.y1 < extents->y1) box.y1 = extents->y1; \
+ if(box.y2 > extents->y2) box.y2 = extents->y2; \
+ }
+
+#define TRANSLATE_BOX(box, pDraw) { \
+ box.x1 += pDraw->x; \
+ box.x2 += pDraw->x; \
+ box.y1 += pDraw->y; \
+ box.y2 += pDraw->y; \
+ }
+
+#define TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC) { \
+ TRANSLATE_BOX(box, pDraw); \
+ TRIM_BOX(box, pGC); \
+ }
+
+#define BOX_NOT_EMPTY(box) \
+ (((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0))
+
+Bool
+ShadowFBInit2(ScreenPtr pScreen,
+ RefreshAreaFuncPtr preRefreshArea,
+ RefreshAreaFuncPtr postRefreshArea)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ ShadowScreenPtr pPriv;
+ PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
+
+ if (!preRefreshArea && !postRefreshArea)
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&ShadowScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey
+ (&ShadowGCKeyRec, PRIVATE_GC, sizeof(ShadowGCRec)))
+ return FALSE;
+
+ if (!(pPriv = (ShadowScreenPtr) malloc(sizeof(ShadowScreenRec))))
+ return FALSE;
+
+ dixSetPrivate(&pScreen->devPrivates, ShadowScreenKey, pPriv);
+
+ pPriv->pScrn = pScrn;
+ pPriv->preRefresh = preRefreshArea;
+ pPriv->postRefresh = postRefreshArea;
+ pPriv->vtSema = TRUE;
+
+ pPriv->CloseScreen = pScreen->CloseScreen;
+ pPriv->CopyWindow = pScreen->CopyWindow;
+ pPriv->CreateGC = pScreen->CreateGC;
+ pPriv->ModifyPixmapHeader = pScreen->ModifyPixmapHeader;
+
+ pPriv->EnterVT = pScrn->EnterVT;
+ pPriv->LeaveVT = pScrn->LeaveVT;
+
+ pScreen->CloseScreen = ShadowCloseScreen;
+ pScreen->CopyWindow = ShadowCopyWindow;
+ pScreen->CreateGC = ShadowCreateGC;
+
+ pScrn->EnterVT = ShadowEnterVT;
+ pScrn->LeaveVT = ShadowLeaveVT;
+
+ if (ps) {
+ pPriv->Composite = ps->Composite;
+ ps->Composite = ShadowComposite;
+ }
+
+ return TRUE;
+}
+
+Bool
+ShadowFBInit(ScreenPtr pScreen, RefreshAreaFuncPtr refreshArea)
+{
+ return ShadowFBInit2(pScreen, NULL, refreshArea);
+}
+
+/**********************************************************/
+
+static Bool
+ShadowEnterVT(int index, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ Bool ret;
+ ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScrn->pScreen);
+
+ pScrn->EnterVT = pPriv->EnterVT;
+ ret = (*pPriv->EnterVT) (index, flags);
+ pPriv->EnterVT = pScrn->EnterVT;
+ pScrn->EnterVT = ShadowEnterVT;
+ if (ret) {
+ pPriv->vtSema = TRUE;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+ShadowLeaveVT(int index, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(xf86Screens[index]->pScreen);
+
+ pPriv->vtSema = FALSE;
+
+ pScrn->LeaveVT = pPriv->LeaveVT;
+ (*pPriv->LeaveVT) (index, flags);
+ pPriv->LeaveVT = pScrn->LeaveVT;
+ pScrn->LeaveVT = ShadowLeaveVT;
+}
+
+/**********************************************************/
+
+static Bool
+ShadowCloseScreen(int i, ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen);
+ PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
+
+ pScreen->CloseScreen = pPriv->CloseScreen;
+ pScreen->CopyWindow = pPriv->CopyWindow;
+ pScreen->CreateGC = pPriv->CreateGC;
+ pScreen->ModifyPixmapHeader = pPriv->ModifyPixmapHeader;
+
+ pScrn->EnterVT = pPriv->EnterVT;
+ pScrn->LeaveVT = pPriv->LeaveVT;
+
+ if (ps) {
+ ps->Composite = pPriv->Composite;
+ }
+
+ free((pointer) pPriv);
+
+ return (*pScreen->CloseScreen) (i, pScreen);
+}
+
+static void
+ShadowCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgn)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen);
+ int num = 0;
+ RegionRec rgnDst;
+
+ if (pPriv->vtSema) {
+ RegionNull(&rgnDst);
+ RegionCopy(&rgnDst, prgn);
+
+ RegionTranslate(&rgnDst,
+ pWin->drawable.x - ptOldOrg.x,
+ pWin->drawable.y - ptOldOrg.y);
+ RegionIntersect(&rgnDst, &pWin->borderClip, &rgnDst);
+ if ((num = RegionNumRects(&rgnDst))) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, num, RegionRects(&rgnDst));
+ }
+ else {
+ RegionUninit(&rgnDst);
+ }
+ }
+
+ pScreen->CopyWindow = pPriv->CopyWindow;
+ (*pScreen->CopyWindow) (pWin, ptOldOrg, prgn);
+ pScreen->CopyWindow = ShadowCopyWindow;
+
+ if (num) {
+ if (pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, num, RegionRects(&rgnDst));
+ RegionUninit(&rgnDst);
+ }
+}
+
+static void
+ShadowComposite(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen);
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ BoxRec box;
+ BoxPtr extents;
+ Bool boxNotEmpty = FALSE;
+
+ if (pPriv->vtSema && pDst->pDrawable->type == DRAWABLE_WINDOW) {
+
+ box.x1 = pDst->pDrawable->x + xDst;
+ box.y1 = pDst->pDrawable->y + yDst;
+ box.x2 = box.x1 + width;
+ box.y2 = box.y1 + height;
+
+ extents = &pDst->pCompositeClip->extents;
+ if (box.x1 < extents->x1)
+ box.x1 = extents->x1;
+ if (box.x2 > extents->x2)
+ box.x2 = extents->x2;
+ if (box.y1 < extents->y1)
+ box.y1 = extents->y1;
+ if (box.y2 > extents->y2)
+ box.y2 = extents->y2;
+
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+ }
+
+ ps->Composite = pPriv->Composite;
+ (*ps->Composite) (op, pSrc, pMask, pDst, xSrc, ySrc,
+ xMask, yMask, xDst, yDst, width, height);
+ ps->Composite = ShadowComposite;
+
+ if (pPriv->postRefresh && boxNotEmpty) {
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+ }
+}
+
+/**********************************************************/
+
+static void ShadowValidateGC(GCPtr, unsigned long, DrawablePtr);
+static void ShadowChangeGC(GCPtr, unsigned long);
+static void ShadowCopyGC(GCPtr, unsigned long, GCPtr);
+static void ShadowDestroyGC(GCPtr);
+static void ShadowChangeClip(GCPtr, int, pointer, int);
+static void ShadowDestroyClip(GCPtr);
+static void ShadowCopyClip(GCPtr, GCPtr);
+
+GCFuncs ShadowGCFuncs = {
+ ShadowValidateGC, ShadowChangeGC, ShadowCopyGC, ShadowDestroyGC,
+ ShadowChangeClip, ShadowDestroyClip, ShadowCopyClip
+};
+
+extern GCOps ShadowGCOps;
+
+static Bool
+ShadowCreateGC(GCPtr pGC)
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen);
+ ShadowGCPtr pGCPriv = GET_GC_PRIVATE(pGC);
+ Bool ret;
+
+ pScreen->CreateGC = pPriv->CreateGC;
+ if ((ret = (*pScreen->CreateGC) (pGC))) {
+ pGCPriv->ops = NULL;
+ pGCPriv->funcs = pGC->funcs;
+ pGC->funcs = &ShadowGCFuncs;
+ }
+ pScreen->CreateGC = ShadowCreateGC;
+
+ return ret;
+}
+
+static void
+ShadowValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDraw)
+{
+ SHADOW_GC_FUNC_PROLOGUE(pGC);
+ (*pGC->funcs->ValidateGC) (pGC, changes, pDraw);
+ if (pDraw->type == DRAWABLE_WINDOW)
+ pGCPriv->ops = pGC->ops; /* just so it's not NULL */
+ else
+ pGCPriv->ops = NULL;
+ SHADOW_GC_FUNC_EPILOGUE(pGC);
+}
+
+static void
+ShadowDestroyGC(GCPtr pGC)
+{
+ SHADOW_GC_FUNC_PROLOGUE(pGC);
+ (*pGC->funcs->DestroyGC) (pGC);
+ SHADOW_GC_FUNC_EPILOGUE(pGC);
+}
+
+static void
+ShadowChangeGC(GCPtr pGC, unsigned long mask)
+{
+ SHADOW_GC_FUNC_PROLOGUE(pGC);
+ (*pGC->funcs->ChangeGC) (pGC, mask);
+ SHADOW_GC_FUNC_EPILOGUE(pGC);
+}
+
+static void
+ShadowCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
+{
+ SHADOW_GC_FUNC_PROLOGUE(pGCDst);
+ (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
+ SHADOW_GC_FUNC_EPILOGUE(pGCDst);
+}
+
+static void
+ShadowChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects)
+{
+ SHADOW_GC_FUNC_PROLOGUE(pGC);
+ (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
+ SHADOW_GC_FUNC_EPILOGUE(pGC);
+}
+
+static void
+ShadowCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
+{
+ SHADOW_GC_FUNC_PROLOGUE(pgcDst);
+ (*pgcDst->funcs->CopyClip) (pgcDst, pgcSrc);
+ SHADOW_GC_FUNC_EPILOGUE(pgcDst);
+}
+
+static void
+ShadowDestroyClip(GCPtr pGC)
+{
+ SHADOW_GC_FUNC_PROLOGUE(pGC);
+ (*pGC->funcs->DestroyClip) (pGC);
+ SHADOW_GC_FUNC_EPILOGUE(pGC);
+}
+
+/**********************************************************/
+
+static void
+ShadowFillSpans(DrawablePtr pDraw,
+ GC * pGC,
+ int nInit, DDXPointPtr pptInit, int *pwidthInit, int fSorted)
+{
+ SHADOW_GC_OP_PROLOGUE(pGC);
+
+ if (IS_VISIBLE(pDraw) && nInit) {
+ DDXPointPtr ppt = pptInit;
+ int *pwidth = pwidthInit;
+ int i = nInit;
+ BoxRec box;
+ Bool boxNotEmpty = FALSE;
+
+ box.x1 = ppt->x;
+ box.x2 = box.x1 + *pwidth;
+ box.y2 = box.y1 = ppt->y;
+
+ while (--i) {
+ ppt++;
+ pwidth++;
+ if (box.x1 > ppt->x)
+ box.x1 = ppt->x;
+ if (box.x2 < (ppt->x + *pwidth))
+ box.x2 = ppt->x + *pwidth;
+ if (box.y1 > ppt->y)
+ box.y1 = ppt->y;
+ else if (box.y2 < ppt->y)
+ box.y2 = ppt->y;
+ }
+
+ box.y2++;
+
+ if (!pGC->miTranslate) {
+ TRANSLATE_BOX(box, pDraw);
+ }
+ TRIM_BOX(box, pGC);
+
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+
+ (*pGC->ops->FillSpans) (pDraw, pGC, nInit, pptInit, pwidthInit,
+ fSorted);
+
+ if (boxNotEmpty && pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+ }
+ else
+ (*pGC->ops->FillSpans) (pDraw, pGC, nInit, pptInit, pwidthInit,
+ fSorted);
+
+ SHADOW_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+ShadowSetSpans(DrawablePtr pDraw,
+ GCPtr pGC,
+ char *pcharsrc,
+ DDXPointPtr pptInit, int *pwidthInit, int nspans, int fSorted)
+{
+ SHADOW_GC_OP_PROLOGUE(pGC);
+
+ if (IS_VISIBLE(pDraw) && nspans) {
+ DDXPointPtr ppt = pptInit;
+ int *pwidth = pwidthInit;
+ int i = nspans;
+ BoxRec box;
+ Bool boxNotEmpty = FALSE;
+
+ box.x1 = ppt->x;
+ box.x2 = box.x1 + *pwidth;
+ box.y2 = box.y1 = ppt->y;
+
+ while (--i) {
+ ppt++;
+ pwidth++;
+ if (box.x1 > ppt->x)
+ box.x1 = ppt->x;
+ if (box.x2 < (ppt->x + *pwidth))
+ box.x2 = ppt->x + *pwidth;
+ if (box.y1 > ppt->y)
+ box.y1 = ppt->y;
+ else if (box.y2 < ppt->y)
+ box.y2 = ppt->y;
+ }
+
+ box.y2++;
+
+ if (!pGC->miTranslate) {
+ TRANSLATE_BOX(box, pDraw);
+ }
+ TRIM_BOX(box, pGC);
+
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+
+ (*pGC->ops->SetSpans) (pDraw, pGC, pcharsrc, pptInit,
+ pwidthInit, nspans, fSorted);
+
+ if (boxNotEmpty && pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+ }
+ else
+ (*pGC->ops->SetSpans) (pDraw, pGC, pcharsrc, pptInit,
+ pwidthInit, nspans, fSorted);
+
+ SHADOW_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+ShadowPutImage(DrawablePtr pDraw,
+ GCPtr pGC,
+ int depth,
+ int x, int y, int w, int h,
+ int leftPad, int format, char *pImage)
+{
+ BoxRec box;
+ Bool boxNotEmpty = FALSE;
+
+ SHADOW_GC_OP_PROLOGUE(pGC);
+
+ if (IS_VISIBLE(pDraw)) {
+ box.x1 = x + pDraw->x;
+ box.x2 = box.x1 + w;
+ box.y1 = y + pDraw->y;
+ box.y2 = box.y1 + h;
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+ }
+
+ (*pGC->ops->PutImage) (pDraw, pGC, depth, x, y, w, h,
+ leftPad, format, pImage);
+
+ if (boxNotEmpty && pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+
+ SHADOW_GC_OP_EPILOGUE(pGC);
+
+}
+
+static RegionPtr
+ShadowCopyArea(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GC * pGC,
+ int srcx, int srcy, int width, int height, int dstx, int dsty)
+{
+ RegionPtr ret;
+ BoxRec box;
+ Bool boxNotEmpty = FALSE;
+
+ SHADOW_GC_OP_PROLOGUE(pGC);
+
+ if (IS_VISIBLE(pDst)) {
+ box.x1 = dstx + pDst->x;
+ box.x2 = box.x1 + width;
+ box.y1 = dsty + pDst->y;
+ box.y2 = box.y1 + height;
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+ }
+
+ ret = (*pGC->ops->CopyArea) (pSrc, pDst,
+ pGC, srcx, srcy, width, height, dstx, dsty);
+
+ if (boxNotEmpty && pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+
+ SHADOW_GC_OP_EPILOGUE(pGC);
+
+ return ret;
+}
+
+static RegionPtr
+ShadowCopyPlane(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx, int srcy,
+ int width, int height,
+ int dstx, int dsty, unsigned long bitPlane)
+{
+ RegionPtr ret;
+ BoxRec box;
+ Bool boxNotEmpty = FALSE;
+
+ SHADOW_GC_OP_PROLOGUE(pGC);
+
+ if (IS_VISIBLE(pDst)) {
+ box.x1 = dstx + pDst->x;
+ box.x2 = box.x1 + width;
+ box.y1 = dsty + pDst->y;
+ box.y2 = box.y1 + height;
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+ }
+
+ ret = (*pGC->ops->CopyPlane) (pSrc, pDst,
+ pGC, srcx, srcy, width, height, dstx, dsty,
+ bitPlane);
+
+ if (boxNotEmpty && pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+
+ SHADOW_GC_OP_EPILOGUE(pGC);
+
+ return ret;
+}
+
+static void
+ShadowPolyPoint(DrawablePtr pDraw,
+ GCPtr pGC, int mode, int nptInit, xPoint * pptInit)
+{
+ BoxRec box;
+ Bool boxNotEmpty = FALSE;
+
+ SHADOW_GC_OP_PROLOGUE(pGC);
+
+ if (IS_VISIBLE(pDraw) && nptInit) {
+ xPoint *ppt = pptInit;
+ int npt = nptInit;
+
+ box.x2 = box.x1 = pptInit->x;
+ box.y2 = box.y1 = pptInit->y;
+
+ /* this could be slow if the points were spread out */
+
+ while (--npt) {
+ ppt++;
+ if (box.x1 > ppt->x)
+ box.x1 = ppt->x;
+ else if (box.x2 < ppt->x)
+ box.x2 = ppt->x;
+ if (box.y1 > ppt->y)
+ box.y1 = ppt->y;
+ else if (box.y2 < ppt->y)
+ box.y2 = ppt->y;
+ }
+
+ box.x2++;
+ box.y2++;
+
+ TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+ }
+
+ (*pGC->ops->PolyPoint) (pDraw, pGC, mode, nptInit, pptInit);
+
+ if (boxNotEmpty && pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+
+ SHADOW_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+ShadowPolylines(DrawablePtr pDraw,
+ GCPtr pGC, int mode, int nptInit, DDXPointPtr pptInit)
+{
+ BoxRec box;
+ Bool boxNotEmpty = FALSE;
+
+ SHADOW_GC_OP_PROLOGUE(pGC);
+
+ if (IS_VISIBLE(pDraw) && nptInit) {
+ DDXPointPtr ppt = pptInit;
+ int npt = nptInit;
+ int extra = pGC->lineWidth >> 1;
+
+ box.x2 = box.x1 = pptInit->x;
+ box.y2 = box.y1 = pptInit->y;
+
+ if (npt > 1) {
+ if (pGC->joinStyle == JoinMiter)
+ extra = 6 * pGC->lineWidth;
+ else if (pGC->capStyle == CapProjecting)
+ extra = pGC->lineWidth;
+ }
+
+ if (mode == CoordModePrevious) {
+ int x = box.x1;
+ int y = box.y1;
+
+ while (--npt) {
+ ppt++;
+ x += ppt->x;
+ y += ppt->y;
+ if (box.x1 > x)
+ box.x1 = x;
+ else if (box.x2 < x)
+ box.x2 = x;
+ if (box.y1 > y)
+ box.y1 = y;
+ else if (box.y2 < y)
+ box.y2 = y;
+ }
+ }
+ else {
+ while (--npt) {
+ ppt++;
+ if (box.x1 > ppt->x)
+ box.x1 = ppt->x;
+ else if (box.x2 < ppt->x)
+ box.x2 = ppt->x;
+ if (box.y1 > ppt->y)
+ box.y1 = ppt->y;
+ else if (box.y2 < ppt->y)
+ box.y2 = ppt->y;
+ }
+ }
+
+ box.x2++;
+ box.y2++;
+
+ if (extra) {
+ box.x1 -= extra;
+ box.x2 += extra;
+ box.y1 -= extra;
+ box.y2 += extra;
+ }
+
+ TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+ }
+
+ (*pGC->ops->Polylines) (pDraw, pGC, mode, nptInit, pptInit);
+
+ if (boxNotEmpty && pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+
+ SHADOW_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+ShadowPolySegment(DrawablePtr pDraw,
+ GCPtr pGC, int nsegInit, xSegment * pSegInit)
+{
+ BoxRec box;
+ Bool boxNotEmpty = FALSE;
+
+ SHADOW_GC_OP_PROLOGUE(pGC);
+
+ if (IS_VISIBLE(pDraw) && nsegInit) {
+ int extra = pGC->lineWidth;
+ xSegment *pSeg = pSegInit;
+ int nseg = nsegInit;
+
+ if (pGC->capStyle != CapProjecting)
+ extra >>= 1;
+
+ if (pSeg->x2 > pSeg->x1) {
+ box.x1 = pSeg->x1;
+ box.x2 = pSeg->x2;
+ }
+ else {
+ box.x2 = pSeg->x1;
+ box.x1 = pSeg->x2;
+ }
+
+ if (pSeg->y2 > pSeg->y1) {
+ box.y1 = pSeg->y1;
+ box.y2 = pSeg->y2;
+ }
+ else {
+ box.y2 = pSeg->y1;
+ box.y1 = pSeg->y2;
+ }
+
+ while (--nseg) {
+ pSeg++;
+ if (pSeg->x2 > pSeg->x1) {
+ if (pSeg->x1 < box.x1)
+ box.x1 = pSeg->x1;
+ if (pSeg->x2 > box.x2)
+ box.x2 = pSeg->x2;
+ }
+ else {
+ if (pSeg->x2 < box.x1)
+ box.x1 = pSeg->x2;
+ if (pSeg->x1 > box.x2)
+ box.x2 = pSeg->x1;
+ }
+ if (pSeg->y2 > pSeg->y1) {
+ if (pSeg->y1 < box.y1)
+ box.y1 = pSeg->y1;
+ if (pSeg->y2 > box.y2)
+ box.y2 = pSeg->y2;
+ }
+ else {
+ if (pSeg->y2 < box.y1)
+ box.y1 = pSeg->y2;
+ if (pSeg->y1 > box.y2)
+ box.y2 = pSeg->y1;
+ }
+ }
+
+ box.x2++;
+ box.y2++;
+
+ if (extra) {
+ box.x1 -= extra;
+ box.x2 += extra;
+ box.y1 -= extra;
+ box.y2 += extra;
+ }
+
+ TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+ }
+
+ (*pGC->ops->PolySegment) (pDraw, pGC, nsegInit, pSegInit);
+
+ if (boxNotEmpty && pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+
+ SHADOW_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+ShadowPolyRectangle(DrawablePtr pDraw,
+ GCPtr pGC, int nRectsInit, xRectangle *pRectsInit)
+{
+ BoxRec box;
+ BoxPtr pBoxInit = NULL;
+ Bool boxNotEmpty = FALSE;
+ int num = 0;
+
+ SHADOW_GC_OP_PROLOGUE(pGC);
+
+ if (IS_VISIBLE(pDraw) && nRectsInit) {
+ xRectangle *pRects = pRectsInit;
+ int nRects = nRectsInit;
+
+ if (nRects >= 32) {
+ int extra = pGC->lineWidth >> 1;
+
+ box.x1 = pRects->x;
+ box.x2 = box.x1 + pRects->width;
+ box.y1 = pRects->y;
+ box.y2 = box.y1 + pRects->height;
+
+ while (--nRects) {
+ pRects++;
+ if (box.x1 > pRects->x)
+ box.x1 = pRects->x;
+ if (box.x2 < (pRects->x + pRects->width))
+ box.x2 = pRects->x + pRects->width;
+ if (box.y1 > pRects->y)
+ box.y1 = pRects->y;
+ if (box.y2 < (pRects->y + pRects->height))
+ box.y2 = pRects->y + pRects->height;
+ }
+
+ if (extra) {
+ box.x1 -= extra;
+ box.x2 += extra;
+ box.y1 -= extra;
+ box.y2 += extra;
+ }
+
+ box.x2++;
+ box.y2++;
+
+ TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+ }
+ else {
+ BoxPtr pbox;
+ int offset1, offset2, offset3;
+
+ offset2 = pGC->lineWidth;
+ if (!offset2)
+ offset2 = 1;
+ offset1 = offset2 >> 1;
+ offset3 = offset2 - offset1;
+
+ pBoxInit = (BoxPtr) malloc(nRects * 4 * sizeof(BoxRec));
+ pbox = pBoxInit;
+
+ while (nRects--) {
+ pbox->x1 = pRects->x - offset1;
+ pbox->y1 = pRects->y - offset1;
+ pbox->x2 = pbox->x1 + pRects->width + offset2;
+ pbox->y2 = pbox->y1 + offset2;
+ TRIM_AND_TRANSLATE_BOX((*pbox), pDraw, pGC);
+ if (BOX_NOT_EMPTY((*pbox))) {
+ num++;
+ pbox++;
+ }
+
+ pbox->x1 = pRects->x - offset1;
+ pbox->y1 = pRects->y + offset3;
+ pbox->x2 = pbox->x1 + offset2;
+ pbox->y2 = pbox->y1 + pRects->height - offset2;
+ TRIM_AND_TRANSLATE_BOX((*pbox), pDraw, pGC);
+ if (BOX_NOT_EMPTY((*pbox))) {
+ num++;
+ pbox++;
+ }
+
+ pbox->x1 = pRects->x + pRects->width - offset1;
+ pbox->y1 = pRects->y + offset3;
+ pbox->x2 = pbox->x1 + offset2;
+ pbox->y2 = pbox->y1 + pRects->height - offset2;
+ TRIM_AND_TRANSLATE_BOX((*pbox), pDraw, pGC);
+ if (BOX_NOT_EMPTY((*pbox))) {
+ num++;
+ pbox++;
+ }
+
+ pbox->x1 = pRects->x - offset1;
+ pbox->y1 = pRects->y + pRects->height - offset1;
+ pbox->x2 = pbox->x1 + pRects->width + offset2;
+ pbox->y2 = pbox->y1 + offset2;
+ TRIM_AND_TRANSLATE_BOX((*pbox), pDraw, pGC);
+ if (BOX_NOT_EMPTY((*pbox))) {
+ num++;
+ pbox++;
+ }
+
+ pRects++;
+ }
+
+ if (num) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, num, pBoxInit);
+ }
+ else {
+ free(pBoxInit);
+ }
+ }
+ }
+
+ (*pGC->ops->PolyRectangle) (pDraw, pGC, nRectsInit, pRectsInit);
+
+ if (boxNotEmpty && pPriv->postRefresh) {
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+ }
+ else if (num) {
+ if (pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, num, pBoxInit);
+ free(pBoxInit);
+ }
+
+ SHADOW_GC_OP_EPILOGUE(pGC);
+
+}
+
+static void
+ShadowPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcsInit, xArc * parcsInit)
+{
+ BoxRec box;
+ Bool boxNotEmpty = FALSE;
+
+ SHADOW_GC_OP_PROLOGUE(pGC);
+
+ if (IS_VISIBLE(pDraw) && narcsInit) {
+ int narcs = narcsInit;
+ xArc *parcs = parcsInit;
+ int extra = pGC->lineWidth >> 1;
+
+ box.x1 = parcs->x;
+ box.x2 = box.x1 + parcs->width;
+ box.y1 = parcs->y;
+ box.y2 = box.y1 + parcs->height;
+
+ /* should I break these up instead ? */
+
+ while (--narcs) {
+ parcs++;
+ if (box.x1 > parcs->x)
+ box.x1 = parcs->x;
+ if (box.x2 < (parcs->x + parcs->width))
+ box.x2 = parcs->x + parcs->width;
+ if (box.y1 > parcs->y)
+ box.y1 = parcs->y;
+ if (box.y2 < (parcs->y + parcs->height))
+ box.y2 = parcs->y + parcs->height;
+ }
+
+ if (extra) {
+ box.x1 -= extra;
+ box.x2 += extra;
+ box.y1 -= extra;
+ box.y2 += extra;
+ }
+
+ box.x2++;
+ box.y2++;
+
+ TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+ }
+
+ (*pGC->ops->PolyArc) (pDraw, pGC, narcsInit, parcsInit);
+
+ if (boxNotEmpty && pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+
+ SHADOW_GC_OP_EPILOGUE(pGC);
+
+}
+
+static void
+ShadowFillPolygon(DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape, int mode, int count, DDXPointPtr pptInit)
+{
+ SHADOW_GC_OP_PROLOGUE(pGC);
+
+ if (IS_VISIBLE(pDraw) && (count > 2)) {
+ DDXPointPtr ppt = pptInit;
+ int i = count;
+ BoxRec box;
+ Bool boxNotEmpty = FALSE;
+
+ box.x2 = box.x1 = ppt->x;
+ box.y2 = box.y1 = ppt->y;
+
+ if (mode != CoordModeOrigin) {
+ int x = box.x1;
+ int y = box.y1;
+
+ while (--i) {
+ ppt++;
+ x += ppt->x;
+ y += ppt->y;
+ if (box.x1 > x)
+ box.x1 = x;
+ else if (box.x2 < x)
+ box.x2 = x;
+ if (box.y1 > y)
+ box.y1 = y;
+ else if (box.y2 < y)
+ box.y2 = y;
+ }
+ }
+ else {
+ while (--i) {
+ ppt++;
+ if (box.x1 > ppt->x)
+ box.x1 = ppt->x;
+ else if (box.x2 < ppt->x)
+ box.x2 = ppt->x;
+ if (box.y1 > ppt->y)
+ box.y1 = ppt->y;
+ else if (box.y2 < ppt->y)
+ box.y2 = ppt->y;
+ }
+ }
+
+ box.x2++;
+ box.y2++;
+
+ TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+
+ (*pGC->ops->FillPolygon) (pDraw, pGC, shape, mode, count, pptInit);
+
+ if (boxNotEmpty && pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+ }
+ else
+ (*pGC->ops->FillPolygon) (pDraw, pGC, shape, mode, count, pptInit);
+
+ SHADOW_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+ShadowPolyFillRect(DrawablePtr pDraw,
+ GCPtr pGC, int nRectsInit, xRectangle *pRectsInit)
+{
+ SHADOW_GC_OP_PROLOGUE(pGC);
+
+ if (IS_VISIBLE(pDraw) && nRectsInit) {
+ BoxRec box;
+ Bool boxNotEmpty = FALSE;
+ xRectangle *pRects = pRectsInit;
+ int nRects = nRectsInit;
+
+ box.x1 = pRects->x;
+ box.x2 = box.x1 + pRects->width;
+ box.y1 = pRects->y;
+ box.y2 = box.y1 + pRects->height;
+
+ while (--nRects) {
+ pRects++;
+ if (box.x1 > pRects->x)
+ box.x1 = pRects->x;
+ if (box.x2 < (pRects->x + pRects->width))
+ box.x2 = pRects->x + pRects->width;
+ if (box.y1 > pRects->y)
+ box.y1 = pRects->y;
+ if (box.y2 < (pRects->y + pRects->height))
+ box.y2 = pRects->y + pRects->height;
+ }
+
+ /* cfb messes with the pRectsInit so we have to do our
+ calculations first */
+
+ TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+
+ (*pGC->ops->PolyFillRect) (pDraw, pGC, nRectsInit, pRectsInit);
+
+ if (boxNotEmpty && pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+ }
+ else
+ (*pGC->ops->PolyFillRect) (pDraw, pGC, nRectsInit, pRectsInit);
+
+ SHADOW_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+ShadowPolyFillArc(DrawablePtr pDraw, GCPtr pGC, int narcsInit, xArc * parcsInit)
+{
+ BoxRec box;
+ Bool boxNotEmpty = FALSE;
+
+ SHADOW_GC_OP_PROLOGUE(pGC);
+
+ if (IS_VISIBLE(pDraw) && narcsInit) {
+ xArc *parcs = parcsInit;
+ int narcs = narcsInit;
+
+ box.x1 = parcs->x;
+ box.x2 = box.x1 + parcs->width;
+ box.y1 = parcs->y;
+ box.y2 = box.y1 + parcs->height;
+
+ /* should I break these up instead ? */
+
+ while (--narcs) {
+ parcs++;
+ if (box.x1 > parcs->x)
+ box.x1 = parcs->x;
+ if (box.x2 < (parcs->x + parcs->width))
+ box.x2 = parcs->x + parcs->width;
+ if (box.y1 > parcs->y)
+ box.y1 = parcs->y;
+ if (box.y2 < (parcs->y + parcs->height))
+ box.y2 = parcs->y + parcs->height;
+ }
+
+ TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+ }
+
+ (*pGC->ops->PolyFillArc) (pDraw, pGC, narcsInit, parcsInit);
+
+ if (boxNotEmpty && pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+
+ SHADOW_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+ShadowTextExtent(FontPtr pFont, int count, char *chars,
+ FontEncoding fontEncoding, BoxPtr box)
+{
+ unsigned long n, i;
+ int w;
+ CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */
+
+ GetGlyphs(pFont, (unsigned long) count, (unsigned char *) chars,
+ fontEncoding, &n, charinfo);
+ w = 0;
+ for (i = 0; i < n; i++) {
+ w += charinfo[i]->metrics.characterWidth;
+ }
+ if (i) {
+ w += charinfo[i - 1]->metrics.rightSideBearing;
+ }
+
+ box->x1 = 0;
+ if (n) {
+ if (charinfo[0]->metrics.leftSideBearing < 0) {
+ box->x1 = charinfo[0]->metrics.leftSideBearing;
+ }
+ }
+ box->x2 = w;
+ box->y1 = -FONTMAXBOUNDS(pFont, ascent);
+ box->y2 = FONTMAXBOUNDS(pFont, descent);
+}
+
+static void
+ShadowFontToBox(BoxPtr BB, DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ int count, char *chars, int wide)
+{
+ FontPtr pFont;
+
+ pFont = pGC->font;
+ if (pFont->info.constantWidth) {
+ int ascent, descent, left, right = 0;
+
+ ascent = max(pFont->info.fontAscent, pFont->info.maxbounds.ascent);
+ descent = max(pFont->info.fontDescent, pFont->info.maxbounds.descent);
+ left = pFont->info.maxbounds.leftSideBearing;
+ if (count > 0) {
+ right = (count - 1) * pFont->info.maxbounds.characterWidth;
+ }
+ right += pFont->info.maxbounds.rightSideBearing;
+ BB->x1 =
+ max(pDrawable->x + x - left,
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->x1);
+ BB->y1 =
+ max(pDrawable->y + y - ascent,
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->y1);
+ BB->x2 =
+ min(pDrawable->x + x + right,
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->x2);
+ BB->y2 =
+ min(pDrawable->y + y + descent,
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->y2);
+ }
+ else {
+ ShadowTextExtent(pFont, count, chars, wide ? (FONTLASTROW(pFont) == 0)
+ ? Linear16Bit : TwoD16Bit : Linear8Bit, BB);
+ BB->x1 =
+ max(pDrawable->x + x + BB->x1,
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->x1);
+ BB->y1 =
+ max(pDrawable->y + y + BB->y1,
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->y1);
+ BB->x2 =
+ min(pDrawable->x + x + BB->x2,
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->x2);
+ BB->y2 =
+ min(pDrawable->y + y + BB->y2,
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->y2);
+ }
+}
+
+static int
+ShadowPolyText8(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars)
+{
+ int width;
+ BoxRec box;
+ Bool boxNotEmpty = FALSE;
+
+ SHADOW_GC_OP_PROLOGUE(pGC);
+
+ if (IS_VISIBLE(pDraw)) {
+ ShadowFontToBox(&box, pDraw, pGC, x, y, count, chars, 0);
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+ }
+
+ width = (*pGC->ops->PolyText8) (pDraw, pGC, x, y, count, chars);
+
+ if (boxNotEmpty && pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+
+ SHADOW_GC_OP_EPILOGUE(pGC);
+
+ return width;
+}
+
+static int
+ShadowPolyText16(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, unsigned short *chars)
+{
+ int width;
+ BoxRec box;
+ Bool boxNotEmpty = FALSE;
+
+ SHADOW_GC_OP_PROLOGUE(pGC);
+
+ if (IS_VISIBLE(pDraw)) {
+ ShadowFontToBox(&box, pDraw, pGC, x, y, count, (char *) chars, 1);
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+ }
+
+ width = (*pGC->ops->PolyText16) (pDraw, pGC, x, y, count, chars);
+
+ if (boxNotEmpty && pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+
+ SHADOW_GC_OP_EPILOGUE(pGC);
+
+ return width;
+}
+
+static void
+ShadowImageText8(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars)
+{
+ BoxRec box;
+ Bool boxNotEmpty = FALSE;
+
+ SHADOW_GC_OP_PROLOGUE(pGC);
+
+ if (IS_VISIBLE(pDraw) && count) {
+ int top, bot, Min, Max;
+
+ top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
+ bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
+
+ Min = count * FONTMINBOUNDS(pGC->font, characterWidth);
+ if (Min > 0)
+ Min = 0;
+ Max = count * FONTMAXBOUNDS(pGC->font, characterWidth);
+ if (Max < 0)
+ Max = 0;
+
+ /* ugh */
+ box.x1 = pDraw->x + x + Min + FONTMINBOUNDS(pGC->font, leftSideBearing);
+ box.x2 = pDraw->x + x + Max +
+ FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+ box.y1 = pDraw->y + y - top;
+ box.y2 = pDraw->y + y + bot;
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+ }
+
+ (*pGC->ops->ImageText8) (pDraw, pGC, x, y, count, chars);
+
+ if (boxNotEmpty && pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+
+ SHADOW_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+ShadowImageText16(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, unsigned short *chars)
+{
+ BoxRec box;
+ Bool boxNotEmpty = FALSE;
+
+ SHADOW_GC_OP_PROLOGUE(pGC);
+
+ if (IS_VISIBLE(pDraw) && count) {
+ int top, bot, Min, Max;
+
+ top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
+ bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
+
+ Min = count * FONTMINBOUNDS(pGC->font, characterWidth);
+ if (Min > 0)
+ Min = 0;
+ Max = count * FONTMAXBOUNDS(pGC->font, characterWidth);
+ if (Max < 0)
+ Max = 0;
+
+ /* ugh */
+ box.x1 = pDraw->x + x + Min + FONTMINBOUNDS(pGC->font, leftSideBearing);
+ box.x2 = pDraw->x + x + Max +
+ FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+ box.y1 = pDraw->y + y - top;
+ box.y2 = pDraw->y + y + bot;
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+ }
+
+ (*pGC->ops->ImageText16) (pDraw, pGC, x, y, count, chars);
+
+ if (boxNotEmpty && pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+
+ SHADOW_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+ShadowImageGlyphBlt(DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y,
+ unsigned int nglyphInit,
+ CharInfoPtr * ppciInit, pointer pglyphBase)
+{
+ BoxRec box;
+ Bool boxNotEmpty = FALSE;
+
+ SHADOW_GC_OP_PROLOGUE(pGC);
+
+ if (IS_VISIBLE(pDraw) && nglyphInit) {
+ CharInfoPtr *ppci = ppciInit;
+ unsigned int nglyph = nglyphInit;
+ int top, bot, width = 0;
+
+ top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
+ bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
+
+ box.x1 = ppci[0]->metrics.leftSideBearing;
+ if (box.x1 > 0)
+ box.x1 = 0;
+ box.x2 = ppci[nglyph - 1]->metrics.rightSideBearing -
+ ppci[nglyph - 1]->metrics.characterWidth;
+ if (box.x2 < 0)
+ box.x2 = 0;
+
+ box.x2 += pDraw->x + x;
+ box.x1 += pDraw->x + x;
+
+ while (nglyph--) {
+ width += (*ppci)->metrics.characterWidth;
+ ppci++;
+ }
+
+ if (width > 0)
+ box.x2 += width;
+ else
+ box.x1 += width;
+
+ box.y1 = pDraw->y + y - top;
+ box.y2 = pDraw->y + y + bot;
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+ }
+
+ (*pGC->ops->ImageGlyphBlt) (pDraw, pGC, x, y, nglyphInit,
+ ppciInit, pglyphBase);
+
+ if (boxNotEmpty && pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+
+ SHADOW_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+ShadowPolyGlyphBlt(DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y,
+ unsigned int nglyphInit,
+ CharInfoPtr * ppciInit, pointer pglyphBase)
+{
+ BoxRec box;
+ Bool boxNotEmpty = FALSE;
+
+ SHADOW_GC_OP_PROLOGUE(pGC);
+
+ if (IS_VISIBLE(pDraw) && nglyphInit) {
+ CharInfoPtr *ppci = ppciInit;
+ unsigned int nglyph = nglyphInit;
+
+ /* ugh */
+ box.x1 = pDraw->x + x + ppci[0]->metrics.leftSideBearing;
+ box.x2 = pDraw->x + x + ppci[nglyph - 1]->metrics.rightSideBearing;
+
+ if (nglyph > 1) {
+ int width = 0;
+
+ while (--nglyph) {
+ width += (*ppci)->metrics.characterWidth;
+ ppci++;
+ }
+
+ if (width > 0)
+ box.x2 += width;
+ else
+ box.x1 += width;
+ }
+
+ box.y1 = pDraw->y + y - FONTMAXBOUNDS(pGC->font, ascent);
+ box.y2 = pDraw->y + y + FONTMAXBOUNDS(pGC->font, descent);
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+ }
+
+ (*pGC->ops->PolyGlyphBlt) (pDraw, pGC, x, y, nglyphInit,
+ ppciInit, pglyphBase);
+
+ if (boxNotEmpty && pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+
+ SHADOW_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+ShadowPushPixels(GCPtr pGC,
+ PixmapPtr pBitMap,
+ DrawablePtr pDraw, int dx, int dy, int xOrg, int yOrg)
+{
+ BoxRec box;
+ Bool boxNotEmpty = FALSE;
+
+ SHADOW_GC_OP_PROLOGUE(pGC);
+
+ if (IS_VISIBLE(pDraw)) {
+ box.x1 = xOrg;
+ box.y1 = yOrg;
+
+ if (!pGC->miTranslate) {
+ box.x1 += pDraw->x;
+ box.y1 += pDraw->y;
+ }
+
+ box.x2 = box.x1 + dx;
+ box.y2 = box.y1 + dy;
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box)) {
+ if (pPriv->preRefresh)
+ (*pPriv->preRefresh) (pPriv->pScrn, 1, &box);
+ boxNotEmpty = TRUE;
+ }
+ }
+
+ (*pGC->ops->PushPixels) (pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
+
+ if (boxNotEmpty && pPriv->postRefresh)
+ (*pPriv->postRefresh) (pPriv->pScrn, 1, &box);
+
+ SHADOW_GC_OP_EPILOGUE(pGC);
+}
+
+GCOps ShadowGCOps = {
+ ShadowFillSpans, ShadowSetSpans,
+ ShadowPutImage, ShadowCopyArea,
+ ShadowCopyPlane, ShadowPolyPoint,
+ ShadowPolylines, ShadowPolySegment,
+ ShadowPolyRectangle, ShadowPolyArc,
+ ShadowFillPolygon, ShadowPolyFillRect,
+ ShadowPolyFillArc, ShadowPolyText8,
+ ShadowPolyText16, ShadowImageText8,
+ ShadowImageText16, ShadowImageGlyphBlt,
+ ShadowPolyGlyphBlt, ShadowPushPixels,
+};
diff --git a/xorg-server/hw/xfree86/shadowfb/shadowfb.h b/xorg-server/hw/xfree86/shadowfb/shadowfb.h
index 56e0e86fe..bcf59f9b2 100644
--- a/xorg-server/hw/xfree86/shadowfb/shadowfb.h
+++ b/xorg-server/hw/xfree86/shadowfb/shadowfb.h
@@ -9,7 +9,7 @@
* the number of dirty rectangles, and a pointer to the first dirty rectangle
* in the array.
*/
-typedef void (*RefreshAreaFuncPtr)(ScrnInfoPtr, int, BoxPtr);
+typedef void (*RefreshAreaFuncPtr) (ScrnInfoPtr, int, BoxPtr);
/*
* ShadowFBInit initializes the shadowfb subsystem. refreshArea is a pointer
@@ -20,10 +20,7 @@ typedef void (*RefreshAreaFuncPtr)(ScrnInfoPtr, int, BoxPtr);
* Returns FALSE in the event of an error.
*/
extern _X_EXPORT Bool
-ShadowFBInit (
- ScreenPtr pScreen,
- RefreshAreaFuncPtr refreshArea
-);
+ ShadowFBInit(ScreenPtr pScreen, RefreshAreaFuncPtr refreshArea);
/*
* ShadowFBInit2 is a more featureful refinement of the original shadowfb.
@@ -34,10 +31,9 @@ ShadowFBInit (
* Returns FALSE in the event of an error
*/
extern _X_EXPORT Bool
-ShadowFBInit2 (
- ScreenPtr pScreen,
- RefreshAreaFuncPtr preRefreshArea,
- RefreshAreaFuncPtr postRefreshArea
-);
-#endif /* _SHADOWFB_H */
+ShadowFBInit2(ScreenPtr pScreen,
+ RefreshAreaFuncPtr preRefreshArea,
+ RefreshAreaFuncPtr postRefreshArea);
+
+#endif /* _SHADOWFB_H */
diff --git a/xorg-server/hw/xfree86/utils/cvt/cvt.c b/xorg-server/hw/xfree86/utils/cvt/cvt.c
index 0de5ffea4..9483964e0 100644
--- a/xorg-server/hw/xfree86/utils/cvt/cvt.c
+++ b/xorg-server/hw/xfree86/utils/cvt/cvt.c
@@ -30,6 +30,7 @@ void
FatalError(const char *f, ...)
{
va_list args;
+
va_start(args, f);
vfprintf(stderr, f, args);
va_end(args);
@@ -69,22 +70,21 @@ XNFcalloc(unsigned long n)
*/
static Bool
CVTCheckStandard(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
- Bool Verbose)
+ Bool Verbose)
{
- Bool IsCVT = TRUE;
+ Bool IsCVT = TRUE;
if ((!(VDisplay % 3) && ((VDisplay * 4 / 3) == HDisplay)) ||
(!(VDisplay % 9) && ((VDisplay * 16 / 9) == HDisplay)) ||
(!(VDisplay % 10) && ((VDisplay * 16 / 10) == HDisplay)) ||
(!(VDisplay % 4) && ((VDisplay * 5 / 4) == HDisplay)) ||
- (!(VDisplay % 9) && ((VDisplay * 15 / 9) == HDisplay)))
- ;
+ (!(VDisplay % 9) && ((VDisplay * 15 / 9) == HDisplay)));
else {
if (Verbose)
fprintf(stderr, "Warning: Aspect Ratio is not CVT standard.\n");
IsCVT = FALSE;
}
-
+
if ((VRefresh != 50.0) && (VRefresh != 60.0) &&
(VRefresh != 75.0) && (VRefresh != 85.0)) {
if (Verbose)
@@ -92,11 +92,10 @@ CVTCheckStandard(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
"(50, 60, 75 or 85Hz).\n");
IsCVT = FALSE;
}
-
+
return IsCVT;
}
-
/*
* I'm not documenting --interlaced for obvious reasons, even though I did
* implement it. I also can't deny having looked at gtf here.
@@ -113,20 +112,21 @@ PrintUsage(char *Name)
"(default: normal blanking).\n");
fprintf(stderr, " X : Desired horizontal resolution "
"(multiple of 8, required).\n");
- fprintf(stderr, " Y : Desired vertical resolution (required).\n");
- fprintf(stderr, " refresh : Desired refresh rate (default: 60.0Hz).\n");
+ fprintf(stderr,
+ " Y : Desired vertical resolution (required).\n");
+ fprintf(stderr,
+ " refresh : Desired refresh rate (default: 60.0Hz).\n");
fprintf(stderr, "\n");
fprintf(stderr, "Calculates VESA CVT (Coordinated Video Timing) modelines"
- " for use with X.\n");
+ " for use with X.\n");
}
-
/*
*
*/
static void
-PrintComment(DisplayModeRec *Mode, Bool CVT, Bool Reduced)
+PrintComment(DisplayModeRec * Mode, Bool CVT, Bool Reduced)
{
printf("# %dx%d %.2f Hz ", Mode->HDisplay, Mode->VDisplay, Mode->VRefresh);
@@ -154,16 +154,16 @@ PrintComment(DisplayModeRec *Mode, Bool CVT, Bool Reduced)
printf("-R");
printf(") ");
- } else
+ }
+ else
printf("(CVT) ");
printf("hsync: %.2f kHz; ", Mode->HSync);
- printf("pclk: %.2f MHz", ((float ) Mode->Clock) / 1000.0);
+ printf("pclk: %.2f MHz", ((float) Mode->Clock) / 1000.0);
printf("\n");
}
-
/*
* Originally grabbed from xf86Mode.c.
*
@@ -179,9 +179,9 @@ PrintModeline(DisplayModePtr Mode, int HDisplay, int VDisplay, float VRefresh,
else
printf("Modeline \"%dx%d_%.2f\" ", HDisplay, VDisplay, VRefresh);
- printf("%6.2f %i %i %i %i %i %i %i %i", Mode->Clock/1000., Mode->HDisplay,
- Mode->HSyncStart, Mode->HSyncEnd, Mode->HTotal, Mode->VDisplay,
- Mode->VSyncStart, Mode->VSyncEnd, Mode->VTotal);
+ printf("%6.2f %i %i %i %i %i %i %i %i", Mode->Clock / 1000.,
+ Mode->HDisplay, Mode->HSyncStart, Mode->HSyncEnd, Mode->HTotal,
+ Mode->VDisplay, Mode->VSyncStart, Mode->VSyncEnd, Mode->VTotal);
if (Mode->Flags & V_INTERLACE)
printf(" interlace");
@@ -197,19 +197,18 @@ PrintModeline(DisplayModePtr Mode, int HDisplay, int VDisplay, float VRefresh,
printf("\n");
}
-
/*
*
*/
int
-main (int argc, char *argv[])
+main(int argc, char *argv[])
{
- DisplayModeRec *Mode;
- int HDisplay = 0, VDisplay = 0;
- float VRefresh = 0.0;
- Bool Reduced = FALSE, Verbose = FALSE, IsCVT;
- Bool Interlaced = FALSE;
- int n;
+ DisplayModeRec *Mode;
+ int HDisplay = 0, VDisplay = 0;
+ float VRefresh = 0.0;
+ Bool Reduced = FALSE, Verbose = FALSE, IsCVT;
+ Bool Interlaced = FALSE;
+ int n;
if ((argc < 3) || (argc > 7)) {
PrintUsage(argv[0]);
@@ -230,27 +229,28 @@ main (int argc, char *argv[])
else if (!strcmp(argv[n], "-h") || !strcmp(argv[n], "--help")) {
PrintUsage(argv[0]);
return 0;
- } else if (!HDisplay) {
+ }
+ else if (!HDisplay) {
HDisplay = atoi(argv[n]);
- if (!HDisplay) {
- PrintUsage(argv[0]);
- return 1;
- }
- }
+ if (!HDisplay) {
+ PrintUsage(argv[0]);
+ return 1;
+ }
+ }
else if (!VDisplay) {
VDisplay = atoi(argv[n]);
- if (!VDisplay) {
- PrintUsage(argv[0]);
- return 1;
- }
- }
+ if (!VDisplay) {
+ PrintUsage(argv[0]);
+ return 1;
+ }
+ }
else if (!VRefresh) {
VRefresh = atof(argv[n]);
- if (!VRefresh) {
- PrintUsage(argv[0]);
- return 1;
- }
- }
+ if (!VRefresh) {
+ PrintUsage(argv[0]);
+ return 1;
+ }
+ }
else {
PrintUsage(argv[0]);
return 1;
@@ -273,13 +273,13 @@ main (int argc, char *argv[])
}
if (Reduced) {
- if ((VRefresh / 60.0) != floor(VRefresh / 60.0)) {
- fprintf(stderr,
- "\nERROR: Multiple of 60Hz refresh rate required for "
- " reduced blanking.\n");
- PrintUsage(argv[0]);
- return 0;
- }
+ if ((VRefresh / 60.0) != floor(VRefresh / 60.0)) {
+ fprintf(stderr,
+ "\nERROR: Multiple of 60Hz refresh rate required for "
+ " reduced blanking.\n");
+ PrintUsage(argv[0]);
+ return 0;
+ }
}
IsCVT = CVTCheckStandard(HDisplay, VDisplay, VRefresh, Reduced, Verbose);
@@ -288,6 +288,6 @@ main (int argc, char *argv[])
PrintComment(Mode, IsCVT, Reduced);
PrintModeline(Mode, HDisplay, VDisplay, VRefresh, Reduced);
-
+
return 0;
}
diff --git a/xorg-server/hw/xfree86/utils/gtf/gtf.c b/xorg-server/hw/xfree86/utils/gtf/gtf.c
index 87fcb3f0e..15503bb35 100644
--- a/xorg-server/hw/xfree86/utils/gtf/gtf.c
+++ b/xorg-server/hw/xfree86/utils/gtf/gtf.c
@@ -104,7 +104,7 @@
*/
#ifdef HAVE_XORG_CONFIG_H
-# include <xorg-config.h>
+#include <xorg-config.h>
#endif
#include <stdio.h>
@@ -128,38 +128,28 @@
#define C_PRIME (((C - J) * K/256.0) + J)
#define M_PRIME (K/256.0 * M)
-
/* struct definitions */
-typedef struct __mode
-{
+typedef struct __mode {
int hr, hss, hse, hfl;
int vr, vss, vse, vfl;
float pclk, h_freq, v_freq;
} mode;
-
-typedef struct __options
-{
+typedef struct __options {
int x, y;
int xorgmode, fbmode;
float v_freq;
} options;
-
-
-
/* prototypes */
void print_value(int n, const char *name, float val);
-void print_xf86_mode (mode *m);
-void print_fb_mode (mode *m);
-mode *vert_refresh (int h_pixels, int v_lines, float freq,
- int interlaced, int margins);
-options *parse_command_line (int argc, char *argv[]);
-
-
-
+void print_xf86_mode(mode * m);
+void print_fb_mode(mode * m);
+mode *vert_refresh(int h_pixels, int v_lines, float freq,
+ int interlaced, int margins);
+options *parse_command_line(int argc, char *argv[]);
/*
* print_value() - print the result of the named computation; this is
@@ -168,34 +158,31 @@ options *parse_command_line (int argc, char *argv[]);
int global_verbose = 0;
-void print_value(int n, const char *name, float val)
+void
+print_value(int n, const char *name, float val)
{
if (global_verbose) {
printf("%2d: %-27s: %15f\n", n, name, val);
}
}
-
-
/* print_xf86_mode() - print the XServer modeline, given mode timings. */
-void print_xf86_mode (mode *m)
+void
+print_xf86_mode(mode * m)
{
- printf ("\n");
- printf (" # %dx%d @ %.2f Hz (GTF) hsync: %.2f kHz; pclk: %.2f MHz\n",
- m->hr, m->vr, m->v_freq, m->h_freq, m->pclk);
-
- printf (" Modeline \"%dx%d_%.2f\" %.2f"
- " %d %d %d %d"
- " %d %d %d %d"
- " -HSync +Vsync\n\n",
- m->hr, m->vr, m->v_freq, m->pclk,
- m->hr, m->hss, m->hse, m->hfl,
- m->vr, m->vss, m->vse, m->vfl);
-
-}
+ printf("\n");
+ printf(" # %dx%d @ %.2f Hz (GTF) hsync: %.2f kHz; pclk: %.2f MHz\n",
+ m->hr, m->vr, m->v_freq, m->h_freq, m->pclk);
+ printf(" Modeline \"%dx%d_%.2f\" %.2f"
+ " %d %d %d %d"
+ " %d %d %d %d"
+ " -HSync +Vsync\n\n",
+ m->hr, m->vr, m->v_freq, m->pclk,
+ m->hr, m->hss, m->hse, m->hfl, m->vr, m->vss, m->vse, m->vfl);
+}
/*
* print_fb_mode() - print a mode description in fbset(8) format;
@@ -243,31 +230,26 @@ void print_xf86_mode (mode *m)
* to edit the mode description after it's generated.
*/
-void print_fb_mode (mode *m)
+void
+print_fb_mode(mode * m)
{
- printf ("\n");
- printf ("mode \"%dx%d %.2fHz 32bit (GTF)\"\n",
- m->hr, m->vr, m->v_freq);
- printf (" # PCLK: %.2f MHz, H: %.2f kHz, V: %.2f Hz\n",
- m->pclk, m->h_freq, m->v_freq);
- printf (" geometry %d %d %d %d 32\n",
- m->hr, m->vr, m->hr, m->vr);
- printf (" timings %d %d %d %d %d %d %d\n",
- (int) rint(1000000.0/m->pclk),/* pixclock in picoseconds */
- m->hfl - m->hse, /* left margin (in pixels) */
- m->hss - m->hr, /* right margin (in pixels) */
- m->vfl - m->vse, /* upper margin (in pixel lines) */
- m->vss - m->vr, /* lower margin (in pixel lines) */
- m->hse - m->hss, /* horizontal sync length (pixels) */
- m->vse - m->vss); /* vert sync length (pixel lines) */
- printf (" hsync low\n");
- printf (" vsync high\n");
- printf ("endmode\n\n");
-
-}
-
-
+ printf("\n");
+ printf("mode \"%dx%d %.2fHz 32bit (GTF)\"\n", m->hr, m->vr, m->v_freq);
+ printf(" # PCLK: %.2f MHz, H: %.2f kHz, V: %.2f Hz\n",
+ m->pclk, m->h_freq, m->v_freq);
+ printf(" geometry %d %d %d %d 32\n", m->hr, m->vr, m->hr, m->vr);
+ printf(" timings %d %d %d %d %d %d %d\n", (int) rint(1000000.0 / m->pclk), /* pixclock in picoseconds */
+ m->hfl - m->hse, /* left margin (in pixels) */
+ m->hss - m->hr, /* right margin (in pixels) */
+ m->vfl - m->vse, /* upper margin (in pixel lines) */
+ m->vss - m->vr, /* lower margin (in pixel lines) */
+ m->hse - m->hss, /* horizontal sync length (pixels) */
+ m->vse - m->vss); /* vert sync length (pixel lines) */
+ printf(" hsync low\n");
+ printf(" vsync high\n");
+ printf("endmode\n\n");
+}
/*
* vert_refresh() - as defined by the GTF Timing Standard, compute the
@@ -282,8 +264,8 @@ void print_fb_mode (mode *m)
* XServer of fbset mode descriptions, from what I can tell).
*/
-mode *vert_refresh (int h_pixels, int v_lines, float freq,
- int interlaced, int margins)
+mode *
+vert_refresh(int h_pixels, int v_lines, float freq, int interlaced, int margins)
{
float h_pixels_rnd;
float v_lines_rnd;
@@ -312,9 +294,8 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
float h_front_porch;
float v_odd_front_porch_lines;
- mode *m = (mode*) malloc (sizeof (mode));
-
-
+ mode *m = (mode *) malloc(sizeof(mode));
+
/* 1. In order to give correct results, the number of horizontal
* pixels requested is first processed to ensure that it is divisible
* by the character size, by rounding it to the nearest character
@@ -322,12 +303,11 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
*
* [H PIXELS RND] = ((ROUND([H PIXELS]/[CELL GRAN RND],0))*[CELLGRAN RND])
*/
-
+
h_pixels_rnd = rint((float) h_pixels / CELL_GRAN) * CELL_GRAN;
-
+
print_value(1, "[H PIXELS RND]", h_pixels_rnd);
-
/* 2. If interlace is requested, the number of vertical lines assumed
* by the calculation must be halved, as the computation calculates
* the number of vertical lines per field. In either case, the
@@ -338,12 +318,10 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
*/
v_lines_rnd = interlaced ?
- rint((float) v_lines) / 2.0 :
- rint((float) v_lines);
-
+ rint((float) v_lines) / 2.0 : rint((float) v_lines);
+
print_value(2, "[V LINES RND]", v_lines_rnd);
-
-
+
/* 3. Find the frame rate required:
*
* [V FIELD RATE RQD] = IF([INT RQD?]="y", [I/P FREQ RQD]*2,
@@ -353,7 +331,6 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
v_field_rate_rqd = interlaced ? (freq * 2.0) : (freq);
print_value(3, "[V FIELD RATE RQD]", v_field_rate_rqd);
-
/* 4. Find number of lines in Top margin:
*
@@ -365,7 +342,6 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
top_margin = margins ? rint(MARGIN_PERCENT / 100.0 * v_lines_rnd) : (0.0);
print_value(4, "[TOP MARGIN (LINES)]", top_margin);
-
/* 5. Find number of lines in Bottom margin:
*
@@ -374,11 +350,11 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
* 0)
*/
- bottom_margin = margins ? rint(MARGIN_PERCENT/100.0 * v_lines_rnd) : (0.0);
+ bottom_margin =
+ margins ? rint(MARGIN_PERCENT / 100.0 * v_lines_rnd) : (0.0);
print_value(5, "[BOT MARGIN (LINES)]", bottom_margin);
-
/* 6. If interlace is required, then set variable [INTERLACE]=0.5:
*
* [INTERLACE]=(IF([INT RQD?]="y",0.5,0))
@@ -387,7 +363,6 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
interlace = interlaced ? 0.5 : 0.0;
print_value(6, "[INTERLACE]", interlace);
-
/* 7. Estimate the Horizontal period
*
@@ -396,34 +371,31 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
* [MIN PORCH RND]+[INTERLACE]) * 1000000
*/
- h_period_est = (((1.0/v_field_rate_rqd) - (MIN_VSYNC_PLUS_BP/1000000.0))
- / (v_lines_rnd + (2*top_margin) + MIN_PORCH + interlace)
+ h_period_est = (((1.0 / v_field_rate_rqd) - (MIN_VSYNC_PLUS_BP / 1000000.0))
+ / (v_lines_rnd + (2 * top_margin) + MIN_PORCH + interlace)
* 1000000.0);
print_value(7, "[H PERIOD EST]", h_period_est);
-
/* 8. Find the number of lines in V sync + back porch:
*
* [V SYNC+BP] = ROUND(([MIN VSYNC+BP]/[H PERIOD EST]),0)
*/
- vsync_plus_bp = rint(MIN_VSYNC_PLUS_BP/h_period_est);
+ vsync_plus_bp = rint(MIN_VSYNC_PLUS_BP / h_period_est);
print_value(8, "[V SYNC+BP]", vsync_plus_bp);
-
-
+
/* 9. Find the number of lines in V back porch alone:
*
* [V BACK PORCH] = [V SYNC+BP] - [V SYNC RND]
*
* XXX is "[V SYNC RND]" a typo? should be [V SYNC RQD]?
*/
-
+
v_back_porch = vsync_plus_bp - V_SYNC_RQD;
-
+
print_value(9, "[V BACK PORCH]", v_back_porch);
-
/* 10. Find the total number of lines in Vertical field period:
*
@@ -434,9 +406,8 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
total_v_lines = v_lines_rnd + top_margin + bottom_margin + vsync_plus_bp +
interlace + MIN_PORCH;
-
+
print_value(10, "[TOTAL V LINES]", total_v_lines);
-
/* 11. Estimate the Vertical field frequency:
*
@@ -444,9 +415,8 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
*/
v_field_rate_est = 1.0 / h_period_est / total_v_lines * 1000000.0;
-
+
print_value(11, "[V FIELD RATE EST]", v_field_rate_est);
-
/* 12. Find the actual horizontal period:
*
@@ -454,9 +424,8 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
*/
h_period = h_period_est / (v_field_rate_rqd / v_field_rate_est);
-
+
print_value(12, "[H PERIOD]", h_period);
-
/* 13. Find the actual Vertical field frequency:
*
@@ -466,7 +435,6 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
v_field_rate = 1.0 / h_period / total_v_lines * 1000000.0;
print_value(13, "[V FIELD RATE]", v_field_rate);
-
/* 14. Find the Vertical frame frequency:
*
@@ -476,7 +444,6 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
v_frame_rate = interlaced ? v_field_rate / 2.0 : v_field_rate;
print_value(14, "[V FRAME RATE]", v_frame_rate);
-
/* 15. Find number of pixels in left margin:
*
@@ -489,9 +456,8 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
left_margin = margins ?
rint(h_pixels_rnd * MARGIN_PERCENT / 100.0 / CELL_GRAN) * CELL_GRAN :
0.0;
-
+
print_value(15, "[LEFT MARGIN (PIXELS)]", left_margin);
-
/* 16. Find number of pixels in right margin:
*
@@ -500,13 +466,12 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
* [CELL GRAN RND]),0)) * [CELL GRAN RND],
* 0))
*/
-
+
right_margin = margins ?
rint(h_pixels_rnd * MARGIN_PERCENT / 100.0 / CELL_GRAN) * CELL_GRAN :
0.0;
-
+
print_value(16, "[RIGHT MARGIN (PIXELS)]", right_margin);
-
/* 17. Find total number of active pixels in image and left and right
* margins:
@@ -516,10 +481,9 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
*/
total_active_pixels = h_pixels_rnd + left_margin + right_margin;
-
+
print_value(17, "[TOTAL ACTIVE PIXELS]", total_active_pixels);
-
-
+
/* 18. Find the ideal blanking duty cycle from the blanking duty cycle
* equation:
*
@@ -527,9 +491,8 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
*/
ideal_duty_cycle = C_PRIME - (M_PRIME * h_period / 1000.0);
-
+
print_value(18, "[IDEAL DUTY CYCLE]", ideal_duty_cycle);
-
/* 19. Find the number of pixels in the blanking time to the nearest
* double character cell:
@@ -545,9 +508,8 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
ideal_duty_cycle /
(100.0 - ideal_duty_cycle) /
(2.0 * CELL_GRAN)) * (2.0 * CELL_GRAN);
-
+
print_value(19, "[H BLANK (PIXELS)]", h_blank);
-
/* 20. Find total number of pixels:
*
@@ -555,19 +517,17 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
*/
total_pixels = total_active_pixels + h_blank;
-
+
print_value(20, "[TOTAL PIXELS]", total_pixels);
-
/* 21. Find pixel clock frequency:
*
* [PIXEL FREQ] = [TOTAL PIXELS] / [H PERIOD]
*/
-
+
pixel_freq = total_pixels / h_period;
-
+
print_value(21, "[PIXEL FREQ]", pixel_freq);
-
/* 22. Find horizontal frequency:
*
@@ -575,28 +535,24 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
*/
h_freq = 1000.0 / h_period;
-
- print_value(22, "[H FREQ]", h_freq);
-
+ print_value(22, "[H FREQ]", h_freq);
/* Stage 1 computations are now complete; I should really pass
the results to another function and do the Stage 2
computations, but I only need a few more values so I'll just
append the computations here for now */
-
-
/* 17. Find the number of pixels in the horizontal sync period:
*
* [H SYNC (PIXELS)] =(ROUND(([H SYNC%] / 100 * [TOTAL PIXELS] /
* [CELL GRAN RND]),0))*[CELL GRAN RND]
*/
- h_sync = rint(H_SYNC_PERCENT/100.0 * total_pixels / CELL_GRAN) * CELL_GRAN;
+ h_sync =
+ rint(H_SYNC_PERCENT / 100.0 * total_pixels / CELL_GRAN) * CELL_GRAN;
print_value(17, "[H SYNC (PIXELS)]", h_sync);
-
/* 18. Find the number of pixels in the horizontal front porch period:
*
@@ -606,136 +562,136 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
h_front_porch = (h_blank / 2.0) - h_sync;
print_value(18, "[H FRONT PORCH (PIXELS)]", h_front_porch);
-
-
+
/* 36. Find the number of lines in the odd front porch period:
*
* [V ODD FRONT PORCH(LINES)]=([MIN PORCH RND]+[INTERLACE])
*/
-
+
v_odd_front_porch_lines = MIN_PORCH + interlace;
-
+
print_value(36, "[V ODD FRONT PORCH(LINES)]", v_odd_front_porch_lines);
-
/* finally, pack the results in the mode struct */
-
- m->hr = (int) (h_pixels_rnd);
+
+ m->hr = (int) (h_pixels_rnd);
m->hss = (int) (h_pixels_rnd + h_front_porch);
m->hse = (int) (h_pixels_rnd + h_front_porch + h_sync);
m->hfl = (int) (total_pixels);
- m->vr = (int) (v_lines_rnd);
+ m->vr = (int) (v_lines_rnd);
m->vss = (int) (v_lines_rnd + v_odd_front_porch_lines);
m->vse = (int) (int) (v_lines_rnd + v_odd_front_porch_lines + V_SYNC_RQD);
m->vfl = (int) (total_v_lines);
- m->pclk = pixel_freq;
+ m->pclk = pixel_freq;
m->h_freq = h_freq;
m->v_freq = freq;
return m;
-
-}
-
-
+}
/*
* parse_command_line() - parse the command line and return an
* alloced structure containing the results. On error print usage
* and return NULL.
- */
+ */
-options *parse_command_line (int argc, char *argv[])
+options *
+parse_command_line(int argc, char *argv[])
{
int n;
- options *o = (options *) calloc (1, sizeof (options));
+ options *o = (options *) calloc(1, sizeof(options));
- if (argc < 4) goto bad_option;
+ if (argc < 4)
+ goto bad_option;
- o->x = atoi (argv[1]);
- o->y = atoi (argv[2]);
- o->v_freq = atof (argv[3]);
+ o->x = atoi(argv[1]);
+ o->y = atoi(argv[2]);
+ o->v_freq = atof(argv[3]);
/* XXX should check for errors in the above */
-
+
n = 4;
while (n < argc) {
- if ((strcmp (argv[n], "-v") == 0) ||
- (strcmp (argv[n], "--verbose") == 0)) {
+ if ((strcmp(argv[n], "-v") == 0) || (strcmp(argv[n], "--verbose") == 0)) {
global_verbose = 1;
- } else if ((strcmp (argv[n], "-f") == 0) ||
- (strcmp (argv[n], "--fbmode") == 0)) {
+ }
+ else if ((strcmp(argv[n], "-f") == 0) ||
+ (strcmp(argv[n], "--fbmode") == 0)) {
o->fbmode = 1;
- } else if ((strcmp (argv[n], "-x") == 0) ||
- (strcmp (argv[n], "--xorgmode") == 0) ||
- (strcmp (argv[n], "--xf86mode") == 0)) {
+ }
+ else if ((strcmp(argv[n], "-x") == 0) ||
+ (strcmp(argv[n], "--xorgmode") == 0) ||
+ (strcmp(argv[n], "--xf86mode") == 0)) {
o->xorgmode = 1;
- } else {
+ }
+ else {
goto bad_option;
}
-
+
n++;
}
/* if neither xorgmode nor fbmode were requested, default to
xorgmode */
- if (!o->fbmode && !o->xorgmode) o->xorgmode = 1;
-
+ if (!o->fbmode && !o->xorgmode)
+ o->xorgmode = 1;
+
return o;
-
+
bad_option:
- fprintf (stderr, "\n");
- fprintf (stderr, "usage: %s x y refresh [-v|--verbose] "
- "[-f|--fbmode] [-x|--xorgmode]\n", argv[0]);
-
- fprintf (stderr, "\n");
-
- fprintf (stderr, " x : the desired horizontal "
- "resolution (required)\n");
- fprintf (stderr, " y : the desired vertical "
- "resolution (required)\n");
- fprintf (stderr, " refresh : the desired refresh "
- "rate (required)\n");
- fprintf (stderr, " -v|--verbose : enable verbose printouts "
- "(traces each step of the computation)\n");
- fprintf (stderr, " -f|--fbmode : output an fbset(8)-style mode "
- "description\n");
- fprintf (stderr, " -x|--xorgmode : output an "__XSERVERNAME__"-style mode "
- "description (this is the default\n"
- " if no mode description is requested)\n");
-
- fprintf (stderr, "\n");
-
- free (o);
- return NULL;
+ fprintf(stderr, "\n");
+ fprintf(stderr, "usage: %s x y refresh [-v|--verbose] "
+ "[-f|--fbmode] [-x|--xorgmode]\n", argv[0]);
-}
+ fprintf(stderr, "\n");
+ fprintf(stderr, " x : the desired horizontal "
+ "resolution (required)\n");
+ fprintf(stderr, " y : the desired vertical "
+ "resolution (required)\n");
+ fprintf(stderr, " refresh : the desired refresh " "rate (required)\n");
+ fprintf(stderr, " -v|--verbose : enable verbose printouts "
+ "(traces each step of the computation)\n");
+ fprintf(stderr, " -f|--fbmode : output an fbset(8)-style mode "
+ "description\n");
+ fprintf(stderr, " -x|--xorgmode : output an " __XSERVERNAME__ "-style mode "
+ "description (this is the default\n"
+ " if no mode description is requested)\n");
+ fprintf(stderr, "\n");
-int main (int argc, char *argv[])
+ free(o);
+ return NULL;
+
+}
+
+int
+main(int argc, char *argv[])
{
mode *m;
options *o;
- o = parse_command_line (argc, argv);
- if (!o) exit (1);
-
- m = vert_refresh (o->x, o->y, o->v_freq, 0, 0);
- if (!m) exit (1);
+ o = parse_command_line(argc, argv);
+ if (!o)
+ exit(1);
+
+ m = vert_refresh(o->x, o->y, o->v_freq, 0, 0);
+ if (!m)
+ exit(1);
if (o->xorgmode)
print_xf86_mode(m);
-
+
if (o->fbmode)
print_fb_mode(m);
-
+
return 0;
-
+
}
diff --git a/xorg-server/hw/xfree86/vbe/vbe.c b/xorg-server/hw/xfree86/vbe/vbe.c
index 6ecca6858..bbb60e3a1 100644
--- a/xorg-server/hw/xfree86/vbe/vbe.c
+++ b/xorg-server/hw/xfree86/vbe/vbe.c
@@ -22,7 +22,7 @@
#define VERSION(x) VBE_VERSION_MAJOR(x),VBE_VERSION_MINOR(x)
#if X_BYTE_ORDER == X_LITTLE_ENDIAN
-#define B_O16(x) (x)
+#define B_O16(x) (x)
#define B_O32(x) (x)
#else
#define B_O16(x) ((((x) & 0xff) << 8) | (((x) & 0xff) >> 8))
@@ -34,7 +34,7 @@
#define FARP(p) (((unsigned)(p & 0xffff0000) >> 12) | (p & 0xffff))
#define R16(v) ((v) & 0xffff)
-static unsigned char * vbeReadEDID(vbeInfoPtr pVbe);
+static unsigned char *vbeReadEDID(vbeInfoPtr pVbe);
static Bool vbeProbeDDC(vbeInfoPtr pVbe);
static const char vbeVersionString[] = "VBE2";
@@ -56,85 +56,93 @@ VBEExtendedInit(xf86Int10InfoPtr pInt, int entityIndex, int Flags)
vbeInfoPtr vip = NULL;
int screen;
- if (!pScrn) return NULL;
+ if (!pScrn)
+ return NULL;
screen = pScrn->scrnIndex;
-
+
if (!pInt) {
- if (!xf86LoadSubModule(pScrn, "int10"))
- goto error;
-
- xf86DrvMsg(screen,X_INFO,"initializing int10\n");
- pInt = xf86ExtendedInitInt10(entityIndex,Flags);
- if (!pInt)
- goto error;
- init_int10 = TRUE;
+ if (!xf86LoadSubModule(pScrn, "int10"))
+ goto error;
+
+ xf86DrvMsg(screen, X_INFO, "initializing int10\n");
+ pInt = xf86ExtendedInitInt10(entityIndex, Flags);
+ if (!pInt)
+ goto error;
+ init_int10 = TRUE;
}
-
- page = xf86Int10AllocPages(pInt,1,&RealOff);
- if (!page) goto error;
- vbe = (vbeControllerInfoPtr) page;
- memcpy(vbe->VbeSignature,vbeVersionString,4);
+
+ page = xf86Int10AllocPages(pInt, 1, &RealOff);
+ if (!page)
+ goto error;
+ vbe = (vbeControllerInfoPtr) page;
+ memcpy(vbe->VbeSignature, vbeVersionString, 4);
pInt->ax = 0x4F00;
pInt->es = SEG_ADDR(RealOff);
pInt->di = SEG_OFF(RealOff);
pInt->num = 0x10;
-
+
xf86ExecX86int10(pInt);
if ((pInt->ax & 0xff) != 0x4f) {
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA BIOS not detected\n");
- goto error;
+ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA BIOS not detected\n");
+ goto error;
}
-
+
switch (pInt->ax & 0xff00) {
case 0:
- xf86DrvMsg(screen,X_INFO,"VESA BIOS detected\n");
- break;
+ xf86DrvMsg(screen, X_INFO, "VESA BIOS detected\n");
+ break;
case 0x100:
- xf86DrvMsg(screen,X_INFO,"VESA BIOS function failed\n");
- goto error;
+ xf86DrvMsg(screen, X_INFO, "VESA BIOS function failed\n");
+ goto error;
case 0x200:
- xf86DrvMsg(screen,X_INFO,"VESA BIOS not supported\n");
- goto error;
+ xf86DrvMsg(screen, X_INFO, "VESA BIOS not supported\n");
+ goto error;
case 0x300:
- xf86DrvMsg(screen,X_INFO,"VESA BIOS not supported in current mode\n");
- goto error;
+ xf86DrvMsg(screen, X_INFO, "VESA BIOS not supported in current mode\n");
+ goto error;
default:
- xf86DrvMsg(screen,X_INFO,"Invalid\n");
- goto error;
+ xf86DrvMsg(screen, X_INFO, "Invalid\n");
+ goto error;
}
-
+
xf86DrvMsgVerb(screen, X_INFO, 4,
- "VbeVersion is %d, OemStringPtr is 0x%08lx,\n"
- "\tOemVendorNamePtr is 0x%08lx, OemProductNamePtr is 0x%08lx,\n"
- "\tOemProductRevPtr is 0x%08lx\n",
- vbe->VbeVersion, (unsigned long)vbe->OemStringPtr,
- (unsigned long)vbe->OemVendorNamePtr,
- (unsigned long)vbe->OemProductNamePtr,
- (unsigned long)vbe->OemProductRevPtr);
-
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE Version %i.%i\n",
- VERSION(vbe->VbeVersion));
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE Total Mem: %i kB\n",
- vbe->TotalMem * 64);
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM: %s\n",
- (CARD8*)xf86int10Addr(pInt,L_ADD(vbe->OemStringPtr)));
-
+ "VbeVersion is %d, OemStringPtr is 0x%08lx,\n"
+ "\tOemVendorNamePtr is 0x%08lx, OemProductNamePtr is 0x%08lx,\n"
+ "\tOemProductRevPtr is 0x%08lx\n",
+ vbe->VbeVersion, (unsigned long) vbe->OemStringPtr,
+ (unsigned long) vbe->OemVendorNamePtr,
+ (unsigned long) vbe->OemProductNamePtr,
+ (unsigned long) vbe->OemProductRevPtr);
+
+ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE Version %i.%i\n",
+ VERSION(vbe->VbeVersion));
+ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE Total Mem: %i kB\n",
+ vbe->TotalMem * 64);
+ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE OEM: %s\n",
+ (CARD8 *) xf86int10Addr(pInt, L_ADD(vbe->OemStringPtr)));
+
if (B_O16(vbe->VbeVersion) >= 0x200) {
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM Software Rev: %i.%i\n",
- VERSION(vbe->OemSoftwareRev));
- if (vbe->OemVendorNamePtr)
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM Vendor: %s\n",
- (CARD8*)xf86int10Addr(pInt,L_ADD(vbe->OemVendorNamePtr)));
- if (vbe->OemProductNamePtr)
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM Product: %s\n",
- (CARD8*)xf86int10Addr(pInt,L_ADD(vbe->OemProductNamePtr)));
- if (vbe->OemProductRevPtr)
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM Product Rev: %s\n",
- (CARD8*)xf86int10Addr(pInt,L_ADD(vbe->OemProductRevPtr)));
+ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE OEM Software Rev: %i.%i\n",
+ VERSION(vbe->OemSoftwareRev));
+ if (vbe->OemVendorNamePtr)
+ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE OEM Vendor: %s\n",
+ (CARD8 *) xf86int10Addr(pInt,
+ L_ADD(vbe->
+ OemVendorNamePtr)));
+ if (vbe->OemProductNamePtr)
+ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE OEM Product: %s\n",
+ (CARD8 *) xf86int10Addr(pInt,
+ L_ADD(vbe->
+ OemProductNamePtr)));
+ if (vbe->OemProductRevPtr)
+ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE OEM Product Rev: %s\n",
+ (CARD8 *) xf86int10Addr(pInt,
+ L_ADD(vbe->
+ OemProductRevPtr)));
}
- vip = (vbeInfoPtr)xnfalloc(sizeof(vbeInfoRec));
+ vip = (vbeInfoPtr) xnfalloc(sizeof(vbeInfoRec));
vip->version = B_O16(vbe->VbeVersion);
vip->pInt10 = pInt;
vip->ddc = DDC_UNCHECKED;
@@ -147,9 +155,9 @@ VBEExtendedInit(xf86Int10InfoPtr pInt, int entityIndex, int Flags)
error:
if (page)
- xf86Int10FreePages(pInt, page, 1);
+ xf86Int10FreePages(pInt, page, 1);
if (init_int10)
- xf86FreeInt10(pInt);
+ xf86FreeInt10(pInt);
return NULL;
}
@@ -157,12 +165,12 @@ void
vbeFree(vbeInfoPtr pVbe)
{
if (!pVbe)
- return;
+ return;
- xf86Int10FreePages(pVbe->pInt10,pVbe->memory,pVbe->num_pages);
+ xf86Int10FreePages(pVbe->pInt10, pVbe->memory, pVbe->num_pages);
/* If we have initalized int10 we ought to free it, too */
- if (pVbe->init_int10)
- xf86FreeInt10(pVbe->pInt10);
+ if (pVbe->init_int10)
+ xf86FreeInt10(pVbe->pInt10);
free(pVbe);
return;
}
@@ -172,11 +180,11 @@ vbeProbeDDC(vbeInfoPtr pVbe)
{
const char *ddc_level;
int screen = pVbe->pInt10->scrnIndex;
-
+
if (pVbe->ddc == DDC_NONE)
- return FALSE;
+ return FALSE;
if (pVbe->ddc != DDC_UNCHECKED)
- return TRUE;
+ return TRUE;
pVbe->pInt10->ax = 0x4F15;
pVbe->pInt10->bx = 0;
@@ -188,61 +196,62 @@ vbeProbeDDC(vbeInfoPtr pVbe)
xf86ExecX86int10(pVbe->pInt10);
if ((pVbe->pInt10->ax & 0xff) != 0x4f) {
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC not supported\n");
- pVbe->ddc = DDC_NONE;
- return FALSE;
+ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC not supported\n");
+ pVbe->ddc = DDC_NONE;
+ return FALSE;
}
switch ((pVbe->pInt10->ax >> 8) & 0xff) {
case 0:
- xf86DrvMsg(screen,X_INFO,"VESA VBE DDC supported\n");
- switch (pVbe->pInt10->bx & 0x3) {
- case 0:
- ddc_level = " none";
- pVbe->ddc = DDC_NONE;
- break;
- case 1:
- ddc_level = " 1";
- pVbe->ddc = DDC_1;
- break;
- case 2:
- ddc_level = " 2";
- pVbe->ddc = DDC_2;
- break;
- case 3:
- ddc_level = " 1 + 2";
- pVbe->ddc = DDC_1_2;
- break;
- default:
- ddc_level = "";
- pVbe->ddc = DDC_NONE;
- break;
- }
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC Level%s\n",ddc_level);
- if (pVbe->pInt10->bx & 0x4) {
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC Screen blanked"
- "for data transfer\n");
- pVbe->ddc_blank = TRUE;
- } else
- pVbe->ddc_blank = FALSE;
-
- xf86DrvMsgVerb(screen,X_INFO,3,
- "VESA VBE DDC transfer in appr. %x sec.\n",
- (pVbe->pInt10->bx >> 8) & 0xff);
+ xf86DrvMsg(screen, X_INFO, "VESA VBE DDC supported\n");
+ switch (pVbe->pInt10->bx & 0x3) {
+ case 0:
+ ddc_level = " none";
+ pVbe->ddc = DDC_NONE;
+ break;
+ case 1:
+ ddc_level = " 1";
+ pVbe->ddc = DDC_1;
+ break;
+ case 2:
+ ddc_level = " 2";
+ pVbe->ddc = DDC_2;
+ break;
+ case 3:
+ ddc_level = " 1 + 2";
+ pVbe->ddc = DDC_1_2;
+ break;
+ default:
+ ddc_level = "";
+ pVbe->ddc = DDC_NONE;
+ break;
+ }
+ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC Level%s\n", ddc_level);
+ if (pVbe->pInt10->bx & 0x4) {
+ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC Screen blanked"
+ "for data transfer\n");
+ pVbe->ddc_blank = TRUE;
+ }
+ else
+ pVbe->ddc_blank = FALSE;
+
+ xf86DrvMsgVerb(screen, X_INFO, 3,
+ "VESA VBE DDC transfer in appr. %x sec.\n",
+ (pVbe->pInt10->bx >> 8) & 0xff);
}
-
- return TRUE;
+
+ return TRUE;
}
typedef enum {
- VBEOPT_NOVBE,
+ VBEOPT_NOVBE,
VBEOPT_NODDC
} VBEOpts;
static const OptionInfoRec VBEOptions[] = {
- { VBEOPT_NOVBE, "NoVBE", OPTV_BOOLEAN, {0}, FALSE },
- { VBEOPT_NODDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE },
- { -1, NULL, OPTV_NONE, {0}, FALSE },
+ {VBEOPT_NOVBE, "NoVBE", OPTV_BOOLEAN, {0}, FALSE},
+ {VBEOPT_NODDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE},
+ {-1, NULL, OPTV_NONE, {0}, FALSE},
};
static unsigned char *
@@ -256,20 +265,23 @@ vbeReadEDID(vbeInfoPtr pVbe)
int screen = pVbe->pInt10->scrnIndex;
OptionInfoPtr options;
- if (!page) return NULL;
+ if (!page)
+ return NULL;
options = xnfalloc(sizeof(VBEOptions));
- (void)memcpy(options, VBEOptions, sizeof(VBEOptions));
+ (void) memcpy(options, VBEOptions, sizeof(VBEOptions));
xf86ProcessOptions(screen, xf86Screens[screen]->options, options);
xf86GetOptValBool(options, VBEOPT_NOVBE, &novbe);
xf86GetOptValBool(options, VBEOPT_NODDC, &noddc);
free(options);
- if (novbe || noddc) return NULL;
-
- if (!vbeProbeDDC(pVbe)) goto error;
+ if (novbe || noddc)
+ return NULL;
- memset(page,0,sizeof(vbeInfoPtr));
- strcpy(page,vbeVersionString);
+ if (!vbeProbeDDC(pVbe))
+ goto error;
+
+ memset(page, 0, sizeof(vbeInfoPtr));
+ strcpy(page, vbeVersionString);
pVbe->pInt10->ax = 0x4F15;
pVbe->pInt10->bx = 0x01;
@@ -282,24 +294,24 @@ vbeReadEDID(vbeInfoPtr pVbe)
xf86ExecX86int10(pVbe->pInt10);
if ((pVbe->pInt10->ax & 0xff) != 0x4f) {
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC invalid\n");
- goto error;
+ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC invalid\n");
+ goto error;
}
switch (pVbe->pInt10->ax & 0xff00) {
case 0x0:
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC read successfully\n");
- tmp = (unsigned char *)xnfalloc(128);
- memcpy(tmp,page,128);
- break;
+ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC read successfully\n");
+ tmp = (unsigned char *) xnfalloc(128);
+ memcpy(tmp, page, 128);
+ break;
case 0x100:
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC read failed\n");
- break;
+ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC read failed\n");
+ break;
default:
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC unkown failure %i\n",
- pVbe->pInt10->ax & 0xff00);
- break;
+ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC unkown failure %i\n",
+ pVbe->pInt10->ax & 0xff00);
+ break;
}
-
+
error:
return tmp;
}
@@ -307,26 +319,27 @@ vbeReadEDID(vbeInfoPtr pVbe)
xf86MonPtr
vbeDoEDID(vbeInfoPtr pVbe, pointer pDDCModule)
{
- xf86MonPtr pMonitor;
- pointer pModule;
+ xf86MonPtr pMonitor;
+ pointer pModule;
unsigned char *DDC_data = NULL;
-
- if (!pVbe) return NULL;
+
+ if (!pVbe)
+ return NULL;
if (pVbe->version < 0x200)
- return NULL;
+ return NULL;
if (!(pModule = pDDCModule)) {
- pModule =
- xf86LoadSubModule(xf86Screens[pVbe->pInt10->scrnIndex], "ddc");
- if (!pModule)
- return NULL;
+ pModule =
+ xf86LoadSubModule(xf86Screens[pVbe->pInt10->scrnIndex], "ddc");
+ if (!pModule)
+ return NULL;
}
-
+
DDC_data = vbeReadEDID(pVbe);
- if (!DDC_data)
- return NULL;
-
+ if (!DDC_data)
+ return NULL;
+
pMonitor = xf86InterpretEDID(pVbe->pInt10->scrnIndex, DDC_data);
if (!pDDCModule)
@@ -348,20 +361,20 @@ VBEGetVBEInfo(vbeInfoPtr pVbe)
memset(pVbe->memory, 0, sizeof(VbeInfoBlock));
/*
- Input:
- AH := 4Fh Super VGA support
- AL := 00h Return Super VGA information
- ES:DI := Pointer to buffer
-
- Output:
- AX := status
- (All other registers are preserved)
+ Input:
+ AH := 4Fh Super VGA support
+ AL := 00h Return Super VGA information
+ ES:DI := Pointer to buffer
+
+ Output:
+ AX := status
+ (All other registers are preserved)
*/
- ((char*)pVbe->memory)[0] = 'V';
- ((char*)pVbe->memory)[1] = 'B';
- ((char*)pVbe->memory)[2] = 'E';
- ((char*)pVbe->memory)[3] = '2';
+ ((char *) pVbe->memory)[0] = 'V';
+ ((char *) pVbe->memory)[1] = 'B';
+ ((char *) pVbe->memory)[2] = 'E';
+ ((char *) pVbe->memory)[3] = '2';
pVbe->pInt10->num = 0x10;
pVbe->pInt10->ax = 0x4f00;
@@ -370,102 +383,103 @@ VBEGetVBEInfo(vbeInfoPtr pVbe)
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return NULL;
+ return NULL;
block = calloc(sizeof(VbeInfoBlock), 1);
- block->VESASignature[0] = ((char*)pVbe->memory)[0];
- block->VESASignature[1] = ((char*)pVbe->memory)[1];
- block->VESASignature[2] = ((char*)pVbe->memory)[2];
- block->VESASignature[3] = ((char*)pVbe->memory)[3];
+ block->VESASignature[0] = ((char *) pVbe->memory)[0];
+ block->VESASignature[1] = ((char *) pVbe->memory)[1];
+ block->VESASignature[2] = ((char *) pVbe->memory)[2];
+ block->VESASignature[3] = ((char *) pVbe->memory)[3];
- block->VESAVersion = *(CARD16*)(((char*)pVbe->memory) + 4);
- major = (unsigned)block->VESAVersion >> 8;
+ block->VESAVersion = *(CARD16 *) (((char *) pVbe->memory) + 4);
+ major = (unsigned) block->VESAVersion >> 8;
- pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 6));
+ pStr = GET_UNALIGNED2((((char *) pVbe->memory) + 6));
str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
block->OEMStringPtr = strdup(str);
- block->Capabilities[0] = ((char*)pVbe->memory)[10];
- block->Capabilities[1] = ((char*)pVbe->memory)[11];
- block->Capabilities[2] = ((char*)pVbe->memory)[12];
- block->Capabilities[3] = ((char*)pVbe->memory)[13];
+ block->Capabilities[0] = ((char *) pVbe->memory)[10];
+ block->Capabilities[1] = ((char *) pVbe->memory)[11];
+ block->Capabilities[2] = ((char *) pVbe->memory)[12];
+ block->Capabilities[3] = ((char *) pVbe->memory)[13];
- pModes = GET_UNALIGNED2((((char*)pVbe->memory) + 14));
+ pModes = GET_UNALIGNED2((((char *) pVbe->memory) + 14));
modes = xf86int10Addr(pVbe->pInt10, FARP(pModes));
i = 0;
while (modes[i] != 0xffff)
- i++;
+ i++;
block->VideoModePtr = malloc(sizeof(CARD16) * (i + 1));
memcpy(block->VideoModePtr, modes, sizeof(CARD16) * i);
block->VideoModePtr[i] = 0xffff;
- block->TotalMemory = *(CARD16*)(((char*)pVbe->memory) + 18);
+ block->TotalMemory = *(CARD16 *) (((char *) pVbe->memory) + 18);
if (major < 2)
- memcpy(&block->OemSoftwareRev, ((char*)pVbe->memory) + 20, 236);
+ memcpy(&block->OemSoftwareRev, ((char *) pVbe->memory) + 20, 236);
else {
- block->OemSoftwareRev = *(CARD16*)(((char*)pVbe->memory) + 20);
- pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 22));
- str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
- block->OemVendorNamePtr = strdup(str);
- pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 26));
- str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
- block->OemProductNamePtr = strdup(str);
- pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 30));
- str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
- block->OemProductRevPtr = strdup(str);
- memcpy(&block->Reserved, ((char*)pVbe->memory) + 34, 222);
- memcpy(&block->OemData, ((char*)pVbe->memory) + 256, 256);
+ block->OemSoftwareRev = *(CARD16 *) (((char *) pVbe->memory) + 20);
+ pStr = GET_UNALIGNED2((((char *) pVbe->memory) + 22));
+ str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
+ block->OemVendorNamePtr = strdup(str);
+ pStr = GET_UNALIGNED2((((char *) pVbe->memory) + 26));
+ str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
+ block->OemProductNamePtr = strdup(str);
+ pStr = GET_UNALIGNED2((((char *) pVbe->memory) + 30));
+ str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
+ block->OemProductRevPtr = strdup(str);
+ memcpy(&block->Reserved, ((char *) pVbe->memory) + 34, 222);
+ memcpy(&block->OemData, ((char *) pVbe->memory) + 256, 256);
}
return block;
}
void
-VBEFreeVBEInfo(VbeInfoBlock *block)
+VBEFreeVBEInfo(VbeInfoBlock * block)
{
free(block->OEMStringPtr);
free(block->VideoModePtr);
- if (((unsigned)block->VESAVersion >> 8) >= 2) {
- free(block->OemVendorNamePtr);
- free(block->OemProductNamePtr);
- free(block->OemProductRevPtr);
+ if (((unsigned) block->VESAVersion >> 8) >= 2) {
+ free(block->OemVendorNamePtr);
+ free(block->OemProductNamePtr);
+ free(block->OemProductRevPtr);
}
free(block);
}
Bool
-VBESetVBEMode(vbeInfoPtr pVbe, int mode, VbeCRTCInfoBlock *block)
+VBESetVBEMode(vbeInfoPtr pVbe, int mode, VbeCRTCInfoBlock * block)
{
/*
- Input:
- AH := 4Fh Super VGA support
- AL := 02h Set Super VGA video mode
- BX := Video mode
- D0-D8 := Mode number
- D9-D10 := Reserved (must be 0)
- D11 := 0 Use current default refresh rate
- := 1 Use user specified CRTC values for refresh rate
- D12-13 Reserved for VBE/AF (must be 0)
- D14 := 0 Use windowed frame buffer model
- := 1 Use linear/flat frame buffer model
- D15 := 0 Clear video memory
- := 1 Don't clear video memory
- ES:DI := Pointer to VbeCRTCInfoBlock structure
-
- Output: AX = Status
- (All other registers are preserved)
- */
+ Input:
+ AH := 4Fh Super VGA support
+ AL := 02h Set Super VGA video mode
+ BX := Video mode
+ D0-D8 := Mode number
+ D9-D10 := Reserved (must be 0)
+ D11 := 0 Use current default refresh rate
+ := 1 Use user specified CRTC values for refresh rate
+ D12-13 Reserved for VBE/AF (must be 0)
+ D14 := 0 Use windowed frame buffer model
+ := 1 Use linear/flat frame buffer model
+ D15 := 0 Clear video memory
+ := 1 Don't clear video memory
+ ES:DI := Pointer to VbeCRTCInfoBlock structure
+
+ Output: AX = Status
+ (All other registers are preserved)
+ */
pVbe->pInt10->num = 0x10;
pVbe->pInt10->ax = 0x4f02;
pVbe->pInt10->bx = mode;
if (block) {
- pVbe->pInt10->bx |= 1 << 11;
- memcpy(pVbe->memory, block, sizeof(VbeCRTCInfoBlock));
- pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base);
- pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
- } else
- pVbe->pInt10->bx &= ~(1 << 11);
+ pVbe->pInt10->bx |= 1 << 11;
+ memcpy(pVbe->memory, block, sizeof(VbeCRTCInfoBlock));
+ pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base);
+ pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
+ }
+ else
+ pVbe->pInt10->bx &= ~(1 << 11);
xf86ExecX86int10(pVbe->pInt10);
@@ -476,24 +490,24 @@ Bool
VBEGetVBEMode(vbeInfoPtr pVbe, int *mode)
{
/*
- Input:
- AH := 4Fh Super VGA support
- AL := 03h Return current video mode
-
- Output:
- AX := Status
- BX := Current video mode
- (All other registers are preserved)
- */
+ Input:
+ AH := 4Fh Super VGA support
+ AL := 03h Return current video mode
+
+ Output:
+ AX := Status
+ BX := Current video mode
+ (All other registers are preserved)
+ */
pVbe->pInt10->num = 0x10;
pVbe->pInt10->ax = 0x4f03;
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) == 0x4f) {
- *mode = R16(pVbe->pInt10->bx);
+ *mode = R16(pVbe->pInt10->bx);
- return TRUE;
+ return TRUE;
}
return FALSE;
@@ -507,16 +521,16 @@ VBEGetModeInfo(vbeInfoPtr pVbe, int mode)
memset(pVbe->memory, 0, sizeof(VbeModeInfoBlock));
/*
- Input:
- AH := 4Fh Super VGA support
- AL := 01h Return Super VGA mode information
- CX := Super VGA video mode
- (mode number must be one of those returned by Function 0)
- ES:DI := Pointer to buffer
-
- Output:
- AX := status
- (All other registers are preserved)
+ Input:
+ AH := 4Fh Super VGA support
+ AL := 01h Return Super VGA mode information
+ CX := Super VGA video mode
+ (mode number must be one of those returned by Function 0)
+ ES:DI := Pointer to buffer
+
+ Output:
+ AX := status
+ (All other registers are preserved)
*/
pVbe->pInt10->num = 0x10;
pVbe->pInt10->ax = 0x4f01;
@@ -525,116 +539,116 @@ VBEGetModeInfo(vbeInfoPtr pVbe, int mode)
pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return NULL;
+ return NULL;
block = malloc(sizeof(VbeModeInfoBlock));
if (block)
- memcpy(block, pVbe->memory, sizeof(*block));
+ memcpy(block, pVbe->memory, sizeof(*block));
return block;
}
void
-VBEFreeModeInfo(VbeModeInfoBlock *block)
+VBEFreeModeInfo(VbeModeInfoBlock * block)
{
free(block);
}
Bool
-VBESaveRestore(vbeInfoPtr pVbe, vbeSaveRestoreFunction function,
- pointer *memory, int *size, int *real_mode_pages)
+VBESaveRestore(vbeInfoPtr pVbe, vbeSaveRestoreFunction function,
+ pointer *memory, int *size, int *real_mode_pages)
{
/*
- Input:
- AH := 4Fh Super VGA support
- AL := 04h Save/restore Super VGA video state
- DL := 00h Return save/restore state buffer size
- CX := Requested states
- D0 = Save/restore video hardware state
- D1 = Save/restore video BIOS data state
- D2 = Save/restore video DAC state
- D3 = Save/restore Super VGA state
-
- Output:
- AX = Status
- BX = Number of 64-byte blocks to hold the state buffer
- (All other registers are preserved)
-
-
- Input:
- AH := 4Fh Super VGA support
- AL := 04h Save/restore Super VGA video state
- DL := 01h Save Super VGA video state
- CX := Requested states (see above)
- ES:BX := Pointer to buffer
-
- Output:
- AX := Status
- (All other registers are preserved)
-
-
- Input:
- AH := 4Fh Super VGA support
- AL := 04h Save/restore Super VGA video state
- DL := 02h Restore Super VGA video state
- CX := Requested states (see above)
- ES:BX := Pointer to buffer
-
- Output:
- AX := Status
- (All other registers are preserved)
+ Input:
+ AH := 4Fh Super VGA support
+ AL := 04h Save/restore Super VGA video state
+ DL := 00h Return save/restore state buffer size
+ CX := Requested states
+ D0 = Save/restore video hardware state
+ D1 = Save/restore video BIOS data state
+ D2 = Save/restore video DAC state
+ D3 = Save/restore Super VGA state
+
+ Output:
+ AX = Status
+ BX = Number of 64-byte blocks to hold the state buffer
+ (All other registers are preserved)
+
+ Input:
+ AH := 4Fh Super VGA support
+ AL := 04h Save/restore Super VGA video state
+ DL := 01h Save Super VGA video state
+ CX := Requested states (see above)
+ ES:BX := Pointer to buffer
+
+ Output:
+ AX := Status
+ (All other registers are preserved)
+
+ Input:
+ AH := 4Fh Super VGA support
+ AL := 04h Save/restore Super VGA video state
+ DL := 02h Restore Super VGA video state
+ CX := Requested states (see above)
+ ES:BX := Pointer to buffer
+
+ Output:
+ AX := Status
+ (All other registers are preserved)
*/
if ((pVbe->version & 0xff00) > 0x100) {
int screen = pVbe->pInt10->scrnIndex;
- if (function == MODE_QUERY ||
- (function == MODE_SAVE && !*memory)) {
- /* Query amount of memory to save state */
-
- pVbe->pInt10->num = 0x10;
- pVbe->pInt10->ax = 0x4f04;
- pVbe->pInt10->dx = 0;
- pVbe->pInt10->cx = 0x000f;
- xf86ExecX86int10(pVbe->pInt10);
- if (R16(pVbe->pInt10->ax) != 0x4f)
- return FALSE;
-
- if (function == MODE_SAVE) {
- int npages = (R16(pVbe->pInt10->bx) * 64) / 4096 + 1;
- if ((*memory = xf86Int10AllocPages(pVbe->pInt10, npages,
- real_mode_pages)) == NULL) {
- xf86DrvMsg(screen, X_ERROR,
- "Cannot allocate memory to save SVGA state.\n");
- return FALSE;
- }
- }
- *size = pVbe->pInt10->bx * 64;
- }
-
- /* Save/Restore Super VGA state */
- if (function != MODE_QUERY) {
-
- if (!*memory) return FALSE;
- pVbe->pInt10->num = 0x10;
- pVbe->pInt10->ax = 0x4f04;
- switch (function) {
- case MODE_SAVE:
- pVbe->pInt10->dx = 1;
- break;
- case MODE_RESTORE:
- pVbe->pInt10->dx = 2;
- break;
- case MODE_QUERY:
- return FALSE;
- }
- pVbe->pInt10->cx = 0x000f;
-
- pVbe->pInt10->es = SEG_ADDR(*real_mode_pages);
- pVbe->pInt10->bx = SEG_OFF(*real_mode_pages);
- xf86ExecX86int10(pVbe->pInt10);
- return (R16(pVbe->pInt10->ax) == 0x4f);
-
- }
+
+ if (function == MODE_QUERY || (function == MODE_SAVE && !*memory)) {
+ /* Query amount of memory to save state */
+
+ pVbe->pInt10->num = 0x10;
+ pVbe->pInt10->ax = 0x4f04;
+ pVbe->pInt10->dx = 0;
+ pVbe->pInt10->cx = 0x000f;
+ xf86ExecX86int10(pVbe->pInt10);
+ if (R16(pVbe->pInt10->ax) != 0x4f)
+ return FALSE;
+
+ if (function == MODE_SAVE) {
+ int npages = (R16(pVbe->pInt10->bx) * 64) / 4096 + 1;
+
+ if ((*memory = xf86Int10AllocPages(pVbe->pInt10, npages,
+ real_mode_pages)) == NULL) {
+ xf86DrvMsg(screen, X_ERROR,
+ "Cannot allocate memory to save SVGA state.\n");
+ return FALSE;
+ }
+ }
+ *size = pVbe->pInt10->bx * 64;
+ }
+
+ /* Save/Restore Super VGA state */
+ if (function != MODE_QUERY) {
+
+ if (!*memory)
+ return FALSE;
+ pVbe->pInt10->num = 0x10;
+ pVbe->pInt10->ax = 0x4f04;
+ switch (function) {
+ case MODE_SAVE:
+ pVbe->pInt10->dx = 1;
+ break;
+ case MODE_RESTORE:
+ pVbe->pInt10->dx = 2;
+ break;
+ case MODE_QUERY:
+ return FALSE;
+ }
+ pVbe->pInt10->cx = 0x000f;
+
+ pVbe->pInt10->es = SEG_ADDR(*real_mode_pages);
+ pVbe->pInt10->bx = SEG_OFF(*real_mode_pages);
+ xf86ExecX86int10(pVbe->pInt10);
+ return (R16(pVbe->pInt10->ax) == 0x4f);
+
+ }
}
return TRUE;
}
@@ -643,11 +657,11 @@ Bool
VBEBankSwitch(vbeInfoPtr pVbe, unsigned int iBank, int window)
{
/*
- Input:
- AH := 4Fh Super VGA support
- AL := 05h
+ Input:
+ AH := 4Fh Super VGA support
+ AL := 05h
- Output:
+ Output:
*/
pVbe->pInt10->num = 0x10;
pVbe->pInt10->ax = 0x4f05;
@@ -656,54 +670,54 @@ VBEBankSwitch(vbeInfoPtr pVbe, unsigned int iBank, int window)
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return FALSE;
+ return FALSE;
return TRUE;
}
Bool
VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe, vbeScanwidthCommand command,
- int width, int *pixels, int *bytes, int *max)
+ int width, int *pixels, int *bytes, int *max)
{
if (command < SCANWID_SET || command > SCANWID_GET_MAX)
- return FALSE;
+ return FALSE;
/*
- Input:
- AX := 4F06h VBE Set/Get Logical Scan Line Length
- BL := 00h Set Scan Line Length in Pixels
- := 01h Get Scan Line Length
- := 02h Set Scan Line Length in Bytes
- := 03h Get Maximum Scan Line Length
- CX := If BL=00h Desired Width in Pixels
- If BL=02h Desired Width in Bytes
- (Ignored for Get Functions)
-
- Output:
- AX := VBE Return Status
- BX := Bytes Per Scan Line
- CX := Actual Pixels Per Scan Line
- (truncated to nearest complete pixel)
- DX := Maximum Number of Scan Lines
+ Input:
+ AX := 4F06h VBE Set/Get Logical Scan Line Length
+ BL := 00h Set Scan Line Length in Pixels
+ := 01h Get Scan Line Length
+ := 02h Set Scan Line Length in Bytes
+ := 03h Get Maximum Scan Line Length
+ CX := If BL=00h Desired Width in Pixels
+ If BL=02h Desired Width in Bytes
+ (Ignored for Get Functions)
+
+ Output:
+ AX := VBE Return Status
+ BX := Bytes Per Scan Line
+ CX := Actual Pixels Per Scan Line
+ (truncated to nearest complete pixel)
+ DX := Maximum Number of Scan Lines
*/
pVbe->pInt10->num = 0x10;
pVbe->pInt10->ax = 0x4f06;
pVbe->pInt10->bx = command;
if (command == SCANWID_SET || command == SCANWID_SET_BYTES)
- pVbe->pInt10->cx = width;
+ pVbe->pInt10->cx = width;
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return FALSE;
+ return FALSE;
if (command == SCANWID_GET || command == SCANWID_GET_MAX) {
- if (pixels)
- *pixels = R16(pVbe->pInt10->cx);
- if (bytes)
- *bytes = R16(pVbe->pInt10->bx);
- if (max)
- *max = R16(pVbe->pInt10->dx);
+ if (pixels)
+ *pixels = R16(pVbe->pInt10->cx);
+ if (bytes)
+ *bytes = R16(pVbe->pInt10->bx);
+ if (max)
+ *max = R16(pVbe->pInt10->dx);
}
return TRUE;
@@ -720,7 +734,7 @@ VBESetDisplayStart(vbeInfoPtr pVbe, int x, int y, Bool wait_retrace)
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return FALSE;
+ return FALSE;
return TRUE;
}
@@ -734,7 +748,7 @@ VBEGetDisplayStart(vbeInfoPtr pVbe, int *x, int *y)
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return FALSE;
+ return FALSE;
*x = pVbe->pInt10->cx;
*y = pVbe->pInt10->dx;
@@ -746,82 +760,81 @@ int
VBESetGetDACPaletteFormat(vbeInfoPtr pVbe, int bits)
{
/*
- Input:
- AX := 4F08h VBE Set/Get Palette Format
- BL := 00h Set DAC Palette Format
- := 01h Get DAC Palette Format
- BH := Desired bits of color per primary
- (Set DAC Palette Format only)
-
- Output:
- AX := VBE Return Status
- BH := Current number of bits of color per primary
+ Input:
+ AX := 4F08h VBE Set/Get Palette Format
+ BL := 00h Set DAC Palette Format
+ := 01h Get DAC Palette Format
+ BH := Desired bits of color per primary
+ (Set DAC Palette Format only)
+
+ Output:
+ AX := VBE Return Status
+ BH := Current number of bits of color per primary
*/
pVbe->pInt10->num = 0x10;
pVbe->pInt10->ax = 0x4f08;
if (!bits)
- pVbe->pInt10->bx = 0x01;
- else
- pVbe->pInt10->bx = (bits & 0x00ff) << 8;
+ pVbe->pInt10->bx = 0x01;
+ else
+ pVbe->pInt10->bx = (bits & 0x00ff) << 8;
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return 0;
+ return 0;
return (bits != 0 ? bits : (pVbe->pInt10->bx >> 8) & 0x00ff);
}
CARD32 *
VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set, int first, int num,
- CARD32 *data, Bool secondary, Bool wait_retrace)
+ CARD32 *data, Bool secondary, Bool wait_retrace)
{
/*
- Input:
- (16-bit)
- AX := 4F09h VBE Load/Unload Palette Data
- BL := 00h Set Palette Data
- := 01h Get Palette Data
- := 02h Set Secondary Palette Data
- := 03h Get Secondary Palette Data
- := 80h Set Palette Data during Vertical Retrace
- CX := Number of palette registers to update (to a maximum of 256)
- DX := First of the palette registers to update (start)
- ES:DI := Table of palette values (see below for format)
-
- Output:
- AX := VBE Return Status
-
-
- Input:
- (32-bit)
- BL := 00h Set Palette Data
- := 80h Set Palette Data during Vertical Retrace
- CX := Number of palette registers to update (to a maximum of 256)
- DX := First of the palette registers to update (start)
- ES:EDI := Table of palette values (see below for format)
- DS := Selector for memory mapped registers
+ Input:
+ (16-bit)
+ AX := 4F09h VBE Load/Unload Palette Data
+ BL := 00h Set Palette Data
+ := 01h Get Palette Data
+ := 02h Set Secondary Palette Data
+ := 03h Get Secondary Palette Data
+ := 80h Set Palette Data during Vertical Retrace
+ CX := Number of palette registers to update (to a maximum of 256)
+ DX := First of the palette registers to update (start)
+ ES:DI := Table of palette values (see below for format)
+
+ Output:
+ AX := VBE Return Status
+
+ Input:
+ (32-bit)
+ BL := 00h Set Palette Data
+ := 80h Set Palette Data during Vertical Retrace
+ CX := Number of palette registers to update (to a maximum of 256)
+ DX := First of the palette registers to update (start)
+ ES:EDI := Table of palette values (see below for format)
+ DS := Selector for memory mapped registers
*/
pVbe->pInt10->num = 0x10;
pVbe->pInt10->ax = 0x4f09;
if (!secondary)
- pVbe->pInt10->bx = set && wait_retrace ? 0x80 : set ? 0 : 1;
+ pVbe->pInt10->bx = set && wait_retrace ? 0x80 : set ? 0 : 1;
else
- pVbe->pInt10->bx = set ? 2 : 3;
+ pVbe->pInt10->bx = set ? 2 : 3;
pVbe->pInt10->cx = num;
pVbe->pInt10->dx = first;
pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base);
pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
if (set)
- memcpy(pVbe->memory, data, num * sizeof(CARD32));
+ memcpy(pVbe->memory, data, num * sizeof(CARD32));
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return NULL;
+ return NULL;
if (set)
- return data;
+ return data;
data = malloc(num * sizeof(CARD32));
memcpy(data, pVbe->memory, num * sizeof(CARD32));
@@ -835,17 +848,17 @@ VBEGetVBEpmi(vbeInfoPtr pVbe)
VBEpmi *pmi;
/*
- Input:
- AH := 4Fh Super VGA support
- AL := 0Ah Protected Mode Interface
- BL := 00h Return Protected Mode Table
-
- Output:
- AX := Status
- ES := Real Mode Segment of Table
- DI := Offset of Table
- CX := Lenght of Table including protected mode code in bytes (for copying purposes)
- (All other registers are preserved)
+ Input:
+ AH := 4Fh Super VGA support
+ AL := 0Ah Protected Mode Interface
+ BL := 00h Return Protected Mode Table
+
+ Output:
+ AX := Status
+ ES := Real Mode Segment of Table
+ DI := Offset of Table
+ CX := Lenght of Table including protected mode code in bytes (for copying purposes)
+ (All other registers are preserved)
*/
pVbe->pInt10->num = 0x10;
@@ -855,7 +868,7 @@ VBEGetVBEpmi(vbeInfoPtr pVbe)
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return NULL;
+ return NULL;
pmi = malloc(sizeof(VBEpmi));
pmi->seg_tbl = R16(pVbe->pInt10->es);
@@ -867,49 +880,49 @@ VBEGetVBEpmi(vbeInfoPtr pVbe)
#if 0
vbeModeInfoPtr
-VBEBuildVbeModeList(vbeInfoPtr pVbe, VbeInfoBlock *vbe)
+VBEBuildVbeModeList(vbeInfoPtr pVbe, VbeInfoBlock * vbe)
{
vbeModeInfoPtr ModeList = NULL;
int i = 0;
+
while (vbe->VideoModePtr[i] != 0xffff) {
- vbeModeInfoPtr m;
- VbeModeInfoBlock *mode;
- int id = vbe->VideoModePtr[i++];
- int bpp;
+ vbeModeInfoPtr m;
+ VbeModeInfoBlock *mode;
+ int id = vbe->VideoModePtr[i++];
+ int bpp;
- if ((mode = VBEGetModeInfo(pVbe, id)) == NULL)
- continue;
+ if ((mode = VBEGetModeInfo(pVbe, id)) == NULL)
+ continue;
- bpp = mode->BitsPerPixel;
+ bpp = mode->BitsPerPixel;
- m = xnfcalloc(sizeof(vbeModeInfoRec),1);
- m->width = mode->XResolution;
- m->height = mode->YResolution;
- m->bpp = bpp;
- m->n = id;
- m->next = ModeList;
+ m = xnfcalloc(sizeof(vbeModeInfoRec), 1);
+ m->width = mode->XResolution;
+ m->height = mode->YResolution;
+ m->bpp = bpp;
+ m->n = id;
+ m->next = ModeList;
- xf86DrvMsgVerb(pVbe->pInt10->scrnIndex, X_PROBED, 3,
- "BIOS reported VESA mode 0x%x: x:%i y:%i bpp:%i\n",
- m->n, m->width, m->height, m->bpp);
+ xf86DrvMsgVerb(pVbe->pInt10->scrnIndex, X_PROBED, 3,
+ "BIOS reported VESA mode 0x%x: x:%i y:%i bpp:%i\n",
+ m->n, m->width, m->height, m->bpp);
- ModeList = m;
+ ModeList = m;
- VBEFreeModeInfo(mode);
+ VBEFreeModeInfo(mode);
}
return ModeList;
}
-unsigned short
+unsigned short
VBECalcVbeModeIndex(vbeModeInfoPtr m, DisplayModePtr mode, int bpp)
{
while (m) {
- if (bpp == m->bpp
- && mode->HDisplay == m->width
- && mode->VDisplay == m->height)
- return m->n;
- m = m->next;
+ if (bpp == m->bpp
+ && mode->HDisplay == m->width && mode->VDisplay == m->height)
+ return m->n;
+ m = m->next;
}
return 0;
}
@@ -917,37 +930,37 @@ VBECalcVbeModeIndex(vbeModeInfoPtr m, DisplayModePtr mode, int bpp)
void
VBEVesaSaveRestore(vbeInfoPtr pVbe, vbeSaveRestorePtr vbe_sr,
- vbeSaveRestoreFunction function)
+ vbeSaveRestoreFunction function)
{
Bool SaveSucc = FALSE;
if (VBE_VERSION_MAJOR(pVbe->version) > 1
- && (function == MODE_SAVE || vbe_sr->pstate)) {
- if (function == MODE_RESTORE)
- memcpy(vbe_sr->state, vbe_sr->pstate, vbe_sr->stateSize);
- ErrorF("VBESaveRestore\n");
- if ((VBESaveRestore(pVbe,function,
- (pointer)&vbe_sr->state,
- &vbe_sr->stateSize,&vbe_sr->statePage))) {
- if (function == MODE_SAVE) {
- SaveSucc = TRUE;
- vbe_sr->stateMode = -1; /* invalidate */
- /* don't rely on the memory not being touched */
- if (vbe_sr->pstate == NULL)
- vbe_sr->pstate = malloc(vbe_sr->stateSize);
- memcpy(vbe_sr->pstate, vbe_sr->state, vbe_sr->stateSize);
- }
- ErrorF("VBESaveRestore done with success\n");
- return;
- }
- ErrorF("VBESaveRestore done\n");
- }
-
+ && (function == MODE_SAVE || vbe_sr->pstate)) {
+ if (function == MODE_RESTORE)
+ memcpy(vbe_sr->state, vbe_sr->pstate, vbe_sr->stateSize);
+ ErrorF("VBESaveRestore\n");
+ if ((VBESaveRestore(pVbe, function,
+ (pointer) &vbe_sr->state,
+ &vbe_sr->stateSize, &vbe_sr->statePage))) {
+ if (function == MODE_SAVE) {
+ SaveSucc = TRUE;
+ vbe_sr->stateMode = -1; /* invalidate */
+ /* don't rely on the memory not being touched */
+ if (vbe_sr->pstate == NULL)
+ vbe_sr->pstate = malloc(vbe_sr->stateSize);
+ memcpy(vbe_sr->pstate, vbe_sr->state, vbe_sr->stateSize);
+ }
+ ErrorF("VBESaveRestore done with success\n");
+ return;
+ }
+ ErrorF("VBESaveRestore done\n");
+ }
+
if (function == MODE_SAVE && !SaveSucc)
- (void)VBEGetVBEMode(pVbe, &vbe_sr->stateMode);
-
+ (void) VBEGetVBEMode(pVbe, &vbe_sr->stateMode);
+
if (function == MODE_RESTORE && vbe_sr->stateMode != -1)
- VBESetVBEMode(pVbe, vbe_sr->stateMode, NULL);
+ VBESetVBEMode(pVbe, vbe_sr->stateMode, NULL);
}
@@ -955,15 +968,15 @@ int
VBEGetPixelClock(vbeInfoPtr pVbe, int mode, int clock)
{
/*
- Input:
- AX := 4F0Bh VBE Get Pixel Clock
- BL := 00h Get Pixel Clock
- ECX := pixel clock in units of Hz
- DX := mode number
-
- Output:
- AX := VBE Return Status
- ECX := Closest pixel clock
+ Input:
+ AX := 4F0Bh VBE Get Pixel Clock
+ BL := 00h Get Pixel Clock
+ ECX := pixel clock in units of Hz
+ DX := mode number
+
+ Output:
+ AX := VBE Return Status
+ ECX := Closest pixel clock
*/
pVbe->pInt10->num = 0x10;
@@ -974,7 +987,7 @@ VBEGetPixelClock(vbeInfoPtr pVbe, int mode, int clock)
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return 0;
+ return 0;
return pVbe->pInt10->cx;
}
@@ -983,13 +996,13 @@ Bool
VBEDPMSSet(vbeInfoPtr pVbe, int mode)
{
/*
- Input:
- AX := 4F10h DPMS
- BL := 01h Set Display Power State
- BH := requested power state
-
- Output:
- AX := VBE Return Status
+ Input:
+ AX := 4F10h DPMS
+ BL := 01h Set Display Power State
+ BH := requested power state
+
+ Output:
+ AX := VBE Return Status
*/
pVbe->pInt10->num = 0x10;
@@ -997,16 +1010,16 @@ VBEDPMSSet(vbeInfoPtr pVbe, int mode)
pVbe->pInt10->bx = 0x01;
switch (mode) {
case DPMSModeOn:
- break;
+ break;
case DPMSModeStandby:
- pVbe->pInt10->bx |= 0x100;
- break;
+ pVbe->pInt10->bx |= 0x100;
+ break;
case DPMSModeSuspend:
- pVbe->pInt10->bx |= 0x200;
- break;
+ pVbe->pInt10->bx |= 0x200;
+ break;
case DPMSModeOff:
- pVbe->pInt10->bx |= 0x400;
- break;
+ pVbe->pInt10->bx |= 0x400;
+ break;
}
xf86ExecX86int10(pVbe->pInt10);
return (R16(pVbe->pInt10->ax) == 0x4f);
@@ -1020,31 +1033,32 @@ VBEInterpretPanelID(int scrnIndex, struct vbePanelID *data)
const float PANEL_HZ = 60.0;
if (!data)
- return;
+ return;
xf86DrvMsg(scrnIndex, X_INFO, "PanelID returned panel resolution %dx%d\n",
- data->hsize, data->vsize);
+ data->hsize, data->vsize);
if (pScrn->monitor->nHsync || pScrn->monitor->nVrefresh)
- return;
+ return;
if (data->hsize < 320 || data->vsize < 240) {
- xf86DrvMsg(scrnIndex, X_INFO, "...which I refuse to believe\n");
- return;
+ xf86DrvMsg(scrnIndex, X_INFO, "...which I refuse to believe\n");
+ return;
}
mode = xf86CVTMode(data->hsize, data->vsize, PANEL_HZ, 1, 0);
pScrn->monitor->nHsync = 1;
pScrn->monitor->hsync[0].lo = 29.37;
- pScrn->monitor->hsync[0].hi = (float)mode->Clock / (float)mode->HTotal;
+ pScrn->monitor->hsync[0].hi = (float) mode->Clock / (float) mode->HTotal;
pScrn->monitor->nVrefresh = 1;
pScrn->monitor->vrefresh[0].lo = 56.0;
pScrn->monitor->vrefresh[0].hi =
- (float)mode->Clock*1000.0 / (float)mode->HTotal / (float)mode->VTotal;
+ (float) mode->Clock * 1000.0 / (float) mode->HTotal /
+ (float) mode->VTotal;
if (pScrn->monitor->vrefresh[0].hi < 59.47)
- pScrn->monitor->vrefresh[0].hi = 59.47;
+ pScrn->monitor->vrefresh[0].hi = 59.47;
free(mode);
}
@@ -1068,25 +1082,27 @@ VBEReadPanelID(vbeInfoPtr pVbe)
xf86ExecX86int10(pVbe->pInt10);
if ((pVbe->pInt10->ax & 0xff) != 0x4f) {
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE PanelID invalid\n");
- goto error;
+ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE PanelID invalid\n");
+ goto error;
}
switch (pVbe->pInt10->ax & 0xff00) {
case 0x0:
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE PanelID read successfully\n");
- tmp = xnfalloc(32);
- memcpy(tmp, page, 32);
- break;
+ xf86DrvMsgVerb(screen, X_INFO, 3,
+ "VESA VBE PanelID read successfully\n");
+ tmp = xnfalloc(32);
+ memcpy(tmp, page, 32);
+ break;
case 0x100:
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE PanelID read failed\n");
- break;
+ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE PanelID read failed\n");
+ break;
default:
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE PanelID unknown failure %i\n",
- pVbe->pInt10->ax & 0xff00);
- break;
+ xf86DrvMsgVerb(screen, X_INFO, 3,
+ "VESA VBE PanelID unknown failure %i\n",
+ pVbe->pInt10->ax & 0xff00);
+ break;
}
-error:
+ error:
return tmp;
}
diff --git a/xorg-server/hw/xfree86/vbe/vbe.h b/xorg-server/hw/xfree86/vbe/vbe.h
index 5bb163df8..81be0ff40 100644
--- a/xorg-server/hw/xfree86/vbe/vbe.h
+++ b/xorg-server/hw/xfree86/vbe/vbe.h
@@ -1,341 +1,357 @@
-
-/*
- * XFree86 vbe module
- * Copyright 2000 Egbert Eich
- *
- * The mode query/save/set/restore functions from the vesa driver
- * have been moved here.
- * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
- * Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
- */
-
-#ifndef _VBE_H
-#define _VBE_H
-#include "xf86int10.h"
-#include "xf86DDC.h"
-
-typedef enum {
- DDC_UNCHECKED,
- DDC_NONE,
- DDC_1,
- DDC_2,
- DDC_1_2
-}
-ddc_lvl;
-
-typedef struct {
- xf86Int10InfoPtr pInt10;
- int version;
- pointer memory;
- int real_mode_base;
- int num_pages;
- Bool init_int10;
- ddc_lvl ddc;
- Bool ddc_blank;
-} vbeInfoRec, *vbeInfoPtr;
-
-#define VBE_VERSION_MAJOR(x) *((CARD8*)(&x) + 1)
-#define VBE_VERSION_MINOR(x) (CARD8)(x)
-
-extern _X_EXPORT vbeInfoPtr VBEInit(xf86Int10InfoPtr pInt, int entityIndex);
-extern _X_EXPORT vbeInfoPtr VBEExtendedInit(xf86Int10InfoPtr pInt, int entityIndex, int Flags);
-extern _X_EXPORT void vbeFree(vbeInfoPtr pVbe);
-extern _X_EXPORT xf86MonPtr vbeDoEDID(vbeInfoPtr pVbe, pointer pDDCModule);
-
-#pragma pack(1)
-
-typedef struct vbeControllerInfoBlock {
- CARD8 VbeSignature[4];
- CARD16 VbeVersion;
- CARD32 OemStringPtr;
- CARD8 Capabilities[4];
- CARD32 VideoModePtr;
- CARD16 TotalMem;
- CARD16 OemSoftwareRev;
- CARD32 OemVendorNamePtr;
- CARD32 OemProductNamePtr;
- CARD32 OemProductRevPtr;
- CARD8 Scratch[222];
- CARD8 OemData[256];
-} vbeControllerInfoRec, *vbeControllerInfoPtr;
-
-#if defined(__GNUC__) || defined(__USLC__) || defined(__SUNPRO_C)
-#pragma pack() /* All GCC versions recognise this syntax */
-#else
-#pragma pack(0)
-#endif
-
-#if !( defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) )
-#define __attribute__(a)
-#endif
-
-typedef struct _VbeInfoBlock VbeInfoBlock;
-typedef struct _VbeModeInfoBlock VbeModeInfoBlock;
-typedef struct _VbeCRTCInfoBlock VbeCRTCInfoBlock;
-
-/*
- * INT 0
- */
-
-struct _VbeInfoBlock {
- /* VESA 1.2 fields */
- CARD8 VESASignature[4]; /* VESA */
- CARD16 VESAVersion; /* Higher byte major, lower byte minor */
- /*CARD32*/char *OEMStringPtr; /* Pointer to OEM string */
- CARD8 Capabilities[4]; /* Capabilities of the video environment */
-
- /*CARD32*/CARD16 *VideoModePtr; /* pointer to supported Super VGA modes */
-
- CARD16 TotalMemory; /* Number of 64kb memory blocks on board */
- /* if not VESA 2, 236 scratch bytes follow (256 bytes total size) */
-
- /* VESA 2 fields */
- CARD16 OemSoftwareRev; /* VBE implementation Software revision */
- /*CARD32*/char *OemVendorNamePtr; /* Pointer to Vendor Name String */
- /*CARD32*/char *OemProductNamePtr; /* Pointer to Product Name String */
- /*CARD32*/char *OemProductRevPtr; /* Pointer to Product Revision String */
- CARD8 Reserved[222]; /* Reserved for VBE implementation */
- CARD8 OemData[256]; /* Data Area for OEM Strings */
-} __attribute__((packed));
-
-/* Return Super VGA Information */
-extern _X_EXPORT VbeInfoBlock *VBEGetVBEInfo(vbeInfoPtr pVbe);
-extern _X_EXPORT void VBEFreeVBEInfo(VbeInfoBlock *block);
-
-/*
- * INT 1
- */
-
-struct _VbeModeInfoBlock {
- CARD16 ModeAttributes; /* mode attributes */
- CARD8 WinAAttributes; /* window A attributes */
- CARD8 WinBAttributes; /* window B attributes */
- CARD16 WinGranularity; /* window granularity */
- CARD16 WinSize; /* window size */
- CARD16 WinASegment; /* window A start segment */
- CARD16 WinBSegment; /* window B start segment */
- CARD32 WinFuncPtr; /* real mode pointer to window function */
- CARD16 BytesPerScanline; /* bytes per scanline */
-
- /* Mandatory information for VBE 1.2 and above */
- CARD16 XResolution; /* horizontal resolution in pixels or characters */
- CARD16 YResolution; /* vertical resolution in pixels or characters */
- CARD8 XCharSize; /* character cell width in pixels */
- CARD8 YCharSize; /* character cell height in pixels */
- CARD8 NumberOfPlanes; /* number of memory planes */
- CARD8 BitsPerPixel; /* bits per pixel */
- CARD8 NumberOfBanks; /* number of banks */
- CARD8 MemoryModel; /* memory model type */
- CARD8 BankSize; /* bank size in KB */
- CARD8 NumberOfImages; /* number of images */
- CARD8 Reserved; /* 1 */ /* reserved for page function */
-
- /* Direct color fields (required for direct/6 and YUV/7 memory models) */
- CARD8 RedMaskSize; /* size of direct color red mask in bits */
- CARD8 RedFieldPosition; /* bit position of lsb of red mask */
- CARD8 GreenMaskSize; /* size of direct color green mask in bits */
- CARD8 GreenFieldPosition; /* bit position of lsb of green mask */
- CARD8 BlueMaskSize; /* size of direct color blue mask in bits */
- CARD8 BlueFieldPosition; /* bit position of lsb of blue mask */
- CARD8 RsvdMaskSize; /* size of direct color reserved mask in bits */
- CARD8 RsvdFieldPosition; /* bit position of lsb of reserved mask */
- CARD8 DirectColorModeInfo; /* direct color mode attributes */
-
- /* Mandatory information for VBE 2.0 and above */
- CARD32 PhysBasePtr; /* physical address for flat memory frame buffer */
- CARD32 Reserved32; /* 0 */ /* Reserved - always set to 0 */
- CARD16 Reserved16; /* 0 */ /* Reserved - always set to 0 */
-
- /* Mandatory information for VBE 3.0 and above */
- CARD16 LinBytesPerScanLine; /* bytes per scan line for linear modes */
- CARD8 BnkNumberOfImagePages; /* number of images for banked modes */
- CARD8 LinNumberOfImagePages; /* number of images for linear modes */
- CARD8 LinRedMaskSize; /* size of direct color red mask (linear modes) */
- CARD8 LinRedFieldPosition; /* bit position of lsb of red mask (linear modes) */
- CARD8 LinGreenMaskSize; /* size of direct color green mask (linear modes) */
- CARD8 LinGreenFieldPosition; /* bit position of lsb of green mask (linear modes) */
- CARD8 LinBlueMaskSize; /* size of direct color blue mask (linear modes) */
- CARD8 LinBlueFieldPosition; /* bit position of lsb of blue mask (linear modes) */
- CARD8 LinRsvdMaskSize; /* size of direct color reserved mask (linear modes) */
- CARD8 LinRsvdFieldPosition; /* bit position of lsb of reserved mask (linear modes) */
- CARD32 MaxPixelClock; /* maximum pixel clock (in Hz) for graphics mode */
- CARD8 Reserved2[189]; /* remainder of VbeModeInfoBlock */
-} __attribute__((packed));
-
-/* Return VBE Mode Information */
-extern _X_EXPORT VbeModeInfoBlock *VBEGetModeInfo(vbeInfoPtr pVbe, int mode);
-extern _X_EXPORT void VBEFreeModeInfo(VbeModeInfoBlock *block);
-
-/*
- * INT2
- */
-
-#define CRTC_DBLSCAN (1<<0)
-#define CRTC_INTERLACE (1<<1)
-#define CRTC_NHSYNC (1<<2)
-#define CRTC_NVSYNC (1<<3)
-
-struct _VbeCRTCInfoBlock {
- CARD16 HorizontalTotal; /* Horizontal total in pixels */
- CARD16 HorizontalSyncStart; /* Horizontal sync start in pixels */
- CARD16 HorizontalSyncEnd; /* Horizontal sync end in pixels */
- CARD16 VerticalTotal; /* Vertical total in lines */
- CARD16 VerticalSyncStart; /* Vertical sync start in lines */
- CARD16 VerticalSyncEnd; /* Vertical sync end in lines */
- CARD8 Flags; /* Flags (Interlaced, Double Scan etc) */
- CARD32 PixelClock; /* Pixel clock in units of Hz */
- CARD16 RefreshRate; /* Refresh rate in units of 0.01 Hz */
- CARD8 Reserved[40]; /* remainder of ModeInfoBlock */
-} __attribute__((packed));
-/* VbeCRTCInfoBlock is in the VESA 3.0 specs */
-
-extern _X_EXPORT Bool VBESetVBEMode(vbeInfoPtr pVbe, int mode, VbeCRTCInfoBlock *crtc);
-
-/*
- * INT 3
- */
-
-extern _X_EXPORT Bool VBEGetVBEMode(vbeInfoPtr pVbe, int *mode);
-
-/*
- * INT 4
- */
-
-/* Save/Restore Super VGA video state */
-/* function values are (values stored in VESAPtr):
- * 0 := query & allocate amount of memory to save state
- * 1 := save state
- * 2 := restore state
- *
- * function 0 called automatically if function 1 called without
- * a previous call to function 0.
- */
-
-typedef enum {
- MODE_QUERY,
- MODE_SAVE,
- MODE_RESTORE
-} vbeSaveRestoreFunction;
-
-extern _X_EXPORT Bool
-VBESaveRestore(vbeInfoPtr pVbe, vbeSaveRestoreFunction fuction,
- pointer *memory, int *size, int *real_mode_pages);
-
-/*
- * INT 5
- */
-
-extern _X_EXPORT Bool
-VBEBankSwitch(vbeInfoPtr pVbe, unsigned int iBank, int window);
-
-/*
- * INT 6
- */
-
-typedef enum {
- SCANWID_SET,
- SCANWID_GET,
- SCANWID_SET_BYTES,
- SCANWID_GET_MAX
-} vbeScanwidthCommand;
-
-#define VBESetLogicalScanline(pVbe, width) \
- VBESetGetLogicalScanlineLength(pVbe, SCANWID_SET, width, \
- NULL, NULL, NULL)
-#define VBESetLogicalScanlineBytes(pVbe, width) \
- VBESetGetLogicalScanlineLength(pVbe, SCANWID_SET_BYTES, width, \
- NULL, NULL, NULL)
-#define VBEGetLogicalScanline(pVbe, pixels, bytes, max) \
- VBESetGetLogicalScanlineLength(pVbe, SCANWID_GET, 0, \
- pixels, bytes, max)
-#define VBEGetMaxLogicalScanline(pVbe, pixels, bytes, max) \
- VBESetGetLogicalScanlineLength(pVbe, SCANWID_GET_MAX, 0, \
- pixels, bytes, max)
-extern _X_EXPORT Bool VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe,
- vbeScanwidthCommand command, int width,
- int *pixels, int *bytes, int *max);
-
-/*
- * INT 7
- */
-
-/* 16 bit code */
-extern _X_EXPORT Bool VBESetDisplayStart(vbeInfoPtr pVbe, int x, int y, Bool wait_retrace);
-extern _X_EXPORT Bool VBEGetDisplayStart(vbeInfoPtr pVbe, int *x, int *y);
-
-/*
- * INT 8
- */
-
-/* if bits is 0, then it is a GET */
-extern _X_EXPORT int VBESetGetDACPaletteFormat(vbeInfoPtr pVbe, int bits);
-
-/*
- * INT 9
- */
-
-/*
- * If getting a palette, the data argument is not used. It will return
- * the data.
- * If setting a palette, it will return the pointer received on success,
- * NULL on failure.
- */
-extern _X_EXPORT CARD32 *VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set, int first, int num,
- CARD32 *data, Bool secondary, Bool wait_retrace);
-#define VBEFreePaletteData(data) free(data)
-
-/*
- * INT A
- */
-
-typedef struct _VBEpmi {
- int seg_tbl;
- int tbl_off;
- int tbl_len;
-} VBEpmi;
-
-extern _X_EXPORT VBEpmi *VBEGetVBEpmi(vbeInfoPtr pVbe);
-#define VESAFreeVBEpmi(pmi) free(pmi)
-
-/* high level helper functions */
-
-typedef struct _vbeModeInfoRec {
- int width;
- int height;
- int bpp;
- int n;
- struct _vbeModeInfoRec *next;
-} vbeModeInfoRec, *vbeModeInfoPtr;
-
-typedef struct {
- CARD8 *state;
- CARD8 *pstate;
- int statePage;
- int stateSize;
- int stateMode;
-} vbeSaveRestoreRec, *vbeSaveRestorePtr;
-
-extern _X_EXPORT void
-VBEVesaSaveRestore(vbeInfoPtr pVbe, vbeSaveRestorePtr vbe_sr,
- vbeSaveRestoreFunction function);
-
-extern _X_EXPORT int VBEGetPixelClock(vbeInfoPtr pVbe, int mode, int Clock);
-extern _X_EXPORT Bool VBEDPMSSet(vbeInfoPtr pVbe, int mode);
-
-struct vbePanelID {
- short hsize;
- short vsize;
- short fptype;
- char redbpp;
- char greenbpp;
- char bluebpp;
- char reservedbpp;
- int reserved_offscreen_mem_size;
- int reserved_offscreen_mem_pointer;
- char reserved[14];
-};
-
-extern _X_EXPORT void VBEInterpretPanelID(int scrnIndex, struct vbePanelID *data);
-extern _X_EXPORT struct vbePanelID *VBEReadPanelID(vbeInfoPtr pVbe);
-
-#endif
+
+/*
+ * XFree86 vbe module
+ * Copyright 2000 Egbert Eich
+ *
+ * The mode query/save/set/restore functions from the vesa driver
+ * have been moved here.
+ * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
+ * Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
+ */
+
+#ifndef _VBE_H
+#define _VBE_H
+#include "xf86int10.h"
+#include "xf86DDC.h"
+
+typedef enum {
+ DDC_UNCHECKED,
+ DDC_NONE,
+ DDC_1,
+ DDC_2,
+ DDC_1_2
+} ddc_lvl;
+
+typedef struct {
+ xf86Int10InfoPtr pInt10;
+ int version;
+ pointer memory;
+ int real_mode_base;
+ int num_pages;
+ Bool init_int10;
+ ddc_lvl ddc;
+ Bool ddc_blank;
+} vbeInfoRec, *vbeInfoPtr;
+
+#define VBE_VERSION_MAJOR(x) *((CARD8*)(&x) + 1)
+#define VBE_VERSION_MINOR(x) (CARD8)(x)
+
+extern _X_EXPORT vbeInfoPtr VBEInit(xf86Int10InfoPtr pInt, int entityIndex);
+extern _X_EXPORT vbeInfoPtr VBEExtendedInit(xf86Int10InfoPtr pInt,
+ int entityIndex, int Flags);
+extern _X_EXPORT void vbeFree(vbeInfoPtr pVbe);
+extern _X_EXPORT xf86MonPtr vbeDoEDID(vbeInfoPtr pVbe, pointer pDDCModule);
+
+#pragma pack(1)
+
+typedef struct vbeControllerInfoBlock {
+ CARD8 VbeSignature[4];
+ CARD16 VbeVersion;
+ CARD32 OemStringPtr;
+ CARD8 Capabilities[4];
+ CARD32 VideoModePtr;
+ CARD16 TotalMem;
+ CARD16 OemSoftwareRev;
+ CARD32 OemVendorNamePtr;
+ CARD32 OemProductNamePtr;
+ CARD32 OemProductRevPtr;
+ CARD8 Scratch[222];
+ CARD8 OemData[256];
+} vbeControllerInfoRec, *vbeControllerInfoPtr;
+
+#if defined(__GNUC__) || defined(__USLC__) || defined(__SUNPRO_C)
+#pragma pack() /* All GCC versions recognise this syntax */
+#else
+#pragma pack(0)
+#endif
+
+#if !( defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) )
+#define __attribute__(a)
+#endif
+
+typedef struct _VbeInfoBlock VbeInfoBlock;
+typedef struct _VbeModeInfoBlock VbeModeInfoBlock;
+typedef struct _VbeCRTCInfoBlock VbeCRTCInfoBlock;
+
+/*
+ * INT 0
+ */
+
+struct _VbeInfoBlock {
+ /* VESA 1.2 fields */
+ CARD8 VESASignature[4]; /* VESA */
+ CARD16 VESAVersion; /* Higher byte major, lower byte minor */
+ /*CARD32 */ char *OEMStringPtr;
+ /* Pointer to OEM string */
+ CARD8 Capabilities[4]; /* Capabilities of the video environment */
+
+ /*CARD32 */ CARD16 *VideoModePtr;
+ /* pointer to supported Super VGA modes */
+
+ CARD16 TotalMemory; /* Number of 64kb memory blocks on board */
+ /* if not VESA 2, 236 scratch bytes follow (256 bytes total size) */
+
+ /* VESA 2 fields */
+ CARD16 OemSoftwareRev; /* VBE implementation Software revision */
+ /*CARD32 */ char *OemVendorNamePtr;
+ /* Pointer to Vendor Name String */
+ /*CARD32 */ char *OemProductNamePtr;
+ /* Pointer to Product Name String */
+ /*CARD32 */ char *OemProductRevPtr;
+ /* Pointer to Product Revision String */
+ CARD8 Reserved[222]; /* Reserved for VBE implementation */
+ CARD8 OemData[256]; /* Data Area for OEM Strings */
+} __attribute__ ((packed));
+
+/* Return Super VGA Information */
+extern _X_EXPORT VbeInfoBlock *VBEGetVBEInfo(vbeInfoPtr pVbe);
+extern _X_EXPORT void VBEFreeVBEInfo(VbeInfoBlock * block);
+
+/*
+ * INT 1
+ */
+
+struct _VbeModeInfoBlock {
+ CARD16 ModeAttributes; /* mode attributes */
+ CARD8 WinAAttributes; /* window A attributes */
+ CARD8 WinBAttributes; /* window B attributes */
+ CARD16 WinGranularity; /* window granularity */
+ CARD16 WinSize; /* window size */
+ CARD16 WinASegment; /* window A start segment */
+ CARD16 WinBSegment; /* window B start segment */
+ CARD32 WinFuncPtr; /* real mode pointer to window function */
+ CARD16 BytesPerScanline; /* bytes per scanline */
+
+ /* Mandatory information for VBE 1.2 and above */
+ CARD16 XResolution; /* horizontal resolution in pixels or characters */
+ CARD16 YResolution; /* vertical resolution in pixels or characters */
+ CARD8 XCharSize; /* character cell width in pixels */
+ CARD8 YCharSize; /* character cell height in pixels */
+ CARD8 NumberOfPlanes; /* number of memory planes */
+ CARD8 BitsPerPixel; /* bits per pixel */
+ CARD8 NumberOfBanks; /* number of banks */
+ CARD8 MemoryModel; /* memory model type */
+ CARD8 BankSize; /* bank size in KB */
+ CARD8 NumberOfImages; /* number of images */
+ CARD8 Reserved; /* 1 *//* reserved for page function */
+
+ /* Direct color fields (required for direct/6 and YUV/7 memory models) */
+ CARD8 RedMaskSize; /* size of direct color red mask in bits */
+ CARD8 RedFieldPosition; /* bit position of lsb of red mask */
+ CARD8 GreenMaskSize; /* size of direct color green mask in bits */
+ CARD8 GreenFieldPosition; /* bit position of lsb of green mask */
+ CARD8 BlueMaskSize; /* size of direct color blue mask in bits */
+ CARD8 BlueFieldPosition; /* bit position of lsb of blue mask */
+ CARD8 RsvdMaskSize; /* size of direct color reserved mask in bits */
+ CARD8 RsvdFieldPosition; /* bit position of lsb of reserved mask */
+ CARD8 DirectColorModeInfo; /* direct color mode attributes */
+
+ /* Mandatory information for VBE 2.0 and above */
+ CARD32 PhysBasePtr; /* physical address for flat memory frame buffer */
+ CARD32 Reserved32; /* 0 *//* Reserved - always set to 0 */
+ CARD16 Reserved16; /* 0 *//* Reserved - always set to 0 */
+
+ /* Mandatory information for VBE 3.0 and above */
+ CARD16 LinBytesPerScanLine; /* bytes per scan line for linear modes */
+ CARD8 BnkNumberOfImagePages; /* number of images for banked modes */
+ CARD8 LinNumberOfImagePages; /* number of images for linear modes */
+ CARD8 LinRedMaskSize; /* size of direct color red mask (linear modes) */
+ CARD8 LinRedFieldPosition; /* bit position of lsb of red mask (linear modes) */
+ CARD8 LinGreenMaskSize; /* size of direct color green mask (linear modes) */
+ CARD8 LinGreenFieldPosition; /* bit position of lsb of green mask (linear modes) */
+ CARD8 LinBlueMaskSize; /* size of direct color blue mask (linear modes) */
+ CARD8 LinBlueFieldPosition; /* bit position of lsb of blue mask (linear modes) */
+ CARD8 LinRsvdMaskSize; /* size of direct color reserved mask (linear modes) */
+ CARD8 LinRsvdFieldPosition; /* bit position of lsb of reserved mask (linear modes) */
+ CARD32 MaxPixelClock; /* maximum pixel clock (in Hz) for graphics mode */
+ CARD8 Reserved2[189]; /* remainder of VbeModeInfoBlock */
+} __attribute__ ((packed));
+
+/* Return VBE Mode Information */
+extern _X_EXPORT VbeModeInfoBlock *VBEGetModeInfo(vbeInfoPtr pVbe, int mode);
+extern _X_EXPORT void VBEFreeModeInfo(VbeModeInfoBlock * block);
+
+/*
+ * INT2
+ */
+
+#define CRTC_DBLSCAN (1<<0)
+#define CRTC_INTERLACE (1<<1)
+#define CRTC_NHSYNC (1<<2)
+#define CRTC_NVSYNC (1<<3)
+
+struct _VbeCRTCInfoBlock {
+ CARD16 HorizontalTotal; /* Horizontal total in pixels */
+ CARD16 HorizontalSyncStart; /* Horizontal sync start in pixels */
+ CARD16 HorizontalSyncEnd; /* Horizontal sync end in pixels */
+ CARD16 VerticalTotal; /* Vertical total in lines */
+ CARD16 VerticalSyncStart; /* Vertical sync start in lines */
+ CARD16 VerticalSyncEnd; /* Vertical sync end in lines */
+ CARD8 Flags; /* Flags (Interlaced, Double Scan etc) */
+ CARD32 PixelClock; /* Pixel clock in units of Hz */
+ CARD16 RefreshRate; /* Refresh rate in units of 0.01 Hz */
+ CARD8 Reserved[40]; /* remainder of ModeInfoBlock */
+} __attribute__ ((packed));
+
+/* VbeCRTCInfoBlock is in the VESA 3.0 specs */
+
+extern _X_EXPORT Bool VBESetVBEMode(vbeInfoPtr pVbe, int mode,
+ VbeCRTCInfoBlock * crtc);
+
+/*
+ * INT 3
+ */
+
+extern _X_EXPORT Bool VBEGetVBEMode(vbeInfoPtr pVbe, int *mode);
+
+/*
+ * INT 4
+ */
+
+/* Save/Restore Super VGA video state */
+/* function values are (values stored in VESAPtr):
+ * 0 := query & allocate amount of memory to save state
+ * 1 := save state
+ * 2 := restore state
+ *
+ * function 0 called automatically if function 1 called without
+ * a previous call to function 0.
+ */
+
+typedef enum {
+ MODE_QUERY,
+ MODE_SAVE,
+ MODE_RESTORE
+} vbeSaveRestoreFunction;
+
+extern _X_EXPORT Bool
+
+VBESaveRestore(vbeInfoPtr pVbe, vbeSaveRestoreFunction fuction,
+ pointer *memory, int *size, int *real_mode_pages);
+
+/*
+ * INT 5
+ */
+
+extern _X_EXPORT Bool
+ VBEBankSwitch(vbeInfoPtr pVbe, unsigned int iBank, int window);
+
+/*
+ * INT 6
+ */
+
+typedef enum {
+ SCANWID_SET,
+ SCANWID_GET,
+ SCANWID_SET_BYTES,
+ SCANWID_GET_MAX
+} vbeScanwidthCommand;
+
+#define VBESetLogicalScanline(pVbe, width) \
+ VBESetGetLogicalScanlineLength(pVbe, SCANWID_SET, width, \
+ NULL, NULL, NULL)
+#define VBESetLogicalScanlineBytes(pVbe, width) \
+ VBESetGetLogicalScanlineLength(pVbe, SCANWID_SET_BYTES, width, \
+ NULL, NULL, NULL)
+#define VBEGetLogicalScanline(pVbe, pixels, bytes, max) \
+ VBESetGetLogicalScanlineLength(pVbe, SCANWID_GET, 0, \
+ pixels, bytes, max)
+#define VBEGetMaxLogicalScanline(pVbe, pixels, bytes, max) \
+ VBESetGetLogicalScanlineLength(pVbe, SCANWID_GET_MAX, 0, \
+ pixels, bytes, max)
+extern _X_EXPORT Bool VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe,
+ vbeScanwidthCommand
+ command, int width,
+ int *pixels, int *bytes,
+ int *max);
+
+/*
+ * INT 7
+ */
+
+/* 16 bit code */
+extern _X_EXPORT Bool VBESetDisplayStart(vbeInfoPtr pVbe, int x, int y,
+ Bool wait_retrace);
+extern _X_EXPORT Bool VBEGetDisplayStart(vbeInfoPtr pVbe, int *x, int *y);
+
+/*
+ * INT 8
+ */
+
+/* if bits is 0, then it is a GET */
+extern _X_EXPORT int VBESetGetDACPaletteFormat(vbeInfoPtr pVbe, int bits);
+
+/*
+ * INT 9
+ */
+
+/*
+ * If getting a palette, the data argument is not used. It will return
+ * the data.
+ * If setting a palette, it will return the pointer received on success,
+ * NULL on failure.
+ */
+extern _X_EXPORT CARD32 *VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set,
+ int first, int num, CARD32 *data,
+ Bool secondary,
+ Bool wait_retrace);
+#define VBEFreePaletteData(data) free(data)
+
+/*
+ * INT A
+ */
+
+typedef struct _VBEpmi {
+ int seg_tbl;
+ int tbl_off;
+ int tbl_len;
+} VBEpmi;
+
+extern _X_EXPORT VBEpmi *VBEGetVBEpmi(vbeInfoPtr pVbe);
+
+#define VESAFreeVBEpmi(pmi) free(pmi)
+
+/* high level helper functions */
+
+typedef struct _vbeModeInfoRec {
+ int width;
+ int height;
+ int bpp;
+ int n;
+ struct _vbeModeInfoRec *next;
+} vbeModeInfoRec, *vbeModeInfoPtr;
+
+typedef struct {
+ CARD8 *state;
+ CARD8 *pstate;
+ int statePage;
+ int stateSize;
+ int stateMode;
+} vbeSaveRestoreRec, *vbeSaveRestorePtr;
+
+extern _X_EXPORT void
+
+VBEVesaSaveRestore(vbeInfoPtr pVbe, vbeSaveRestorePtr vbe_sr,
+ vbeSaveRestoreFunction function);
+
+extern _X_EXPORT int VBEGetPixelClock(vbeInfoPtr pVbe, int mode, int Clock);
+extern _X_EXPORT Bool VBEDPMSSet(vbeInfoPtr pVbe, int mode);
+
+struct vbePanelID {
+ short hsize;
+ short vsize;
+ short fptype;
+ char redbpp;
+ char greenbpp;
+ char bluebpp;
+ char reservedbpp;
+ int reserved_offscreen_mem_size;
+ int reserved_offscreen_mem_pointer;
+ char reserved[14];
+};
+
+extern _X_EXPORT void VBEInterpretPanelID(int scrnIndex,
+ struct vbePanelID *data);
+extern _X_EXPORT struct vbePanelID *VBEReadPanelID(vbeInfoPtr pVbe);
+
+#endif
diff --git a/xorg-server/hw/xfree86/vbe/vbeModes.c b/xorg-server/hw/xfree86/vbe/vbeModes.c
index 9ccbe6b51..415167d0e 100644
--- a/xorg-server/hw/xfree86/vbe/vbeModes.c
+++ b/xorg-server/hw/xfree86/vbe/vbeModes.c
@@ -1,451 +1,451 @@
-#define DEBUG_VERB 2
-/*
- * Copyright © 2002 David Dawes
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the author(s) shall
- * not be used in advertising or otherwise to promote the sale, use or other
- * dealings in this Software without prior written authorization from
- * the author(s).
- *
- * Authors: David Dawes <dawes@xfree86.org>
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
-#include "xf86.h"
-#include "vbe.h"
-#include "vbeModes.h"
-
-static int
-GetDepthFlag(vbeInfoPtr pVbe, int id)
-{
- VbeModeInfoBlock *mode;
- int bpp;
-
- if ((mode = VBEGetModeInfo(pVbe, id)) == NULL)
- return 0;
-
- if (VBE_MODE_USABLE(mode, 0)) {
- int depth;
-
- if (VBE_MODE_COLOR(mode)) {
- depth = mode->RedMaskSize + mode->GreenMaskSize +
- mode->BlueMaskSize;
- } else {
- depth = 1;
- }
- bpp = mode->BitsPerPixel;
- VBEFreeModeInfo(mode);
- mode = NULL;
- switch (depth) {
- case 1:
- return V_DEPTH_1;
- case 4:
- return V_DEPTH_4;
- case 8:
- return V_DEPTH_8;
- case 15:
- return V_DEPTH_15;
- case 16:
- return V_DEPTH_16;
- case 24:
- switch (bpp) {
- case 24:
- return V_DEPTH_24_24;
- case 32:
- return V_DEPTH_24_32;
- }
- }
- }
- if (mode)
- VBEFreeModeInfo(mode);
- return 0;
-}
-
-/*
- * Find supported mode depths.
- */
-int
-VBEFindSupportedDepths(vbeInfoPtr pVbe, VbeInfoBlock *vbe, int *flags24,
- int modeTypes)
-{
- int i = 0;
- int depths = 0;
-
- if (modeTypes & V_MODETYPE_VBE) {
- while (vbe->VideoModePtr[i] != 0xffff) {
- depths |= GetDepthFlag(pVbe, vbe->VideoModePtr[i++]);
- }
- }
-
- /*
- * XXX This possibly only works with VBE 3.0 and later.
- */
- if (modeTypes & V_MODETYPE_VGA) {
- for (i = 0; i < 0x7F; i++) {
- depths |= GetDepthFlag(pVbe, i);
- }
- }
-
- if (flags24) {
- if (depths & V_DEPTH_24_24)
- *flags24 |= Support24bppFb;
- if (depths & V_DEPTH_24_32)
- *flags24 |= Support32bppFb;
- }
-
- return depths;
-}
-
-static DisplayModePtr
-CheckMode(ScrnInfoPtr pScrn, vbeInfoPtr pVbe, VbeInfoBlock *vbe, int id,
- int flags)
-{
- CARD16 major;
- VbeModeInfoBlock *mode;
- DisplayModePtr pMode;
- VbeModeInfoData *data;
- Bool modeOK = FALSE;
-
- major = (unsigned)(vbe->VESAVersion >> 8);
-
- if ((mode = VBEGetModeInfo(pVbe, id)) == NULL)
- return NULL;
-
- /* Does the mode match the depth/bpp? */
- /* Some BIOS's set BitsPerPixel to 15 instead of 16 for 15/16 */
- if (VBE_MODE_USABLE(mode, flags) &&
- ((pScrn->bitsPerPixel == 1 && !VBE_MODE_COLOR(mode)) ||
- (mode->BitsPerPixel > 8 &&
- (mode->RedMaskSize + mode->GreenMaskSize +
- mode->BlueMaskSize) == pScrn->depth &&
- mode->BitsPerPixel == pScrn->bitsPerPixel) ||
- (mode->BitsPerPixel == 15 && pScrn->depth == 15) ||
- (mode->BitsPerPixel <= 8 &&
- mode->BitsPerPixel == pScrn->bitsPerPixel))) {
- modeOK = TRUE;
- xf86ErrorFVerb(DEBUG_VERB, "*");
- }
-
- xf86ErrorFVerb(DEBUG_VERB,
- "Mode: %x (%dx%d)\n", id, mode->XResolution, mode->YResolution);
- xf86ErrorFVerb(DEBUG_VERB,
- " ModeAttributes: 0x%x\n", mode->ModeAttributes);
- xf86ErrorFVerb(DEBUG_VERB,
- " WinAAttributes: 0x%x\n", mode->WinAAttributes);
- xf86ErrorFVerb(DEBUG_VERB,
- " WinBAttributes: 0x%x\n", mode->WinBAttributes);
- xf86ErrorFVerb(DEBUG_VERB,
- " WinGranularity: %d\n", mode->WinGranularity);
- xf86ErrorFVerb(DEBUG_VERB,
- " WinSize: %d\n", mode->WinSize);
- xf86ErrorFVerb(DEBUG_VERB,
- " WinASegment: 0x%x\n", mode->WinASegment);
- xf86ErrorFVerb(DEBUG_VERB,
- " WinBSegment: 0x%x\n", mode->WinBSegment);
- xf86ErrorFVerb(DEBUG_VERB,
- " WinFuncPtr: 0x%lx\n", (unsigned long)mode->WinFuncPtr);
- xf86ErrorFVerb(DEBUG_VERB,
- " BytesPerScanline: %d\n", mode->BytesPerScanline);
- xf86ErrorFVerb(DEBUG_VERB,
- " XResolution: %d\n", mode->XResolution);
- xf86ErrorFVerb(DEBUG_VERB,
- " YResolution: %d\n", mode->YResolution);
- xf86ErrorFVerb(DEBUG_VERB,
- " XCharSize: %d\n", mode->XCharSize);
- xf86ErrorFVerb(DEBUG_VERB,
- " YCharSize: %d\n", mode->YCharSize);
- xf86ErrorFVerb(DEBUG_VERB,
- " NumberOfPlanes: %d\n", mode->NumberOfPlanes);
- xf86ErrorFVerb(DEBUG_VERB,
- " BitsPerPixel: %d\n", mode->BitsPerPixel);
- xf86ErrorFVerb(DEBUG_VERB,
- " NumberOfBanks: %d\n", mode->NumberOfBanks);
- xf86ErrorFVerb(DEBUG_VERB,
- " MemoryModel: %d\n", mode->MemoryModel);
- xf86ErrorFVerb(DEBUG_VERB,
- " BankSize: %d\n", mode->BankSize);
- xf86ErrorFVerb(DEBUG_VERB,
- " NumberOfImages: %d\n", mode->NumberOfImages);
- xf86ErrorFVerb(DEBUG_VERB,
- " RedMaskSize: %d\n", mode->RedMaskSize);
- xf86ErrorFVerb(DEBUG_VERB,
- " RedFieldPosition: %d\n", mode->RedFieldPosition);
- xf86ErrorFVerb(DEBUG_VERB,
- " GreenMaskSize: %d\n", mode->GreenMaskSize);
- xf86ErrorFVerb(DEBUG_VERB,
- " GreenFieldPosition: %d\n", mode->GreenFieldPosition);
- xf86ErrorFVerb(DEBUG_VERB,
- " BlueMaskSize: %d\n", mode->BlueMaskSize);
- xf86ErrorFVerb(DEBUG_VERB,
- " BlueFieldPosition: %d\n", mode->BlueFieldPosition);
- xf86ErrorFVerb(DEBUG_VERB,
- " RsvdMaskSize: %d\n", mode->RsvdMaskSize);
- xf86ErrorFVerb(DEBUG_VERB,
- " RsvdFieldPosition: %d\n", mode->RsvdFieldPosition);
- xf86ErrorFVerb(DEBUG_VERB,
- " DirectColorModeInfo: %d\n", mode->DirectColorModeInfo);
- if (major >= 2) {
- xf86ErrorFVerb(DEBUG_VERB,
- " PhysBasePtr: 0x%lx\n",
- (unsigned long)mode->PhysBasePtr);
- if (major >= 3) {
- xf86ErrorFVerb(DEBUG_VERB,
- " LinBytesPerScanLine: %d\n", mode->LinBytesPerScanLine);
- xf86ErrorFVerb(DEBUG_VERB,
- " BnkNumberOfImagePages: %d\n", mode->BnkNumberOfImagePages);
- xf86ErrorFVerb(DEBUG_VERB,
- " LinNumberOfImagePages: %d\n", mode->LinNumberOfImagePages);
- xf86ErrorFVerb(DEBUG_VERB,
- " LinRedMaskSize: %d\n", mode->LinRedMaskSize);
- xf86ErrorFVerb(DEBUG_VERB,
- " LinRedFieldPosition: %d\n", mode->LinRedFieldPosition);
- xf86ErrorFVerb(DEBUG_VERB,
- " LinGreenMaskSize: %d\n", mode->LinGreenMaskSize);
- xf86ErrorFVerb(DEBUG_VERB,
- " LinGreenFieldPosition: %d\n", mode->LinGreenFieldPosition);
- xf86ErrorFVerb(DEBUG_VERB,
- " LinBlueMaskSize: %d\n", mode->LinBlueMaskSize);
- xf86ErrorFVerb(DEBUG_VERB,
- " LinBlueFieldPosition: %d\n", mode->LinBlueFieldPosition);
- xf86ErrorFVerb(DEBUG_VERB,
- " LinRsvdMaskSize: %d\n", mode->LinRsvdMaskSize);
- xf86ErrorFVerb(DEBUG_VERB,
- " LinRsvdFieldPosition: %d\n", mode->LinRsvdFieldPosition);
- xf86ErrorFVerb(DEBUG_VERB,
- " MaxPixelClock: %ld\n", (unsigned long)mode->MaxPixelClock);
- }
- }
-
- if (!modeOK) {
- VBEFreeModeInfo(mode);
- return NULL;
- }
- pMode = xnfcalloc(sizeof(DisplayModeRec), 1);
-
- pMode->status = MODE_OK;
- pMode->type = M_T_BUILTIN;
-
- /* for adjust frame */
- pMode->HDisplay = mode->XResolution;
- pMode->VDisplay = mode->YResolution;
-
- data = xnfcalloc(sizeof(VbeModeInfoData), 1);
- data->mode = id;
- data->data = mode;
- pMode->PrivSize = sizeof(VbeModeInfoData);
- pMode->Private = (INT32*)data;
- pMode->next = NULL;
- return pMode;
-}
-
-/*
- * Check the available BIOS modes, and extract those that match the
- * requirements into the modePool. Note: modePool is a NULL-terminated
- * list.
- */
-
-DisplayModePtr
-VBEGetModePool(ScrnInfoPtr pScrn, vbeInfoPtr pVbe, VbeInfoBlock *vbe,
- int modeTypes)
-{
- DisplayModePtr pMode, p = NULL, modePool = NULL;
- int i = 0;
-
- if (modeTypes & V_MODETYPE_VBE) {
- while (vbe->VideoModePtr[i] != 0xffff) {
- int id = vbe->VideoModePtr[i++];
-
- if ((pMode = CheckMode(pScrn, pVbe, vbe, id, modeTypes)) != NULL) {
- ModeStatus status = MODE_OK;
-
- /* Check the mode against a specified virtual size (if any) */
- if (pScrn->display->virtualX > 0 &&
- pMode->HDisplay > pScrn->display->virtualX) {
- status = MODE_VIRTUAL_X;
- }
- if (pScrn->display->virtualY > 0 &&
- pMode->VDisplay > pScrn->display->virtualY) {
- status = MODE_VIRTUAL_Y;
- }
- if (status != MODE_OK) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Not using mode \"%dx%d\" (%s)\n",
- pMode->HDisplay, pMode->VDisplay,
- xf86ModeStatusToString(status));
- } else {
- if (p == NULL) {
- modePool = pMode;
- } else {
- p->next = pMode;
- }
- pMode->prev = NULL;
- p = pMode;
- }
- }
- }
- }
- if (modeTypes & V_MODETYPE_VGA) {
- for (i = 0; i < 0x7F; i++) {
- if ((pMode = CheckMode(pScrn, pVbe, vbe, i, modeTypes)) != NULL) {
- ModeStatus status = MODE_OK;
-
- /* Check the mode against a specified virtual size (if any) */
- if (pScrn->display->virtualX > 0 &&
- pMode->HDisplay > pScrn->display->virtualX) {
- status = MODE_VIRTUAL_X;
- }
- if (pScrn->display->virtualY > 0 &&
- pMode->VDisplay > pScrn->display->virtualY) {
- status = MODE_VIRTUAL_Y;
- }
- if (status != MODE_OK) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Not using mode \"%dx%d\" (%s)\n",
- pMode->HDisplay, pMode->VDisplay,
- xf86ModeStatusToString(status));
- } else {
- if (p == NULL) {
- modePool = pMode;
- } else {
- p->next = pMode;
- }
- pMode->prev = NULL;
- p = pMode;
- }
- }
- }
- }
- return modePool;
-}
-
-void
-VBESetModeNames(DisplayModePtr pMode)
-{
- if (!pMode)
- return;
-
- do {
- if (!pMode->name) {
- /* Catch "bad" modes. */
- if (pMode->HDisplay > 10000 || pMode->HDisplay < 0 ||
- pMode->VDisplay > 10000 || pMode->VDisplay < 0) {
- pMode->name = strdup("BADMODE");
- } else {
- XNFasprintf(&pMode->name, "%dx%d",
- pMode->HDisplay, pMode->VDisplay);
- }
- }
- pMode = pMode->next;
- } while (pMode);
-}
-
-/*
- * Go through the monitor modes and selecting the best set of
- * parameters for each BIOS mode. Note: This is only supported in
- * VBE version 3.0 or later.
- */
-void
-VBESetModeParameters(ScrnInfoPtr pScrn, vbeInfoPtr pVbe)
-{
- DisplayModePtr pMode;
- VbeModeInfoData *data;
-
- pMode = pScrn->modes;
- do {
- DisplayModePtr p, best = NULL;
- ModeStatus status;
-
- for (p = pScrn->monitor->Modes; p != NULL; p = p->next) {
- if ((p->HDisplay != pMode->HDisplay) ||
- (p->VDisplay != pMode->VDisplay) ||
- (p->Flags & (V_INTERLACE | V_DBLSCAN | V_CLKDIV2)))
- continue;
- /* XXX could support the various V_ flags */
- status = xf86CheckModeForMonitor(p, pScrn->monitor);
- if (status != MODE_OK)
- continue;
- if (!best || (p->Clock > best->Clock))
- best = p;
- }
-
- if (best) {
- int clock;
-
- data = (VbeModeInfoData*)pMode->Private;
- pMode->HSync = (float)best->Clock * 1000.0 / best->HTotal + 0.5;
- pMode->VRefresh = pMode->HSync / best->VTotal + 0.5;
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Attempting to use %dHz refresh for mode \"%s\" (%x)\n",
- (int)pMode->VRefresh, pMode->name, data->mode);
- data->block = calloc(sizeof(VbeCRTCInfoBlock), 1);
- data->block->HorizontalTotal = best->HTotal;
- data->block->HorizontalSyncStart = best->HSyncStart;
- data->block->HorizontalSyncEnd = best->HSyncEnd;
- data->block->VerticalTotal = best->VTotal;
- data->block->VerticalSyncStart = best->VSyncStart;
- data->block->VerticalSyncEnd = best->VSyncEnd;
- data->block->Flags = ((best->Flags & V_NHSYNC) ? CRTC_NHSYNC : 0) |
- ((best->Flags & V_NVSYNC) ? CRTC_NVSYNC : 0);
- data->block->PixelClock = best->Clock * 1000;
- /* XXX May not have this. */
- clock = VBEGetPixelClock(pVbe, data->mode, data->block->PixelClock);
- DebugF("Setting clock %.2fMHz, closest is %.2fMHz\n",
- (double)data->block->PixelClock / 1000000.0,
- (double)clock / 1000000.0);
- if (clock)
- data->block->PixelClock = clock;
- data->mode |= (1 << 11);
- data->block->RefreshRate = ((double)(data->block->PixelClock) /
- (double)(best->HTotal * best->VTotal)) * 100;
- }
- pMode = pMode->next;
- } while (pMode != pScrn->modes);
-}
-
-/*
- * These wrappers are to allow (temporary) funtionality divergences.
- */
-int
-VBEValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
- char **modeNames, ClockRangePtr clockRanges,
- int *linePitches, int minPitch, int maxPitch, int pitchInc,
- int minHeight, int maxHeight, int virtualX, int virtualY,
- int apertureSize, LookupModeFlags strategy)
-{
- return xf86ValidateModes(scrp, availModes, modeNames, clockRanges,
- linePitches, minPitch, maxPitch, pitchInc,
- minHeight, maxHeight, virtualX, virtualY,
- apertureSize, strategy);
-}
-
-void
-VBEPrintModes(ScrnInfoPtr scrp)
-{
- xf86PrintModes(scrp);
-}
-
+#define DEBUG_VERB 2
+/*
+ * Copyright © 2002 David Dawes
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the author(s) shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from
+ * the author(s).
+ *
+ * Authors: David Dawes <dawes@xfree86.org>
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+
+#include "xf86.h"
+#include "vbe.h"
+#include "vbeModes.h"
+
+static int
+GetDepthFlag(vbeInfoPtr pVbe, int id)
+{
+ VbeModeInfoBlock *mode;
+ int bpp;
+
+ if ((mode = VBEGetModeInfo(pVbe, id)) == NULL)
+ return 0;
+
+ if (VBE_MODE_USABLE(mode, 0)) {
+ int depth;
+
+ if (VBE_MODE_COLOR(mode)) {
+ depth = mode->RedMaskSize + mode->GreenMaskSize +
+ mode->BlueMaskSize;
+ }
+ else {
+ depth = 1;
+ }
+ bpp = mode->BitsPerPixel;
+ VBEFreeModeInfo(mode);
+ mode = NULL;
+ switch (depth) {
+ case 1:
+ return V_DEPTH_1;
+ case 4:
+ return V_DEPTH_4;
+ case 8:
+ return V_DEPTH_8;
+ case 15:
+ return V_DEPTH_15;
+ case 16:
+ return V_DEPTH_16;
+ case 24:
+ switch (bpp) {
+ case 24:
+ return V_DEPTH_24_24;
+ case 32:
+ return V_DEPTH_24_32;
+ }
+ }
+ }
+ if (mode)
+ VBEFreeModeInfo(mode);
+ return 0;
+}
+
+/*
+ * Find supported mode depths.
+ */
+int
+VBEFindSupportedDepths(vbeInfoPtr pVbe, VbeInfoBlock * vbe, int *flags24,
+ int modeTypes)
+{
+ int i = 0;
+ int depths = 0;
+
+ if (modeTypes & V_MODETYPE_VBE) {
+ while (vbe->VideoModePtr[i] != 0xffff) {
+ depths |= GetDepthFlag(pVbe, vbe->VideoModePtr[i++]);
+ }
+ }
+
+ /*
+ * XXX This possibly only works with VBE 3.0 and later.
+ */
+ if (modeTypes & V_MODETYPE_VGA) {
+ for (i = 0; i < 0x7F; i++) {
+ depths |= GetDepthFlag(pVbe, i);
+ }
+ }
+
+ if (flags24) {
+ if (depths & V_DEPTH_24_24)
+ *flags24 |= Support24bppFb;
+ if (depths & V_DEPTH_24_32)
+ *flags24 |= Support32bppFb;
+ }
+
+ return depths;
+}
+
+static DisplayModePtr
+CheckMode(ScrnInfoPtr pScrn, vbeInfoPtr pVbe, VbeInfoBlock * vbe, int id,
+ int flags)
+{
+ CARD16 major;
+ VbeModeInfoBlock *mode;
+ DisplayModePtr pMode;
+ VbeModeInfoData *data;
+ Bool modeOK = FALSE;
+
+ major = (unsigned) (vbe->VESAVersion >> 8);
+
+ if ((mode = VBEGetModeInfo(pVbe, id)) == NULL)
+ return NULL;
+
+ /* Does the mode match the depth/bpp? */
+ /* Some BIOS's set BitsPerPixel to 15 instead of 16 for 15/16 */
+ if (VBE_MODE_USABLE(mode, flags) &&
+ ((pScrn->bitsPerPixel == 1 && !VBE_MODE_COLOR(mode)) ||
+ (mode->BitsPerPixel > 8 &&
+ (mode->RedMaskSize + mode->GreenMaskSize +
+ mode->BlueMaskSize) == pScrn->depth &&
+ mode->BitsPerPixel == pScrn->bitsPerPixel) ||
+ (mode->BitsPerPixel == 15 && pScrn->depth == 15) ||
+ (mode->BitsPerPixel <= 8 &&
+ mode->BitsPerPixel == pScrn->bitsPerPixel))) {
+ modeOK = TRUE;
+ xf86ErrorFVerb(DEBUG_VERB, "*");
+ }
+
+ xf86ErrorFVerb(DEBUG_VERB,
+ "Mode: %x (%dx%d)\n", id, mode->XResolution,
+ mode->YResolution);
+ xf86ErrorFVerb(DEBUG_VERB, " ModeAttributes: 0x%x\n",
+ mode->ModeAttributes);
+ xf86ErrorFVerb(DEBUG_VERB, " WinAAttributes: 0x%x\n",
+ mode->WinAAttributes);
+ xf86ErrorFVerb(DEBUG_VERB, " WinBAttributes: 0x%x\n",
+ mode->WinBAttributes);
+ xf86ErrorFVerb(DEBUG_VERB, " WinGranularity: %d\n",
+ mode->WinGranularity);
+ xf86ErrorFVerb(DEBUG_VERB, " WinSize: %d\n", mode->WinSize);
+ xf86ErrorFVerb(DEBUG_VERB,
+ " WinASegment: 0x%x\n", mode->WinASegment);
+ xf86ErrorFVerb(DEBUG_VERB,
+ " WinBSegment: 0x%x\n", mode->WinBSegment);
+ xf86ErrorFVerb(DEBUG_VERB,
+ " WinFuncPtr: 0x%lx\n", (unsigned long) mode->WinFuncPtr);
+ xf86ErrorFVerb(DEBUG_VERB,
+ " BytesPerScanline: %d\n", mode->BytesPerScanline);
+ xf86ErrorFVerb(DEBUG_VERB, " XResolution: %d\n", mode->XResolution);
+ xf86ErrorFVerb(DEBUG_VERB, " YResolution: %d\n", mode->YResolution);
+ xf86ErrorFVerb(DEBUG_VERB, " XCharSize: %d\n", mode->XCharSize);
+ xf86ErrorFVerb(DEBUG_VERB, " YCharSize: %d\n", mode->YCharSize);
+ xf86ErrorFVerb(DEBUG_VERB,
+ " NumberOfPlanes: %d\n", mode->NumberOfPlanes);
+ xf86ErrorFVerb(DEBUG_VERB,
+ " BitsPerPixel: %d\n", mode->BitsPerPixel);
+ xf86ErrorFVerb(DEBUG_VERB,
+ " NumberOfBanks: %d\n", mode->NumberOfBanks);
+ xf86ErrorFVerb(DEBUG_VERB, " MemoryModel: %d\n", mode->MemoryModel);
+ xf86ErrorFVerb(DEBUG_VERB, " BankSize: %d\n", mode->BankSize);
+ xf86ErrorFVerb(DEBUG_VERB,
+ " NumberOfImages: %d\n", mode->NumberOfImages);
+ xf86ErrorFVerb(DEBUG_VERB, " RedMaskSize: %d\n", mode->RedMaskSize);
+ xf86ErrorFVerb(DEBUG_VERB,
+ " RedFieldPosition: %d\n", mode->RedFieldPosition);
+ xf86ErrorFVerb(DEBUG_VERB,
+ " GreenMaskSize: %d\n", mode->GreenMaskSize);
+ xf86ErrorFVerb(DEBUG_VERB,
+ " GreenFieldPosition: %d\n", mode->GreenFieldPosition);
+ xf86ErrorFVerb(DEBUG_VERB,
+ " BlueMaskSize: %d\n", mode->BlueMaskSize);
+ xf86ErrorFVerb(DEBUG_VERB,
+ " BlueFieldPosition: %d\n", mode->BlueFieldPosition);
+ xf86ErrorFVerb(DEBUG_VERB,
+ " RsvdMaskSize: %d\n", mode->RsvdMaskSize);
+ xf86ErrorFVerb(DEBUG_VERB,
+ " RsvdFieldPosition: %d\n", mode->RsvdFieldPosition);
+ xf86ErrorFVerb(DEBUG_VERB,
+ " DirectColorModeInfo: %d\n", mode->DirectColorModeInfo);
+ if (major >= 2) {
+ xf86ErrorFVerb(DEBUG_VERB,
+ " PhysBasePtr: 0x%lx\n",
+ (unsigned long) mode->PhysBasePtr);
+ if (major >= 3) {
+ xf86ErrorFVerb(DEBUG_VERB,
+ " LinBytesPerScanLine: %d\n",
+ mode->LinBytesPerScanLine);
+ xf86ErrorFVerb(DEBUG_VERB, " BnkNumberOfImagePages: %d\n",
+ mode->BnkNumberOfImagePages);
+ xf86ErrorFVerb(DEBUG_VERB, " LinNumberOfImagePages: %d\n",
+ mode->LinNumberOfImagePages);
+ xf86ErrorFVerb(DEBUG_VERB, " LinRedMaskSize: %d\n",
+ mode->LinRedMaskSize);
+ xf86ErrorFVerb(DEBUG_VERB, " LinRedFieldPosition: %d\n",
+ mode->LinRedFieldPosition);
+ xf86ErrorFVerb(DEBUG_VERB, " LinGreenMaskSize: %d\n",
+ mode->LinGreenMaskSize);
+ xf86ErrorFVerb(DEBUG_VERB, " LinGreenFieldPosition: %d\n",
+ mode->LinGreenFieldPosition);
+ xf86ErrorFVerb(DEBUG_VERB, " LinBlueMaskSize: %d\n",
+ mode->LinBlueMaskSize);
+ xf86ErrorFVerb(DEBUG_VERB, " LinBlueFieldPosition: %d\n",
+ mode->LinBlueFieldPosition);
+ xf86ErrorFVerb(DEBUG_VERB, " LinRsvdMaskSize: %d\n",
+ mode->LinRsvdMaskSize);
+ xf86ErrorFVerb(DEBUG_VERB, " LinRsvdFieldPosition: %d\n",
+ mode->LinRsvdFieldPosition);
+ xf86ErrorFVerb(DEBUG_VERB, " MaxPixelClock: %ld\n",
+ (unsigned long) mode->MaxPixelClock);
+ }
+ }
+
+ if (!modeOK) {
+ VBEFreeModeInfo(mode);
+ return NULL;
+ }
+ pMode = xnfcalloc(sizeof(DisplayModeRec), 1);
+
+ pMode->status = MODE_OK;
+ pMode->type = M_T_BUILTIN;
+
+ /* for adjust frame */
+ pMode->HDisplay = mode->XResolution;
+ pMode->VDisplay = mode->YResolution;
+
+ data = xnfcalloc(sizeof(VbeModeInfoData), 1);
+ data->mode = id;
+ data->data = mode;
+ pMode->PrivSize = sizeof(VbeModeInfoData);
+ pMode->Private = (INT32 *) data;
+ pMode->next = NULL;
+ return pMode;
+}
+
+/*
+ * Check the available BIOS modes, and extract those that match the
+ * requirements into the modePool. Note: modePool is a NULL-terminated
+ * list.
+ */
+
+DisplayModePtr
+VBEGetModePool(ScrnInfoPtr pScrn, vbeInfoPtr pVbe, VbeInfoBlock * vbe,
+ int modeTypes)
+{
+ DisplayModePtr pMode, p = NULL, modePool = NULL;
+ int i = 0;
+
+ if (modeTypes & V_MODETYPE_VBE) {
+ while (vbe->VideoModePtr[i] != 0xffff) {
+ int id = vbe->VideoModePtr[i++];
+
+ if ((pMode = CheckMode(pScrn, pVbe, vbe, id, modeTypes)) != NULL) {
+ ModeStatus status = MODE_OK;
+
+ /* Check the mode against a specified virtual size (if any) */
+ if (pScrn->display->virtualX > 0 &&
+ pMode->HDisplay > pScrn->display->virtualX) {
+ status = MODE_VIRTUAL_X;
+ }
+ if (pScrn->display->virtualY > 0 &&
+ pMode->VDisplay > pScrn->display->virtualY) {
+ status = MODE_VIRTUAL_Y;
+ }
+ if (status != MODE_OK) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Not using mode \"%dx%d\" (%s)\n",
+ pMode->HDisplay, pMode->VDisplay,
+ xf86ModeStatusToString(status));
+ }
+ else {
+ if (p == NULL) {
+ modePool = pMode;
+ }
+ else {
+ p->next = pMode;
+ }
+ pMode->prev = NULL;
+ p = pMode;
+ }
+ }
+ }
+ }
+ if (modeTypes & V_MODETYPE_VGA) {
+ for (i = 0; i < 0x7F; i++) {
+ if ((pMode = CheckMode(pScrn, pVbe, vbe, i, modeTypes)) != NULL) {
+ ModeStatus status = MODE_OK;
+
+ /* Check the mode against a specified virtual size (if any) */
+ if (pScrn->display->virtualX > 0 &&
+ pMode->HDisplay > pScrn->display->virtualX) {
+ status = MODE_VIRTUAL_X;
+ }
+ if (pScrn->display->virtualY > 0 &&
+ pMode->VDisplay > pScrn->display->virtualY) {
+ status = MODE_VIRTUAL_Y;
+ }
+ if (status != MODE_OK) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Not using mode \"%dx%d\" (%s)\n",
+ pMode->HDisplay, pMode->VDisplay,
+ xf86ModeStatusToString(status));
+ }
+ else {
+ if (p == NULL) {
+ modePool = pMode;
+ }
+ else {
+ p->next = pMode;
+ }
+ pMode->prev = NULL;
+ p = pMode;
+ }
+ }
+ }
+ }
+ return modePool;
+}
+
+void
+VBESetModeNames(DisplayModePtr pMode)
+{
+ if (!pMode)
+ return;
+
+ do {
+ if (!pMode->name) {
+ /* Catch "bad" modes. */
+ if (pMode->HDisplay > 10000 || pMode->HDisplay < 0 ||
+ pMode->VDisplay > 10000 || pMode->VDisplay < 0) {
+ pMode->name = strdup("BADMODE");
+ }
+ else {
+ XNFasprintf(&pMode->name, "%dx%d",
+ pMode->HDisplay, pMode->VDisplay);
+ }
+ }
+ pMode = pMode->next;
+ } while (pMode);
+}
+
+/*
+ * Go through the monitor modes and selecting the best set of
+ * parameters for each BIOS mode. Note: This is only supported in
+ * VBE version 3.0 or later.
+ */
+void
+VBESetModeParameters(ScrnInfoPtr pScrn, vbeInfoPtr pVbe)
+{
+ DisplayModePtr pMode;
+ VbeModeInfoData *data;
+
+ pMode = pScrn->modes;
+ do {
+ DisplayModePtr p, best = NULL;
+ ModeStatus status;
+
+ for (p = pScrn->monitor->Modes; p != NULL; p = p->next) {
+ if ((p->HDisplay != pMode->HDisplay) ||
+ (p->VDisplay != pMode->VDisplay) ||
+ (p->Flags & (V_INTERLACE | V_DBLSCAN | V_CLKDIV2)))
+ continue;
+ /* XXX could support the various V_ flags */
+ status = xf86CheckModeForMonitor(p, pScrn->monitor);
+ if (status != MODE_OK)
+ continue;
+ if (!best || (p->Clock > best->Clock))
+ best = p;
+ }
+
+ if (best) {
+ int clock;
+
+ data = (VbeModeInfoData *) pMode->Private;
+ pMode->HSync = (float) best->Clock * 1000.0 / best->HTotal + 0.5;
+ pMode->VRefresh = pMode->HSync / best->VTotal + 0.5;
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Attempting to use %dHz refresh for mode \"%s\" (%x)\n",
+ (int) pMode->VRefresh, pMode->name, data->mode);
+ data->block = calloc(sizeof(VbeCRTCInfoBlock), 1);
+ data->block->HorizontalTotal = best->HTotal;
+ data->block->HorizontalSyncStart = best->HSyncStart;
+ data->block->HorizontalSyncEnd = best->HSyncEnd;
+ data->block->VerticalTotal = best->VTotal;
+ data->block->VerticalSyncStart = best->VSyncStart;
+ data->block->VerticalSyncEnd = best->VSyncEnd;
+ data->block->Flags = ((best->Flags & V_NHSYNC) ? CRTC_NHSYNC : 0) |
+ ((best->Flags & V_NVSYNC) ? CRTC_NVSYNC : 0);
+ data->block->PixelClock = best->Clock * 1000;
+ /* XXX May not have this. */
+ clock = VBEGetPixelClock(pVbe, data->mode, data->block->PixelClock);
+ DebugF("Setting clock %.2fMHz, closest is %.2fMHz\n",
+ (double) data->block->PixelClock / 1000000.0,
+ (double) clock / 1000000.0);
+ if (clock)
+ data->block->PixelClock = clock;
+ data->mode |= (1 << 11);
+ data->block->RefreshRate = ((double) (data->block->PixelClock) /
+ (double) (best->HTotal *
+ best->VTotal)) * 100;
+ }
+ pMode = pMode->next;
+ } while (pMode != pScrn->modes);
+}
+
+/*
+ * These wrappers are to allow (temporary) funtionality divergences.
+ */
+int
+VBEValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
+ char **modeNames, ClockRangePtr clockRanges,
+ int *linePitches, int minPitch, int maxPitch, int pitchInc,
+ int minHeight, int maxHeight, int virtualX, int virtualY,
+ int apertureSize, LookupModeFlags strategy)
+{
+ return xf86ValidateModes(scrp, availModes, modeNames, clockRanges,
+ linePitches, minPitch, maxPitch, pitchInc,
+ minHeight, maxHeight, virtualX, virtualY,
+ apertureSize, strategy);
+}
+
+void
+VBEPrintModes(ScrnInfoPtr scrp)
+{
+ xf86PrintModes(scrp);
+}
diff --git a/xorg-server/hw/xfree86/vbe/vbeModes.h b/xorg-server/hw/xfree86/vbe/vbeModes.h
index 447798709..affd5b639 100644
--- a/xorg-server/hw/xfree86/vbe/vbeModes.h
+++ b/xorg-server/hw/xfree86/vbe/vbeModes.h
@@ -62,29 +62,33 @@ typedef struct _VbeModeInfoData {
(f & V_MODETYPE_BAD)) && \
VBE_MODE_GRAPHICS(m) && \
(VBE_MODE_VGA(m) || VBE_MODE_LINEAR(m))
-
+
#define V_MODETYPE_VBE 0x01
#define V_MODETYPE_VGA 0x02
#define V_MODETYPE_BAD 0x04
-extern _X_EXPORT int VBEFindSupportedDepths(vbeInfoPtr pVbe, VbeInfoBlock *vbe,
- int *flags24, int modeTypes);
-extern _X_EXPORT DisplayModePtr VBEGetModePool(ScrnInfoPtr pScrn, vbeInfoPtr pVbe,
- VbeInfoBlock *vbe, int modeTypes);
+extern _X_EXPORT int VBEFindSupportedDepths(vbeInfoPtr pVbe, VbeInfoBlock * vbe,
+ int *flags24, int modeTypes);
+extern _X_EXPORT DisplayModePtr VBEGetModePool(ScrnInfoPtr pScrn,
+ vbeInfoPtr pVbe,
+ VbeInfoBlock * vbe,
+ int modeTypes);
extern _X_EXPORT void VBESetModeNames(DisplayModePtr pMode);
extern _X_EXPORT void VBESetModeParameters(ScrnInfoPtr pScrn, vbeInfoPtr pVbe);
-
/*
* Note: These are alternatives to the standard helpers. They should
* usually just wrap the standard helpers.
*/
-extern _X_EXPORT int VBEValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
- char **modeNames, ClockRangePtr clockRanges,
- int *linePitches, int minPitch, int maxPitch,
- int pitchInc, int minHeight, int maxHeight,
- int virtualX, int virtualY, int apertureSize,
- LookupModeFlags strategy);
+extern _X_EXPORT int VBEValidateModes(ScrnInfoPtr scrp,
+ DisplayModePtr availModes,
+ char **modeNames,
+ ClockRangePtr clockRanges,
+ int *linePitches, int minPitch,
+ int maxPitch, int pitchInc, int minHeight,
+ int maxHeight, int virtualX, int virtualY,
+ int apertureSize,
+ LookupModeFlags strategy);
extern _X_EXPORT void VBEPrintModes(ScrnInfoPtr scrp);
-#endif /* VBE_MODES_H */
+#endif /* VBE_MODES_H */
diff --git a/xorg-server/hw/xfree86/vbe/vbe_module.c b/xorg-server/hw/xfree86/vbe/vbe_module.c
index 5aba16f51..3fb86956e 100644
--- a/xorg-server/hw/xfree86/vbe/vbe_module.c
+++ b/xorg-server/hw/xfree86/vbe/vbe_module.c
@@ -1,23 +1,22 @@
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86str.h"
-#include "vbe.h"
-
-static XF86ModuleVersionInfo vbeVersRec =
-{
- "vbe",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 1, 0,
- ABI_CLASS_VIDEODRV, /* needs the video driver ABI */
- ABI_VIDEODRV_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0}
-};
-
-_X_EXPORT XF86ModuleData vbeModuleData = { &vbeVersRec, NULL, NULL };
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86str.h"
+#include "vbe.h"
+
+static XF86ModuleVersionInfo vbeVersRec = {
+ "vbe",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 1, 0,
+ ABI_CLASS_VIDEODRV, /* needs the video driver ABI */
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_NONE,
+ {0, 0, 0, 0}
+};
+
+_X_EXPORT XF86ModuleData vbeModuleData = { &vbeVersRec, NULL, NULL };
diff --git a/xorg-server/hw/xfree86/vgahw/vgaCmap.c b/xorg-server/hw/xfree86/vgahw/vgaCmap.c
index a65bb5e86..0cfabc5d6 100644
--- a/xorg-server/hw/xfree86/vgahw/vgaCmap.c
+++ b/xorg-server/hw/xfree86/vgahw/vgaCmap.c
@@ -1,301 +1,279 @@
-/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Thomas Roell not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Thomas Roell makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "windowstr.h"
-#include "compiler.h"
-#include "mipointer.h"
-#include "micmap.h"
-
-#include "xf86.h"
-#include "vgaHW.h"
-
-#include <X11/extensions/xf86dgaproto.h>
-#include "dgaproc.h"
-
-
-#define NOMAPYET (ColormapPtr) 0
-
-int
-vgaListInstalledColormaps(pScreen, pmaps)
- ScreenPtr pScreen;
- Colormap *pmaps;
-{
- /* By the time we are processing requests, we can guarantee that there
- * is always a colormap installed */
-
- *pmaps = GetInstalledmiColormap(pScreen)->mid;
- return 1;
-}
-
-int
-vgaGetInstalledColormaps(pScreen, pmaps)
- ScreenPtr pScreen;
- ColormapPtr *pmaps;
-{
- /* By the time we are processing requests, we can guarantee that there
- * is always a colormap installed */
-
- *pmaps = GetInstalledmiColormap(pScreen);
- return 1;
-}
-
-int vgaCheckColorMap(ColormapPtr pmap)
-{
- return (pmap != GetInstalledmiColormap(pmap->pScreen));
-}
-
-
-void
-vgaStoreColors(pmap, ndef, pdefs)
- ColormapPtr pmap;
- int ndef;
- xColorItem *pdefs;
-{
- int i;
- unsigned char *cmap, *tmp = NULL;
- xColorItem directDefs[256];
- Bool new_overscan = FALSE;
- Bool writeColormap;
-
- /* This can get called before the ScrnInfoRec is installed so we
- can't rely on getting it with XF86SCRNINFO() */
- int scrnIndex = pmap->pScreen->myNum;
- ScrnInfoPtr scrninfp = xf86Screens[scrnIndex];
- vgaHWPtr hwp = VGAHWPTR(scrninfp);
-
- unsigned char overscan = hwp->ModeReg.Attribute[OVERSCAN];
- unsigned char tmp_overscan = 0;
-
- if (vgaCheckColorMap(pmap))
- return;
-
- if ((pmap->pVisual->class | DynamicClass) == DirectColor)
- {
- ndef = miExpandDirectColors (pmap, ndef, pdefs, directDefs);
- pdefs = directDefs;
- }
-
- writeColormap = scrninfp->vtSema;
- if (DGAAvailable(scrnIndex))
- {
- writeColormap = writeColormap ||
- (DGAGetDirectMode(scrnIndex) &&
- !(DGAGetFlags(scrnIndex) & XF86DGADirectColormap)) ||
- (DGAGetFlags(scrnIndex) & XF86DGAHasColormap);
- }
-
- if (writeColormap)
- hwp->enablePalette(hwp);
-
- for(i = 0; i < ndef; i++)
- {
- if (pdefs[i].pixel == overscan)
- {
- new_overscan = TRUE;
- }
- cmap = &(hwp->ModeReg.DAC[pdefs[i].pixel*3]);
- if (scrninfp->rgbBits == 8) {
- cmap[0] = pdefs[i].red >> 8;
- cmap[1] = pdefs[i].green >> 8;
- cmap[2] = pdefs[i].blue >> 8;
- }
- else {
- cmap[0] = pdefs[i].red >> 10;
- cmap[1] = pdefs[i].green >> 10;
- cmap[2] = pdefs[i].blue >> 10;
- }
-#if 0
- if (clgd6225Lcd)
- {
- /* The LCD doesn't like white */
- if (cmap[0] == 63) cmap[0]= 62;
- if (cmap[1] == 63) cmap[1]= 62;
- if (cmap[2] == 63) cmap[2]= 62;
- }
-#endif
-
- if (writeColormap)
- {
- if (hwp->ShowOverscan && i == 255)
- continue;
- hwp->writeDacWriteAddr(hwp, pdefs[i].pixel);
- DACDelay(hwp);
- hwp->writeDacData(hwp, cmap[0]);
- DACDelay(hwp);
- hwp->writeDacData(hwp, cmap[1]);
- DACDelay(hwp);
- hwp->writeDacData(hwp, cmap[2]);
- DACDelay(hwp);
- }
- }
- if (new_overscan && !hwp->ShowOverscan)
- {
- new_overscan = FALSE;
- for(i = 0; i < ndef; i++)
- {
- if (pdefs[i].pixel == overscan)
- {
- if ((pdefs[i].red != 0) ||
- (pdefs[i].green != 0) ||
- (pdefs[i].blue != 0))
- {
- new_overscan = TRUE;
- tmp_overscan = overscan;
- tmp = &(hwp->ModeReg.DAC[pdefs[i].pixel*3]);
- }
- break;
- }
- }
- if (new_overscan)
- {
- /*
- * Find a black pixel, or the nearest match.
- */
- for (i=255; i >= 0; i--)
- {
- cmap = &(hwp->ModeReg.DAC[i*3]);
- if ((cmap[0] == 0) && (cmap[1] == 0) && (cmap[2] == 0))
- {
- overscan = i;
- break;
- }
- else
- {
- if ((cmap[0] < tmp[0]) &&
- (cmap[1] < tmp[1]) && (cmap[2] < tmp[2]))
- {
- tmp = cmap;
- tmp_overscan = i;
- }
- }
- }
- if (i < 0)
- {
- overscan = tmp_overscan;
- }
- hwp->ModeReg.Attribute[OVERSCAN] = overscan;
- if (writeColormap)
- {
- hwp->writeAttr(hwp, OVERSCAN, overscan);
- }
- }
- }
-
- if (writeColormap)
- hwp->disablePalette(hwp);
-}
-
-
-void
-vgaInstallColormap(pmap)
- ColormapPtr pmap;
-{
- ColormapPtr oldmap = GetInstalledmiColormap(pmap->pScreen);
- int entries;
- Pixel * ppix;
- xrgb * prgb;
- xColorItem *defs;
- int i;
-
-
- if (pmap == oldmap)
- return;
-
- if ((pmap->pVisual->class | DynamicClass) == DirectColor)
- entries = (pmap->pVisual->redMask |
- pmap->pVisual->greenMask |
- pmap->pVisual->blueMask) + 1;
- else
- entries = pmap->pVisual->ColormapEntries;
-
- ppix = (Pixel *)malloc( entries * sizeof(Pixel));
- prgb = (xrgb *)malloc( entries * sizeof(xrgb));
- defs = (xColorItem *)malloc(entries * sizeof(xColorItem));
-
- if ( oldmap != NOMAPYET)
- WalkTree( pmap->pScreen, TellLostMap, &oldmap->mid);
-
- SetInstalledmiColormap(pmap->pScreen, pmap);
-
- for ( i=0; i<entries; i++) ppix[i] = i;
-
- QueryColors(pmap, entries, ppix, prgb, serverClient);
-
- for ( i=0; i<entries; i++) /* convert xrgbs to xColorItems */
- {
- defs[i].pixel = ppix[i];
- defs[i].red = prgb[i].red;
- defs[i].green = prgb[i].green;
- defs[i].blue = prgb[i].blue;
- defs[i].flags = DoRed|DoGreen|DoBlue;
- }
- pmap->pScreen->StoreColors(pmap, entries, defs);
-
- WalkTree(pmap->pScreen, TellGainedMap, &pmap->mid);
-
- free(ppix);
- free(prgb);
- free(defs);
-}
-
-
-void
-vgaUninstallColormap(pmap)
- ColormapPtr pmap;
-{
-
- ColormapPtr defColormap;
-
- if ( pmap != GetInstalledmiColormap(pmap->pScreen))
- return;
-
- dixLookupResourceByType((pointer *)&defColormap, pmap->pScreen->defColormap,
- RT_COLORMAP, serverClient, DixInstallAccess);
-
- if (defColormap == GetInstalledmiColormap(pmap->pScreen))
- return;
-
- (*pmap->pScreen->InstallColormap) (defColormap);
-}
-
-
-void
-vgaHandleColormaps(ScreenPtr pScreen, ScrnInfoPtr scrnp)
-{
- if (scrnp->bitsPerPixel > 1) {
- if (scrnp->bitsPerPixel <= 8) { /* For 8bpp SVGA and VGA16 */
- pScreen->InstallColormap = vgaInstallColormap;
- pScreen->UninstallColormap = vgaUninstallColormap;
- pScreen->ListInstalledColormaps = vgaListInstalledColormaps;
- pScreen->StoreColors = vgaStoreColors;
- }
- }
-}
-
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Roell makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "windowstr.h"
+#include "compiler.h"
+#include "mipointer.h"
+#include "micmap.h"
+
+#include "xf86.h"
+#include "vgaHW.h"
+
+#include <X11/extensions/xf86dgaproto.h>
+#include "dgaproc.h"
+
+#define NOMAPYET (ColormapPtr) 0
+
+int
+vgaListInstalledColormaps(pScreen, pmaps)
+ScreenPtr pScreen;
+Colormap *pmaps;
+{
+ /* By the time we are processing requests, we can guarantee that there
+ * is always a colormap installed */
+
+ *pmaps = GetInstalledmiColormap(pScreen)->mid;
+ return 1;
+}
+
+int
+vgaGetInstalledColormaps(pScreen, pmaps)
+ScreenPtr pScreen;
+ColormapPtr *pmaps;
+{
+ /* By the time we are processing requests, we can guarantee that there
+ * is always a colormap installed */
+
+ *pmaps = GetInstalledmiColormap(pScreen);
+ return 1;
+}
+
+int
+vgaCheckColorMap(ColormapPtr pmap)
+{
+ return (pmap != GetInstalledmiColormap(pmap->pScreen));
+}
+
+void
+vgaStoreColors(pmap, ndef, pdefs)
+ColormapPtr pmap;
+int ndef;
+xColorItem *pdefs;
+{
+ int i;
+ unsigned char *cmap, *tmp = NULL;
+ xColorItem directDefs[256];
+ Bool new_overscan = FALSE;
+ Bool writeColormap;
+
+ /* This can get called before the ScrnInfoRec is installed so we
+ can't rely on getting it with XF86SCRNINFO() */
+ int scrnIndex = pmap->pScreen->myNum;
+ ScrnInfoPtr scrninfp = xf86Screens[scrnIndex];
+ vgaHWPtr hwp = VGAHWPTR(scrninfp);
+
+ unsigned char overscan = hwp->ModeReg.Attribute[OVERSCAN];
+ unsigned char tmp_overscan = 0;
+
+ if (vgaCheckColorMap(pmap))
+ return;
+
+ if ((pmap->pVisual->class | DynamicClass) == DirectColor) {
+ ndef = miExpandDirectColors(pmap, ndef, pdefs, directDefs);
+ pdefs = directDefs;
+ }
+
+ writeColormap = scrninfp->vtSema;
+ if (DGAAvailable(scrnIndex)) {
+ writeColormap = writeColormap ||
+ (DGAGetDirectMode(scrnIndex) &&
+ !(DGAGetFlags(scrnIndex) & XF86DGADirectColormap)) ||
+ (DGAGetFlags(scrnIndex) & XF86DGAHasColormap);
+ }
+
+ if (writeColormap)
+ hwp->enablePalette(hwp);
+
+ for (i = 0; i < ndef; i++) {
+ if (pdefs[i].pixel == overscan) {
+ new_overscan = TRUE;
+ }
+ cmap = &(hwp->ModeReg.DAC[pdefs[i].pixel * 3]);
+ if (scrninfp->rgbBits == 8) {
+ cmap[0] = pdefs[i].red >> 8;
+ cmap[1] = pdefs[i].green >> 8;
+ cmap[2] = pdefs[i].blue >> 8;
+ }
+ else {
+ cmap[0] = pdefs[i].red >> 10;
+ cmap[1] = pdefs[i].green >> 10;
+ cmap[2] = pdefs[i].blue >> 10;
+ }
+#if 0
+ if (clgd6225Lcd) {
+ /* The LCD doesn't like white */
+ if (cmap[0] == 63)
+ cmap[0] = 62;
+ if (cmap[1] == 63)
+ cmap[1] = 62;
+ if (cmap[2] == 63)
+ cmap[2] = 62;
+ }
+#endif
+
+ if (writeColormap) {
+ if (hwp->ShowOverscan && i == 255)
+ continue;
+ hwp->writeDacWriteAddr(hwp, pdefs[i].pixel);
+ DACDelay(hwp);
+ hwp->writeDacData(hwp, cmap[0]);
+ DACDelay(hwp);
+ hwp->writeDacData(hwp, cmap[1]);
+ DACDelay(hwp);
+ hwp->writeDacData(hwp, cmap[2]);
+ DACDelay(hwp);
+ }
+ }
+ if (new_overscan && !hwp->ShowOverscan) {
+ new_overscan = FALSE;
+ for (i = 0; i < ndef; i++) {
+ if (pdefs[i].pixel == overscan) {
+ if ((pdefs[i].red != 0) ||
+ (pdefs[i].green != 0) || (pdefs[i].blue != 0)) {
+ new_overscan = TRUE;
+ tmp_overscan = overscan;
+ tmp = &(hwp->ModeReg.DAC[pdefs[i].pixel * 3]);
+ }
+ break;
+ }
+ }
+ if (new_overscan) {
+ /*
+ * Find a black pixel, or the nearest match.
+ */
+ for (i = 255; i >= 0; i--) {
+ cmap = &(hwp->ModeReg.DAC[i * 3]);
+ if ((cmap[0] == 0) && (cmap[1] == 0) && (cmap[2] == 0)) {
+ overscan = i;
+ break;
+ }
+ else {
+ if ((cmap[0] < tmp[0]) &&
+ (cmap[1] < tmp[1]) && (cmap[2] < tmp[2])) {
+ tmp = cmap;
+ tmp_overscan = i;
+ }
+ }
+ }
+ if (i < 0) {
+ overscan = tmp_overscan;
+ }
+ hwp->ModeReg.Attribute[OVERSCAN] = overscan;
+ if (writeColormap) {
+ hwp->writeAttr(hwp, OVERSCAN, overscan);
+ }
+ }
+ }
+
+ if (writeColormap)
+ hwp->disablePalette(hwp);
+}
+
+void
+vgaInstallColormap(pmap)
+ColormapPtr pmap;
+{
+ ColormapPtr oldmap = GetInstalledmiColormap(pmap->pScreen);
+ int entries;
+ Pixel *ppix;
+ xrgb *prgb;
+ xColorItem *defs;
+ int i;
+
+ if (pmap == oldmap)
+ return;
+
+ if ((pmap->pVisual->class | DynamicClass) == DirectColor)
+ entries = (pmap->pVisual->redMask |
+ pmap->pVisual->greenMask | pmap->pVisual->blueMask) + 1;
+ else
+ entries = pmap->pVisual->ColormapEntries;
+
+ ppix = (Pixel *) malloc(entries * sizeof(Pixel));
+ prgb = (xrgb *) malloc(entries * sizeof(xrgb));
+ defs = (xColorItem *) malloc(entries * sizeof(xColorItem));
+
+ if (oldmap != NOMAPYET)
+ WalkTree(pmap->pScreen, TellLostMap, &oldmap->mid);
+
+ SetInstalledmiColormap(pmap->pScreen, pmap);
+
+ for (i = 0; i < entries; i++)
+ ppix[i] = i;
+
+ QueryColors(pmap, entries, ppix, prgb, serverClient);
+
+ for (i = 0; i < entries; i++) { /* convert xrgbs to xColorItems */
+ defs[i].pixel = ppix[i];
+ defs[i].red = prgb[i].red;
+ defs[i].green = prgb[i].green;
+ defs[i].blue = prgb[i].blue;
+ defs[i].flags = DoRed | DoGreen | DoBlue;
+ }
+ pmap->pScreen->StoreColors(pmap, entries, defs);
+
+ WalkTree(pmap->pScreen, TellGainedMap, &pmap->mid);
+
+ free(ppix);
+ free(prgb);
+ free(defs);
+}
+
+void
+vgaUninstallColormap(pmap)
+ColormapPtr pmap;
+{
+
+ ColormapPtr defColormap;
+
+ if (pmap != GetInstalledmiColormap(pmap->pScreen))
+ return;
+
+ dixLookupResourceByType((pointer *) &defColormap,
+ pmap->pScreen->defColormap, RT_COLORMAP,
+ serverClient, DixInstallAccess);
+
+ if (defColormap == GetInstalledmiColormap(pmap->pScreen))
+ return;
+
+ (*pmap->pScreen->InstallColormap) (defColormap);
+}
+
+void
+vgaHandleColormaps(ScreenPtr pScreen, ScrnInfoPtr scrnp)
+{
+ if (scrnp->bitsPerPixel > 1) {
+ if (scrnp->bitsPerPixel <= 8) { /* For 8bpp SVGA and VGA16 */
+ pScreen->InstallColormap = vgaInstallColormap;
+ pScreen->UninstallColormap = vgaUninstallColormap;
+ pScreen->ListInstalledColormaps = vgaListInstalledColormaps;
+ pScreen->StoreColors = vgaStoreColors;
+ }
+ }
+}
diff --git a/xorg-server/hw/xfree86/vgahw/vgaHW.c b/xorg-server/hw/xfree86/vgahw/vgaHW.c
index 4036a01f5..e044682c7 100644
--- a/xorg-server/hw/xfree86/vgahw/vgaHW.c
+++ b/xorg-server/hw/xfree86/vgahw/vgaHW.c
@@ -75,7 +75,6 @@
#define BLACK_VALUE 0x00
#define OVERSCAN_VALUE 0x01
-
/* Use a private definition of this here */
#undef VGAHWPTR
#define VGAHWPTRLVAL(p) (p)->privates[vgaHWPrivateIndex].ptr
@@ -88,74 +87,73 @@ static int vgaHWPrivateIndex = -1;
#ifdef NEED_SAVED_CMAP
/* This default colourmap is used only when it can't be read from the VGA */
-static CARD8 defaultDAC[768] =
-{
- 0, 0, 0, 0, 0, 42, 0, 42, 0, 0, 42, 42,
- 42, 0, 0, 42, 0, 42, 42, 21, 0, 42, 42, 42,
- 21, 21, 21, 21, 21, 63, 21, 63, 21, 21, 63, 63,
- 63, 21, 21, 63, 21, 63, 63, 63, 21, 63, 63, 63,
- 0, 0, 0, 5, 5, 5, 8, 8, 8, 11, 11, 11,
- 14, 14, 14, 17, 17, 17, 20, 20, 20, 24, 24, 24,
- 28, 28, 28, 32, 32, 32, 36, 36, 36, 40, 40, 40,
- 45, 45, 45, 50, 50, 50, 56, 56, 56, 63, 63, 63,
- 0, 0, 63, 16, 0, 63, 31, 0, 63, 47, 0, 63,
- 63, 0, 63, 63, 0, 47, 63, 0, 31, 63, 0, 16,
- 63, 0, 0, 63, 16, 0, 63, 31, 0, 63, 47, 0,
- 63, 63, 0, 47, 63, 0, 31, 63, 0, 16, 63, 0,
- 0, 63, 0, 0, 63, 16, 0, 63, 31, 0, 63, 47,
- 0, 63, 63, 0, 47, 63, 0, 31, 63, 0, 16, 63,
- 31, 31, 63, 39, 31, 63, 47, 31, 63, 55, 31, 63,
- 63, 31, 63, 63, 31, 55, 63, 31, 47, 63, 31, 39,
- 63, 31, 31, 63, 39, 31, 63, 47, 31, 63, 55, 31,
- 63, 63, 31, 55, 63, 31, 47, 63, 31, 39, 63, 31,
- 31, 63, 31, 31, 63, 39, 31, 63, 47, 31, 63, 55,
- 31, 63, 63, 31, 55, 63, 31, 47, 63, 31, 39, 63,
- 45, 45, 63, 49, 45, 63, 54, 45, 63, 58, 45, 63,
- 63, 45, 63, 63, 45, 58, 63, 45, 54, 63, 45, 49,
- 63, 45, 45, 63, 49, 45, 63, 54, 45, 63, 58, 45,
- 63, 63, 45, 58, 63, 45, 54, 63, 45, 49, 63, 45,
- 45, 63, 45, 45, 63, 49, 45, 63, 54, 45, 63, 58,
- 45, 63, 63, 45, 58, 63, 45, 54, 63, 45, 49, 63,
- 0, 0, 28, 7, 0, 28, 14, 0, 28, 21, 0, 28,
- 28, 0, 28, 28, 0, 21, 28, 0, 14, 28, 0, 7,
- 28, 0, 0, 28, 7, 0, 28, 14, 0, 28, 21, 0,
- 28, 28, 0, 21, 28, 0, 14, 28, 0, 7, 28, 0,
- 0, 28, 0, 0, 28, 7, 0, 28, 14, 0, 28, 21,
- 0, 28, 28, 0, 21, 28, 0, 14, 28, 0, 7, 28,
- 14, 14, 28, 17, 14, 28, 21, 14, 28, 24, 14, 28,
- 28, 14, 28, 28, 14, 24, 28, 14, 21, 28, 14, 17,
- 28, 14, 14, 28, 17, 14, 28, 21, 14, 28, 24, 14,
- 28, 28, 14, 24, 28, 14, 21, 28, 14, 17, 28, 14,
- 14, 28, 14, 14, 28, 17, 14, 28, 21, 14, 28, 24,
- 14, 28, 28, 14, 24, 28, 14, 21, 28, 14, 17, 28,
- 20, 20, 28, 22, 20, 28, 24, 20, 28, 26, 20, 28,
- 28, 20, 28, 28, 20, 26, 28, 20, 24, 28, 20, 22,
- 28, 20, 20, 28, 22, 20, 28, 24, 20, 28, 26, 20,
- 28, 28, 20, 26, 28, 20, 24, 28, 20, 22, 28, 20,
- 20, 28, 20, 20, 28, 22, 20, 28, 24, 20, 28, 26,
- 20, 28, 28, 20, 26, 28, 20, 24, 28, 20, 22, 28,
- 0, 0, 16, 4, 0, 16, 8, 0, 16, 12, 0, 16,
- 16, 0, 16, 16, 0, 12, 16, 0, 8, 16, 0, 4,
- 16, 0, 0, 16, 4, 0, 16, 8, 0, 16, 12, 0,
- 16, 16, 0, 12, 16, 0, 8, 16, 0, 4, 16, 0,
- 0, 16, 0, 0, 16, 4, 0, 16, 8, 0, 16, 12,
- 0, 16, 16, 0, 12, 16, 0, 8, 16, 0, 4, 16,
- 8, 8, 16, 10, 8, 16, 12, 8, 16, 14, 8, 16,
- 16, 8, 16, 16, 8, 14, 16, 8, 12, 16, 8, 10,
- 16, 8, 8, 16, 10, 8, 16, 12, 8, 16, 14, 8,
- 16, 16, 8, 14, 16, 8, 12, 16, 8, 10, 16, 8,
- 8, 16, 8, 8, 16, 10, 8, 16, 12, 8, 16, 14,
- 8, 16, 16, 8, 14, 16, 8, 12, 16, 8, 10, 16,
- 11, 11, 16, 12, 11, 16, 13, 11, 16, 15, 11, 16,
- 16, 11, 16, 16, 11, 15, 16, 11, 13, 16, 11, 12,
- 16, 11, 11, 16, 12, 11, 16, 13, 11, 16, 15, 11,
- 16, 16, 11, 15, 16, 11, 13, 16, 11, 12, 16, 11,
- 11, 16, 11, 11, 16, 12, 11, 16, 13, 11, 16, 15,
- 11, 16, 16, 11, 15, 16, 11, 13, 16, 11, 12, 16,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+static CARD8 defaultDAC[768] = {
+ 0, 0, 0, 0, 0, 42, 0, 42, 0, 0, 42, 42,
+ 42, 0, 0, 42, 0, 42, 42, 21, 0, 42, 42, 42,
+ 21, 21, 21, 21, 21, 63, 21, 63, 21, 21, 63, 63,
+ 63, 21, 21, 63, 21, 63, 63, 63, 21, 63, 63, 63,
+ 0, 0, 0, 5, 5, 5, 8, 8, 8, 11, 11, 11,
+ 14, 14, 14, 17, 17, 17, 20, 20, 20, 24, 24, 24,
+ 28, 28, 28, 32, 32, 32, 36, 36, 36, 40, 40, 40,
+ 45, 45, 45, 50, 50, 50, 56, 56, 56, 63, 63, 63,
+ 0, 0, 63, 16, 0, 63, 31, 0, 63, 47, 0, 63,
+ 63, 0, 63, 63, 0, 47, 63, 0, 31, 63, 0, 16,
+ 63, 0, 0, 63, 16, 0, 63, 31, 0, 63, 47, 0,
+ 63, 63, 0, 47, 63, 0, 31, 63, 0, 16, 63, 0,
+ 0, 63, 0, 0, 63, 16, 0, 63, 31, 0, 63, 47,
+ 0, 63, 63, 0, 47, 63, 0, 31, 63, 0, 16, 63,
+ 31, 31, 63, 39, 31, 63, 47, 31, 63, 55, 31, 63,
+ 63, 31, 63, 63, 31, 55, 63, 31, 47, 63, 31, 39,
+ 63, 31, 31, 63, 39, 31, 63, 47, 31, 63, 55, 31,
+ 63, 63, 31, 55, 63, 31, 47, 63, 31, 39, 63, 31,
+ 31, 63, 31, 31, 63, 39, 31, 63, 47, 31, 63, 55,
+ 31, 63, 63, 31, 55, 63, 31, 47, 63, 31, 39, 63,
+ 45, 45, 63, 49, 45, 63, 54, 45, 63, 58, 45, 63,
+ 63, 45, 63, 63, 45, 58, 63, 45, 54, 63, 45, 49,
+ 63, 45, 45, 63, 49, 45, 63, 54, 45, 63, 58, 45,
+ 63, 63, 45, 58, 63, 45, 54, 63, 45, 49, 63, 45,
+ 45, 63, 45, 45, 63, 49, 45, 63, 54, 45, 63, 58,
+ 45, 63, 63, 45, 58, 63, 45, 54, 63, 45, 49, 63,
+ 0, 0, 28, 7, 0, 28, 14, 0, 28, 21, 0, 28,
+ 28, 0, 28, 28, 0, 21, 28, 0, 14, 28, 0, 7,
+ 28, 0, 0, 28, 7, 0, 28, 14, 0, 28, 21, 0,
+ 28, 28, 0, 21, 28, 0, 14, 28, 0, 7, 28, 0,
+ 0, 28, 0, 0, 28, 7, 0, 28, 14, 0, 28, 21,
+ 0, 28, 28, 0, 21, 28, 0, 14, 28, 0, 7, 28,
+ 14, 14, 28, 17, 14, 28, 21, 14, 28, 24, 14, 28,
+ 28, 14, 28, 28, 14, 24, 28, 14, 21, 28, 14, 17,
+ 28, 14, 14, 28, 17, 14, 28, 21, 14, 28, 24, 14,
+ 28, 28, 14, 24, 28, 14, 21, 28, 14, 17, 28, 14,
+ 14, 28, 14, 14, 28, 17, 14, 28, 21, 14, 28, 24,
+ 14, 28, 28, 14, 24, 28, 14, 21, 28, 14, 17, 28,
+ 20, 20, 28, 22, 20, 28, 24, 20, 28, 26, 20, 28,
+ 28, 20, 28, 28, 20, 26, 28, 20, 24, 28, 20, 22,
+ 28, 20, 20, 28, 22, 20, 28, 24, 20, 28, 26, 20,
+ 28, 28, 20, 26, 28, 20, 24, 28, 20, 22, 28, 20,
+ 20, 28, 20, 20, 28, 22, 20, 28, 24, 20, 28, 26,
+ 20, 28, 28, 20, 26, 28, 20, 24, 28, 20, 22, 28,
+ 0, 0, 16, 4, 0, 16, 8, 0, 16, 12, 0, 16,
+ 16, 0, 16, 16, 0, 12, 16, 0, 8, 16, 0, 4,
+ 16, 0, 0, 16, 4, 0, 16, 8, 0, 16, 12, 0,
+ 16, 16, 0, 12, 16, 0, 8, 16, 0, 4, 16, 0,
+ 0, 16, 0, 0, 16, 4, 0, 16, 8, 0, 16, 12,
+ 0, 16, 16, 0, 12, 16, 0, 8, 16, 0, 4, 16,
+ 8, 8, 16, 10, 8, 16, 12, 8, 16, 14, 8, 16,
+ 16, 8, 16, 16, 8, 14, 16, 8, 12, 16, 8, 10,
+ 16, 8, 8, 16, 10, 8, 16, 12, 8, 16, 14, 8,
+ 16, 16, 8, 14, 16, 8, 12, 16, 8, 10, 16, 8,
+ 8, 16, 8, 8, 16, 10, 8, 16, 12, 8, 16, 14,
+ 8, 16, 16, 8, 14, 16, 8, 12, 16, 8, 10, 16,
+ 11, 11, 16, 12, 11, 16, 13, 11, 16, 15, 11, 16,
+ 16, 11, 16, 16, 11, 15, 16, 11, 13, 16, 11, 12,
+ 16, 11, 11, 16, 12, 11, 16, 13, 11, 16, 15, 11,
+ 16, 16, 11, 15, 16, 11, 13, 16, 11, 12, 16, 11,
+ 11, 16, 11, 11, 16, 12, 11, 16, 13, 11, 16, 15,
+ 11, 16, 16, 11, 15, 16, 11, 13, 16, 11, 12, 16,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
-#endif /* NEED_SAVED_CMAP */
+#endif /* NEED_SAVED_CMAP */
/*
* Standard VGA versions of the register access functions.
@@ -223,16 +221,16 @@ stdReadFCR(vgaHWPtr hwp)
static void
stdWriteFCR(vgaHWPtr hwp, CARD8 value)
{
- pci_io_write8(hwp->io, hwp->IOBase + VGA_FEATURE_W_OFFSET,value);
+ pci_io_write8(hwp->io, hwp->IOBase + VGA_FEATURE_W_OFFSET, value);
}
static void
stdWriteAttr(vgaHWPtr hwp, CARD8 index, CARD8 value)
{
if (hwp->paletteEnabled)
- index &= ~0x20;
+ index &= ~0x20;
else
- index |= 0x20;
+ index |= 0x20;
(void) pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET);
pci_io_write8(hwp->io, VGA_ATTR_INDEX, index);
@@ -243,9 +241,9 @@ static CARD8
stdReadAttr(vgaHWPtr hwp, CARD8 index)
{
if (hwp->paletteEnabled)
- index &= ~0x20;
+ index &= ~0x20;
else
- index |= 0x20;
+ index |= 0x20;
(void) pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET);
pci_io_write8(hwp->io, VGA_ATTR_INDEX, index);
@@ -331,30 +329,30 @@ stdWriteEnable(vgaHWPtr hwp, CARD8 value)
void
vgaHWSetStdFuncs(vgaHWPtr hwp)
{
- hwp->writeCrtc = stdWriteCrtc;
- hwp->readCrtc = stdReadCrtc;
- hwp->writeGr = stdWriteGr;
- hwp->readGr = stdReadGr;
- hwp->readST00 = stdReadST00;
- hwp->readST01 = stdReadST01;
- hwp->readFCR = stdReadFCR;
- hwp->writeFCR = stdWriteFCR;
- hwp->writeAttr = stdWriteAttr;
- hwp->readAttr = stdReadAttr;
- hwp->writeSeq = stdWriteSeq;
- hwp->readSeq = stdReadSeq;
- hwp->writeMiscOut = stdWriteMiscOut;
- hwp->readMiscOut = stdReadMiscOut;
- hwp->enablePalette = stdEnablePalette;
- hwp->disablePalette = stdDisablePalette;
- hwp->writeDacMask = stdWriteDacMask;
- hwp->readDacMask = stdReadDacMask;
- hwp->writeDacWriteAddr = stdWriteDacWriteAddr;
- hwp->writeDacReadAddr = stdWriteDacReadAddr;
- hwp->writeDacData = stdWriteDacData;
- hwp->readDacData = stdReadDacData;
- hwp->readEnable = stdReadEnable;
- hwp->writeEnable = stdWriteEnable;
+ hwp->writeCrtc = stdWriteCrtc;
+ hwp->readCrtc = stdReadCrtc;
+ hwp->writeGr = stdWriteGr;
+ hwp->readGr = stdReadGr;
+ hwp->readST00 = stdReadST00;
+ hwp->readST01 = stdReadST01;
+ hwp->readFCR = stdReadFCR;
+ hwp->writeFCR = stdWriteFCR;
+ hwp->writeAttr = stdWriteAttr;
+ hwp->readAttr = stdReadAttr;
+ hwp->writeSeq = stdWriteSeq;
+ hwp->readSeq = stdReadSeq;
+ hwp->writeMiscOut = stdWriteMiscOut;
+ hwp->readMiscOut = stdReadMiscOut;
+ hwp->enablePalette = stdEnablePalette;
+ hwp->disablePalette = stdDisablePalette;
+ hwp->writeDacMask = stdWriteDacMask;
+ hwp->readDacMask = stdReadDacMask;
+ hwp->writeDacWriteAddr = stdWriteDacWriteAddr;
+ hwp->writeDacReadAddr = stdWriteDacReadAddr;
+ hwp->writeDacData = stdWriteDacData;
+ hwp->readDacData = stdReadDacData;
+ hwp->readEnable = stdReadEnable;
+ hwp->writeEnable = stdWriteEnable;
hwp->io = pci_legacy_open_io(hwp->dev, 0, 64 * 1024);
}
@@ -431,16 +429,16 @@ mmioReadFCR(vgaHWPtr hwp)
static void
mmioWriteFCR(vgaHWPtr hwp, CARD8 value)
{
- moutb(hwp->IOBase + VGA_FEATURE_W_OFFSET,value);
+ moutb(hwp->IOBase + VGA_FEATURE_W_OFFSET, value);
}
static void
mmioWriteAttr(vgaHWPtr hwp, CARD8 index, CARD8 value)
{
if (hwp->paletteEnabled)
- index &= ~0x20;
+ index &= ~0x20;
else
- index |= 0x20;
+ index |= 0x20;
(void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET);
moutb(VGA_ATTR_INDEX, index);
@@ -451,9 +449,9 @@ static CARD8
mmioReadAttr(vgaHWPtr hwp, CARD8 index)
{
if (hwp->paletteEnabled)
- index &= ~0x20;
+ index &= ~0x20;
else
- index |= 0x20;
+ index |= 0x20;
(void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET);
moutb(VGA_ATTR_INDEX, index);
@@ -539,32 +537,32 @@ mmioWriteEnable(vgaHWPtr hwp, CARD8 value)
void
vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset)
{
- hwp->writeCrtc = mmioWriteCrtc;
- hwp->readCrtc = mmioReadCrtc;
- hwp->writeGr = mmioWriteGr;
- hwp->readGr = mmioReadGr;
- hwp->readST00 = mmioReadST00;
- hwp->readST01 = mmioReadST01;
- hwp->readFCR = mmioReadFCR;
- hwp->writeFCR = mmioWriteFCR;
- hwp->writeAttr = mmioWriteAttr;
- hwp->readAttr = mmioReadAttr;
- hwp->writeSeq = mmioWriteSeq;
- hwp->readSeq = mmioReadSeq;
- hwp->writeMiscOut = mmioWriteMiscOut;
- hwp->readMiscOut = mmioReadMiscOut;
- hwp->enablePalette = mmioEnablePalette;
- hwp->disablePalette = mmioDisablePalette;
- hwp->writeDacMask = mmioWriteDacMask;
- hwp->readDacMask = mmioReadDacMask;
- hwp->writeDacWriteAddr = mmioWriteDacWriteAddr;
- hwp->writeDacReadAddr = mmioWriteDacReadAddr;
- hwp->writeDacData = mmioWriteDacData;
- hwp->readDacData = mmioReadDacData;
- hwp->MMIOBase = base;
- hwp->MMIOOffset = offset;
- hwp->readEnable = mmioReadEnable;
- hwp->writeEnable = mmioWriteEnable;
+ hwp->writeCrtc = mmioWriteCrtc;
+ hwp->readCrtc = mmioReadCrtc;
+ hwp->writeGr = mmioWriteGr;
+ hwp->readGr = mmioReadGr;
+ hwp->readST00 = mmioReadST00;
+ hwp->readST01 = mmioReadST01;
+ hwp->readFCR = mmioReadFCR;
+ hwp->writeFCR = mmioWriteFCR;
+ hwp->writeAttr = mmioWriteAttr;
+ hwp->readAttr = mmioReadAttr;
+ hwp->writeSeq = mmioWriteSeq;
+ hwp->readSeq = mmioReadSeq;
+ hwp->writeMiscOut = mmioWriteMiscOut;
+ hwp->readMiscOut = mmioReadMiscOut;
+ hwp->enablePalette = mmioEnablePalette;
+ hwp->disablePalette = mmioDisablePalette;
+ hwp->writeDacMask = mmioWriteDacMask;
+ hwp->readDacMask = mmioReadDacMask;
+ hwp->writeDacWriteAddr = mmioWriteDacWriteAddr;
+ hwp->writeDacReadAddr = mmioWriteDacReadAddr;
+ hwp->writeDacData = mmioWriteDacData;
+ hwp->readDacData = mmioReadDacData;
+ hwp->MMIOBase = base;
+ hwp->MMIOOffset = offset;
+ hwp->readEnable = mmioReadEnable;
+ hwp->writeEnable = mmioWriteEnable;
}
/*
@@ -575,38 +573,41 @@ vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset)
void
vgaHWProtect(ScrnInfoPtr pScrn, Bool on)
{
- vgaHWPtr hwp = VGAHWPTR(pScrn);
-
- unsigned char tmp;
-
- if (pScrn->vtSema) {
- if (on) {
- /*
- * Turn off screen and disable sequencer.
- */
- tmp = hwp->readSeq(hwp, 0x01);
-
- vgaHWSeqReset(hwp, TRUE); /* start synchronous reset */
- hwp->writeSeq(hwp, 0x01, tmp | 0x20); /* disable the display */
-
- hwp->enablePalette(hwp);
- } else {
- /*
- * Reenable sequencer, then turn on screen.
- */
-
- tmp = hwp->readSeq(hwp, 0x01);
-
- hwp->writeSeq(hwp, 0x01, tmp & ~0x20); /* reenable display */
- vgaHWSeqReset(hwp, FALSE); /* clear synchronousreset */
-
- hwp->disablePalette(hwp);
+ vgaHWPtr hwp = VGAHWPTR(pScrn);
+
+ unsigned char tmp;
+
+ if (pScrn->vtSema) {
+ if (on) {
+ /*
+ * Turn off screen and disable sequencer.
+ */
+ tmp = hwp->readSeq(hwp, 0x01);
+
+ vgaHWSeqReset(hwp, TRUE); /* start synchronous reset */
+ hwp->writeSeq(hwp, 0x01, tmp | 0x20); /* disable the display */
+
+ hwp->enablePalette(hwp);
+ }
+ else {
+ /*
+ * Reenable sequencer, then turn on screen.
+ */
+
+ tmp = hwp->readSeq(hwp, 0x01);
+
+ hwp->writeSeq(hwp, 0x01, tmp & ~0x20); /* reenable display */
+ vgaHWSeqReset(hwp, FALSE); /* clear synchronousreset */
+
+ hwp->disablePalette(hwp);
+ }
}
- }
}
-vgaHWProtectProc *vgaHWProtectWeak(void) {
- return vgaHWProtect;
+vgaHWProtectProc *
+vgaHWProtectWeak(void)
+{
+ return vgaHWProtect;
}
/*
@@ -616,25 +617,28 @@ vgaHWProtectProc *vgaHWProtectWeak(void) {
void
vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on)
{
- vgaHWPtr hwp = VGAHWPTR(pScrn);
- unsigned char scrn;
+ vgaHWPtr hwp = VGAHWPTR(pScrn);
+ unsigned char scrn;
- scrn = hwp->readSeq(hwp, 0x01);
+ scrn = hwp->readSeq(hwp, 0x01);
- if (on) {
- scrn &= ~0x20; /* enable screen */
- } else {
- scrn |= 0x20; /* blank screen */
- }
+ if (on) {
+ scrn &= ~0x20; /* enable screen */
+ }
+ else {
+ scrn |= 0x20; /* blank screen */
+ }
- vgaHWSeqReset(hwp, TRUE);
- hwp->writeSeq(hwp, 0x01, scrn); /* change mode */
- vgaHWSeqReset(hwp, FALSE);
+ vgaHWSeqReset(hwp, TRUE);
+ hwp->writeSeq(hwp, 0x01, scrn); /* change mode */
+ vgaHWSeqReset(hwp, FALSE);
}
-vgaHWBlankScreenProc *vgaHWBlankScreenWeak(void) {
- return vgaHWBlankScreen;
-}
+vgaHWBlankScreenProc *
+vgaHWBlankScreenWeak(void)
+{
+ return vgaHWBlankScreen;
+}
/*
* vgaHWSaveScreen -- blank the screen.
@@ -643,26 +647,25 @@ vgaHWBlankScreenProc *vgaHWBlankScreenWeak(void) {
Bool
vgaHWSaveScreen(ScreenPtr pScreen, int mode)
{
- ScrnInfoPtr pScrn = NULL;
- Bool on;
+ ScrnInfoPtr pScrn = NULL;
+ Bool on;
- if (pScreen != NULL)
- pScrn = xf86Screens[pScreen->myNum];
+ if (pScreen != NULL)
+ pScrn = xf86Screens[pScreen->myNum];
- on = xf86IsUnblank(mode);
+ on = xf86IsUnblank(mode);
#if 0
- if (on)
- SetTimeSinceLastInputEvent();
+ if (on)
+ SetTimeSinceLastInputEvent();
#endif
- if ((pScrn != NULL) && pScrn->vtSema) {
- vgaHWBlankScreen(pScrn, on);
- }
- return TRUE;
+ if ((pScrn != NULL) && pScrn->vtSema) {
+ vgaHWBlankScreen(pScrn, on);
+ }
+ return TRUE;
}
-
/*
* vgaHWDPMSSet -- Sets VESA Display Power Management Signaling (DPMS) Mode
*
@@ -674,42 +677,42 @@ vgaHWSaveScreen(ScreenPtr pScreen, int mode)
void
vgaHWDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags)
{
- unsigned char seq1 = 0, crtc17 = 0;
- vgaHWPtr hwp = VGAHWPTR(pScrn);
-
- if (!pScrn->vtSema) return;
-
- switch (PowerManagementMode) {
- case DPMSModeOn:
- /* Screen: On; HSync: On, VSync: On */
- seq1 = 0x00;
- crtc17 = 0x80;
- break;
- case DPMSModeStandby:
- /* Screen: Off; HSync: Off, VSync: On -- Not Supported */
- seq1 = 0x20;
- crtc17 = 0x80;
- break;
- case DPMSModeSuspend:
- /* Screen: Off; HSync: On, VSync: Off -- Not Supported */
- seq1 = 0x20;
- crtc17 = 0x80;
- break;
- case DPMSModeOff:
- /* Screen: Off; HSync: Off, VSync: Off */
- seq1 = 0x20;
- crtc17 = 0x00;
- break;
- }
- hwp->writeSeq(hwp, 0x00, 0x01); /* Synchronous Reset */
- seq1 |= hwp->readSeq(hwp, 0x01) & ~0x20;
- hwp->writeSeq(hwp, 0x01, seq1);
- crtc17 |= hwp->readCrtc(hwp, 0x17) & ~0x80;
- usleep(10000);
- hwp->writeCrtc(hwp, 0x17, crtc17);
- hwp->writeSeq(hwp, 0x00, 0x03); /* End Reset */
-}
+ unsigned char seq1 = 0, crtc17 = 0;
+ vgaHWPtr hwp = VGAHWPTR(pScrn);
+ if (!pScrn->vtSema)
+ return;
+
+ switch (PowerManagementMode) {
+ case DPMSModeOn:
+ /* Screen: On; HSync: On, VSync: On */
+ seq1 = 0x00;
+ crtc17 = 0x80;
+ break;
+ case DPMSModeStandby:
+ /* Screen: Off; HSync: Off, VSync: On -- Not Supported */
+ seq1 = 0x20;
+ crtc17 = 0x80;
+ break;
+ case DPMSModeSuspend:
+ /* Screen: Off; HSync: On, VSync: Off -- Not Supported */
+ seq1 = 0x20;
+ crtc17 = 0x80;
+ break;
+ case DPMSModeOff:
+ /* Screen: Off; HSync: Off, VSync: Off */
+ seq1 = 0x20;
+ crtc17 = 0x00;
+ break;
+ }
+ hwp->writeSeq(hwp, 0x00, 0x01); /* Synchronous Reset */
+ seq1 |= hwp->readSeq(hwp, 0x01) & ~0x20;
+ hwp->writeSeq(hwp, 0x01, seq1);
+ crtc17 |= hwp->readCrtc(hwp, 0x17) & ~0x80;
+ usleep(10000);
+ hwp->writeCrtc(hwp, 0x17, crtc17);
+ hwp->writeSeq(hwp, 0x00, 0x03); /* End Reset */
+}
/*
* vgaHWSeqReset
@@ -719,13 +722,12 @@ vgaHWDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags)
void
vgaHWSeqReset(vgaHWPtr hwp, Bool start)
{
- if (start)
- hwp->writeSeq(hwp, 0x00, 0x01); /* Synchronous Reset */
- else
- hwp->writeSeq(hwp, 0x00, 0x03); /* End Reset */
+ if (start)
+ hwp->writeSeq(hwp, 0x00, 0x01); /* Synchronous Reset */
+ else
+ hwp->writeSeq(hwp, 0x00, 0x03); /* End Reset */
}
-
void
vgaHWRestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore)
{
@@ -737,15 +739,15 @@ vgaHWRestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore)
/* If nothing to do, return now */
if (!hwp->FontInfo1 && !hwp->FontInfo2 && !hwp->TextInfo)
- return;
+ return;
if (hwp->Base == NULL) {
- doMap = TRUE;
- if (!vgaHWMapMem(scrninfp)) {
- xf86DrvMsg(scrninfp->scrnIndex, X_ERROR,
- "vgaHWRestoreFonts: vgaHWMapMem() failed\n");
- return;
- }
+ doMap = TRUE;
+ if (!vgaHWMapMem(scrninfp)) {
+ xf86DrvMsg(scrninfp->scrnIndex, X_ERROR,
+ "vgaHWRestoreFonts: vgaHWMapMem() failed\n");
+ return;
+ }
}
/* save the registers that are needed here */
@@ -776,45 +778,45 @@ vgaHWRestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore)
* BUG ALERT: The (S)VGA's segment-select register MUST be set correctly!
*/
#if 0
- hwp->writeAttr(hwp, 0x10, 0x01); /* graphics mode */
+ hwp->writeAttr(hwp, 0x10, 0x01); /* graphics mode */
#endif
- hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
- hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */
- hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
+ hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
+ hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */
+ hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
if (scrninfp->depth == 4) {
- /* GJA */
- hwp->writeGr(hwp, 0x03, 0x00); /* don't rotate, write unmodified */
- hwp->writeGr(hwp, 0x08, 0xFF); /* write all bits in a byte */
- hwp->writeGr(hwp, 0x01, 0x00); /* all planes come from CPU */
+ /* GJA */
+ hwp->writeGr(hwp, 0x03, 0x00); /* don't rotate, write unmodified */
+ hwp->writeGr(hwp, 0x08, 0xFF); /* write all bits in a byte */
+ hwp->writeGr(hwp, 0x01, 0x00); /* all planes come from CPU */
}
#if SAVE_FONT1
if (hwp->FontInfo1) {
- hwp->writeSeq(hwp, 0x02, 0x04); /* write to plane 2 */
- hwp->writeGr(hwp, 0x04, 0x02); /* read plane 2 */
- slowbcopy_tobus(hwp->FontInfo1, hwp->Base, FONT_AMOUNT);
+ hwp->writeSeq(hwp, 0x02, 0x04); /* write to plane 2 */
+ hwp->writeGr(hwp, 0x04, 0x02); /* read plane 2 */
+ slowbcopy_tobus(hwp->FontInfo1, hwp->Base, FONT_AMOUNT);
}
#endif
#if SAVE_FONT2
if (hwp->FontInfo2) {
- hwp->writeSeq(hwp, 0x02, 0x08); /* write to plane 3 */
- hwp->writeGr(hwp, 0x04, 0x03); /* read plane 3 */
- slowbcopy_tobus(hwp->FontInfo2, hwp->Base, FONT_AMOUNT);
+ hwp->writeSeq(hwp, 0x02, 0x08); /* write to plane 3 */
+ hwp->writeGr(hwp, 0x04, 0x03); /* read plane 3 */
+ slowbcopy_tobus(hwp->FontInfo2, hwp->Base, FONT_AMOUNT);
}
#endif
#if SAVE_TEXT
if (hwp->TextInfo) {
- hwp->writeSeq(hwp, 0x02, 0x01); /* write to plane 0 */
- hwp->writeGr(hwp, 0x04, 0x00); /* read plane 0 */
- slowbcopy_tobus(hwp->TextInfo, hwp->Base, TEXT_AMOUNT);
- hwp->writeSeq(hwp, 0x02, 0x02); /* write to plane 1 */
- hwp->writeGr(hwp, 0x04, 0x01); /* read plane 1 */
- slowbcopy_tobus((unsigned char *)hwp->TextInfo + TEXT_AMOUNT,
- hwp->Base, TEXT_AMOUNT);
+ hwp->writeSeq(hwp, 0x02, 0x01); /* write to plane 0 */
+ hwp->writeGr(hwp, 0x04, 0x00); /* read plane 0 */
+ slowbcopy_tobus(hwp->TextInfo, hwp->Base, TEXT_AMOUNT);
+ hwp->writeSeq(hwp, 0x02, 0x02); /* write to plane 1 */
+ hwp->writeGr(hwp, 0x04, 0x01); /* read plane 1 */
+ slowbcopy_tobus((unsigned char *) hwp->TextInfo + TEXT_AMOUNT,
+ hwp->Base, TEXT_AMOUNT);
}
#endif
@@ -834,12 +836,11 @@ vgaHWRestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore)
hwp->IOBase = savedIOBase;
if (doMap)
- vgaHWUnmapMem(scrninfp);
+ vgaHWUnmapMem(scrninfp);
-#endif /* SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2 */
+#endif /* SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2 */
}
-
void
vgaHWRestoreMode(ScrnInfoPtr scrninfp, vgaRegPtr restore)
{
@@ -847,31 +848,30 @@ vgaHWRestoreMode(ScrnInfoPtr scrninfp, vgaRegPtr restore)
int i;
if (restore->MiscOutReg & 0x01)
- hwp->IOBase = VGA_IOBASE_COLOR;
+ hwp->IOBase = VGA_IOBASE_COLOR;
else
- hwp->IOBase = VGA_IOBASE_MONO;
+ hwp->IOBase = VGA_IOBASE_MONO;
hwp->writeMiscOut(hwp, restore->MiscOutReg);
for (i = 1; i < restore->numSequencer; i++)
- hwp->writeSeq(hwp, i, restore->Sequencer[i]);
-
+ hwp->writeSeq(hwp, i, restore->Sequencer[i]);
+
/* Ensure CRTC registers 0-7 are unlocked by clearing bit 7 of CRTC[17] */
hwp->writeCrtc(hwp, 17, restore->CRTC[17] & ~0x80);
for (i = 0; i < restore->numCRTC; i++)
- hwp->writeCrtc(hwp, i, restore->CRTC[i]);
+ hwp->writeCrtc(hwp, i, restore->CRTC[i]);
for (i = 0; i < restore->numGraphics; i++)
- hwp->writeGr(hwp, i, restore->Graphics[i]);
+ hwp->writeGr(hwp, i, restore->Graphics[i]);
hwp->enablePalette(hwp);
for (i = 0; i < restore->numAttribute; i++)
- hwp->writeAttr(hwp, i, restore->Attribute[i]);
+ hwp->writeAttr(hwp, i, restore->Attribute[i]);
hwp->disablePalette(hwp);
}
-
void
vgaHWRestoreColormap(ScrnInfoPtr scrninfp, vgaRegPtr restore)
{
@@ -885,14 +885,13 @@ vgaHWRestoreColormap(ScrnInfoPtr scrninfp, vgaRegPtr restore)
hwp->writeDacMask(hwp, 0xFF);
hwp->writeDacWriteAddr(hwp, 0x00);
for (i = 0; i < 768; i++) {
- hwp->writeDacData(hwp, restore->DAC[i]);
- DACDelay(hwp);
+ hwp->writeDacData(hwp, restore->DAC[i]);
+ DACDelay(hwp);
}
hwp->disablePalette(hwp);
}
-
/*
* vgaHWRestore --
* restore the VGA state
@@ -902,13 +901,13 @@ void
vgaHWRestore(ScrnInfoPtr scrninfp, vgaRegPtr restore, int flags)
{
if (flags & VGA_SR_MODE)
- vgaHWRestoreMode(scrninfp, restore);
+ vgaHWRestoreMode(scrninfp, restore);
if (flags & VGA_SR_FONTS)
- vgaHWRestoreFonts(scrninfp, restore);
+ vgaHWRestoreFonts(scrninfp, restore);
if (flags & VGA_SR_CMAP)
- vgaHWRestoreColormap(scrninfp, restore);
+ vgaHWRestoreColormap(scrninfp, restore);
}
void
@@ -921,18 +920,18 @@ vgaHWSaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save)
Bool doMap = FALSE;
if (hwp->Base == NULL) {
- doMap = TRUE;
- if (!vgaHWMapMem(scrninfp)) {
- xf86DrvMsg(scrninfp->scrnIndex, X_ERROR,
- "vgaHWSaveFonts: vgaHWMapMem() failed\n");
- return;
- }
+ doMap = TRUE;
+ if (!vgaHWMapMem(scrninfp)) {
+ xf86DrvMsg(scrninfp->scrnIndex, X_ERROR,
+ "vgaHWSaveFonts: vgaHWMapMem() failed\n");
+ return;
+ }
}
/* If in graphics mode, don't save anything */
attr10 = hwp->readAttr(hwp, 0x10);
if (attr10 & 0x01)
- return;
+ return;
/* save the registers that are needed here */
miscOut = hwp->readMiscOut(hwp);
@@ -950,7 +949,7 @@ vgaHWSaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save)
hwp->writeMiscOut(hwp, miscOut | 0x01);
vgaHWBlankScreen(scrninfp, FALSE);
-
+
/*
* get the character sets, and text screen if required
*/
@@ -961,38 +960,39 @@ vgaHWSaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save)
* BUG ALERT: The (S)VGA's segment-select register MUST be set correctly!
*/
#if 0
- hwp->writeAttr(hwp, 0x10, 0x01); /* graphics mode */
+ hwp->writeAttr(hwp, 0x10, 0x01); /* graphics mode */
#endif
- hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
- hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */
- hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
+ hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
+ hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */
+ hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
#if SAVE_FONT1
if (hwp->FontInfo1 || (hwp->FontInfo1 = malloc(FONT_AMOUNT))) {
- hwp->writeSeq(hwp, 0x02, 0x04); /* write to plane 2 */
- hwp->writeGr(hwp, 0x04, 0x02); /* read plane 2 */
- slowbcopy_frombus(hwp->Base, hwp->FontInfo1, FONT_AMOUNT);
+ hwp->writeSeq(hwp, 0x02, 0x04); /* write to plane 2 */
+ hwp->writeGr(hwp, 0x04, 0x02); /* read plane 2 */
+ slowbcopy_frombus(hwp->Base, hwp->FontInfo1, FONT_AMOUNT);
}
-#endif /* SAVE_FONT1 */
+#endif /* SAVE_FONT1 */
#if SAVE_FONT2
if (hwp->FontInfo2 || (hwp->FontInfo2 = malloc(FONT_AMOUNT))) {
- hwp->writeSeq(hwp, 0x02, 0x08); /* write to plane 3 */
- hwp->writeGr(hwp, 0x04, 0x03); /* read plane 3 */
- slowbcopy_frombus(hwp->Base, hwp->FontInfo2, FONT_AMOUNT);
+ hwp->writeSeq(hwp, 0x02, 0x08); /* write to plane 3 */
+ hwp->writeGr(hwp, 0x04, 0x03); /* read plane 3 */
+ slowbcopy_frombus(hwp->Base, hwp->FontInfo2, FONT_AMOUNT);
}
-#endif /* SAVE_FONT2 */
+#endif /* SAVE_FONT2 */
#if SAVE_TEXT
if (hwp->TextInfo || (hwp->TextInfo = malloc(2 * TEXT_AMOUNT))) {
- hwp->writeSeq(hwp, 0x02, 0x01); /* write to plane 0 */
- hwp->writeGr(hwp, 0x04, 0x00); /* read plane 0 */
- slowbcopy_frombus(hwp->Base, hwp->TextInfo, TEXT_AMOUNT);
- hwp->writeSeq(hwp, 0x02, 0x02); /* write to plane 1 */
- hwp->writeGr(hwp, 0x04, 0x01); /* read plane 1 */
- slowbcopy_frombus(hwp->Base,
- (unsigned char *)hwp->TextInfo + TEXT_AMOUNT, TEXT_AMOUNT);
+ hwp->writeSeq(hwp, 0x02, 0x01); /* write to plane 0 */
+ hwp->writeGr(hwp, 0x04, 0x00); /* read plane 0 */
+ slowbcopy_frombus(hwp->Base, hwp->TextInfo, TEXT_AMOUNT);
+ hwp->writeSeq(hwp, 0x02, 0x02); /* write to plane 1 */
+ hwp->writeGr(hwp, 0x04, 0x01); /* read plane 1 */
+ slowbcopy_frombus(hwp->Base,
+ (unsigned char *) hwp->TextInfo + TEXT_AMOUNT,
+ TEXT_AMOUNT);
}
-#endif /* SAVE_TEXT */
+#endif /* SAVE_TEXT */
/* Restore clobbered registers */
hwp->writeAttr(hwp, 0x10, attr10);
@@ -1007,9 +1007,9 @@ vgaHWSaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save)
vgaHWBlankScreen(scrninfp, TRUE);
if (doMap)
- vgaHWUnmapMem(scrninfp);
+ vgaHWUnmapMem(scrninfp);
-#endif /* SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2 */
+#endif /* SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2 */
}
void
@@ -1020,34 +1020,33 @@ vgaHWSaveMode(ScrnInfoPtr scrninfp, vgaRegPtr save)
save->MiscOutReg = hwp->readMiscOut(hwp);
if (save->MiscOutReg & 0x01)
- hwp->IOBase = VGA_IOBASE_COLOR;
+ hwp->IOBase = VGA_IOBASE_COLOR;
else
- hwp->IOBase = VGA_IOBASE_MONO;
+ hwp->IOBase = VGA_IOBASE_MONO;
for (i = 0; i < save->numCRTC; i++) {
- save->CRTC[i] = hwp->readCrtc(hwp, i);
- DebugF("CRTC[0x%02x] = 0x%02x\n", i, save->CRTC[i]);
+ save->CRTC[i] = hwp->readCrtc(hwp, i);
+ DebugF("CRTC[0x%02x] = 0x%02x\n", i, save->CRTC[i]);
}
hwp->enablePalette(hwp);
for (i = 0; i < save->numAttribute; i++) {
- save->Attribute[i] = hwp->readAttr(hwp, i);
- DebugF("Attribute[0x%02x] = 0x%02x\n", i, save->Attribute[i]);
+ save->Attribute[i] = hwp->readAttr(hwp, i);
+ DebugF("Attribute[0x%02x] = 0x%02x\n", i, save->Attribute[i]);
}
hwp->disablePalette(hwp);
for (i = 0; i < save->numGraphics; i++) {
- save->Graphics[i] = hwp->readGr(hwp, i);
- DebugF("Graphics[0x%02x] = 0x%02x\n", i, save->Graphics[i]);
+ save->Graphics[i] = hwp->readGr(hwp, i);
+ DebugF("Graphics[0x%02x] = 0x%02x\n", i, save->Graphics[i]);
}
for (i = 1; i < save->numSequencer; i++) {
- save->Sequencer[i] = hwp->readSeq(hwp, i);
- DebugF("Sequencer[0x%02x] = 0x%02x\n", i, save->Sequencer[i]);
+ save->Sequencer[i] = hwp->readSeq(hwp, i);
+ DebugF("Sequencer[0x%02x] = 0x%02x\n", i, save->Sequencer[i]);
}
}
-
void
vgaHWSaveColormap(ScrnInfoPtr scrninfp, vgaRegPtr save)
{
@@ -1067,7 +1066,7 @@ vgaHWSaveColormap(ScrnInfoPtr scrninfp, vgaRegPtr save)
/* Only save it once */
if (hwp->cmapSaved)
- return;
+ return;
#if 0
hwp->enablePalette(hwp);
@@ -1080,17 +1079,17 @@ vgaHWSaveColormap(ScrnInfoPtr scrninfp, vgaRegPtr save)
*/
hwp->writeDacReadAddr(hwp, 0x00);
for (i = 0; i < 6; i++) {
- save->DAC[i] = hwp->readDacData(hwp);
- switch (i % 3) {
- case 0:
- DebugF("DAC[0x%02x] = 0x%02x, ", i / 3, save->DAC[i]);
- break;
- case 1:
- DebugF("0x%02x, ", save->DAC[i]);
- break;
- case 2:
- DebugF("0x%02x\n", save->DAC[i]);
- }
+ save->DAC[i] = hwp->readDacData(hwp);
+ switch (i % 3) {
+ case 0:
+ DebugF("DAC[0x%02x] = 0x%02x, ", i / 3, save->DAC[i]);
+ break;
+ case 1:
+ DebugF("0x%02x, ", save->DAC[i]);
+ break;
+ case 2:
+ DebugF("0x%02x\n", save->DAC[i]);
+ }
}
/*
@@ -1099,40 +1098,41 @@ vgaHWSaveColormap(ScrnInfoPtr scrninfp, vgaRegPtr save)
*/
hwp->writeDacWriteAddr(hwp, 0x01);
for (i = 3; i < 6; i++)
- hwp->writeDacData(hwp, ~save->DAC[i] & DAC_TEST_MASK);
+ hwp->writeDacData(hwp, ~save->DAC[i] & DAC_TEST_MASK);
hwp->writeDacReadAddr(hwp, 0x01);
for (i = 3; i < 6; i++) {
- if (hwp->readDacData(hwp) != (~save->DAC[i] & DAC_TEST_MASK))
- readError = TRUE;
+ if (hwp->readDacData(hwp) != (~save->DAC[i] & DAC_TEST_MASK))
+ readError = TRUE;
}
hwp->writeDacWriteAddr(hwp, 0x01);
for (i = 3; i < 6; i++)
- hwp->writeDacData(hwp, save->DAC[i]);
+ hwp->writeDacData(hwp, save->DAC[i]);
if (readError) {
- /*
- * save the default lookup table
- */
- memmove(save->DAC, defaultDAC, 768);
- xf86DrvMsg(scrninfp->scrnIndex, X_WARNING,
- "Cannot read colourmap from VGA. Will restore with default\n");
- } else {
- /* save the colourmap */
- hwp->writeDacReadAddr(hwp, 0x02);
- for (i = 6; i < 768; i++) {
- save->DAC[i] = hwp->readDacData(hwp);
- DACDelay(hwp);
- switch (i % 3) {
- case 0:
- DebugF("DAC[0x%02x] = 0x%02x, ", i / 3, save->DAC[i]);
- break;
- case 1:
- DebugF("0x%02x, ", save->DAC[i]);
- break;
- case 2:
- DebugF("0x%02x\n", save->DAC[i]);
- }
- }
+ /*
+ * save the default lookup table
+ */
+ memmove(save->DAC, defaultDAC, 768);
+ xf86DrvMsg(scrninfp->scrnIndex, X_WARNING,
+ "Cannot read colourmap from VGA. Will restore with default\n");
+ }
+ else {
+ /* save the colourmap */
+ hwp->writeDacReadAddr(hwp, 0x02);
+ for (i = 6; i < 768; i++) {
+ save->DAC[i] = hwp->readDacData(hwp);
+ DACDelay(hwp);
+ switch (i % 3) {
+ case 0:
+ DebugF("DAC[0x%02x] = 0x%02x, ", i / 3, save->DAC[i]);
+ break;
+ case 1:
+ DebugF("0x%02x, ", save->DAC[i]);
+ break;
+ case 2:
+ DebugF("0x%02x\n", save->DAC[i]);
+ }
+ }
}
hwp->disablePalette(hwp);
@@ -1149,19 +1149,18 @@ void
vgaHWSave(ScrnInfoPtr scrninfp, vgaRegPtr save, int flags)
{
if (save == NULL)
- return;
+ return;
- if (flags & VGA_SR_CMAP)
- vgaHWSaveColormap(scrninfp, save);
+ if (flags & VGA_SR_CMAP)
+ vgaHWSaveColormap(scrninfp, save);
- if (flags & VGA_SR_MODE)
- vgaHWSaveMode(scrninfp, save);
+ if (flags & VGA_SR_MODE)
+ vgaHWSaveMode(scrninfp, save);
- if (flags & VGA_SR_FONTS)
- vgaHWSaveFonts(scrninfp, save);
+ if (flags & VGA_SR_FONTS)
+ vgaHWSaveFonts(scrninfp, save);
}
-
/*
* vgaHWInit --
* Handle the initialization, etc. of a screen.
@@ -1171,7 +1170,7 @@ vgaHWSave(ScrnInfoPtr scrninfp, vgaRegPtr save, int flags)
Bool
vgaHWInit(ScrnInfoPtr scrninfp, DisplayModePtr mode)
{
- unsigned int i;
+ unsigned int i;
vgaHWPtr hwp;
vgaRegPtr regp;
int depth = scrninfp->depth;
@@ -1180,37 +1179,38 @@ vgaHWInit(ScrnInfoPtr scrninfp, DisplayModePtr mode)
* make sure the vgaHWRec is allocated
*/
if (!vgaHWGetHWRec(scrninfp))
- return FALSE;
+ return FALSE;
hwp = VGAHWPTR(scrninfp);
regp = &hwp->ModeReg;
-
+
/*
* compute correct Hsync & Vsync polarity
*/
if ((mode->Flags & (V_PHSYNC | V_NHSYNC))
- && (mode->Flags & (V_PVSYNC | V_NVSYNC)))
- {
+ && (mode->Flags & (V_PVSYNC | V_NVSYNC))) {
regp->MiscOutReg = 0x23;
- if (mode->Flags & V_NHSYNC) regp->MiscOutReg |= 0x40;
- if (mode->Flags & V_NVSYNC) regp->MiscOutReg |= 0x80;
+ if (mode->Flags & V_NHSYNC)
+ regp->MiscOutReg |= 0x40;
+ if (mode->Flags & V_NVSYNC)
+ regp->MiscOutReg |= 0x80;
}
- else
- {
+ else {
int VDisplay = mode->VDisplay;
+
if (mode->Flags & V_DBLSCAN)
VDisplay *= 2;
if (mode->VScan > 1)
VDisplay *= mode->VScan;
- if (VDisplay < 400)
- regp->MiscOutReg = 0xA3; /* +hsync -vsync */
+ if (VDisplay < 400)
+ regp->MiscOutReg = 0xA3; /* +hsync -vsync */
else if (VDisplay < 480)
- regp->MiscOutReg = 0x63; /* -hsync +vsync */
+ regp->MiscOutReg = 0x63; /* -hsync +vsync */
else if (VDisplay < 768)
- regp->MiscOutReg = 0xE3; /* -hsync -vsync */
+ regp->MiscOutReg = 0xE3; /* -hsync -vsync */
else
- regp->MiscOutReg = 0x23; /* +hsync +vsync */
+ regp->MiscOutReg = 0x23; /* +hsync +vsync */
}
-
+
regp->MiscOutReg |= (mode->ClockIndex & 0x03) << 2;
/*
@@ -1220,7 +1220,7 @@ vgaHWInit(ScrnInfoPtr scrninfp, DisplayModePtr mode)
regp->Sequencer[0] = 0x02;
else
regp->Sequencer[0] = 0x00;
- if (mode->Flags & V_CLKDIV2)
+ if (mode->Flags & V_CLKDIV2)
regp->Sequencer[1] = 0x09;
else
regp->Sequencer[1] = 0x01;
@@ -1228,42 +1228,41 @@ vgaHWInit(ScrnInfoPtr scrninfp, DisplayModePtr mode)
regp->Sequencer[2] = 1 << BIT_PLANE;
else
regp->Sequencer[2] = 0x0F;
- regp->Sequencer[3] = 0x00; /* Font select */
+ regp->Sequencer[3] = 0x00; /* Font select */
if (depth < 8)
- regp->Sequencer[4] = 0x06; /* Misc */
+ regp->Sequencer[4] = 0x06; /* Misc */
else
- regp->Sequencer[4] = 0x0E; /* Misc */
+ regp->Sequencer[4] = 0x0E; /* Misc */
/*
* CRTC Controller
*/
- regp->CRTC[0] = (mode->CrtcHTotal >> 3) - 5;
- regp->CRTC[1] = (mode->CrtcHDisplay >> 3) - 1;
- regp->CRTC[2] = (mode->CrtcHBlankStart >> 3) - 1;
- regp->CRTC[3] = (((mode->CrtcHBlankEnd >> 3) - 1) & 0x1F) | 0x80;
+ regp->CRTC[0] = (mode->CrtcHTotal >> 3) - 5;
+ regp->CRTC[1] = (mode->CrtcHDisplay >> 3) - 1;
+ regp->CRTC[2] = (mode->CrtcHBlankStart >> 3) - 1;
+ regp->CRTC[3] = (((mode->CrtcHBlankEnd >> 3) - 1) & 0x1F) | 0x80;
i = (((mode->CrtcHSkew << 2) + 0x10) & ~0x1F);
if (i < 0x80)
- regp->CRTC[3] |= i;
- regp->CRTC[4] = (mode->CrtcHSyncStart >> 3);
- regp->CRTC[5] = ((((mode->CrtcHBlankEnd >> 3) - 1) & 0x20) << 2)
- | (((mode->CrtcHSyncEnd >> 3)) & 0x1F);
- regp->CRTC[6] = (mode->CrtcVTotal - 2) & 0xFF;
- regp->CRTC[7] = (((mode->CrtcVTotal - 2) & 0x100) >> 8)
- | (((mode->CrtcVDisplay - 1) & 0x100) >> 7)
- | ((mode->CrtcVSyncStart & 0x100) >> 6)
- | (((mode->CrtcVBlankStart - 1) & 0x100) >> 5)
- | 0x10
- | (((mode->CrtcVTotal - 2) & 0x200) >> 4)
- | (((mode->CrtcVDisplay - 1) & 0x200) >> 3)
- | ((mode->CrtcVSyncStart & 0x200) >> 2);
- regp->CRTC[8] = 0x00;
- regp->CRTC[9] = (((mode->CrtcVBlankStart - 1) & 0x200) >> 4) | 0x40;
+ regp->CRTC[3] |= i;
+ regp->CRTC[4] = (mode->CrtcHSyncStart >> 3);
+ regp->CRTC[5] = ((((mode->CrtcHBlankEnd >> 3) - 1) & 0x20) << 2)
+ | (((mode->CrtcHSyncEnd >> 3)) & 0x1F);
+ regp->CRTC[6] = (mode->CrtcVTotal - 2) & 0xFF;
+ regp->CRTC[7] = (((mode->CrtcVTotal - 2) & 0x100) >> 8)
+ | (((mode->CrtcVDisplay - 1) & 0x100) >> 7)
+ | ((mode->CrtcVSyncStart & 0x100) >> 6)
+ | (((mode->CrtcVBlankStart - 1) & 0x100) >> 5)
+ | 0x10 | (((mode->CrtcVTotal - 2) & 0x200) >> 4)
+ | (((mode->CrtcVDisplay - 1) & 0x200) >> 3)
+ | ((mode->CrtcVSyncStart & 0x200) >> 2);
+ regp->CRTC[8] = 0x00;
+ regp->CRTC[9] = (((mode->CrtcVBlankStart - 1) & 0x200) >> 4) | 0x40;
if (mode->Flags & V_DBLSCAN)
- regp->CRTC[9] |= 0x80;
+ regp->CRTC[9] |= 0x80;
if (mode->VScan >= 32)
- regp->CRTC[9] |= 0x1F;
+ regp->CRTC[9] |= 0x1F;
else if (mode->VScan > 1)
- regp->CRTC[9] |= mode->VScan - 1;
+ regp->CRTC[9] |= mode->VScan - 1;
regp->CRTC[10] = 0x00;
regp->CRTC[11] = 0x00;
regp->CRTC[12] = 0x00;
@@ -1273,14 +1272,14 @@ vgaHWInit(ScrnInfoPtr scrninfp, DisplayModePtr mode)
regp->CRTC[16] = mode->CrtcVSyncStart & 0xFF;
regp->CRTC[17] = (mode->CrtcVSyncEnd & 0x0F) | 0x20;
regp->CRTC[18] = (mode->CrtcVDisplay - 1) & 0xFF;
- regp->CRTC[19] = scrninfp->displayWidth >> 4; /* just a guess */
+ regp->CRTC[19] = scrninfp->displayWidth >> 4; /* just a guess */
regp->CRTC[20] = 0x00;
- regp->CRTC[21] = (mode->CrtcVBlankStart - 1) & 0xFF;
+ regp->CRTC[21] = (mode->CrtcVBlankStart - 1) & 0xFF;
regp->CRTC[22] = (mode->CrtcVBlankEnd - 1) & 0xFF;
if (depth < 8)
- regp->CRTC[23] = 0xE3;
+ regp->CRTC[23] = 0xE3;
else
- regp->CRTC[23] = 0xC3;
+ regp->CRTC[23] = 0xC3;
regp->CRTC[24] = 0xFF;
vgaHWHBlankKGA(mode, regp, 0, KGA_FIX_OVERSCAN | KGA_ENABLE_ON_ZERO);
@@ -1300,7 +1299,8 @@ vgaHWInit(ScrnInfoPtr scrninfp, DisplayModePtr mode)
if (depth == 1) {
regp->Graphics[4] = BIT_PLANE;
regp->Graphics[5] = 0x00;
- } else {
+ }
+ else {
regp->Graphics[4] = 0x00;
if (depth == 4)
regp->Graphics[5] = 0x02;
@@ -1310,32 +1310,33 @@ vgaHWInit(ScrnInfoPtr scrninfp, DisplayModePtr mode)
regp->Graphics[6] = 0x05; /* only map 64k VGA memory !!!! */
regp->Graphics[7] = 0x0F;
regp->Graphics[8] = 0xFF;
-
+
if (depth == 1) {
/* Initialise the Mono map according to which bit-plane gets used */
- Bool flipPixels = xf86GetFlipPixels();
+ Bool flipPixels = xf86GetFlipPixels();
- for (i=0; i<16; i++)
+ for (i = 0; i < 16; i++)
if (((i & (1 << BIT_PLANE)) != 0) != flipPixels)
regp->Attribute[i] = WHITE_VALUE;
else
regp->Attribute[i] = BLACK_VALUE;
- regp->Attribute[16] = 0x01; /* -VGA2- */ /* wrong for the ET4000 */
- if (!hwp->ShowOverscan)
- regp->Attribute[OVERSCAN] = OVERSCAN_VALUE; /* -VGA2- */
- } else {
- regp->Attribute[0] = 0x00; /* standard colormap translation */
- regp->Attribute[1] = 0x01;
- regp->Attribute[2] = 0x02;
- regp->Attribute[3] = 0x03;
- regp->Attribute[4] = 0x04;
- regp->Attribute[5] = 0x05;
- regp->Attribute[6] = 0x06;
- regp->Attribute[7] = 0x07;
- regp->Attribute[8] = 0x08;
- regp->Attribute[9] = 0x09;
+ regp->Attribute[16] = 0x01; /* -VGA2- *//* wrong for the ET4000 */
+ if (!hwp->ShowOverscan)
+ regp->Attribute[OVERSCAN] = OVERSCAN_VALUE; /* -VGA2- */
+ }
+ else {
+ regp->Attribute[0] = 0x00; /* standard colormap translation */
+ regp->Attribute[1] = 0x01;
+ regp->Attribute[2] = 0x02;
+ regp->Attribute[3] = 0x03;
+ regp->Attribute[4] = 0x04;
+ regp->Attribute[5] = 0x05;
+ regp->Attribute[6] = 0x06;
+ regp->Attribute[7] = 0x07;
+ regp->Attribute[8] = 0x08;
+ regp->Attribute[9] = 0x09;
regp->Attribute[10] = 0x0A;
regp->Attribute[11] = 0x0B;
regp->Attribute[12] = 0x0C;
@@ -1389,36 +1390,37 @@ vgaHWInit(ScrnInfoPtr scrninfp, DisplayModePtr mode)
*/
CARD32
-vgaHWHBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
- unsigned int Flags)
+vgaHWHBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
+ unsigned int Flags)
{
int nExtBits = (nBits < 6) ? 0 : nBits - 6;
CARD32 ExtBits;
CARD32 ExtBitMask = ((1 << nExtBits) - 1) << 6;
- regp->CRTC[3] = (regp->CRTC[3] & ~0x1F)
- | (((mode->CrtcHBlankEnd >> 3) - 1) & 0x1F);
- regp->CRTC[5] = (regp->CRTC[5] & ~0x80)
- | ((((mode->CrtcHBlankEnd >> 3) - 1) & 0x20) << 2);
- ExtBits = ((mode->CrtcHBlankEnd >> 3) - 1) & ExtBitMask;
+ regp->CRTC[3] = (regp->CRTC[3] & ~0x1F)
+ | (((mode->CrtcHBlankEnd >> 3) - 1) & 0x1F);
+ regp->CRTC[5] = (regp->CRTC[5] & ~0x80)
+ | ((((mode->CrtcHBlankEnd >> 3) - 1) & 0x20) << 2);
+ ExtBits = ((mode->CrtcHBlankEnd >> 3) - 1) & ExtBitMask;
/* First the horizontal case */
if ((Flags & KGA_FIX_OVERSCAN)
- && ((mode->CrtcHBlankEnd >> 3) == (mode->CrtcHTotal >> 3)))
- {
- int i = (regp->CRTC[3] & 0x1F)
- | ((regp->CRTC[5] & 0x80) >> 2)
- | ExtBits;
- if (Flags & KGA_ENABLE_ON_ZERO) {
- if ((i-- > (((mode->CrtcHBlankStart >> 3) - 1)
- & (0x3F | ExtBitMask)))
- && (mode->CrtcHBlankEnd == mode->CrtcHTotal))
- i = 0;
- } else if (Flags & KGA_BE_TOT_DEC)
- i--;
- regp->CRTC[3] = (regp->CRTC[3] & ~0x1F) | (i & 0x1F);
- regp->CRTC[5] = (regp->CRTC[5] & ~0x80) | ((i << 2) & 0x80);
- ExtBits = i & ExtBitMask;
+ && ((mode->CrtcHBlankEnd >> 3) == (mode->CrtcHTotal >> 3))) {
+ int i = (regp->CRTC[3] & 0x1F)
+ | ((regp->CRTC[5] & 0x80) >> 2)
+ | ExtBits;
+
+ if (Flags & KGA_ENABLE_ON_ZERO) {
+ if ((i-- > (((mode->CrtcHBlankStart >> 3) - 1)
+ & (0x3F | ExtBitMask)))
+ && (mode->CrtcHBlankEnd == mode->CrtcHTotal))
+ i = 0;
+ }
+ else if (Flags & KGA_BE_TOT_DEC)
+ i--;
+ regp->CRTC[3] = (regp->CRTC[3] & ~0x1F) | (i & 0x1F);
+ regp->CRTC[5] = (regp->CRTC[5] & ~0x80) | ((i << 2) & 0x80);
+ ExtBits = i & ExtBitMask;
}
return ExtBits >> 6;
}
@@ -1430,37 +1432,41 @@ vgaHWHBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
* needs further investigation.
*/
CARD32
-vgaHWVBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
- unsigned int Flags)
+vgaHWVBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
+ unsigned int Flags)
{
CARD32 ExtBits;
CARD32 nExtBits = (nBits < 8) ? 0 : (nBits - 8);
CARD32 ExtBitMask = ((1 << nExtBits) - 1) << 8;
+
/* If width is not known nBits should be 0. In this
* case BitMask is set to 0 so we can check for it. */
CARD32 BitMask = (nBits < 7) ? 0 : ((1 << nExtBits) - 1);
- int VBlankStart = (mode->CrtcVBlankStart - 1) & 0xFF;
+ int VBlankStart = (mode->CrtcVBlankStart - 1) & 0xFF;
+
regp->CRTC[22] = (mode->CrtcVBlankEnd - 1) & 0xFF;
- ExtBits = (mode->CrtcVBlankEnd - 1) & ExtBitMask;
+ ExtBits = (mode->CrtcVBlankEnd - 1) & ExtBitMask;
- if ((Flags & KGA_FIX_OVERSCAN)
- && (mode->CrtcVBlankEnd == mode->CrtcVTotal))
- /* Null top overscan */
+ if ((Flags & KGA_FIX_OVERSCAN)
+ && (mode->CrtcVBlankEnd == mode->CrtcVTotal))
+ /* Null top overscan */
{
- int i = regp->CRTC[22] | ExtBits;
- if (Flags & KGA_ENABLE_ON_ZERO) {
- if (((BitMask && ((i & BitMask) > (VBlankStart & BitMask)))
- || ((i > VBlankStart) && /* 8-bit case */
- ((i & 0x7F) > (VBlankStart & 0x7F)))) && /* 7-bit case */
- !(regp->CRTC[9] & 0x9F)) /* 1 scanline/row */
- i = 0;
- else
- i = (i - 1);
- } else if (Flags & KGA_BE_TOT_DEC)
- i = (i - 1);
-
- regp->CRTC[22] = i & 0xFF;
- ExtBits = i & 0xFF00;
+ int i = regp->CRTC[22] | ExtBits;
+
+ if (Flags & KGA_ENABLE_ON_ZERO) {
+ if (((BitMask && ((i & BitMask) > (VBlankStart & BitMask)))
+ || ((i > VBlankStart) && /* 8-bit case */
+ ((i & 0x7F) > (VBlankStart & 0x7F)))) && /* 7-bit case */
+ !(regp->CRTC[9] & 0x9F)) /* 1 scanline/row */
+ i = 0;
+ else
+ i = (i - 1);
+ }
+ else if (Flags & KGA_BE_TOT_DEC)
+ i = (i - 1);
+
+ regp->CRTC[22] = i & 0xFF;
+ ExtBits = i & 0xFF00;
}
return ExtBits >> 8;
}
@@ -1472,29 +1478,21 @@ static void
vgaHWGetHWRecPrivate(void)
{
if (vgaHWPrivateIndex < 0)
- vgaHWPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
+ vgaHWPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
return;
}
-
static void
vgaHWFreeRegs(vgaRegPtr regp)
{
free(regp->CRTC);
- regp->CRTC =
- regp->Sequencer =
- regp->Graphics =
- regp->Attribute = NULL;
+ regp->CRTC = regp->Sequencer = regp->Graphics = regp->Attribute = NULL;
regp->numCRTC =
- regp->numSequencer =
- regp->numGraphics =
- regp->numAttribute = 0;
+ regp->numSequencer = regp->numGraphics = regp->numAttribute = 0;
}
-
-
static Bool
vgaHWAllocRegs(vgaRegPtr regp)
{
@@ -1505,11 +1503,10 @@ vgaHWAllocRegs(vgaRegPtr regp)
return FALSE;
buf = calloc(regp->numCRTC +
- regp->numSequencer +
- regp->numGraphics +
- regp->numAttribute, 1);
+ regp->numSequencer +
+ regp->numGraphics + regp->numAttribute, 1);
if (!buf)
- return FALSE;
+ return FALSE;
regp->CRTC = buf;
regp->Sequencer = regp->CRTC + regp->numCRTC;
@@ -1519,7 +1516,6 @@ vgaHWAllocRegs(vgaRegPtr regp)
return TRUE;
}
-
Bool
vgaHWAllocDefaultRegs(vgaRegPtr regp)
{
@@ -1531,10 +1527,9 @@ vgaHWAllocDefaultRegs(vgaRegPtr regp)
return vgaHWAllocRegs(regp);
}
-
Bool
vgaHWSetRegCounts(ScrnInfoPtr scrp, int numCRTC, int numSequencer,
- int numGraphics, int numAttribute)
+ int numGraphics, int numAttribute)
{
#define VGAHWMINNUM(regtype) \
((newMode.num##regtype < regp->num##regtype) ? \
@@ -1546,7 +1541,7 @@ vgaHWSetRegCounts(ScrnInfoPtr scrp, int numCRTC, int numSequencer,
vgaRegPtr regp;
regp = &VGAHWPTR(scrp)->ModeReg;
- memcpy (&newMode, regp, sizeof(vgaRegRec));
+ memcpy(&newMode, regp, sizeof(vgaRegRec));
/* allocate space for new registers */
@@ -1556,10 +1551,10 @@ vgaHWSetRegCounts(ScrnInfoPtr scrp, int numCRTC, int numSequencer,
regp->numGraphics = numGraphics;
regp->numAttribute = numAttribute;
if (!vgaHWAllocRegs(regp))
- return FALSE;
+ return FALSE;
regp = &VGAHWPTR(scrp)->SavedReg;
- memcpy (&newSaved, regp, sizeof(vgaRegRec));
+ memcpy(&newSaved, regp, sizeof(vgaRegRec));
regp = &newSaved;
regp->numCRTC = numCRTC;
@@ -1568,7 +1563,7 @@ vgaHWSetRegCounts(ScrnInfoPtr scrp, int numCRTC, int numSequencer,
regp->numAttribute = numAttribute;
if (!vgaHWAllocRegs(regp)) {
vgaHWFreeRegs(&newMode);
- return FALSE;
+ return FALSE;
}
/* allocations succeeded, copy register data into new space */
@@ -1601,7 +1596,6 @@ vgaHWSetRegCounts(ScrnInfoPtr scrp, int numCRTC, int numSequencer,
#undef VGAHWCOPYREGSET
}
-
Bool
vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src)
{
@@ -1610,7 +1604,7 @@ vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src)
memcpy(dst, src, sizeof(vgaRegRec));
if (!vgaHWAllocRegs(dst))
- return FALSE;
+ return FALSE;
memcpy(dst->CRTC, src->CRTC, src->numCRTC);
memcpy(dst->Sequencer, src->Sequencer, src->numSequencer);
@@ -1620,14 +1614,13 @@ vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src)
return TRUE;
}
-
Bool
vgaHWGetHWRec(ScrnInfoPtr scrp)
{
vgaRegPtr regp;
vgaHWPtr hwp;
int i;
-
+
/*
* Let's make sure that the private exists and allocate one.
*/
@@ -1637,41 +1630,49 @@ vgaHWGetHWRec(ScrnInfoPtr scrp)
* has already been done.
*/
if (VGAHWPTR(scrp))
- return TRUE;
+ return TRUE;
hwp = VGAHWPTRLVAL(scrp) = xnfcalloc(sizeof(vgaHWRec), 1);
regp = &VGAHWPTR(scrp)->ModeReg;
if ((!vgaHWAllocDefaultRegs(&VGAHWPTR(scrp)->SavedReg)) ||
- (!vgaHWAllocDefaultRegs(&VGAHWPTR(scrp)->ModeReg))) {
+ (!vgaHWAllocDefaultRegs(&VGAHWPTR(scrp)->ModeReg))) {
free(hwp);
- return FALSE;
+ return FALSE;
}
if (scrp->bitsPerPixel == 1) {
- rgb blackColour = scrp->display->blackColour,
- whiteColour = scrp->display->whiteColour;
-
- if (blackColour.red > 0x3F) blackColour.red = 0x3F;
- if (blackColour.green > 0x3F) blackColour.green = 0x3F;
- if (blackColour.blue > 0x3F) blackColour.blue = 0x3F;
-
- if (whiteColour.red > 0x3F) whiteColour.red = 0x3F;
- if (whiteColour.green > 0x3F) whiteColour.green = 0x3F;
- if (whiteColour.blue > 0x3F) whiteColour.blue = 0x3F;
-
- if ((blackColour.red == whiteColour.red ) &&
- (blackColour.green == whiteColour.green) &&
- (blackColour.blue == whiteColour.blue )) {
- blackColour.red ^= 0x3F;
- blackColour.green ^= 0x3F;
- blackColour.blue ^= 0x3F;
- }
+ rgb blackColour = scrp->display->blackColour,
+ whiteColour = scrp->display->whiteColour;
+
+ if (blackColour.red > 0x3F)
+ blackColour.red = 0x3F;
+ if (blackColour.green > 0x3F)
+ blackColour.green = 0x3F;
+ if (blackColour.blue > 0x3F)
+ blackColour.blue = 0x3F;
+
+ if (whiteColour.red > 0x3F)
+ whiteColour.red = 0x3F;
+ if (whiteColour.green > 0x3F)
+ whiteColour.green = 0x3F;
+ if (whiteColour.blue > 0x3F)
+ whiteColour.blue = 0x3F;
+
+ if ((blackColour.red == whiteColour.red) &&
+ (blackColour.green == whiteColour.green) &&
+ (blackColour.blue == whiteColour.blue)) {
+ blackColour.red ^= 0x3F;
+ blackColour.green ^= 0x3F;
+ blackColour.blue ^= 0x3F;
+ }
/*
* initialize default colormap for monochrome
*/
- for (i=0; i<3; i++) regp->DAC[i] = 0x00;
- for (i=3; i<768; i++) regp->DAC[i] = 0x3F;
+ for (i = 0; i < 3; i++)
+ regp->DAC[i] = 0x00;
+ for (i = 3; i < 768; i++)
+ regp->DAC[i] = 0x3F;
i = BLACK_VALUE * 3;
regp->DAC[i++] = blackColour.red;
regp->DAC[i++] = blackColour.green;
@@ -1684,23 +1685,26 @@ vgaHWGetHWRec(ScrnInfoPtr scrp)
regp->DAC[i++] = 0x00;
regp->DAC[i++] = 0x00;
regp->DAC[i] = 0x00;
- } else {
- /* Set all colours to black */
- for (i=0; i<768; i++) regp->DAC[i] = 0x00;
+ }
+ else {
+ /* Set all colours to black */
+ for (i = 0; i < 768; i++)
+ regp->DAC[i] = 0x00;
/* ... and the overscan */
if (scrp->depth >= 4)
regp->Attribute[OVERSCAN] = 0xFF;
}
if (xf86FindOption(scrp->confScreen->options, "ShowOverscan")) {
- xf86MarkOptionUsedByName(scrp->confScreen->options, "ShowOverscan");
- xf86DrvMsg(scrp->scrnIndex, X_CONFIG, "Showing overscan area\n");
- regp->DAC[765] = 0x3F;
- regp->DAC[766] = 0x00;
- regp->DAC[767] = 0x3F;
- regp->Attribute[OVERSCAN] = 0xFF;
- hwp->ShowOverscan = TRUE;
- } else
- hwp->ShowOverscan = FALSE;
+ xf86MarkOptionUsedByName(scrp->confScreen->options, "ShowOverscan");
+ xf86DrvMsg(scrp->scrnIndex, X_CONFIG, "Showing overscan area\n");
+ regp->DAC[765] = 0x3F;
+ regp->DAC[766] = 0x00;
+ regp->DAC[767] = 0x3F;
+ regp->Attribute[OVERSCAN] = 0xFF;
+ hwp->ShowOverscan = TRUE;
+ }
+ else
+ hwp->ShowOverscan = FALSE;
hwp->paletteEnabled = FALSE;
hwp->cmapSaved = FALSE;
@@ -1712,44 +1716,42 @@ vgaHWGetHWRec(ScrnInfoPtr scrp)
return TRUE;
}
-
void
vgaHWFreeHWRec(ScrnInfoPtr scrp)
{
if (vgaHWPrivateIndex >= 0) {
- vgaHWPtr hwp = VGAHWPTR(scrp);
+ vgaHWPtr hwp = VGAHWPTR(scrp);
- if (!hwp)
+ if (!hwp)
return;
pci_device_close_io(hwp->dev, hwp->io);
- free(hwp->FontInfo1);
- free(hwp->FontInfo2);
- free(hwp->TextInfo);
+ free(hwp->FontInfo1);
+ free(hwp->FontInfo2);
+ free(hwp->TextInfo);
- vgaHWFreeRegs (&hwp->ModeReg);
- vgaHWFreeRegs (&hwp->SavedReg);
+ vgaHWFreeRegs(&hwp->ModeReg);
+ vgaHWFreeRegs(&hwp->SavedReg);
- free(hwp);
- VGAHWPTRLVAL(scrp) = NULL;
+ free(hwp);
+ VGAHWPTRLVAL(scrp) = NULL;
}
}
-
Bool
vgaHWMapMem(ScrnInfoPtr scrp)
{
vgaHWPtr hwp = VGAHWPTR(scrp);
-
+
if (hwp->Base)
- return TRUE;
+ return TRUE;
/* If not set, initialise with the defaults */
if (hwp->MapSize == 0)
- hwp->MapSize = VGA_DEFAULT_MEM_SIZE;
+ hwp->MapSize = VGA_DEFAULT_MEM_SIZE;
if (hwp->MapPhys == 0)
- hwp->MapPhys = VGA_DEFAULT_PHYS_ADDR;
+ hwp->MapPhys = VGA_DEFAULT_PHYS_ADDR;
/*
* Map as VIDMEM_MMIO_32BIT because WC
@@ -1758,19 +1760,19 @@ vgaHWMapMem(ScrnInfoPtr scrp)
* for now.
*/
DebugF("Mapping VGAMem\n");
- pci_device_map_legacy(hwp->dev, hwp->MapPhys, hwp->MapSize, PCI_DEV_MAP_FLAG_WRITABLE, &hwp->Base);
+ pci_device_map_legacy(hwp->dev, hwp->MapPhys, hwp->MapSize,
+ PCI_DEV_MAP_FLAG_WRITABLE, &hwp->Base);
return hwp->Base != NULL;
}
-
void
vgaHWUnmapMem(ScrnInfoPtr scrp)
{
vgaHWPtr hwp = VGAHWPTR(scrp);
if (hwp->Base == NULL)
- return;
-
+ return;
+
DebugF("Unmapping VGAMem\n");
pci_device_unmap_legacy(hwp->dev, hwp->Base, hwp->MapSize);
hwp->Base = NULL;
@@ -1782,17 +1784,15 @@ vgaHWGetIndex(void)
return vgaHWPrivateIndex;
}
-
void
vgaHWGetIOBase(vgaHWPtr hwp)
{
hwp->IOBase = (hwp->readMiscOut(hwp) & 0x01) ?
- VGA_IOBASE_COLOR : VGA_IOBASE_MONO;
+ VGA_IOBASE_COLOR : VGA_IOBASE_MONO;
xf86DrvMsgVerb(hwp->pScrn->scrnIndex, X_INFO, 3,
- "vgaHWGetIOBase: hwp->IOBase is 0x%04x\n", hwp->IOBase);
+ "vgaHWGetIOBase: hwp->IOBase is 0x%04x\n", hwp->IOBase);
}
-
void
vgaHWLock(vgaHWPtr hwp)
{
@@ -1804,87 +1804,82 @@ void
vgaHWUnlock(vgaHWPtr hwp)
{
/* Unprotect CRTC[0-7] */
- hwp->writeCrtc(hwp, 0x11, hwp->readCrtc(hwp, 0x11) & ~0x80);
+ hwp->writeCrtc(hwp, 0x11, hwp->readCrtc(hwp, 0x11) & ~0x80);
}
-
void
vgaHWEnable(vgaHWPtr hwp)
{
hwp->writeEnable(hwp, hwp->readEnable(hwp) | 0x01);
}
-
void
vgaHWDisable(vgaHWPtr hwp)
{
hwp->writeEnable(hwp, hwp->readEnable(hwp) & ~0x01);
}
-
static void
-vgaHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors,
- VisualPtr pVisual)
+vgaHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO * colors,
+ VisualPtr pVisual)
{
vgaHWPtr hwp = VGAHWPTR(pScrn);
int i, index;
for (i = 0; i < numColors; i++) {
- index = indices[i];
- hwp->writeDacWriteAddr(hwp, index);
- DACDelay(hwp);
- hwp->writeDacData(hwp, colors[index].red);
- DACDelay(hwp);
- hwp->writeDacData(hwp, colors[index].green);
- DACDelay(hwp);
- hwp->writeDacData(hwp, colors[index].blue);
- DACDelay(hwp);
+ index = indices[i];
+ hwp->writeDacWriteAddr(hwp, index);
+ DACDelay(hwp);
+ hwp->writeDacData(hwp, colors[index].red);
+ DACDelay(hwp);
+ hwp->writeDacData(hwp, colors[index].green);
+ DACDelay(hwp);
+ hwp->writeDacData(hwp, colors[index].blue);
+ DACDelay(hwp);
}
/* This shouldn't be necessary, but we'll play safe. */
hwp->disablePalette(hwp);
}
-
static void
vgaHWSetOverscan(ScrnInfoPtr pScrn, int overscan)
{
vgaHWPtr hwp = VGAHWPTR(pScrn);
if (overscan < 0 || overscan > 255)
- return;
+ return;
hwp->enablePalette(hwp);
hwp->writeAttr(hwp, OVERSCAN, overscan);
#ifdef DEBUGOVERSCAN
{
- int ov = hwp->readAttr(hwp, OVERSCAN);
- int red, green, blue;
-
- hwp->writeDacReadAddr(hwp, ov);
- red = hwp->readDacData(hwp);
- green = hwp->readDacData(hwp);
- blue = hwp->readDacData(hwp);
- ErrorF("Overscan index is 0x%02x, colours are #%02x%02x%02x\n",
- ov, red, green, blue);
+ int ov = hwp->readAttr(hwp, OVERSCAN);
+ int red, green, blue;
+
+ hwp->writeDacReadAddr(hwp, ov);
+ red = hwp->readDacData(hwp);
+ green = hwp->readDacData(hwp);
+ blue = hwp->readDacData(hwp);
+ ErrorF("Overscan index is 0x%02x, colours are #%02x%02x%02x\n",
+ ov, red, green, blue);
}
#endif
hwp->disablePalette(hwp);
}
-
Bool
vgaHWHandleColormaps(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
if (pScrn->depth > 1 && pScrn->depth <= 8) {
- return xf86HandleColormaps(pScreen, 1 << pScrn->depth,
- pScrn->rgbBits, vgaHWLoadPalette,
- pScrn->depth > 4 ? vgaHWSetOverscan : NULL,
- CMAP_RELOAD_ON_MODE_SWITCH);
+ return xf86HandleColormaps(pScreen, 1 << pScrn->depth,
+ pScrn->rgbBits, vgaHWLoadPalette,
+ pScrn->depth > 4 ? vgaHWSetOverscan : NULL,
+ CMAP_RELOAD_ON_MODE_SWITCH);
}
return TRUE;
}
@@ -1923,57 +1918,60 @@ vgaHWddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed)
{
vgaHWPtr hwp = VGAHWPTR(pScrn);
unsigned char tmp;
- struct _vgaDdcSave* save;
+ struct _vgaDdcSave *save;
+
switch (speed) {
case DDC_FAST:
-
- if (hwp->ddc != NULL) break;
- hwp->ddc = xnfcalloc(sizeof(struct _vgaDdcSave),1);
- save = (struct _vgaDdcSave *)hwp->ddc;
- /* Lightpen register disable - allow access to cr10 & 11; just in case */
- save->cr03 = hwp->readCrtc(hwp, 0x03);
- hwp->writeCrtc(hwp,0x03,(save->cr03 |0x80));
- save->cr12 = hwp->readCrtc(hwp, 0x12);
- hwp->writeCrtc(hwp,0x12,DISPLAY_END);
- save->cr15 = hwp->readCrtc(hwp, 0x15);
- hwp->writeCrtc(hwp,0x15,BLANK_START);
- save->cr10 = hwp->readCrtc(hwp, 0x10);
- hwp->writeCrtc(hwp,0x10,SYNC_START);
- save->cr11 = hwp->readCrtc(hwp, 0x11);
- /* unprotect group 1 registers; just in case ...*/
- hwp->writeCrtc(hwp,0x11,((save->cr11 & 0x70) | SYNC_END));
- save->cr16 = hwp->readCrtc(hwp, 0x16);
- hwp->writeCrtc(hwp,0x16,BLANK_END);
- save->cr06 = hwp->readCrtc(hwp, 0x06);
- hwp->writeCrtc(hwp,0x06,V_TOTAL);
- /* all values have less than 8 bit - mask out 9th and 10th bits */
- save->cr09 = hwp->readCrtc(hwp, 0x09);
- hwp->writeCrtc(hwp,0x09,(save->cr09 &0xDF));
- save->cr07 = hwp->readCrtc(hwp, 0x07);
- hwp->writeCrtc(hwp,0x07,(save->cr07 &0x10));
- /* vsync polarity negativ & ensure a 25MHz clock */
- save->msr = hwp->readMiscOut(hwp);
- hwp->writeMiscOut(hwp,((save->msr & 0xF3) | 0x80));
- break;
+
+ if (hwp->ddc != NULL)
+ break;
+ hwp->ddc = xnfcalloc(sizeof(struct _vgaDdcSave), 1);
+ save = (struct _vgaDdcSave *) hwp->ddc;
+ /* Lightpen register disable - allow access to cr10 & 11; just in case */
+ save->cr03 = hwp->readCrtc(hwp, 0x03);
+ hwp->writeCrtc(hwp, 0x03, (save->cr03 | 0x80));
+ save->cr12 = hwp->readCrtc(hwp, 0x12);
+ hwp->writeCrtc(hwp, 0x12, DISPLAY_END);
+ save->cr15 = hwp->readCrtc(hwp, 0x15);
+ hwp->writeCrtc(hwp, 0x15, BLANK_START);
+ save->cr10 = hwp->readCrtc(hwp, 0x10);
+ hwp->writeCrtc(hwp, 0x10, SYNC_START);
+ save->cr11 = hwp->readCrtc(hwp, 0x11);
+ /* unprotect group 1 registers; just in case ... */
+ hwp->writeCrtc(hwp, 0x11, ((save->cr11 & 0x70) | SYNC_END));
+ save->cr16 = hwp->readCrtc(hwp, 0x16);
+ hwp->writeCrtc(hwp, 0x16, BLANK_END);
+ save->cr06 = hwp->readCrtc(hwp, 0x06);
+ hwp->writeCrtc(hwp, 0x06, V_TOTAL);
+ /* all values have less than 8 bit - mask out 9th and 10th bits */
+ save->cr09 = hwp->readCrtc(hwp, 0x09);
+ hwp->writeCrtc(hwp, 0x09, (save->cr09 & 0xDF));
+ save->cr07 = hwp->readCrtc(hwp, 0x07);
+ hwp->writeCrtc(hwp, 0x07, (save->cr07 & 0x10));
+ /* vsync polarity negativ & ensure a 25MHz clock */
+ save->msr = hwp->readMiscOut(hwp);
+ hwp->writeMiscOut(hwp, ((save->msr & 0xF3) | 0x80));
+ break;
case DDC_SLOW:
- if (hwp->ddc == NULL) break;
- save = (struct _vgaDdcSave *)hwp->ddc;
- hwp->writeMiscOut(hwp,save->msr);
- hwp->writeCrtc(hwp,0x07,save->cr07);
- tmp = hwp->readCrtc(hwp, 0x09);
- hwp->writeCrtc(hwp,0x09,((save->cr09 & 0x20) | (tmp & 0xDF)));
- hwp->writeCrtc(hwp,0x06,save->cr06);
- hwp->writeCrtc(hwp,0x16,save->cr16);
- hwp->writeCrtc(hwp,0x11,save->cr11);
- hwp->writeCrtc(hwp,0x10,save->cr10);
- hwp->writeCrtc(hwp,0x15,save->cr15);
- hwp->writeCrtc(hwp,0x12,save->cr12);
- hwp->writeCrtc(hwp,0x03,save->cr03);
- free(save);
- hwp->ddc = NULL;
- break;
+ if (hwp->ddc == NULL)
+ break;
+ save = (struct _vgaDdcSave *) hwp->ddc;
+ hwp->writeMiscOut(hwp, save->msr);
+ hwp->writeCrtc(hwp, 0x07, save->cr07);
+ tmp = hwp->readCrtc(hwp, 0x09);
+ hwp->writeCrtc(hwp, 0x09, ((save->cr09 & 0x20) | (tmp & 0xDF)));
+ hwp->writeCrtc(hwp, 0x06, save->cr06);
+ hwp->writeCrtc(hwp, 0x16, save->cr16);
+ hwp->writeCrtc(hwp, 0x11, save->cr11);
+ hwp->writeCrtc(hwp, 0x10, save->cr10);
+ hwp->writeCrtc(hwp, 0x15, save->cr15);
+ hwp->writeCrtc(hwp, 0x12, save->cr12);
+ hwp->writeCrtc(hwp, 0x03, save->cr03);
+ free(save);
+ hwp->ddc = NULL;
+ break;
default:
- break;
+ break;
}
}
@@ -1983,7 +1981,8 @@ vgaHWddc1SetSpeedWeak(void)
return vgaHWddc1SetSpeed;
}
-SaveScreenProcPtr vgaHWSaveScreenWeak(void)
+SaveScreenProcPtr
+vgaHWSaveScreenWeak(void)
{
return vgaHWSaveScreen;
}
@@ -1992,89 +1991,87 @@ SaveScreenProcPtr vgaHWSaveScreenWeak(void)
* xf86GetClocks -- get the dot-clocks via a BIG BAD hack ...
*/
void
-xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int),
- void (*ProtectRegs)(ScrnInfoPtr, Bool),
- void (*BlankScreen)(ScrnInfoPtr, Bool), unsigned long vertsyncreg,
- int maskval, int knownclkindex, int knownclkvalue)
+xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc) (ScrnInfoPtr, int),
+ void (*ProtectRegs) (ScrnInfoPtr, Bool),
+ void (*BlankScreen) (ScrnInfoPtr, Bool),
+ unsigned long vertsyncreg, int maskval, int knownclkindex,
+ int knownclkvalue)
{
register int status = vertsyncreg;
unsigned long i, cnt, rcnt, sync;
vgaHWPtr hwp = VGAHWPTR(pScrn);
/* First save registers that get written on */
- (*ClockFunc)(pScrn, CLK_REG_SAVE);
+ (*ClockFunc) (pScrn, CLK_REG_SAVE);
if (num > MAXCLOCKS)
- num = MAXCLOCKS;
-
- for (i = 0; i < num; i++)
- {
- if (ProtectRegs)
- (*ProtectRegs)(pScrn, TRUE);
- if (!(*ClockFunc)(pScrn, i))
- {
- pScrn->clock[i] = -1;
- continue;
- }
- if (ProtectRegs)
- (*ProtectRegs)(pScrn, FALSE);
- if (BlankScreen)
- (*BlankScreen)(pScrn, FALSE);
-
- usleep(50000); /* let VCO stabilise */
-
- cnt = 0;
- sync = 200000;
-
- while ((pci_io_read8(hwp->io, status) & maskval) == 0x00)
- if (sync-- == 0) goto finish;
- /* Something appears to be happening, so reset sync count */
- sync = 200000;
- while ((pci_io_read8(hwp->io, status) & maskval) == maskval)
- if (sync-- == 0) goto finish;
- /* Something appears to be happening, so reset sync count */
- sync = 200000;
- while ((pci_io_read8(hwp->io, status) & maskval) == 0x00)
- if (sync-- == 0) goto finish;
-
- for (rcnt = 0; rcnt < 5; rcnt++)
- {
- while (!(pci_io_read8(hwp->io, status) & maskval))
- cnt++;
- while ((pci_io_read8(hwp->io, status) & maskval))
- cnt++;
- }
-
-finish:
- pScrn->clock[i] = cnt ? cnt : -1;
- if (BlankScreen)
- (*BlankScreen)(pScrn, TRUE);
+ num = MAXCLOCKS;
+
+ for (i = 0; i < num; i++) {
+ if (ProtectRegs)
+ (*ProtectRegs) (pScrn, TRUE);
+ if (!(*ClockFunc) (pScrn, i)) {
+ pScrn->clock[i] = -1;
+ continue;
+ }
+ if (ProtectRegs)
+ (*ProtectRegs) (pScrn, FALSE);
+ if (BlankScreen)
+ (*BlankScreen) (pScrn, FALSE);
+
+ usleep(50000); /* let VCO stabilise */
+
+ cnt = 0;
+ sync = 200000;
+
+ while ((pci_io_read8(hwp->io, status) & maskval) == 0x00)
+ if (sync-- == 0)
+ goto finish;
+ /* Something appears to be happening, so reset sync count */
+ sync = 200000;
+ while ((pci_io_read8(hwp->io, status) & maskval) == maskval)
+ if (sync-- == 0)
+ goto finish;
+ /* Something appears to be happening, so reset sync count */
+ sync = 200000;
+ while ((pci_io_read8(hwp->io, status) & maskval) == 0x00)
+ if (sync-- == 0)
+ goto finish;
+
+ for (rcnt = 0; rcnt < 5; rcnt++) {
+ while (!(pci_io_read8(hwp->io, status) & maskval))
+ cnt++;
+ while ((pci_io_read8(hwp->io, status) & maskval))
+ cnt++;
+ }
+
+ finish:
+ pScrn->clock[i] = cnt ? cnt : -1;
+ if (BlankScreen)
+ (*BlankScreen) (pScrn, TRUE);
}
- for (i = 0; i < num; i++)
- {
- if (i != knownclkindex)
- {
- if (pScrn->clock[i] == -1)
- {
- pScrn->clock[i] = 0;
- }
- else
- {
- pScrn->clock[i] = (int)(0.5 +
- (((float)knownclkvalue) * pScrn->clock[knownclkindex]) /
- (pScrn->clock[i]));
- /* Round to nearest 10KHz */
- pScrn->clock[i] += 5;
- pScrn->clock[i] /= 10;
- pScrn->clock[i] *= 10;
- }
- }
+ for (i = 0; i < num; i++) {
+ if (i != knownclkindex) {
+ if (pScrn->clock[i] == -1) {
+ pScrn->clock[i] = 0;
+ }
+ else {
+ pScrn->clock[i] = (int) (0.5 +
+ (((float) knownclkvalue) *
+ pScrn->clock[knownclkindex]) /
+ (pScrn->clock[i]));
+ /* Round to nearest 10KHz */
+ pScrn->clock[i] += 5;
+ pScrn->clock[i] /= 10;
+ pScrn->clock[i] *= 10;
+ }
+ }
}
pScrn->clock[knownclkindex] = knownclkvalue;
pScrn->numClocks = num;
/* Restore registers that were written on */
- (*ClockFunc)(pScrn, CLK_REG_RESTORE);
+ (*ClockFunc) (pScrn, CLK_REG_RESTORE);
}
diff --git a/xorg-server/hw/xfree86/vgahw/vgaHW.h b/xorg-server/hw/xfree86/vgahw/vgaHW.h
index d1ba9da89..937a8a507 100644
--- a/xorg-server/hw/xfree86/vgahw/vgaHW.h
+++ b/xorg-server/hw/xfree86/vgahw/vgaHW.h
@@ -1,5 +1,4 @@
-
/*
* Copyright (c) 1997,1998 The XFree86 Project, Inc.
*
@@ -38,8 +37,8 @@ extern _X_EXPORT int vgaHWGetIndex(void);
#define VGA_ATTR_INDEX 0x3C0
#define VGA_ATTR_DATA_W 0x3C0
#define VGA_ATTR_DATA_R 0x3C1
-#define VGA_IN_STAT_0 0x3C2 /* read */
-#define VGA_MISC_OUT_W 0x3C2 /* write */
+#define VGA_IN_STAT_0 0x3C2 /* read */
+#define VGA_MISC_OUT_W 0x3C2 /* write */
#define VGA_ENABLE 0x3C3
#define VGA_SEQ_INDEX 0x3C4
#define VGA_SEQ_DATA 0x3C5
@@ -47,8 +46,8 @@ extern _X_EXPORT int vgaHWGetIndex(void);
#define VGA_DAC_READ_ADDR 0x3C7
#define VGA_DAC_WRITE_ADDR 0x3C8
#define VGA_DAC_DATA 0x3C9
-#define VGA_FEATURE_R 0x3CA /* read */
-#define VGA_MISC_OUT_R 0x3CC /* read */
+#define VGA_FEATURE_R 0x3CA /* read */
+#define VGA_MISC_OUT_R 0x3CC /* read */
#define VGA_GRAPH_INDEX 0x3CE
#define VGA_GRAPH_DATA 0x3CF
@@ -57,8 +56,8 @@ extern _X_EXPORT int vgaHWGetIndex(void);
#define VGA_CRTC_INDEX_OFFSET 0x04
#define VGA_CRTC_DATA_OFFSET 0x05
-#define VGA_IN_STAT_1_OFFSET 0x0A /* read */
-#define VGA_FEATURE_W_OFFSET 0x0A /* write */
+#define VGA_IN_STAT_1_OFFSET 0x0A /* read */
+#define VGA_FEATURE_W_OFFSET 0x0A /* write */
/* default number of VGA registers stored internally */
#define VGA_NUM_CRTC 25
@@ -80,26 +79,25 @@ extern _X_EXPORT int vgaHWGetIndex(void);
* vgaRegRec contains settings of standard VGA registers.
*/
typedef struct {
- unsigned char MiscOutReg; /* */
- unsigned char *CRTC; /* Crtc Controller */
+ unsigned char MiscOutReg; /* */
+ unsigned char *CRTC; /* Crtc Controller */
unsigned char *Sequencer; /* Video Sequencer */
unsigned char *Graphics; /* Video Graphics */
- unsigned char *Attribute; /* Video Atribute */
- unsigned char DAC[768]; /* Internal Colorlookuptable */
- unsigned char numCRTC; /* number of CRTC registers, def=VGA_NUM_CRTC */
- unsigned char numSequencer; /* number of seq registers, def=VGA_NUM_SEQ */
- unsigned char numGraphics; /* number of gfx registers, def=VGA_NUM_GFX */
- unsigned char numAttribute; /* number of attr registers, def=VGA_NUM_ATTR */
+ unsigned char *Attribute; /* Video Atribute */
+ unsigned char DAC[768]; /* Internal Colorlookuptable */
+ unsigned char numCRTC; /* number of CRTC registers, def=VGA_NUM_CRTC */
+ unsigned char numSequencer; /* number of seq registers, def=VGA_NUM_SEQ */
+ unsigned char numGraphics; /* number of gfx registers, def=VGA_NUM_GFX */
+ unsigned char numAttribute; /* number of attr registers, def=VGA_NUM_ATTR */
} vgaRegRec, *vgaRegPtr;
typedef struct _vgaHWRec *vgaHWPtr;
-typedef void (*vgaHWWriteIndexProcPtr)(vgaHWPtr hwp, CARD8 indx, CARD8 value);
-typedef CARD8 (*vgaHWReadIndexProcPtr)(vgaHWPtr hwp, CARD8 indx);
-typedef void (*vgaHWWriteProcPtr)(vgaHWPtr hwp, CARD8 value);
-typedef CARD8 (*vgaHWReadProcPtr)(vgaHWPtr hwp);
-typedef void (*vgaHWMiscProcPtr)(vgaHWPtr hwp);
-
+typedef void (*vgaHWWriteIndexProcPtr) (vgaHWPtr hwp, CARD8 indx, CARD8 value);
+typedef CARD8 (*vgaHWReadIndexProcPtr) (vgaHWPtr hwp, CARD8 indx);
+typedef void (*vgaHWWriteProcPtr) (vgaHWPtr hwp, CARD8 value);
+typedef CARD8 (*vgaHWReadProcPtr) (vgaHWPtr hwp);
+typedef void (*vgaHWMiscProcPtr) (vgaHWPtr hwp);
/*
* vgaHWRec contains per-screen information required by the vgahw module.
@@ -109,64 +107,64 @@ typedef void (*vgaHWMiscProcPtr)(vgaHWPtr hwp);
* via the first 17 attribute registers and not the main 8-bit palette.
*/
typedef struct _vgaHWRec {
- pointer Base; /* Address of "VGA" memory */
- int MapSize; /* Size of "VGA" memory */
- unsigned long MapPhys; /* phys location of VGA mem */
- int IOBase; /* I/O Base address */
- CARD8 * MMIOBase; /* Pointer to MMIO start */
- int MMIOOffset; /* base + offset + vgareg
- = mmioreg */
- pointer FontInfo1; /* save area for fonts in
- plane 2 */
- pointer FontInfo2; /* save area for fonts in
- plane 3 */
- pointer TextInfo; /* save area for text */
- vgaRegRec SavedReg; /* saved registers */
- vgaRegRec ModeReg; /* register settings for
- current mode */
- Bool ShowOverscan;
- Bool paletteEnabled;
- Bool cmapSaved;
- ScrnInfoPtr pScrn;
- vgaHWWriteIndexProcPtr writeCrtc;
- vgaHWReadIndexProcPtr readCrtc;
- vgaHWWriteIndexProcPtr writeGr;
- vgaHWReadIndexProcPtr readGr;
- vgaHWReadProcPtr readST00;
- vgaHWReadProcPtr readST01;
- vgaHWReadProcPtr readFCR;
- vgaHWWriteProcPtr writeFCR;
- vgaHWWriteIndexProcPtr writeAttr;
- vgaHWReadIndexProcPtr readAttr;
- vgaHWWriteIndexProcPtr writeSeq;
- vgaHWReadIndexProcPtr readSeq;
- vgaHWWriteProcPtr writeMiscOut;
- vgaHWReadProcPtr readMiscOut;
- vgaHWMiscProcPtr enablePalette;
- vgaHWMiscProcPtr disablePalette;
- vgaHWWriteProcPtr writeDacMask;
- vgaHWReadProcPtr readDacMask;
- vgaHWWriteProcPtr writeDacWriteAddr;
- vgaHWWriteProcPtr writeDacReadAddr;
- vgaHWWriteProcPtr writeDacData;
- vgaHWReadProcPtr readDacData;
- pointer ddc;
- struct pci_io_handle *io;
- vgaHWReadProcPtr readEnable;
- vgaHWWriteProcPtr writeEnable;
- struct pci_device *dev;
+ pointer Base; /* Address of "VGA" memory */
+ int MapSize; /* Size of "VGA" memory */
+ unsigned long MapPhys; /* phys location of VGA mem */
+ int IOBase; /* I/O Base address */
+ CARD8 *MMIOBase; /* Pointer to MMIO start */
+ int MMIOOffset; /* base + offset + vgareg
+ = mmioreg */
+ pointer FontInfo1; /* save area for fonts in
+ plane 2 */
+ pointer FontInfo2; /* save area for fonts in
+ plane 3 */
+ pointer TextInfo; /* save area for text */
+ vgaRegRec SavedReg; /* saved registers */
+ vgaRegRec ModeReg; /* register settings for
+ current mode */
+ Bool ShowOverscan;
+ Bool paletteEnabled;
+ Bool cmapSaved;
+ ScrnInfoPtr pScrn;
+ vgaHWWriteIndexProcPtr writeCrtc;
+ vgaHWReadIndexProcPtr readCrtc;
+ vgaHWWriteIndexProcPtr writeGr;
+ vgaHWReadIndexProcPtr readGr;
+ vgaHWReadProcPtr readST00;
+ vgaHWReadProcPtr readST01;
+ vgaHWReadProcPtr readFCR;
+ vgaHWWriteProcPtr writeFCR;
+ vgaHWWriteIndexProcPtr writeAttr;
+ vgaHWReadIndexProcPtr readAttr;
+ vgaHWWriteIndexProcPtr writeSeq;
+ vgaHWReadIndexProcPtr readSeq;
+ vgaHWWriteProcPtr writeMiscOut;
+ vgaHWReadProcPtr readMiscOut;
+ vgaHWMiscProcPtr enablePalette;
+ vgaHWMiscProcPtr disablePalette;
+ vgaHWWriteProcPtr writeDacMask;
+ vgaHWReadProcPtr readDacMask;
+ vgaHWWriteProcPtr writeDacWriteAddr;
+ vgaHWWriteProcPtr writeDacReadAddr;
+ vgaHWWriteProcPtr writeDacData;
+ vgaHWReadProcPtr readDacData;
+ pointer ddc;
+ struct pci_io_handle *io;
+ vgaHWReadProcPtr readEnable;
+ vgaHWWriteProcPtr writeEnable;
+ struct pci_device *dev;
} vgaHWRec;
/* Some macros that VGA drivers can use in their ChipProbe() function */
-#define OVERSCAN 0x11 /* Index of OverScan register */
+#define OVERSCAN 0x11 /* Index of OverScan register */
/* Flags that define how overscan correction should take place */
-#define KGA_FIX_OVERSCAN 1 /* overcan correction required */
-#define KGA_ENABLE_ON_ZERO 2 /* if possible enable display at beginning */
+#define KGA_FIX_OVERSCAN 1 /* overcan correction required */
+#define KGA_ENABLE_ON_ZERO 2 /* if possible enable display at beginning */
/* of next scanline/frame */
-#define KGA_BE_TOT_DEC 4 /* always fix problem by setting blank end */
- /* to total - 1 */
-#define BIT_PLANE 3 /* Which plane we write to in mono mode */
+#define KGA_BE_TOT_DEC 4 /* always fix problem by setting blank end */
+ /* to total - 1 */
+#define BIT_PLANE 3 /* Which plane we write to in mono mode */
#define BITS_PER_GUN 6
#define COLORMAP_SIZE 256
@@ -191,17 +189,22 @@ extern _X_EXPORT Bool vgaHWSaveScreen(ScreenPtr pScreen, int mode);
extern _X_EXPORT void vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on);
extern _X_EXPORT vgaHWBlankScreenProc *vgaHWBlankScreenWeak(void);
extern _X_EXPORT void vgaHWSeqReset(vgaHWPtr hwp, Bool start);
-extern _X_EXPORT void vgaHWRestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore);
+extern _X_EXPORT void vgaHWRestoreFonts(ScrnInfoPtr scrninfp,
+ vgaRegPtr restore);
extern _X_EXPORT void vgaHWRestoreMode(ScrnInfoPtr scrninfp, vgaRegPtr restore);
-extern _X_EXPORT void vgaHWRestoreColormap(ScrnInfoPtr scrninfp, vgaRegPtr restore);
-extern _X_EXPORT void vgaHWRestore(ScrnInfoPtr scrninfp, vgaRegPtr restore, int flags);
+extern _X_EXPORT void vgaHWRestoreColormap(ScrnInfoPtr scrninfp,
+ vgaRegPtr restore);
+extern _X_EXPORT void vgaHWRestore(ScrnInfoPtr scrninfp, vgaRegPtr restore,
+ int flags);
extern _X_EXPORT void vgaHWSaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save);
extern _X_EXPORT void vgaHWSaveMode(ScrnInfoPtr scrninfp, vgaRegPtr save);
extern _X_EXPORT void vgaHWSaveColormap(ScrnInfoPtr scrninfp, vgaRegPtr save);
-extern _X_EXPORT void vgaHWSave(ScrnInfoPtr scrninfp, vgaRegPtr save, int flags);
+extern _X_EXPORT void vgaHWSave(ScrnInfoPtr scrninfp, vgaRegPtr save,
+ int flags);
extern _X_EXPORT Bool vgaHWInit(ScrnInfoPtr scrnp, DisplayModePtr mode);
-extern _X_EXPORT Bool vgaHWSetRegCounts(ScrnInfoPtr scrp, int numCRTC, int numSequencer,
- int numGraphics, int numAttribute);
+extern _X_EXPORT Bool vgaHWSetRegCounts(ScrnInfoPtr scrp, int numCRTC,
+ int numSequencer, int numGraphics,
+ int numAttribute);
extern _X_EXPORT Bool vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src);
extern _X_EXPORT Bool vgaHWGetHWRec(ScrnInfoPtr scrp);
extern _X_EXPORT void vgaHWFreeHWRec(ScrnInfoPtr scrp);
@@ -212,22 +215,23 @@ extern _X_EXPORT void vgaHWLock(vgaHWPtr hwp);
extern _X_EXPORT void vgaHWUnlock(vgaHWPtr hwp);
extern _X_EXPORT void vgaHWEnable(vgaHWPtr hwp);
extern _X_EXPORT void vgaHWDisable(vgaHWPtr hwp);
-extern _X_EXPORT void vgaHWDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags);
+extern _X_EXPORT void vgaHWDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode,
+ int flags);
extern _X_EXPORT Bool vgaHWHandleColormaps(ScreenPtr pScreen);
extern _X_EXPORT void vgaHWddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed);
-extern _X_EXPORT CARD32 vgaHWHBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
- unsigned int Flags);
-extern _X_EXPORT CARD32 vgaHWVBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
- unsigned int Flags);
+extern _X_EXPORT CARD32 vgaHWHBlankKGA(DisplayModePtr mode, vgaRegPtr regp,
+ int nBits, unsigned int Flags);
+extern _X_EXPORT CARD32 vgaHWVBlankKGA(DisplayModePtr mode, vgaRegPtr regp,
+ int nBits, unsigned int Flags);
extern _X_EXPORT Bool vgaHWAllocDefaultRegs(vgaRegPtr regp);
extern _X_EXPORT DDC1SetSpeedProc vgaHWddc1SetSpeedWeak(void);
extern _X_EXPORT SaveScreenProcPtr vgaHWSaveScreenWeak(void);
extern _X_EXPORT void xf86GetClocks(ScrnInfoPtr pScrn, int num,
- Bool (*ClockFunc)(ScrnInfoPtr, int),
- void (*ProtectRegs)(ScrnInfoPtr, Bool),
- void (*BlankScreen)(ScrnInfoPtr, Bool),
- unsigned long vertsyncreg, int maskval,
- int knownclkindex, int knownclkvalue);
+ Bool (*ClockFunc) (ScrnInfoPtr, int),
+ void (*ProtectRegs) (ScrnInfoPtr, Bool),
+ void (*BlankScreen) (ScrnInfoPtr, Bool),
+ unsigned long vertsyncreg, int maskval,
+ int knownclkindex, int knownclkvalue);
-#endif /* _VGAHW_H */
+#endif /* _VGAHW_H */
diff --git a/xorg-server/hw/xfree86/x86emu/debug.c b/xorg-server/hw/xfree86/x86emu/debug.c
index 6dea9c7bc..1a8d1d6c4 100644
--- a/xorg-server/hw/xfree86/x86emu/debug.c
+++ b/xorg-server/hw/xfree86/x86emu/debug.c
@@ -49,46 +49,51 @@
#ifdef DEBUG
-static void print_encoded_bytes (u16 s, u16 o);
-static void print_decoded_instruction (void);
-static int parse_line (char *s, int *ps, int *n);
-
+static void print_encoded_bytes(u16 s, u16 o);
+static void print_decoded_instruction(void);
+static int parse_line(char *s, int *ps, int *n);
+
/* should look something like debug's output. */
-void X86EMU_trace_regs (void)
+void
+X86EMU_trace_regs(void)
{
- if (DEBUG_TRACE()) {
- x86emu_dump_regs();
+ if (DEBUG_TRACE()) {
+ x86emu_dump_regs();
}
- if (DEBUG_DECODE() && ! DEBUG_DECODE_NOPRINT()) {
- printk("%04x:%04x ",M.x86.saved_cs, M.x86.saved_ip);
- print_encoded_bytes( M.x86.saved_cs, M.x86.saved_ip);
- print_decoded_instruction();
+ if (DEBUG_DECODE() && !DEBUG_DECODE_NOPRINT()) {
+ printk("%04x:%04x ", M.x86.saved_cs, M.x86.saved_ip);
+ print_encoded_bytes(M.x86.saved_cs, M.x86.saved_ip);
+ print_decoded_instruction();
}
}
-void X86EMU_trace_xregs (void)
+void
+X86EMU_trace_xregs(void)
{
- if (DEBUG_TRACE()) {
- x86emu_dump_xregs();
+ if (DEBUG_TRACE()) {
+ x86emu_dump_xregs();
}
}
-void x86emu_just_disassemble (void)
+void
+x86emu_just_disassemble(void)
{
/*
* This routine called if the flag DEBUG_DISASSEMBLE is set kind
* of a hack!
*/
- printk("%04x:%04x ",M.x86.saved_cs, M.x86.saved_ip);
- print_encoded_bytes( M.x86.saved_cs, M.x86.saved_ip);
- print_decoded_instruction();
+ printk("%04x:%04x ", M.x86.saved_cs, M.x86.saved_ip);
+ print_encoded_bytes(M.x86.saved_cs, M.x86.saved_ip);
+ print_decoded_instruction();
}
-static void disassemble_forward (u16 seg, u16 off, int n)
+static void
+disassemble_forward(u16 seg, u16 off, int n)
{
- X86EMU_sysEnv tregs;
- int i;
- u8 op1;
+ X86EMU_sysEnv tregs;
+ int i;
+ u8 op1;
+
/*
* hack, hack, hack. What we do is use the exact machinery set up
* for execution, except that now there is an additional state
@@ -113,17 +118,17 @@ static void disassemble_forward (u16 seg, u16 off, int n)
* This was done for an entirely different reason, but makes a
* nice way to get the system to help debug codes.
*/
- tregs = M;
+ tregs = M;
tregs.x86.R_IP = off;
tregs.x86.R_CS = seg;
-
+
/* reset the decoding buffers */
tregs.x86.enc_str_pos = 0;
tregs.x86.enc_pos = 0;
-
+
/* turn on the "disassemble only, no execute" flag */
tregs.x86.debug |= DEBUG_DISASSEMBLE_F;
-
+
/* DUMP NEXT n instructions to screen in straight_line fashion */
/*
* This looks like the regular instruction fetch stream, except
@@ -132,299 +137,359 @@ static void disassemble_forward (u16 seg, u16 off, int n)
* the instruction. XXX --- CHECK THAT MEM IS NOT AFFECTED!!!
* Note the use of a copy of the register structure...
*/
- for (i=0; i<n; i++) {
- op1 = (*sys_rdb)(((u32)M.x86.R_CS<<4) + (M.x86.R_IP++));
- (x86emu_optab[op1])(op1);
+ for (i = 0; i < n; i++) {
+ op1 = (*sys_rdb) (((u32) M.x86.R_CS << 4) + (M.x86.R_IP++));
+ (x86emu_optab[op1]) (op1);
}
/* end major hack mode. */
}
-void x86emu_check_ip_access (void)
+void
+x86emu_check_ip_access(void)
{
/* NULL as of now */
}
-void x86emu_check_sp_access (void)
+void
+x86emu_check_sp_access(void)
{
}
-void x86emu_check_mem_access (u32 dummy)
+void
+x86emu_check_mem_access(u32 dummy)
{
- /* check bounds, etc */
+ /* check bounds, etc */
}
-void x86emu_check_data_access (uint dummy1, uint dummy2)
+void
+x86emu_check_data_access(uint dummy1, uint dummy2)
{
- /* check bounds, etc */
+ /* check bounds, etc */
}
-void x86emu_inc_decoded_inst_len (int x)
+void
+x86emu_inc_decoded_inst_len(int x)
{
- M.x86.enc_pos += x;
+ M.x86.enc_pos += x;
}
-void x86emu_decode_printf (const char *x)
+void
+x86emu_decode_printf(const char *x)
{
- sprintf(M.x86.decoded_buf+M.x86.enc_str_pos,"%s",x);
- M.x86.enc_str_pos += strlen(x);
+ sprintf(M.x86.decoded_buf + M.x86.enc_str_pos, "%s", x);
+ M.x86.enc_str_pos += strlen(x);
}
-void x86emu_decode_printf2 (const char *x, int y)
+void
+x86emu_decode_printf2(const char *x, int y)
{
- char temp[100];
- snprintf(temp,sizeof(temp),x,y);
- sprintf(M.x86.decoded_buf+M.x86.enc_str_pos,"%s",temp);
- M.x86.enc_str_pos += strlen(temp);
+ char temp[100];
+
+ snprintf(temp, sizeof(temp), x, y);
+ sprintf(M.x86.decoded_buf + M.x86.enc_str_pos, "%s", temp);
+ M.x86.enc_str_pos += strlen(temp);
}
-void x86emu_end_instr (void)
+void
+x86emu_end_instr(void)
{
- M.x86.enc_str_pos = 0;
- M.x86.enc_pos = 0;
+ M.x86.enc_str_pos = 0;
+ M.x86.enc_pos = 0;
}
-static void print_encoded_bytes (u16 s, u16 o)
+static void
+print_encoded_bytes(u16 s, u16 o)
{
int i;
char buf1[64];
- for (i=0; i< M.x86.enc_pos; i++) {
- sprintf(buf1+2*i,"%02x", fetch_data_byte_abs(s,o+i));
+
+ for (i = 0; i < M.x86.enc_pos; i++) {
+ sprintf(buf1 + 2 * i, "%02x", fetch_data_byte_abs(s, o + i));
}
- printk("%-20s",buf1);
+ printk("%-20s", buf1);
}
-static void print_decoded_instruction (void)
+static void
+print_decoded_instruction(void)
{
- printk("%s", M.x86.decoded_buf);
+ printk("%s", M.x86.decoded_buf);
}
-void x86emu_print_int_vect (u16 iv)
+void
+x86emu_print_int_vect(u16 iv)
{
- u16 seg,off;
+ u16 seg, off;
- if (iv > 256) return;
- seg = fetch_data_word_abs(0,iv*4);
- off = fetch_data_word_abs(0,iv*4+2);
- printk("%04x:%04x ", seg, off);
+ if (iv > 256)
+ return;
+ seg = fetch_data_word_abs(0, iv * 4);
+ off = fetch_data_word_abs(0, iv * 4 + 2);
+ printk("%04x:%04x ", seg, off);
}
-void X86EMU_dump_memory (u16 seg, u16 off, u32 amt)
+void
+X86EMU_dump_memory(u16 seg, u16 off, u32 amt)
{
- u32 start = off & 0xfffffff0;
- u32 end = (off+16) & 0xfffffff0;
- u32 i;
- u32 current;
-
- current = start;
- while (end <= off + amt) {
- printk("%04x:%04x ", seg, start);
- for (i=start; i< off; i++)
- printk(" ");
- for ( ; i< end; i++)
- printk("%02x ", fetch_data_byte_abs(seg,i));
- printk("\n");
- start = end;
- end = start + 16;
- }
+ u32 start = off & 0xfffffff0;
+ u32 end = (off + 16) & 0xfffffff0;
+ u32 i;
+ u32 current;
+
+ current = start;
+ while (end <= off + amt) {
+ printk("%04x:%04x ", seg, start);
+ for (i = start; i < off; i++)
+ printk(" ");
+ for (; i < end; i++)
+ printk("%02x ", fetch_data_byte_abs(seg, i));
+ printk("\n");
+ start = end;
+ end = start + 16;
+ }
}
-void x86emu_single_step (void)
+void
+x86emu_single_step(void)
{
char s[1024];
int ps[10];
int ntok;
int cmd;
int done;
- int segment;
+ int segment;
int offset;
static int breakpoint;
static int noDecode = 1;
-
+
char *p;
- if (DEBUG_BREAK()) {
- if (M.x86.saved_ip != breakpoint) {
- return;
- } else {
- M.x86.debug &= ~DEBUG_DECODE_NOPRINT_F;
- M.x86.debug |= DEBUG_TRACE_F;
- M.x86.debug &= ~DEBUG_BREAK_F;
- print_decoded_instruction ();
- X86EMU_trace_regs();
- }
- }
- done=0;
- offset = M.x86.saved_ip;
+ if (DEBUG_BREAK()) {
+ if (M.x86.saved_ip != breakpoint) {
+ return;
+ }
+ else {
+ M.x86.debug &= ~DEBUG_DECODE_NOPRINT_F;
+ M.x86.debug |= DEBUG_TRACE_F;
+ M.x86.debug &= ~DEBUG_BREAK_F;
+ print_decoded_instruction();
+ X86EMU_trace_regs();
+ }
+ }
+ done = 0;
+ offset = M.x86.saved_ip;
while (!done) {
printk("-");
p = fgets(s, 1023, stdin);
cmd = parse_line(s, ps, &ntok);
- switch(cmd) {
- case 'u':
- disassemble_forward(M.x86.saved_cs,(u16)offset,10);
+ switch (cmd) {
+ case 'u':
+ disassemble_forward(M.x86.saved_cs, (u16) offset, 10);
break;
- case 'd':
- if (ntok == 2) {
- segment = M.x86.saved_cs;
- offset = ps[1];
- X86EMU_dump_memory(segment,(u16)offset,16);
- offset += 16;
- } else if (ntok == 3) {
- segment = ps[1];
- offset = ps[2];
- X86EMU_dump_memory(segment,(u16)offset,16);
- offset += 16;
- } else {
- segment = M.x86.saved_cs;
- X86EMU_dump_memory(segment,(u16)offset,16);
- offset += 16;
- }
+ case 'd':
+ if (ntok == 2) {
+ segment = M.x86.saved_cs;
+ offset = ps[1];
+ X86EMU_dump_memory(segment, (u16) offset, 16);
+ offset += 16;
+ }
+ else if (ntok == 3) {
+ segment = ps[1];
+ offset = ps[2];
+ X86EMU_dump_memory(segment, (u16) offset, 16);
+ offset += 16;
+ }
+ else {
+ segment = M.x86.saved_cs;
+ X86EMU_dump_memory(segment, (u16) offset, 16);
+ offset += 16;
+ }
break;
- case 'c':
- M.x86.debug ^= DEBUG_TRACECALL_F;
+ case 'c':
+ M.x86.debug ^= DEBUG_TRACECALL_F;
break;
- case 's':
- M.x86.debug ^= DEBUG_SVC_F | DEBUG_SYS_F | DEBUG_SYSINT_F;
+ case 's':
+ M.x86.debug ^= DEBUG_SVC_F | DEBUG_SYS_F | DEBUG_SYSINT_F;
break;
- case 'r':
- X86EMU_trace_regs();
+ case 'r':
+ X86EMU_trace_regs();
break;
- case 'x':
- X86EMU_trace_xregs();
+ case 'x':
+ X86EMU_trace_xregs();
break;
- case 'g':
+ case 'g':
if (ntok == 2) {
breakpoint = ps[1];
- if (noDecode) {
- M.x86.debug |= DEBUG_DECODE_NOPRINT_F;
- } else {
- M.x86.debug &= ~DEBUG_DECODE_NOPRINT_F;
- }
- M.x86.debug &= ~DEBUG_TRACE_F;
- M.x86.debug |= DEBUG_BREAK_F;
- done = 1;
+ if (noDecode) {
+ M.x86.debug |= DEBUG_DECODE_NOPRINT_F;
+ }
+ else {
+ M.x86.debug &= ~DEBUG_DECODE_NOPRINT_F;
+ }
+ M.x86.debug &= ~DEBUG_TRACE_F;
+ M.x86.debug |= DEBUG_BREAK_F;
+ done = 1;
}
break;
- case 'q':
- M.x86.debug |= DEBUG_EXIT;
- return;
- case 'P':
- noDecode = (noDecode)?0:1;
- printk("Toggled decoding to %s\n",(noDecode)?"FALSE":"TRUE");
- break;
- case 't':
- case 0:
+ case 'q':
+ M.x86.debug |= DEBUG_EXIT;
+ return;
+ case 'P':
+ noDecode = (noDecode) ? 0 : 1;
+ printk("Toggled decoding to %s\n", (noDecode) ? "FALSE" : "TRUE");
+ break;
+ case 't':
+ case 0:
done = 1;
break;
- }
+ }
}
}
-int X86EMU_trace_on(void)
+int
+X86EMU_trace_on(void)
{
- return M.x86.debug |= DEBUG_STEP_F | DEBUG_DECODE_F | DEBUG_TRACE_F;
+ return M.x86.debug |= DEBUG_STEP_F | DEBUG_DECODE_F | DEBUG_TRACE_F;
}
-int X86EMU_trace_off(void)
+int
+X86EMU_trace_off(void)
{
- return M.x86.debug &= ~(DEBUG_STEP_F | DEBUG_DECODE_F | DEBUG_TRACE_F);
+ return M.x86.debug &= ~(DEBUG_STEP_F | DEBUG_DECODE_F | DEBUG_TRACE_F);
}
-static int parse_line (char *s, int *ps, int *n)
+static int
+parse_line(char *s, int *ps, int *n)
{
int cmd;
*n = 0;
- while(*s == ' ' || *s == '\t') s++;
+ while (*s == ' ' || *s == '\t')
+ s++;
ps[*n] = *s;
switch (*s) {
- case '\n':
+ case '\n':
*n += 1;
return 0;
- default:
+ default:
cmd = *s;
*n += 1;
}
- while (1) {
- while (*s != ' ' && *s != '\t' && *s != '\n') s++;
-
- if (*s == '\n')
- return cmd;
-
- while(*s == ' ' || *s == '\t') s++;
-
- sscanf(s,"%x",&ps[*n]);
- *n += 1;
- }
+ while (1) {
+ while (*s != ' ' && *s != '\t' && *s != '\n')
+ s++;
+
+ if (*s == '\n')
+ return cmd;
+
+ while (*s == ' ' || *s == '\t')
+ s++;
+
+ sscanf(s, "%x", &ps[*n]);
+ *n += 1;
+ }
}
-#endif /* DEBUG */
+#endif /* DEBUG */
-void x86emu_dump_regs (void)
+void
+x86emu_dump_regs(void)
{
- printk("\tAX=%04x ", M.x86.R_AX );
- printk("BX=%04x ", M.x86.R_BX );
- printk("CX=%04x ", M.x86.R_CX );
- printk("DX=%04x ", M.x86.R_DX );
- printk("SP=%04x ", M.x86.R_SP );
- printk("BP=%04x ", M.x86.R_BP );
- printk("SI=%04x ", M.x86.R_SI );
- printk("DI=%04x\n", M.x86.R_DI );
- printk("\tDS=%04x ", M.x86.R_DS );
- printk("ES=%04x ", M.x86.R_ES );
- printk("SS=%04x ", M.x86.R_SS );
- printk("CS=%04x ", M.x86.R_CS );
- printk("IP=%04x ", M.x86.R_IP );
- if (ACCESS_FLAG(F_OF)) printk("OV "); /* CHECKED... */
- else printk("NV ");
- if (ACCESS_FLAG(F_DF)) printk("DN ");
- else printk("UP ");
- if (ACCESS_FLAG(F_IF)) printk("EI ");
- else printk("DI ");
- if (ACCESS_FLAG(F_SF)) printk("NG ");
- else printk("PL ");
- if (ACCESS_FLAG(F_ZF)) printk("ZR ");
- else printk("NZ ");
- if (ACCESS_FLAG(F_AF)) printk("AC ");
- else printk("NA ");
- if (ACCESS_FLAG(F_PF)) printk("PE ");
- else printk("PO ");
- if (ACCESS_FLAG(F_CF)) printk("CY ");
- else printk("NC ");
- printk("\n");
+ printk("\tAX=%04x ", M.x86.R_AX);
+ printk("BX=%04x ", M.x86.R_BX);
+ printk("CX=%04x ", M.x86.R_CX);
+ printk("DX=%04x ", M.x86.R_DX);
+ printk("SP=%04x ", M.x86.R_SP);
+ printk("BP=%04x ", M.x86.R_BP);
+ printk("SI=%04x ", M.x86.R_SI);
+ printk("DI=%04x\n", M.x86.R_DI);
+ printk("\tDS=%04x ", M.x86.R_DS);
+ printk("ES=%04x ", M.x86.R_ES);
+ printk("SS=%04x ", M.x86.R_SS);
+ printk("CS=%04x ", M.x86.R_CS);
+ printk("IP=%04x ", M.x86.R_IP);
+ if (ACCESS_FLAG(F_OF))
+ printk("OV "); /* CHECKED... */
+ else
+ printk("NV ");
+ if (ACCESS_FLAG(F_DF))
+ printk("DN ");
+ else
+ printk("UP ");
+ if (ACCESS_FLAG(F_IF))
+ printk("EI ");
+ else
+ printk("DI ");
+ if (ACCESS_FLAG(F_SF))
+ printk("NG ");
+ else
+ printk("PL ");
+ if (ACCESS_FLAG(F_ZF))
+ printk("ZR ");
+ else
+ printk("NZ ");
+ if (ACCESS_FLAG(F_AF))
+ printk("AC ");
+ else
+ printk("NA ");
+ if (ACCESS_FLAG(F_PF))
+ printk("PE ");
+ else
+ printk("PO ");
+ if (ACCESS_FLAG(F_CF))
+ printk("CY ");
+ else
+ printk("NC ");
+ printk("\n");
}
-void x86emu_dump_xregs (void)
+void
+x86emu_dump_xregs(void)
{
- printk("\tEAX=%08x ", M.x86.R_EAX );
- printk("EBX=%08x ", M.x86.R_EBX );
- printk("ECX=%08x ", M.x86.R_ECX );
- printk("EDX=%08x \n", M.x86.R_EDX );
- printk("\tESP=%08x ", M.x86.R_ESP );
- printk("EBP=%08x ", M.x86.R_EBP );
- printk("ESI=%08x ", M.x86.R_ESI );
- printk("EDI=%08x\n", M.x86.R_EDI );
- printk("\tDS=%04x ", M.x86.R_DS );
- printk("ES=%04x ", M.x86.R_ES );
- printk("SS=%04x ", M.x86.R_SS );
- printk("CS=%04x ", M.x86.R_CS );
- printk("EIP=%08x\n\t", M.x86.R_EIP );
- if (ACCESS_FLAG(F_OF)) printk("OV "); /* CHECKED... */
- else printk("NV ");
- if (ACCESS_FLAG(F_DF)) printk("DN ");
- else printk("UP ");
- if (ACCESS_FLAG(F_IF)) printk("EI ");
- else printk("DI ");
- if (ACCESS_FLAG(F_SF)) printk("NG ");
- else printk("PL ");
- if (ACCESS_FLAG(F_ZF)) printk("ZR ");
- else printk("NZ ");
- if (ACCESS_FLAG(F_AF)) printk("AC ");
- else printk("NA ");
- if (ACCESS_FLAG(F_PF)) printk("PE ");
- else printk("PO ");
- if (ACCESS_FLAG(F_CF)) printk("CY ");
- else printk("NC ");
- printk("\n");
+ printk("\tEAX=%08x ", M.x86.R_EAX);
+ printk("EBX=%08x ", M.x86.R_EBX);
+ printk("ECX=%08x ", M.x86.R_ECX);
+ printk("EDX=%08x \n", M.x86.R_EDX);
+ printk("\tESP=%08x ", M.x86.R_ESP);
+ printk("EBP=%08x ", M.x86.R_EBP);
+ printk("ESI=%08x ", M.x86.R_ESI);
+ printk("EDI=%08x\n", M.x86.R_EDI);
+ printk("\tDS=%04x ", M.x86.R_DS);
+ printk("ES=%04x ", M.x86.R_ES);
+ printk("SS=%04x ", M.x86.R_SS);
+ printk("CS=%04x ", M.x86.R_CS);
+ printk("EIP=%08x\n\t", M.x86.R_EIP);
+ if (ACCESS_FLAG(F_OF))
+ printk("OV "); /* CHECKED... */
+ else
+ printk("NV ");
+ if (ACCESS_FLAG(F_DF))
+ printk("DN ");
+ else
+ printk("UP ");
+ if (ACCESS_FLAG(F_IF))
+ printk("EI ");
+ else
+ printk("DI ");
+ if (ACCESS_FLAG(F_SF))
+ printk("NG ");
+ else
+ printk("PL ");
+ if (ACCESS_FLAG(F_ZF))
+ printk("ZR ");
+ else
+ printk("NZ ");
+ if (ACCESS_FLAG(F_AF))
+ printk("AC ");
+ else
+ printk("NA ");
+ if (ACCESS_FLAG(F_PF))
+ printk("PE ");
+ else
+ printk("PO ");
+ if (ACCESS_FLAG(F_CF))
+ printk("CY ");
+ else
+ printk("NC ");
+ printk("\n");
}
diff --git a/xorg-server/hw/xfree86/x86emu/decode.c b/xorg-server/hw/xfree86/x86emu/decode.c
index 9339f4c7f..12f8fb84b 100644
--- a/xorg-server/hw/xfree86/x86emu/decode.c
+++ b/xorg-server/hw/xfree86/x86emu/decode.c
@@ -46,25 +46,27 @@
REMARKS:
Handles any pending asychronous interrupts.
****************************************************************************/
-static void x86emu_intr_handle(void)
+static void
+x86emu_intr_handle(void)
{
- u8 intno;
-
- if (M.x86.intr & INTR_SYNCH) {
- intno = M.x86.intno;
- if (_X86EMU_intrTab[intno]) {
- (*_X86EMU_intrTab[intno])(intno);
- } else {
- push_word((u16)M.x86.R_FLG);
- CLEAR_FLAG(F_IF);
- CLEAR_FLAG(F_TF);
- push_word(M.x86.R_CS);
- M.x86.R_CS = mem_access_word(intno * 4 + 2);
- push_word(M.x86.R_IP);
- M.x86.R_IP = mem_access_word(intno * 4);
- M.x86.intr = 0;
- }
- }
+ u8 intno;
+
+ if (M.x86.intr & INTR_SYNCH) {
+ intno = M.x86.intno;
+ if (_X86EMU_intrTab[intno]) {
+ (*_X86EMU_intrTab[intno]) (intno);
+ }
+ else {
+ push_word((u16) M.x86.R_FLG);
+ CLEAR_FLAG(F_IF);
+ CLEAR_FLAG(F_TF);
+ push_word(M.x86.R_CS);
+ M.x86.R_CS = mem_access_word(intno * 4 + 2);
+ push_word(M.x86.R_IP);
+ M.x86.R_IP = mem_access_word(intno * 4);
+ M.x86.intr = 0;
+ }
+ }
}
/****************************************************************************
@@ -75,11 +77,11 @@ REMARKS:
Raise the specified interrupt to be handled before the execution of the
next instruction.
****************************************************************************/
-void x86emu_intr_raise(
- u8 intrnum)
+void
+x86emu_intr_raise(u8 intrnum)
{
- M.x86.intno = intrnum;
- M.x86.intr |= INTR_SYNCH;
+ M.x86.intno = intrnum;
+ M.x86.intr |= INTR_SYNCH;
}
/****************************************************************************
@@ -88,38 +90,39 @@ Main execution loop for the emulator. We return from here when the system
halts, which is normally caused by a stack fault when we return from the
original real mode call.
****************************************************************************/
-void X86EMU_exec(void)
+void
+X86EMU_exec(void)
{
- u8 op1;
-
- M.x86.intr = 0;
- DB(x86emu_end_instr();)
-
- for (;;) {
-DB( if (CHECK_IP_FETCH())
- x86emu_check_ip_access();)
- /* If debugging, save the IP and CS values. */
- SAVE_IP_CS(M.x86.R_CS, M.x86.R_IP);
- INC_DECODED_INST_LEN(1);
- if (M.x86.intr) {
- if (M.x86.intr & INTR_HALTED) {
-DB( if (M.x86.R_SP != 0) {
- printk("halted\n");
- X86EMU_trace_regs();
- }
- else {
- if (M.x86.debug)
- printk("Service completed successfully\n");
- })
- return;
+ u8 op1;
+
+ M.x86.intr = 0;
+ DB(x86emu_end_instr();
+ )
+
+ for (;;) {
+ DB(if (CHECK_IP_FETCH())
+ x86emu_check_ip_access();)
+ /* If debugging, save the IP and CS values. */
+ SAVE_IP_CS(M.x86.R_CS, M.x86.R_IP);
+ INC_DECODED_INST_LEN(1);
+ if (M.x86.intr) {
+ if (M.x86.intr & INTR_HALTED) {
+ DB(if (M.x86.R_SP != 0) {
+ printk("halted\n"); X86EMU_trace_regs();}
+ else {
+ if (M.x86.debug)
+ printk("Service completed successfully\n");}
+ )
+ return;
}
- if (((M.x86.intr & INTR_SYNCH) && (M.x86.intno == 0 || M.x86.intno == 2)) ||
- !ACCESS_FLAG(F_IF)) {
- x86emu_intr_handle();
- }
- }
- op1 = (*sys_rdb)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP++));
- (*x86emu_optab[op1])(op1);
+ if (((M.x86.intr & INTR_SYNCH) &&
+ (M.x86.intno == 0 || M.x86.intno == 2)) ||
+ !ACCESS_FLAG(F_IF)) {
+ x86emu_intr_handle();
+ }
+ }
+ op1 = (*sys_rdb) (((u32) M.x86.R_CS << 4) + (M.x86.R_IP++));
+ (*x86emu_optab[op1]) (op1);
if (M.x86.debug & DEBUG_EXIT) {
M.x86.debug &= ~DEBUG_EXIT;
return;
@@ -131,9 +134,10 @@ DB( if (M.x86.R_SP != 0) {
REMARKS:
Halts the system by setting the halted system flag.
****************************************************************************/
-void X86EMU_halt_sys(void)
+void
+X86EMU_halt_sys(void)
{
- M.x86.intr |= INTR_HALTED;
+ M.x86.intr |= INTR_HALTED;
}
/****************************************************************************
@@ -148,19 +152,17 @@ next instruction.
NOTE: Do not inline this function, as (*sys_rdb) is already inline!
****************************************************************************/
-void fetch_decode_modrm(
- int *mod,
- int *regh,
- int *regl)
+void
+fetch_decode_modrm(int *mod, int *regh, int *regl)
{
- int fetched;
-
-DB( if (CHECK_IP_FETCH())
- x86emu_check_ip_access();)
- fetched = (*sys_rdb)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP++));
- INC_DECODED_INST_LEN(1);
- *mod = (fetched >> 6) & 0x03;
- *regh = (fetched >> 3) & 0x07;
+ int fetched;
+
+ DB(if (CHECK_IP_FETCH())
+ x86emu_check_ip_access();)
+ fetched = (*sys_rdb) (((u32) M.x86.R_CS << 4) + (M.x86.R_IP++));
+ INC_DECODED_INST_LEN(1);
+ *mod = (fetched >> 6) & 0x03;
+ *regh = (fetched >> 3) & 0x07;
*regl = (fetched >> 0) & 0x07;
}
@@ -174,15 +176,16 @@ moves the instruction pointer to the next value.
NOTE: Do not inline this function, as (*sys_rdb) is already inline!
****************************************************************************/
-u8 fetch_byte_imm(void)
+u8
+fetch_byte_imm(void)
{
- u8 fetched;
+ u8 fetched;
-DB( if (CHECK_IP_FETCH())
- x86emu_check_ip_access();)
- fetched = (*sys_rdb)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP++));
- INC_DECODED_INST_LEN(1);
- return fetched;
+ DB(if (CHECK_IP_FETCH())
+ x86emu_check_ip_access();)
+ fetched = (*sys_rdb) (((u32) M.x86.R_CS << 4) + (M.x86.R_IP++));
+ INC_DECODED_INST_LEN(1);
+ return fetched;
}
/****************************************************************************
@@ -195,16 +198,17 @@ moves the instruction pointer to the next value.
NOTE: Do not inline this function, as (*sys_rdw) is already inline!
****************************************************************************/
-u16 fetch_word_imm(void)
+u16
+fetch_word_imm(void)
{
- u16 fetched;
-
-DB( if (CHECK_IP_FETCH())
- x86emu_check_ip_access();)
- fetched = (*sys_rdw)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP));
- M.x86.R_IP += 2;
- INC_DECODED_INST_LEN(2);
- return fetched;
+ u16 fetched;
+
+ DB(if (CHECK_IP_FETCH())
+ x86emu_check_ip_access();)
+ fetched = (*sys_rdw) (((u32) M.x86.R_CS << 4) + (M.x86.R_IP));
+ M.x86.R_IP += 2;
+ INC_DECODED_INST_LEN(2);
+ return fetched;
}
/****************************************************************************
@@ -217,16 +221,17 @@ moves the instruction pointer to the next value.
NOTE: Do not inline this function, as (*sys_rdw) is already inline!
****************************************************************************/
-u32 fetch_long_imm(void)
+u32
+fetch_long_imm(void)
{
- u32 fetched;
-
-DB( if (CHECK_IP_FETCH())
- x86emu_check_ip_access();)
- fetched = (*sys_rdl)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP));
- M.x86.R_IP += 4;
- INC_DECODED_INST_LEN(4);
- return fetched;
+ u32 fetched;
+
+ DB(if (CHECK_IP_FETCH())
+ x86emu_check_ip_access();)
+ fetched = (*sys_rdl) (((u32) M.x86.R_CS << 4) + (M.x86.R_IP));
+ M.x86.R_IP += 4;
+ INC_DECODED_INST_LEN(4);
+ return fetched;
}
/****************************************************************************
@@ -258,38 +263,39 @@ cpu-state-varible M.x86.mode. There are several potential states:
Each of the above 7 items are handled with a bit in the mode field.
****************************************************************************/
-_INLINE u32 get_data_segment(void)
+_INLINE u32
+get_data_segment(void)
{
#define GET_SEGMENT(segment)
- switch (M.x86.mode & SYSMODE_SEGMASK) {
- case 0: /* default case: use ds register */
- case SYSMODE_SEGOVR_DS:
- case SYSMODE_SEGOVR_DS | SYSMODE_SEG_DS_SS:
- return M.x86.R_DS;
- case SYSMODE_SEG_DS_SS: /* non-overridden, use ss register */
- return M.x86.R_SS;
- case SYSMODE_SEGOVR_CS:
- case SYSMODE_SEGOVR_CS | SYSMODE_SEG_DS_SS:
- return M.x86.R_CS;
- case SYSMODE_SEGOVR_ES:
- case SYSMODE_SEGOVR_ES | SYSMODE_SEG_DS_SS:
- return M.x86.R_ES;
- case SYSMODE_SEGOVR_FS:
- case SYSMODE_SEGOVR_FS | SYSMODE_SEG_DS_SS:
- return M.x86.R_FS;
- case SYSMODE_SEGOVR_GS:
- case SYSMODE_SEGOVR_GS | SYSMODE_SEG_DS_SS:
- return M.x86.R_GS;
- case SYSMODE_SEGOVR_SS:
- case SYSMODE_SEGOVR_SS | SYSMODE_SEG_DS_SS:
- return M.x86.R_SS;
- default:
+ switch (M.x86.mode & SYSMODE_SEGMASK) {
+ case 0: /* default case: use ds register */
+ case SYSMODE_SEGOVR_DS:
+ case SYSMODE_SEGOVR_DS | SYSMODE_SEG_DS_SS:
+ return M.x86.R_DS;
+ case SYSMODE_SEG_DS_SS: /* non-overridden, use ss register */
+ return M.x86.R_SS;
+ case SYSMODE_SEGOVR_CS:
+ case SYSMODE_SEGOVR_CS | SYSMODE_SEG_DS_SS:
+ return M.x86.R_CS;
+ case SYSMODE_SEGOVR_ES:
+ case SYSMODE_SEGOVR_ES | SYSMODE_SEG_DS_SS:
+ return M.x86.R_ES;
+ case SYSMODE_SEGOVR_FS:
+ case SYSMODE_SEGOVR_FS | SYSMODE_SEG_DS_SS:
+ return M.x86.R_FS;
+ case SYSMODE_SEGOVR_GS:
+ case SYSMODE_SEGOVR_GS | SYSMODE_SEG_DS_SS:
+ return M.x86.R_GS;
+ case SYSMODE_SEGOVR_SS:
+ case SYSMODE_SEGOVR_SS | SYSMODE_SEG_DS_SS:
+ return M.x86.R_SS;
+ default:
#ifdef DEBUG
- printk("error: should not happen: multiple overrides.\n");
+ printk("error: should not happen: multiple overrides.\n");
#endif
- HALT_SYS();
- return 0;
- }
+ HALT_SYS();
+ return 0;
+ }
}
/****************************************************************************
@@ -301,14 +307,14 @@ Byte value read from the absolute memory location.
NOTE: Do not inline this function as (*sys_rdX) is already inline!
****************************************************************************/
-u8 fetch_data_byte(
- uint offset)
+u8
+fetch_data_byte(uint offset)
{
#ifdef DEBUG
- if (CHECK_DATA_ACCESS())
- x86emu_check_data_access((u16)get_data_segment(), offset);
+ if (CHECK_DATA_ACCESS())
+ x86emu_check_data_access((u16) get_data_segment(), offset);
#endif
- return (*sys_rdb)((get_data_segment() << 4) + offset);
+ return (*sys_rdb) ((get_data_segment() << 4) + offset);
}
/****************************************************************************
@@ -320,14 +326,14 @@ Word value read from the absolute memory location.
NOTE: Do not inline this function as (*sys_rdX) is already inline!
****************************************************************************/
-u16 fetch_data_word(
- uint offset)
+u16
+fetch_data_word(uint offset)
{
#ifdef DEBUG
- if (CHECK_DATA_ACCESS())
- x86emu_check_data_access((u16)get_data_segment(), offset);
+ if (CHECK_DATA_ACCESS())
+ x86emu_check_data_access((u16) get_data_segment(), offset);
#endif
- return (*sys_rdw)((get_data_segment() << 4) + offset);
+ return (*sys_rdw) ((get_data_segment() << 4) + offset);
}
/****************************************************************************
@@ -339,14 +345,14 @@ Long value read from the absolute memory location.
NOTE: Do not inline this function as (*sys_rdX) is already inline!
****************************************************************************/
-u32 fetch_data_long(
- uint offset)
+u32
+fetch_data_long(uint offset)
{
#ifdef DEBUG
- if (CHECK_DATA_ACCESS())
- x86emu_check_data_access((u16)get_data_segment(), offset);
+ if (CHECK_DATA_ACCESS())
+ x86emu_check_data_access((u16) get_data_segment(), offset);
#endif
- return (*sys_rdl)((get_data_segment() << 4) + offset);
+ return (*sys_rdl) ((get_data_segment() << 4) + offset);
}
/****************************************************************************
@@ -359,15 +365,14 @@ Byte value read from the absolute memory location.
NOTE: Do not inline this function as (*sys_rdX) is already inline!
****************************************************************************/
-u8 fetch_data_byte_abs(
- uint segment,
- uint offset)
+u8
+fetch_data_byte_abs(uint segment, uint offset)
{
#ifdef DEBUG
- if (CHECK_DATA_ACCESS())
- x86emu_check_data_access(segment, offset);
+ if (CHECK_DATA_ACCESS())
+ x86emu_check_data_access(segment, offset);
#endif
- return (*sys_rdb)(((u32)segment << 4) + offset);
+ return (*sys_rdb) (((u32) segment << 4) + offset);
}
/****************************************************************************
@@ -380,15 +385,14 @@ Word value read from the absolute memory location.
NOTE: Do not inline this function as (*sys_rdX) is already inline!
****************************************************************************/
-u16 fetch_data_word_abs(
- uint segment,
- uint offset)
+u16
+fetch_data_word_abs(uint segment, uint offset)
{
#ifdef DEBUG
- if (CHECK_DATA_ACCESS())
- x86emu_check_data_access(segment, offset);
+ if (CHECK_DATA_ACCESS())
+ x86emu_check_data_access(segment, offset);
#endif
- return (*sys_rdw)(((u32)segment << 4) + offset);
+ return (*sys_rdw) (((u32) segment << 4) + offset);
}
/****************************************************************************
@@ -401,15 +405,14 @@ Long value read from the absolute memory location.
NOTE: Do not inline this function as (*sys_rdX) is already inline!
****************************************************************************/
-u32 fetch_data_long_abs(
- uint segment,
- uint offset)
+u32
+fetch_data_long_abs(uint segment, uint offset)
{
#ifdef DEBUG
- if (CHECK_DATA_ACCESS())
- x86emu_check_data_access(segment, offset);
+ if (CHECK_DATA_ACCESS())
+ x86emu_check_data_access(segment, offset);
#endif
- return (*sys_rdl)(((u32)segment << 4) + offset);
+ return (*sys_rdl) (((u32) segment << 4) + offset);
}
/****************************************************************************
@@ -423,15 +426,14 @@ the current 'default' segment, which may have been overridden.
NOTE: Do not inline this function as (*sys_wrX) is already inline!
****************************************************************************/
-void store_data_byte(
- uint offset,
- u8 val)
+void
+store_data_byte(uint offset, u8 val)
{
#ifdef DEBUG
- if (CHECK_DATA_ACCESS())
- x86emu_check_data_access((u16)get_data_segment(), offset);
+ if (CHECK_DATA_ACCESS())
+ x86emu_check_data_access((u16) get_data_segment(), offset);
#endif
- (*sys_wrb)((get_data_segment() << 4) + offset, val);
+ (*sys_wrb) ((get_data_segment() << 4) + offset, val);
}
/****************************************************************************
@@ -445,15 +447,14 @@ the current 'default' segment, which may have been overridden.
NOTE: Do not inline this function as (*sys_wrX) is already inline!
****************************************************************************/
-void store_data_word(
- uint offset,
- u16 val)
+void
+store_data_word(uint offset, u16 val)
{
#ifdef DEBUG
- if (CHECK_DATA_ACCESS())
- x86emu_check_data_access((u16)get_data_segment(), offset);
+ if (CHECK_DATA_ACCESS())
+ x86emu_check_data_access((u16) get_data_segment(), offset);
#endif
- (*sys_wrw)((get_data_segment() << 4) + offset, val);
+ (*sys_wrw) ((get_data_segment() << 4) + offset, val);
}
/****************************************************************************
@@ -467,15 +468,14 @@ the current 'default' segment, which may have been overridden.
NOTE: Do not inline this function as (*sys_wrX) is already inline!
****************************************************************************/
-void store_data_long(
- uint offset,
- u32 val)
+void
+store_data_long(uint offset, u32 val)
{
#ifdef DEBUG
- if (CHECK_DATA_ACCESS())
- x86emu_check_data_access((u16)get_data_segment(), offset);
+ if (CHECK_DATA_ACCESS())
+ x86emu_check_data_access((u16) get_data_segment(), offset);
#endif
- (*sys_wrl)((get_data_segment() << 4) + offset, val);
+ (*sys_wrl) ((get_data_segment() << 4) + offset, val);
}
/****************************************************************************
@@ -489,16 +489,14 @@ Writes a byte value to an absolute memory location.
NOTE: Do not inline this function as (*sys_wrX) is already inline!
****************************************************************************/
-void store_data_byte_abs(
- uint segment,
- uint offset,
- u8 val)
+void
+store_data_byte_abs(uint segment, uint offset, u8 val)
{
#ifdef DEBUG
- if (CHECK_DATA_ACCESS())
- x86emu_check_data_access(segment, offset);
+ if (CHECK_DATA_ACCESS())
+ x86emu_check_data_access(segment, offset);
#endif
- (*sys_wrb)(((u32)segment << 4) + offset, val);
+ (*sys_wrb) (((u32) segment << 4) + offset, val);
}
/****************************************************************************
@@ -512,16 +510,14 @@ Writes a word value to an absolute memory location.
NOTE: Do not inline this function as (*sys_wrX) is already inline!
****************************************************************************/
-void store_data_word_abs(
- uint segment,
- uint offset,
- u16 val)
+void
+store_data_word_abs(uint segment, uint offset, u16 val)
{
#ifdef DEBUG
- if (CHECK_DATA_ACCESS())
- x86emu_check_data_access(segment, offset);
+ if (CHECK_DATA_ACCESS())
+ x86emu_check_data_access(segment, offset);
#endif
- (*sys_wrw)(((u32)segment << 4) + offset, val);
+ (*sys_wrw) (((u32) segment << 4) + offset, val);
}
/****************************************************************************
@@ -535,16 +531,14 @@ Writes a long value to an absolute memory location.
NOTE: Do not inline this function as (*sys_wrX) is already inline!
****************************************************************************/
-void store_data_long_abs(
- uint segment,
- uint offset,
- u32 val)
+void
+store_data_long_abs(uint segment, uint offset, u32 val)
{
#ifdef DEBUG
- if (CHECK_DATA_ACCESS())
- x86emu_check_data_access(segment, offset);
+ if (CHECK_DATA_ACCESS())
+ x86emu_check_data_access(segment, offset);
#endif
- (*sys_wrl)(((u32)segment << 4) + offset, val);
+ (*sys_wrl) (((u32) segment << 4) + offset, val);
}
/****************************************************************************
@@ -558,37 +552,37 @@ REMARKS:
Return a pointer to the register given by the R/RM field of the
modrm byte, for byte operands. Also enables the decoding of instructions.
****************************************************************************/
-u8* decode_rm_byte_register(
- int reg)
+u8 *
+decode_rm_byte_register(int reg)
{
- switch (reg) {
- case 0:
- DECODE_PRINTF("AL");
- return &M.x86.R_AL;
- case 1:
- DECODE_PRINTF("CL");
- return &M.x86.R_CL;
- case 2:
- DECODE_PRINTF("DL");
- return &M.x86.R_DL;
- case 3:
- DECODE_PRINTF("BL");
- return &M.x86.R_BL;
- case 4:
- DECODE_PRINTF("AH");
- return &M.x86.R_AH;
- case 5:
- DECODE_PRINTF("CH");
- return &M.x86.R_CH;
- case 6:
- DECODE_PRINTF("DH");
- return &M.x86.R_DH;
- case 7:
- DECODE_PRINTF("BH");
- return &M.x86.R_BH;
- }
- HALT_SYS();
- return NULL; /* NOT REACHED OR REACHED ON ERROR */
+ switch (reg) {
+ case 0:
+ DECODE_PRINTF("AL");
+ return &M.x86.R_AL;
+ case 1:
+ DECODE_PRINTF("CL");
+ return &M.x86.R_CL;
+ case 2:
+ DECODE_PRINTF("DL");
+ return &M.x86.R_DL;
+ case 3:
+ DECODE_PRINTF("BL");
+ return &M.x86.R_BL;
+ case 4:
+ DECODE_PRINTF("AH");
+ return &M.x86.R_AH;
+ case 5:
+ DECODE_PRINTF("CH");
+ return &M.x86.R_CH;
+ case 6:
+ DECODE_PRINTF("DH");
+ return &M.x86.R_DH;
+ case 7:
+ DECODE_PRINTF("BH");
+ return &M.x86.R_BH;
+ }
+ HALT_SYS();
+ return NULL; /* NOT REACHED OR REACHED ON ERROR */
}
/****************************************************************************
@@ -602,36 +596,36 @@ REMARKS:
Return a pointer to the register given by the R/RM field of the
modrm byte, for word operands. Also enables the decoding of instructions.
****************************************************************************/
-u16* decode_rm_word_register(
- int reg)
+u16 *
+decode_rm_word_register(int reg)
{
- switch (reg) {
- case 0:
- DECODE_PRINTF("AX");
- return &M.x86.R_AX;
- case 1:
- DECODE_PRINTF("CX");
- return &M.x86.R_CX;
- case 2:
- DECODE_PRINTF("DX");
- return &M.x86.R_DX;
- case 3:
- DECODE_PRINTF("BX");
- return &M.x86.R_BX;
- case 4:
- DECODE_PRINTF("SP");
- return &M.x86.R_SP;
- case 5:
- DECODE_PRINTF("BP");
- return &M.x86.R_BP;
- case 6:
- DECODE_PRINTF("SI");
- return &M.x86.R_SI;
- case 7:
- DECODE_PRINTF("DI");
- return &M.x86.R_DI;
- }
- HALT_SYS();
+ switch (reg) {
+ case 0:
+ DECODE_PRINTF("AX");
+ return &M.x86.R_AX;
+ case 1:
+ DECODE_PRINTF("CX");
+ return &M.x86.R_CX;
+ case 2:
+ DECODE_PRINTF("DX");
+ return &M.x86.R_DX;
+ case 3:
+ DECODE_PRINTF("BX");
+ return &M.x86.R_BX;
+ case 4:
+ DECODE_PRINTF("SP");
+ return &M.x86.R_SP;
+ case 5:
+ DECODE_PRINTF("BP");
+ return &M.x86.R_BP;
+ case 6:
+ DECODE_PRINTF("SI");
+ return &M.x86.R_SI;
+ case 7:
+ DECODE_PRINTF("DI");
+ return &M.x86.R_DI;
+ }
+ HALT_SYS();
return NULL; /* NOTREACHED OR REACHED ON ERROR */
}
@@ -646,36 +640,36 @@ REMARKS:
Return a pointer to the register given by the R/RM field of the
modrm byte, for dword operands. Also enables the decoding of instructions.
****************************************************************************/
-u32* decode_rm_long_register(
- int reg)
+u32 *
+decode_rm_long_register(int reg)
{
switch (reg) {
- case 0:
- DECODE_PRINTF("EAX");
- return &M.x86.R_EAX;
- case 1:
- DECODE_PRINTF("ECX");
- return &M.x86.R_ECX;
- case 2:
- DECODE_PRINTF("EDX");
- return &M.x86.R_EDX;
- case 3:
- DECODE_PRINTF("EBX");
- return &M.x86.R_EBX;
- case 4:
- DECODE_PRINTF("ESP");
- return &M.x86.R_ESP;
- case 5:
- DECODE_PRINTF("EBP");
- return &M.x86.R_EBP;
- case 6:
- DECODE_PRINTF("ESI");
- return &M.x86.R_ESI;
- case 7:
- DECODE_PRINTF("EDI");
- return &M.x86.R_EDI;
- }
- HALT_SYS();
+ case 0:
+ DECODE_PRINTF("EAX");
+ return &M.x86.R_EAX;
+ case 1:
+ DECODE_PRINTF("ECX");
+ return &M.x86.R_ECX;
+ case 2:
+ DECODE_PRINTF("EDX");
+ return &M.x86.R_EDX;
+ case 3:
+ DECODE_PRINTF("EBX");
+ return &M.x86.R_EBX;
+ case 4:
+ DECODE_PRINTF("ESP");
+ return &M.x86.R_ESP;
+ case 5:
+ DECODE_PRINTF("EBP");
+ return &M.x86.R_EBP;
+ case 6:
+ DECODE_PRINTF("ESI");
+ return &M.x86.R_ESI;
+ case 7:
+ DECODE_PRINTF("EDI");
+ return &M.x86.R_EDI;
+ }
+ HALT_SYS();
return NULL; /* NOTREACHED OR REACHED ON ERROR */
}
@@ -691,126 +685,129 @@ Return a pointer to the register given by the R/RM field of the
modrm byte, for word operands, modified from above for the weirdo
special case of segreg operands. Also enables the decoding of instructions.
****************************************************************************/
-u16* decode_rm_seg_register(
- int reg)
+u16 *
+decode_rm_seg_register(int reg)
{
- switch (reg) {
- case 0:
- DECODE_PRINTF("ES");
- return &M.x86.R_ES;
- case 1:
- DECODE_PRINTF("CS");
- return &M.x86.R_CS;
- case 2:
- DECODE_PRINTF("SS");
- return &M.x86.R_SS;
- case 3:
- DECODE_PRINTF("DS");
- return &M.x86.R_DS;
- case 4:
- DECODE_PRINTF("FS");
- return &M.x86.R_FS;
- case 5:
- DECODE_PRINTF("GS");
- return &M.x86.R_GS;
- case 6:
- case 7:
- DECODE_PRINTF("ILLEGAL SEGREG");
- break;
- }
- HALT_SYS();
- return NULL; /* NOT REACHED OR REACHED ON ERROR */
+ switch (reg) {
+ case 0:
+ DECODE_PRINTF("ES");
+ return &M.x86.R_ES;
+ case 1:
+ DECODE_PRINTF("CS");
+ return &M.x86.R_CS;
+ case 2:
+ DECODE_PRINTF("SS");
+ return &M.x86.R_SS;
+ case 3:
+ DECODE_PRINTF("DS");
+ return &M.x86.R_DS;
+ case 4:
+ DECODE_PRINTF("FS");
+ return &M.x86.R_FS;
+ case 5:
+ DECODE_PRINTF("GS");
+ return &M.x86.R_GS;
+ case 6:
+ case 7:
+ DECODE_PRINTF("ILLEGAL SEGREG");
+ break;
+ }
+ HALT_SYS();
+ return NULL; /* NOT REACHED OR REACHED ON ERROR */
}
/*
*
* return offset from the SIB Byte
*/
-u32 decode_sib_address(int sib, int mod)
+u32
+decode_sib_address(int sib, int mod)
{
u32 base = 0, i = 0, scale = 1;
- switch(sib & 0x07) {
+ switch (sib & 0x07) {
case 0:
- DECODE_PRINTF("[EAX]");
- base = M.x86.R_EAX;
- break;
+ DECODE_PRINTF("[EAX]");
+ base = M.x86.R_EAX;
+ break;
case 1:
- DECODE_PRINTF("[ECX]");
- base = M.x86.R_ECX;
- break;
+ DECODE_PRINTF("[ECX]");
+ base = M.x86.R_ECX;
+ break;
case 2:
- DECODE_PRINTF("[EDX]");
- base = M.x86.R_EDX;
- break;
+ DECODE_PRINTF("[EDX]");
+ base = M.x86.R_EDX;
+ break;
case 3:
- DECODE_PRINTF("[EBX]");
- base = M.x86.R_EBX;
- break;
+ DECODE_PRINTF("[EBX]");
+ base = M.x86.R_EBX;
+ break;
case 4:
- DECODE_PRINTF("[ESP]");
- base = M.x86.R_ESP;
- M.x86.mode |= SYSMODE_SEG_DS_SS;
- break;
+ DECODE_PRINTF("[ESP]");
+ base = M.x86.R_ESP;
+ M.x86.mode |= SYSMODE_SEG_DS_SS;
+ break;
case 5:
- if (mod == 0) {
- base = fetch_long_imm();
- DECODE_PRINTF2("%08x", base);
- } else {
- DECODE_PRINTF("[EBP]");
- base = M.x86.R_ESP;
- M.x86.mode |= SYSMODE_SEG_DS_SS;
- }
- break;
+ if (mod == 0) {
+ base = fetch_long_imm();
+ DECODE_PRINTF2("%08x", base);
+ }
+ else {
+ DECODE_PRINTF("[EBP]");
+ base = M.x86.R_ESP;
+ M.x86.mode |= SYSMODE_SEG_DS_SS;
+ }
+ break;
case 6:
- DECODE_PRINTF("[ESI]");
- base = M.x86.R_ESI;
- break;
+ DECODE_PRINTF("[ESI]");
+ base = M.x86.R_ESI;
+ break;
case 7:
- DECODE_PRINTF("[EDI]");
- base = M.x86.R_EDI;
- break;
+ DECODE_PRINTF("[EDI]");
+ base = M.x86.R_EDI;
+ break;
}
switch ((sib >> 3) & 0x07) {
case 0:
- DECODE_PRINTF("[EAX");
- i = M.x86.R_EAX;
- break;
+ DECODE_PRINTF("[EAX");
+ i = M.x86.R_EAX;
+ break;
case 1:
- DECODE_PRINTF("[ECX");
- i = M.x86.R_ECX;
- break;
+ DECODE_PRINTF("[ECX");
+ i = M.x86.R_ECX;
+ break;
case 2:
- DECODE_PRINTF("[EDX");
- i = M.x86.R_EDX;
- break;
+ DECODE_PRINTF("[EDX");
+ i = M.x86.R_EDX;
+ break;
case 3:
- DECODE_PRINTF("[EBX");
- i = M.x86.R_EBX;
- break;
+ DECODE_PRINTF("[EBX");
+ i = M.x86.R_EBX;
+ break;
case 4:
- i = 0;
- break;
+ i = 0;
+ break;
case 5:
- DECODE_PRINTF("[EBP");
- i = M.x86.R_EBP;
- break;
+ DECODE_PRINTF("[EBP");
+ i = M.x86.R_EBP;
+ break;
case 6:
- DECODE_PRINTF("[ESI");
- i = M.x86.R_ESI;
- break;
+ DECODE_PRINTF("[ESI");
+ i = M.x86.R_ESI;
+ break;
case 7:
- DECODE_PRINTF("[EDI");
- i = M.x86.R_EDI;
- break;
+ DECODE_PRINTF("[EDI");
+ i = M.x86.R_EDI;
+ break;
}
scale = 1 << ((sib >> 6) & 0x03);
if (((sib >> 3) & 0x07) != 4) {
- if (scale == 1) {
- DECODE_PRINTF("]");
- } else {
- DECODE_PRINTF2("*%d]", scale);
- }
+ if (scale == 1) {
+ DECODE_PRINTF("]");
+ }
+ else {
+ DECODE_PRINTF2("*%d]", scale);
+ }
}
return base + (i * scale);
}
@@ -835,74 +832,75 @@ NOTE: The code which specifies the corresponding segment (ds vs ss)
if a SS access is needed, set this bit. Otherwise, DS access
occurs (unless any of the segment override bits are set).
****************************************************************************/
-u32 decode_rm00_address(
- int rm)
+u32
+decode_rm00_address(int rm)
{
u32 offset;
int sib;
if (M.x86.mode & SYSMODE_PREFIX_ADDR) {
/* 32-bit addressing */
- switch (rm) {
- case 0:
- DECODE_PRINTF("[EAX]");
- return M.x86.R_EAX;
- case 1:
- DECODE_PRINTF("[ECX]");
- return M.x86.R_ECX;
- case 2:
- DECODE_PRINTF("[EDX]");
- return M.x86.R_EDX;
- case 3:
- DECODE_PRINTF("[EBX]");
- return M.x86.R_EBX;
- case 4:
- sib = fetch_byte_imm();
- return decode_sib_address(sib, 0);
- case 5:
- offset = fetch_long_imm();
- DECODE_PRINTF2("[%08x]", offset);
- return offset;
- case 6:
- DECODE_PRINTF("[ESI]");
- return M.x86.R_ESI;
- case 7:
- DECODE_PRINTF("[EDI]");
- return M.x86.R_EDI;
- }
- HALT_SYS();
- } else {
+ switch (rm) {
+ case 0:
+ DECODE_PRINTF("[EAX]");
+ return M.x86.R_EAX;
+ case 1:
+ DECODE_PRINTF("[ECX]");
+ return M.x86.R_ECX;
+ case 2:
+ DECODE_PRINTF("[EDX]");
+ return M.x86.R_EDX;
+ case 3:
+ DECODE_PRINTF("[EBX]");
+ return M.x86.R_EBX;
+ case 4:
+ sib = fetch_byte_imm();
+ return decode_sib_address(sib, 0);
+ case 5:
+ offset = fetch_long_imm();
+ DECODE_PRINTF2("[%08x]", offset);
+ return offset;
+ case 6:
+ DECODE_PRINTF("[ESI]");
+ return M.x86.R_ESI;
+ case 7:
+ DECODE_PRINTF("[EDI]");
+ return M.x86.R_EDI;
+ }
+ HALT_SYS();
+ }
+ else {
/* 16-bit addressing */
- switch (rm) {
- case 0:
- DECODE_PRINTF("[BX+SI]");
+ switch (rm) {
+ case 0:
+ DECODE_PRINTF("[BX+SI]");
return (M.x86.R_BX + M.x86.R_SI) & 0xffff;
- case 1:
- DECODE_PRINTF("[BX+DI]");
+ case 1:
+ DECODE_PRINTF("[BX+DI]");
return (M.x86.R_BX + M.x86.R_DI) & 0xffff;
- case 2:
- DECODE_PRINTF("[BP+SI]");
- M.x86.mode |= SYSMODE_SEG_DS_SS;
+ case 2:
+ DECODE_PRINTF("[BP+SI]");
+ M.x86.mode |= SYSMODE_SEG_DS_SS;
return (M.x86.R_BP + M.x86.R_SI) & 0xffff;
- case 3:
- DECODE_PRINTF("[BP+DI]");
- M.x86.mode |= SYSMODE_SEG_DS_SS;
+ case 3:
+ DECODE_PRINTF("[BP+DI]");
+ M.x86.mode |= SYSMODE_SEG_DS_SS;
return (M.x86.R_BP + M.x86.R_DI) & 0xffff;
- case 4:
- DECODE_PRINTF("[SI]");
- return M.x86.R_SI;
- case 5:
- DECODE_PRINTF("[DI]");
- return M.x86.R_DI;
- case 6:
- offset = fetch_word_imm();
- DECODE_PRINTF2("[%04x]", offset);
- return offset;
- case 7:
- DECODE_PRINTF("[BX]");
- return M.x86.R_BX;
- }
- HALT_SYS();
+ case 4:
+ DECODE_PRINTF("[SI]");
+ return M.x86.R_SI;
+ case 5:
+ DECODE_PRINTF("[DI]");
+ return M.x86.R_DI;
+ case 6:
+ offset = fetch_word_imm();
+ DECODE_PRINTF2("[%04x]", offset);
+ return offset;
+ case 7:
+ DECODE_PRINTF("[BX]");
+ return M.x86.R_BX;
+ }
+ HALT_SYS();
}
return 0;
}
@@ -918,79 +916,80 @@ REMARKS:
Return the offset given by mod=01 addressing. Also enables the
decoding of instructions.
****************************************************************************/
-u32 decode_rm01_address(
- int rm)
+u32
+decode_rm01_address(int rm)
{
int displacement = 0;
int sib;
/* Fetch disp8 if no SIB byte */
if (!((M.x86.mode & SYSMODE_PREFIX_ADDR) && (rm == 4)))
- displacement = (s8)fetch_byte_imm();
+ displacement = (s8) fetch_byte_imm();
if (M.x86.mode & SYSMODE_PREFIX_ADDR) {
/* 32-bit addressing */
- switch (rm) {
- case 0:
- DECODE_PRINTF2("%d[EAX]", displacement);
- return M.x86.R_EAX + displacement;
- case 1:
- DECODE_PRINTF2("%d[ECX]", displacement);
- return M.x86.R_ECX + displacement;
- case 2:
- DECODE_PRINTF2("%d[EDX]", displacement);
- return M.x86.R_EDX + displacement;
- case 3:
- DECODE_PRINTF2("%d[EBX]", displacement);
- return M.x86.R_EBX + displacement;
- case 4:
- sib = fetch_byte_imm();
- displacement = (s8)fetch_byte_imm();
- DECODE_PRINTF2("%d", displacement);
- return decode_sib_address(sib, 1) + displacement;
- case 5:
- DECODE_PRINTF2("%d[EBP]", displacement);
- return M.x86.R_EBP + displacement;
- case 6:
- DECODE_PRINTF2("%d[ESI]", displacement);
- return M.x86.R_ESI + displacement;
- case 7:
- DECODE_PRINTF2("%d[EDI]", displacement);
- return M.x86.R_EDI + displacement;
- }
- HALT_SYS();
- } else {
+ switch (rm) {
+ case 0:
+ DECODE_PRINTF2("%d[EAX]", displacement);
+ return M.x86.R_EAX + displacement;
+ case 1:
+ DECODE_PRINTF2("%d[ECX]", displacement);
+ return M.x86.R_ECX + displacement;
+ case 2:
+ DECODE_PRINTF2("%d[EDX]", displacement);
+ return M.x86.R_EDX + displacement;
+ case 3:
+ DECODE_PRINTF2("%d[EBX]", displacement);
+ return M.x86.R_EBX + displacement;
+ case 4:
+ sib = fetch_byte_imm();
+ displacement = (s8) fetch_byte_imm();
+ DECODE_PRINTF2("%d", displacement);
+ return decode_sib_address(sib, 1) + displacement;
+ case 5:
+ DECODE_PRINTF2("%d[EBP]", displacement);
+ return M.x86.R_EBP + displacement;
+ case 6:
+ DECODE_PRINTF2("%d[ESI]", displacement);
+ return M.x86.R_ESI + displacement;
+ case 7:
+ DECODE_PRINTF2("%d[EDI]", displacement);
+ return M.x86.R_EDI + displacement;
+ }
+ HALT_SYS();
+ }
+ else {
/* 16-bit addressing */
- switch (rm) {
- case 0:
- DECODE_PRINTF2("%d[BX+SI]", displacement);
+ switch (rm) {
+ case 0:
+ DECODE_PRINTF2("%d[BX+SI]", displacement);
return (M.x86.R_BX + M.x86.R_SI + displacement) & 0xffff;
- case 1:
- DECODE_PRINTF2("%d[BX+DI]", displacement);
+ case 1:
+ DECODE_PRINTF2("%d[BX+DI]", displacement);
return (M.x86.R_BX + M.x86.R_DI + displacement) & 0xffff;
- case 2:
- DECODE_PRINTF2("%d[BP+SI]", displacement);
- M.x86.mode |= SYSMODE_SEG_DS_SS;
+ case 2:
+ DECODE_PRINTF2("%d[BP+SI]", displacement);
+ M.x86.mode |= SYSMODE_SEG_DS_SS;
return (M.x86.R_BP + M.x86.R_SI + displacement) & 0xffff;
- case 3:
- DECODE_PRINTF2("%d[BP+DI]", displacement);
- M.x86.mode |= SYSMODE_SEG_DS_SS;
+ case 3:
+ DECODE_PRINTF2("%d[BP+DI]", displacement);
+ M.x86.mode |= SYSMODE_SEG_DS_SS;
return (M.x86.R_BP + M.x86.R_DI + displacement) & 0xffff;
- case 4:
- DECODE_PRINTF2("%d[SI]", displacement);
+ case 4:
+ DECODE_PRINTF2("%d[SI]", displacement);
return (M.x86.R_SI + displacement) & 0xffff;
- case 5:
- DECODE_PRINTF2("%d[DI]", displacement);
+ case 5:
+ DECODE_PRINTF2("%d[DI]", displacement);
return (M.x86.R_DI + displacement) & 0xffff;
- case 6:
- DECODE_PRINTF2("%d[BP]", displacement);
- M.x86.mode |= SYSMODE_SEG_DS_SS;
+ case 6:
+ DECODE_PRINTF2("%d[BP]", displacement);
+ M.x86.mode |= SYSMODE_SEG_DS_SS;
return (M.x86.R_BP + displacement) & 0xffff;
- case 7:
- DECODE_PRINTF2("%d[BX]", displacement);
+ case 7:
+ DECODE_PRINTF2("%d[BX]", displacement);
return (M.x86.R_BX + displacement) & 0xffff;
- }
- HALT_SYS();
+ }
+ HALT_SYS();
}
return 0; /* SHOULD NOT HAPPEN */
}
@@ -1006,86 +1005,87 @@ REMARKS:
Return the offset given by mod=10 addressing. Also enables the
decoding of instructions.
****************************************************************************/
-u32 decode_rm10_address(
- int rm)
+u32
+decode_rm10_address(int rm)
{
u32 displacement = 0;
int sib;
/* Fetch disp16 if 16-bit addr mode */
if (!(M.x86.mode & SYSMODE_PREFIX_ADDR))
- displacement = (u16)fetch_word_imm();
+ displacement = (u16) fetch_word_imm();
else {
- /* Fetch disp32 if no SIB byte */
- if (rm != 4)
- displacement = (u32)fetch_long_imm();
+ /* Fetch disp32 if no SIB byte */
+ if (rm != 4)
+ displacement = (u32) fetch_long_imm();
}
if (M.x86.mode & SYSMODE_PREFIX_ADDR) {
/* 32-bit addressing */
- switch (rm) {
- case 0:
- DECODE_PRINTF2("%08x[EAX]", displacement);
- return M.x86.R_EAX + displacement;
- case 1:
- DECODE_PRINTF2("%08x[ECX]", displacement);
- return M.x86.R_ECX + displacement;
- case 2:
- DECODE_PRINTF2("%08x[EDX]", displacement);
- M.x86.mode |= SYSMODE_SEG_DS_SS;
- return M.x86.R_EDX + displacement;
- case 3:
- DECODE_PRINTF2("%08x[EBX]", displacement);
- return M.x86.R_EBX + displacement;
- case 4:
- sib = fetch_byte_imm();
- displacement = (u32)fetch_long_imm();
- DECODE_PRINTF2("%08x", displacement);
- return decode_sib_address(sib, 2) + displacement;
- break;
- case 5:
- DECODE_PRINTF2("%08x[EBP]", displacement);
- return M.x86.R_EBP + displacement;
- case 6:
- DECODE_PRINTF2("%08x[ESI]", displacement);
- return M.x86.R_ESI + displacement;
- case 7:
- DECODE_PRINTF2("%08x[EDI]", displacement);
- return M.x86.R_EDI + displacement;
- }
- HALT_SYS();
- } else {
+ switch (rm) {
+ case 0:
+ DECODE_PRINTF2("%08x[EAX]", displacement);
+ return M.x86.R_EAX + displacement;
+ case 1:
+ DECODE_PRINTF2("%08x[ECX]", displacement);
+ return M.x86.R_ECX + displacement;
+ case 2:
+ DECODE_PRINTF2("%08x[EDX]", displacement);
+ M.x86.mode |= SYSMODE_SEG_DS_SS;
+ return M.x86.R_EDX + displacement;
+ case 3:
+ DECODE_PRINTF2("%08x[EBX]", displacement);
+ return M.x86.R_EBX + displacement;
+ case 4:
+ sib = fetch_byte_imm();
+ displacement = (u32) fetch_long_imm();
+ DECODE_PRINTF2("%08x", displacement);
+ return decode_sib_address(sib, 2) + displacement;
+ break;
+ case 5:
+ DECODE_PRINTF2("%08x[EBP]", displacement);
+ return M.x86.R_EBP + displacement;
+ case 6:
+ DECODE_PRINTF2("%08x[ESI]", displacement);
+ return M.x86.R_ESI + displacement;
+ case 7:
+ DECODE_PRINTF2("%08x[EDI]", displacement);
+ return M.x86.R_EDI + displacement;
+ }
+ HALT_SYS();
+ }
+ else {
/* 16-bit addressing */
- switch (rm) {
- case 0:
+ switch (rm) {
+ case 0:
DECODE_PRINTF2("%04x[BX+SI]", displacement);
return (M.x86.R_BX + M.x86.R_SI + displacement) & 0xffff;
- case 1:
+ case 1:
DECODE_PRINTF2("%04x[BX+DI]", displacement);
return (M.x86.R_BX + M.x86.R_DI + displacement) & 0xffff;
- case 2:
- DECODE_PRINTF2("%04x[BP+SI]", displacement);
- M.x86.mode |= SYSMODE_SEG_DS_SS;
+ case 2:
+ DECODE_PRINTF2("%04x[BP+SI]", displacement);
+ M.x86.mode |= SYSMODE_SEG_DS_SS;
return (M.x86.R_BP + M.x86.R_SI + displacement) & 0xffff;
- case 3:
- DECODE_PRINTF2("%04x[BP+DI]", displacement);
- M.x86.mode |= SYSMODE_SEG_DS_SS;
+ case 3:
+ DECODE_PRINTF2("%04x[BP+DI]", displacement);
+ M.x86.mode |= SYSMODE_SEG_DS_SS;
return (M.x86.R_BP + M.x86.R_DI + displacement) & 0xffff;
- case 4:
+ case 4:
DECODE_PRINTF2("%04x[SI]", displacement);
return (M.x86.R_SI + displacement) & 0xffff;
- case 5:
+ case 5:
DECODE_PRINTF2("%04x[DI]", displacement);
return (M.x86.R_DI + displacement) & 0xffff;
- case 6:
- DECODE_PRINTF2("%04x[BP]", displacement);
- M.x86.mode |= SYSMODE_SEG_DS_SS;
+ case 6:
+ DECODE_PRINTF2("%04x[BP]", displacement);
+ M.x86.mode |= SYSMODE_SEG_DS_SS;
return (M.x86.R_BP + displacement) & 0xffff;
- case 7:
+ case 7:
DECODE_PRINTF2("%04x[BX]", displacement);
return (M.x86.R_BX + displacement) & 0xffff;
- }
- HALT_SYS();
+ }
+ HALT_SYS();
}
return 0;
/*NOTREACHED */
diff --git a/xorg-server/hw/xfree86/x86emu/fpu.c b/xorg-server/hw/xfree86/x86emu/fpu.c
index fbc602da5..0dab05ce3 100644
--- a/xorg-server/hw/xfree86/x86emu/fpu.c
+++ b/xorg-server/hw/xfree86/x86emu/fpu.c
@@ -42,7 +42,8 @@
/*----------------------------- Implementation ----------------------------*/
/* opcode=0xd8 */
-void x86emuOp_esc_coprocess_d8(u8 X86EMU_UNUSED(op1))
+void
+x86emuOp_esc_coprocess_d8(u8 X86EMU_UNUSED(op1))
{
START_OF_INSTR();
DECODE_PRINTF("ESC D8\n");
@@ -89,10 +90,11 @@ static const char *x86emu_fpu_op_d9_tab1[] = {
"FRNDINT", "FSCALE", "ESC_D9", "ESC_D9",
};
-#endif /* DEBUG */
+#endif /* DEBUG */
/* opcode=0xd9 */
-void x86emuOp_esc_coprocess_d9(u8 X86EMU_UNUSED(op1))
+void
+x86emuOp_esc_coprocess_d9(u8 X86EMU_UNUSED(op1))
{
int mod, rl, rh;
uint destoffset = 0;
@@ -103,56 +105,58 @@ void x86emuOp_esc_coprocess_d9(u8 X86EMU_UNUSED(op1))
#ifdef DEBUG
if (mod != 3) {
DECODE_PRINTINSTR32(x86emu_fpu_op_d9_tab, mod, rh, rl);
- } else {
+ }
+ else {
DECODE_PRINTF(x86emu_fpu_op_d9_tab1[(rh << 3) + rl]);
}
#endif
switch (mod) {
- case 0:
+ case 0:
destoffset = decode_rm00_address(rl);
DECODE_PRINTF("\n");
break;
- case 1:
+ case 1:
destoffset = decode_rm01_address(rl);
DECODE_PRINTF("\n");
break;
- case 2:
+ case 2:
destoffset = decode_rm10_address(rl);
DECODE_PRINTF("\n");
break;
- case 3: /* register to register */
- stkelem = (u8)rl;
- if (rh < 4) {
- DECODE_PRINTF2("ST(%d)\n", stkelem);
- } else {
- DECODE_PRINTF("\n");
- }
+ case 3: /* register to register */
+ stkelem = (u8) rl;
+ if (rh < 4) {
+ DECODE_PRINTF2("ST(%d)\n", stkelem);
+ }
+ else {
+ DECODE_PRINTF("\n");
+ }
break;
}
#ifdef X86EMU_FPU_PRESENT
/* execute */
switch (mod) {
- case 3:
+ case 3:
switch (rh) {
- case 0:
+ case 0:
x86emu_fpu_R_fld(X86EMU_FPU_STKTOP, stkelem);
break;
- case 1:
+ case 1:
x86emu_fpu_R_fxch(X86EMU_FPU_STKTOP, stkelem);
break;
- case 2:
+ case 2:
switch (rl) {
- case 0:
+ case 0:
x86emu_fpu_R_nop();
break;
- default:
+ default:
x86emu_fpu_illegal();
break;
}
- case 3:
+ case 3:
x86emu_fpu_R_fstp(X86EMU_FPU_STKTOP, stkelem);
break;
- case 4:
+ case 4:
switch (rl) {
case 0:
x86emu_fpu_R_fchs(X86EMU_FPU_STKTOP);
@@ -173,126 +177,126 @@ void x86emuOp_esc_coprocess_d9(u8 X86EMU_UNUSED(op1))
}
break;
- case 5:
+ case 5:
switch (rl) {
- case 0:
+ case 0:
x86emu_fpu_R_fld1(X86EMU_FPU_STKTOP);
break;
- case 1:
+ case 1:
x86emu_fpu_R_fldl2t(X86EMU_FPU_STKTOP);
break;
- case 2:
+ case 2:
x86emu_fpu_R_fldl2e(X86EMU_FPU_STKTOP);
break;
- case 3:
+ case 3:
x86emu_fpu_R_fldpi(X86EMU_FPU_STKTOP);
break;
- case 4:
+ case 4:
x86emu_fpu_R_fldlg2(X86EMU_FPU_STKTOP);
break;
- case 5:
+ case 5:
x86emu_fpu_R_fldln2(X86EMU_FPU_STKTOP);
break;
- case 6:
+ case 6:
x86emu_fpu_R_fldz(X86EMU_FPU_STKTOP);
break;
- default:
+ default:
/* 7 */
x86emu_fpu_illegal();
break;
}
break;
- case 6:
+ case 6:
switch (rl) {
- case 0:
+ case 0:
x86emu_fpu_R_f2xm1(X86EMU_FPU_STKTOP);
break;
- case 1:
+ case 1:
x86emu_fpu_R_fyl2x(X86EMU_FPU_STKTOP);
break;
- case 2:
+ case 2:
x86emu_fpu_R_fptan(X86EMU_FPU_STKTOP);
break;
- case 3:
+ case 3:
x86emu_fpu_R_fpatan(X86EMU_FPU_STKTOP);
break;
- case 4:
+ case 4:
x86emu_fpu_R_fxtract(X86EMU_FPU_STKTOP);
break;
- case 5:
+ case 5:
x86emu_fpu_illegal();
break;
- case 6:
+ case 6:
x86emu_fpu_R_decstp();
break;
- case 7:
+ case 7:
x86emu_fpu_R_incstp();
break;
}
break;
- case 7:
+ case 7:
switch (rl) {
- case 0:
+ case 0:
x86emu_fpu_R_fprem(X86EMU_FPU_STKTOP);
break;
- case 1:
+ case 1:
x86emu_fpu_R_fyl2xp1(X86EMU_FPU_STKTOP);
break;
- case 2:
+ case 2:
x86emu_fpu_R_fsqrt(X86EMU_FPU_STKTOP);
break;
- case 3:
+ case 3:
x86emu_fpu_illegal();
break;
- case 4:
+ case 4:
x86emu_fpu_R_frndint(X86EMU_FPU_STKTOP);
break;
- case 5:
+ case 5:
x86emu_fpu_R_fscale(X86EMU_FPU_STKTOP);
break;
- case 6:
- case 7:
- default:
+ case 6:
+ case 7:
+ default:
x86emu_fpu_illegal();
break;
}
break;
- default:
+ default:
switch (rh) {
- case 0:
+ case 0:
x86emu_fpu_M_fld(X86EMU_FPU_FLOAT, destoffset);
break;
- case 1:
+ case 1:
x86emu_fpu_illegal();
break;
- case 2:
+ case 2:
x86emu_fpu_M_fst(X86EMU_FPU_FLOAT, destoffset);
break;
- case 3:
+ case 3:
x86emu_fpu_M_fstp(X86EMU_FPU_FLOAT, destoffset);
break;
- case 4:
+ case 4:
x86emu_fpu_M_fldenv(X86EMU_FPU_WORD, destoffset);
break;
- case 5:
+ case 5:
x86emu_fpu_M_fldcw(X86EMU_FPU_WORD, destoffset);
break;
- case 6:
+ case 6:
x86emu_fpu_M_fstenv(X86EMU_FPU_WORD, destoffset);
break;
- case 7:
+ case 7:
x86emu_fpu_M_fstcw(X86EMU_FPU_WORD, destoffset);
break;
}
}
}
#else
- (void)destoffset;
- (void)stkelem;
-#endif /* X86EMU_FPU_PRESENT */
+ (void) destoffset;
+ (void) stkelem;
+#endif /* X86EMU_FPU_PRESENT */
DECODE_CLEAR_SEGOVR();
END_OF_INSTR_NO_TRACE();
}
@@ -309,7 +313,7 @@ static const char *x86emu_fpu_op_da_tab[] = {
"FICOMP\tDWORD PTR ",
"FISUB\tDWORD PTR ", "FISUBR\tDWORD PTR ", "FIDIV\tDWORD PTR ",
"FIDIVR\tDWORD PTR ",
-
+
"FIADD\tDWORD PTR ", "FIMUL\tDWORD PTR ", "FICOM\tDWORD PTR ",
"FICOMP\tDWORD PTR ",
"FISUB\tDWORD PTR ", "FISUBR\tDWORD PTR ", "FIDIV\tDWORD PTR ",
@@ -319,10 +323,11 @@ static const char *x86emu_fpu_op_da_tab[] = {
"ESC_DA ", "ESC_DA ", "ESC_DA ", "ESC_DA ",
};
-#endif /* DEBUG */
+#endif /* DEBUG */
/* opcode=0xda */
-void x86emuOp_esc_coprocess_da(u8 X86EMU_UNUSED(op1))
+void
+x86emuOp_esc_coprocess_da(u8 X86EMU_UNUSED(op1))
{
int mod, rl, rh;
uint destoffset = 0;
@@ -332,59 +337,59 @@ void x86emuOp_esc_coprocess_da(u8 X86EMU_UNUSED(op1))
FETCH_DECODE_MODRM(mod, rh, rl);
DECODE_PRINTINSTR32(x86emu_fpu_op_da_tab, mod, rh, rl);
switch (mod) {
- case 0:
+ case 0:
destoffset = decode_rm00_address(rl);
DECODE_PRINTF("\n");
break;
- case 1:
+ case 1:
destoffset = decode_rm01_address(rl);
DECODE_PRINTF("\n");
break;
- case 2:
+ case 2:
destoffset = decode_rm10_address(rl);
DECODE_PRINTF("\n");
break;
- case 3: /* register to register */
- stkelem = (u8)rl;
+ case 3: /* register to register */
+ stkelem = (u8) rl;
DECODE_PRINTF2("\tST(%d),ST\n", stkelem);
break;
}
#ifdef X86EMU_FPU_PRESENT
switch (mod) {
- case 3:
+ case 3:
x86emu_fpu_illegal();
break;
- default:
+ default:
switch (rh) {
- case 0:
+ case 0:
x86emu_fpu_M_iadd(X86EMU_FPU_SHORT, destoffset);
break;
- case 1:
+ case 1:
x86emu_fpu_M_imul(X86EMU_FPU_SHORT, destoffset);
break;
- case 2:
+ case 2:
x86emu_fpu_M_icom(X86EMU_FPU_SHORT, destoffset);
break;
- case 3:
+ case 3:
x86emu_fpu_M_icomp(X86EMU_FPU_SHORT, destoffset);
break;
- case 4:
+ case 4:
x86emu_fpu_M_isub(X86EMU_FPU_SHORT, destoffset);
break;
- case 5:
+ case 5:
x86emu_fpu_M_isubr(X86EMU_FPU_SHORT, destoffset);
break;
- case 6:
+ case 6:
x86emu_fpu_M_idiv(X86EMU_FPU_SHORT, destoffset);
break;
- case 7:
+ case 7:
x86emu_fpu_M_idivr(X86EMU_FPU_SHORT, destoffset);
break;
}
}
#else
- (void)destoffset;
- (void)stkelem;
+ (void) destoffset;
+ (void) stkelem;
#endif
DECODE_CLEAR_SEGOVR();
END_OF_INSTR_NO_TRACE();
@@ -403,10 +408,11 @@ static const char *x86emu_fpu_op_db_tab[] = {
"ESC_DB\t1C", "FLD\tTBYTE PTR ", "ESC_DB\t1E", "FSTP\tTBYTE PTR ",
};
-#endif /* DEBUG */
+#endif /* DEBUG */
/* opcode=0xdb */
-void x86emuOp_esc_coprocess_db(u8 X86EMU_UNUSED(op1))
+void
+x86emuOp_esc_coprocess_db(u8 X86EMU_UNUSED(op1))
{
int mod, rl, rh;
uint destoffset = 0;
@@ -416,97 +422,99 @@ void x86emuOp_esc_coprocess_db(u8 X86EMU_UNUSED(op1))
#ifdef DEBUG
if (mod != 3) {
DECODE_PRINTINSTR32(x86emu_fpu_op_db_tab, mod, rh, rl);
- } else if (rh == 4) { /* === 11 10 0 nnn */
+ }
+ else if (rh == 4) { /* === 11 10 0 nnn */
switch (rl) {
- case 0:
+ case 0:
DECODE_PRINTF("FENI\n");
break;
- case 1:
+ case 1:
DECODE_PRINTF("FDISI\n");
break;
- case 2:
+ case 2:
DECODE_PRINTF("FCLEX\n");
break;
- case 3:
+ case 3:
DECODE_PRINTF("FINIT\n");
break;
}
- } else {
+ }
+ else {
DECODE_PRINTF2("ESC_DB %0x\n", (mod << 6) + (rh << 3) + (rl));
}
-#endif /* DEBUG */
+#endif /* DEBUG */
switch (mod) {
- case 0:
+ case 0:
destoffset = decode_rm00_address(rl);
break;
- case 1:
+ case 1:
destoffset = decode_rm01_address(rl);
break;
- case 2:
+ case 2:
destoffset = decode_rm10_address(rl);
break;
- case 3: /* register to register */
+ case 3: /* register to register */
break;
}
#ifdef X86EMU_FPU_PRESENT
/* execute */
switch (mod) {
- case 3:
+ case 3:
switch (rh) {
- case 4:
+ case 4:
switch (rl) {
- case 0:
+ case 0:
x86emu_fpu_R_feni();
break;
- case 1:
+ case 1:
x86emu_fpu_R_fdisi();
break;
- case 2:
+ case 2:
x86emu_fpu_R_fclex();
break;
- case 3:
+ case 3:
x86emu_fpu_R_finit();
break;
- default:
+ default:
x86emu_fpu_illegal();
break;
}
break;
- default:
+ default:
x86emu_fpu_illegal();
break;
}
break;
- default:
+ default:
switch (rh) {
- case 0:
+ case 0:
x86emu_fpu_M_fild(X86EMU_FPU_SHORT, destoffset);
break;
- case 1:
+ case 1:
x86emu_fpu_illegal();
break;
- case 2:
+ case 2:
x86emu_fpu_M_fist(X86EMU_FPU_SHORT, destoffset);
break;
- case 3:
+ case 3:
x86emu_fpu_M_fistp(X86EMU_FPU_SHORT, destoffset);
break;
- case 4:
+ case 4:
x86emu_fpu_illegal();
break;
- case 5:
+ case 5:
x86emu_fpu_M_fld(X86EMU_FPU_LDBL, destoffset);
break;
- case 6:
+ case 6:
x86emu_fpu_illegal();
break;
- case 7:
+ case 7:
x86emu_fpu_M_fstp(X86EMU_FPU_LDBL, destoffset);
break;
}
}
#else
- (void)destoffset;
+ (void) destoffset;
#endif
DECODE_CLEAR_SEGOVR();
END_OF_INSTR_NO_TRACE();
@@ -532,10 +540,11 @@ static const char *x86emu_fpu_op_dc_tab[] = {
"FADD\t", "FMUL\t", "FCOM\t", "FCOMP\t",
"FSUBR\t", "FSUB\t", "FDIVR\t", "FDIV\t",
};
-#endif /* DEBUG */
+#endif /* DEBUG */
/* opcode=0xdc */
-void x86emuOp_esc_coprocess_dc(u8 X86EMU_UNUSED(op1))
+void
+x86emuOp_esc_coprocess_dc(u8 X86EMU_UNUSED(op1))
{
int mod, rl, rh;
uint destoffset = 0;
@@ -545,85 +554,85 @@ void x86emuOp_esc_coprocess_dc(u8 X86EMU_UNUSED(op1))
FETCH_DECODE_MODRM(mod, rh, rl);
DECODE_PRINTINSTR32(x86emu_fpu_op_dc_tab, mod, rh, rl);
switch (mod) {
- case 0:
+ case 0:
destoffset = decode_rm00_address(rl);
DECODE_PRINTF("\n");
break;
- case 1:
+ case 1:
destoffset = decode_rm01_address(rl);
DECODE_PRINTF("\n");
break;
- case 2:
+ case 2:
destoffset = decode_rm10_address(rl);
DECODE_PRINTF("\n");
break;
- case 3: /* register to register */
- stkelem = (u8)rl;
+ case 3: /* register to register */
+ stkelem = (u8) rl;
DECODE_PRINTF2("\tST(%d),ST\n", stkelem);
break;
}
#ifdef X86EMU_FPU_PRESENT
/* execute */
switch (mod) {
- case 3:
+ case 3:
switch (rh) {
- case 0:
+ case 0:
x86emu_fpu_R_fadd(stkelem, X86EMU_FPU_STKTOP);
break;
- case 1:
+ case 1:
x86emu_fpu_R_fmul(stkelem, X86EMU_FPU_STKTOP);
break;
- case 2:
+ case 2:
x86emu_fpu_R_fcom(stkelem, X86EMU_FPU_STKTOP);
break;
- case 3:
+ case 3:
x86emu_fpu_R_fcomp(stkelem, X86EMU_FPU_STKTOP);
break;
- case 4:
+ case 4:
x86emu_fpu_R_fsubr(stkelem, X86EMU_FPU_STKTOP);
break;
- case 5:
+ case 5:
x86emu_fpu_R_fsub(stkelem, X86EMU_FPU_STKTOP);
break;
- case 6:
+ case 6:
x86emu_fpu_R_fdivr(stkelem, X86EMU_FPU_STKTOP);
break;
- case 7:
+ case 7:
x86emu_fpu_R_fdiv(stkelem, X86EMU_FPU_STKTOP);
break;
}
break;
- default:
+ default:
switch (rh) {
- case 0:
+ case 0:
x86emu_fpu_M_fadd(X86EMU_FPU_DOUBLE, destoffset);
break;
- case 1:
+ case 1:
x86emu_fpu_M_fmul(X86EMU_FPU_DOUBLE, destoffset);
break;
- case 2:
+ case 2:
x86emu_fpu_M_fcom(X86EMU_FPU_DOUBLE, destoffset);
break;
- case 3:
+ case 3:
x86emu_fpu_M_fcomp(X86EMU_FPU_DOUBLE, destoffset);
break;
- case 4:
+ case 4:
x86emu_fpu_M_fsub(X86EMU_FPU_DOUBLE, destoffset);
break;
- case 5:
+ case 5:
x86emu_fpu_M_fsubr(X86EMU_FPU_DOUBLE, destoffset);
break;
- case 6:
+ case 6:
x86emu_fpu_M_fdiv(X86EMU_FPU_DOUBLE, destoffset);
break;
- case 7:
+ case 7:
x86emu_fpu_M_fdivr(X86EMU_FPU_DOUBLE, destoffset);
break;
}
}
#else
- (void)destoffset;
- (void)stkelem;
+ (void) destoffset;
+ (void) stkelem;
#endif
DECODE_CLEAR_SEGOVR();
END_OF_INSTR_NO_TRACE();
@@ -645,10 +654,11 @@ static const char *x86emu_fpu_op_dd_tab[] = {
"ESC_DD\t2C,", "ESC_DD\t2D,", "ESC_DD\t2E,", "ESC_DD\t2F,",
};
-#endif /* DEBUG */
+#endif /* DEBUG */
/* opcode=0xdd */
-void x86emuOp_esc_coprocess_dd(u8 X86EMU_UNUSED(op1))
+void
+x86emuOp_esc_coprocess_dd(u8 X86EMU_UNUSED(op1))
{
int mod, rl, rh;
uint destoffset = 0;
@@ -658,75 +668,75 @@ void x86emuOp_esc_coprocess_dd(u8 X86EMU_UNUSED(op1))
FETCH_DECODE_MODRM(mod, rh, rl);
DECODE_PRINTINSTR32(x86emu_fpu_op_dd_tab, mod, rh, rl);
switch (mod) {
- case 0:
+ case 0:
destoffset = decode_rm00_address(rl);
DECODE_PRINTF("\n");
break;
- case 1:
+ case 1:
destoffset = decode_rm01_address(rl);
DECODE_PRINTF("\n");
break;
- case 2:
+ case 2:
destoffset = decode_rm10_address(rl);
DECODE_PRINTF("\n");
break;
- case 3: /* register to register */
- stkelem = (u8)rl;
+ case 3: /* register to register */
+ stkelem = (u8) rl;
DECODE_PRINTF2("\tST(%d),ST\n", stkelem);
break;
}
#ifdef X86EMU_FPU_PRESENT
switch (mod) {
- case 3:
+ case 3:
switch (rh) {
- case 0:
+ case 0:
x86emu_fpu_R_ffree(stkelem);
break;
- case 1:
+ case 1:
x86emu_fpu_R_fxch(stkelem);
break;
- case 2:
+ case 2:
x86emu_fpu_R_fst(stkelem); /* register version */
break;
- case 3:
+ case 3:
x86emu_fpu_R_fstp(stkelem); /* register version */
break;
- default:
+ default:
x86emu_fpu_illegal();
break;
}
break;
- default:
+ default:
switch (rh) {
- case 0:
+ case 0:
x86emu_fpu_M_fld(X86EMU_FPU_DOUBLE, destoffset);
break;
- case 1:
+ case 1:
x86emu_fpu_illegal();
break;
- case 2:
+ case 2:
x86emu_fpu_M_fst(X86EMU_FPU_DOUBLE, destoffset);
break;
- case 3:
+ case 3:
x86emu_fpu_M_fstp(X86EMU_FPU_DOUBLE, destoffset);
break;
- case 4:
+ case 4:
x86emu_fpu_M_frstor(X86EMU_FPU_WORD, destoffset);
break;
- case 5:
+ case 5:
x86emu_fpu_illegal();
break;
- case 6:
+ case 6:
x86emu_fpu_M_fsave(X86EMU_FPU_WORD, destoffset);
break;
- case 7:
+ case 7:
x86emu_fpu_M_fstsw(X86EMU_FPU_WORD, destoffset);
break;
}
}
#else
- (void)destoffset;
- (void)stkelem;
+ (void) destoffset;
+ (void) stkelem;
#endif
DECODE_CLEAR_SEGOVR();
END_OF_INSTR_NO_TRACE();
@@ -734,8 +744,7 @@ void x86emuOp_esc_coprocess_dd(u8 X86EMU_UNUSED(op1))
#ifdef DEBUG
-static const char *x86emu_fpu_op_de_tab[] =
-{
+static const char *x86emu_fpu_op_de_tab[] = {
"FIADD\tWORD PTR ", "FIMUL\tWORD PTR ", "FICOM\tWORD PTR ",
"FICOMP\tWORD PTR ",
"FISUB\tWORD PTR ", "FISUBR\tWORD PTR ", "FIDIV\tWORD PTR ",
@@ -755,10 +764,11 @@ static const char *x86emu_fpu_op_de_tab[] =
"FSUBRP\t", "FSUBP\t", "FDIVRP\t", "FDIVP\t",
};
-#endif /* DEBUG */
+#endif /* DEBUG */
/* opcode=0xde */
-void x86emuOp_esc_coprocess_de(u8 X86EMU_UNUSED(op1))
+void
+x86emuOp_esc_coprocess_de(u8 X86EMU_UNUSED(op1))
{
int mod, rl, rh;
uint destoffset = 0;
@@ -768,87 +778,87 @@ void x86emuOp_esc_coprocess_de(u8 X86EMU_UNUSED(op1))
FETCH_DECODE_MODRM(mod, rh, rl);
DECODE_PRINTINSTR32(x86emu_fpu_op_de_tab, mod, rh, rl);
switch (mod) {
- case 0:
+ case 0:
destoffset = decode_rm00_address(rl);
DECODE_PRINTF("\n");
break;
- case 1:
+ case 1:
destoffset = decode_rm01_address(rl);
DECODE_PRINTF("\n");
break;
- case 2:
+ case 2:
destoffset = decode_rm10_address(rl);
DECODE_PRINTF("\n");
break;
- case 3: /* register to register */
- stkelem = (u8)rl;
+ case 3: /* register to register */
+ stkelem = (u8) rl;
DECODE_PRINTF2("\tST(%d),ST\n", stkelem);
break;
}
#ifdef X86EMU_FPU_PRESENT
switch (mod) {
- case 3:
+ case 3:
switch (rh) {
- case 0:
+ case 0:
x86emu_fpu_R_faddp(stkelem, X86EMU_FPU_STKTOP);
break;
- case 1:
+ case 1:
x86emu_fpu_R_fmulp(stkelem, X86EMU_FPU_STKTOP);
break;
- case 2:
+ case 2:
x86emu_fpu_R_fcomp(stkelem, X86EMU_FPU_STKTOP);
break;
- case 3:
+ case 3:
if (stkelem == 1)
- x86emu_fpu_R_fcompp(stkelem, X86EMU_FPU_STKTOP);
+ x86emu_fpu_R_fcompp(stkelem, X86EMU_FPU_STKTOP);
else
- x86emu_fpu_illegal();
+ x86emu_fpu_illegal();
break;
- case 4:
+ case 4:
x86emu_fpu_R_fsubrp(stkelem, X86EMU_FPU_STKTOP);
break;
- case 5:
+ case 5:
x86emu_fpu_R_fsubp(stkelem, X86EMU_FPU_STKTOP);
break;
- case 6:
+ case 6:
x86emu_fpu_R_fdivrp(stkelem, X86EMU_FPU_STKTOP);
break;
- case 7:
+ case 7:
x86emu_fpu_R_fdivp(stkelem, X86EMU_FPU_STKTOP);
break;
}
break;
- default:
+ default:
switch (rh) {
- case 0:
+ case 0:
x86emu_fpu_M_fiadd(X86EMU_FPU_WORD, destoffset);
break;
- case 1:
+ case 1:
x86emu_fpu_M_fimul(X86EMU_FPU_WORD, destoffset);
break;
- case 2:
+ case 2:
x86emu_fpu_M_ficom(X86EMU_FPU_WORD, destoffset);
break;
- case 3:
+ case 3:
x86emu_fpu_M_ficomp(X86EMU_FPU_WORD, destoffset);
break;
- case 4:
+ case 4:
x86emu_fpu_M_fisub(X86EMU_FPU_WORD, destoffset);
break;
- case 5:
+ case 5:
x86emu_fpu_M_fisubr(X86EMU_FPU_WORD, destoffset);
break;
- case 6:
+ case 6:
x86emu_fpu_M_fidiv(X86EMU_FPU_WORD, destoffset);
break;
- case 7:
+ case 7:
x86emu_fpu_M_fidivr(X86EMU_FPU_WORD, destoffset);
break;
}
}
#else
- (void)destoffset;
- (void)stkelem;
+ (void) destoffset;
+ (void) stkelem;
#endif
DECODE_CLEAR_SEGOVR();
END_OF_INSTR_NO_TRACE();
@@ -877,10 +887,11 @@ static const char *x86emu_fpu_op_df_tab[] = {
"ESC_DF\t3C,", "ESC_DF\t3D,", "ESC_DF\t3E,", "ESC_DF\t3F,"
};
-#endif /* DEBUG */
+#endif /* DEBUG */
/* opcode=0xdf */
-void x86emuOp_esc_coprocess_df(u8 X86EMU_UNUSED(op1))
+void
+x86emuOp_esc_coprocess_df(u8 X86EMU_UNUSED(op1))
{
int mod, rl, rh;
uint destoffset = 0;
@@ -890,75 +901,75 @@ void x86emuOp_esc_coprocess_df(u8 X86EMU_UNUSED(op1))
FETCH_DECODE_MODRM(mod, rh, rl);
DECODE_PRINTINSTR32(x86emu_fpu_op_df_tab, mod, rh, rl);
switch (mod) {
- case 0:
+ case 0:
destoffset = decode_rm00_address(rl);
DECODE_PRINTF("\n");
break;
- case 1:
+ case 1:
destoffset = decode_rm01_address(rl);
DECODE_PRINTF("\n");
break;
- case 2:
+ case 2:
destoffset = decode_rm10_address(rl);
DECODE_PRINTF("\n");
break;
- case 3: /* register to register */
- stkelem = (u8)rl;
+ case 3: /* register to register */
+ stkelem = (u8) rl;
DECODE_PRINTF2("\tST(%d)\n", stkelem);
break;
}
#ifdef X86EMU_FPU_PRESENT
switch (mod) {
- case 3:
+ case 3:
switch (rh) {
- case 0:
+ case 0:
x86emu_fpu_R_ffree(stkelem);
break;
- case 1:
+ case 1:
x86emu_fpu_R_fxch(stkelem);
break;
- case 2:
+ case 2:
x86emu_fpu_R_fst(stkelem); /* register version */
break;
- case 3:
+ case 3:
x86emu_fpu_R_fstp(stkelem); /* register version */
break;
- default:
+ default:
x86emu_fpu_illegal();
break;
}
break;
- default:
+ default:
switch (rh) {
- case 0:
+ case 0:
x86emu_fpu_M_fild(X86EMU_FPU_WORD, destoffset);
break;
- case 1:
+ case 1:
x86emu_fpu_illegal();
break;
- case 2:
+ case 2:
x86emu_fpu_M_fist(X86EMU_FPU_WORD, destoffset);
break;
- case 3:
+ case 3:
x86emu_fpu_M_fistp(X86EMU_FPU_WORD, destoffset);
break;
- case 4:
+ case 4:
x86emu_fpu_M_fbld(X86EMU_FPU_BSD, destoffset);
break;
- case 5:
+ case 5:
x86emu_fpu_M_fild(X86EMU_FPU_LONG, destoffset);
break;
- case 6:
+ case 6:
x86emu_fpu_M_fbstp(X86EMU_FPU_BSD, destoffset);
break;
- case 7:
+ case 7:
x86emu_fpu_M_fistp(X86EMU_FPU_LONG, destoffset);
break;
}
}
#else
- (void)destoffset;
- (void)stkelem;
+ (void) destoffset;
+ (void) stkelem;
#endif
DECODE_CLEAR_SEGOVR();
END_OF_INSTR_NO_TRACE();
diff --git a/xorg-server/hw/xfree86/x86emu/ops.c b/xorg-server/hw/xfree86/x86emu/ops.c
index a55398275..76b83581f 100644
--- a/xorg-server/hw/xfree86/x86emu/ops.c
+++ b/xorg-server/hw/xfree86/x86emu/ops.c
@@ -1,11752 +1,12307 @@
-/****************************************************************************
-*
-* Realmode X86 Emulator Library
-*
-* Copyright (C) 1996-1999 SciTech Software, Inc.
-* Copyright (C) David Mosberger-Tang
-* Copyright (C) 1999 Egbert Eich
-*
-* ========================================================================
-*
-* Permission to use, copy, modify, distribute, and sell this software and
-* its documentation for any purpose is hereby granted without fee,
-* provided that the above copyright notice appear in all copies and that
-* both that copyright notice and this permission notice appear in
-* supporting documentation, and that the name of the authors not be used
-* in advertising or publicity pertaining to distribution of the software
-* without specific, written prior permission. The authors makes no
-* representations about the suitability of this software for any purpose.
-* It is provided "as is" without express or implied warranty.
-*
-* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
-* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
-* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
-* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
-* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-* PERFORMANCE OF THIS SOFTWARE.
-*
-* ========================================================================
-*
-* Language: ANSI C
-* Environment: Any
-* Developer: Kendall Bennett
-*
-* Description: This file includes subroutines to implement the decoding
-* and emulation of all the x86 processor instructions.
-*
-* There are approximately 250 subroutines in here, which correspond
-* to the 256 byte-"opcodes" found on the 8086. The table which
-* dispatches this is found in the files optab.[ch].
-*
-* Each opcode proc has a comment preceeding it which gives it's table
-* address. Several opcodes are missing (undefined) in the table.
-*
-* Each proc includes information for decoding (DECODE_PRINTF and
-* DECODE_PRINTF2), debugging (TRACE_REGS, SINGLE_STEP), and misc
-* functions (START_OF_INSTR, END_OF_INSTR).
-*
-* Many of the procedures are *VERY* similar in coding. This has
-* allowed for a very large amount of code to be generated in a fairly
-* short amount of time (i.e. cut, paste, and modify). The result is
-* that much of the code below could have been folded into subroutines
-* for a large reduction in size of this file. The downside would be
-* that there would be a penalty in execution speed. The file could
-* also have been *MUCH* larger by inlining certain functions which
-* were called. This could have resulted even faster execution. The
-* prime directive I used to decide whether to inline the code or to
-* modularize it, was basically: 1) no unnecessary subroutine calls,
-* 2) no routines more than about 200 lines in size, and 3) modularize
-* any code that I might not get right the first time. The fetch_*
-* subroutines fall into the latter category. The The decode_* fall
-* into the second category. The coding of the "switch(mod){ .... }"
-* in many of the subroutines below falls into the first category.
-* Especially, the coding of {add,and,or,sub,...}_{byte,word}
-* subroutines are an especially glaring case of the third guideline.
-* Since so much of the code is cloned from other modules (compare
-* opcode #00 to opcode #01), making the basic operations subroutine
-* calls is especially important; otherwise mistakes in coding an
-* "add" would represent a nightmare in maintenance.
-*
-****************************************************************************/
-
-#include "x86emu/x86emui.h"
-
-/*----------------------------- Implementation ----------------------------*/
-
-/****************************************************************************
-PARAMETERS:
-op1 - Instruction op code
-
-REMARKS:
-Handles illegal opcodes.
-****************************************************************************/
-static void x86emuOp_illegal_op(
- u8 op1)
-{
- START_OF_INSTR();
- if (M.x86.R_SP != 0) {
- DECODE_PRINTF("ILLEGAL X86 OPCODE\n");
- TRACE_REGS();
- DB( printk("%04x:%04x: %02X ILLEGAL X86 OPCODE!\n",
- M.x86.R_CS, M.x86.R_IP-1,op1));
- HALT_SYS();
- }
- else {
- /* If we get here, it means the stack pointer is back to zero
- * so we are just returning from an emulator service call
- * so therte is no need to display an error message. We trap
- * the emulator with an 0xF1 opcode to finish the service
- * call.
- */
- X86EMU_halt_sys();
- }
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x00
-****************************************************************************/
-static void x86emuOp_add_byte_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
- u8 *destreg, *srcreg;
- u8 destval;
-
- START_OF_INSTR();
- DECODE_PRINTF("ADD\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = add_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
- case 1:
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = add_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
- case 2:
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = add_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = add_byte(*destreg, *srcreg);
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x01
-****************************************************************************/
-static void x86emuOp_add_word_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("ADD\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = add_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = add_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = add_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = add_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = add_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = add_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = add_long(*destreg, *srcreg);
- } else {
- u16 *destreg,*srcreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = add_word(*destreg, *srcreg);
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x02
-****************************************************************************/
-static void x86emuOp_add_byte_R_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg, *srcreg;
- uint srcoffset;
- u8 srcval;
-
- START_OF_INSTR();
- DECODE_PRINTF("ADD\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = add_byte(*destreg, srcval);
- break;
- case 1:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = add_byte(*destreg, srcval);
- break;
- case 2:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = add_byte(*destreg, srcval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = add_byte(*destreg, *srcreg);
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x03
-****************************************************************************/
-static void x86emuOp_add_word_R_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint srcoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("ADD\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = add_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = add_word(*destreg, srcval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = add_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = add_word(*destreg, srcval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = add_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = add_word(*destreg, srcval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = add_long(*destreg, *srcreg);
- } else {
- u16 *destreg,*srcreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = add_word(*destreg, *srcreg);
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x04
-****************************************************************************/
-static void x86emuOp_add_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
-{
- u8 srcval;
-
- START_OF_INSTR();
- DECODE_PRINTF("ADD\tAL,");
- srcval = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- M.x86.R_AL = add_byte(M.x86.R_AL, srcval);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x05
-****************************************************************************/
-static void x86emuOp_add_word_AX_IMM(u8 X86EMU_UNUSED(op1))
-{
- u32 srcval;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("ADD\tEAX,");
- srcval = fetch_long_imm();
- } else {
- DECODE_PRINTF("ADD\tAX,");
- srcval = fetch_word_imm();
- }
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EAX = add_long(M.x86.R_EAX, srcval);
- } else {
- M.x86.R_AX = add_word(M.x86.R_AX, (u16)srcval);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x06
-****************************************************************************/
-static void x86emuOp_push_ES(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("PUSH\tES\n");
- TRACE_AND_STEP();
- push_word(M.x86.R_ES);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x07
-****************************************************************************/
-static void x86emuOp_pop_ES(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("POP\tES\n");
- TRACE_AND_STEP();
- M.x86.R_ES = pop_word();
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x08
-****************************************************************************/
-static void x86emuOp_or_byte_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg, *srcreg;
- uint destoffset;
- u8 destval;
-
- START_OF_INSTR();
- DECODE_PRINTF("OR\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = or_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
- case 1:
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = or_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
- case 2:
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = or_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = or_byte(*destreg, *srcreg);
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x09
-****************************************************************************/
-static void x86emuOp_or_word_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("OR\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = or_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = or_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = or_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = or_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = or_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = or_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = or_long(*destreg, *srcreg);
- } else {
- u16 *destreg,*srcreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = or_word(*destreg, *srcreg);
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x0a
-****************************************************************************/
-static void x86emuOp_or_byte_R_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg, *srcreg;
- uint srcoffset;
- u8 srcval;
-
- START_OF_INSTR();
- DECODE_PRINTF("OR\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = or_byte(*destreg, srcval);
- break;
- case 1:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = or_byte(*destreg, srcval);
- break;
- case 2:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = or_byte(*destreg, srcval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = or_byte(*destreg, *srcreg);
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x0b
-****************************************************************************/
-static void x86emuOp_or_word_R_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint srcoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("OR\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = or_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = or_word(*destreg, srcval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = or_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = or_word(*destreg, srcval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = or_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = or_word(*destreg, srcval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = or_long(*destreg, *srcreg);
- } else {
- u16 *destreg,*srcreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = or_word(*destreg, *srcreg);
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x0c
-****************************************************************************/
-static void x86emuOp_or_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
-{
- u8 srcval;
-
- START_OF_INSTR();
- DECODE_PRINTF("OR\tAL,");
- srcval = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- M.x86.R_AL = or_byte(M.x86.R_AL, srcval);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x0d
-****************************************************************************/
-static void x86emuOp_or_word_AX_IMM(u8 X86EMU_UNUSED(op1))
-{
- u32 srcval;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("OR\tEAX,");
- srcval = fetch_long_imm();
- } else {
- DECODE_PRINTF("OR\tAX,");
- srcval = fetch_word_imm();
- }
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EAX = or_long(M.x86.R_EAX, srcval);
- } else {
- M.x86.R_AX = or_word(M.x86.R_AX, (u16)srcval);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x0e
-****************************************************************************/
-static void x86emuOp_push_CS(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("PUSH\tCS\n");
- TRACE_AND_STEP();
- push_word(M.x86.R_CS);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x0f. Escape for two-byte opcode (286 or better)
-****************************************************************************/
-static void x86emuOp_two_byte(u8 X86EMU_UNUSED(op1))
-{
- u8 op2 = (*sys_rdb)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP++));
- INC_DECODED_INST_LEN(1);
- (*x86emu_optab2[op2])(op2);
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x10
-****************************************************************************/
-static void x86emuOp_adc_byte_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg, *srcreg;
- uint destoffset;
- u8 destval;
-
- START_OF_INSTR();
- DECODE_PRINTF("ADC\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = adc_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
- case 1:
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = adc_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
- case 2:
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = adc_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = adc_byte(*destreg, *srcreg);
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x11
-****************************************************************************/
-static void x86emuOp_adc_word_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("ADC\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = adc_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = adc_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = adc_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = adc_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = adc_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = adc_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = adc_long(*destreg, *srcreg);
- } else {
- u16 *destreg,*srcreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = adc_word(*destreg, *srcreg);
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x12
-****************************************************************************/
-static void x86emuOp_adc_byte_R_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg, *srcreg;
- uint srcoffset;
- u8 srcval;
-
- START_OF_INSTR();
- DECODE_PRINTF("ADC\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = adc_byte(*destreg, srcval);
- break;
- case 1:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = adc_byte(*destreg, srcval);
- break;
- case 2:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = adc_byte(*destreg, srcval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = adc_byte(*destreg, *srcreg);
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x13
-****************************************************************************/
-static void x86emuOp_adc_word_R_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint srcoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("ADC\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = adc_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = adc_word(*destreg, srcval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = adc_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = adc_word(*destreg, srcval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = adc_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = adc_word(*destreg, srcval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = adc_long(*destreg, *srcreg);
- } else {
- u16 *destreg,*srcreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = adc_word(*destreg, *srcreg);
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x14
-****************************************************************************/
-static void x86emuOp_adc_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
-{
- u8 srcval;
-
- START_OF_INSTR();
- DECODE_PRINTF("ADC\tAL,");
- srcval = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- M.x86.R_AL = adc_byte(M.x86.R_AL, srcval);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x15
-****************************************************************************/
-static void x86emuOp_adc_word_AX_IMM(u8 X86EMU_UNUSED(op1))
-{
- u32 srcval;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("ADC\tEAX,");
- srcval = fetch_long_imm();
- } else {
- DECODE_PRINTF("ADC\tAX,");
- srcval = fetch_word_imm();
- }
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EAX = adc_long(M.x86.R_EAX, srcval);
- } else {
- M.x86.R_AX = adc_word(M.x86.R_AX, (u16)srcval);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x16
-****************************************************************************/
-static void x86emuOp_push_SS(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("PUSH\tSS\n");
- TRACE_AND_STEP();
- push_word(M.x86.R_SS);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x17
-****************************************************************************/
-static void x86emuOp_pop_SS(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("POP\tSS\n");
- TRACE_AND_STEP();
- M.x86.R_SS = pop_word();
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x18
-****************************************************************************/
-static void x86emuOp_sbb_byte_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg, *srcreg;
- uint destoffset;
- u8 destval;
-
- START_OF_INSTR();
- DECODE_PRINTF("SBB\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = sbb_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
- case 1:
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = sbb_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
- case 2:
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = sbb_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sbb_byte(*destreg, *srcreg);
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x19
-****************************************************************************/
-static void x86emuOp_sbb_word_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("SBB\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = sbb_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = sbb_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = sbb_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = sbb_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = sbb_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = sbb_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sbb_long(*destreg, *srcreg);
- } else {
- u16 *destreg,*srcreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sbb_word(*destreg, *srcreg);
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x1a
-****************************************************************************/
-static void x86emuOp_sbb_byte_R_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg, *srcreg;
- uint srcoffset;
- u8 srcval;
-
- START_OF_INSTR();
- DECODE_PRINTF("SBB\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sbb_byte(*destreg, srcval);
- break;
- case 1:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sbb_byte(*destreg, srcval);
- break;
- case 2:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sbb_byte(*destreg, srcval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sbb_byte(*destreg, *srcreg);
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x1b
-****************************************************************************/
-static void x86emuOp_sbb_word_R_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint srcoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("SBB\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sbb_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sbb_word(*destreg, srcval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sbb_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sbb_word(*destreg, srcval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sbb_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sbb_word(*destreg, srcval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sbb_long(*destreg, *srcreg);
- } else {
- u16 *destreg,*srcreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sbb_word(*destreg, *srcreg);
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x1c
-****************************************************************************/
-static void x86emuOp_sbb_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
-{
- u8 srcval;
-
- START_OF_INSTR();
- DECODE_PRINTF("SBB\tAL,");
- srcval = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- M.x86.R_AL = sbb_byte(M.x86.R_AL, srcval);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x1d
-****************************************************************************/
-static void x86emuOp_sbb_word_AX_IMM(u8 X86EMU_UNUSED(op1))
-{
- u32 srcval;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("SBB\tEAX,");
- srcval = fetch_long_imm();
- } else {
- DECODE_PRINTF("SBB\tAX,");
- srcval = fetch_word_imm();
- }
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EAX = sbb_long(M.x86.R_EAX, srcval);
- } else {
- M.x86.R_AX = sbb_word(M.x86.R_AX, (u16)srcval);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x1e
-****************************************************************************/
-static void x86emuOp_push_DS(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("PUSH\tDS\n");
- TRACE_AND_STEP();
- push_word(M.x86.R_DS);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x1f
-****************************************************************************/
-static void x86emuOp_pop_DS(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("POP\tDS\n");
- TRACE_AND_STEP();
- M.x86.R_DS = pop_word();
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x20
-****************************************************************************/
-static void x86emuOp_and_byte_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg, *srcreg;
- uint destoffset;
- u8 destval;
-
- START_OF_INSTR();
- DECODE_PRINTF("AND\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
-
- switch (mod) {
- case 0:
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = and_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
-
- case 1:
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = and_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
-
- case 2:
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = and_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
-
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = and_byte(*destreg, *srcreg);
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x21
-****************************************************************************/
-static void x86emuOp_and_word_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("AND\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = and_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = and_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = and_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = and_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = and_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = and_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = and_long(*destreg, *srcreg);
- } else {
- u16 *destreg,*srcreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = and_word(*destreg, *srcreg);
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x22
-****************************************************************************/
-static void x86emuOp_and_byte_R_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg, *srcreg;
- uint srcoffset;
- u8 srcval;
-
- START_OF_INSTR();
- DECODE_PRINTF("AND\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = and_byte(*destreg, srcval);
- break;
- case 1:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = and_byte(*destreg, srcval);
- break;
- case 2:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = and_byte(*destreg, srcval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = and_byte(*destreg, *srcreg);
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x23
-****************************************************************************/
-static void x86emuOp_and_word_R_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint srcoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("AND\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = and_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = and_word(*destreg, srcval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = and_long(*destreg, srcval);
- break;
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = and_word(*destreg, srcval);
- break;
- }
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = and_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = and_word(*destreg, srcval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = and_long(*destreg, *srcreg);
- } else {
- u16 *destreg,*srcreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = and_word(*destreg, *srcreg);
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x24
-****************************************************************************/
-static void x86emuOp_and_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
-{
- u8 srcval;
-
- START_OF_INSTR();
- DECODE_PRINTF("AND\tAL,");
- srcval = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- M.x86.R_AL = and_byte(M.x86.R_AL, srcval);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x25
-****************************************************************************/
-static void x86emuOp_and_word_AX_IMM(u8 X86EMU_UNUSED(op1))
-{
- u32 srcval;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("AND\tEAX,");
- srcval = fetch_long_imm();
- } else {
- DECODE_PRINTF("AND\tAX,");
- srcval = fetch_word_imm();
- }
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EAX = and_long(M.x86.R_EAX, srcval);
- } else {
- M.x86.R_AX = and_word(M.x86.R_AX, (u16)srcval);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x26
-****************************************************************************/
-static void x86emuOp_segovr_ES(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("ES:\n");
- TRACE_AND_STEP();
- M.x86.mode |= SYSMODE_SEGOVR_ES;
- /*
- * note the lack of DECODE_CLEAR_SEGOVR(r) since, here is one of 4
- * opcode subroutines we do not want to do this.
- */
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x27
-****************************************************************************/
-static void x86emuOp_daa(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("DAA\n");
- TRACE_AND_STEP();
- M.x86.R_AL = daa_byte(M.x86.R_AL);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x28
-****************************************************************************/
-static void x86emuOp_sub_byte_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg, *srcreg;
- uint destoffset;
- u8 destval;
-
- START_OF_INSTR();
- DECODE_PRINTF("SUB\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = sub_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
- case 1:
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = sub_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
- case 2:
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = sub_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sub_byte(*destreg, *srcreg);
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x29
-****************************************************************************/
-static void x86emuOp_sub_word_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("SUB\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = sub_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = sub_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = sub_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = sub_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = sub_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = sub_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sub_long(*destreg, *srcreg);
- } else {
- u16 *destreg,*srcreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sub_word(*destreg, *srcreg);
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x2a
-****************************************************************************/
-static void x86emuOp_sub_byte_R_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg, *srcreg;
- uint srcoffset;
- u8 srcval;
-
- START_OF_INSTR();
- DECODE_PRINTF("SUB\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sub_byte(*destreg, srcval);
- break;
- case 1:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sub_byte(*destreg, srcval);
- break;
- case 2:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sub_byte(*destreg, srcval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sub_byte(*destreg, *srcreg);
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x2b
-****************************************************************************/
-static void x86emuOp_sub_word_R_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint srcoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("SUB\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sub_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sub_word(*destreg, srcval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sub_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sub_word(*destreg, srcval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sub_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sub_word(*destreg, srcval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sub_long(*destreg, *srcreg);
- } else {
- u16 *destreg,*srcreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = sub_word(*destreg, *srcreg);
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x2c
-****************************************************************************/
-static void x86emuOp_sub_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
-{
- u8 srcval;
-
- START_OF_INSTR();
- DECODE_PRINTF("SUB\tAL,");
- srcval = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- M.x86.R_AL = sub_byte(M.x86.R_AL, srcval);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x2d
-****************************************************************************/
-static void x86emuOp_sub_word_AX_IMM(u8 X86EMU_UNUSED(op1))
-{
- u32 srcval;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("SUB\tEAX,");
- srcval = fetch_long_imm();
- } else {
- DECODE_PRINTF("SUB\tAX,");
- srcval = fetch_word_imm();
- }
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EAX = sub_long(M.x86.R_EAX, srcval);
- } else {
- M.x86.R_AX = sub_word(M.x86.R_AX, (u16)srcval);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x2e
-****************************************************************************/
-static void x86emuOp_segovr_CS(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("CS:\n");
- TRACE_AND_STEP();
- M.x86.mode |= SYSMODE_SEGOVR_CS;
- /* note no DECODE_CLEAR_SEGOVR here. */
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x2f
-****************************************************************************/
-static void x86emuOp_das(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("DAS\n");
- TRACE_AND_STEP();
- M.x86.R_AL = das_byte(M.x86.R_AL);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x30
-****************************************************************************/
-static void x86emuOp_xor_byte_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg, *srcreg;
- uint destoffset;
- u8 destval;
-
- START_OF_INSTR();
- DECODE_PRINTF("XOR\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = xor_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
- case 1:
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = xor_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
- case 2:
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = xor_byte(destval, *srcreg);
- store_data_byte(destoffset, destval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = xor_byte(*destreg, *srcreg);
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x31
-****************************************************************************/
-static void x86emuOp_xor_word_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("XOR\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = xor_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = xor_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = xor_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = xor_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = xor_long(destval, *srcreg);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = xor_word(destval, *srcreg);
- store_data_word(destoffset, destval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = xor_long(*destreg, *srcreg);
- } else {
- u16 *destreg,*srcreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = xor_word(*destreg, *srcreg);
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x32
-****************************************************************************/
-static void x86emuOp_xor_byte_R_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg, *srcreg;
- uint srcoffset;
- u8 srcval;
-
- START_OF_INSTR();
- DECODE_PRINTF("XOR\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = xor_byte(*destreg, srcval);
- break;
- case 1:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = xor_byte(*destreg, srcval);
- break;
- case 2:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = xor_byte(*destreg, srcval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = xor_byte(*destreg, *srcreg);
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x33
-****************************************************************************/
-static void x86emuOp_xor_word_R_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint srcoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("XOR\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = xor_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = xor_word(*destreg, srcval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = xor_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = xor_word(*destreg, srcval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = xor_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = xor_word(*destreg, srcval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = xor_long(*destreg, *srcreg);
- } else {
- u16 *destreg,*srcreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = xor_word(*destreg, *srcreg);
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x34
-****************************************************************************/
-static void x86emuOp_xor_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
-{
- u8 srcval;
-
- START_OF_INSTR();
- DECODE_PRINTF("XOR\tAL,");
- srcval = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- M.x86.R_AL = xor_byte(M.x86.R_AL, srcval);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x35
-****************************************************************************/
-static void x86emuOp_xor_word_AX_IMM(u8 X86EMU_UNUSED(op1))
-{
- u32 srcval;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("XOR\tEAX,");
- srcval = fetch_long_imm();
- } else {
- DECODE_PRINTF("XOR\tAX,");
- srcval = fetch_word_imm();
- }
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EAX = xor_long(M.x86.R_EAX, srcval);
- } else {
- M.x86.R_AX = xor_word(M.x86.R_AX, (u16)srcval);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x36
-****************************************************************************/
-static void x86emuOp_segovr_SS(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("SS:\n");
- TRACE_AND_STEP();
- M.x86.mode |= SYSMODE_SEGOVR_SS;
- /* no DECODE_CLEAR_SEGOVR ! */
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x37
-****************************************************************************/
-static void x86emuOp_aaa(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("AAA\n");
- TRACE_AND_STEP();
- M.x86.R_AX = aaa_word(M.x86.R_AX);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x38
-****************************************************************************/
-static void x86emuOp_cmp_byte_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
- u8 *destreg, *srcreg;
- u8 destval;
-
- START_OF_INSTR();
- DECODE_PRINTF("CMP\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_byte(destval, *srcreg);
- break;
- case 1:
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_byte(destval, *srcreg);
- break;
- case 2:
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_byte(destval, *srcreg);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_byte(*destreg, *srcreg);
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x39
-****************************************************************************/
-static void x86emuOp_cmp_word_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("CMP\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_long(destval, *srcreg);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_word(destval, *srcreg);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_long(destval, *srcreg);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_word(destval, *srcreg);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_long(destval, *srcreg);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_word(destval, *srcreg);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_long(*destreg, *srcreg);
- } else {
- u16 *destreg,*srcreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_word(*destreg, *srcreg);
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x3a
-****************************************************************************/
-static void x86emuOp_cmp_byte_R_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg, *srcreg;
- uint srcoffset;
- u8 srcval;
-
- START_OF_INSTR();
- DECODE_PRINTF("CMP\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_byte(*destreg, srcval);
- break;
- case 1:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_byte(*destreg, srcval);
- break;
- case 2:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_byte(*destreg, srcval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_byte(*destreg, *srcreg);
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x3b
-****************************************************************************/
-static void x86emuOp_cmp_word_R_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint srcoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("CMP\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_word(*destreg, srcval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_word(*destreg, srcval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_word(*destreg, srcval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_long(*destreg, *srcreg);
- } else {
- u16 *destreg,*srcreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- cmp_word(*destreg, *srcreg);
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x3c
-****************************************************************************/
-static void x86emuOp_cmp_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
-{
- u8 srcval;
-
- START_OF_INSTR();
- DECODE_PRINTF("CMP\tAL,");
- srcval = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- cmp_byte(M.x86.R_AL, srcval);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x3d
-****************************************************************************/
-static void x86emuOp_cmp_word_AX_IMM(u8 X86EMU_UNUSED(op1))
-{
- u32 srcval;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("CMP\tEAX,");
- srcval = fetch_long_imm();
- } else {
- DECODE_PRINTF("CMP\tAX,");
- srcval = fetch_word_imm();
- }
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- cmp_long(M.x86.R_EAX, srcval);
- } else {
- cmp_word(M.x86.R_AX, (u16)srcval);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x3e
-****************************************************************************/
-static void x86emuOp_segovr_DS(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("DS:\n");
- TRACE_AND_STEP();
- M.x86.mode |= SYSMODE_SEGOVR_DS;
- /* NO DECODE_CLEAR_SEGOVR! */
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x3f
-****************************************************************************/
-static void x86emuOp_aas(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("AAS\n");
- TRACE_AND_STEP();
- M.x86.R_AX = aas_word(M.x86.R_AX);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x40
-****************************************************************************/
-static void x86emuOp_inc_AX(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("INC\tEAX\n");
- } else {
- DECODE_PRINTF("INC\tAX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EAX = inc_long(M.x86.R_EAX);
- } else {
- M.x86.R_AX = inc_word(M.x86.R_AX);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x41
-****************************************************************************/
-static void x86emuOp_inc_CX(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("INC\tECX\n");
- } else {
- DECODE_PRINTF("INC\tCX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_ECX = inc_long(M.x86.R_ECX);
- } else {
- M.x86.R_CX = inc_word(M.x86.R_CX);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x42
-****************************************************************************/
-static void x86emuOp_inc_DX(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("INC\tEDX\n");
- } else {
- DECODE_PRINTF("INC\tDX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EDX = inc_long(M.x86.R_EDX);
- } else {
- M.x86.R_DX = inc_word(M.x86.R_DX);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x43
-****************************************************************************/
-static void x86emuOp_inc_BX(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("INC\tEBX\n");
- } else {
- DECODE_PRINTF("INC\tBX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EBX = inc_long(M.x86.R_EBX);
- } else {
- M.x86.R_BX = inc_word(M.x86.R_BX);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x44
-****************************************************************************/
-static void x86emuOp_inc_SP(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("INC\tESP\n");
- } else {
- DECODE_PRINTF("INC\tSP\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_ESP = inc_long(M.x86.R_ESP);
- } else {
- M.x86.R_SP = inc_word(M.x86.R_SP);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x45
-****************************************************************************/
-static void x86emuOp_inc_BP(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("INC\tEBP\n");
- } else {
- DECODE_PRINTF("INC\tBP\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EBP = inc_long(M.x86.R_EBP);
- } else {
- M.x86.R_BP = inc_word(M.x86.R_BP);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x46
-****************************************************************************/
-static void x86emuOp_inc_SI(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("INC\tESI\n");
- } else {
- DECODE_PRINTF("INC\tSI\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_ESI = inc_long(M.x86.R_ESI);
- } else {
- M.x86.R_SI = inc_word(M.x86.R_SI);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x47
-****************************************************************************/
-static void x86emuOp_inc_DI(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("INC\tEDI\n");
- } else {
- DECODE_PRINTF("INC\tDI\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EDI = inc_long(M.x86.R_EDI);
- } else {
- M.x86.R_DI = inc_word(M.x86.R_DI);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x48
-****************************************************************************/
-static void x86emuOp_dec_AX(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("DEC\tEAX\n");
- } else {
- DECODE_PRINTF("DEC\tAX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EAX = dec_long(M.x86.R_EAX);
- } else {
- M.x86.R_AX = dec_word(M.x86.R_AX);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x49
-****************************************************************************/
-static void x86emuOp_dec_CX(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("DEC\tECX\n");
- } else {
- DECODE_PRINTF("DEC\tCX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_ECX = dec_long(M.x86.R_ECX);
- } else {
- M.x86.R_CX = dec_word(M.x86.R_CX);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x4a
-****************************************************************************/
-static void x86emuOp_dec_DX(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("DEC\tEDX\n");
- } else {
- DECODE_PRINTF("DEC\tDX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EDX = dec_long(M.x86.R_EDX);
- } else {
- M.x86.R_DX = dec_word(M.x86.R_DX);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x4b
-****************************************************************************/
-static void x86emuOp_dec_BX(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("DEC\tEBX\n");
- } else {
- DECODE_PRINTF("DEC\tBX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EBX = dec_long(M.x86.R_EBX);
- } else {
- M.x86.R_BX = dec_word(M.x86.R_BX);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x4c
-****************************************************************************/
-static void x86emuOp_dec_SP(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("DEC\tESP\n");
- } else {
- DECODE_PRINTF("DEC\tSP\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_ESP = dec_long(M.x86.R_ESP);
- } else {
- M.x86.R_SP = dec_word(M.x86.R_SP);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x4d
-****************************************************************************/
-static void x86emuOp_dec_BP(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("DEC\tEBP\n");
- } else {
- DECODE_PRINTF("DEC\tBP\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EBP = dec_long(M.x86.R_EBP);
- } else {
- M.x86.R_BP = dec_word(M.x86.R_BP);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x4e
-****************************************************************************/
-static void x86emuOp_dec_SI(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("DEC\tESI\n");
- } else {
- DECODE_PRINTF("DEC\tSI\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_ESI = dec_long(M.x86.R_ESI);
- } else {
- M.x86.R_SI = dec_word(M.x86.R_SI);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x4f
-****************************************************************************/
-static void x86emuOp_dec_DI(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("DEC\tEDI\n");
- } else {
- DECODE_PRINTF("DEC\tDI\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EDI = dec_long(M.x86.R_EDI);
- } else {
- M.x86.R_DI = dec_word(M.x86.R_DI);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x50
-****************************************************************************/
-static void x86emuOp_push_AX(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("PUSH\tEAX\n");
- } else {
- DECODE_PRINTF("PUSH\tAX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- push_long(M.x86.R_EAX);
- } else {
- push_word(M.x86.R_AX);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x51
-****************************************************************************/
-static void x86emuOp_push_CX(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("PUSH\tECX\n");
- } else {
- DECODE_PRINTF("PUSH\tCX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- push_long(M.x86.R_ECX);
- } else {
- push_word(M.x86.R_CX);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x52
-****************************************************************************/
-static void x86emuOp_push_DX(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("PUSH\tEDX\n");
- } else {
- DECODE_PRINTF("PUSH\tDX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- push_long(M.x86.R_EDX);
- } else {
- push_word(M.x86.R_DX);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x53
-****************************************************************************/
-static void x86emuOp_push_BX(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("PUSH\tEBX\n");
- } else {
- DECODE_PRINTF("PUSH\tBX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- push_long(M.x86.R_EBX);
- } else {
- push_word(M.x86.R_BX);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x54
-****************************************************************************/
-static void x86emuOp_push_SP(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("PUSH\tESP\n");
- } else {
- DECODE_PRINTF("PUSH\tSP\n");
- }
- TRACE_AND_STEP();
- /* Always push (E)SP, since we are emulating an i386 and above
- * processor. This is necessary as some BIOS'es use this to check
- * what type of processor is in the system.
- */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- push_long(M.x86.R_ESP);
- } else {
- push_word((u16)(M.x86.R_SP));
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x55
-****************************************************************************/
-static void x86emuOp_push_BP(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("PUSH\tEBP\n");
- } else {
- DECODE_PRINTF("PUSH\tBP\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- push_long(M.x86.R_EBP);
- } else {
- push_word(M.x86.R_BP);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x56
-****************************************************************************/
-static void x86emuOp_push_SI(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("PUSH\tESI\n");
- } else {
- DECODE_PRINTF("PUSH\tSI\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- push_long(M.x86.R_ESI);
- } else {
- push_word(M.x86.R_SI);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x57
-****************************************************************************/
-static void x86emuOp_push_DI(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("PUSH\tEDI\n");
- } else {
- DECODE_PRINTF("PUSH\tDI\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- push_long(M.x86.R_EDI);
- } else {
- push_word(M.x86.R_DI);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x58
-****************************************************************************/
-static void x86emuOp_pop_AX(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("POP\tEAX\n");
- } else {
- DECODE_PRINTF("POP\tAX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EAX = pop_long();
- } else {
- M.x86.R_AX = pop_word();
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x59
-****************************************************************************/
-static void x86emuOp_pop_CX(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("POP\tECX\n");
- } else {
- DECODE_PRINTF("POP\tCX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_ECX = pop_long();
- } else {
- M.x86.R_CX = pop_word();
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x5a
-****************************************************************************/
-static void x86emuOp_pop_DX(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("POP\tEDX\n");
- } else {
- DECODE_PRINTF("POP\tDX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EDX = pop_long();
- } else {
- M.x86.R_DX = pop_word();
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x5b
-****************************************************************************/
-static void x86emuOp_pop_BX(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("POP\tEBX\n");
- } else {
- DECODE_PRINTF("POP\tBX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EBX = pop_long();
- } else {
- M.x86.R_BX = pop_word();
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x5c
-****************************************************************************/
-static void x86emuOp_pop_SP(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("POP\tESP\n");
- } else {
- DECODE_PRINTF("POP\tSP\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_ESP = pop_long();
- } else {
- M.x86.R_SP = pop_word();
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x5d
-****************************************************************************/
-static void x86emuOp_pop_BP(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("POP\tEBP\n");
- } else {
- DECODE_PRINTF("POP\tBP\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EBP = pop_long();
- } else {
- M.x86.R_BP = pop_word();
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x5e
-****************************************************************************/
-static void x86emuOp_pop_SI(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("POP\tESI\n");
- } else {
- DECODE_PRINTF("POP\tSI\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_ESI = pop_long();
- } else {
- M.x86.R_SI = pop_word();
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x5f
-****************************************************************************/
-static void x86emuOp_pop_DI(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("POP\tEDI\n");
- } else {
- DECODE_PRINTF("POP\tDI\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EDI = pop_long();
- } else {
- M.x86.R_DI = pop_word();
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x60
-****************************************************************************/
-static void x86emuOp_push_all(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("PUSHAD\n");
- } else {
- DECODE_PRINTF("PUSHA\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 old_sp = M.x86.R_ESP;
-
- push_long(M.x86.R_EAX);
- push_long(M.x86.R_ECX);
- push_long(M.x86.R_EDX);
- push_long(M.x86.R_EBX);
- push_long(old_sp);
- push_long(M.x86.R_EBP);
- push_long(M.x86.R_ESI);
- push_long(M.x86.R_EDI);
- } else {
- u16 old_sp = M.x86.R_SP;
-
- push_word(M.x86.R_AX);
- push_word(M.x86.R_CX);
- push_word(M.x86.R_DX);
- push_word(M.x86.R_BX);
- push_word(old_sp);
- push_word(M.x86.R_BP);
- push_word(M.x86.R_SI);
- push_word(M.x86.R_DI);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x61
-****************************************************************************/
-static void x86emuOp_pop_all(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("POPAD\n");
- } else {
- DECODE_PRINTF("POPA\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EDI = pop_long();
- M.x86.R_ESI = pop_long();
- M.x86.R_EBP = pop_long();
- M.x86.R_ESP += 4; /* skip ESP */
- M.x86.R_EBX = pop_long();
- M.x86.R_EDX = pop_long();
- M.x86.R_ECX = pop_long();
- M.x86.R_EAX = pop_long();
- } else {
- M.x86.R_DI = pop_word();
- M.x86.R_SI = pop_word();
- M.x86.R_BP = pop_word();
- M.x86.R_SP += 2; /* skip SP */
- M.x86.R_BX = pop_word();
- M.x86.R_DX = pop_word();
- M.x86.R_CX = pop_word();
- M.x86.R_AX = pop_word();
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/*opcode 0x62 ILLEGAL OP, calls x86emuOp_illegal_op() */
-/*opcode 0x63 ILLEGAL OP, calls x86emuOp_illegal_op() */
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x64
-****************************************************************************/
-static void x86emuOp_segovr_FS(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("FS:\n");
- TRACE_AND_STEP();
- M.x86.mode |= SYSMODE_SEGOVR_FS;
- /*
- * note the lack of DECODE_CLEAR_SEGOVR(r) since, here is one of 4
- * opcode subroutines we do not want to do this.
- */
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x65
-****************************************************************************/
-static void x86emuOp_segovr_GS(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("GS:\n");
- TRACE_AND_STEP();
- M.x86.mode |= SYSMODE_SEGOVR_GS;
- /*
- * note the lack of DECODE_CLEAR_SEGOVR(r) since, here is one of 4
- * opcode subroutines we do not want to do this.
- */
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x66 - prefix for 32-bit register
-****************************************************************************/
-static void x86emuOp_prefix_data(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("DATA:\n");
- TRACE_AND_STEP();
- M.x86.mode |= SYSMODE_PREFIX_DATA;
- /* note no DECODE_CLEAR_SEGOVR here. */
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x67 - prefix for 32-bit address
-****************************************************************************/
-static void x86emuOp_prefix_addr(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("ADDR:\n");
- TRACE_AND_STEP();
- M.x86.mode |= SYSMODE_PREFIX_ADDR;
- /* note no DECODE_CLEAR_SEGOVR here. */
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x68
-****************************************************************************/
-static void x86emuOp_push_word_IMM(u8 X86EMU_UNUSED(op1))
-{
- u32 imm;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- imm = fetch_long_imm();
- } else {
- imm = fetch_word_imm();
- }
- DECODE_PRINTF2("PUSH\t%x\n", imm);
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- push_long(imm);
- } else {
- push_word((u16)imm);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x69
-****************************************************************************/
-static void x86emuOp_imul_word_IMM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint srcoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("IMUL\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
- u32 res_lo,res_hi;
- s32 imm;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_long(srcoffset);
- imm = fetch_long_imm();
- DECODE_PRINTF2(",%d\n", (s32)imm);
- TRACE_AND_STEP();
- imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm);
- if (res_hi != 0) {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
- } else {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- }
- *destreg = (u32)res_lo;
- } else {
- u16 *destreg;
- u16 srcval;
- u32 res;
- s16 imm;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_word(srcoffset);
- imm = fetch_word_imm();
- DECODE_PRINTF2(",%d\n", (s32)imm);
- TRACE_AND_STEP();
- res = (s16)srcval * (s16)imm;
- if (res > 0xFFFF) {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
- } else {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- }
- *destreg = (u16)res;
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
- u32 res_lo,res_hi;
- s32 imm;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_long(srcoffset);
- imm = fetch_long_imm();
- DECODE_PRINTF2(",%d\n", (s32)imm);
- TRACE_AND_STEP();
- imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm);
- if (res_hi != 0) {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
- } else {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- }
- *destreg = (u32)res_lo;
- } else {
- u16 *destreg;
- u16 srcval;
- u32 res;
- s16 imm;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_word(srcoffset);
- imm = fetch_word_imm();
- DECODE_PRINTF2(",%d\n", (s32)imm);
- TRACE_AND_STEP();
- res = (s16)srcval * (s16)imm;
- if (res > 0xFFFF) {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
- } else {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- }
- *destreg = (u16)res;
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
- u32 res_lo,res_hi;
- s32 imm;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_long(srcoffset);
- imm = fetch_long_imm();
- DECODE_PRINTF2(",%d\n", (s32)imm);
- TRACE_AND_STEP();
- imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm);
- if (res_hi != 0) {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
- } else {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- }
- *destreg = (u32)res_lo;
- } else {
- u16 *destreg;
- u16 srcval;
- u32 res;
- s16 imm;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_word(srcoffset);
- imm = fetch_word_imm();
- DECODE_PRINTF2(",%d\n", (s32)imm);
- TRACE_AND_STEP();
- res = (s16)srcval * (s16)imm;
- if (res > 0xFFFF) {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
- } else {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- }
- *destreg = (u16)res;
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
- u32 res_lo,res_hi;
- s32 imm;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rl);
- imm = fetch_long_imm();
- DECODE_PRINTF2(",%d\n", (s32)imm);
- TRACE_AND_STEP();
- imul_long_direct(&res_lo,&res_hi,(s32)*srcreg,(s32)imm);
- if (res_hi != 0) {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
- } else {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- }
- *destreg = (u32)res_lo;
- } else {
- u16 *destreg,*srcreg;
- u32 res;
- s16 imm;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rl);
- imm = fetch_word_imm();
- DECODE_PRINTF2(",%d\n", (s32)imm);
- res = (s16)*srcreg * (s16)imm;
- if (res > 0xFFFF) {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
- } else {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- }
- *destreg = (u16)res;
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x6a
-****************************************************************************/
-static void x86emuOp_push_byte_IMM(u8 X86EMU_UNUSED(op1))
-{
- s16 imm;
-
- START_OF_INSTR();
- imm = (s8)fetch_byte_imm();
- DECODE_PRINTF2("PUSH\t%d\n", imm);
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- push_long((s32)imm);
- } else {
- push_word(imm);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x6b
-****************************************************************************/
-static void x86emuOp_imul_byte_IMM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint srcoffset;
- s8 imm;
-
- START_OF_INSTR();
- DECODE_PRINTF("IMUL\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
- u32 res_lo,res_hi;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_long(srcoffset);
- imm = fetch_byte_imm();
- DECODE_PRINTF2(",%d\n", (s32)imm);
- TRACE_AND_STEP();
- imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm);
- if (res_hi != 0) {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
- } else {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- }
- *destreg = (u32)res_lo;
- } else {
- u16 *destreg;
- u16 srcval;
- u32 res;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_word(srcoffset);
- imm = fetch_byte_imm();
- DECODE_PRINTF2(",%d\n", (s32)imm);
- TRACE_AND_STEP();
- res = (s16)srcval * (s16)imm;
- if (res > 0xFFFF) {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
- } else {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- }
- *destreg = (u16)res;
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
- u32 res_lo,res_hi;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_long(srcoffset);
- imm = fetch_byte_imm();
- DECODE_PRINTF2(",%d\n", (s32)imm);
- TRACE_AND_STEP();
- imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm);
- if (res_hi != 0) {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
- } else {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- }
- *destreg = (u32)res_lo;
- } else {
- u16 *destreg;
- u16 srcval;
- u32 res;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_word(srcoffset);
- imm = fetch_byte_imm();
- DECODE_PRINTF2(",%d\n", (s32)imm);
- TRACE_AND_STEP();
- res = (s16)srcval * (s16)imm;
- if (res > 0xFFFF) {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
- } else {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- }
- *destreg = (u16)res;
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
- u32 res_lo,res_hi;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_long(srcoffset);
- imm = fetch_byte_imm();
- DECODE_PRINTF2(",%d\n", (s32)imm);
- TRACE_AND_STEP();
- imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm);
- if (res_hi != 0) {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
- } else {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- }
- *destreg = (u32)res_lo;
- } else {
- u16 *destreg;
- u16 srcval;
- u32 res;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_word(srcoffset);
- imm = fetch_byte_imm();
- DECODE_PRINTF2(",%d\n", (s32)imm);
- TRACE_AND_STEP();
- res = (s16)srcval * (s16)imm;
- if (res > 0xFFFF) {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
- } else {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- }
- *destreg = (u16)res;
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
- u32 res_lo,res_hi;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rl);
- imm = fetch_byte_imm();
- DECODE_PRINTF2(",%d\n", (s32)imm);
- TRACE_AND_STEP();
- imul_long_direct(&res_lo,&res_hi,(s32)*srcreg,(s32)imm);
- if (res_hi != 0) {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
- } else {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- }
- *destreg = (u32)res_lo;
- } else {
- u16 *destreg,*srcreg;
- u32 res;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rl);
- imm = fetch_byte_imm();
- DECODE_PRINTF2(",%d\n", (s32)imm);
- res = (s16)*srcreg * (s16)imm;
- if (res > 0xFFFF) {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
- } else {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- }
- *destreg = (u16)res;
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x6c
-****************************************************************************/
-static void x86emuOp_ins_byte(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("INSB\n");
- ins(1);
- TRACE_AND_STEP();
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x6d
-****************************************************************************/
-static void x86emuOp_ins_word(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("INSD\n");
- ins(4);
- } else {
- DECODE_PRINTF("INSW\n");
- ins(2);
- }
- TRACE_AND_STEP();
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x6e
-****************************************************************************/
-static void x86emuOp_outs_byte(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("OUTSB\n");
- outs(1);
- TRACE_AND_STEP();
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x6f
-****************************************************************************/
-static void x86emuOp_outs_word(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("OUTSD\n");
- outs(4);
- } else {
- DECODE_PRINTF("OUTSW\n");
- outs(2);
- }
- TRACE_AND_STEP();
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x70
-****************************************************************************/
-static void x86emuOp_jump_near_O(u8 X86EMU_UNUSED(op1))
-{
- s8 offset;
- u16 target;
-
- /* jump to byte offset if overflow flag is set */
- START_OF_INSTR();
- DECODE_PRINTF("JO\t");
- offset = (s8)fetch_byte_imm();
- target = (u16)(M.x86.R_IP + (s16)offset);
- DECODE_PRINTF2("%x\n", target);
- TRACE_AND_STEP();
- if (ACCESS_FLAG(F_OF))
- M.x86.R_IP = target;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x71
-****************************************************************************/
-static void x86emuOp_jump_near_NO(u8 X86EMU_UNUSED(op1))
-{
- s8 offset;
- u16 target;
-
- /* jump to byte offset if overflow is not set */
- START_OF_INSTR();
- DECODE_PRINTF("JNO\t");
- offset = (s8)fetch_byte_imm();
- target = (u16)(M.x86.R_IP + (s16)offset);
- DECODE_PRINTF2("%x\n", target);
- TRACE_AND_STEP();
- if (!ACCESS_FLAG(F_OF))
- M.x86.R_IP = target;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x72
-****************************************************************************/
-static void x86emuOp_jump_near_B(u8 X86EMU_UNUSED(op1))
-{
- s8 offset;
- u16 target;
-
- /* jump to byte offset if carry flag is set. */
- START_OF_INSTR();
- DECODE_PRINTF("JB\t");
- offset = (s8)fetch_byte_imm();
- target = (u16)(M.x86.R_IP + (s16)offset);
- DECODE_PRINTF2("%x\n", target);
- TRACE_AND_STEP();
- if (ACCESS_FLAG(F_CF))
- M.x86.R_IP = target;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x73
-****************************************************************************/
-static void x86emuOp_jump_near_NB(u8 X86EMU_UNUSED(op1))
-{
- s8 offset;
- u16 target;
-
- /* jump to byte offset if carry flag is clear. */
- START_OF_INSTR();
- DECODE_PRINTF("JNB\t");
- offset = (s8)fetch_byte_imm();
- target = (u16)(M.x86.R_IP + (s16)offset);
- DECODE_PRINTF2("%x\n", target);
- TRACE_AND_STEP();
- if (!ACCESS_FLAG(F_CF))
- M.x86.R_IP = target;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x74
-****************************************************************************/
-static void x86emuOp_jump_near_Z(u8 X86EMU_UNUSED(op1))
-{
- s8 offset;
- u16 target;
-
- /* jump to byte offset if zero flag is set. */
- START_OF_INSTR();
- DECODE_PRINTF("JZ\t");
- offset = (s8)fetch_byte_imm();
- target = (u16)(M.x86.R_IP + (s16)offset);
- DECODE_PRINTF2("%x\n", target);
- TRACE_AND_STEP();
- if (ACCESS_FLAG(F_ZF))
- M.x86.R_IP = target;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x75
-****************************************************************************/
-static void x86emuOp_jump_near_NZ(u8 X86EMU_UNUSED(op1))
-{
- s8 offset;
- u16 target;
-
- /* jump to byte offset if zero flag is clear. */
- START_OF_INSTR();
- DECODE_PRINTF("JNZ\t");
- offset = (s8)fetch_byte_imm();
- target = (u16)(M.x86.R_IP + (s16)offset);
- DECODE_PRINTF2("%x\n", target);
- TRACE_AND_STEP();
- if (!ACCESS_FLAG(F_ZF))
- M.x86.R_IP = target;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x76
-****************************************************************************/
-static void x86emuOp_jump_near_BE(u8 X86EMU_UNUSED(op1))
-{
- s8 offset;
- u16 target;
-
- /* jump to byte offset if carry flag is set or if the zero
- flag is set. */
- START_OF_INSTR();
- DECODE_PRINTF("JBE\t");
- offset = (s8)fetch_byte_imm();
- target = (u16)(M.x86.R_IP + (s16)offset);
- DECODE_PRINTF2("%x\n", target);
- TRACE_AND_STEP();
- if (ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF))
- M.x86.R_IP = target;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x77
-****************************************************************************/
-static void x86emuOp_jump_near_NBE(u8 X86EMU_UNUSED(op1))
-{
- s8 offset;
- u16 target;
-
- /* jump to byte offset if carry flag is clear and if the zero
- flag is clear */
- START_OF_INSTR();
- DECODE_PRINTF("JNBE\t");
- offset = (s8)fetch_byte_imm();
- target = (u16)(M.x86.R_IP + (s16)offset);
- DECODE_PRINTF2("%x\n", target);
- TRACE_AND_STEP();
- if (!(ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF)))
- M.x86.R_IP = target;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x78
-****************************************************************************/
-static void x86emuOp_jump_near_S(u8 X86EMU_UNUSED(op1))
-{
- s8 offset;
- u16 target;
-
- /* jump to byte offset if sign flag is set */
- START_OF_INSTR();
- DECODE_PRINTF("JS\t");
- offset = (s8)fetch_byte_imm();
- target = (u16)(M.x86.R_IP + (s16)offset);
- DECODE_PRINTF2("%x\n", target);
- TRACE_AND_STEP();
- if (ACCESS_FLAG(F_SF))
- M.x86.R_IP = target;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x79
-****************************************************************************/
-static void x86emuOp_jump_near_NS(u8 X86EMU_UNUSED(op1))
-{
- s8 offset;
- u16 target;
-
- /* jump to byte offset if sign flag is clear */
- START_OF_INSTR();
- DECODE_PRINTF("JNS\t");
- offset = (s8)fetch_byte_imm();
- target = (u16)(M.x86.R_IP + (s16)offset);
- DECODE_PRINTF2("%x\n", target);
- TRACE_AND_STEP();
- if (!ACCESS_FLAG(F_SF))
- M.x86.R_IP = target;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x7a
-****************************************************************************/
-static void x86emuOp_jump_near_P(u8 X86EMU_UNUSED(op1))
-{
- s8 offset;
- u16 target;
-
- /* jump to byte offset if parity flag is set (even parity) */
- START_OF_INSTR();
- DECODE_PRINTF("JP\t");
- offset = (s8)fetch_byte_imm();
- target = (u16)(M.x86.R_IP + (s16)offset);
- DECODE_PRINTF2("%x\n", target);
- TRACE_AND_STEP();
- if (ACCESS_FLAG(F_PF))
- M.x86.R_IP = target;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x7b
-****************************************************************************/
-static void x86emuOp_jump_near_NP(u8 X86EMU_UNUSED(op1))
-{
- s8 offset;
- u16 target;
-
- /* jump to byte offset if parity flag is clear (odd parity) */
- START_OF_INSTR();
- DECODE_PRINTF("JNP\t");
- offset = (s8)fetch_byte_imm();
- target = (u16)(M.x86.R_IP + (s16)offset);
- DECODE_PRINTF2("%x\n", target);
- TRACE_AND_STEP();
- if (!ACCESS_FLAG(F_PF))
- M.x86.R_IP = target;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x7c
-****************************************************************************/
-static void x86emuOp_jump_near_L(u8 X86EMU_UNUSED(op1))
-{
- s8 offset;
- u16 target;
- int sf, of;
-
- /* jump to byte offset if sign flag not equal to overflow flag. */
- START_OF_INSTR();
- DECODE_PRINTF("JL\t");
- offset = (s8)fetch_byte_imm();
- target = (u16)(M.x86.R_IP + (s16)offset);
- DECODE_PRINTF2("%x\n", target);
- TRACE_AND_STEP();
- sf = ACCESS_FLAG(F_SF) != 0;
- of = ACCESS_FLAG(F_OF) != 0;
- if (sf ^ of)
- M.x86.R_IP = target;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x7d
-****************************************************************************/
-static void x86emuOp_jump_near_NL(u8 X86EMU_UNUSED(op1))
-{
- s8 offset;
- u16 target;
- int sf, of;
-
- /* jump to byte offset if sign flag not equal to overflow flag. */
- START_OF_INSTR();
- DECODE_PRINTF("JNL\t");
- offset = (s8)fetch_byte_imm();
- target = (u16)(M.x86.R_IP + (s16)offset);
- DECODE_PRINTF2("%x\n", target);
- TRACE_AND_STEP();
- sf = ACCESS_FLAG(F_SF) != 0;
- of = ACCESS_FLAG(F_OF) != 0;
- /* note: inverse of above, but using == instead of xor. */
- if (sf == of)
- M.x86.R_IP = target;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x7e
-****************************************************************************/
-static void x86emuOp_jump_near_LE(u8 X86EMU_UNUSED(op1))
-{
- s8 offset;
- u16 target;
- int sf, of;
-
- /* jump to byte offset if sign flag not equal to overflow flag
- or the zero flag is set */
- START_OF_INSTR();
- DECODE_PRINTF("JLE\t");
- offset = (s8)fetch_byte_imm();
- target = (u16)(M.x86.R_IP + (s16)offset);
- DECODE_PRINTF2("%x\n", target);
- TRACE_AND_STEP();
- sf = ACCESS_FLAG(F_SF) != 0;
- of = ACCESS_FLAG(F_OF) != 0;
- if ((sf ^ of) || ACCESS_FLAG(F_ZF))
- M.x86.R_IP = target;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x7f
-****************************************************************************/
-static void x86emuOp_jump_near_NLE(u8 X86EMU_UNUSED(op1))
-{
- s8 offset;
- u16 target;
- int sf, of;
-
- /* jump to byte offset if sign flag equal to overflow flag.
- and the zero flag is clear */
- START_OF_INSTR();
- DECODE_PRINTF("JNLE\t");
- offset = (s8)fetch_byte_imm();
- target = (u16)(M.x86.R_IP + (s16)offset);
- DECODE_PRINTF2("%x\n", target);
- TRACE_AND_STEP();
- sf = ACCESS_FLAG(F_SF) != 0;
- of = ACCESS_FLAG(F_OF) != 0;
- if ((sf == of) && !ACCESS_FLAG(F_ZF))
- M.x86.R_IP = target;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-static u8 (*opc80_byte_operation[])(u8 d, u8 s) =
-{
- add_byte, /* 00 */
- or_byte, /* 01 */
- adc_byte, /* 02 */
- sbb_byte, /* 03 */
- and_byte, /* 04 */
- sub_byte, /* 05 */
- xor_byte, /* 06 */
- cmp_byte, /* 07 */
-};
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x80
-****************************************************************************/
-static void x86emuOp_opc80_byte_RM_IMM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg;
- uint destoffset;
- u8 imm;
- u8 destval;
-
- /*
- * Weirdo special case instruction format. Part of the opcode
- * held below in "RH". Doubly nested case would result, except
- * that the decoded instruction
- */
- START_OF_INSTR();
- FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
- if (DEBUG_DECODE()) {
- /* XXX DECODE_PRINTF may be changed to something more
- general, so that it is important to leave the strings
- in the same format, even though the result is that the
- above test is done twice. */
-
- switch (rh) {
- case 0:
- DECODE_PRINTF("ADD\t");
- break;
- case 1:
- DECODE_PRINTF("OR\t");
- break;
- case 2:
- DECODE_PRINTF("ADC\t");
- break;
- case 3:
- DECODE_PRINTF("SBB\t");
- break;
- case 4:
- DECODE_PRINTF("AND\t");
- break;
- case 5:
- DECODE_PRINTF("SUB\t");
- break;
- case 6:
- DECODE_PRINTF("XOR\t");
- break;
- case 7:
- DECODE_PRINTF("CMP\t");
- break;
- }
- }
-#endif
- /* know operation, decode the mod byte to find the addressing
- mode. */
- switch (mod) {
- case 0:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- imm = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc80_byte_operation[rh]) (destval, imm);
- if (rh != 7)
- store_data_byte(destoffset, destval);
- break;
- case 1:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- imm = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc80_byte_operation[rh]) (destval, imm);
- if (rh != 7)
- store_data_byte(destoffset, destval);
- break;
- case 2:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- imm = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc80_byte_operation[rh]) (destval, imm);
- if (rh != 7)
- store_data_byte(destoffset, destval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF(",");
- imm = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc80_byte_operation[rh]) (*destreg, imm);
- if (rh != 7)
- *destreg = destval;
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-static u16 (*opc81_word_operation[])(u16 d, u16 s) =
-{
- add_word, /*00 */
- or_word, /*01 */
- adc_word, /*02 */
- sbb_word, /*03 */
- and_word, /*04 */
- sub_word, /*05 */
- xor_word, /*06 */
- cmp_word, /*07 */
-};
-
-static u32 (*opc81_long_operation[])(u32 d, u32 s) =
-{
- add_long, /*00 */
- or_long, /*01 */
- adc_long, /*02 */
- sbb_long, /*03 */
- and_long, /*04 */
- sub_long, /*05 */
- xor_long, /*06 */
- cmp_long, /*07 */
-};
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x81
-****************************************************************************/
-static void x86emuOp_opc81_word_RM_IMM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
-
- /*
- * Weirdo special case instruction format. Part of the opcode
- * held below in "RH". Doubly nested case would result, except
- * that the decoded instruction
- */
- START_OF_INSTR();
- FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
- if (DEBUG_DECODE()) {
- /* XXX DECODE_PRINTF may be changed to something more
- general, so that it is important to leave the strings
- in the same format, even though the result is that the
- above test is done twice. */
-
- switch (rh) {
- case 0:
- DECODE_PRINTF("ADD\t");
- break;
- case 1:
- DECODE_PRINTF("OR\t");
- break;
- case 2:
- DECODE_PRINTF("ADC\t");
- break;
- case 3:
- DECODE_PRINTF("SBB\t");
- break;
- case 4:
- DECODE_PRINTF("AND\t");
- break;
- case 5:
- DECODE_PRINTF("SUB\t");
- break;
- case 6:
- DECODE_PRINTF("XOR\t");
- break;
- case 7:
- DECODE_PRINTF("CMP\t");
- break;
- }
- }
-#endif
- /*
- * Know operation, decode the mod byte to find the addressing
- * mode.
- */
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval,imm;
-
- DECODE_PRINTF("DWORD PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- imm = fetch_long_imm();
- DECODE_PRINTF2("%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc81_long_operation[rh]) (destval, imm);
- if (rh != 7)
- store_data_long(destoffset, destval);
- } else {
- u16 destval,imm;
-
- DECODE_PRINTF("WORD PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- imm = fetch_word_imm();
- DECODE_PRINTF2("%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc81_word_operation[rh]) (destval, imm);
- if (rh != 7)
- store_data_word(destoffset, destval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval,imm;
-
- DECODE_PRINTF("DWORD PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- imm = fetch_long_imm();
- DECODE_PRINTF2("%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc81_long_operation[rh]) (destval, imm);
- if (rh != 7)
- store_data_long(destoffset, destval);
- } else {
- u16 destval,imm;
-
- DECODE_PRINTF("WORD PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- imm = fetch_word_imm();
- DECODE_PRINTF2("%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc81_word_operation[rh]) (destval, imm);
- if (rh != 7)
- store_data_word(destoffset, destval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval,imm;
-
- DECODE_PRINTF("DWORD PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- imm = fetch_long_imm();
- DECODE_PRINTF2("%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc81_long_operation[rh]) (destval, imm);
- if (rh != 7)
- store_data_long(destoffset, destval);
- } else {
- u16 destval,imm;
-
- DECODE_PRINTF("WORD PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- imm = fetch_word_imm();
- DECODE_PRINTF2("%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc81_word_operation[rh]) (destval, imm);
- if (rh != 7)
- store_data_word(destoffset, destval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 destval,imm;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF(",");
- imm = fetch_long_imm();
- DECODE_PRINTF2("%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc81_long_operation[rh]) (*destreg, imm);
- if (rh != 7)
- *destreg = destval;
- } else {
- u16 *destreg;
- u16 destval,imm;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",");
- imm = fetch_word_imm();
- DECODE_PRINTF2("%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc81_word_operation[rh]) (*destreg, imm);
- if (rh != 7)
- *destreg = destval;
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-static u8 (*opc82_byte_operation[])(u8 s, u8 d) =
-{
- add_byte, /*00 */
- or_byte, /*01 *//*YYY UNUSED ???? */
- adc_byte, /*02 */
- sbb_byte, /*03 */
- and_byte, /*04 *//*YYY UNUSED ???? */
- sub_byte, /*05 */
- xor_byte, /*06 *//*YYY UNUSED ???? */
- cmp_byte, /*07 */
-};
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x82
-****************************************************************************/
-static void x86emuOp_opc82_byte_RM_IMM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg;
- uint destoffset;
- u8 imm;
- u8 destval;
-
- /*
- * Weirdo special case instruction format. Part of the opcode
- * held below in "RH". Doubly nested case would result, except
- * that the decoded instruction Similar to opcode 81, except that
- * the immediate byte is sign extended to a word length.
- */
- START_OF_INSTR();
- FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
- if (DEBUG_DECODE()) {
- /* XXX DECODE_PRINTF may be changed to something more
- general, so that it is important to leave the strings
- in the same format, even though the result is that the
- above test is done twice. */
- switch (rh) {
- case 0:
- DECODE_PRINTF("ADD\t");
- break;
- case 1:
- DECODE_PRINTF("OR\t");
- break;
- case 2:
- DECODE_PRINTF("ADC\t");
- break;
- case 3:
- DECODE_PRINTF("SBB\t");
- break;
- case 4:
- DECODE_PRINTF("AND\t");
- break;
- case 5:
- DECODE_PRINTF("SUB\t");
- break;
- case 6:
- DECODE_PRINTF("XOR\t");
- break;
- case 7:
- DECODE_PRINTF("CMP\t");
- break;
- }
- }
-#endif
- /* know operation, decode the mod byte to find the addressing
- mode. */
- switch (mod) {
- case 0:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm00_address(rl);
- destval = fetch_data_byte(destoffset);
- imm = fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc82_byte_operation[rh]) (destval, imm);
- if (rh != 7)
- store_data_byte(destoffset, destval);
- break;
- case 1:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm01_address(rl);
- destval = fetch_data_byte(destoffset);
- imm = fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc82_byte_operation[rh]) (destval, imm);
- if (rh != 7)
- store_data_byte(destoffset, destval);
- break;
- case 2:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm10_address(rl);
- destval = fetch_data_byte(destoffset);
- imm = fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc82_byte_operation[rh]) (destval, imm);
- if (rh != 7)
- store_data_byte(destoffset, destval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- imm = fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc82_byte_operation[rh]) (*destreg, imm);
- if (rh != 7)
- *destreg = destval;
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-static u16 (*opc83_word_operation[])(u16 s, u16 d) =
-{
- add_word, /*00 */
- or_word, /*01 *//*YYY UNUSED ???? */
- adc_word, /*02 */
- sbb_word, /*03 */
- and_word, /*04 *//*YYY UNUSED ???? */
- sub_word, /*05 */
- xor_word, /*06 *//*YYY UNUSED ???? */
- cmp_word, /*07 */
-};
-
-static u32 (*opc83_long_operation[])(u32 s, u32 d) =
-{
- add_long, /*00 */
- or_long, /*01 *//*YYY UNUSED ???? */
- adc_long, /*02 */
- sbb_long, /*03 */
- and_long, /*04 *//*YYY UNUSED ???? */
- sub_long, /*05 */
- xor_long, /*06 *//*YYY UNUSED ???? */
- cmp_long, /*07 */
-};
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x83
-****************************************************************************/
-static void x86emuOp_opc83_word_RM_IMM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
-
- /*
- * Weirdo special case instruction format. Part of the opcode
- * held below in "RH". Doubly nested case would result, except
- * that the decoded instruction Similar to opcode 81, except that
- * the immediate byte is sign extended to a word length.
- */
- START_OF_INSTR();
- FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
- if (DEBUG_DECODE()) {
- /* XXX DECODE_PRINTF may be changed to something more
- general, so that it is important to leave the strings
- in the same format, even though the result is that the
- above test is done twice. */
- switch (rh) {
- case 0:
- DECODE_PRINTF("ADD\t");
- break;
- case 1:
- DECODE_PRINTF("OR\t");
- break;
- case 2:
- DECODE_PRINTF("ADC\t");
- break;
- case 3:
- DECODE_PRINTF("SBB\t");
- break;
- case 4:
- DECODE_PRINTF("AND\t");
- break;
- case 5:
- DECODE_PRINTF("SUB\t");
- break;
- case 6:
- DECODE_PRINTF("XOR\t");
- break;
- case 7:
- DECODE_PRINTF("CMP\t");
- break;
- }
- }
-#endif
- /* know operation, decode the mod byte to find the addressing
- mode. */
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval,imm;
-
- DECODE_PRINTF("DWORD PTR ");
- destoffset = decode_rm00_address(rl);
- destval = fetch_data_long(destoffset);
- imm = (s8) fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc83_long_operation[rh]) (destval, imm);
- if (rh != 7)
- store_data_long(destoffset, destval);
- } else {
- u16 destval,imm;
-
- DECODE_PRINTF("WORD PTR ");
- destoffset = decode_rm00_address(rl);
- destval = fetch_data_word(destoffset);
- imm = (s8) fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc83_word_operation[rh]) (destval, imm);
- if (rh != 7)
- store_data_word(destoffset, destval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval,imm;
-
- DECODE_PRINTF("DWORD PTR ");
- destoffset = decode_rm01_address(rl);
- destval = fetch_data_long(destoffset);
- imm = (s8) fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc83_long_operation[rh]) (destval, imm);
- if (rh != 7)
- store_data_long(destoffset, destval);
- } else {
- u16 destval,imm;
-
- DECODE_PRINTF("WORD PTR ");
- destoffset = decode_rm01_address(rl);
- destval = fetch_data_word(destoffset);
- imm = (s8) fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc83_word_operation[rh]) (destval, imm);
- if (rh != 7)
- store_data_word(destoffset, destval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval,imm;
-
- DECODE_PRINTF("DWORD PTR ");
- destoffset = decode_rm10_address(rl);
- destval = fetch_data_long(destoffset);
- imm = (s8) fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc83_long_operation[rh]) (destval, imm);
- if (rh != 7)
- store_data_long(destoffset, destval);
- } else {
- u16 destval,imm;
-
- DECODE_PRINTF("WORD PTR ");
- destoffset = decode_rm10_address(rl);
- destval = fetch_data_word(destoffset);
- imm = (s8) fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc83_word_operation[rh]) (destval, imm);
- if (rh != 7)
- store_data_word(destoffset, destval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 destval,imm;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- imm = (s8) fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc83_long_operation[rh]) (*destreg, imm);
- if (rh != 7)
- *destreg = destval;
- } else {
- u16 *destreg;
- u16 destval,imm;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- imm = (s8) fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", imm);
- TRACE_AND_STEP();
- destval = (*opc83_word_operation[rh]) (*destreg, imm);
- if (rh != 7)
- *destreg = destval;
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x84
-****************************************************************************/
-static void x86emuOp_test_byte_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg, *srcreg;
- uint destoffset;
- u8 destval;
-
- START_OF_INSTR();
- DECODE_PRINTF("TEST\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- test_byte(destval, *srcreg);
- break;
- case 1:
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- test_byte(destval, *srcreg);
- break;
- case 2:
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- test_byte(destval, *srcreg);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- test_byte(*destreg, *srcreg);
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x85
-****************************************************************************/
-static void x86emuOp_test_word_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("TEST\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- test_long(destval, *srcreg);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- test_word(destval, *srcreg);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- test_long(destval, *srcreg);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- test_word(destval, *srcreg);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *srcreg;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- test_long(destval, *srcreg);
- } else {
- u16 destval;
- u16 *srcreg;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- test_word(destval, *srcreg);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- test_long(*destreg, *srcreg);
- } else {
- u16 *destreg,*srcreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- test_word(*destreg, *srcreg);
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x86
-****************************************************************************/
-static void x86emuOp_xchg_byte_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg, *srcreg;
- uint destoffset;
- u8 destval;
- u8 tmp;
-
- START_OF_INSTR();
- DECODE_PRINTF("XCHG\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- tmp = *srcreg;
- *srcreg = destval;
- destval = tmp;
- store_data_byte(destoffset, destval);
- break;
- case 1:
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- tmp = *srcreg;
- *srcreg = destval;
- destval = tmp;
- store_data_byte(destoffset, destval);
- break;
- case 2:
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_byte(destoffset);
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- tmp = *srcreg;
- *srcreg = destval;
- destval = tmp;
- store_data_byte(destoffset, destval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- tmp = *srcreg;
- *srcreg = *destreg;
- *destreg = tmp;
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x87
-****************************************************************************/
-static void x86emuOp_xchg_word_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("XCHG\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *srcreg;
- u32 destval,tmp;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- tmp = *srcreg;
- *srcreg = destval;
- destval = tmp;
- store_data_long(destoffset, destval);
- } else {
- u16 *srcreg;
- u16 destval,tmp;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- tmp = *srcreg;
- *srcreg = destval;
- destval = tmp;
- store_data_word(destoffset, destval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *srcreg;
- u32 destval,tmp;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- tmp = *srcreg;
- *srcreg = destval;
- destval = tmp;
- store_data_long(destoffset, destval);
- } else {
- u16 *srcreg;
- u16 destval,tmp;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- tmp = *srcreg;
- *srcreg = destval;
- destval = tmp;
- store_data_word(destoffset, destval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *srcreg;
- u32 destval,tmp;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_long(destoffset);
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- tmp = *srcreg;
- *srcreg = destval;
- destval = tmp;
- store_data_long(destoffset, destval);
- } else {
- u16 *srcreg;
- u16 destval,tmp;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- destval = fetch_data_word(destoffset);
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- tmp = *srcreg;
- *srcreg = destval;
- destval = tmp;
- store_data_word(destoffset, destval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
- u32 tmp;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- tmp = *srcreg;
- *srcreg = *destreg;
- *destreg = tmp;
- } else {
- u16 *destreg,*srcreg;
- u16 tmp;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- tmp = *srcreg;
- *srcreg = *destreg;
- *destreg = tmp;
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x88
-****************************************************************************/
-static void x86emuOp_mov_byte_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg, *srcreg;
- uint destoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("MOV\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- store_data_byte(destoffset, *srcreg);
- break;
- case 1:
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- store_data_byte(destoffset, *srcreg);
- break;
- case 2:
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- store_data_byte(destoffset, *srcreg);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = *srcreg;
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x89
-****************************************************************************/
-static void x86emuOp_mov_word_RM_R(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u32 destoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("MOV\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *srcreg;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- store_data_long(destoffset, *srcreg);
- } else {
- u16 *srcreg;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- store_data_word(destoffset, *srcreg);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *srcreg;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- store_data_long(destoffset, *srcreg);
- } else {
- u16 *srcreg;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- store_data_word(destoffset, *srcreg);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *srcreg;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- store_data_long(destoffset, *srcreg);
- } else {
- u16 *srcreg;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- store_data_word(destoffset, *srcreg);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = *srcreg;
- } else {
- u16 *destreg,*srcreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = *srcreg;
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x8a
-****************************************************************************/
-static void x86emuOp_mov_byte_R_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg, *srcreg;
- uint srcoffset;
- u8 srcval;
-
- START_OF_INSTR();
- DECODE_PRINTF("MOV\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = srcval;
- break;
- case 1:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = srcval;
- break;
- case 2:
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_byte(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = srcval;
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = *srcreg;
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x8b
-****************************************************************************/
-static void x86emuOp_mov_word_R_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint srcoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("MOV\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = srcval;
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = srcval;
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = srcval;
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = srcval;
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_long(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = srcval;
- } else {
- u16 *destreg;
- u16 srcval;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = srcval;
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg, *srcreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = *srcreg;
- } else {
- u16 *destreg, *srcreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = *srcreg;
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x8c
-****************************************************************************/
-static void x86emuOp_mov_word_RM_SR(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u16 *destreg, *srcreg;
- uint destoffset;
- u16 destval;
-
- START_OF_INSTR();
- DECODE_PRINTF("MOV\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- srcreg = decode_rm_seg_register(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = *srcreg;
- store_data_word(destoffset, destval);
- break;
- case 1:
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- srcreg = decode_rm_seg_register(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = *srcreg;
- store_data_word(destoffset, destval);
- break;
- case 2:
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- srcreg = decode_rm_seg_register(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = *srcreg;
- store_data_word(destoffset, destval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",");
- srcreg = decode_rm_seg_register(rh);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = *srcreg;
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x8d
-****************************************************************************/
-static void x86emuOp_lea_word_R_M(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("LEA\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_ADDR) {
- u32 *srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *srcreg = (u32)destoffset;
- } else {
- u16 *srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *srcreg = (u16)destoffset;
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_ADDR) {
- u32 *srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *srcreg = (u32)destoffset;
- } else {
- u16 *srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *srcreg = (u16)destoffset;
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_ADDR) {
- u32 *srcreg = DECODE_RM_LONG_REGISTER(rh);
- DECODE_PRINTF(",");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *srcreg = (u32)destoffset;
- } else {
- u16 *srcreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *srcreg = (u16)destoffset;
- }
- break;
- case 3: /* register to register */
- /* undefined. Do nothing. */
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x8e
-****************************************************************************/
-static void x86emuOp_mov_word_SR_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u16 *destreg, *srcreg;
- uint srcoffset;
- u16 srcval;
-
- START_OF_INSTR();
- DECODE_PRINTF("MOV\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- destreg = decode_rm_seg_register(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = srcval;
- break;
- case 1:
- destreg = decode_rm_seg_register(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = srcval;
- break;
- case 2:
- destreg = decode_rm_seg_register(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- srcval = fetch_data_word(srcoffset);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = srcval;
- break;
- case 3: /* register to register */
- destreg = decode_rm_seg_register(rh);
- DECODE_PRINTF(",");
- srcreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = *srcreg;
- break;
- }
- /*
- * Clean up, and reset all the R_xSP pointers to the correct
- * locations. This is about 3x too much overhead (doing all the
- * segreg ptrs when only one is needed, but this instruction
- * *cannot* be that common, and this isn't too much work anyway.
- */
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x8f
-****************************************************************************/
-static void x86emuOp_pop_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("POP\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- if (rh != 0) {
- DECODE_PRINTF("ILLEGAL DECODE OF OPCODE 8F\n");
- HALT_SYS();
- }
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = pop_long();
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = pop_word();
- store_data_word(destoffset, destval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = pop_long();
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = pop_word();
- store_data_word(destoffset, destval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = pop_long();
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- destval = pop_word();
- store_data_word(destoffset, destval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = pop_long();
- } else {
- u16 *destreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = pop_word();
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x90
-****************************************************************************/
-static void x86emuOp_nop(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("NOP\n");
- TRACE_AND_STEP();
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x91
-****************************************************************************/
-static void x86emuOp_xchg_word_AX_CX(u8 X86EMU_UNUSED(op1))
-{
- u32 tmp;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("XCHG\tEAX,ECX\n");
- } else {
- DECODE_PRINTF("XCHG\tAX,CX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- tmp = M.x86.R_EAX;
- M.x86.R_EAX = M.x86.R_ECX;
- M.x86.R_ECX = tmp;
- } else {
- tmp = M.x86.R_AX;
- M.x86.R_AX = M.x86.R_CX;
- M.x86.R_CX = (u16)tmp;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x92
-****************************************************************************/
-static void x86emuOp_xchg_word_AX_DX(u8 X86EMU_UNUSED(op1))
-{
- u32 tmp;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("XCHG\tEAX,EDX\n");
- } else {
- DECODE_PRINTF("XCHG\tAX,DX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- tmp = M.x86.R_EAX;
- M.x86.R_EAX = M.x86.R_EDX;
- M.x86.R_EDX = tmp;
- } else {
- tmp = M.x86.R_AX;
- M.x86.R_AX = M.x86.R_DX;
- M.x86.R_DX = (u16)tmp;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x93
-****************************************************************************/
-static void x86emuOp_xchg_word_AX_BX(u8 X86EMU_UNUSED(op1))
-{
- u32 tmp;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("XCHG\tEAX,EBX\n");
- } else {
- DECODE_PRINTF("XCHG\tAX,BX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- tmp = M.x86.R_EAX;
- M.x86.R_EAX = M.x86.R_EBX;
- M.x86.R_EBX = tmp;
- } else {
- tmp = M.x86.R_AX;
- M.x86.R_AX = M.x86.R_BX;
- M.x86.R_BX = (u16)tmp;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x94
-****************************************************************************/
-static void x86emuOp_xchg_word_AX_SP(u8 X86EMU_UNUSED(op1))
-{
- u32 tmp;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("XCHG\tEAX,ESP\n");
- } else {
- DECODE_PRINTF("XCHG\tAX,SP\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- tmp = M.x86.R_EAX;
- M.x86.R_EAX = M.x86.R_ESP;
- M.x86.R_ESP = tmp;
- } else {
- tmp = M.x86.R_AX;
- M.x86.R_AX = M.x86.R_SP;
- M.x86.R_SP = (u16)tmp;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x95
-****************************************************************************/
-static void x86emuOp_xchg_word_AX_BP(u8 X86EMU_UNUSED(op1))
-{
- u32 tmp;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("XCHG\tEAX,EBP\n");
- } else {
- DECODE_PRINTF("XCHG\tAX,BP\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- tmp = M.x86.R_EAX;
- M.x86.R_EAX = M.x86.R_EBP;
- M.x86.R_EBP = tmp;
- } else {
- tmp = M.x86.R_AX;
- M.x86.R_AX = M.x86.R_BP;
- M.x86.R_BP = (u16)tmp;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x96
-****************************************************************************/
-static void x86emuOp_xchg_word_AX_SI(u8 X86EMU_UNUSED(op1))
-{
- u32 tmp;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("XCHG\tEAX,ESI\n");
- } else {
- DECODE_PRINTF("XCHG\tAX,SI\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- tmp = M.x86.R_EAX;
- M.x86.R_EAX = M.x86.R_ESI;
- M.x86.R_ESI = tmp;
- } else {
- tmp = M.x86.R_AX;
- M.x86.R_AX = M.x86.R_SI;
- M.x86.R_SI = (u16)tmp;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x97
-****************************************************************************/
-static void x86emuOp_xchg_word_AX_DI(u8 X86EMU_UNUSED(op1))
-{
- u32 tmp;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("XCHG\tEAX,EDI\n");
- } else {
- DECODE_PRINTF("XCHG\tAX,DI\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- tmp = M.x86.R_EAX;
- M.x86.R_EAX = M.x86.R_EDI;
- M.x86.R_EDI = tmp;
- } else {
- tmp = M.x86.R_AX;
- M.x86.R_AX = M.x86.R_DI;
- M.x86.R_DI = (u16)tmp;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x98
-****************************************************************************/
-static void x86emuOp_cbw(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("CWDE\n");
- } else {
- DECODE_PRINTF("CBW\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- if (M.x86.R_AX & 0x8000) {
- M.x86.R_EAX |= 0xffff0000;
- } else {
- M.x86.R_EAX &= 0x0000ffff;
- }
- } else {
- if (M.x86.R_AL & 0x80) {
- M.x86.R_AH = 0xff;
- } else {
- M.x86.R_AH = 0x0;
- }
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x99
-****************************************************************************/
-static void x86emuOp_cwd(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("CDQ\n");
- } else {
- DECODE_PRINTF("CWD\n");
- }
- DECODE_PRINTF("CWD\n");
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- if (M.x86.R_EAX & 0x80000000) {
- M.x86.R_EDX = 0xffffffff;
- } else {
- M.x86.R_EDX = 0x0;
- }
- } else {
- if (M.x86.R_AX & 0x8000) {
- M.x86.R_DX = 0xffff;
- } else {
- M.x86.R_DX = 0x0;
- }
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x9a
-****************************************************************************/
-static void x86emuOp_call_far_IMM(u8 X86EMU_UNUSED(op1))
-{
- u32 farseg, faroff;
-
- START_OF_INSTR();
- DECODE_PRINTF("CALL\t");
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- faroff = fetch_long_imm();
- farseg = fetch_word_imm();
- } else {
- faroff = fetch_word_imm();
- farseg = fetch_word_imm();
- }
- DECODE_PRINTF2("%04x:", farseg);
- DECODE_PRINTF2("%04x\n", faroff);
- CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, farseg, faroff, "FAR ");
-
- /* XXX
- *
- * Hooked interrupt vectors calling into our "BIOS" will cause
- * problems unless all intersegment stuff is checked for BIOS
- * access. Check needed here. For moment, let it alone.
- */
- TRACE_AND_STEP();
- push_word(M.x86.R_CS);
- M.x86.R_CS = farseg;
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- push_long(M.x86.R_EIP);
- } else {
- push_word(M.x86.R_IP);
- }
- M.x86.R_EIP = faroff & 0xffff;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x9b
-****************************************************************************/
-static void x86emuOp_wait(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("WAIT");
- TRACE_AND_STEP();
- /* NADA. */
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x9c
-****************************************************************************/
-static void x86emuOp_pushf_word(u8 X86EMU_UNUSED(op1))
-{
- u32 flags;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("PUSHFD\n");
- } else {
- DECODE_PRINTF("PUSHF\n");
- }
- TRACE_AND_STEP();
-
- /* clear out *all* bits not representing flags, and turn on real bits */
- flags = (M.x86.R_EFLG & F_MSK) | F_ALWAYS_ON;
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- push_long(flags);
- } else {
- push_word((u16)flags);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x9d
-****************************************************************************/
-static void x86emuOp_popf_word(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("POPFD\n");
- } else {
- DECODE_PRINTF("POPF\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EFLG = pop_long();
- } else {
- M.x86.R_FLG = pop_word();
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x9e
-****************************************************************************/
-static void x86emuOp_sahf(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("SAHF\n");
- TRACE_AND_STEP();
- /* clear the lower bits of the flag register */
- M.x86.R_FLG &= 0xffffff00;
- /* or in the AH register into the flags register */
- M.x86.R_FLG |= M.x86.R_AH;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0x9f
-****************************************************************************/
-static void x86emuOp_lahf(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("LAHF\n");
- TRACE_AND_STEP();
- M.x86.R_AH = (u8)(M.x86.R_FLG & 0xff);
- /*undocumented TC++ behavior??? Nope. It's documented, but
- you have too look real hard to notice it. */
- M.x86.R_AH |= 0x2;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xa0
-****************************************************************************/
-static void x86emuOp_mov_AL_M_IMM(u8 X86EMU_UNUSED(op1))
-{
- u16 offset;
-
- START_OF_INSTR();
- DECODE_PRINTF("MOV\tAL,");
- offset = fetch_word_imm();
- DECODE_PRINTF2("[%04x]\n", offset);
- TRACE_AND_STEP();
- M.x86.R_AL = fetch_data_byte(offset);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xa1
-****************************************************************************/
-static void x86emuOp_mov_AX_M_IMM(u8 X86EMU_UNUSED(op1))
-{
- u16 offset;
-
- START_OF_INSTR();
- offset = fetch_word_imm();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF2("MOV\tEAX,[%04x]\n", offset);
- } else {
- DECODE_PRINTF2("MOV\tAX,[%04x]\n", offset);
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EAX = fetch_data_long(offset);
- } else {
- M.x86.R_AX = fetch_data_word(offset);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xa2
-****************************************************************************/
-static void x86emuOp_mov_M_AL_IMM(u8 X86EMU_UNUSED(op1))
-{
- u16 offset;
-
- START_OF_INSTR();
- DECODE_PRINTF("MOV\t");
- offset = fetch_word_imm();
- DECODE_PRINTF2("[%04x],AL\n", offset);
- TRACE_AND_STEP();
- store_data_byte(offset, M.x86.R_AL);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xa3
-****************************************************************************/
-static void x86emuOp_mov_M_AX_IMM(u8 X86EMU_UNUSED(op1))
-{
- u16 offset;
-
- START_OF_INSTR();
- offset = fetch_word_imm();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF2("MOV\t[%04x],EAX\n", offset);
- } else {
- DECODE_PRINTF2("MOV\t[%04x],AX\n", offset);
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- store_data_long(offset, M.x86.R_EAX);
- } else {
- store_data_word(offset, M.x86.R_AX);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xa4
-****************************************************************************/
-static void x86emuOp_movs_byte(u8 X86EMU_UNUSED(op1))
-{
- u8 val;
- u32 count;
- int inc;
-
- START_OF_INSTR();
- DECODE_PRINTF("MOVS\tBYTE\n");
- if (ACCESS_FLAG(F_DF)) /* down */
- inc = -1;
- else
- inc = 1;
- TRACE_AND_STEP();
- count = 1;
- if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
- /* dont care whether REPE or REPNE */
- /* move them until CX is ZERO. */
- count = M.x86.R_CX;
- M.x86.R_CX = 0;
- M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
- }
- while (count--) {
- val = fetch_data_byte(M.x86.R_SI);
- store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, val);
- M.x86.R_SI += inc;
- M.x86.R_DI += inc;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xa5
-****************************************************************************/
-static void x86emuOp_movs_word(u8 X86EMU_UNUSED(op1))
-{
- u32 val;
- int inc;
- u32 count;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("MOVS\tDWORD\n");
- if (ACCESS_FLAG(F_DF)) /* down */
- inc = -4;
- else
- inc = 4;
- } else {
- DECODE_PRINTF("MOVS\tWORD\n");
- if (ACCESS_FLAG(F_DF)) /* down */
- inc = -2;
- else
- inc = 2;
- }
- TRACE_AND_STEP();
- count = 1;
- if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
- /* dont care whether REPE or REPNE */
- /* move them until CX is ZERO. */
- count = M.x86.R_CX;
- M.x86.R_CX = 0;
- M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
- }
- while (count--) {
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- val = fetch_data_long(M.x86.R_SI);
- store_data_long_abs(M.x86.R_ES, M.x86.R_DI, val);
- } else {
- val = fetch_data_word(M.x86.R_SI);
- store_data_word_abs(M.x86.R_ES, M.x86.R_DI, (u16)val);
- }
- M.x86.R_SI += inc;
- M.x86.R_DI += inc;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xa6
-****************************************************************************/
-static void x86emuOp_cmps_byte(u8 X86EMU_UNUSED(op1))
-{
- s8 val1, val2;
- int inc;
-
- START_OF_INSTR();
- DECODE_PRINTF("CMPS\tBYTE\n");
- TRACE_AND_STEP();
- if (ACCESS_FLAG(F_DF)) /* down */
- inc = -1;
- else
- inc = 1;
-
- if (M.x86.mode & SYSMODE_PREFIX_REPE) {
- /* REPE */
- /* move them until CX is ZERO. */
- while (M.x86.R_CX != 0) {
- val1 = fetch_data_byte(M.x86.R_SI);
- val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
- cmp_byte(val1, val2);
- M.x86.R_CX -= 1;
- M.x86.R_SI += inc;
- M.x86.R_DI += inc;
- if (ACCESS_FLAG(F_ZF) == 0)
- break;
- }
- M.x86.mode &= ~SYSMODE_PREFIX_REPE;
- } else if (M.x86.mode & SYSMODE_PREFIX_REPNE) {
- /* REPNE */
- /* move them until CX is ZERO. */
- while (M.x86.R_CX != 0) {
- val1 = fetch_data_byte(M.x86.R_SI);
- val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
- cmp_byte(val1, val2);
- M.x86.R_CX -= 1;
- M.x86.R_SI += inc;
- M.x86.R_DI += inc;
- if (ACCESS_FLAG(F_ZF))
- break; /* zero flag set means equal */
- }
- M.x86.mode &= ~SYSMODE_PREFIX_REPNE;
- } else {
- val1 = fetch_data_byte(M.x86.R_SI);
- val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
- cmp_byte(val1, val2);
- M.x86.R_SI += inc;
- M.x86.R_DI += inc;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xa7
-****************************************************************************/
-static void x86emuOp_cmps_word(u8 X86EMU_UNUSED(op1))
-{
- u32 val1,val2;
- int inc;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("CMPS\tDWORD\n");
- if (ACCESS_FLAG(F_DF)) /* down */
- inc = -4;
- else
- inc = 4;
- } else {
- DECODE_PRINTF("CMPS\tWORD\n");
- if (ACCESS_FLAG(F_DF)) /* down */
- inc = -2;
- else
- inc = 2;
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_REPE) {
- /* REPE */
- /* move them until CX is ZERO. */
- while (M.x86.R_CX != 0) {
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- val1 = fetch_data_long(M.x86.R_SI);
- val2 = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
- cmp_long(val1, val2);
- } else {
- val1 = fetch_data_word(M.x86.R_SI);
- val2 = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
- cmp_word((u16)val1, (u16)val2);
- }
- M.x86.R_CX -= 1;
- M.x86.R_SI += inc;
- M.x86.R_DI += inc;
- if (ACCESS_FLAG(F_ZF) == 0)
- break;
- }
- M.x86.mode &= ~SYSMODE_PREFIX_REPE;
- } else if (M.x86.mode & SYSMODE_PREFIX_REPNE) {
- /* REPNE */
- /* move them until CX is ZERO. */
- while (M.x86.R_CX != 0) {
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- val1 = fetch_data_long(M.x86.R_SI);
- val2 = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
- cmp_long(val1, val2);
- } else {
- val1 = fetch_data_word(M.x86.R_SI);
- val2 = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
- cmp_word((u16)val1, (u16)val2);
- }
- M.x86.R_CX -= 1;
- M.x86.R_SI += inc;
- M.x86.R_DI += inc;
- if (ACCESS_FLAG(F_ZF))
- break; /* zero flag set means equal */
- }
- M.x86.mode &= ~SYSMODE_PREFIX_REPNE;
- } else {
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- val1 = fetch_data_long(M.x86.R_SI);
- val2 = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
- cmp_long(val1, val2);
- } else {
- val1 = fetch_data_word(M.x86.R_SI);
- val2 = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
- cmp_word((u16)val1, (u16)val2);
- }
- M.x86.R_SI += inc;
- M.x86.R_DI += inc;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xa8
-****************************************************************************/
-static void x86emuOp_test_AL_IMM(u8 X86EMU_UNUSED(op1))
-{
- int imm;
-
- START_OF_INSTR();
- DECODE_PRINTF("TEST\tAL,");
- imm = fetch_byte_imm();
- DECODE_PRINTF2("%04x\n", imm);
- TRACE_AND_STEP();
- test_byte(M.x86.R_AL, (u8)imm);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xa9
-****************************************************************************/
-static void x86emuOp_test_AX_IMM(u8 X86EMU_UNUSED(op1))
-{
- u32 srcval;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("TEST\tEAX,");
- srcval = fetch_long_imm();
- } else {
- DECODE_PRINTF("TEST\tAX,");
- srcval = fetch_word_imm();
- }
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- test_long(M.x86.R_EAX, srcval);
- } else {
- test_word(M.x86.R_AX, (u16)srcval);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xaa
-****************************************************************************/
-static void x86emuOp_stos_byte(u8 X86EMU_UNUSED(op1))
-{
- int inc;
-
- START_OF_INSTR();
- DECODE_PRINTF("STOS\tBYTE\n");
- if (ACCESS_FLAG(F_DF)) /* down */
- inc = -1;
- else
- inc = 1;
- TRACE_AND_STEP();
- if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
- /* dont care whether REPE or REPNE */
- /* move them until CX is ZERO. */
- while (M.x86.R_CX != 0) {
- store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_AL);
- M.x86.R_CX -= 1;
- M.x86.R_DI += inc;
- }
- M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
- } else {
- store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_AL);
- M.x86.R_DI += inc;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xab
-****************************************************************************/
-static void x86emuOp_stos_word(u8 X86EMU_UNUSED(op1))
-{
- int inc;
- u32 count;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("STOS\tDWORD\n");
- if (ACCESS_FLAG(F_DF)) /* down */
- inc = -4;
- else
- inc = 4;
- } else {
- DECODE_PRINTF("STOS\tWORD\n");
- if (ACCESS_FLAG(F_DF)) /* down */
- inc = -2;
- else
- inc = 2;
- }
- TRACE_AND_STEP();
- count = 1;
- if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
- /* dont care whether REPE or REPNE */
- /* move them until CX is ZERO. */
- count = M.x86.R_CX;
- M.x86.R_CX = 0;
- M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
- }
- while (count--) {
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- store_data_long_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_EAX);
- } else {
- store_data_word_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_AX);
- }
- M.x86.R_DI += inc;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xac
-****************************************************************************/
-static void x86emuOp_lods_byte(u8 X86EMU_UNUSED(op1))
-{
- int inc;
-
- START_OF_INSTR();
- DECODE_PRINTF("LODS\tBYTE\n");
- TRACE_AND_STEP();
- if (ACCESS_FLAG(F_DF)) /* down */
- inc = -1;
- else
- inc = 1;
- if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
- /* dont care whether REPE or REPNE */
- /* move them until CX is ZERO. */
- while (M.x86.R_CX != 0) {
- M.x86.R_AL = fetch_data_byte(M.x86.R_SI);
- M.x86.R_CX -= 1;
- M.x86.R_SI += inc;
- }
- M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
- } else {
- M.x86.R_AL = fetch_data_byte(M.x86.R_SI);
- M.x86.R_SI += inc;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xad
-****************************************************************************/
-static void x86emuOp_lods_word(u8 X86EMU_UNUSED(op1))
-{
- int inc;
- u32 count;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("LODS\tDWORD\n");
- if (ACCESS_FLAG(F_DF)) /* down */
- inc = -4;
- else
- inc = 4;
- } else {
- DECODE_PRINTF("LODS\tWORD\n");
- if (ACCESS_FLAG(F_DF)) /* down */
- inc = -2;
- else
- inc = 2;
- }
- TRACE_AND_STEP();
- count = 1;
- if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
- /* dont care whether REPE or REPNE */
- /* move them until CX is ZERO. */
- count = M.x86.R_CX;
- M.x86.R_CX = 0;
- M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
- }
- while (count--) {
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EAX = fetch_data_long(M.x86.R_SI);
- } else {
- M.x86.R_AX = fetch_data_word(M.x86.R_SI);
- }
- M.x86.R_SI += inc;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xae
-****************************************************************************/
-static void x86emuOp_scas_byte(u8 X86EMU_UNUSED(op1))
-{
- s8 val2;
- int inc;
-
- START_OF_INSTR();
- DECODE_PRINTF("SCAS\tBYTE\n");
- TRACE_AND_STEP();
- if (ACCESS_FLAG(F_DF)) /* down */
- inc = -1;
- else
- inc = 1;
- if (M.x86.mode & SYSMODE_PREFIX_REPE) {
- /* REPE */
- /* move them until CX is ZERO. */
- while (M.x86.R_CX != 0) {
- val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
- cmp_byte(M.x86.R_AL, val2);
- M.x86.R_CX -= 1;
- M.x86.R_DI += inc;
- if (ACCESS_FLAG(F_ZF) == 0)
- break;
- }
- M.x86.mode &= ~SYSMODE_PREFIX_REPE;
- } else if (M.x86.mode & SYSMODE_PREFIX_REPNE) {
- /* REPNE */
- /* move them until CX is ZERO. */
- while (M.x86.R_CX != 0) {
- val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
- cmp_byte(M.x86.R_AL, val2);
- M.x86.R_CX -= 1;
- M.x86.R_DI += inc;
- if (ACCESS_FLAG(F_ZF))
- break; /* zero flag set means equal */
- }
- M.x86.mode &= ~SYSMODE_PREFIX_REPNE;
- } else {
- val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
- cmp_byte(M.x86.R_AL, val2);
- M.x86.R_DI += inc;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xaf
-****************************************************************************/
-static void x86emuOp_scas_word(u8 X86EMU_UNUSED(op1))
-{
- int inc;
- u32 val;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("SCAS\tDWORD\n");
- if (ACCESS_FLAG(F_DF)) /* down */
- inc = -4;
- else
- inc = 4;
- } else {
- DECODE_PRINTF("SCAS\tWORD\n");
- if (ACCESS_FLAG(F_DF)) /* down */
- inc = -2;
- else
- inc = 2;
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_REPE) {
- /* REPE */
- /* move them until CX is ZERO. */
- while (M.x86.R_CX != 0) {
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- val = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
- cmp_long(M.x86.R_EAX, val);
- } else {
- val = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
- cmp_word(M.x86.R_AX, (u16)val);
- }
- M.x86.R_CX -= 1;
- M.x86.R_DI += inc;
- if (ACCESS_FLAG(F_ZF) == 0)
- break;
- }
- M.x86.mode &= ~SYSMODE_PREFIX_REPE;
- } else if (M.x86.mode & SYSMODE_PREFIX_REPNE) {
- /* REPNE */
- /* move them until CX is ZERO. */
- while (M.x86.R_CX != 0) {
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- val = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
- cmp_long(M.x86.R_EAX, val);
- } else {
- val = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
- cmp_word(M.x86.R_AX, (u16)val);
- }
- M.x86.R_CX -= 1;
- M.x86.R_DI += inc;
- if (ACCESS_FLAG(F_ZF))
- break; /* zero flag set means equal */
- }
- M.x86.mode &= ~SYSMODE_PREFIX_REPNE;
- } else {
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- val = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
- cmp_long(M.x86.R_EAX, val);
- } else {
- val = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
- cmp_word(M.x86.R_AX, (u16)val);
- }
- M.x86.R_DI += inc;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xb0
-****************************************************************************/
-static void x86emuOp_mov_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
-{
- u8 imm;
-
- START_OF_INSTR();
- DECODE_PRINTF("MOV\tAL,");
- imm = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", imm);
- TRACE_AND_STEP();
- M.x86.R_AL = imm;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xb1
-****************************************************************************/
-static void x86emuOp_mov_byte_CL_IMM(u8 X86EMU_UNUSED(op1))
-{
- u8 imm;
-
- START_OF_INSTR();
- DECODE_PRINTF("MOV\tCL,");
- imm = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", imm);
- TRACE_AND_STEP();
- M.x86.R_CL = imm;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xb2
-****************************************************************************/
-static void x86emuOp_mov_byte_DL_IMM(u8 X86EMU_UNUSED(op1))
-{
- u8 imm;
-
- START_OF_INSTR();
- DECODE_PRINTF("MOV\tDL,");
- imm = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", imm);
- TRACE_AND_STEP();
- M.x86.R_DL = imm;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xb3
-****************************************************************************/
-static void x86emuOp_mov_byte_BL_IMM(u8 X86EMU_UNUSED(op1))
-{
- u8 imm;
-
- START_OF_INSTR();
- DECODE_PRINTF("MOV\tBL,");
- imm = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", imm);
- TRACE_AND_STEP();
- M.x86.R_BL = imm;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xb4
-****************************************************************************/
-static void x86emuOp_mov_byte_AH_IMM(u8 X86EMU_UNUSED(op1))
-{
- u8 imm;
-
- START_OF_INSTR();
- DECODE_PRINTF("MOV\tAH,");
- imm = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", imm);
- TRACE_AND_STEP();
- M.x86.R_AH = imm;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xb5
-****************************************************************************/
-static void x86emuOp_mov_byte_CH_IMM(u8 X86EMU_UNUSED(op1))
-{
- u8 imm;
-
- START_OF_INSTR();
- DECODE_PRINTF("MOV\tCH,");
- imm = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", imm);
- TRACE_AND_STEP();
- M.x86.R_CH = imm;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xb6
-****************************************************************************/
-static void x86emuOp_mov_byte_DH_IMM(u8 X86EMU_UNUSED(op1))
-{
- u8 imm;
-
- START_OF_INSTR();
- DECODE_PRINTF("MOV\tDH,");
- imm = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", imm);
- TRACE_AND_STEP();
- M.x86.R_DH = imm;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xb7
-****************************************************************************/
-static void x86emuOp_mov_byte_BH_IMM(u8 X86EMU_UNUSED(op1))
-{
- u8 imm;
-
- START_OF_INSTR();
- DECODE_PRINTF("MOV\tBH,");
- imm = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", imm);
- TRACE_AND_STEP();
- M.x86.R_BH = imm;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xb8
-****************************************************************************/
-static void x86emuOp_mov_word_AX_IMM(u8 X86EMU_UNUSED(op1))
-{
- u32 srcval;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("MOV\tEAX,");
- srcval = fetch_long_imm();
- } else {
- DECODE_PRINTF("MOV\tAX,");
- srcval = fetch_word_imm();
- }
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EAX = srcval;
- } else {
- M.x86.R_AX = (u16)srcval;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xb9
-****************************************************************************/
-static void x86emuOp_mov_word_CX_IMM(u8 X86EMU_UNUSED(op1))
-{
- u32 srcval;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("MOV\tECX,");
- srcval = fetch_long_imm();
- } else {
- DECODE_PRINTF("MOV\tCX,");
- srcval = fetch_word_imm();
- }
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_ECX = srcval;
- } else {
- M.x86.R_CX = (u16)srcval;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xba
-****************************************************************************/
-static void x86emuOp_mov_word_DX_IMM(u8 X86EMU_UNUSED(op1))
-{
- u32 srcval;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("MOV\tEDX,");
- srcval = fetch_long_imm();
- } else {
- DECODE_PRINTF("MOV\tDX,");
- srcval = fetch_word_imm();
- }
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EDX = srcval;
- } else {
- M.x86.R_DX = (u16)srcval;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xbb
-****************************************************************************/
-static void x86emuOp_mov_word_BX_IMM(u8 X86EMU_UNUSED(op1))
-{
- u32 srcval;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("MOV\tEBX,");
- srcval = fetch_long_imm();
- } else {
- DECODE_PRINTF("MOV\tBX,");
- srcval = fetch_word_imm();
- }
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EBX = srcval;
- } else {
- M.x86.R_BX = (u16)srcval;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xbc
-****************************************************************************/
-static void x86emuOp_mov_word_SP_IMM(u8 X86EMU_UNUSED(op1))
-{
- u32 srcval;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("MOV\tESP,");
- srcval = fetch_long_imm();
- } else {
- DECODE_PRINTF("MOV\tSP,");
- srcval = fetch_word_imm();
- }
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_ESP = srcval;
- } else {
- M.x86.R_SP = (u16)srcval;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xbd
-****************************************************************************/
-static void x86emuOp_mov_word_BP_IMM(u8 X86EMU_UNUSED(op1))
-{
- u32 srcval;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("MOV\tEBP,");
- srcval = fetch_long_imm();
- } else {
- DECODE_PRINTF("MOV\tBP,");
- srcval = fetch_word_imm();
- }
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EBP = srcval;
- } else {
- M.x86.R_BP = (u16)srcval;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xbe
-****************************************************************************/
-static void x86emuOp_mov_word_SI_IMM(u8 X86EMU_UNUSED(op1))
-{
- u32 srcval;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("MOV\tESI,");
- srcval = fetch_long_imm();
- } else {
- DECODE_PRINTF("MOV\tSI,");
- srcval = fetch_word_imm();
- }
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_ESI = srcval;
- } else {
- M.x86.R_SI = (u16)srcval;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xbf
-****************************************************************************/
-static void x86emuOp_mov_word_DI_IMM(u8 X86EMU_UNUSED(op1))
-{
- u32 srcval;
-
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("MOV\tEDI,");
- srcval = fetch_long_imm();
- } else {
- DECODE_PRINTF("MOV\tDI,");
- srcval = fetch_word_imm();
- }
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EDI = srcval;
- } else {
- M.x86.R_DI = (u16)srcval;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/* used by opcodes c0, d0, and d2. */
-static u8(*opcD0_byte_operation[])(u8 d, u8 s) =
-{
- rol_byte,
- ror_byte,
- rcl_byte,
- rcr_byte,
- shl_byte,
- shr_byte,
- shl_byte, /* sal_byte === shl_byte by definition */
- sar_byte,
-};
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xc0
-****************************************************************************/
-static void x86emuOp_opcC0_byte_RM_MEM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg;
- uint destoffset;
- u8 destval;
- u8 amt;
-
- /*
- * Yet another weirdo special case instruction format. Part of
- * the opcode held below in "RH". Doubly nested case would
- * result, except that the decoded instruction
- */
- START_OF_INSTR();
- FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
- if (DEBUG_DECODE()) {
- /* XXX DECODE_PRINTF may be changed to something more
- general, so that it is important to leave the strings
- in the same format, even though the result is that the
- above test is done twice. */
-
- switch (rh) {
- case 0:
- DECODE_PRINTF("ROL\t");
- break;
- case 1:
- DECODE_PRINTF("ROR\t");
- break;
- case 2:
- DECODE_PRINTF("RCL\t");
- break;
- case 3:
- DECODE_PRINTF("RCR\t");
- break;
- case 4:
- DECODE_PRINTF("SHL\t");
- break;
- case 5:
- DECODE_PRINTF("SHR\t");
- break;
- case 6:
- DECODE_PRINTF("SAL\t");
- break;
- case 7:
- DECODE_PRINTF("SAR\t");
- break;
- }
- }
-#endif
- /* know operation, decode the mod byte to find the addressing
- mode. */
- switch (mod) {
- case 0:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm00_address(rl);
- amt = fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", amt);
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD0_byte_operation[rh]) (destval, amt);
- store_data_byte(destoffset, destval);
- break;
- case 1:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm01_address(rl);
- amt = fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", amt);
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD0_byte_operation[rh]) (destval, amt);
- store_data_byte(destoffset, destval);
- break;
- case 2:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm10_address(rl);
- amt = fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", amt);
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD0_byte_operation[rh]) (destval, amt);
- store_data_byte(destoffset, destval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- amt = fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", amt);
- TRACE_AND_STEP();
- destval = (*opcD0_byte_operation[rh]) (*destreg, amt);
- *destreg = destval;
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/* used by opcodes c1, d1, and d3. */
-static u16(*opcD1_word_operation[])(u16 s, u8 d) =
-{
- rol_word,
- ror_word,
- rcl_word,
- rcr_word,
- shl_word,
- shr_word,
- shl_word, /* sal_byte === shl_byte by definition */
- sar_word,
-};
-
-/* used by opcodes c1, d1, and d3. */
-static u32 (*opcD1_long_operation[])(u32 s, u8 d) =
-{
- rol_long,
- ror_long,
- rcl_long,
- rcr_long,
- shl_long,
- shr_long,
- shl_long, /* sal_byte === shl_byte by definition */
- sar_long,
-};
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xc1
-****************************************************************************/
-static void x86emuOp_opcC1_word_RM_MEM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
- u8 amt;
-
- /*
- * Yet another weirdo special case instruction format. Part of
- * the opcode held below in "RH". Doubly nested case would
- * result, except that the decoded instruction
- */
- START_OF_INSTR();
- FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
- if (DEBUG_DECODE()) {
- /* XXX DECODE_PRINTF may be changed to something more
- general, so that it is important to leave the strings
- in the same format, even though the result is that the
- above test is done twice. */
-
- switch (rh) {
- case 0:
- DECODE_PRINTF("ROL\t");
- break;
- case 1:
- DECODE_PRINTF("ROR\t");
- break;
- case 2:
- DECODE_PRINTF("RCL\t");
- break;
- case 3:
- DECODE_PRINTF("RCR\t");
- break;
- case 4:
- DECODE_PRINTF("SHL\t");
- break;
- case 5:
- DECODE_PRINTF("SHR\t");
- break;
- case 6:
- DECODE_PRINTF("SAL\t");
- break;
- case 7:
- DECODE_PRINTF("SAR\t");
- break;
- }
- }
-#endif
- /* know operation, decode the mod byte to find the addressing
- mode. */
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("DWORD PTR ");
- destoffset = decode_rm00_address(rl);
- amt = fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", amt);
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD1_long_operation[rh]) (destval, amt);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("WORD PTR ");
- destoffset = decode_rm00_address(rl);
- amt = fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", amt);
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD1_word_operation[rh]) (destval, amt);
- store_data_word(destoffset, destval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("DWORD PTR ");
- destoffset = decode_rm01_address(rl);
- amt = fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", amt);
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD1_long_operation[rh]) (destval, amt);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("WORD PTR ");
- destoffset = decode_rm01_address(rl);
- amt = fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", amt);
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD1_word_operation[rh]) (destval, amt);
- store_data_word(destoffset, destval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("DWORD PTR ");
- destoffset = decode_rm10_address(rl);
- amt = fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", amt);
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD1_long_operation[rh]) (destval, amt);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("WORD PTR ");
- destoffset = decode_rm10_address(rl);
- amt = fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", amt);
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD1_word_operation[rh]) (destval, amt);
- store_data_word(destoffset, destval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- amt = fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", amt);
- TRACE_AND_STEP();
- *destreg = (*opcD1_long_operation[rh]) (*destreg, amt);
- } else {
- u16 *destreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- amt = fetch_byte_imm();
- DECODE_PRINTF2(",%x\n", amt);
- TRACE_AND_STEP();
- *destreg = (*opcD1_word_operation[rh]) (*destreg, amt);
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xc2
-****************************************************************************/
-static void x86emuOp_ret_near_IMM(u8 X86EMU_UNUSED(op1))
-{
- u16 imm;
-
- START_OF_INSTR();
- DECODE_PRINTF("RET\t");
- imm = fetch_word_imm();
- DECODE_PRINTF2("%x\n", imm);
- RETURN_TRACE("RET",M.x86.saved_cs,M.x86.saved_ip);
- TRACE_AND_STEP();
- M.x86.R_IP = pop_word();
- M.x86.R_SP += imm;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xc3
-****************************************************************************/
-static void x86emuOp_ret_near(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("RET\n");
- RETURN_TRACE("RET",M.x86.saved_cs,M.x86.saved_ip);
- TRACE_AND_STEP();
- M.x86.R_IP = pop_word();
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xc4
-****************************************************************************/
-static void x86emuOp_les_R_IMM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rh, rl;
- u16 *dstreg;
- uint srcoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("LES\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- dstreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *dstreg = fetch_data_word(srcoffset);
- M.x86.R_ES = fetch_data_word(srcoffset + 2);
- break;
- case 1:
- dstreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *dstreg = fetch_data_word(srcoffset);
- M.x86.R_ES = fetch_data_word(srcoffset + 2);
- break;
- case 2:
- dstreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *dstreg = fetch_data_word(srcoffset);
- M.x86.R_ES = fetch_data_word(srcoffset + 2);
- break;
- case 3: /* register to register */
- /* UNDEFINED! */
- TRACE_AND_STEP();
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xc5
-****************************************************************************/
-static void x86emuOp_lds_R_IMM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rh, rl;
- u16 *dstreg;
- uint srcoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("LDS\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- dstreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *dstreg = fetch_data_word(srcoffset);
- M.x86.R_DS = fetch_data_word(srcoffset + 2);
- break;
- case 1:
- dstreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *dstreg = fetch_data_word(srcoffset);
- M.x86.R_DS = fetch_data_word(srcoffset + 2);
- break;
- case 2:
- dstreg = DECODE_RM_WORD_REGISTER(rh);
- DECODE_PRINTF(",");
- srcoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *dstreg = fetch_data_word(srcoffset);
- M.x86.R_DS = fetch_data_word(srcoffset + 2);
- break;
- case 3: /* register to register */
- /* UNDEFINED! */
- TRACE_AND_STEP();
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xc6
-****************************************************************************/
-static void x86emuOp_mov_byte_RM_IMM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg;
- uint destoffset;
- u8 imm;
-
- START_OF_INSTR();
- DECODE_PRINTF("MOV\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- if (rh != 0) {
- DECODE_PRINTF("ILLEGAL DECODE OF OPCODE c6\n");
- HALT_SYS();
- }
- switch (mod) {
- case 0:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm00_address(rl);
- imm = fetch_byte_imm();
- DECODE_PRINTF2(",%2x\n", imm);
- TRACE_AND_STEP();
- store_data_byte(destoffset, imm);
- break;
- case 1:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm01_address(rl);
- imm = fetch_byte_imm();
- DECODE_PRINTF2(",%2x\n", imm);
- TRACE_AND_STEP();
- store_data_byte(destoffset, imm);
- break;
- case 2:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm10_address(rl);
- imm = fetch_byte_imm();
- DECODE_PRINTF2(",%2x\n", imm);
- TRACE_AND_STEP();
- store_data_byte(destoffset, imm);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- imm = fetch_byte_imm();
- DECODE_PRINTF2(",%2x\n", imm);
- TRACE_AND_STEP();
- *destreg = imm;
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xc7
-****************************************************************************/
-static void x86emuOp_mov_word_RM_IMM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
-
- START_OF_INSTR();
- DECODE_PRINTF("MOV\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- if (rh != 0) {
- DECODE_PRINTF("ILLEGAL DECODE OF OPCODE 8F\n");
- HALT_SYS();
- }
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 imm;
-
- DECODE_PRINTF("DWORD PTR ");
- destoffset = decode_rm00_address(rl);
- imm = fetch_long_imm();
- DECODE_PRINTF2(",%x\n", imm);
- TRACE_AND_STEP();
- store_data_long(destoffset, imm);
- } else {
- u16 imm;
-
- DECODE_PRINTF("WORD PTR ");
- destoffset = decode_rm00_address(rl);
- imm = fetch_word_imm();
- DECODE_PRINTF2(",%x\n", imm);
- TRACE_AND_STEP();
- store_data_word(destoffset, imm);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 imm;
-
- DECODE_PRINTF("DWORD PTR ");
- destoffset = decode_rm01_address(rl);
- imm = fetch_long_imm();
- DECODE_PRINTF2(",%x\n", imm);
- TRACE_AND_STEP();
- store_data_long(destoffset, imm);
- } else {
- u16 imm;
-
- DECODE_PRINTF("WORD PTR ");
- destoffset = decode_rm01_address(rl);
- imm = fetch_word_imm();
- DECODE_PRINTF2(",%x\n", imm);
- TRACE_AND_STEP();
- store_data_word(destoffset, imm);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 imm;
-
- DECODE_PRINTF("DWORD PTR ");
- destoffset = decode_rm10_address(rl);
- imm = fetch_long_imm();
- DECODE_PRINTF2(",%x\n", imm);
- TRACE_AND_STEP();
- store_data_long(destoffset, imm);
- } else {
- u16 imm;
-
- DECODE_PRINTF("WORD PTR ");
- destoffset = decode_rm10_address(rl);
- imm = fetch_word_imm();
- DECODE_PRINTF2(",%x\n", imm);
- TRACE_AND_STEP();
- store_data_word(destoffset, imm);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 imm;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- imm = fetch_long_imm();
- DECODE_PRINTF2(",%x\n", imm);
- TRACE_AND_STEP();
- *destreg = imm;
- } else {
- u16 *destreg;
- u16 imm;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- imm = fetch_word_imm();
- DECODE_PRINTF2(",%x\n", imm);
- TRACE_AND_STEP();
- *destreg = imm;
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xc8
-****************************************************************************/
-static void x86emuOp_enter(u8 X86EMU_UNUSED(op1))
-{
- u16 local,frame_pointer;
- u8 nesting;
- int i;
-
- START_OF_INSTR();
- local = fetch_word_imm();
- nesting = fetch_byte_imm();
- DECODE_PRINTF2("ENTER %x\n", local);
- DECODE_PRINTF2(",%x\n", nesting);
- TRACE_AND_STEP();
- push_word(M.x86.R_BP);
- frame_pointer = M.x86.R_SP;
- if (nesting > 0) {
- for (i = 1; i < nesting; i++) {
- M.x86.R_BP -= 2;
- push_word(fetch_data_word_abs(M.x86.R_SS, M.x86.R_BP));
- }
- push_word(frame_pointer);
- }
- M.x86.R_BP = frame_pointer;
- M.x86.R_SP = (u16)(M.x86.R_SP - local);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xc9
-****************************************************************************/
-static void x86emuOp_leave(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("LEAVE\n");
- TRACE_AND_STEP();
- M.x86.R_SP = M.x86.R_BP;
- M.x86.R_BP = pop_word();
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xca
-****************************************************************************/
-static void x86emuOp_ret_far_IMM(u8 X86EMU_UNUSED(op1))
-{
- u16 imm;
-
- START_OF_INSTR();
- DECODE_PRINTF("RETF\t");
- imm = fetch_word_imm();
- DECODE_PRINTF2("%x\n", imm);
- RETURN_TRACE("RETF",M.x86.saved_cs,M.x86.saved_ip);
- TRACE_AND_STEP();
- M.x86.R_IP = pop_word();
- M.x86.R_CS = pop_word();
- M.x86.R_SP += imm;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xcb
-****************************************************************************/
-static void x86emuOp_ret_far(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("RETF\n");
- RETURN_TRACE("RETF",M.x86.saved_cs,M.x86.saved_ip);
- TRACE_AND_STEP();
- M.x86.R_IP = pop_word();
- M.x86.R_CS = pop_word();
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xcc
-****************************************************************************/
-static void x86emuOp_int3(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("INT 3\n");
- TRACE_AND_STEP();
- if (_X86EMU_intrTab[3]) {
- (*_X86EMU_intrTab[3])(3);
- } else {
- push_word((u16)M.x86.R_FLG);
- CLEAR_FLAG(F_IF);
- CLEAR_FLAG(F_TF);
- push_word(M.x86.R_CS);
- M.x86.R_CS = mem_access_word(3 * 4 + 2);
- push_word(M.x86.R_IP);
- M.x86.R_IP = mem_access_word(3 * 4);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xcd
-****************************************************************************/
-static void x86emuOp_int_IMM(u8 X86EMU_UNUSED(op1))
-{
- u8 intnum;
-
- START_OF_INSTR();
- DECODE_PRINTF("INT\t");
- intnum = fetch_byte_imm();
- DECODE_PRINTF2("%x\n", intnum);
- TRACE_AND_STEP();
- if (_X86EMU_intrTab[intnum]) {
- (*_X86EMU_intrTab[intnum])(intnum);
- } else {
- push_word((u16)M.x86.R_FLG);
- CLEAR_FLAG(F_IF);
- CLEAR_FLAG(F_TF);
- push_word(M.x86.R_CS);
- M.x86.R_CS = mem_access_word(intnum * 4 + 2);
- push_word(M.x86.R_IP);
- M.x86.R_IP = mem_access_word(intnum * 4);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xce
-****************************************************************************/
-static void x86emuOp_into(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("INTO\n");
- TRACE_AND_STEP();
- if (ACCESS_FLAG(F_OF)) {
- if (_X86EMU_intrTab[4]) {
- (*_X86EMU_intrTab[4])(4);
- } else {
- push_word((u16)M.x86.R_FLG);
- CLEAR_FLAG(F_IF);
- CLEAR_FLAG(F_TF);
- push_word(M.x86.R_CS);
- M.x86.R_CS = mem_access_word(4 * 4 + 2);
- push_word(M.x86.R_IP);
- M.x86.R_IP = mem_access_word(4 * 4);
- }
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xcf
-****************************************************************************/
-static void x86emuOp_iret(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("IRET\n");
-
- TRACE_AND_STEP();
-
- M.x86.R_IP = pop_word();
- M.x86.R_CS = pop_word();
- M.x86.R_FLG = pop_word();
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xd0
-****************************************************************************/
-static void x86emuOp_opcD0_byte_RM_1(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg;
- uint destoffset;
- u8 destval;
-
- /*
- * Yet another weirdo special case instruction format. Part of
- * the opcode held below in "RH". Doubly nested case would
- * result, except that the decoded instruction
- */
- START_OF_INSTR();
- FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
- if (DEBUG_DECODE()) {
- /* XXX DECODE_PRINTF may be changed to something more
- general, so that it is important to leave the strings
- in the same format, even though the result is that the
- above test is done twice. */
- switch (rh) {
- case 0:
- DECODE_PRINTF("ROL\t");
- break;
- case 1:
- DECODE_PRINTF("ROR\t");
- break;
- case 2:
- DECODE_PRINTF("RCL\t");
- break;
- case 3:
- DECODE_PRINTF("RCR\t");
- break;
- case 4:
- DECODE_PRINTF("SHL\t");
- break;
- case 5:
- DECODE_PRINTF("SHR\t");
- break;
- case 6:
- DECODE_PRINTF("SAL\t");
- break;
- case 7:
- DECODE_PRINTF("SAR\t");
- break;
- }
- }
-#endif
- /* know operation, decode the mod byte to find the addressing
- mode. */
- switch (mod) {
- case 0:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",1\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD0_byte_operation[rh]) (destval, 1);
- store_data_byte(destoffset, destval);
- break;
- case 1:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",1\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD0_byte_operation[rh]) (destval, 1);
- store_data_byte(destoffset, destval);
- break;
- case 2:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",1\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD0_byte_operation[rh]) (destval, 1);
- store_data_byte(destoffset, destval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF(",1\n");
- TRACE_AND_STEP();
- destval = (*opcD0_byte_operation[rh]) (*destreg, 1);
- *destreg = destval;
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xd1
-****************************************************************************/
-static void x86emuOp_opcD1_word_RM_1(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
-
- /*
- * Yet another weirdo special case instruction format. Part of
- * the opcode held below in "RH". Doubly nested case would
- * result, except that the decoded instruction
- */
- START_OF_INSTR();
- FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
- if (DEBUG_DECODE()) {
- /* XXX DECODE_PRINTF may be changed to something more
- general, so that it is important to leave the strings
- in the same format, even though the result is that the
- above test is done twice. */
- switch (rh) {
- case 0:
- DECODE_PRINTF("ROL\t");
- break;
- case 1:
- DECODE_PRINTF("ROR\t");
- break;
- case 2:
- DECODE_PRINTF("RCL\t");
- break;
- case 3:
- DECODE_PRINTF("RCR\t");
- break;
- case 4:
- DECODE_PRINTF("SHL\t");
- break;
- case 5:
- DECODE_PRINTF("SHR\t");
- break;
- case 6:
- DECODE_PRINTF("SAL\t");
- break;
- case 7:
- DECODE_PRINTF("SAR\t");
- break;
- }
- }
-#endif
- /* know operation, decode the mod byte to find the addressing
- mode. */
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("DWORD PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",1\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD1_long_operation[rh]) (destval, 1);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("WORD PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",1\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD1_word_operation[rh]) (destval, 1);
- store_data_word(destoffset, destval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("DWORD PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",1\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD1_long_operation[rh]) (destval, 1);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("WORD PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",1\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD1_word_operation[rh]) (destval, 1);
- store_data_word(destoffset, destval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("DWORD PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",1\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD1_long_operation[rh]) (destval, 1);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",1\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD1_word_operation[rh]) (destval, 1);
- store_data_word(destoffset, destval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
- u32 *destreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF(",1\n");
- TRACE_AND_STEP();
- destval = (*opcD1_long_operation[rh]) (*destreg, 1);
- *destreg = destval;
- } else {
- u16 destval;
- u16 *destreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",1\n");
- TRACE_AND_STEP();
- destval = (*opcD1_word_operation[rh]) (*destreg, 1);
- *destreg = destval;
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xd2
-****************************************************************************/
-static void x86emuOp_opcD2_byte_RM_CL(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg;
- uint destoffset;
- u8 destval;
- u8 amt;
-
- /*
- * Yet another weirdo special case instruction format. Part of
- * the opcode held below in "RH". Doubly nested case would
- * result, except that the decoded instruction
- */
- START_OF_INSTR();
- FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
- if (DEBUG_DECODE()) {
- /* XXX DECODE_PRINTF may be changed to something more
- general, so that it is important to leave the strings
- in the same format, even though the result is that the
- above test is done twice. */
- switch (rh) {
- case 0:
- DECODE_PRINTF("ROL\t");
- break;
- case 1:
- DECODE_PRINTF("ROR\t");
- break;
- case 2:
- DECODE_PRINTF("RCL\t");
- break;
- case 3:
- DECODE_PRINTF("RCR\t");
- break;
- case 4:
- DECODE_PRINTF("SHL\t");
- break;
- case 5:
- DECODE_PRINTF("SHR\t");
- break;
- case 6:
- DECODE_PRINTF("SAL\t");
- break;
- case 7:
- DECODE_PRINTF("SAR\t");
- break;
- }
- }
-#endif
- /* know operation, decode the mod byte to find the addressing
- mode. */
- amt = M.x86.R_CL;
- switch (mod) {
- case 0:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",CL\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD0_byte_operation[rh]) (destval, amt);
- store_data_byte(destoffset, destval);
- break;
- case 1:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",CL\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD0_byte_operation[rh]) (destval, amt);
- store_data_byte(destoffset, destval);
- break;
- case 2:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",CL\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD0_byte_operation[rh]) (destval, amt);
- store_data_byte(destoffset, destval);
- break;
- case 3: /* register to register */
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF(",CL\n");
- TRACE_AND_STEP();
- destval = (*opcD0_byte_operation[rh]) (*destreg, amt);
- *destreg = destval;
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xd3
-****************************************************************************/
-static void x86emuOp_opcD3_word_RM_CL(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
- u8 amt;
-
- /*
- * Yet another weirdo special case instruction format. Part of
- * the opcode held below in "RH". Doubly nested case would
- * result, except that the decoded instruction
- */
- START_OF_INSTR();
- FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
- if (DEBUG_DECODE()) {
- /* XXX DECODE_PRINTF may be changed to something more
- general, so that it is important to leave the strings
- in the same format, even though the result is that the
- above test is done twice. */
- switch (rh) {
- case 0:
- DECODE_PRINTF("ROL\t");
- break;
- case 1:
- DECODE_PRINTF("ROR\t");
- break;
- case 2:
- DECODE_PRINTF("RCL\t");
- break;
- case 3:
- DECODE_PRINTF("RCR\t");
- break;
- case 4:
- DECODE_PRINTF("SHL\t");
- break;
- case 5:
- DECODE_PRINTF("SHR\t");
- break;
- case 6:
- DECODE_PRINTF("SAL\t");
- break;
- case 7:
- DECODE_PRINTF("SAR\t");
- break;
- }
- }
-#endif
- /* know operation, decode the mod byte to find the addressing
- mode. */
- amt = M.x86.R_CL;
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("DWORD PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",CL\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD1_long_operation[rh]) (destval, amt);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("WORD PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",CL\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD1_word_operation[rh]) (destval, amt);
- store_data_word(destoffset, destval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("DWORD PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",CL\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD1_long_operation[rh]) (destval, amt);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("WORD PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",CL\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD1_word_operation[rh]) (destval, amt);
- store_data_word(destoffset, destval);
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("DWORD PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",CL\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD1_long_operation[rh]) (destval, amt);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("WORD PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",CL\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = (*opcD1_word_operation[rh]) (destval, amt);
- store_data_word(destoffset, destval);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF(",CL\n");
- TRACE_AND_STEP();
- *destreg = (*opcD1_long_operation[rh]) (*destreg, amt);
- } else {
- u16 *destreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",CL\n");
- TRACE_AND_STEP();
- *destreg = (*opcD1_word_operation[rh]) (*destreg, amt);
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xd4
-****************************************************************************/
-static void x86emuOp_aam(u8 X86EMU_UNUSED(op1))
-{
- u8 a;
-
- START_OF_INSTR();
- DECODE_PRINTF("AAM\n");
- a = fetch_byte_imm(); /* this is a stupid encoding. */
- if (a != 10) {
- /* fix: add base decoding
- aam_word(u8 val, int base a) */
- DECODE_PRINTF("ERROR DECODING AAM\n");
- TRACE_REGS();
- HALT_SYS();
- }
- TRACE_AND_STEP();
- /* note the type change here --- returning AL and AH in AX. */
- M.x86.R_AX = aam_word(M.x86.R_AL);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xd5
-****************************************************************************/
-static void x86emuOp_aad(u8 X86EMU_UNUSED(op1))
-{
- u8 a;
-
- START_OF_INSTR();
- DECODE_PRINTF("AAD\n");
- a = fetch_byte_imm();
- if (a != 10) {
- /* fix: add base decoding
- aad_word(u16 val, int base a) */
- DECODE_PRINTF("ERROR DECODING AAM\n");
- TRACE_REGS();
- HALT_SYS();
- }
- TRACE_AND_STEP();
- M.x86.R_AX = aad_word(M.x86.R_AX);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/* opcode 0xd6 ILLEGAL OPCODE */
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xd7
-****************************************************************************/
-static void x86emuOp_xlat(u8 X86EMU_UNUSED(op1))
-{
- u16 addr;
-
- START_OF_INSTR();
- DECODE_PRINTF("XLAT\n");
- TRACE_AND_STEP();
- addr = (u16)(M.x86.R_BX + (u8)M.x86.R_AL);
- M.x86.R_AL = fetch_data_byte(addr);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/* instuctions D8 .. DF are in i87_ops.c */
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xe0
-****************************************************************************/
-static void x86emuOp_loopne(u8 X86EMU_UNUSED(op1))
-{
- s16 ip;
-
- START_OF_INSTR();
- DECODE_PRINTF("LOOPNE\t");
- ip = (s8) fetch_byte_imm();
- ip += (s16) M.x86.R_IP;
- DECODE_PRINTF2("%04x\n", ip);
- TRACE_AND_STEP();
- M.x86.R_CX -= 1;
- if (M.x86.R_CX != 0 && !ACCESS_FLAG(F_ZF)) /* CX != 0 and !ZF */
- M.x86.R_IP = ip;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xe1
-****************************************************************************/
-static void x86emuOp_loope(u8 X86EMU_UNUSED(op1))
-{
- s16 ip;
-
- START_OF_INSTR();
- DECODE_PRINTF("LOOPE\t");
- ip = (s8) fetch_byte_imm();
- ip += (s16) M.x86.R_IP;
- DECODE_PRINTF2("%04x\n", ip);
- TRACE_AND_STEP();
- M.x86.R_CX -= 1;
- if (M.x86.R_CX != 0 && ACCESS_FLAG(F_ZF)) /* CX != 0 and ZF */
- M.x86.R_IP = ip;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xe2
-****************************************************************************/
-static void x86emuOp_loop(u8 X86EMU_UNUSED(op1))
-{
- s16 ip;
-
- START_OF_INSTR();
- DECODE_PRINTF("LOOP\t");
- ip = (s8) fetch_byte_imm();
- ip += (s16) M.x86.R_IP;
- DECODE_PRINTF2("%04x\n", ip);
- TRACE_AND_STEP();
- M.x86.R_CX -= 1;
- if (M.x86.R_CX != 0)
- M.x86.R_IP = ip;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xe3
-****************************************************************************/
-static void x86emuOp_jcxz(u8 X86EMU_UNUSED(op1))
-{
- u16 target;
- s8 offset;
-
- /* jump to byte offset if overflow flag is set */
- START_OF_INSTR();
- DECODE_PRINTF("JCXZ\t");
- offset = (s8)fetch_byte_imm();
- target = (u16)(M.x86.R_IP + offset);
- DECODE_PRINTF2("%x\n", target);
- TRACE_AND_STEP();
- if (M.x86.R_CX == 0)
- M.x86.R_IP = target;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xe4
-****************************************************************************/
-static void x86emuOp_in_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
-{
- u8 port;
-
- START_OF_INSTR();
- DECODE_PRINTF("IN\t");
- port = (u8) fetch_byte_imm();
- DECODE_PRINTF2("%x,AL\n", port);
- TRACE_AND_STEP();
- M.x86.R_AL = (*sys_inb)(port);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xe5
-****************************************************************************/
-static void x86emuOp_in_word_AX_IMM(u8 X86EMU_UNUSED(op1))
-{
- u8 port;
-
- START_OF_INSTR();
- DECODE_PRINTF("IN\t");
- port = (u8) fetch_byte_imm();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF2("EAX,%x\n", port);
- } else {
- DECODE_PRINTF2("AX,%x\n", port);
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EAX = (*sys_inl)(port);
- } else {
- M.x86.R_AX = (*sys_inw)(port);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xe6
-****************************************************************************/
-static void x86emuOp_out_byte_IMM_AL(u8 X86EMU_UNUSED(op1))
-{
- u8 port;
-
- START_OF_INSTR();
- DECODE_PRINTF("OUT\t");
- port = (u8) fetch_byte_imm();
- DECODE_PRINTF2("%x,AL\n", port);
- TRACE_AND_STEP();
- (*sys_outb)(port, M.x86.R_AL);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xe7
-****************************************************************************/
-static void x86emuOp_out_word_IMM_AX(u8 X86EMU_UNUSED(op1))
-{
- u8 port;
-
- START_OF_INSTR();
- DECODE_PRINTF("OUT\t");
- port = (u8) fetch_byte_imm();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF2("%x,EAX\n", port);
- } else {
- DECODE_PRINTF2("%x,AX\n", port);
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- (*sys_outl)(port, M.x86.R_EAX);
- } else {
- (*sys_outw)(port, M.x86.R_AX);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xe8
-****************************************************************************/
-static void x86emuOp_call_near_IMM(u8 X86EMU_UNUSED(op1))
-{
- s16 ip16;
- s32 ip32;
-
- START_OF_INSTR();
- DECODE_PRINTF("CALL\t");
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- ip32 = (s32) fetch_long_imm();
- ip32 += (s16) M.x86.R_IP; /* CHECK SIGN */
- DECODE_PRINTF2("%04x\n", (u16)ip32);
- CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, M.x86.R_CS, ip32, "");
- } else {
- ip16 = (s16) fetch_word_imm();
- ip16 += (s16) M.x86.R_IP; /* CHECK SIGN */
- DECODE_PRINTF2("%04x\n", (u16)ip16);
- CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, M.x86.R_CS, ip16, "");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- push_long(M.x86.R_EIP);
- M.x86.R_EIP = ip32 & 0xffff;
- } else {
- push_word(M.x86.R_IP);
- M.x86.R_EIP = ip16;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xe9
-****************************************************************************/
-static void x86emuOp_jump_near_IMM(u8 X86EMU_UNUSED(op1))
-{
- u32 ip;
-
- START_OF_INSTR();
- DECODE_PRINTF("JMP\t");
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- ip = (u32)fetch_long_imm();
- ip += (u32)M.x86.R_EIP;
- DECODE_PRINTF2("%08x\n", (u32)ip);
- TRACE_AND_STEP();
- M.x86.R_EIP = (u32)ip;
- } else {
- ip = (s16)fetch_word_imm();
- ip += (s16)M.x86.R_IP;
- DECODE_PRINTF2("%04x\n", (u16)ip);
- TRACE_AND_STEP();
- M.x86.R_IP = (u16)ip;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xea
-****************************************************************************/
-static void x86emuOp_jump_far_IMM(u8 X86EMU_UNUSED(op1))
-{
- u16 cs;
- u32 ip;
-
- START_OF_INSTR();
- DECODE_PRINTF("JMP\tFAR ");
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- ip = fetch_long_imm();
- } else {
- ip = fetch_word_imm();
- }
- cs = fetch_word_imm();
- DECODE_PRINTF2("%04x:", cs);
- DECODE_PRINTF2("%04x\n", ip);
- TRACE_AND_STEP();
- M.x86.R_EIP = ip & 0xffff;
- M.x86.R_CS = cs;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xeb
-****************************************************************************/
-static void x86emuOp_jump_byte_IMM(u8 X86EMU_UNUSED(op1))
-{
- u16 target;
- s8 offset;
-
- START_OF_INSTR();
- DECODE_PRINTF("JMP\t");
- offset = (s8)fetch_byte_imm();
- target = (u16)(M.x86.R_IP + offset);
- DECODE_PRINTF2("%x\n", target);
- TRACE_AND_STEP();
- M.x86.R_IP = target;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xec
-****************************************************************************/
-static void x86emuOp_in_byte_AL_DX(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("IN\tAL,DX\n");
- TRACE_AND_STEP();
- M.x86.R_AL = (*sys_inb)(M.x86.R_DX);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xed
-****************************************************************************/
-static void x86emuOp_in_word_AX_DX(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("IN\tEAX,DX\n");
- } else {
- DECODE_PRINTF("IN\tAX,DX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_EAX = (*sys_inl)(M.x86.R_DX);
- } else {
- M.x86.R_AX = (*sys_inw)(M.x86.R_DX);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xee
-****************************************************************************/
-static void x86emuOp_out_byte_DX_AL(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("OUT\tDX,AL\n");
- TRACE_AND_STEP();
- (*sys_outb)(M.x86.R_DX, M.x86.R_AL);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xef
-****************************************************************************/
-static void x86emuOp_out_word_DX_AX(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("OUT\tDX,EAX\n");
- } else {
- DECODE_PRINTF("OUT\tDX,AX\n");
- }
- TRACE_AND_STEP();
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- (*sys_outl)(M.x86.R_DX, M.x86.R_EAX);
- } else {
- (*sys_outw)(M.x86.R_DX, M.x86.R_AX);
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xf0
-****************************************************************************/
-static void x86emuOp_lock(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("LOCK:\n");
- TRACE_AND_STEP();
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/*opcode 0xf1 ILLEGAL OPERATION */
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xf2
-****************************************************************************/
-static void x86emuOp_repne(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("REPNE\n");
- TRACE_AND_STEP();
- M.x86.mode |= SYSMODE_PREFIX_REPNE;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xf3
-****************************************************************************/
-static void x86emuOp_repe(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("REPE\n");
- TRACE_AND_STEP();
- M.x86.mode |= SYSMODE_PREFIX_REPE;
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xf4
-****************************************************************************/
-static void x86emuOp_halt(u8 X86EMU_UNUSED(op1))
-{
- START_OF_INSTR();
- DECODE_PRINTF("HALT\n");
- TRACE_AND_STEP();
- HALT_SYS();
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xf5
-****************************************************************************/
-static void x86emuOp_cmc(u8 X86EMU_UNUSED(op1))
-{
- /* complement the carry flag. */
- START_OF_INSTR();
- DECODE_PRINTF("CMC\n");
- TRACE_AND_STEP();
- TOGGLE_FLAG(F_CF);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xf6
-****************************************************************************/
-static void x86emuOp_opcF6_byte_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- u8 *destreg;
- uint destoffset;
- u8 destval, srcval;
-
- /* long, drawn out code follows. Double switch for a total
- of 32 cases. */
- START_OF_INSTR();
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0: /* mod=00 */
- switch (rh) {
- case 0: /* test byte imm */
- DECODE_PRINTF("TEST\tBYTE PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- srcval = fetch_byte_imm();
- DECODE_PRINTF2("%02x\n", srcval);
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- test_byte(destval, srcval);
- break;
- case 1:
- DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n");
- HALT_SYS();
- break;
- case 2:
- DECODE_PRINTF("NOT\tBYTE PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = not_byte(destval);
- store_data_byte(destoffset, destval);
- break;
- case 3:
- DECODE_PRINTF("NEG\tBYTE PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = neg_byte(destval);
- store_data_byte(destoffset, destval);
- break;
- case 4:
- DECODE_PRINTF("MUL\tBYTE PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- mul_byte(destval);
- break;
- case 5:
- DECODE_PRINTF("IMUL\tBYTE PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- imul_byte(destval);
- break;
- case 6:
- DECODE_PRINTF("DIV\tBYTE PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- div_byte(destval);
- break;
- case 7:
- DECODE_PRINTF("IDIV\tBYTE PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- idiv_byte(destval);
- break;
- }
- break; /* end mod==00 */
- case 1: /* mod=01 */
- switch (rh) {
- case 0: /* test byte imm */
- DECODE_PRINTF("TEST\tBYTE PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- srcval = fetch_byte_imm();
- DECODE_PRINTF2("%02x\n", srcval);
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- test_byte(destval, srcval);
- break;
- case 1:
- DECODE_PRINTF("ILLEGAL OP MOD=01 RH=01 OP=F6\n");
- HALT_SYS();
- break;
- case 2:
- DECODE_PRINTF("NOT\tBYTE PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = not_byte(destval);
- store_data_byte(destoffset, destval);
- break;
- case 3:
- DECODE_PRINTF("NEG\tBYTE PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = neg_byte(destval);
- store_data_byte(destoffset, destval);
- break;
- case 4:
- DECODE_PRINTF("MUL\tBYTE PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- mul_byte(destval);
- break;
- case 5:
- DECODE_PRINTF("IMUL\tBYTE PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- imul_byte(destval);
- break;
- case 6:
- DECODE_PRINTF("DIV\tBYTE PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- div_byte(destval);
- break;
- case 7:
- DECODE_PRINTF("IDIV\tBYTE PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- idiv_byte(destval);
- break;
- }
- break; /* end mod==01 */
- case 2: /* mod=10 */
- switch (rh) {
- case 0: /* test byte imm */
- DECODE_PRINTF("TEST\tBYTE PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- srcval = fetch_byte_imm();
- DECODE_PRINTF2("%02x\n", srcval);
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- test_byte(destval, srcval);
- break;
- case 1:
- DECODE_PRINTF("ILLEGAL OP MOD=10 RH=01 OP=F6\n");
- HALT_SYS();
- break;
- case 2:
- DECODE_PRINTF("NOT\tBYTE PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = not_byte(destval);
- store_data_byte(destoffset, destval);
- break;
- case 3:
- DECODE_PRINTF("NEG\tBYTE PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = neg_byte(destval);
- store_data_byte(destoffset, destval);
- break;
- case 4:
- DECODE_PRINTF("MUL\tBYTE PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- mul_byte(destval);
- break;
- case 5:
- DECODE_PRINTF("IMUL\tBYTE PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- imul_byte(destval);
- break;
- case 6:
- DECODE_PRINTF("DIV\tBYTE PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- div_byte(destval);
- break;
- case 7:
- DECODE_PRINTF("IDIV\tBYTE PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- idiv_byte(destval);
- break;
- }
- break; /* end mod==10 */
- case 3: /* mod=11 */
- switch (rh) {
- case 0: /* test byte imm */
- DECODE_PRINTF("TEST\t");
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF(",");
- srcval = fetch_byte_imm();
- DECODE_PRINTF2("%02x\n", srcval);
- TRACE_AND_STEP();
- test_byte(*destreg, srcval);
- break;
- case 1:
- DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n");
- HALT_SYS();
- break;
- case 2:
- DECODE_PRINTF("NOT\t");
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = not_byte(*destreg);
- break;
- case 3:
- DECODE_PRINTF("NEG\t");
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = neg_byte(*destreg);
- break;
- case 4:
- DECODE_PRINTF("MUL\t");
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- mul_byte(*destreg); /*!!! */
- break;
- case 5:
- DECODE_PRINTF("IMUL\t");
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- imul_byte(*destreg);
- break;
- case 6:
- DECODE_PRINTF("DIV\t");
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- div_byte(*destreg);
- break;
- case 7:
- DECODE_PRINTF("IDIV\t");
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- idiv_byte(*destreg);
- break;
- }
- break; /* end mod==11 */
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xf7
-****************************************************************************/
-static void x86emuOp_opcF7_word_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rl, rh;
- uint destoffset;
-
- /* long, drawn out code follows. Double switch for a total
- of 32 cases. */
- START_OF_INSTR();
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0: /* mod=00 */
- switch (rh) {
- case 0: /* test word imm */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval,srcval;
-
- DECODE_PRINTF("TEST\tDWORD PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- srcval = fetch_long_imm();
- DECODE_PRINTF2("%x\n", srcval);
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- test_long(destval, srcval);
- } else {
- u16 destval,srcval;
-
- DECODE_PRINTF("TEST\tWORD PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- srcval = fetch_word_imm();
- DECODE_PRINTF2("%x\n", srcval);
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- test_word(destval, srcval);
- }
- break;
- case 1:
- DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F7\n");
- HALT_SYS();
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("NOT\tDWORD PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = not_long(destval);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("NOT\tWORD PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = not_word(destval);
- store_data_word(destoffset, destval);
- }
- break;
- case 3:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("NEG\tDWORD PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = neg_long(destval);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("NEG\tWORD PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = neg_word(destval);
- store_data_word(destoffset, destval);
- }
- break;
- case 4:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("MUL\tDWORD PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- mul_long(destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("MUL\tWORD PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- mul_word(destval);
- }
- break;
- case 5:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("IMUL\tDWORD PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- imul_long(destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("IMUL\tWORD PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- imul_word(destval);
- }
- break;
- case 6:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("DIV\tDWORD PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- div_long(destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("DIV\tWORD PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- div_word(destval);
- }
- break;
- case 7:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("IDIV\tDWORD PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- idiv_long(destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("IDIV\tWORD PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- idiv_word(destval);
- }
- break;
- }
- break; /* end mod==00 */
- case 1: /* mod=01 */
- switch (rh) {
- case 0: /* test word imm */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval,srcval;
-
- DECODE_PRINTF("TEST\tDWORD PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- srcval = fetch_long_imm();
- DECODE_PRINTF2("%x\n", srcval);
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- test_long(destval, srcval);
- } else {
- u16 destval,srcval;
-
- DECODE_PRINTF("TEST\tWORD PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- srcval = fetch_word_imm();
- DECODE_PRINTF2("%x\n", srcval);
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- test_word(destval, srcval);
- }
- break;
- case 1:
- DECODE_PRINTF("ILLEGAL OP MOD=01 RH=01 OP=F6\n");
- HALT_SYS();
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("NOT\tDWORD PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = not_long(destval);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("NOT\tWORD PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = not_word(destval);
- store_data_word(destoffset, destval);
- }
- break;
- case 3:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("NEG\tDWORD PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = neg_long(destval);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("NEG\tWORD PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = neg_word(destval);
- store_data_word(destoffset, destval);
- }
- break;
- case 4:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("MUL\tDWORD PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- mul_long(destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("MUL\tWORD PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- mul_word(destval);
- }
- break;
- case 5:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("IMUL\tDWORD PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- imul_long(destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("IMUL\tWORD PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- imul_word(destval);
- }
- break;
- case 6:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("DIV\tDWORD PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- div_long(destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("DIV\tWORD PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- div_word(destval);
- }
- break;
- case 7:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("IDIV\tDWORD PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- idiv_long(destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("IDIV\tWORD PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- idiv_word(destval);
- }
- break;
- }
- break; /* end mod==01 */
- case 2: /* mod=10 */
- switch (rh) {
- case 0: /* test word imm */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval,srcval;
-
- DECODE_PRINTF("TEST\tDWORD PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- srcval = fetch_long_imm();
- DECODE_PRINTF2("%x\n", srcval);
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- test_long(destval, srcval);
- } else {
- u16 destval,srcval;
-
- DECODE_PRINTF("TEST\tWORD PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- srcval = fetch_word_imm();
- DECODE_PRINTF2("%x\n", srcval);
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- test_word(destval, srcval);
- }
- break;
- case 1:
- DECODE_PRINTF("ILLEGAL OP MOD=10 RH=01 OP=F6\n");
- HALT_SYS();
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("NOT\tDWORD PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = not_long(destval);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("NOT\tWORD PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = not_word(destval);
- store_data_word(destoffset, destval);
- }
- break;
- case 3:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("NEG\tDWORD PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = neg_long(destval);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("NEG\tWORD PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = neg_word(destval);
- store_data_word(destoffset, destval);
- }
- break;
- case 4:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("MUL\tDWORD PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- mul_long(destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("MUL\tWORD PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- mul_word(destval);
- }
- break;
- case 5:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("IMUL\tDWORD PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- imul_long(destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("IMUL\tWORD PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- imul_word(destval);
- }
- break;
- case 6:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("DIV\tDWORD PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- div_long(destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("DIV\tWORD PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- div_word(destval);
- }
- break;
- case 7:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- DECODE_PRINTF("IDIV\tDWORD PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- idiv_long(destval);
- } else {
- u16 destval;
-
- DECODE_PRINTF("IDIV\tWORD PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- idiv_word(destval);
- }
- break;
- }
- break; /* end mod==10 */
- case 3: /* mod=11 */
- switch (rh) {
- case 0: /* test word imm */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
- u32 srcval;
-
- DECODE_PRINTF("TEST\t");
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF(",");
- srcval = fetch_long_imm();
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- test_long(*destreg, srcval);
- } else {
- u16 *destreg;
- u16 srcval;
-
- DECODE_PRINTF("TEST\t");
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",");
- srcval = fetch_word_imm();
- DECODE_PRINTF2("%x\n", srcval);
- TRACE_AND_STEP();
- test_word(*destreg, srcval);
- }
- break;
- case 1:
- DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n");
- HALT_SYS();
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
-
- DECODE_PRINTF("NOT\t");
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = not_long(*destreg);
- } else {
- u16 *destreg;
-
- DECODE_PRINTF("NOT\t");
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = not_word(*destreg);
- }
- break;
- case 3:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
-
- DECODE_PRINTF("NEG\t");
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = neg_long(*destreg);
- } else {
- u16 *destreg;
-
- DECODE_PRINTF("NEG\t");
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = neg_word(*destreg);
- }
- break;
- case 4:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
-
- DECODE_PRINTF("MUL\t");
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- mul_long(*destreg); /*!!! */
- } else {
- u16 *destreg;
-
- DECODE_PRINTF("MUL\t");
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- mul_word(*destreg); /*!!! */
- }
- break;
- case 5:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
-
- DECODE_PRINTF("IMUL\t");
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- imul_long(*destreg);
- } else {
- u16 *destreg;
-
- DECODE_PRINTF("IMUL\t");
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- imul_word(*destreg);
- }
- break;
- case 6:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
-
- DECODE_PRINTF("DIV\t");
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- div_long(*destreg);
- } else {
- u16 *destreg;
-
- DECODE_PRINTF("DIV\t");
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- div_word(*destreg);
- }
- break;
- case 7:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
-
- DECODE_PRINTF("IDIV\t");
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- idiv_long(*destreg);
- } else {
- u16 *destreg;
-
- DECODE_PRINTF("IDIV\t");
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- idiv_word(*destreg);
- }
- break;
- }
- break; /* end mod==11 */
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xf8
-****************************************************************************/
-static void x86emuOp_clc(u8 X86EMU_UNUSED(op1))
-{
- /* clear the carry flag. */
- START_OF_INSTR();
- DECODE_PRINTF("CLC\n");
- TRACE_AND_STEP();
- CLEAR_FLAG(F_CF);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xf9
-****************************************************************************/
-static void x86emuOp_stc(u8 X86EMU_UNUSED(op1))
-{
- /* set the carry flag. */
- START_OF_INSTR();
- DECODE_PRINTF("STC\n");
- TRACE_AND_STEP();
- SET_FLAG(F_CF);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xfa
-****************************************************************************/
-static void x86emuOp_cli(u8 X86EMU_UNUSED(op1))
-{
- /* clear interrupts. */
- START_OF_INSTR();
- DECODE_PRINTF("CLI\n");
- TRACE_AND_STEP();
- CLEAR_FLAG(F_IF);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xfb
-****************************************************************************/
-static void x86emuOp_sti(u8 X86EMU_UNUSED(op1))
-{
- /* enable interrupts. */
- START_OF_INSTR();
- DECODE_PRINTF("STI\n");
- TRACE_AND_STEP();
- SET_FLAG(F_IF);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xfc
-****************************************************************************/
-static void x86emuOp_cld(u8 X86EMU_UNUSED(op1))
-{
- /* clear interrupts. */
- START_OF_INSTR();
- DECODE_PRINTF("CLD\n");
- TRACE_AND_STEP();
- CLEAR_FLAG(F_DF);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xfd
-****************************************************************************/
-static void x86emuOp_std(u8 X86EMU_UNUSED(op1))
-{
- /* clear interrupts. */
- START_OF_INSTR();
- DECODE_PRINTF("STD\n");
- TRACE_AND_STEP();
- SET_FLAG(F_DF);
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xfe
-****************************************************************************/
-static void x86emuOp_opcFE_byte_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rh, rl;
- u8 destval;
- uint destoffset;
- u8 *destreg;
-
- /* Yet another special case instruction. */
- START_OF_INSTR();
- FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
- if (DEBUG_DECODE()) {
- /* XXX DECODE_PRINTF may be changed to something more
- general, so that it is important to leave the strings
- in the same format, even though the result is that the
- above test is done twice. */
-
- switch (rh) {
- case 0:
- DECODE_PRINTF("INC\t");
- break;
- case 1:
- DECODE_PRINTF("DEC\t");
- break;
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- DECODE_PRINTF2("ILLEGAL OP MAJOR OP 0xFE MINOR OP %x \n", mod);
- HALT_SYS();
- break;
- }
- }
-#endif
- switch (mod) {
- case 0:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- switch (rh) {
- case 0: /* inc word ptr ... */
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = inc_byte(destval);
- store_data_byte(destoffset, destval);
- break;
- case 1: /* dec word ptr ... */
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = dec_byte(destval);
- store_data_byte(destoffset, destval);
- break;
- }
- break;
- case 1:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- switch (rh) {
- case 0:
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = inc_byte(destval);
- store_data_byte(destoffset, destval);
- break;
- case 1:
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = dec_byte(destval);
- store_data_byte(destoffset, destval);
- break;
- }
- break;
- case 2:
- DECODE_PRINTF("BYTE PTR ");
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- switch (rh) {
- case 0:
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = inc_byte(destval);
- store_data_byte(destoffset, destval);
- break;
- case 1:
- destval = fetch_data_byte(destoffset);
- TRACE_AND_STEP();
- destval = dec_byte(destval);
- store_data_byte(destoffset, destval);
- break;
- }
- break;
- case 3:
- destreg = DECODE_RM_BYTE_REGISTER(rl);
- DECODE_PRINTF("\n");
- switch (rh) {
- case 0:
- TRACE_AND_STEP();
- *destreg = inc_byte(*destreg);
- break;
- case 1:
- TRACE_AND_STEP();
- *destreg = dec_byte(*destreg);
- break;
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/****************************************************************************
-REMARKS:
-Handles opcode 0xff
-****************************************************************************/
-static void x86emuOp_opcFF_word_RM(u8 X86EMU_UNUSED(op1))
-{
- int mod, rh, rl;
- uint destoffset = 0;
- u16 *destreg;
- u16 destval,destval2;
-
- /* Yet another special case instruction. */
- START_OF_INSTR();
- FETCH_DECODE_MODRM(mod, rh, rl);
-#ifdef DEBUG
- if (DEBUG_DECODE()) {
- /* XXX DECODE_PRINTF may be changed to something more
- general, so that it is important to leave the strings
- in the same format, even though the result is that the
- above test is done twice. */
-
- switch (rh) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("INC\tDWORD PTR ");
- } else {
- DECODE_PRINTF("INC\tWORD PTR ");
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- DECODE_PRINTF("DEC\tDWORD PTR ");
- } else {
- DECODE_PRINTF("DEC\tWORD PTR ");
- }
- break;
- case 2:
- DECODE_PRINTF("CALL\t");
- break;
- case 3:
- DECODE_PRINTF("CALL\tFAR ");
- break;
- case 4:
- DECODE_PRINTF("JMP\t");
- break;
- case 5:
- DECODE_PRINTF("JMP\tFAR ");
- break;
- case 6:
- DECODE_PRINTF("PUSH\t");
- break;
- case 7:
- DECODE_PRINTF("ILLEGAL DECODING OF OPCODE FF\t");
- HALT_SYS();
- break;
- }
- }
-#endif
- switch (mod) {
- case 0:
- destoffset = decode_rm00_address(rl);
- DECODE_PRINTF("\n");
- switch (rh) {
- case 0: /* inc word ptr ... */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = inc_long(destval);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = inc_word(destval);
- store_data_word(destoffset, destval);
- }
- break;
- case 1: /* dec word ptr ... */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = dec_long(destval);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = dec_word(destval);
- store_data_word(destoffset, destval);
- }
- break;
- case 2: /* call word ptr ... */
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- push_word(M.x86.R_IP);
- M.x86.R_IP = destval;
- break;
- case 3: /* call far ptr ... */
- destval = fetch_data_word(destoffset);
- destval2 = fetch_data_word(destoffset + 2);
- TRACE_AND_STEP();
- push_word(M.x86.R_CS);
- M.x86.R_CS = destval2;
- push_word(M.x86.R_IP);
- M.x86.R_IP = destval;
- break;
- case 4: /* jmp word ptr ... */
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- M.x86.R_IP = destval;
- break;
- case 5: /* jmp far ptr ... */
- destval = fetch_data_word(destoffset);
- destval2 = fetch_data_word(destoffset + 2);
- TRACE_AND_STEP();
- M.x86.R_IP = destval;
- M.x86.R_CS = destval2;
- break;
- case 6: /* push word ptr ... */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- push_long(destval);
- } else {
- u16 destval;
-
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- push_word(destval);
- }
- break;
- }
- break;
- case 1:
- destoffset = decode_rm01_address(rl);
- DECODE_PRINTF("\n");
- switch (rh) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = inc_long(destval);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = inc_word(destval);
- store_data_word(destoffset, destval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = dec_long(destval);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = dec_word(destval);
- store_data_word(destoffset, destval);
- }
- break;
- case 2: /* call word ptr ... */
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- push_word(M.x86.R_IP);
- M.x86.R_IP = destval;
- break;
- case 3: /* call far ptr ... */
- destval = fetch_data_word(destoffset);
- destval2 = fetch_data_word(destoffset + 2);
- TRACE_AND_STEP();
- push_word(M.x86.R_CS);
- M.x86.R_CS = destval2;
- push_word(M.x86.R_IP);
- M.x86.R_IP = destval;
- break;
- case 4: /* jmp word ptr ... */
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- M.x86.R_IP = destval;
- break;
- case 5: /* jmp far ptr ... */
- destval = fetch_data_word(destoffset);
- destval2 = fetch_data_word(destoffset + 2);
- TRACE_AND_STEP();
- M.x86.R_IP = destval;
- M.x86.R_CS = destval2;
- break;
- case 6: /* push word ptr ... */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- push_long(destval);
- } else {
- u16 destval;
-
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- push_word(destval);
- }
- break;
- }
- break;
- case 2:
- destoffset = decode_rm10_address(rl);
- DECODE_PRINTF("\n");
- switch (rh) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = inc_long(destval);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = inc_word(destval);
- store_data_word(destoffset, destval);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- destval = dec_long(destval);
- store_data_long(destoffset, destval);
- } else {
- u16 destval;
-
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- destval = dec_word(destval);
- store_data_word(destoffset, destval);
- }
- break;
- case 2: /* call word ptr ... */
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- push_word(M.x86.R_IP);
- M.x86.R_IP = destval;
- break;
- case 3: /* call far ptr ... */
- destval = fetch_data_word(destoffset);
- destval2 = fetch_data_word(destoffset + 2);
- TRACE_AND_STEP();
- push_word(M.x86.R_CS);
- M.x86.R_CS = destval2;
- push_word(M.x86.R_IP);
- M.x86.R_IP = destval;
- break;
- case 4: /* jmp word ptr ... */
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- M.x86.R_IP = destval;
- break;
- case 5: /* jmp far ptr ... */
- destval = fetch_data_word(destoffset);
- destval2 = fetch_data_word(destoffset + 2);
- TRACE_AND_STEP();
- M.x86.R_IP = destval;
- M.x86.R_CS = destval2;
- break;
- case 6: /* push word ptr ... */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
-
- destval = fetch_data_long(destoffset);
- TRACE_AND_STEP();
- push_long(destval);
- } else {
- u16 destval;
-
- destval = fetch_data_word(destoffset);
- TRACE_AND_STEP();
- push_word(destval);
- }
- break;
- }
- break;
- case 3:
- switch (rh) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = inc_long(*destreg);
- } else {
- u16 *destreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = inc_word(*destreg);
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = dec_long(*destreg);
- } else {
- u16 *destreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- *destreg = dec_word(*destreg);
- }
- break;
- case 2: /* call word ptr ... */
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- push_word(M.x86.R_IP);
- M.x86.R_IP = *destreg;
- break;
- case 3: /* jmp far ptr ... */
- DECODE_PRINTF("OPERATION UNDEFINED 0XFF \n");
- TRACE_AND_STEP();
- HALT_SYS();
- break;
-
- case 4: /* jmp ... */
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- M.x86.R_IP = (u16) (*destreg);
- break;
- case 5: /* jmp far ptr ... */
- DECODE_PRINTF("OPERATION UNDEFINED 0XFF \n");
- TRACE_AND_STEP();
- HALT_SYS();
- break;
- case 6:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
-
- destreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- push_long(*destreg);
- } else {
- u16 *destreg;
-
- destreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF("\n");
- TRACE_AND_STEP();
- push_word(*destreg);
- }
- break;
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
-}
-
-/***************************************************************************
- * Single byte operation code table:
- **************************************************************************/
-void (*x86emu_optab[256])(u8) =
-{
-/* 0x00 */ x86emuOp_add_byte_RM_R,
-/* 0x01 */ x86emuOp_add_word_RM_R,
-/* 0x02 */ x86emuOp_add_byte_R_RM,
-/* 0x03 */ x86emuOp_add_word_R_RM,
-/* 0x04 */ x86emuOp_add_byte_AL_IMM,
-/* 0x05 */ x86emuOp_add_word_AX_IMM,
-/* 0x06 */ x86emuOp_push_ES,
-/* 0x07 */ x86emuOp_pop_ES,
-
-/* 0x08 */ x86emuOp_or_byte_RM_R,
-/* 0x09 */ x86emuOp_or_word_RM_R,
-/* 0x0a */ x86emuOp_or_byte_R_RM,
-/* 0x0b */ x86emuOp_or_word_R_RM,
-/* 0x0c */ x86emuOp_or_byte_AL_IMM,
-/* 0x0d */ x86emuOp_or_word_AX_IMM,
-/* 0x0e */ x86emuOp_push_CS,
-/* 0x0f */ x86emuOp_two_byte,
-
-/* 0x10 */ x86emuOp_adc_byte_RM_R,
-/* 0x11 */ x86emuOp_adc_word_RM_R,
-/* 0x12 */ x86emuOp_adc_byte_R_RM,
-/* 0x13 */ x86emuOp_adc_word_R_RM,
-/* 0x14 */ x86emuOp_adc_byte_AL_IMM,
-/* 0x15 */ x86emuOp_adc_word_AX_IMM,
-/* 0x16 */ x86emuOp_push_SS,
-/* 0x17 */ x86emuOp_pop_SS,
-
-/* 0x18 */ x86emuOp_sbb_byte_RM_R,
-/* 0x19 */ x86emuOp_sbb_word_RM_R,
-/* 0x1a */ x86emuOp_sbb_byte_R_RM,
-/* 0x1b */ x86emuOp_sbb_word_R_RM,
-/* 0x1c */ x86emuOp_sbb_byte_AL_IMM,
-/* 0x1d */ x86emuOp_sbb_word_AX_IMM,
-/* 0x1e */ x86emuOp_push_DS,
-/* 0x1f */ x86emuOp_pop_DS,
-
-/* 0x20 */ x86emuOp_and_byte_RM_R,
-/* 0x21 */ x86emuOp_and_word_RM_R,
-/* 0x22 */ x86emuOp_and_byte_R_RM,
-/* 0x23 */ x86emuOp_and_word_R_RM,
-/* 0x24 */ x86emuOp_and_byte_AL_IMM,
-/* 0x25 */ x86emuOp_and_word_AX_IMM,
-/* 0x26 */ x86emuOp_segovr_ES,
-/* 0x27 */ x86emuOp_daa,
-
-/* 0x28 */ x86emuOp_sub_byte_RM_R,
-/* 0x29 */ x86emuOp_sub_word_RM_R,
-/* 0x2a */ x86emuOp_sub_byte_R_RM,
-/* 0x2b */ x86emuOp_sub_word_R_RM,
-/* 0x2c */ x86emuOp_sub_byte_AL_IMM,
-/* 0x2d */ x86emuOp_sub_word_AX_IMM,
-/* 0x2e */ x86emuOp_segovr_CS,
-/* 0x2f */ x86emuOp_das,
-
-/* 0x30 */ x86emuOp_xor_byte_RM_R,
-/* 0x31 */ x86emuOp_xor_word_RM_R,
-/* 0x32 */ x86emuOp_xor_byte_R_RM,
-/* 0x33 */ x86emuOp_xor_word_R_RM,
-/* 0x34 */ x86emuOp_xor_byte_AL_IMM,
-/* 0x35 */ x86emuOp_xor_word_AX_IMM,
-/* 0x36 */ x86emuOp_segovr_SS,
-/* 0x37 */ x86emuOp_aaa,
-
-/* 0x38 */ x86emuOp_cmp_byte_RM_R,
-/* 0x39 */ x86emuOp_cmp_word_RM_R,
-/* 0x3a */ x86emuOp_cmp_byte_R_RM,
-/* 0x3b */ x86emuOp_cmp_word_R_RM,
-/* 0x3c */ x86emuOp_cmp_byte_AL_IMM,
-/* 0x3d */ x86emuOp_cmp_word_AX_IMM,
-/* 0x3e */ x86emuOp_segovr_DS,
-/* 0x3f */ x86emuOp_aas,
-
-/* 0x40 */ x86emuOp_inc_AX,
-/* 0x41 */ x86emuOp_inc_CX,
-/* 0x42 */ x86emuOp_inc_DX,
-/* 0x43 */ x86emuOp_inc_BX,
-/* 0x44 */ x86emuOp_inc_SP,
-/* 0x45 */ x86emuOp_inc_BP,
-/* 0x46 */ x86emuOp_inc_SI,
-/* 0x47 */ x86emuOp_inc_DI,
-
-/* 0x48 */ x86emuOp_dec_AX,
-/* 0x49 */ x86emuOp_dec_CX,
-/* 0x4a */ x86emuOp_dec_DX,
-/* 0x4b */ x86emuOp_dec_BX,
-/* 0x4c */ x86emuOp_dec_SP,
-/* 0x4d */ x86emuOp_dec_BP,
-/* 0x4e */ x86emuOp_dec_SI,
-/* 0x4f */ x86emuOp_dec_DI,
-
-/* 0x50 */ x86emuOp_push_AX,
-/* 0x51 */ x86emuOp_push_CX,
-/* 0x52 */ x86emuOp_push_DX,
-/* 0x53 */ x86emuOp_push_BX,
-/* 0x54 */ x86emuOp_push_SP,
-/* 0x55 */ x86emuOp_push_BP,
-/* 0x56 */ x86emuOp_push_SI,
-/* 0x57 */ x86emuOp_push_DI,
-
-/* 0x58 */ x86emuOp_pop_AX,
-/* 0x59 */ x86emuOp_pop_CX,
-/* 0x5a */ x86emuOp_pop_DX,
-/* 0x5b */ x86emuOp_pop_BX,
-/* 0x5c */ x86emuOp_pop_SP,
-/* 0x5d */ x86emuOp_pop_BP,
-/* 0x5e */ x86emuOp_pop_SI,
-/* 0x5f */ x86emuOp_pop_DI,
-
-/* 0x60 */ x86emuOp_push_all,
-/* 0x61 */ x86emuOp_pop_all,
-/* 0x62 */ x86emuOp_illegal_op, /* bound */
-/* 0x63 */ x86emuOp_illegal_op, /* arpl */
-/* 0x64 */ x86emuOp_segovr_FS,
-/* 0x65 */ x86emuOp_segovr_GS,
-/* 0x66 */ x86emuOp_prefix_data,
-/* 0x67 */ x86emuOp_prefix_addr,
-
-/* 0x68 */ x86emuOp_push_word_IMM,
-/* 0x69 */ x86emuOp_imul_word_IMM,
-/* 0x6a */ x86emuOp_push_byte_IMM,
-/* 0x6b */ x86emuOp_imul_byte_IMM,
-/* 0x6c */ x86emuOp_ins_byte,
-/* 0x6d */ x86emuOp_ins_word,
-/* 0x6e */ x86emuOp_outs_byte,
-/* 0x6f */ x86emuOp_outs_word,
-
-/* 0x70 */ x86emuOp_jump_near_O,
-/* 0x71 */ x86emuOp_jump_near_NO,
-/* 0x72 */ x86emuOp_jump_near_B,
-/* 0x73 */ x86emuOp_jump_near_NB,
-/* 0x74 */ x86emuOp_jump_near_Z,
-/* 0x75 */ x86emuOp_jump_near_NZ,
-/* 0x76 */ x86emuOp_jump_near_BE,
-/* 0x77 */ x86emuOp_jump_near_NBE,
-
-/* 0x78 */ x86emuOp_jump_near_S,
-/* 0x79 */ x86emuOp_jump_near_NS,
-/* 0x7a */ x86emuOp_jump_near_P,
-/* 0x7b */ x86emuOp_jump_near_NP,
-/* 0x7c */ x86emuOp_jump_near_L,
-/* 0x7d */ x86emuOp_jump_near_NL,
-/* 0x7e */ x86emuOp_jump_near_LE,
-/* 0x7f */ x86emuOp_jump_near_NLE,
-
-/* 0x80 */ x86emuOp_opc80_byte_RM_IMM,
-/* 0x81 */ x86emuOp_opc81_word_RM_IMM,
-/* 0x82 */ x86emuOp_opc82_byte_RM_IMM,
-/* 0x83 */ x86emuOp_opc83_word_RM_IMM,
-/* 0x84 */ x86emuOp_test_byte_RM_R,
-/* 0x85 */ x86emuOp_test_word_RM_R,
-/* 0x86 */ x86emuOp_xchg_byte_RM_R,
-/* 0x87 */ x86emuOp_xchg_word_RM_R,
-
-/* 0x88 */ x86emuOp_mov_byte_RM_R,
-/* 0x89 */ x86emuOp_mov_word_RM_R,
-/* 0x8a */ x86emuOp_mov_byte_R_RM,
-/* 0x8b */ x86emuOp_mov_word_R_RM,
-/* 0x8c */ x86emuOp_mov_word_RM_SR,
-/* 0x8d */ x86emuOp_lea_word_R_M,
-/* 0x8e */ x86emuOp_mov_word_SR_RM,
-/* 0x8f */ x86emuOp_pop_RM,
-
-/* 0x90 */ x86emuOp_nop,
-/* 0x91 */ x86emuOp_xchg_word_AX_CX,
-/* 0x92 */ x86emuOp_xchg_word_AX_DX,
-/* 0x93 */ x86emuOp_xchg_word_AX_BX,
-/* 0x94 */ x86emuOp_xchg_word_AX_SP,
-/* 0x95 */ x86emuOp_xchg_word_AX_BP,
-/* 0x96 */ x86emuOp_xchg_word_AX_SI,
-/* 0x97 */ x86emuOp_xchg_word_AX_DI,
-
-/* 0x98 */ x86emuOp_cbw,
-/* 0x99 */ x86emuOp_cwd,
-/* 0x9a */ x86emuOp_call_far_IMM,
-/* 0x9b */ x86emuOp_wait,
-/* 0x9c */ x86emuOp_pushf_word,
-/* 0x9d */ x86emuOp_popf_word,
-/* 0x9e */ x86emuOp_sahf,
-/* 0x9f */ x86emuOp_lahf,
-
-/* 0xa0 */ x86emuOp_mov_AL_M_IMM,
-/* 0xa1 */ x86emuOp_mov_AX_M_IMM,
-/* 0xa2 */ x86emuOp_mov_M_AL_IMM,
-/* 0xa3 */ x86emuOp_mov_M_AX_IMM,
-/* 0xa4 */ x86emuOp_movs_byte,
-/* 0xa5 */ x86emuOp_movs_word,
-/* 0xa6 */ x86emuOp_cmps_byte,
-/* 0xa7 */ x86emuOp_cmps_word,
-/* 0xa8 */ x86emuOp_test_AL_IMM,
-/* 0xa9 */ x86emuOp_test_AX_IMM,
-/* 0xaa */ x86emuOp_stos_byte,
-/* 0xab */ x86emuOp_stos_word,
-/* 0xac */ x86emuOp_lods_byte,
-/* 0xad */ x86emuOp_lods_word,
-/* 0xac */ x86emuOp_scas_byte,
-/* 0xad */ x86emuOp_scas_word,
-
-
-/* 0xb0 */ x86emuOp_mov_byte_AL_IMM,
-/* 0xb1 */ x86emuOp_mov_byte_CL_IMM,
-/* 0xb2 */ x86emuOp_mov_byte_DL_IMM,
-/* 0xb3 */ x86emuOp_mov_byte_BL_IMM,
-/* 0xb4 */ x86emuOp_mov_byte_AH_IMM,
-/* 0xb5 */ x86emuOp_mov_byte_CH_IMM,
-/* 0xb6 */ x86emuOp_mov_byte_DH_IMM,
-/* 0xb7 */ x86emuOp_mov_byte_BH_IMM,
-
-/* 0xb8 */ x86emuOp_mov_word_AX_IMM,
-/* 0xb9 */ x86emuOp_mov_word_CX_IMM,
-/* 0xba */ x86emuOp_mov_word_DX_IMM,
-/* 0xbb */ x86emuOp_mov_word_BX_IMM,
-/* 0xbc */ x86emuOp_mov_word_SP_IMM,
-/* 0xbd */ x86emuOp_mov_word_BP_IMM,
-/* 0xbe */ x86emuOp_mov_word_SI_IMM,
-/* 0xbf */ x86emuOp_mov_word_DI_IMM,
-
-/* 0xc0 */ x86emuOp_opcC0_byte_RM_MEM,
-/* 0xc1 */ x86emuOp_opcC1_word_RM_MEM,
-/* 0xc2 */ x86emuOp_ret_near_IMM,
-/* 0xc3 */ x86emuOp_ret_near,
-/* 0xc4 */ x86emuOp_les_R_IMM,
-/* 0xc5 */ x86emuOp_lds_R_IMM,
-/* 0xc6 */ x86emuOp_mov_byte_RM_IMM,
-/* 0xc7 */ x86emuOp_mov_word_RM_IMM,
-/* 0xc8 */ x86emuOp_enter,
-/* 0xc9 */ x86emuOp_leave,
-/* 0xca */ x86emuOp_ret_far_IMM,
-/* 0xcb */ x86emuOp_ret_far,
-/* 0xcc */ x86emuOp_int3,
-/* 0xcd */ x86emuOp_int_IMM,
-/* 0xce */ x86emuOp_into,
-/* 0xcf */ x86emuOp_iret,
-
-/* 0xd0 */ x86emuOp_opcD0_byte_RM_1,
-/* 0xd1 */ x86emuOp_opcD1_word_RM_1,
-/* 0xd2 */ x86emuOp_opcD2_byte_RM_CL,
-/* 0xd3 */ x86emuOp_opcD3_word_RM_CL,
-/* 0xd4 */ x86emuOp_aam,
-/* 0xd5 */ x86emuOp_aad,
-/* 0xd6 */ x86emuOp_illegal_op, /* Undocumented SETALC instruction */
-/* 0xd7 */ x86emuOp_xlat,
-/* 0xd8 */ x86emuOp_esc_coprocess_d8,
-/* 0xd9 */ x86emuOp_esc_coprocess_d9,
-/* 0xda */ x86emuOp_esc_coprocess_da,
-/* 0xdb */ x86emuOp_esc_coprocess_db,
-/* 0xdc */ x86emuOp_esc_coprocess_dc,
-/* 0xdd */ x86emuOp_esc_coprocess_dd,
-/* 0xde */ x86emuOp_esc_coprocess_de,
-/* 0xdf */ x86emuOp_esc_coprocess_df,
-
-/* 0xe0 */ x86emuOp_loopne,
-/* 0xe1 */ x86emuOp_loope,
-/* 0xe2 */ x86emuOp_loop,
-/* 0xe3 */ x86emuOp_jcxz,
-/* 0xe4 */ x86emuOp_in_byte_AL_IMM,
-/* 0xe5 */ x86emuOp_in_word_AX_IMM,
-/* 0xe6 */ x86emuOp_out_byte_IMM_AL,
-/* 0xe7 */ x86emuOp_out_word_IMM_AX,
-
-/* 0xe8 */ x86emuOp_call_near_IMM,
-/* 0xe9 */ x86emuOp_jump_near_IMM,
-/* 0xea */ x86emuOp_jump_far_IMM,
-/* 0xeb */ x86emuOp_jump_byte_IMM,
-/* 0xec */ x86emuOp_in_byte_AL_DX,
-/* 0xed */ x86emuOp_in_word_AX_DX,
-/* 0xee */ x86emuOp_out_byte_DX_AL,
-/* 0xef */ x86emuOp_out_word_DX_AX,
-
-/* 0xf0 */ x86emuOp_lock,
-/* 0xf1 */ x86emuOp_illegal_op,
-/* 0xf2 */ x86emuOp_repne,
-/* 0xf3 */ x86emuOp_repe,
-/* 0xf4 */ x86emuOp_halt,
-/* 0xf5 */ x86emuOp_cmc,
-/* 0xf6 */ x86emuOp_opcF6_byte_RM,
-/* 0xf7 */ x86emuOp_opcF7_word_RM,
-
-/* 0xf8 */ x86emuOp_clc,
-/* 0xf9 */ x86emuOp_stc,
-/* 0xfa */ x86emuOp_cli,
-/* 0xfb */ x86emuOp_sti,
-/* 0xfc */ x86emuOp_cld,
-/* 0xfd */ x86emuOp_std,
-/* 0xfe */ x86emuOp_opcFE_byte_RM,
-/* 0xff */ x86emuOp_opcFF_word_RM,
-};
+/****************************************************************************
+*
+* Realmode X86 Emulator Library
+*
+* Copyright (C) 1996-1999 SciTech Software, Inc.
+* Copyright (C) David Mosberger-Tang
+* Copyright (C) 1999 Egbert Eich
+*
+* ========================================================================
+*
+* Permission to use, copy, modify, distribute, and sell this software and
+* its documentation for any purpose is hereby granted without fee,
+* provided that the above copyright notice appear in all copies and that
+* both that copyright notice and this permission notice appear in
+* supporting documentation, and that the name of the authors not be used
+* in advertising or publicity pertaining to distribution of the software
+* without specific, written prior permission. The authors makes no
+* representations about the suitability of this software for any purpose.
+* It is provided "as is" without express or implied warranty.
+*
+* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+* PERFORMANCE OF THIS SOFTWARE.
+*
+* ========================================================================
+*
+* Language: ANSI C
+* Environment: Any
+* Developer: Kendall Bennett
+*
+* Description: This file includes subroutines to implement the decoding
+* and emulation of all the x86 processor instructions.
+*
+* There are approximately 250 subroutines in here, which correspond
+* to the 256 byte-"opcodes" found on the 8086. The table which
+* dispatches this is found in the files optab.[ch].
+*
+* Each opcode proc has a comment preceeding it which gives it's table
+* address. Several opcodes are missing (undefined) in the table.
+*
+* Each proc includes information for decoding (DECODE_PRINTF and
+* DECODE_PRINTF2), debugging (TRACE_REGS, SINGLE_STEP), and misc
+* functions (START_OF_INSTR, END_OF_INSTR).
+*
+* Many of the procedures are *VERY* similar in coding. This has
+* allowed for a very large amount of code to be generated in a fairly
+* short amount of time (i.e. cut, paste, and modify). The result is
+* that much of the code below could have been folded into subroutines
+* for a large reduction in size of this file. The downside would be
+* that there would be a penalty in execution speed. The file could
+* also have been *MUCH* larger by inlining certain functions which
+* were called. This could have resulted even faster execution. The
+* prime directive I used to decide whether to inline the code or to
+* modularize it, was basically: 1) no unnecessary subroutine calls,
+* 2) no routines more than about 200 lines in size, and 3) modularize
+* any code that I might not get right the first time. The fetch_*
+* subroutines fall into the latter category. The The decode_* fall
+* into the second category. The coding of the "switch(mod){ .... }"
+* in many of the subroutines below falls into the first category.
+* Especially, the coding of {add,and,or,sub,...}_{byte,word}
+* subroutines are an especially glaring case of the third guideline.
+* Since so much of the code is cloned from other modules (compare
+* opcode #00 to opcode #01), making the basic operations subroutine
+* calls is especially important; otherwise mistakes in coding an
+* "add" would represent a nightmare in maintenance.
+*
+****************************************************************************/
+
+#include "x86emu/x86emui.h"
+
+/*----------------------------- Implementation ----------------------------*/
+
+/****************************************************************************
+PARAMETERS:
+op1 - Instruction op code
+
+REMARKS:
+Handles illegal opcodes.
+****************************************************************************/
+static void
+x86emuOp_illegal_op(u8 op1)
+{
+ START_OF_INSTR();
+ if (M.x86.R_SP != 0) {
+ DECODE_PRINTF("ILLEGAL X86 OPCODE\n");
+ TRACE_REGS();
+ DB(printk("%04x:%04x: %02X ILLEGAL X86 OPCODE!\n",
+ M.x86.R_CS, M.x86.R_IP - 1, op1));
+ HALT_SYS();
+ }
+ else {
+ /* If we get here, it means the stack pointer is back to zero
+ * so we are just returning from an emulator service call
+ * so therte is no need to display an error message. We trap
+ * the emulator with an 0xF1 opcode to finish the service
+ * call.
+ */
+ X86EMU_halt_sys();
+ }
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x00
+****************************************************************************/
+static void
+x86emuOp_add_byte_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+ u8 *destreg, *srcreg;
+ u8 destval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("ADD\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = add_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+ case 1:
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = add_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+ case 2:
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = add_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = add_byte(*destreg, *srcreg);
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x01
+****************************************************************************/
+static void
+x86emuOp_add_word_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("ADD\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = add_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = add_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = add_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = add_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = add_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = add_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = add_long(*destreg, *srcreg);
+ }
+ else {
+ u16 *destreg, *srcreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = add_word(*destreg, *srcreg);
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x02
+****************************************************************************/
+static void
+x86emuOp_add_byte_R_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg, *srcreg;
+ uint srcoffset;
+ u8 srcval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("ADD\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = add_byte(*destreg, srcval);
+ break;
+ case 1:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = add_byte(*destreg, srcval);
+ break;
+ case 2:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = add_byte(*destreg, srcval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = add_byte(*destreg, *srcreg);
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x03
+****************************************************************************/
+static void
+x86emuOp_add_word_R_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint srcoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("ADD\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = add_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = add_word(*destreg, srcval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = add_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = add_word(*destreg, srcval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = add_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = add_word(*destreg, srcval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = add_long(*destreg, *srcreg);
+ }
+ else {
+ u16 *destreg, *srcreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = add_word(*destreg, *srcreg);
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x04
+****************************************************************************/
+static void
+x86emuOp_add_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u8 srcval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("ADD\tAL,");
+ srcval = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ M.x86.R_AL = add_byte(M.x86.R_AL, srcval);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x05
+****************************************************************************/
+static void
+x86emuOp_add_word_AX_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u32 srcval;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("ADD\tEAX,");
+ srcval = fetch_long_imm();
+ }
+ else {
+ DECODE_PRINTF("ADD\tAX,");
+ srcval = fetch_word_imm();
+ }
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EAX = add_long(M.x86.R_EAX, srcval);
+ }
+ else {
+ M.x86.R_AX = add_word(M.x86.R_AX, (u16) srcval);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x06
+****************************************************************************/
+static void
+x86emuOp_push_ES(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("PUSH\tES\n");
+ TRACE_AND_STEP();
+ push_word(M.x86.R_ES);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x07
+****************************************************************************/
+static void
+x86emuOp_pop_ES(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("POP\tES\n");
+ TRACE_AND_STEP();
+ M.x86.R_ES = pop_word();
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x08
+****************************************************************************/
+static void
+x86emuOp_or_byte_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg, *srcreg;
+ uint destoffset;
+ u8 destval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("OR\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = or_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+ case 1:
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = or_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+ case 2:
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = or_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = or_byte(*destreg, *srcreg);
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x09
+****************************************************************************/
+static void
+x86emuOp_or_word_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("OR\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = or_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = or_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = or_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = or_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = or_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = or_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = or_long(*destreg, *srcreg);
+ }
+ else {
+ u16 *destreg, *srcreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = or_word(*destreg, *srcreg);
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x0a
+****************************************************************************/
+static void
+x86emuOp_or_byte_R_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg, *srcreg;
+ uint srcoffset;
+ u8 srcval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("OR\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = or_byte(*destreg, srcval);
+ break;
+ case 1:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = or_byte(*destreg, srcval);
+ break;
+ case 2:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = or_byte(*destreg, srcval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = or_byte(*destreg, *srcreg);
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x0b
+****************************************************************************/
+static void
+x86emuOp_or_word_R_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint srcoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("OR\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = or_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = or_word(*destreg, srcval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = or_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = or_word(*destreg, srcval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = or_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = or_word(*destreg, srcval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = or_long(*destreg, *srcreg);
+ }
+ else {
+ u16 *destreg, *srcreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = or_word(*destreg, *srcreg);
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x0c
+****************************************************************************/
+static void
+x86emuOp_or_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u8 srcval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("OR\tAL,");
+ srcval = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ M.x86.R_AL = or_byte(M.x86.R_AL, srcval);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x0d
+****************************************************************************/
+static void
+x86emuOp_or_word_AX_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u32 srcval;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("OR\tEAX,");
+ srcval = fetch_long_imm();
+ }
+ else {
+ DECODE_PRINTF("OR\tAX,");
+ srcval = fetch_word_imm();
+ }
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EAX = or_long(M.x86.R_EAX, srcval);
+ }
+ else {
+ M.x86.R_AX = or_word(M.x86.R_AX, (u16) srcval);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x0e
+****************************************************************************/
+static void
+x86emuOp_push_CS(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("PUSH\tCS\n");
+ TRACE_AND_STEP();
+ push_word(M.x86.R_CS);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x0f. Escape for two-byte opcode (286 or better)
+****************************************************************************/
+static void
+x86emuOp_two_byte(u8 X86EMU_UNUSED(op1))
+{
+ u8 op2 = (*sys_rdb) (((u32) M.x86.R_CS << 4) + (M.x86.R_IP++));
+
+ INC_DECODED_INST_LEN(1);
+ (*x86emu_optab2[op2]) (op2);
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x10
+****************************************************************************/
+static void
+x86emuOp_adc_byte_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg, *srcreg;
+ uint destoffset;
+ u8 destval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("ADC\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = adc_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+ case 1:
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = adc_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+ case 2:
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = adc_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = adc_byte(*destreg, *srcreg);
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x11
+****************************************************************************/
+static void
+x86emuOp_adc_word_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("ADC\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = adc_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = adc_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = adc_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = adc_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = adc_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = adc_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = adc_long(*destreg, *srcreg);
+ }
+ else {
+ u16 *destreg, *srcreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = adc_word(*destreg, *srcreg);
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x12
+****************************************************************************/
+static void
+x86emuOp_adc_byte_R_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg, *srcreg;
+ uint srcoffset;
+ u8 srcval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("ADC\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = adc_byte(*destreg, srcval);
+ break;
+ case 1:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = adc_byte(*destreg, srcval);
+ break;
+ case 2:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = adc_byte(*destreg, srcval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = adc_byte(*destreg, *srcreg);
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x13
+****************************************************************************/
+static void
+x86emuOp_adc_word_R_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint srcoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("ADC\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = adc_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = adc_word(*destreg, srcval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = adc_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = adc_word(*destreg, srcval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = adc_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = adc_word(*destreg, srcval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = adc_long(*destreg, *srcreg);
+ }
+ else {
+ u16 *destreg, *srcreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = adc_word(*destreg, *srcreg);
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x14
+****************************************************************************/
+static void
+x86emuOp_adc_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u8 srcval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("ADC\tAL,");
+ srcval = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ M.x86.R_AL = adc_byte(M.x86.R_AL, srcval);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x15
+****************************************************************************/
+static void
+x86emuOp_adc_word_AX_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u32 srcval;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("ADC\tEAX,");
+ srcval = fetch_long_imm();
+ }
+ else {
+ DECODE_PRINTF("ADC\tAX,");
+ srcval = fetch_word_imm();
+ }
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EAX = adc_long(M.x86.R_EAX, srcval);
+ }
+ else {
+ M.x86.R_AX = adc_word(M.x86.R_AX, (u16) srcval);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x16
+****************************************************************************/
+static void
+x86emuOp_push_SS(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("PUSH\tSS\n");
+ TRACE_AND_STEP();
+ push_word(M.x86.R_SS);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x17
+****************************************************************************/
+static void
+x86emuOp_pop_SS(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("POP\tSS\n");
+ TRACE_AND_STEP();
+ M.x86.R_SS = pop_word();
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x18
+****************************************************************************/
+static void
+x86emuOp_sbb_byte_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg, *srcreg;
+ uint destoffset;
+ u8 destval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("SBB\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = sbb_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+ case 1:
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = sbb_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+ case 2:
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = sbb_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sbb_byte(*destreg, *srcreg);
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x19
+****************************************************************************/
+static void
+x86emuOp_sbb_word_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("SBB\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = sbb_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = sbb_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = sbb_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = sbb_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = sbb_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = sbb_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sbb_long(*destreg, *srcreg);
+ }
+ else {
+ u16 *destreg, *srcreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sbb_word(*destreg, *srcreg);
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x1a
+****************************************************************************/
+static void
+x86emuOp_sbb_byte_R_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg, *srcreg;
+ uint srcoffset;
+ u8 srcval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("SBB\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sbb_byte(*destreg, srcval);
+ break;
+ case 1:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sbb_byte(*destreg, srcval);
+ break;
+ case 2:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sbb_byte(*destreg, srcval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sbb_byte(*destreg, *srcreg);
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x1b
+****************************************************************************/
+static void
+x86emuOp_sbb_word_R_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint srcoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("SBB\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sbb_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sbb_word(*destreg, srcval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sbb_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sbb_word(*destreg, srcval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sbb_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sbb_word(*destreg, srcval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sbb_long(*destreg, *srcreg);
+ }
+ else {
+ u16 *destreg, *srcreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sbb_word(*destreg, *srcreg);
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x1c
+****************************************************************************/
+static void
+x86emuOp_sbb_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u8 srcval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("SBB\tAL,");
+ srcval = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ M.x86.R_AL = sbb_byte(M.x86.R_AL, srcval);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x1d
+****************************************************************************/
+static void
+x86emuOp_sbb_word_AX_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u32 srcval;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("SBB\tEAX,");
+ srcval = fetch_long_imm();
+ }
+ else {
+ DECODE_PRINTF("SBB\tAX,");
+ srcval = fetch_word_imm();
+ }
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EAX = sbb_long(M.x86.R_EAX, srcval);
+ }
+ else {
+ M.x86.R_AX = sbb_word(M.x86.R_AX, (u16) srcval);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x1e
+****************************************************************************/
+static void
+x86emuOp_push_DS(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("PUSH\tDS\n");
+ TRACE_AND_STEP();
+ push_word(M.x86.R_DS);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x1f
+****************************************************************************/
+static void
+x86emuOp_pop_DS(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("POP\tDS\n");
+ TRACE_AND_STEP();
+ M.x86.R_DS = pop_word();
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x20
+****************************************************************************/
+static void
+x86emuOp_and_byte_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg, *srcreg;
+ uint destoffset;
+ u8 destval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("AND\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+
+ switch (mod) {
+ case 0:
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = and_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+
+ case 1:
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = and_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+
+ case 2:
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = and_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = and_byte(*destreg, *srcreg);
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x21
+****************************************************************************/
+static void
+x86emuOp_and_word_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("AND\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = and_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = and_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = and_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = and_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = and_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = and_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = and_long(*destreg, *srcreg);
+ }
+ else {
+ u16 *destreg, *srcreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = and_word(*destreg, *srcreg);
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x22
+****************************************************************************/
+static void
+x86emuOp_and_byte_R_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg, *srcreg;
+ uint srcoffset;
+ u8 srcval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("AND\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = and_byte(*destreg, srcval);
+ break;
+ case 1:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = and_byte(*destreg, srcval);
+ break;
+ case 2:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = and_byte(*destreg, srcval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = and_byte(*destreg, *srcreg);
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x23
+****************************************************************************/
+static void
+x86emuOp_and_word_R_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint srcoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("AND\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = and_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = and_word(*destreg, srcval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = and_long(*destreg, srcval);
+ break;
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = and_word(*destreg, srcval);
+ break;
+ }
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = and_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = and_word(*destreg, srcval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = and_long(*destreg, *srcreg);
+ }
+ else {
+ u16 *destreg, *srcreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = and_word(*destreg, *srcreg);
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x24
+****************************************************************************/
+static void
+x86emuOp_and_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u8 srcval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("AND\tAL,");
+ srcval = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ M.x86.R_AL = and_byte(M.x86.R_AL, srcval);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x25
+****************************************************************************/
+static void
+x86emuOp_and_word_AX_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u32 srcval;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("AND\tEAX,");
+ srcval = fetch_long_imm();
+ }
+ else {
+ DECODE_PRINTF("AND\tAX,");
+ srcval = fetch_word_imm();
+ }
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EAX = and_long(M.x86.R_EAX, srcval);
+ }
+ else {
+ M.x86.R_AX = and_word(M.x86.R_AX, (u16) srcval);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x26
+****************************************************************************/
+static void
+x86emuOp_segovr_ES(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("ES:\n");
+ TRACE_AND_STEP();
+ M.x86.mode |= SYSMODE_SEGOVR_ES;
+ /*
+ * note the lack of DECODE_CLEAR_SEGOVR(r) since, here is one of 4
+ * opcode subroutines we do not want to do this.
+ */
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x27
+****************************************************************************/
+static void
+x86emuOp_daa(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("DAA\n");
+ TRACE_AND_STEP();
+ M.x86.R_AL = daa_byte(M.x86.R_AL);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x28
+****************************************************************************/
+static void
+x86emuOp_sub_byte_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg, *srcreg;
+ uint destoffset;
+ u8 destval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("SUB\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = sub_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+ case 1:
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = sub_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+ case 2:
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = sub_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sub_byte(*destreg, *srcreg);
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x29
+****************************************************************************/
+static void
+x86emuOp_sub_word_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("SUB\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = sub_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = sub_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = sub_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = sub_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = sub_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = sub_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sub_long(*destreg, *srcreg);
+ }
+ else {
+ u16 *destreg, *srcreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sub_word(*destreg, *srcreg);
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x2a
+****************************************************************************/
+static void
+x86emuOp_sub_byte_R_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg, *srcreg;
+ uint srcoffset;
+ u8 srcval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("SUB\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sub_byte(*destreg, srcval);
+ break;
+ case 1:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sub_byte(*destreg, srcval);
+ break;
+ case 2:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sub_byte(*destreg, srcval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sub_byte(*destreg, *srcreg);
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x2b
+****************************************************************************/
+static void
+x86emuOp_sub_word_R_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint srcoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("SUB\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sub_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sub_word(*destreg, srcval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sub_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sub_word(*destreg, srcval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sub_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sub_word(*destreg, srcval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sub_long(*destreg, *srcreg);
+ }
+ else {
+ u16 *destreg, *srcreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = sub_word(*destreg, *srcreg);
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x2c
+****************************************************************************/
+static void
+x86emuOp_sub_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u8 srcval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("SUB\tAL,");
+ srcval = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ M.x86.R_AL = sub_byte(M.x86.R_AL, srcval);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x2d
+****************************************************************************/
+static void
+x86emuOp_sub_word_AX_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u32 srcval;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("SUB\tEAX,");
+ srcval = fetch_long_imm();
+ }
+ else {
+ DECODE_PRINTF("SUB\tAX,");
+ srcval = fetch_word_imm();
+ }
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EAX = sub_long(M.x86.R_EAX, srcval);
+ }
+ else {
+ M.x86.R_AX = sub_word(M.x86.R_AX, (u16) srcval);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x2e
+****************************************************************************/
+static void
+x86emuOp_segovr_CS(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("CS:\n");
+ TRACE_AND_STEP();
+ M.x86.mode |= SYSMODE_SEGOVR_CS;
+ /* note no DECODE_CLEAR_SEGOVR here. */
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x2f
+****************************************************************************/
+static void
+x86emuOp_das(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("DAS\n");
+ TRACE_AND_STEP();
+ M.x86.R_AL = das_byte(M.x86.R_AL);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x30
+****************************************************************************/
+static void
+x86emuOp_xor_byte_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg, *srcreg;
+ uint destoffset;
+ u8 destval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("XOR\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = xor_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+ case 1:
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = xor_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+ case 2:
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = xor_byte(destval, *srcreg);
+ store_data_byte(destoffset, destval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = xor_byte(*destreg, *srcreg);
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x31
+****************************************************************************/
+static void
+x86emuOp_xor_word_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("XOR\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = xor_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = xor_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = xor_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = xor_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = xor_long(destval, *srcreg);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = xor_word(destval, *srcreg);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = xor_long(*destreg, *srcreg);
+ }
+ else {
+ u16 *destreg, *srcreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = xor_word(*destreg, *srcreg);
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x32
+****************************************************************************/
+static void
+x86emuOp_xor_byte_R_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg, *srcreg;
+ uint srcoffset;
+ u8 srcval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("XOR\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = xor_byte(*destreg, srcval);
+ break;
+ case 1:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = xor_byte(*destreg, srcval);
+ break;
+ case 2:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = xor_byte(*destreg, srcval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = xor_byte(*destreg, *srcreg);
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x33
+****************************************************************************/
+static void
+x86emuOp_xor_word_R_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint srcoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("XOR\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = xor_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = xor_word(*destreg, srcval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = xor_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = xor_word(*destreg, srcval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = xor_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = xor_word(*destreg, srcval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = xor_long(*destreg, *srcreg);
+ }
+ else {
+ u16 *destreg, *srcreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = xor_word(*destreg, *srcreg);
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x34
+****************************************************************************/
+static void
+x86emuOp_xor_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u8 srcval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("XOR\tAL,");
+ srcval = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ M.x86.R_AL = xor_byte(M.x86.R_AL, srcval);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x35
+****************************************************************************/
+static void
+x86emuOp_xor_word_AX_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u32 srcval;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("XOR\tEAX,");
+ srcval = fetch_long_imm();
+ }
+ else {
+ DECODE_PRINTF("XOR\tAX,");
+ srcval = fetch_word_imm();
+ }
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EAX = xor_long(M.x86.R_EAX, srcval);
+ }
+ else {
+ M.x86.R_AX = xor_word(M.x86.R_AX, (u16) srcval);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x36
+****************************************************************************/
+static void
+x86emuOp_segovr_SS(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("SS:\n");
+ TRACE_AND_STEP();
+ M.x86.mode |= SYSMODE_SEGOVR_SS;
+ /* no DECODE_CLEAR_SEGOVR ! */
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x37
+****************************************************************************/
+static void
+x86emuOp_aaa(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("AAA\n");
+ TRACE_AND_STEP();
+ M.x86.R_AX = aaa_word(M.x86.R_AX);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x38
+****************************************************************************/
+static void
+x86emuOp_cmp_byte_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+ u8 *destreg, *srcreg;
+ u8 destval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("CMP\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_byte(destval, *srcreg);
+ break;
+ case 1:
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_byte(destval, *srcreg);
+ break;
+ case 2:
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_byte(destval, *srcreg);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_byte(*destreg, *srcreg);
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x39
+****************************************************************************/
+static void
+x86emuOp_cmp_word_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("CMP\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_long(destval, *srcreg);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_word(destval, *srcreg);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_long(destval, *srcreg);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_word(destval, *srcreg);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_long(destval, *srcreg);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_word(destval, *srcreg);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_long(*destreg, *srcreg);
+ }
+ else {
+ u16 *destreg, *srcreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_word(*destreg, *srcreg);
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x3a
+****************************************************************************/
+static void
+x86emuOp_cmp_byte_R_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg, *srcreg;
+ uint srcoffset;
+ u8 srcval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("CMP\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_byte(*destreg, srcval);
+ break;
+ case 1:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_byte(*destreg, srcval);
+ break;
+ case 2:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_byte(*destreg, srcval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_byte(*destreg, *srcreg);
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x3b
+****************************************************************************/
+static void
+x86emuOp_cmp_word_R_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint srcoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("CMP\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_word(*destreg, srcval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_word(*destreg, srcval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_word(*destreg, srcval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_long(*destreg, *srcreg);
+ }
+ else {
+ u16 *destreg, *srcreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ cmp_word(*destreg, *srcreg);
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x3c
+****************************************************************************/
+static void
+x86emuOp_cmp_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u8 srcval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("CMP\tAL,");
+ srcval = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ cmp_byte(M.x86.R_AL, srcval);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x3d
+****************************************************************************/
+static void
+x86emuOp_cmp_word_AX_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u32 srcval;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("CMP\tEAX,");
+ srcval = fetch_long_imm();
+ }
+ else {
+ DECODE_PRINTF("CMP\tAX,");
+ srcval = fetch_word_imm();
+ }
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ cmp_long(M.x86.R_EAX, srcval);
+ }
+ else {
+ cmp_word(M.x86.R_AX, (u16) srcval);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x3e
+****************************************************************************/
+static void
+x86emuOp_segovr_DS(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("DS:\n");
+ TRACE_AND_STEP();
+ M.x86.mode |= SYSMODE_SEGOVR_DS;
+ /* NO DECODE_CLEAR_SEGOVR! */
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x3f
+****************************************************************************/
+static void
+x86emuOp_aas(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("AAS\n");
+ TRACE_AND_STEP();
+ M.x86.R_AX = aas_word(M.x86.R_AX);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x40
+****************************************************************************/
+static void
+x86emuOp_inc_AX(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("INC\tEAX\n");
+ }
+ else {
+ DECODE_PRINTF("INC\tAX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EAX = inc_long(M.x86.R_EAX);
+ }
+ else {
+ M.x86.R_AX = inc_word(M.x86.R_AX);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x41
+****************************************************************************/
+static void
+x86emuOp_inc_CX(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("INC\tECX\n");
+ }
+ else {
+ DECODE_PRINTF("INC\tCX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_ECX = inc_long(M.x86.R_ECX);
+ }
+ else {
+ M.x86.R_CX = inc_word(M.x86.R_CX);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x42
+****************************************************************************/
+static void
+x86emuOp_inc_DX(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("INC\tEDX\n");
+ }
+ else {
+ DECODE_PRINTF("INC\tDX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EDX = inc_long(M.x86.R_EDX);
+ }
+ else {
+ M.x86.R_DX = inc_word(M.x86.R_DX);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x43
+****************************************************************************/
+static void
+x86emuOp_inc_BX(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("INC\tEBX\n");
+ }
+ else {
+ DECODE_PRINTF("INC\tBX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EBX = inc_long(M.x86.R_EBX);
+ }
+ else {
+ M.x86.R_BX = inc_word(M.x86.R_BX);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x44
+****************************************************************************/
+static void
+x86emuOp_inc_SP(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("INC\tESP\n");
+ }
+ else {
+ DECODE_PRINTF("INC\tSP\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_ESP = inc_long(M.x86.R_ESP);
+ }
+ else {
+ M.x86.R_SP = inc_word(M.x86.R_SP);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x45
+****************************************************************************/
+static void
+x86emuOp_inc_BP(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("INC\tEBP\n");
+ }
+ else {
+ DECODE_PRINTF("INC\tBP\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EBP = inc_long(M.x86.R_EBP);
+ }
+ else {
+ M.x86.R_BP = inc_word(M.x86.R_BP);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x46
+****************************************************************************/
+static void
+x86emuOp_inc_SI(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("INC\tESI\n");
+ }
+ else {
+ DECODE_PRINTF("INC\tSI\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_ESI = inc_long(M.x86.R_ESI);
+ }
+ else {
+ M.x86.R_SI = inc_word(M.x86.R_SI);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x47
+****************************************************************************/
+static void
+x86emuOp_inc_DI(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("INC\tEDI\n");
+ }
+ else {
+ DECODE_PRINTF("INC\tDI\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EDI = inc_long(M.x86.R_EDI);
+ }
+ else {
+ M.x86.R_DI = inc_word(M.x86.R_DI);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x48
+****************************************************************************/
+static void
+x86emuOp_dec_AX(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("DEC\tEAX\n");
+ }
+ else {
+ DECODE_PRINTF("DEC\tAX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EAX = dec_long(M.x86.R_EAX);
+ }
+ else {
+ M.x86.R_AX = dec_word(M.x86.R_AX);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x49
+****************************************************************************/
+static void
+x86emuOp_dec_CX(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("DEC\tECX\n");
+ }
+ else {
+ DECODE_PRINTF("DEC\tCX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_ECX = dec_long(M.x86.R_ECX);
+ }
+ else {
+ M.x86.R_CX = dec_word(M.x86.R_CX);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x4a
+****************************************************************************/
+static void
+x86emuOp_dec_DX(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("DEC\tEDX\n");
+ }
+ else {
+ DECODE_PRINTF("DEC\tDX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EDX = dec_long(M.x86.R_EDX);
+ }
+ else {
+ M.x86.R_DX = dec_word(M.x86.R_DX);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x4b
+****************************************************************************/
+static void
+x86emuOp_dec_BX(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("DEC\tEBX\n");
+ }
+ else {
+ DECODE_PRINTF("DEC\tBX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EBX = dec_long(M.x86.R_EBX);
+ }
+ else {
+ M.x86.R_BX = dec_word(M.x86.R_BX);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x4c
+****************************************************************************/
+static void
+x86emuOp_dec_SP(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("DEC\tESP\n");
+ }
+ else {
+ DECODE_PRINTF("DEC\tSP\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_ESP = dec_long(M.x86.R_ESP);
+ }
+ else {
+ M.x86.R_SP = dec_word(M.x86.R_SP);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x4d
+****************************************************************************/
+static void
+x86emuOp_dec_BP(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("DEC\tEBP\n");
+ }
+ else {
+ DECODE_PRINTF("DEC\tBP\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EBP = dec_long(M.x86.R_EBP);
+ }
+ else {
+ M.x86.R_BP = dec_word(M.x86.R_BP);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x4e
+****************************************************************************/
+static void
+x86emuOp_dec_SI(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("DEC\tESI\n");
+ }
+ else {
+ DECODE_PRINTF("DEC\tSI\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_ESI = dec_long(M.x86.R_ESI);
+ }
+ else {
+ M.x86.R_SI = dec_word(M.x86.R_SI);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x4f
+****************************************************************************/
+static void
+x86emuOp_dec_DI(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("DEC\tEDI\n");
+ }
+ else {
+ DECODE_PRINTF("DEC\tDI\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EDI = dec_long(M.x86.R_EDI);
+ }
+ else {
+ M.x86.R_DI = dec_word(M.x86.R_DI);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x50
+****************************************************************************/
+static void
+x86emuOp_push_AX(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("PUSH\tEAX\n");
+ }
+ else {
+ DECODE_PRINTF("PUSH\tAX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ push_long(M.x86.R_EAX);
+ }
+ else {
+ push_word(M.x86.R_AX);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x51
+****************************************************************************/
+static void
+x86emuOp_push_CX(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("PUSH\tECX\n");
+ }
+ else {
+ DECODE_PRINTF("PUSH\tCX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ push_long(M.x86.R_ECX);
+ }
+ else {
+ push_word(M.x86.R_CX);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x52
+****************************************************************************/
+static void
+x86emuOp_push_DX(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("PUSH\tEDX\n");
+ }
+ else {
+ DECODE_PRINTF("PUSH\tDX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ push_long(M.x86.R_EDX);
+ }
+ else {
+ push_word(M.x86.R_DX);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x53
+****************************************************************************/
+static void
+x86emuOp_push_BX(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("PUSH\tEBX\n");
+ }
+ else {
+ DECODE_PRINTF("PUSH\tBX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ push_long(M.x86.R_EBX);
+ }
+ else {
+ push_word(M.x86.R_BX);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x54
+****************************************************************************/
+static void
+x86emuOp_push_SP(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("PUSH\tESP\n");
+ }
+ else {
+ DECODE_PRINTF("PUSH\tSP\n");
+ }
+ TRACE_AND_STEP();
+ /* Always push (E)SP, since we are emulating an i386 and above
+ * processor. This is necessary as some BIOS'es use this to check
+ * what type of processor is in the system.
+ */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ push_long(M.x86.R_ESP);
+ }
+ else {
+ push_word((u16) (M.x86.R_SP));
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x55
+****************************************************************************/
+static void
+x86emuOp_push_BP(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("PUSH\tEBP\n");
+ }
+ else {
+ DECODE_PRINTF("PUSH\tBP\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ push_long(M.x86.R_EBP);
+ }
+ else {
+ push_word(M.x86.R_BP);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x56
+****************************************************************************/
+static void
+x86emuOp_push_SI(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("PUSH\tESI\n");
+ }
+ else {
+ DECODE_PRINTF("PUSH\tSI\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ push_long(M.x86.R_ESI);
+ }
+ else {
+ push_word(M.x86.R_SI);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x57
+****************************************************************************/
+static void
+x86emuOp_push_DI(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("PUSH\tEDI\n");
+ }
+ else {
+ DECODE_PRINTF("PUSH\tDI\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ push_long(M.x86.R_EDI);
+ }
+ else {
+ push_word(M.x86.R_DI);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x58
+****************************************************************************/
+static void
+x86emuOp_pop_AX(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("POP\tEAX\n");
+ }
+ else {
+ DECODE_PRINTF("POP\tAX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EAX = pop_long();
+ }
+ else {
+ M.x86.R_AX = pop_word();
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x59
+****************************************************************************/
+static void
+x86emuOp_pop_CX(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("POP\tECX\n");
+ }
+ else {
+ DECODE_PRINTF("POP\tCX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_ECX = pop_long();
+ }
+ else {
+ M.x86.R_CX = pop_word();
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x5a
+****************************************************************************/
+static void
+x86emuOp_pop_DX(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("POP\tEDX\n");
+ }
+ else {
+ DECODE_PRINTF("POP\tDX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EDX = pop_long();
+ }
+ else {
+ M.x86.R_DX = pop_word();
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x5b
+****************************************************************************/
+static void
+x86emuOp_pop_BX(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("POP\tEBX\n");
+ }
+ else {
+ DECODE_PRINTF("POP\tBX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EBX = pop_long();
+ }
+ else {
+ M.x86.R_BX = pop_word();
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x5c
+****************************************************************************/
+static void
+x86emuOp_pop_SP(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("POP\tESP\n");
+ }
+ else {
+ DECODE_PRINTF("POP\tSP\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_ESP = pop_long();
+ }
+ else {
+ M.x86.R_SP = pop_word();
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x5d
+****************************************************************************/
+static void
+x86emuOp_pop_BP(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("POP\tEBP\n");
+ }
+ else {
+ DECODE_PRINTF("POP\tBP\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EBP = pop_long();
+ }
+ else {
+ M.x86.R_BP = pop_word();
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x5e
+****************************************************************************/
+static void
+x86emuOp_pop_SI(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("POP\tESI\n");
+ }
+ else {
+ DECODE_PRINTF("POP\tSI\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_ESI = pop_long();
+ }
+ else {
+ M.x86.R_SI = pop_word();
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x5f
+****************************************************************************/
+static void
+x86emuOp_pop_DI(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("POP\tEDI\n");
+ }
+ else {
+ DECODE_PRINTF("POP\tDI\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EDI = pop_long();
+ }
+ else {
+ M.x86.R_DI = pop_word();
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x60
+****************************************************************************/
+static void
+x86emuOp_push_all(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("PUSHAD\n");
+ }
+ else {
+ DECODE_PRINTF("PUSHA\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 old_sp = M.x86.R_ESP;
+
+ push_long(M.x86.R_EAX);
+ push_long(M.x86.R_ECX);
+ push_long(M.x86.R_EDX);
+ push_long(M.x86.R_EBX);
+ push_long(old_sp);
+ push_long(M.x86.R_EBP);
+ push_long(M.x86.R_ESI);
+ push_long(M.x86.R_EDI);
+ }
+ else {
+ u16 old_sp = M.x86.R_SP;
+
+ push_word(M.x86.R_AX);
+ push_word(M.x86.R_CX);
+ push_word(M.x86.R_DX);
+ push_word(M.x86.R_BX);
+ push_word(old_sp);
+ push_word(M.x86.R_BP);
+ push_word(M.x86.R_SI);
+ push_word(M.x86.R_DI);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x61
+****************************************************************************/
+static void
+x86emuOp_pop_all(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("POPAD\n");
+ }
+ else {
+ DECODE_PRINTF("POPA\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EDI = pop_long();
+ M.x86.R_ESI = pop_long();
+ M.x86.R_EBP = pop_long();
+ M.x86.R_ESP += 4; /* skip ESP */
+ M.x86.R_EBX = pop_long();
+ M.x86.R_EDX = pop_long();
+ M.x86.R_ECX = pop_long();
+ M.x86.R_EAX = pop_long();
+ }
+ else {
+ M.x86.R_DI = pop_word();
+ M.x86.R_SI = pop_word();
+ M.x86.R_BP = pop_word();
+ M.x86.R_SP += 2; /* skip SP */
+ M.x86.R_BX = pop_word();
+ M.x86.R_DX = pop_word();
+ M.x86.R_CX = pop_word();
+ M.x86.R_AX = pop_word();
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/*opcode 0x62 ILLEGAL OP, calls x86emuOp_illegal_op() */
+/*opcode 0x63 ILLEGAL OP, calls x86emuOp_illegal_op() */
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x64
+****************************************************************************/
+static void
+x86emuOp_segovr_FS(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("FS:\n");
+ TRACE_AND_STEP();
+ M.x86.mode |= SYSMODE_SEGOVR_FS;
+ /*
+ * note the lack of DECODE_CLEAR_SEGOVR(r) since, here is one of 4
+ * opcode subroutines we do not want to do this.
+ */
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x65
+****************************************************************************/
+static void
+x86emuOp_segovr_GS(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("GS:\n");
+ TRACE_AND_STEP();
+ M.x86.mode |= SYSMODE_SEGOVR_GS;
+ /*
+ * note the lack of DECODE_CLEAR_SEGOVR(r) since, here is one of 4
+ * opcode subroutines we do not want to do this.
+ */
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x66 - prefix for 32-bit register
+****************************************************************************/
+static void
+x86emuOp_prefix_data(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("DATA:\n");
+ TRACE_AND_STEP();
+ M.x86.mode |= SYSMODE_PREFIX_DATA;
+ /* note no DECODE_CLEAR_SEGOVR here. */
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x67 - prefix for 32-bit address
+****************************************************************************/
+static void
+x86emuOp_prefix_addr(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("ADDR:\n");
+ TRACE_AND_STEP();
+ M.x86.mode |= SYSMODE_PREFIX_ADDR;
+ /* note no DECODE_CLEAR_SEGOVR here. */
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x68
+****************************************************************************/
+static void
+x86emuOp_push_word_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u32 imm;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ imm = fetch_long_imm();
+ }
+ else {
+ imm = fetch_word_imm();
+ }
+ DECODE_PRINTF2("PUSH\t%x\n", imm);
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ push_long(imm);
+ }
+ else {
+ push_word((u16) imm);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x69
+****************************************************************************/
+static void
+x86emuOp_imul_word_IMM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint srcoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("IMUL\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+ u32 res_lo, res_hi;
+ s32 imm;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ imm = fetch_long_imm();
+ DECODE_PRINTF2(",%d\n", (s32) imm);
+ TRACE_AND_STEP();
+ imul_long_direct(&res_lo, &res_hi, (s32) srcval, (s32) imm);
+ if (res_hi != 0) {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ *destreg = (u32) res_lo;
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+ u32 res;
+ s16 imm;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ imm = fetch_word_imm();
+ DECODE_PRINTF2(",%d\n", (s32) imm);
+ TRACE_AND_STEP();
+ res = (s16) srcval *(s16) imm;
+
+ if (res > 0xFFFF) {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ *destreg = (u16) res;
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+ u32 res_lo, res_hi;
+ s32 imm;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ imm = fetch_long_imm();
+ DECODE_PRINTF2(",%d\n", (s32) imm);
+ TRACE_AND_STEP();
+ imul_long_direct(&res_lo, &res_hi, (s32) srcval, (s32) imm);
+ if (res_hi != 0) {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ *destreg = (u32) res_lo;
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+ u32 res;
+ s16 imm;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ imm = fetch_word_imm();
+ DECODE_PRINTF2(",%d\n", (s32) imm);
+ TRACE_AND_STEP();
+ res = (s16) srcval *(s16) imm;
+
+ if (res > 0xFFFF) {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ *destreg = (u16) res;
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+ u32 res_lo, res_hi;
+ s32 imm;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ imm = fetch_long_imm();
+ DECODE_PRINTF2(",%d\n", (s32) imm);
+ TRACE_AND_STEP();
+ imul_long_direct(&res_lo, &res_hi, (s32) srcval, (s32) imm);
+ if (res_hi != 0) {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ *destreg = (u32) res_lo;
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+ u32 res;
+ s16 imm;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ imm = fetch_word_imm();
+ DECODE_PRINTF2(",%d\n", (s32) imm);
+ TRACE_AND_STEP();
+ res = (s16) srcval *(s16) imm;
+
+ if (res > 0xFFFF) {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ *destreg = (u16) res;
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+ u32 res_lo, res_hi;
+ s32 imm;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rl);
+ imm = fetch_long_imm();
+ DECODE_PRINTF2(",%d\n", (s32) imm);
+ TRACE_AND_STEP();
+ imul_long_direct(&res_lo, &res_hi, (s32) * srcreg, (s32) imm);
+ if (res_hi != 0) {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ *destreg = (u32) res_lo;
+ }
+ else {
+ u16 *destreg, *srcreg;
+ u32 res;
+ s16 imm;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rl);
+ imm = fetch_word_imm();
+ DECODE_PRINTF2(",%d\n", (s32) imm);
+ res = (s16) * srcreg * (s16) imm;
+ if (res > 0xFFFF) {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ *destreg = (u16) res;
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x6a
+****************************************************************************/
+static void
+x86emuOp_push_byte_IMM(u8 X86EMU_UNUSED(op1))
+{
+ s16 imm;
+
+ START_OF_INSTR();
+ imm = (s8) fetch_byte_imm();
+ DECODE_PRINTF2("PUSH\t%d\n", imm);
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ push_long((s32) imm);
+ }
+ else {
+ push_word(imm);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x6b
+****************************************************************************/
+static void
+x86emuOp_imul_byte_IMM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint srcoffset;
+ s8 imm;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("IMUL\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+ u32 res_lo, res_hi;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2(",%d\n", (s32) imm);
+ TRACE_AND_STEP();
+ imul_long_direct(&res_lo, &res_hi, (s32) srcval, (s32) imm);
+ if (res_hi != 0) {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ *destreg = (u32) res_lo;
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+ u32 res;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2(",%d\n", (s32) imm);
+ TRACE_AND_STEP();
+ res = (s16) srcval *(s16) imm;
+
+ if (res > 0xFFFF) {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ *destreg = (u16) res;
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+ u32 res_lo, res_hi;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2(",%d\n", (s32) imm);
+ TRACE_AND_STEP();
+ imul_long_direct(&res_lo, &res_hi, (s32) srcval, (s32) imm);
+ if (res_hi != 0) {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ *destreg = (u32) res_lo;
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+ u32 res;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2(",%d\n", (s32) imm);
+ TRACE_AND_STEP();
+ res = (s16) srcval *(s16) imm;
+
+ if (res > 0xFFFF) {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ *destreg = (u16) res;
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+ u32 res_lo, res_hi;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2(",%d\n", (s32) imm);
+ TRACE_AND_STEP();
+ imul_long_direct(&res_lo, &res_hi, (s32) srcval, (s32) imm);
+ if (res_hi != 0) {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ *destreg = (u32) res_lo;
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+ u32 res;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2(",%d\n", (s32) imm);
+ TRACE_AND_STEP();
+ res = (s16) srcval *(s16) imm;
+
+ if (res > 0xFFFF) {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ *destreg = (u16) res;
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+ u32 res_lo, res_hi;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rl);
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2(",%d\n", (s32) imm);
+ TRACE_AND_STEP();
+ imul_long_direct(&res_lo, &res_hi, (s32) * srcreg, (s32) imm);
+ if (res_hi != 0) {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ *destreg = (u32) res_lo;
+ }
+ else {
+ u16 *destreg, *srcreg;
+ u32 res;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rl);
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2(",%d\n", (s32) imm);
+ res = (s16) * srcreg * (s16) imm;
+ if (res > 0xFFFF) {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ *destreg = (u16) res;
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x6c
+****************************************************************************/
+static void
+x86emuOp_ins_byte(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("INSB\n");
+ ins(1);
+ TRACE_AND_STEP();
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x6d
+****************************************************************************/
+static void
+x86emuOp_ins_word(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("INSD\n");
+ ins(4);
+ }
+ else {
+ DECODE_PRINTF("INSW\n");
+ ins(2);
+ }
+ TRACE_AND_STEP();
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x6e
+****************************************************************************/
+static void
+x86emuOp_outs_byte(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("OUTSB\n");
+ outs(1);
+ TRACE_AND_STEP();
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x6f
+****************************************************************************/
+static void
+x86emuOp_outs_word(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("OUTSD\n");
+ outs(4);
+ }
+ else {
+ DECODE_PRINTF("OUTSW\n");
+ outs(2);
+ }
+ TRACE_AND_STEP();
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x70
+****************************************************************************/
+static void
+x86emuOp_jump_near_O(u8 X86EMU_UNUSED(op1))
+{
+ s8 offset;
+ u16 target;
+
+ /* jump to byte offset if overflow flag is set */
+ START_OF_INSTR();
+ DECODE_PRINTF("JO\t");
+ offset = (s8) fetch_byte_imm();
+ target = (u16) (M.x86.R_IP + (s16) offset);
+ DECODE_PRINTF2("%x\n", target);
+ TRACE_AND_STEP();
+ if (ACCESS_FLAG(F_OF))
+ M.x86.R_IP = target;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x71
+****************************************************************************/
+static void
+x86emuOp_jump_near_NO(u8 X86EMU_UNUSED(op1))
+{
+ s8 offset;
+ u16 target;
+
+ /* jump to byte offset if overflow is not set */
+ START_OF_INSTR();
+ DECODE_PRINTF("JNO\t");
+ offset = (s8) fetch_byte_imm();
+ target = (u16) (M.x86.R_IP + (s16) offset);
+ DECODE_PRINTF2("%x\n", target);
+ TRACE_AND_STEP();
+ if (!ACCESS_FLAG(F_OF))
+ M.x86.R_IP = target;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x72
+****************************************************************************/
+static void
+x86emuOp_jump_near_B(u8 X86EMU_UNUSED(op1))
+{
+ s8 offset;
+ u16 target;
+
+ /* jump to byte offset if carry flag is set. */
+ START_OF_INSTR();
+ DECODE_PRINTF("JB\t");
+ offset = (s8) fetch_byte_imm();
+ target = (u16) (M.x86.R_IP + (s16) offset);
+ DECODE_PRINTF2("%x\n", target);
+ TRACE_AND_STEP();
+ if (ACCESS_FLAG(F_CF))
+ M.x86.R_IP = target;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x73
+****************************************************************************/
+static void
+x86emuOp_jump_near_NB(u8 X86EMU_UNUSED(op1))
+{
+ s8 offset;
+ u16 target;
+
+ /* jump to byte offset if carry flag is clear. */
+ START_OF_INSTR();
+ DECODE_PRINTF("JNB\t");
+ offset = (s8) fetch_byte_imm();
+ target = (u16) (M.x86.R_IP + (s16) offset);
+ DECODE_PRINTF2("%x\n", target);
+ TRACE_AND_STEP();
+ if (!ACCESS_FLAG(F_CF))
+ M.x86.R_IP = target;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x74
+****************************************************************************/
+static void
+x86emuOp_jump_near_Z(u8 X86EMU_UNUSED(op1))
+{
+ s8 offset;
+ u16 target;
+
+ /* jump to byte offset if zero flag is set. */
+ START_OF_INSTR();
+ DECODE_PRINTF("JZ\t");
+ offset = (s8) fetch_byte_imm();
+ target = (u16) (M.x86.R_IP + (s16) offset);
+ DECODE_PRINTF2("%x\n", target);
+ TRACE_AND_STEP();
+ if (ACCESS_FLAG(F_ZF))
+ M.x86.R_IP = target;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x75
+****************************************************************************/
+static void
+x86emuOp_jump_near_NZ(u8 X86EMU_UNUSED(op1))
+{
+ s8 offset;
+ u16 target;
+
+ /* jump to byte offset if zero flag is clear. */
+ START_OF_INSTR();
+ DECODE_PRINTF("JNZ\t");
+ offset = (s8) fetch_byte_imm();
+ target = (u16) (M.x86.R_IP + (s16) offset);
+ DECODE_PRINTF2("%x\n", target);
+ TRACE_AND_STEP();
+ if (!ACCESS_FLAG(F_ZF))
+ M.x86.R_IP = target;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x76
+****************************************************************************/
+static void
+x86emuOp_jump_near_BE(u8 X86EMU_UNUSED(op1))
+{
+ s8 offset;
+ u16 target;
+
+ /* jump to byte offset if carry flag is set or if the zero
+ flag is set. */
+ START_OF_INSTR();
+ DECODE_PRINTF("JBE\t");
+ offset = (s8) fetch_byte_imm();
+ target = (u16) (M.x86.R_IP + (s16) offset);
+ DECODE_PRINTF2("%x\n", target);
+ TRACE_AND_STEP();
+ if (ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF))
+ M.x86.R_IP = target;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x77
+****************************************************************************/
+static void
+x86emuOp_jump_near_NBE(u8 X86EMU_UNUSED(op1))
+{
+ s8 offset;
+ u16 target;
+
+ /* jump to byte offset if carry flag is clear and if the zero
+ flag is clear */
+ START_OF_INSTR();
+ DECODE_PRINTF("JNBE\t");
+ offset = (s8) fetch_byte_imm();
+ target = (u16) (M.x86.R_IP + (s16) offset);
+ DECODE_PRINTF2("%x\n", target);
+ TRACE_AND_STEP();
+ if (!(ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF)))
+ M.x86.R_IP = target;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x78
+****************************************************************************/
+static void
+x86emuOp_jump_near_S(u8 X86EMU_UNUSED(op1))
+{
+ s8 offset;
+ u16 target;
+
+ /* jump to byte offset if sign flag is set */
+ START_OF_INSTR();
+ DECODE_PRINTF("JS\t");
+ offset = (s8) fetch_byte_imm();
+ target = (u16) (M.x86.R_IP + (s16) offset);
+ DECODE_PRINTF2("%x\n", target);
+ TRACE_AND_STEP();
+ if (ACCESS_FLAG(F_SF))
+ M.x86.R_IP = target;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x79
+****************************************************************************/
+static void
+x86emuOp_jump_near_NS(u8 X86EMU_UNUSED(op1))
+{
+ s8 offset;
+ u16 target;
+
+ /* jump to byte offset if sign flag is clear */
+ START_OF_INSTR();
+ DECODE_PRINTF("JNS\t");
+ offset = (s8) fetch_byte_imm();
+ target = (u16) (M.x86.R_IP + (s16) offset);
+ DECODE_PRINTF2("%x\n", target);
+ TRACE_AND_STEP();
+ if (!ACCESS_FLAG(F_SF))
+ M.x86.R_IP = target;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x7a
+****************************************************************************/
+static void
+x86emuOp_jump_near_P(u8 X86EMU_UNUSED(op1))
+{
+ s8 offset;
+ u16 target;
+
+ /* jump to byte offset if parity flag is set (even parity) */
+ START_OF_INSTR();
+ DECODE_PRINTF("JP\t");
+ offset = (s8) fetch_byte_imm();
+ target = (u16) (M.x86.R_IP + (s16) offset);
+ DECODE_PRINTF2("%x\n", target);
+ TRACE_AND_STEP();
+ if (ACCESS_FLAG(F_PF))
+ M.x86.R_IP = target;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x7b
+****************************************************************************/
+static void
+x86emuOp_jump_near_NP(u8 X86EMU_UNUSED(op1))
+{
+ s8 offset;
+ u16 target;
+
+ /* jump to byte offset if parity flag is clear (odd parity) */
+ START_OF_INSTR();
+ DECODE_PRINTF("JNP\t");
+ offset = (s8) fetch_byte_imm();
+ target = (u16) (M.x86.R_IP + (s16) offset);
+ DECODE_PRINTF2("%x\n", target);
+ TRACE_AND_STEP();
+ if (!ACCESS_FLAG(F_PF))
+ M.x86.R_IP = target;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x7c
+****************************************************************************/
+static void
+x86emuOp_jump_near_L(u8 X86EMU_UNUSED(op1))
+{
+ s8 offset;
+ u16 target;
+ int sf, of;
+
+ /* jump to byte offset if sign flag not equal to overflow flag. */
+ START_OF_INSTR();
+ DECODE_PRINTF("JL\t");
+ offset = (s8) fetch_byte_imm();
+ target = (u16) (M.x86.R_IP + (s16) offset);
+ DECODE_PRINTF2("%x\n", target);
+ TRACE_AND_STEP();
+ sf = ACCESS_FLAG(F_SF) != 0;
+ of = ACCESS_FLAG(F_OF) != 0;
+ if (sf ^ of)
+ M.x86.R_IP = target;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x7d
+****************************************************************************/
+static void
+x86emuOp_jump_near_NL(u8 X86EMU_UNUSED(op1))
+{
+ s8 offset;
+ u16 target;
+ int sf, of;
+
+ /* jump to byte offset if sign flag not equal to overflow flag. */
+ START_OF_INSTR();
+ DECODE_PRINTF("JNL\t");
+ offset = (s8) fetch_byte_imm();
+ target = (u16) (M.x86.R_IP + (s16) offset);
+ DECODE_PRINTF2("%x\n", target);
+ TRACE_AND_STEP();
+ sf = ACCESS_FLAG(F_SF) != 0;
+ of = ACCESS_FLAG(F_OF) != 0;
+ /* note: inverse of above, but using == instead of xor. */
+ if (sf == of)
+ M.x86.R_IP = target;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x7e
+****************************************************************************/
+static void
+x86emuOp_jump_near_LE(u8 X86EMU_UNUSED(op1))
+{
+ s8 offset;
+ u16 target;
+ int sf, of;
+
+ /* jump to byte offset if sign flag not equal to overflow flag
+ or the zero flag is set */
+ START_OF_INSTR();
+ DECODE_PRINTF("JLE\t");
+ offset = (s8) fetch_byte_imm();
+ target = (u16) (M.x86.R_IP + (s16) offset);
+ DECODE_PRINTF2("%x\n", target);
+ TRACE_AND_STEP();
+ sf = ACCESS_FLAG(F_SF) != 0;
+ of = ACCESS_FLAG(F_OF) != 0;
+ if ((sf ^ of) || ACCESS_FLAG(F_ZF))
+ M.x86.R_IP = target;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x7f
+****************************************************************************/
+static void
+x86emuOp_jump_near_NLE(u8 X86EMU_UNUSED(op1))
+{
+ s8 offset;
+ u16 target;
+ int sf, of;
+
+ /* jump to byte offset if sign flag equal to overflow flag.
+ and the zero flag is clear */
+ START_OF_INSTR();
+ DECODE_PRINTF("JNLE\t");
+ offset = (s8) fetch_byte_imm();
+ target = (u16) (M.x86.R_IP + (s16) offset);
+ DECODE_PRINTF2("%x\n", target);
+ TRACE_AND_STEP();
+ sf = ACCESS_FLAG(F_SF) != 0;
+ of = ACCESS_FLAG(F_OF) != 0;
+ if ((sf == of) && !ACCESS_FLAG(F_ZF))
+ M.x86.R_IP = target;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+static u8(*opc80_byte_operation[]) (u8 d, u8 s) = {
+ add_byte, /* 00 */
+ or_byte, /* 01 */
+ adc_byte, /* 02 */
+ sbb_byte, /* 03 */
+ and_byte, /* 04 */
+ sub_byte, /* 05 */
+ xor_byte, /* 06 */
+ cmp_byte, /* 07 */
+};
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x80
+****************************************************************************/
+static void
+x86emuOp_opc80_byte_RM_IMM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg;
+ uint destoffset;
+ u8 imm;
+ u8 destval;
+
+ /*
+ * Weirdo special case instruction format. Part of the opcode
+ * held below in "RH". Doubly nested case would result, except
+ * that the decoded instruction
+ */
+ START_OF_INSTR();
+ FETCH_DECODE_MODRM(mod, rh, rl);
+#ifdef DEBUG
+ if (DEBUG_DECODE()) {
+ /* XXX DECODE_PRINTF may be changed to something more
+ general, so that it is important to leave the strings
+ in the same format, even though the result is that the
+ above test is done twice. */
+
+ switch (rh) {
+ case 0:
+ DECODE_PRINTF("ADD\t");
+ break;
+ case 1:
+ DECODE_PRINTF("OR\t");
+ break;
+ case 2:
+ DECODE_PRINTF("ADC\t");
+ break;
+ case 3:
+ DECODE_PRINTF("SBB\t");
+ break;
+ case 4:
+ DECODE_PRINTF("AND\t");
+ break;
+ case 5:
+ DECODE_PRINTF("SUB\t");
+ break;
+ case 6:
+ DECODE_PRINTF("XOR\t");
+ break;
+ case 7:
+ DECODE_PRINTF("CMP\t");
+ break;
+ }
+ }
+#endif
+ /* know operation, decode the mod byte to find the addressing
+ mode. */
+ switch (mod) {
+ case 0:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc80_byte_operation[rh]) (destval, imm);
+ if (rh != 7)
+ store_data_byte(destoffset, destval);
+ break;
+ case 1:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc80_byte_operation[rh]) (destval, imm);
+ if (rh != 7)
+ store_data_byte(destoffset, destval);
+ break;
+ case 2:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc80_byte_operation[rh]) (destval, imm);
+ if (rh != 7)
+ store_data_byte(destoffset, destval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF(",");
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc80_byte_operation[rh]) (*destreg, imm);
+ if (rh != 7)
+ *destreg = destval;
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+static u16(*opc81_word_operation[]) (u16 d, u16 s) = {
+ add_word, /*00 */
+ or_word, /*01 */
+ adc_word, /*02 */
+ sbb_word, /*03 */
+ and_word, /*04 */
+ sub_word, /*05 */
+ xor_word, /*06 */
+ cmp_word, /*07 */
+};
+
+static u32(*opc81_long_operation[]) (u32 d, u32 s) = {
+ add_long, /*00 */
+ or_long, /*01 */
+ adc_long, /*02 */
+ sbb_long, /*03 */
+ and_long, /*04 */
+ sub_long, /*05 */
+ xor_long, /*06 */
+ cmp_long, /*07 */
+};
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x81
+****************************************************************************/
+static void
+x86emuOp_opc81_word_RM_IMM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+
+ /*
+ * Weirdo special case instruction format. Part of the opcode
+ * held below in "RH". Doubly nested case would result, except
+ * that the decoded instruction
+ */
+ START_OF_INSTR();
+ FETCH_DECODE_MODRM(mod, rh, rl);
+#ifdef DEBUG
+ if (DEBUG_DECODE()) {
+ /* XXX DECODE_PRINTF may be changed to something more
+ general, so that it is important to leave the strings
+ in the same format, even though the result is that the
+ above test is done twice. */
+
+ switch (rh) {
+ case 0:
+ DECODE_PRINTF("ADD\t");
+ break;
+ case 1:
+ DECODE_PRINTF("OR\t");
+ break;
+ case 2:
+ DECODE_PRINTF("ADC\t");
+ break;
+ case 3:
+ DECODE_PRINTF("SBB\t");
+ break;
+ case 4:
+ DECODE_PRINTF("AND\t");
+ break;
+ case 5:
+ DECODE_PRINTF("SUB\t");
+ break;
+ case 6:
+ DECODE_PRINTF("XOR\t");
+ break;
+ case 7:
+ DECODE_PRINTF("CMP\t");
+ break;
+ }
+ }
+#endif
+ /*
+ * Know operation, decode the mod byte to find the addressing
+ * mode.
+ */
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval, imm;
+
+ DECODE_PRINTF("DWORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ imm = fetch_long_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc81_long_operation[rh]) (destval, imm);
+ if (rh != 7)
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval, imm;
+
+ DECODE_PRINTF("WORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ imm = fetch_word_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc81_word_operation[rh]) (destval, imm);
+ if (rh != 7)
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval, imm;
+
+ DECODE_PRINTF("DWORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ imm = fetch_long_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc81_long_operation[rh]) (destval, imm);
+ if (rh != 7)
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval, imm;
+
+ DECODE_PRINTF("WORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ imm = fetch_word_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc81_word_operation[rh]) (destval, imm);
+ if (rh != 7)
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval, imm;
+
+ DECODE_PRINTF("DWORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ imm = fetch_long_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc81_long_operation[rh]) (destval, imm);
+ if (rh != 7)
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval, imm;
+
+ DECODE_PRINTF("WORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ imm = fetch_word_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc81_word_operation[rh]) (destval, imm);
+ if (rh != 7)
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 destval, imm;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF(",");
+ imm = fetch_long_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc81_long_operation[rh]) (*destreg, imm);
+ if (rh != 7)
+ *destreg = destval;
+ }
+ else {
+ u16 *destreg;
+ u16 destval, imm;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",");
+ imm = fetch_word_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc81_word_operation[rh]) (*destreg, imm);
+ if (rh != 7)
+ *destreg = destval;
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+static u8(*opc82_byte_operation[]) (u8 s, u8 d) = {
+ add_byte, /*00 */
+ or_byte, /*01 *//*YYY UNUSED ???? */
+ adc_byte, /*02 */
+ sbb_byte, /*03 */
+ and_byte, /*04 *//*YYY UNUSED ???? */
+ sub_byte, /*05 */
+ xor_byte, /*06 *//*YYY UNUSED ???? */
+ cmp_byte, /*07 */
+};
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x82
+****************************************************************************/
+static void
+x86emuOp_opc82_byte_RM_IMM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg;
+ uint destoffset;
+ u8 imm;
+ u8 destval;
+
+ /*
+ * Weirdo special case instruction format. Part of the opcode
+ * held below in "RH". Doubly nested case would result, except
+ * that the decoded instruction Similar to opcode 81, except that
+ * the immediate byte is sign extended to a word length.
+ */
+ START_OF_INSTR();
+ FETCH_DECODE_MODRM(mod, rh, rl);
+#ifdef DEBUG
+ if (DEBUG_DECODE()) {
+ /* XXX DECODE_PRINTF may be changed to something more
+ general, so that it is important to leave the strings
+ in the same format, even though the result is that the
+ above test is done twice. */
+ switch (rh) {
+ case 0:
+ DECODE_PRINTF("ADD\t");
+ break;
+ case 1:
+ DECODE_PRINTF("OR\t");
+ break;
+ case 2:
+ DECODE_PRINTF("ADC\t");
+ break;
+ case 3:
+ DECODE_PRINTF("SBB\t");
+ break;
+ case 4:
+ DECODE_PRINTF("AND\t");
+ break;
+ case 5:
+ DECODE_PRINTF("SUB\t");
+ break;
+ case 6:
+ DECODE_PRINTF("XOR\t");
+ break;
+ case 7:
+ DECODE_PRINTF("CMP\t");
+ break;
+ }
+ }
+#endif
+ /* know operation, decode the mod byte to find the addressing
+ mode. */
+ switch (mod) {
+ case 0:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm00_address(rl);
+ destval = fetch_data_byte(destoffset);
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc82_byte_operation[rh]) (destval, imm);
+ if (rh != 7)
+ store_data_byte(destoffset, destval);
+ break;
+ case 1:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm01_address(rl);
+ destval = fetch_data_byte(destoffset);
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc82_byte_operation[rh]) (destval, imm);
+ if (rh != 7)
+ store_data_byte(destoffset, destval);
+ break;
+ case 2:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm10_address(rl);
+ destval = fetch_data_byte(destoffset);
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc82_byte_operation[rh]) (destval, imm);
+ if (rh != 7)
+ store_data_byte(destoffset, destval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc82_byte_operation[rh]) (*destreg, imm);
+ if (rh != 7)
+ *destreg = destval;
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+static u16(*opc83_word_operation[]) (u16 s, u16 d) = {
+ add_word, /*00 */
+ or_word, /*01 *//*YYY UNUSED ???? */
+ adc_word, /*02 */
+ sbb_word, /*03 */
+ and_word, /*04 *//*YYY UNUSED ???? */
+ sub_word, /*05 */
+ xor_word, /*06 *//*YYY UNUSED ???? */
+ cmp_word, /*07 */
+};
+
+static u32(*opc83_long_operation[]) (u32 s, u32 d) = {
+ add_long, /*00 */
+ or_long, /*01 *//*YYY UNUSED ???? */
+ adc_long, /*02 */
+ sbb_long, /*03 */
+ and_long, /*04 *//*YYY UNUSED ???? */
+ sub_long, /*05 */
+ xor_long, /*06 *//*YYY UNUSED ???? */
+ cmp_long, /*07 */
+};
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x83
+****************************************************************************/
+static void
+x86emuOp_opc83_word_RM_IMM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+
+ /*
+ * Weirdo special case instruction format. Part of the opcode
+ * held below in "RH". Doubly nested case would result, except
+ * that the decoded instruction Similar to opcode 81, except that
+ * the immediate byte is sign extended to a word length.
+ */
+ START_OF_INSTR();
+ FETCH_DECODE_MODRM(mod, rh, rl);
+#ifdef DEBUG
+ if (DEBUG_DECODE()) {
+ /* XXX DECODE_PRINTF may be changed to something more
+ general, so that it is important to leave the strings
+ in the same format, even though the result is that the
+ above test is done twice. */
+ switch (rh) {
+ case 0:
+ DECODE_PRINTF("ADD\t");
+ break;
+ case 1:
+ DECODE_PRINTF("OR\t");
+ break;
+ case 2:
+ DECODE_PRINTF("ADC\t");
+ break;
+ case 3:
+ DECODE_PRINTF("SBB\t");
+ break;
+ case 4:
+ DECODE_PRINTF("AND\t");
+ break;
+ case 5:
+ DECODE_PRINTF("SUB\t");
+ break;
+ case 6:
+ DECODE_PRINTF("XOR\t");
+ break;
+ case 7:
+ DECODE_PRINTF("CMP\t");
+ break;
+ }
+ }
+#endif
+ /* know operation, decode the mod byte to find the addressing
+ mode. */
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval, imm;
+
+ DECODE_PRINTF("DWORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ destval = fetch_data_long(destoffset);
+ imm = (s8) fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc83_long_operation[rh]) (destval, imm);
+ if (rh != 7)
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval, imm;
+
+ DECODE_PRINTF("WORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ destval = fetch_data_word(destoffset);
+ imm = (s8) fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc83_word_operation[rh]) (destval, imm);
+ if (rh != 7)
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval, imm;
+
+ DECODE_PRINTF("DWORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ destval = fetch_data_long(destoffset);
+ imm = (s8) fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc83_long_operation[rh]) (destval, imm);
+ if (rh != 7)
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval, imm;
+
+ DECODE_PRINTF("WORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ destval = fetch_data_word(destoffset);
+ imm = (s8) fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc83_word_operation[rh]) (destval, imm);
+ if (rh != 7)
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval, imm;
+
+ DECODE_PRINTF("DWORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ destval = fetch_data_long(destoffset);
+ imm = (s8) fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc83_long_operation[rh]) (destval, imm);
+ if (rh != 7)
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval, imm;
+
+ DECODE_PRINTF("WORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ destval = fetch_data_word(destoffset);
+ imm = (s8) fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc83_word_operation[rh]) (destval, imm);
+ if (rh != 7)
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 destval, imm;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ imm = (s8) fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc83_long_operation[rh]) (*destreg, imm);
+ if (rh != 7)
+ *destreg = destval;
+ }
+ else {
+ u16 *destreg;
+ u16 destval, imm;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ imm = (s8) fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", imm);
+ TRACE_AND_STEP();
+ destval = (*opc83_word_operation[rh]) (*destreg, imm);
+ if (rh != 7)
+ *destreg = destval;
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x84
+****************************************************************************/
+static void
+x86emuOp_test_byte_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg, *srcreg;
+ uint destoffset;
+ u8 destval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("TEST\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ test_byte(destval, *srcreg);
+ break;
+ case 1:
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ test_byte(destval, *srcreg);
+ break;
+ case 2:
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ test_byte(destval, *srcreg);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ test_byte(*destreg, *srcreg);
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x85
+****************************************************************************/
+static void
+x86emuOp_test_word_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("TEST\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ test_long(destval, *srcreg);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ test_word(destval, *srcreg);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ test_long(destval, *srcreg);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ test_word(destval, *srcreg);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *srcreg;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ test_long(destval, *srcreg);
+ }
+ else {
+ u16 destval;
+ u16 *srcreg;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ test_word(destval, *srcreg);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ test_long(*destreg, *srcreg);
+ }
+ else {
+ u16 *destreg, *srcreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ test_word(*destreg, *srcreg);
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x86
+****************************************************************************/
+static void
+x86emuOp_xchg_byte_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg, *srcreg;
+ uint destoffset;
+ u8 destval;
+ u8 tmp;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("XCHG\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ tmp = *srcreg;
+ *srcreg = destval;
+ destval = tmp;
+ store_data_byte(destoffset, destval);
+ break;
+ case 1:
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ tmp = *srcreg;
+ *srcreg = destval;
+ destval = tmp;
+ store_data_byte(destoffset, destval);
+ break;
+ case 2:
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_byte(destoffset);
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ tmp = *srcreg;
+ *srcreg = destval;
+ destval = tmp;
+ store_data_byte(destoffset, destval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ tmp = *srcreg;
+ *srcreg = *destreg;
+ *destreg = tmp;
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x87
+****************************************************************************/
+static void
+x86emuOp_xchg_word_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("XCHG\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *srcreg;
+ u32 destval, tmp;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ tmp = *srcreg;
+ *srcreg = destval;
+ destval = tmp;
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 *srcreg;
+ u16 destval, tmp;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ tmp = *srcreg;
+ *srcreg = destval;
+ destval = tmp;
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *srcreg;
+ u32 destval, tmp;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ tmp = *srcreg;
+ *srcreg = destval;
+ destval = tmp;
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 *srcreg;
+ u16 destval, tmp;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ tmp = *srcreg;
+ *srcreg = destval;
+ destval = tmp;
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *srcreg;
+ u32 destval, tmp;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_long(destoffset);
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ tmp = *srcreg;
+ *srcreg = destval;
+ destval = tmp;
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 *srcreg;
+ u16 destval, tmp;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ destval = fetch_data_word(destoffset);
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ tmp = *srcreg;
+ *srcreg = destval;
+ destval = tmp;
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+ u32 tmp;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ tmp = *srcreg;
+ *srcreg = *destreg;
+ *destreg = tmp;
+ }
+ else {
+ u16 *destreg, *srcreg;
+ u16 tmp;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ tmp = *srcreg;
+ *srcreg = *destreg;
+ *destreg = tmp;
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x88
+****************************************************************************/
+static void
+x86emuOp_mov_byte_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg, *srcreg;
+ uint destoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("MOV\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ store_data_byte(destoffset, *srcreg);
+ break;
+ case 1:
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ store_data_byte(destoffset, *srcreg);
+ break;
+ case 2:
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ store_data_byte(destoffset, *srcreg);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = *srcreg;
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x89
+****************************************************************************/
+static void
+x86emuOp_mov_word_RM_R(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u32 destoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("MOV\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *srcreg;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ store_data_long(destoffset, *srcreg);
+ }
+ else {
+ u16 *srcreg;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ store_data_word(destoffset, *srcreg);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *srcreg;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ store_data_long(destoffset, *srcreg);
+ }
+ else {
+ u16 *srcreg;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ store_data_word(destoffset, *srcreg);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *srcreg;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ store_data_long(destoffset, *srcreg);
+ }
+ else {
+ u16 *srcreg;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ store_data_word(destoffset, *srcreg);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = *srcreg;
+ }
+ else {
+ u16 *destreg, *srcreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = *srcreg;
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x8a
+****************************************************************************/
+static void
+x86emuOp_mov_byte_R_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg, *srcreg;
+ uint srcoffset;
+ u8 srcval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("MOV\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = srcval;
+ break;
+ case 1:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = srcval;
+ break;
+ case 2:
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_byte(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = srcval;
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = *srcreg;
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x8b
+****************************************************************************/
+static void
+x86emuOp_mov_word_R_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint srcoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("MOV\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = srcval;
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = srcval;
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = srcval;
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = srcval;
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_long(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = srcval;
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = srcval;
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg, *srcreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = *srcreg;
+ }
+ else {
+ u16 *destreg, *srcreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = *srcreg;
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x8c
+****************************************************************************/
+static void
+x86emuOp_mov_word_RM_SR(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u16 *destreg, *srcreg;
+ uint destoffset;
+ u16 destval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("MOV\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ srcreg = decode_rm_seg_register(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = *srcreg;
+ store_data_word(destoffset, destval);
+ break;
+ case 1:
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ srcreg = decode_rm_seg_register(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = *srcreg;
+ store_data_word(destoffset, destval);
+ break;
+ case 2:
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ srcreg = decode_rm_seg_register(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = *srcreg;
+ store_data_word(destoffset, destval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcreg = decode_rm_seg_register(rh);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = *srcreg;
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x8d
+****************************************************************************/
+static void
+x86emuOp_lea_word_R_M(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("LEA\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_ADDR) {
+ u32 *srcreg = DECODE_RM_LONG_REGISTER(rh);
+
+ DECODE_PRINTF(",");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *srcreg = (u32) destoffset;
+ }
+ else {
+ u16 *srcreg = DECODE_RM_WORD_REGISTER(rh);
+
+ DECODE_PRINTF(",");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *srcreg = (u16) destoffset;
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_ADDR) {
+ u32 *srcreg = DECODE_RM_LONG_REGISTER(rh);
+
+ DECODE_PRINTF(",");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *srcreg = (u32) destoffset;
+ }
+ else {
+ u16 *srcreg = DECODE_RM_WORD_REGISTER(rh);
+
+ DECODE_PRINTF(",");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *srcreg = (u16) destoffset;
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_ADDR) {
+ u32 *srcreg = DECODE_RM_LONG_REGISTER(rh);
+
+ DECODE_PRINTF(",");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *srcreg = (u32) destoffset;
+ }
+ else {
+ u16 *srcreg = DECODE_RM_WORD_REGISTER(rh);
+
+ DECODE_PRINTF(",");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *srcreg = (u16) destoffset;
+ }
+ break;
+ case 3: /* register to register */
+ /* undefined. Do nothing. */
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x8e
+****************************************************************************/
+static void
+x86emuOp_mov_word_SR_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u16 *destreg, *srcreg;
+ uint srcoffset;
+ u16 srcval;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("MOV\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ destreg = decode_rm_seg_register(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = srcval;
+ break;
+ case 1:
+ destreg = decode_rm_seg_register(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = srcval;
+ break;
+ case 2:
+ destreg = decode_rm_seg_register(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ srcval = fetch_data_word(srcoffset);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = srcval;
+ break;
+ case 3: /* register to register */
+ destreg = decode_rm_seg_register(rh);
+ DECODE_PRINTF(",");
+ srcreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = *srcreg;
+ break;
+ }
+ /*
+ * Clean up, and reset all the R_xSP pointers to the correct
+ * locations. This is about 3x too much overhead (doing all the
+ * segreg ptrs when only one is needed, but this instruction
+ * *cannot* be that common, and this isn't too much work anyway.
+ */
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x8f
+****************************************************************************/
+static void
+x86emuOp_pop_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("POP\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ if (rh != 0) {
+ DECODE_PRINTF("ILLEGAL DECODE OF OPCODE 8F\n");
+ HALT_SYS();
+ }
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = pop_long();
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = pop_word();
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = pop_long();
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = pop_word();
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = pop_long();
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ destval = pop_word();
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = pop_long();
+ }
+ else {
+ u16 *destreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = pop_word();
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x90
+****************************************************************************/
+static void
+x86emuOp_nop(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("NOP\n");
+ TRACE_AND_STEP();
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x91
+****************************************************************************/
+static void
+x86emuOp_xchg_word_AX_CX(u8 X86EMU_UNUSED(op1))
+{
+ u32 tmp;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("XCHG\tEAX,ECX\n");
+ }
+ else {
+ DECODE_PRINTF("XCHG\tAX,CX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ tmp = M.x86.R_EAX;
+ M.x86.R_EAX = M.x86.R_ECX;
+ M.x86.R_ECX = tmp;
+ }
+ else {
+ tmp = M.x86.R_AX;
+ M.x86.R_AX = M.x86.R_CX;
+ M.x86.R_CX = (u16) tmp;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x92
+****************************************************************************/
+static void
+x86emuOp_xchg_word_AX_DX(u8 X86EMU_UNUSED(op1))
+{
+ u32 tmp;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("XCHG\tEAX,EDX\n");
+ }
+ else {
+ DECODE_PRINTF("XCHG\tAX,DX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ tmp = M.x86.R_EAX;
+ M.x86.R_EAX = M.x86.R_EDX;
+ M.x86.R_EDX = tmp;
+ }
+ else {
+ tmp = M.x86.R_AX;
+ M.x86.R_AX = M.x86.R_DX;
+ M.x86.R_DX = (u16) tmp;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x93
+****************************************************************************/
+static void
+x86emuOp_xchg_word_AX_BX(u8 X86EMU_UNUSED(op1))
+{
+ u32 tmp;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("XCHG\tEAX,EBX\n");
+ }
+ else {
+ DECODE_PRINTF("XCHG\tAX,BX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ tmp = M.x86.R_EAX;
+ M.x86.R_EAX = M.x86.R_EBX;
+ M.x86.R_EBX = tmp;
+ }
+ else {
+ tmp = M.x86.R_AX;
+ M.x86.R_AX = M.x86.R_BX;
+ M.x86.R_BX = (u16) tmp;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x94
+****************************************************************************/
+static void
+x86emuOp_xchg_word_AX_SP(u8 X86EMU_UNUSED(op1))
+{
+ u32 tmp;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("XCHG\tEAX,ESP\n");
+ }
+ else {
+ DECODE_PRINTF("XCHG\tAX,SP\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ tmp = M.x86.R_EAX;
+ M.x86.R_EAX = M.x86.R_ESP;
+ M.x86.R_ESP = tmp;
+ }
+ else {
+ tmp = M.x86.R_AX;
+ M.x86.R_AX = M.x86.R_SP;
+ M.x86.R_SP = (u16) tmp;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x95
+****************************************************************************/
+static void
+x86emuOp_xchg_word_AX_BP(u8 X86EMU_UNUSED(op1))
+{
+ u32 tmp;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("XCHG\tEAX,EBP\n");
+ }
+ else {
+ DECODE_PRINTF("XCHG\tAX,BP\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ tmp = M.x86.R_EAX;
+ M.x86.R_EAX = M.x86.R_EBP;
+ M.x86.R_EBP = tmp;
+ }
+ else {
+ tmp = M.x86.R_AX;
+ M.x86.R_AX = M.x86.R_BP;
+ M.x86.R_BP = (u16) tmp;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x96
+****************************************************************************/
+static void
+x86emuOp_xchg_word_AX_SI(u8 X86EMU_UNUSED(op1))
+{
+ u32 tmp;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("XCHG\tEAX,ESI\n");
+ }
+ else {
+ DECODE_PRINTF("XCHG\tAX,SI\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ tmp = M.x86.R_EAX;
+ M.x86.R_EAX = M.x86.R_ESI;
+ M.x86.R_ESI = tmp;
+ }
+ else {
+ tmp = M.x86.R_AX;
+ M.x86.R_AX = M.x86.R_SI;
+ M.x86.R_SI = (u16) tmp;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x97
+****************************************************************************/
+static void
+x86emuOp_xchg_word_AX_DI(u8 X86EMU_UNUSED(op1))
+{
+ u32 tmp;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("XCHG\tEAX,EDI\n");
+ }
+ else {
+ DECODE_PRINTF("XCHG\tAX,DI\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ tmp = M.x86.R_EAX;
+ M.x86.R_EAX = M.x86.R_EDI;
+ M.x86.R_EDI = tmp;
+ }
+ else {
+ tmp = M.x86.R_AX;
+ M.x86.R_AX = M.x86.R_DI;
+ M.x86.R_DI = (u16) tmp;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x98
+****************************************************************************/
+static void
+x86emuOp_cbw(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("CWDE\n");
+ }
+ else {
+ DECODE_PRINTF("CBW\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ if (M.x86.R_AX & 0x8000) {
+ M.x86.R_EAX |= 0xffff0000;
+ }
+ else {
+ M.x86.R_EAX &= 0x0000ffff;
+ }
+ }
+ else {
+ if (M.x86.R_AL & 0x80) {
+ M.x86.R_AH = 0xff;
+ }
+ else {
+ M.x86.R_AH = 0x0;
+ }
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x99
+****************************************************************************/
+static void
+x86emuOp_cwd(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("CDQ\n");
+ }
+ else {
+ DECODE_PRINTF("CWD\n");
+ }
+ DECODE_PRINTF("CWD\n");
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ if (M.x86.R_EAX & 0x80000000) {
+ M.x86.R_EDX = 0xffffffff;
+ }
+ else {
+ M.x86.R_EDX = 0x0;
+ }
+ }
+ else {
+ if (M.x86.R_AX & 0x8000) {
+ M.x86.R_DX = 0xffff;
+ }
+ else {
+ M.x86.R_DX = 0x0;
+ }
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x9a
+****************************************************************************/
+static void
+x86emuOp_call_far_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u32 farseg, faroff;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("CALL\t");
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ faroff = fetch_long_imm();
+ farseg = fetch_word_imm();
+ }
+ else {
+ faroff = fetch_word_imm();
+ farseg = fetch_word_imm();
+ }
+ DECODE_PRINTF2("%04x:", farseg);
+ DECODE_PRINTF2("%04x\n", faroff);
+ CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, farseg, faroff, "FAR ");
+
+ /* XXX
+ *
+ * Hooked interrupt vectors calling into our "BIOS" will cause
+ * problems unless all intersegment stuff is checked for BIOS
+ * access. Check needed here. For moment, let it alone.
+ */
+ TRACE_AND_STEP();
+ push_word(M.x86.R_CS);
+ M.x86.R_CS = farseg;
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ push_long(M.x86.R_EIP);
+ }
+ else {
+ push_word(M.x86.R_IP);
+ }
+ M.x86.R_EIP = faroff & 0xffff;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x9b
+****************************************************************************/
+static void
+x86emuOp_wait(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("WAIT");
+ TRACE_AND_STEP();
+ /* NADA. */
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x9c
+****************************************************************************/
+static void
+x86emuOp_pushf_word(u8 X86EMU_UNUSED(op1))
+{
+ u32 flags;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("PUSHFD\n");
+ }
+ else {
+ DECODE_PRINTF("PUSHF\n");
+ }
+ TRACE_AND_STEP();
+
+ /* clear out *all* bits not representing flags, and turn on real bits */
+ flags = (M.x86.R_EFLG & F_MSK) | F_ALWAYS_ON;
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ push_long(flags);
+ }
+ else {
+ push_word((u16) flags);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x9d
+****************************************************************************/
+static void
+x86emuOp_popf_word(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("POPFD\n");
+ }
+ else {
+ DECODE_PRINTF("POPF\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EFLG = pop_long();
+ }
+ else {
+ M.x86.R_FLG = pop_word();
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x9e
+****************************************************************************/
+static void
+x86emuOp_sahf(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("SAHF\n");
+ TRACE_AND_STEP();
+ /* clear the lower bits of the flag register */
+ M.x86.R_FLG &= 0xffffff00;
+ /* or in the AH register into the flags register */
+ M.x86.R_FLG |= M.x86.R_AH;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x9f
+****************************************************************************/
+static void
+x86emuOp_lahf(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("LAHF\n");
+ TRACE_AND_STEP();
+ M.x86.R_AH = (u8) (M.x86.R_FLG & 0xff);
+ /*undocumented TC++ behavior??? Nope. It's documented, but
+ you have too look real hard to notice it. */
+ M.x86.R_AH |= 0x2;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xa0
+****************************************************************************/
+static void
+x86emuOp_mov_AL_M_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u16 offset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("MOV\tAL,");
+ offset = fetch_word_imm();
+ DECODE_PRINTF2("[%04x]\n", offset);
+ TRACE_AND_STEP();
+ M.x86.R_AL = fetch_data_byte(offset);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xa1
+****************************************************************************/
+static void
+x86emuOp_mov_AX_M_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u16 offset;
+
+ START_OF_INSTR();
+ offset = fetch_word_imm();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF2("MOV\tEAX,[%04x]\n", offset);
+ }
+ else {
+ DECODE_PRINTF2("MOV\tAX,[%04x]\n", offset);
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EAX = fetch_data_long(offset);
+ }
+ else {
+ M.x86.R_AX = fetch_data_word(offset);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xa2
+****************************************************************************/
+static void
+x86emuOp_mov_M_AL_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u16 offset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("MOV\t");
+ offset = fetch_word_imm();
+ DECODE_PRINTF2("[%04x],AL\n", offset);
+ TRACE_AND_STEP();
+ store_data_byte(offset, M.x86.R_AL);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xa3
+****************************************************************************/
+static void
+x86emuOp_mov_M_AX_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u16 offset;
+
+ START_OF_INSTR();
+ offset = fetch_word_imm();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF2("MOV\t[%04x],EAX\n", offset);
+ }
+ else {
+ DECODE_PRINTF2("MOV\t[%04x],AX\n", offset);
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ store_data_long(offset, M.x86.R_EAX);
+ }
+ else {
+ store_data_word(offset, M.x86.R_AX);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xa4
+****************************************************************************/
+static void
+x86emuOp_movs_byte(u8 X86EMU_UNUSED(op1))
+{
+ u8 val;
+ u32 count;
+ int inc;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("MOVS\tBYTE\n");
+ if (ACCESS_FLAG(F_DF)) /* down */
+ inc = -1;
+ else
+ inc = 1;
+ TRACE_AND_STEP();
+ count = 1;
+ if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
+ /* dont care whether REPE or REPNE */
+ /* move them until CX is ZERO. */
+ count = M.x86.R_CX;
+ M.x86.R_CX = 0;
+ M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
+ }
+ while (count--) {
+ val = fetch_data_byte(M.x86.R_SI);
+ store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, val);
+ M.x86.R_SI += inc;
+ M.x86.R_DI += inc;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xa5
+****************************************************************************/
+static void
+x86emuOp_movs_word(u8 X86EMU_UNUSED(op1))
+{
+ u32 val;
+ int inc;
+ u32 count;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("MOVS\tDWORD\n");
+ if (ACCESS_FLAG(F_DF)) /* down */
+ inc = -4;
+ else
+ inc = 4;
+ }
+ else {
+ DECODE_PRINTF("MOVS\tWORD\n");
+ if (ACCESS_FLAG(F_DF)) /* down */
+ inc = -2;
+ else
+ inc = 2;
+ }
+ TRACE_AND_STEP();
+ count = 1;
+ if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
+ /* dont care whether REPE or REPNE */
+ /* move them until CX is ZERO. */
+ count = M.x86.R_CX;
+ M.x86.R_CX = 0;
+ M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
+ }
+ while (count--) {
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ val = fetch_data_long(M.x86.R_SI);
+ store_data_long_abs(M.x86.R_ES, M.x86.R_DI, val);
+ }
+ else {
+ val = fetch_data_word(M.x86.R_SI);
+ store_data_word_abs(M.x86.R_ES, M.x86.R_DI, (u16) val);
+ }
+ M.x86.R_SI += inc;
+ M.x86.R_DI += inc;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xa6
+****************************************************************************/
+static void
+x86emuOp_cmps_byte(u8 X86EMU_UNUSED(op1))
+{
+ s8 val1, val2;
+ int inc;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("CMPS\tBYTE\n");
+ TRACE_AND_STEP();
+ if (ACCESS_FLAG(F_DF)) /* down */
+ inc = -1;
+ else
+ inc = 1;
+
+ if (M.x86.mode & SYSMODE_PREFIX_REPE) {
+ /* REPE */
+ /* move them until CX is ZERO. */
+ while (M.x86.R_CX != 0) {
+ val1 = fetch_data_byte(M.x86.R_SI);
+ val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
+ cmp_byte(val1, val2);
+ M.x86.R_CX -= 1;
+ M.x86.R_SI += inc;
+ M.x86.R_DI += inc;
+ if (ACCESS_FLAG(F_ZF) == 0)
+ break;
+ }
+ M.x86.mode &= ~SYSMODE_PREFIX_REPE;
+ }
+ else if (M.x86.mode & SYSMODE_PREFIX_REPNE) {
+ /* REPNE */
+ /* move them until CX is ZERO. */
+ while (M.x86.R_CX != 0) {
+ val1 = fetch_data_byte(M.x86.R_SI);
+ val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
+ cmp_byte(val1, val2);
+ M.x86.R_CX -= 1;
+ M.x86.R_SI += inc;
+ M.x86.R_DI += inc;
+ if (ACCESS_FLAG(F_ZF))
+ break; /* zero flag set means equal */
+ }
+ M.x86.mode &= ~SYSMODE_PREFIX_REPNE;
+ }
+ else {
+ val1 = fetch_data_byte(M.x86.R_SI);
+ val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
+ cmp_byte(val1, val2);
+ M.x86.R_SI += inc;
+ M.x86.R_DI += inc;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xa7
+****************************************************************************/
+static void
+x86emuOp_cmps_word(u8 X86EMU_UNUSED(op1))
+{
+ u32 val1, val2;
+ int inc;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("CMPS\tDWORD\n");
+ if (ACCESS_FLAG(F_DF)) /* down */
+ inc = -4;
+ else
+ inc = 4;
+ }
+ else {
+ DECODE_PRINTF("CMPS\tWORD\n");
+ if (ACCESS_FLAG(F_DF)) /* down */
+ inc = -2;
+ else
+ inc = 2;
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_REPE) {
+ /* REPE */
+ /* move them until CX is ZERO. */
+ while (M.x86.R_CX != 0) {
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ val1 = fetch_data_long(M.x86.R_SI);
+ val2 = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
+ cmp_long(val1, val2);
+ }
+ else {
+ val1 = fetch_data_word(M.x86.R_SI);
+ val2 = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
+ cmp_word((u16) val1, (u16) val2);
+ }
+ M.x86.R_CX -= 1;
+ M.x86.R_SI += inc;
+ M.x86.R_DI += inc;
+ if (ACCESS_FLAG(F_ZF) == 0)
+ break;
+ }
+ M.x86.mode &= ~SYSMODE_PREFIX_REPE;
+ }
+ else if (M.x86.mode & SYSMODE_PREFIX_REPNE) {
+ /* REPNE */
+ /* move them until CX is ZERO. */
+ while (M.x86.R_CX != 0) {
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ val1 = fetch_data_long(M.x86.R_SI);
+ val2 = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
+ cmp_long(val1, val2);
+ }
+ else {
+ val1 = fetch_data_word(M.x86.R_SI);
+ val2 = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
+ cmp_word((u16) val1, (u16) val2);
+ }
+ M.x86.R_CX -= 1;
+ M.x86.R_SI += inc;
+ M.x86.R_DI += inc;
+ if (ACCESS_FLAG(F_ZF))
+ break; /* zero flag set means equal */
+ }
+ M.x86.mode &= ~SYSMODE_PREFIX_REPNE;
+ }
+ else {
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ val1 = fetch_data_long(M.x86.R_SI);
+ val2 = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
+ cmp_long(val1, val2);
+ }
+ else {
+ val1 = fetch_data_word(M.x86.R_SI);
+ val2 = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
+ cmp_word((u16) val1, (u16) val2);
+ }
+ M.x86.R_SI += inc;
+ M.x86.R_DI += inc;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xa8
+****************************************************************************/
+static void
+x86emuOp_test_AL_IMM(u8 X86EMU_UNUSED(op1))
+{
+ int imm;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("TEST\tAL,");
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2("%04x\n", imm);
+ TRACE_AND_STEP();
+ test_byte(M.x86.R_AL, (u8) imm);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xa9
+****************************************************************************/
+static void
+x86emuOp_test_AX_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u32 srcval;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("TEST\tEAX,");
+ srcval = fetch_long_imm();
+ }
+ else {
+ DECODE_PRINTF("TEST\tAX,");
+ srcval = fetch_word_imm();
+ }
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ test_long(M.x86.R_EAX, srcval);
+ }
+ else {
+ test_word(M.x86.R_AX, (u16) srcval);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xaa
+****************************************************************************/
+static void
+x86emuOp_stos_byte(u8 X86EMU_UNUSED(op1))
+{
+ int inc;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("STOS\tBYTE\n");
+ if (ACCESS_FLAG(F_DF)) /* down */
+ inc = -1;
+ else
+ inc = 1;
+ TRACE_AND_STEP();
+ if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
+ /* dont care whether REPE or REPNE */
+ /* move them until CX is ZERO. */
+ while (M.x86.R_CX != 0) {
+ store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_AL);
+ M.x86.R_CX -= 1;
+ M.x86.R_DI += inc;
+ }
+ M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
+ }
+ else {
+ store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_AL);
+ M.x86.R_DI += inc;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xab
+****************************************************************************/
+static void
+x86emuOp_stos_word(u8 X86EMU_UNUSED(op1))
+{
+ int inc;
+ u32 count;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("STOS\tDWORD\n");
+ if (ACCESS_FLAG(F_DF)) /* down */
+ inc = -4;
+ else
+ inc = 4;
+ }
+ else {
+ DECODE_PRINTF("STOS\tWORD\n");
+ if (ACCESS_FLAG(F_DF)) /* down */
+ inc = -2;
+ else
+ inc = 2;
+ }
+ TRACE_AND_STEP();
+ count = 1;
+ if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
+ /* dont care whether REPE or REPNE */
+ /* move them until CX is ZERO. */
+ count = M.x86.R_CX;
+ M.x86.R_CX = 0;
+ M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
+ }
+ while (count--) {
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ store_data_long_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_EAX);
+ }
+ else {
+ store_data_word_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_AX);
+ }
+ M.x86.R_DI += inc;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xac
+****************************************************************************/
+static void
+x86emuOp_lods_byte(u8 X86EMU_UNUSED(op1))
+{
+ int inc;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("LODS\tBYTE\n");
+ TRACE_AND_STEP();
+ if (ACCESS_FLAG(F_DF)) /* down */
+ inc = -1;
+ else
+ inc = 1;
+ if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
+ /* dont care whether REPE or REPNE */
+ /* move them until CX is ZERO. */
+ while (M.x86.R_CX != 0) {
+ M.x86.R_AL = fetch_data_byte(M.x86.R_SI);
+ M.x86.R_CX -= 1;
+ M.x86.R_SI += inc;
+ }
+ M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
+ }
+ else {
+ M.x86.R_AL = fetch_data_byte(M.x86.R_SI);
+ M.x86.R_SI += inc;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xad
+****************************************************************************/
+static void
+x86emuOp_lods_word(u8 X86EMU_UNUSED(op1))
+{
+ int inc;
+ u32 count;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("LODS\tDWORD\n");
+ if (ACCESS_FLAG(F_DF)) /* down */
+ inc = -4;
+ else
+ inc = 4;
+ }
+ else {
+ DECODE_PRINTF("LODS\tWORD\n");
+ if (ACCESS_FLAG(F_DF)) /* down */
+ inc = -2;
+ else
+ inc = 2;
+ }
+ TRACE_AND_STEP();
+ count = 1;
+ if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
+ /* dont care whether REPE or REPNE */
+ /* move them until CX is ZERO. */
+ count = M.x86.R_CX;
+ M.x86.R_CX = 0;
+ M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
+ }
+ while (count--) {
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EAX = fetch_data_long(M.x86.R_SI);
+ }
+ else {
+ M.x86.R_AX = fetch_data_word(M.x86.R_SI);
+ }
+ M.x86.R_SI += inc;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xae
+****************************************************************************/
+static void
+x86emuOp_scas_byte(u8 X86EMU_UNUSED(op1))
+{
+ s8 val2;
+ int inc;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("SCAS\tBYTE\n");
+ TRACE_AND_STEP();
+ if (ACCESS_FLAG(F_DF)) /* down */
+ inc = -1;
+ else
+ inc = 1;
+ if (M.x86.mode & SYSMODE_PREFIX_REPE) {
+ /* REPE */
+ /* move them until CX is ZERO. */
+ while (M.x86.R_CX != 0) {
+ val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
+ cmp_byte(M.x86.R_AL, val2);
+ M.x86.R_CX -= 1;
+ M.x86.R_DI += inc;
+ if (ACCESS_FLAG(F_ZF) == 0)
+ break;
+ }
+ M.x86.mode &= ~SYSMODE_PREFIX_REPE;
+ }
+ else if (M.x86.mode & SYSMODE_PREFIX_REPNE) {
+ /* REPNE */
+ /* move them until CX is ZERO. */
+ while (M.x86.R_CX != 0) {
+ val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
+ cmp_byte(M.x86.R_AL, val2);
+ M.x86.R_CX -= 1;
+ M.x86.R_DI += inc;
+ if (ACCESS_FLAG(F_ZF))
+ break; /* zero flag set means equal */
+ }
+ M.x86.mode &= ~SYSMODE_PREFIX_REPNE;
+ }
+ else {
+ val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
+ cmp_byte(M.x86.R_AL, val2);
+ M.x86.R_DI += inc;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xaf
+****************************************************************************/
+static void
+x86emuOp_scas_word(u8 X86EMU_UNUSED(op1))
+{
+ int inc;
+ u32 val;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("SCAS\tDWORD\n");
+ if (ACCESS_FLAG(F_DF)) /* down */
+ inc = -4;
+ else
+ inc = 4;
+ }
+ else {
+ DECODE_PRINTF("SCAS\tWORD\n");
+ if (ACCESS_FLAG(F_DF)) /* down */
+ inc = -2;
+ else
+ inc = 2;
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_REPE) {
+ /* REPE */
+ /* move them until CX is ZERO. */
+ while (M.x86.R_CX != 0) {
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ val = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
+ cmp_long(M.x86.R_EAX, val);
+ }
+ else {
+ val = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
+ cmp_word(M.x86.R_AX, (u16) val);
+ }
+ M.x86.R_CX -= 1;
+ M.x86.R_DI += inc;
+ if (ACCESS_FLAG(F_ZF) == 0)
+ break;
+ }
+ M.x86.mode &= ~SYSMODE_PREFIX_REPE;
+ }
+ else if (M.x86.mode & SYSMODE_PREFIX_REPNE) {
+ /* REPNE */
+ /* move them until CX is ZERO. */
+ while (M.x86.R_CX != 0) {
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ val = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
+ cmp_long(M.x86.R_EAX, val);
+ }
+ else {
+ val = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
+ cmp_word(M.x86.R_AX, (u16) val);
+ }
+ M.x86.R_CX -= 1;
+ M.x86.R_DI += inc;
+ if (ACCESS_FLAG(F_ZF))
+ break; /* zero flag set means equal */
+ }
+ M.x86.mode &= ~SYSMODE_PREFIX_REPNE;
+ }
+ else {
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ val = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
+ cmp_long(M.x86.R_EAX, val);
+ }
+ else {
+ val = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
+ cmp_word(M.x86.R_AX, (u16) val);
+ }
+ M.x86.R_DI += inc;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xb0
+****************************************************************************/
+static void
+x86emuOp_mov_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u8 imm;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("MOV\tAL,");
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ TRACE_AND_STEP();
+ M.x86.R_AL = imm;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xb1
+****************************************************************************/
+static void
+x86emuOp_mov_byte_CL_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u8 imm;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("MOV\tCL,");
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ TRACE_AND_STEP();
+ M.x86.R_CL = imm;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xb2
+****************************************************************************/
+static void
+x86emuOp_mov_byte_DL_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u8 imm;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("MOV\tDL,");
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ TRACE_AND_STEP();
+ M.x86.R_DL = imm;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xb3
+****************************************************************************/
+static void
+x86emuOp_mov_byte_BL_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u8 imm;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("MOV\tBL,");
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ TRACE_AND_STEP();
+ M.x86.R_BL = imm;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xb4
+****************************************************************************/
+static void
+x86emuOp_mov_byte_AH_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u8 imm;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("MOV\tAH,");
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ TRACE_AND_STEP();
+ M.x86.R_AH = imm;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xb5
+****************************************************************************/
+static void
+x86emuOp_mov_byte_CH_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u8 imm;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("MOV\tCH,");
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ TRACE_AND_STEP();
+ M.x86.R_CH = imm;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xb6
+****************************************************************************/
+static void
+x86emuOp_mov_byte_DH_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u8 imm;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("MOV\tDH,");
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ TRACE_AND_STEP();
+ M.x86.R_DH = imm;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xb7
+****************************************************************************/
+static void
+x86emuOp_mov_byte_BH_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u8 imm;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("MOV\tBH,");
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ TRACE_AND_STEP();
+ M.x86.R_BH = imm;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xb8
+****************************************************************************/
+static void
+x86emuOp_mov_word_AX_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u32 srcval;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("MOV\tEAX,");
+ srcval = fetch_long_imm();
+ }
+ else {
+ DECODE_PRINTF("MOV\tAX,");
+ srcval = fetch_word_imm();
+ }
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EAX = srcval;
+ }
+ else {
+ M.x86.R_AX = (u16) srcval;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xb9
+****************************************************************************/
+static void
+x86emuOp_mov_word_CX_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u32 srcval;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("MOV\tECX,");
+ srcval = fetch_long_imm();
+ }
+ else {
+ DECODE_PRINTF("MOV\tCX,");
+ srcval = fetch_word_imm();
+ }
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_ECX = srcval;
+ }
+ else {
+ M.x86.R_CX = (u16) srcval;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xba
+****************************************************************************/
+static void
+x86emuOp_mov_word_DX_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u32 srcval;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("MOV\tEDX,");
+ srcval = fetch_long_imm();
+ }
+ else {
+ DECODE_PRINTF("MOV\tDX,");
+ srcval = fetch_word_imm();
+ }
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EDX = srcval;
+ }
+ else {
+ M.x86.R_DX = (u16) srcval;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xbb
+****************************************************************************/
+static void
+x86emuOp_mov_word_BX_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u32 srcval;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("MOV\tEBX,");
+ srcval = fetch_long_imm();
+ }
+ else {
+ DECODE_PRINTF("MOV\tBX,");
+ srcval = fetch_word_imm();
+ }
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EBX = srcval;
+ }
+ else {
+ M.x86.R_BX = (u16) srcval;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xbc
+****************************************************************************/
+static void
+x86emuOp_mov_word_SP_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u32 srcval;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("MOV\tESP,");
+ srcval = fetch_long_imm();
+ }
+ else {
+ DECODE_PRINTF("MOV\tSP,");
+ srcval = fetch_word_imm();
+ }
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_ESP = srcval;
+ }
+ else {
+ M.x86.R_SP = (u16) srcval;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xbd
+****************************************************************************/
+static void
+x86emuOp_mov_word_BP_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u32 srcval;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("MOV\tEBP,");
+ srcval = fetch_long_imm();
+ }
+ else {
+ DECODE_PRINTF("MOV\tBP,");
+ srcval = fetch_word_imm();
+ }
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EBP = srcval;
+ }
+ else {
+ M.x86.R_BP = (u16) srcval;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xbe
+****************************************************************************/
+static void
+x86emuOp_mov_word_SI_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u32 srcval;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("MOV\tESI,");
+ srcval = fetch_long_imm();
+ }
+ else {
+ DECODE_PRINTF("MOV\tSI,");
+ srcval = fetch_word_imm();
+ }
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_ESI = srcval;
+ }
+ else {
+ M.x86.R_SI = (u16) srcval;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xbf
+****************************************************************************/
+static void
+x86emuOp_mov_word_DI_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u32 srcval;
+
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("MOV\tEDI,");
+ srcval = fetch_long_imm();
+ }
+ else {
+ DECODE_PRINTF("MOV\tDI,");
+ srcval = fetch_word_imm();
+ }
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EDI = srcval;
+ }
+ else {
+ M.x86.R_DI = (u16) srcval;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/* used by opcodes c0, d0, and d2. */
+static u8(*opcD0_byte_operation[]) (u8 d, u8 s) = {
+ rol_byte, ror_byte, rcl_byte, rcr_byte, shl_byte, shr_byte, shl_byte, /* sal_byte === shl_byte by definition */
+sar_byte,};
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xc0
+****************************************************************************/
+static void
+x86emuOp_opcC0_byte_RM_MEM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg;
+ uint destoffset;
+ u8 destval;
+ u8 amt;
+
+ /*
+ * Yet another weirdo special case instruction format. Part of
+ * the opcode held below in "RH". Doubly nested case would
+ * result, except that the decoded instruction
+ */
+ START_OF_INSTR();
+ FETCH_DECODE_MODRM(mod, rh, rl);
+#ifdef DEBUG
+ if (DEBUG_DECODE()) {
+ /* XXX DECODE_PRINTF may be changed to something more
+ general, so that it is important to leave the strings
+ in the same format, even though the result is that the
+ above test is done twice. */
+
+ switch (rh) {
+ case 0:
+ DECODE_PRINTF("ROL\t");
+ break;
+ case 1:
+ DECODE_PRINTF("ROR\t");
+ break;
+ case 2:
+ DECODE_PRINTF("RCL\t");
+ break;
+ case 3:
+ DECODE_PRINTF("RCR\t");
+ break;
+ case 4:
+ DECODE_PRINTF("SHL\t");
+ break;
+ case 5:
+ DECODE_PRINTF("SHR\t");
+ break;
+ case 6:
+ DECODE_PRINTF("SAL\t");
+ break;
+ case 7:
+ DECODE_PRINTF("SAR\t");
+ break;
+ }
+ }
+#endif
+ /* know operation, decode the mod byte to find the addressing
+ mode. */
+ switch (mod) {
+ case 0:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm00_address(rl);
+ amt = fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", amt);
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD0_byte_operation[rh]) (destval, amt);
+ store_data_byte(destoffset, destval);
+ break;
+ case 1:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm01_address(rl);
+ amt = fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", amt);
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD0_byte_operation[rh]) (destval, amt);
+ store_data_byte(destoffset, destval);
+ break;
+ case 2:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm10_address(rl);
+ amt = fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", amt);
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD0_byte_operation[rh]) (destval, amt);
+ store_data_byte(destoffset, destval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ amt = fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", amt);
+ TRACE_AND_STEP();
+ destval = (*opcD0_byte_operation[rh]) (*destreg, amt);
+ *destreg = destval;
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/* used by opcodes c1, d1, and d3. */
+static u16(*opcD1_word_operation[]) (u16 s, u8 d) = {
+ rol_word, ror_word, rcl_word, rcr_word, shl_word, shr_word, shl_word, /* sal_byte === shl_byte by definition */
+sar_word,};
+
+/* used by opcodes c1, d1, and d3. */
+static u32(*opcD1_long_operation[]) (u32 s, u8 d) = {
+ rol_long, ror_long, rcl_long, rcr_long, shl_long, shr_long, shl_long, /* sal_byte === shl_byte by definition */
+sar_long,};
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xc1
+****************************************************************************/
+static void
+x86emuOp_opcC1_word_RM_MEM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+ u8 amt;
+
+ /*
+ * Yet another weirdo special case instruction format. Part of
+ * the opcode held below in "RH". Doubly nested case would
+ * result, except that the decoded instruction
+ */
+ START_OF_INSTR();
+ FETCH_DECODE_MODRM(mod, rh, rl);
+#ifdef DEBUG
+ if (DEBUG_DECODE()) {
+ /* XXX DECODE_PRINTF may be changed to something more
+ general, so that it is important to leave the strings
+ in the same format, even though the result is that the
+ above test is done twice. */
+
+ switch (rh) {
+ case 0:
+ DECODE_PRINTF("ROL\t");
+ break;
+ case 1:
+ DECODE_PRINTF("ROR\t");
+ break;
+ case 2:
+ DECODE_PRINTF("RCL\t");
+ break;
+ case 3:
+ DECODE_PRINTF("RCR\t");
+ break;
+ case 4:
+ DECODE_PRINTF("SHL\t");
+ break;
+ case 5:
+ DECODE_PRINTF("SHR\t");
+ break;
+ case 6:
+ DECODE_PRINTF("SAL\t");
+ break;
+ case 7:
+ DECODE_PRINTF("SAR\t");
+ break;
+ }
+ }
+#endif
+ /* know operation, decode the mod byte to find the addressing
+ mode. */
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("DWORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ amt = fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", amt);
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD1_long_operation[rh]) (destval, amt);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("WORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ amt = fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", amt);
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD1_word_operation[rh]) (destval, amt);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("DWORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ amt = fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", amt);
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD1_long_operation[rh]) (destval, amt);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("WORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ amt = fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", amt);
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD1_word_operation[rh]) (destval, amt);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("DWORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ amt = fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", amt);
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD1_long_operation[rh]) (destval, amt);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("WORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ amt = fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", amt);
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD1_word_operation[rh]) (destval, amt);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ amt = fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", amt);
+ TRACE_AND_STEP();
+ *destreg = (*opcD1_long_operation[rh]) (*destreg, amt);
+ }
+ else {
+ u16 *destreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ amt = fetch_byte_imm();
+ DECODE_PRINTF2(",%x\n", amt);
+ TRACE_AND_STEP();
+ *destreg = (*opcD1_word_operation[rh]) (*destreg, amt);
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xc2
+****************************************************************************/
+static void
+x86emuOp_ret_near_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u16 imm;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("RET\t");
+ imm = fetch_word_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ RETURN_TRACE("RET", M.x86.saved_cs, M.x86.saved_ip);
+ TRACE_AND_STEP();
+ M.x86.R_IP = pop_word();
+ M.x86.R_SP += imm;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xc3
+****************************************************************************/
+static void
+x86emuOp_ret_near(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("RET\n");
+ RETURN_TRACE("RET", M.x86.saved_cs, M.x86.saved_ip);
+ TRACE_AND_STEP();
+ M.x86.R_IP = pop_word();
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xc4
+****************************************************************************/
+static void
+x86emuOp_les_R_IMM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rh, rl;
+ u16 *dstreg;
+ uint srcoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("LES\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ dstreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *dstreg = fetch_data_word(srcoffset);
+ M.x86.R_ES = fetch_data_word(srcoffset + 2);
+ break;
+ case 1:
+ dstreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *dstreg = fetch_data_word(srcoffset);
+ M.x86.R_ES = fetch_data_word(srcoffset + 2);
+ break;
+ case 2:
+ dstreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *dstreg = fetch_data_word(srcoffset);
+ M.x86.R_ES = fetch_data_word(srcoffset + 2);
+ break;
+ case 3: /* register to register */
+ /* UNDEFINED! */
+ TRACE_AND_STEP();
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xc5
+****************************************************************************/
+static void
+x86emuOp_lds_R_IMM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rh, rl;
+ u16 *dstreg;
+ uint srcoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("LDS\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ dstreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *dstreg = fetch_data_word(srcoffset);
+ M.x86.R_DS = fetch_data_word(srcoffset + 2);
+ break;
+ case 1:
+ dstreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *dstreg = fetch_data_word(srcoffset);
+ M.x86.R_DS = fetch_data_word(srcoffset + 2);
+ break;
+ case 2:
+ dstreg = DECODE_RM_WORD_REGISTER(rh);
+ DECODE_PRINTF(",");
+ srcoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *dstreg = fetch_data_word(srcoffset);
+ M.x86.R_DS = fetch_data_word(srcoffset + 2);
+ break;
+ case 3: /* register to register */
+ /* UNDEFINED! */
+ TRACE_AND_STEP();
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xc6
+****************************************************************************/
+static void
+x86emuOp_mov_byte_RM_IMM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg;
+ uint destoffset;
+ u8 imm;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("MOV\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ if (rh != 0) {
+ DECODE_PRINTF("ILLEGAL DECODE OF OPCODE c6\n");
+ HALT_SYS();
+ }
+ switch (mod) {
+ case 0:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm00_address(rl);
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2(",%2x\n", imm);
+ TRACE_AND_STEP();
+ store_data_byte(destoffset, imm);
+ break;
+ case 1:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm01_address(rl);
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2(",%2x\n", imm);
+ TRACE_AND_STEP();
+ store_data_byte(destoffset, imm);
+ break;
+ case 2:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm10_address(rl);
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2(",%2x\n", imm);
+ TRACE_AND_STEP();
+ store_data_byte(destoffset, imm);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ imm = fetch_byte_imm();
+ DECODE_PRINTF2(",%2x\n", imm);
+ TRACE_AND_STEP();
+ *destreg = imm;
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xc7
+****************************************************************************/
+static void
+x86emuOp_mov_word_RM_IMM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("MOV\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ if (rh != 0) {
+ DECODE_PRINTF("ILLEGAL DECODE OF OPCODE 8F\n");
+ HALT_SYS();
+ }
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 imm;
+
+ DECODE_PRINTF("DWORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ imm = fetch_long_imm();
+ DECODE_PRINTF2(",%x\n", imm);
+ TRACE_AND_STEP();
+ store_data_long(destoffset, imm);
+ }
+ else {
+ u16 imm;
+
+ DECODE_PRINTF("WORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ imm = fetch_word_imm();
+ DECODE_PRINTF2(",%x\n", imm);
+ TRACE_AND_STEP();
+ store_data_word(destoffset, imm);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 imm;
+
+ DECODE_PRINTF("DWORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ imm = fetch_long_imm();
+ DECODE_PRINTF2(",%x\n", imm);
+ TRACE_AND_STEP();
+ store_data_long(destoffset, imm);
+ }
+ else {
+ u16 imm;
+
+ DECODE_PRINTF("WORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ imm = fetch_word_imm();
+ DECODE_PRINTF2(",%x\n", imm);
+ TRACE_AND_STEP();
+ store_data_word(destoffset, imm);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 imm;
+
+ DECODE_PRINTF("DWORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ imm = fetch_long_imm();
+ DECODE_PRINTF2(",%x\n", imm);
+ TRACE_AND_STEP();
+ store_data_long(destoffset, imm);
+ }
+ else {
+ u16 imm;
+
+ DECODE_PRINTF("WORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ imm = fetch_word_imm();
+ DECODE_PRINTF2(",%x\n", imm);
+ TRACE_AND_STEP();
+ store_data_word(destoffset, imm);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 imm;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ imm = fetch_long_imm();
+ DECODE_PRINTF2(",%x\n", imm);
+ TRACE_AND_STEP();
+ *destreg = imm;
+ }
+ else {
+ u16 *destreg;
+ u16 imm;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ imm = fetch_word_imm();
+ DECODE_PRINTF2(",%x\n", imm);
+ TRACE_AND_STEP();
+ *destreg = imm;
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xc8
+****************************************************************************/
+static void
+x86emuOp_enter(u8 X86EMU_UNUSED(op1))
+{
+ u16 local, frame_pointer;
+ u8 nesting;
+ int i;
+
+ START_OF_INSTR();
+ local = fetch_word_imm();
+ nesting = fetch_byte_imm();
+ DECODE_PRINTF2("ENTER %x\n", local);
+ DECODE_PRINTF2(",%x\n", nesting);
+ TRACE_AND_STEP();
+ push_word(M.x86.R_BP);
+ frame_pointer = M.x86.R_SP;
+ if (nesting > 0) {
+ for (i = 1; i < nesting; i++) {
+ M.x86.R_BP -= 2;
+ push_word(fetch_data_word_abs(M.x86.R_SS, M.x86.R_BP));
+ }
+ push_word(frame_pointer);
+ }
+ M.x86.R_BP = frame_pointer;
+ M.x86.R_SP = (u16) (M.x86.R_SP - local);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xc9
+****************************************************************************/
+static void
+x86emuOp_leave(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("LEAVE\n");
+ TRACE_AND_STEP();
+ M.x86.R_SP = M.x86.R_BP;
+ M.x86.R_BP = pop_word();
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xca
+****************************************************************************/
+static void
+x86emuOp_ret_far_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u16 imm;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("RETF\t");
+ imm = fetch_word_imm();
+ DECODE_PRINTF2("%x\n", imm);
+ RETURN_TRACE("RETF", M.x86.saved_cs, M.x86.saved_ip);
+ TRACE_AND_STEP();
+ M.x86.R_IP = pop_word();
+ M.x86.R_CS = pop_word();
+ M.x86.R_SP += imm;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xcb
+****************************************************************************/
+static void
+x86emuOp_ret_far(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("RETF\n");
+ RETURN_TRACE("RETF", M.x86.saved_cs, M.x86.saved_ip);
+ TRACE_AND_STEP();
+ M.x86.R_IP = pop_word();
+ M.x86.R_CS = pop_word();
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xcc
+****************************************************************************/
+static void
+x86emuOp_int3(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("INT 3\n");
+ TRACE_AND_STEP();
+ if (_X86EMU_intrTab[3]) {
+ (*_X86EMU_intrTab[3]) (3);
+ }
+ else {
+ push_word((u16) M.x86.R_FLG);
+ CLEAR_FLAG(F_IF);
+ CLEAR_FLAG(F_TF);
+ push_word(M.x86.R_CS);
+ M.x86.R_CS = mem_access_word(3 * 4 + 2);
+ push_word(M.x86.R_IP);
+ M.x86.R_IP = mem_access_word(3 * 4);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xcd
+****************************************************************************/
+static void
+x86emuOp_int_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u8 intnum;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("INT\t");
+ intnum = fetch_byte_imm();
+ DECODE_PRINTF2("%x\n", intnum);
+ TRACE_AND_STEP();
+ if (_X86EMU_intrTab[intnum]) {
+ (*_X86EMU_intrTab[intnum]) (intnum);
+ }
+ else {
+ push_word((u16) M.x86.R_FLG);
+ CLEAR_FLAG(F_IF);
+ CLEAR_FLAG(F_TF);
+ push_word(M.x86.R_CS);
+ M.x86.R_CS = mem_access_word(intnum * 4 + 2);
+ push_word(M.x86.R_IP);
+ M.x86.R_IP = mem_access_word(intnum * 4);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xce
+****************************************************************************/
+static void
+x86emuOp_into(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("INTO\n");
+ TRACE_AND_STEP();
+ if (ACCESS_FLAG(F_OF)) {
+ if (_X86EMU_intrTab[4]) {
+ (*_X86EMU_intrTab[4]) (4);
+ }
+ else {
+ push_word((u16) M.x86.R_FLG);
+ CLEAR_FLAG(F_IF);
+ CLEAR_FLAG(F_TF);
+ push_word(M.x86.R_CS);
+ M.x86.R_CS = mem_access_word(4 * 4 + 2);
+ push_word(M.x86.R_IP);
+ M.x86.R_IP = mem_access_word(4 * 4);
+ }
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xcf
+****************************************************************************/
+static void
+x86emuOp_iret(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("IRET\n");
+
+ TRACE_AND_STEP();
+
+ M.x86.R_IP = pop_word();
+ M.x86.R_CS = pop_word();
+ M.x86.R_FLG = pop_word();
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xd0
+****************************************************************************/
+static void
+x86emuOp_opcD0_byte_RM_1(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg;
+ uint destoffset;
+ u8 destval;
+
+ /*
+ * Yet another weirdo special case instruction format. Part of
+ * the opcode held below in "RH". Doubly nested case would
+ * result, except that the decoded instruction
+ */
+ START_OF_INSTR();
+ FETCH_DECODE_MODRM(mod, rh, rl);
+#ifdef DEBUG
+ if (DEBUG_DECODE()) {
+ /* XXX DECODE_PRINTF may be changed to something more
+ general, so that it is important to leave the strings
+ in the same format, even though the result is that the
+ above test is done twice. */
+ switch (rh) {
+ case 0:
+ DECODE_PRINTF("ROL\t");
+ break;
+ case 1:
+ DECODE_PRINTF("ROR\t");
+ break;
+ case 2:
+ DECODE_PRINTF("RCL\t");
+ break;
+ case 3:
+ DECODE_PRINTF("RCR\t");
+ break;
+ case 4:
+ DECODE_PRINTF("SHL\t");
+ break;
+ case 5:
+ DECODE_PRINTF("SHR\t");
+ break;
+ case 6:
+ DECODE_PRINTF("SAL\t");
+ break;
+ case 7:
+ DECODE_PRINTF("SAR\t");
+ break;
+ }
+ }
+#endif
+ /* know operation, decode the mod byte to find the addressing
+ mode. */
+ switch (mod) {
+ case 0:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",1\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD0_byte_operation[rh]) (destval, 1);
+ store_data_byte(destoffset, destval);
+ break;
+ case 1:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",1\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD0_byte_operation[rh]) (destval, 1);
+ store_data_byte(destoffset, destval);
+ break;
+ case 2:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",1\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD0_byte_operation[rh]) (destval, 1);
+ store_data_byte(destoffset, destval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF(",1\n");
+ TRACE_AND_STEP();
+ destval = (*opcD0_byte_operation[rh]) (*destreg, 1);
+ *destreg = destval;
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xd1
+****************************************************************************/
+static void
+x86emuOp_opcD1_word_RM_1(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+
+ /*
+ * Yet another weirdo special case instruction format. Part of
+ * the opcode held below in "RH". Doubly nested case would
+ * result, except that the decoded instruction
+ */
+ START_OF_INSTR();
+ FETCH_DECODE_MODRM(mod, rh, rl);
+#ifdef DEBUG
+ if (DEBUG_DECODE()) {
+ /* XXX DECODE_PRINTF may be changed to something more
+ general, so that it is important to leave the strings
+ in the same format, even though the result is that the
+ above test is done twice. */
+ switch (rh) {
+ case 0:
+ DECODE_PRINTF("ROL\t");
+ break;
+ case 1:
+ DECODE_PRINTF("ROR\t");
+ break;
+ case 2:
+ DECODE_PRINTF("RCL\t");
+ break;
+ case 3:
+ DECODE_PRINTF("RCR\t");
+ break;
+ case 4:
+ DECODE_PRINTF("SHL\t");
+ break;
+ case 5:
+ DECODE_PRINTF("SHR\t");
+ break;
+ case 6:
+ DECODE_PRINTF("SAL\t");
+ break;
+ case 7:
+ DECODE_PRINTF("SAR\t");
+ break;
+ }
+ }
+#endif
+ /* know operation, decode the mod byte to find the addressing
+ mode. */
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("DWORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",1\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD1_long_operation[rh]) (destval, 1);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("WORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",1\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD1_word_operation[rh]) (destval, 1);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("DWORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",1\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD1_long_operation[rh]) (destval, 1);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("WORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",1\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD1_word_operation[rh]) (destval, 1);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("DWORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",1\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD1_long_operation[rh]) (destval, 1);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",1\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD1_word_operation[rh]) (destval, 1);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+ u32 *destreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF(",1\n");
+ TRACE_AND_STEP();
+ destval = (*opcD1_long_operation[rh]) (*destreg, 1);
+ *destreg = destval;
+ }
+ else {
+ u16 destval;
+ u16 *destreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",1\n");
+ TRACE_AND_STEP();
+ destval = (*opcD1_word_operation[rh]) (*destreg, 1);
+ *destreg = destval;
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xd2
+****************************************************************************/
+static void
+x86emuOp_opcD2_byte_RM_CL(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg;
+ uint destoffset;
+ u8 destval;
+ u8 amt;
+
+ /*
+ * Yet another weirdo special case instruction format. Part of
+ * the opcode held below in "RH". Doubly nested case would
+ * result, except that the decoded instruction
+ */
+ START_OF_INSTR();
+ FETCH_DECODE_MODRM(mod, rh, rl);
+#ifdef DEBUG
+ if (DEBUG_DECODE()) {
+ /* XXX DECODE_PRINTF may be changed to something more
+ general, so that it is important to leave the strings
+ in the same format, even though the result is that the
+ above test is done twice. */
+ switch (rh) {
+ case 0:
+ DECODE_PRINTF("ROL\t");
+ break;
+ case 1:
+ DECODE_PRINTF("ROR\t");
+ break;
+ case 2:
+ DECODE_PRINTF("RCL\t");
+ break;
+ case 3:
+ DECODE_PRINTF("RCR\t");
+ break;
+ case 4:
+ DECODE_PRINTF("SHL\t");
+ break;
+ case 5:
+ DECODE_PRINTF("SHR\t");
+ break;
+ case 6:
+ DECODE_PRINTF("SAL\t");
+ break;
+ case 7:
+ DECODE_PRINTF("SAR\t");
+ break;
+ }
+ }
+#endif
+ /* know operation, decode the mod byte to find the addressing
+ mode. */
+ amt = M.x86.R_CL;
+ switch (mod) {
+ case 0:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",CL\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD0_byte_operation[rh]) (destval, amt);
+ store_data_byte(destoffset, destval);
+ break;
+ case 1:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",CL\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD0_byte_operation[rh]) (destval, amt);
+ store_data_byte(destoffset, destval);
+ break;
+ case 2:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",CL\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD0_byte_operation[rh]) (destval, amt);
+ store_data_byte(destoffset, destval);
+ break;
+ case 3: /* register to register */
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF(",CL\n");
+ TRACE_AND_STEP();
+ destval = (*opcD0_byte_operation[rh]) (*destreg, amt);
+ *destreg = destval;
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xd3
+****************************************************************************/
+static void
+x86emuOp_opcD3_word_RM_CL(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+ u8 amt;
+
+ /*
+ * Yet another weirdo special case instruction format. Part of
+ * the opcode held below in "RH". Doubly nested case would
+ * result, except that the decoded instruction
+ */
+ START_OF_INSTR();
+ FETCH_DECODE_MODRM(mod, rh, rl);
+#ifdef DEBUG
+ if (DEBUG_DECODE()) {
+ /* XXX DECODE_PRINTF may be changed to something more
+ general, so that it is important to leave the strings
+ in the same format, even though the result is that the
+ above test is done twice. */
+ switch (rh) {
+ case 0:
+ DECODE_PRINTF("ROL\t");
+ break;
+ case 1:
+ DECODE_PRINTF("ROR\t");
+ break;
+ case 2:
+ DECODE_PRINTF("RCL\t");
+ break;
+ case 3:
+ DECODE_PRINTF("RCR\t");
+ break;
+ case 4:
+ DECODE_PRINTF("SHL\t");
+ break;
+ case 5:
+ DECODE_PRINTF("SHR\t");
+ break;
+ case 6:
+ DECODE_PRINTF("SAL\t");
+ break;
+ case 7:
+ DECODE_PRINTF("SAR\t");
+ break;
+ }
+ }
+#endif
+ /* know operation, decode the mod byte to find the addressing
+ mode. */
+ amt = M.x86.R_CL;
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("DWORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",CL\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD1_long_operation[rh]) (destval, amt);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("WORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",CL\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD1_word_operation[rh]) (destval, amt);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("DWORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",CL\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD1_long_operation[rh]) (destval, amt);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("WORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",CL\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD1_word_operation[rh]) (destval, amt);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("DWORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",CL\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD1_long_operation[rh]) (destval, amt);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("WORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",CL\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = (*opcD1_word_operation[rh]) (destval, amt);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF(",CL\n");
+ TRACE_AND_STEP();
+ *destreg = (*opcD1_long_operation[rh]) (*destreg, amt);
+ }
+ else {
+ u16 *destreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",CL\n");
+ TRACE_AND_STEP();
+ *destreg = (*opcD1_word_operation[rh]) (*destreg, amt);
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xd4
+****************************************************************************/
+static void
+x86emuOp_aam(u8 X86EMU_UNUSED(op1))
+{
+ u8 a;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("AAM\n");
+ a = fetch_byte_imm(); /* this is a stupid encoding. */
+ if (a != 10) {
+ /* fix: add base decoding
+ aam_word(u8 val, int base a) */
+ DECODE_PRINTF("ERROR DECODING AAM\n");
+ TRACE_REGS();
+ HALT_SYS();
+ }
+ TRACE_AND_STEP();
+ /* note the type change here --- returning AL and AH in AX. */
+ M.x86.R_AX = aam_word(M.x86.R_AL);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xd5
+****************************************************************************/
+static void
+x86emuOp_aad(u8 X86EMU_UNUSED(op1))
+{
+ u8 a;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("AAD\n");
+ a = fetch_byte_imm();
+ if (a != 10) {
+ /* fix: add base decoding
+ aad_word(u16 val, int base a) */
+ DECODE_PRINTF("ERROR DECODING AAM\n");
+ TRACE_REGS();
+ HALT_SYS();
+ }
+ TRACE_AND_STEP();
+ M.x86.R_AX = aad_word(M.x86.R_AX);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/* opcode 0xd6 ILLEGAL OPCODE */
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xd7
+****************************************************************************/
+static void
+x86emuOp_xlat(u8 X86EMU_UNUSED(op1))
+{
+ u16 addr;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("XLAT\n");
+ TRACE_AND_STEP();
+ addr = (u16) (M.x86.R_BX + (u8) M.x86.R_AL);
+ M.x86.R_AL = fetch_data_byte(addr);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/* instuctions D8 .. DF are in i87_ops.c */
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xe0
+****************************************************************************/
+static void
+x86emuOp_loopne(u8 X86EMU_UNUSED(op1))
+{
+ s16 ip;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("LOOPNE\t");
+ ip = (s8) fetch_byte_imm();
+ ip += (s16) M.x86.R_IP;
+ DECODE_PRINTF2("%04x\n", ip);
+ TRACE_AND_STEP();
+ M.x86.R_CX -= 1;
+ if (M.x86.R_CX != 0 && !ACCESS_FLAG(F_ZF)) /* CX != 0 and !ZF */
+ M.x86.R_IP = ip;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xe1
+****************************************************************************/
+static void
+x86emuOp_loope(u8 X86EMU_UNUSED(op1))
+{
+ s16 ip;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("LOOPE\t");
+ ip = (s8) fetch_byte_imm();
+ ip += (s16) M.x86.R_IP;
+ DECODE_PRINTF2("%04x\n", ip);
+ TRACE_AND_STEP();
+ M.x86.R_CX -= 1;
+ if (M.x86.R_CX != 0 && ACCESS_FLAG(F_ZF)) /* CX != 0 and ZF */
+ M.x86.R_IP = ip;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xe2
+****************************************************************************/
+static void
+x86emuOp_loop(u8 X86EMU_UNUSED(op1))
+{
+ s16 ip;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("LOOP\t");
+ ip = (s8) fetch_byte_imm();
+ ip += (s16) M.x86.R_IP;
+ DECODE_PRINTF2("%04x\n", ip);
+ TRACE_AND_STEP();
+ M.x86.R_CX -= 1;
+ if (M.x86.R_CX != 0)
+ M.x86.R_IP = ip;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xe3
+****************************************************************************/
+static void
+x86emuOp_jcxz(u8 X86EMU_UNUSED(op1))
+{
+ u16 target;
+ s8 offset;
+
+ /* jump to byte offset if overflow flag is set */
+ START_OF_INSTR();
+ DECODE_PRINTF("JCXZ\t");
+ offset = (s8) fetch_byte_imm();
+ target = (u16) (M.x86.R_IP + offset);
+ DECODE_PRINTF2("%x\n", target);
+ TRACE_AND_STEP();
+ if (M.x86.R_CX == 0)
+ M.x86.R_IP = target;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xe4
+****************************************************************************/
+static void
+x86emuOp_in_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u8 port;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("IN\t");
+ port = (u8) fetch_byte_imm();
+ DECODE_PRINTF2("%x,AL\n", port);
+ TRACE_AND_STEP();
+ M.x86.R_AL = (*sys_inb) (port);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xe5
+****************************************************************************/
+static void
+x86emuOp_in_word_AX_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u8 port;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("IN\t");
+ port = (u8) fetch_byte_imm();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF2("EAX,%x\n", port);
+ }
+ else {
+ DECODE_PRINTF2("AX,%x\n", port);
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EAX = (*sys_inl) (port);
+ }
+ else {
+ M.x86.R_AX = (*sys_inw) (port);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xe6
+****************************************************************************/
+static void
+x86emuOp_out_byte_IMM_AL(u8 X86EMU_UNUSED(op1))
+{
+ u8 port;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("OUT\t");
+ port = (u8) fetch_byte_imm();
+ DECODE_PRINTF2("%x,AL\n", port);
+ TRACE_AND_STEP();
+ (*sys_outb) (port, M.x86.R_AL);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xe7
+****************************************************************************/
+static void
+x86emuOp_out_word_IMM_AX(u8 X86EMU_UNUSED(op1))
+{
+ u8 port;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("OUT\t");
+ port = (u8) fetch_byte_imm();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF2("%x,EAX\n", port);
+ }
+ else {
+ DECODE_PRINTF2("%x,AX\n", port);
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ (*sys_outl) (port, M.x86.R_EAX);
+ }
+ else {
+ (*sys_outw) (port, M.x86.R_AX);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xe8
+****************************************************************************/
+static void
+x86emuOp_call_near_IMM(u8 X86EMU_UNUSED(op1))
+{
+ s16 ip16;
+ s32 ip32;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("CALL\t");
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ ip32 = (s32) fetch_long_imm();
+ ip32 += (s16) M.x86.R_IP; /* CHECK SIGN */
+ DECODE_PRINTF2("%04x\n", (u16) ip32);
+ CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, M.x86.R_CS, ip32, "");
+ }
+ else {
+ ip16 = (s16) fetch_word_imm();
+ ip16 += (s16) M.x86.R_IP; /* CHECK SIGN */
+ DECODE_PRINTF2("%04x\n", (u16) ip16);
+ CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, M.x86.R_CS, ip16, "");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ push_long(M.x86.R_EIP);
+ M.x86.R_EIP = ip32 & 0xffff;
+ }
+ else {
+ push_word(M.x86.R_IP);
+ M.x86.R_EIP = ip16;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xe9
+****************************************************************************/
+static void
+x86emuOp_jump_near_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u32 ip;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("JMP\t");
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ ip = (u32) fetch_long_imm();
+ ip += (u32) M.x86.R_EIP;
+ DECODE_PRINTF2("%08x\n", (u32) ip);
+ TRACE_AND_STEP();
+ M.x86.R_EIP = (u32) ip;
+ }
+ else {
+ ip = (s16) fetch_word_imm();
+ ip += (s16) M.x86.R_IP;
+ DECODE_PRINTF2("%04x\n", (u16) ip);
+ TRACE_AND_STEP();
+ M.x86.R_IP = (u16) ip;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xea
+****************************************************************************/
+static void
+x86emuOp_jump_far_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u16 cs;
+ u32 ip;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("JMP\tFAR ");
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ ip = fetch_long_imm();
+ }
+ else {
+ ip = fetch_word_imm();
+ }
+ cs = fetch_word_imm();
+ DECODE_PRINTF2("%04x:", cs);
+ DECODE_PRINTF2("%04x\n", ip);
+ TRACE_AND_STEP();
+ M.x86.R_EIP = ip & 0xffff;
+ M.x86.R_CS = cs;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xeb
+****************************************************************************/
+static void
+x86emuOp_jump_byte_IMM(u8 X86EMU_UNUSED(op1))
+{
+ u16 target;
+ s8 offset;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("JMP\t");
+ offset = (s8) fetch_byte_imm();
+ target = (u16) (M.x86.R_IP + offset);
+ DECODE_PRINTF2("%x\n", target);
+ TRACE_AND_STEP();
+ M.x86.R_IP = target;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xec
+****************************************************************************/
+static void
+x86emuOp_in_byte_AL_DX(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("IN\tAL,DX\n");
+ TRACE_AND_STEP();
+ M.x86.R_AL = (*sys_inb) (M.x86.R_DX);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xed
+****************************************************************************/
+static void
+x86emuOp_in_word_AX_DX(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("IN\tEAX,DX\n");
+ }
+ else {
+ DECODE_PRINTF("IN\tAX,DX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_EAX = (*sys_inl) (M.x86.R_DX);
+ }
+ else {
+ M.x86.R_AX = (*sys_inw) (M.x86.R_DX);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xee
+****************************************************************************/
+static void
+x86emuOp_out_byte_DX_AL(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("OUT\tDX,AL\n");
+ TRACE_AND_STEP();
+ (*sys_outb) (M.x86.R_DX, M.x86.R_AL);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xef
+****************************************************************************/
+static void
+x86emuOp_out_word_DX_AX(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("OUT\tDX,EAX\n");
+ }
+ else {
+ DECODE_PRINTF("OUT\tDX,AX\n");
+ }
+ TRACE_AND_STEP();
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ (*sys_outl) (M.x86.R_DX, M.x86.R_EAX);
+ }
+ else {
+ (*sys_outw) (M.x86.R_DX, M.x86.R_AX);
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xf0
+****************************************************************************/
+static void
+x86emuOp_lock(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("LOCK:\n");
+ TRACE_AND_STEP();
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/*opcode 0xf1 ILLEGAL OPERATION */
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xf2
+****************************************************************************/
+static void
+x86emuOp_repne(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("REPNE\n");
+ TRACE_AND_STEP();
+ M.x86.mode |= SYSMODE_PREFIX_REPNE;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xf3
+****************************************************************************/
+static void
+x86emuOp_repe(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("REPE\n");
+ TRACE_AND_STEP();
+ M.x86.mode |= SYSMODE_PREFIX_REPE;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xf4
+****************************************************************************/
+static void
+x86emuOp_halt(u8 X86EMU_UNUSED(op1))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("HALT\n");
+ TRACE_AND_STEP();
+ HALT_SYS();
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xf5
+****************************************************************************/
+static void
+x86emuOp_cmc(u8 X86EMU_UNUSED(op1))
+{
+ /* complement the carry flag. */
+ START_OF_INSTR();
+ DECODE_PRINTF("CMC\n");
+ TRACE_AND_STEP();
+ TOGGLE_FLAG(F_CF);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xf6
+****************************************************************************/
+static void
+x86emuOp_opcF6_byte_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ u8 *destreg;
+ uint destoffset;
+ u8 destval, srcval;
+
+ /* long, drawn out code follows. Double switch for a total
+ of 32 cases. */
+ START_OF_INSTR();
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0: /* mod=00 */
+ switch (rh) {
+ case 0: /* test byte imm */
+ DECODE_PRINTF("TEST\tBYTE PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ srcval = fetch_byte_imm();
+ DECODE_PRINTF2("%02x\n", srcval);
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ test_byte(destval, srcval);
+ break;
+ case 1:
+ DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n");
+ HALT_SYS();
+ break;
+ case 2:
+ DECODE_PRINTF("NOT\tBYTE PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = not_byte(destval);
+ store_data_byte(destoffset, destval);
+ break;
+ case 3:
+ DECODE_PRINTF("NEG\tBYTE PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = neg_byte(destval);
+ store_data_byte(destoffset, destval);
+ break;
+ case 4:
+ DECODE_PRINTF("MUL\tBYTE PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ mul_byte(destval);
+ break;
+ case 5:
+ DECODE_PRINTF("IMUL\tBYTE PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ imul_byte(destval);
+ break;
+ case 6:
+ DECODE_PRINTF("DIV\tBYTE PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ div_byte(destval);
+ break;
+ case 7:
+ DECODE_PRINTF("IDIV\tBYTE PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ idiv_byte(destval);
+ break;
+ }
+ break; /* end mod==00 */
+ case 1: /* mod=01 */
+ switch (rh) {
+ case 0: /* test byte imm */
+ DECODE_PRINTF("TEST\tBYTE PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ srcval = fetch_byte_imm();
+ DECODE_PRINTF2("%02x\n", srcval);
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ test_byte(destval, srcval);
+ break;
+ case 1:
+ DECODE_PRINTF("ILLEGAL OP MOD=01 RH=01 OP=F6\n");
+ HALT_SYS();
+ break;
+ case 2:
+ DECODE_PRINTF("NOT\tBYTE PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = not_byte(destval);
+ store_data_byte(destoffset, destval);
+ break;
+ case 3:
+ DECODE_PRINTF("NEG\tBYTE PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = neg_byte(destval);
+ store_data_byte(destoffset, destval);
+ break;
+ case 4:
+ DECODE_PRINTF("MUL\tBYTE PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ mul_byte(destval);
+ break;
+ case 5:
+ DECODE_PRINTF("IMUL\tBYTE PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ imul_byte(destval);
+ break;
+ case 6:
+ DECODE_PRINTF("DIV\tBYTE PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ div_byte(destval);
+ break;
+ case 7:
+ DECODE_PRINTF("IDIV\tBYTE PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ idiv_byte(destval);
+ break;
+ }
+ break; /* end mod==01 */
+ case 2: /* mod=10 */
+ switch (rh) {
+ case 0: /* test byte imm */
+ DECODE_PRINTF("TEST\tBYTE PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ srcval = fetch_byte_imm();
+ DECODE_PRINTF2("%02x\n", srcval);
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ test_byte(destval, srcval);
+ break;
+ case 1:
+ DECODE_PRINTF("ILLEGAL OP MOD=10 RH=01 OP=F6\n");
+ HALT_SYS();
+ break;
+ case 2:
+ DECODE_PRINTF("NOT\tBYTE PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = not_byte(destval);
+ store_data_byte(destoffset, destval);
+ break;
+ case 3:
+ DECODE_PRINTF("NEG\tBYTE PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = neg_byte(destval);
+ store_data_byte(destoffset, destval);
+ break;
+ case 4:
+ DECODE_PRINTF("MUL\tBYTE PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ mul_byte(destval);
+ break;
+ case 5:
+ DECODE_PRINTF("IMUL\tBYTE PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ imul_byte(destval);
+ break;
+ case 6:
+ DECODE_PRINTF("DIV\tBYTE PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ div_byte(destval);
+ break;
+ case 7:
+ DECODE_PRINTF("IDIV\tBYTE PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ idiv_byte(destval);
+ break;
+ }
+ break; /* end mod==10 */
+ case 3: /* mod=11 */
+ switch (rh) {
+ case 0: /* test byte imm */
+ DECODE_PRINTF("TEST\t");
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcval = fetch_byte_imm();
+ DECODE_PRINTF2("%02x\n", srcval);
+ TRACE_AND_STEP();
+ test_byte(*destreg, srcval);
+ break;
+ case 1:
+ DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n");
+ HALT_SYS();
+ break;
+ case 2:
+ DECODE_PRINTF("NOT\t");
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = not_byte(*destreg);
+ break;
+ case 3:
+ DECODE_PRINTF("NEG\t");
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = neg_byte(*destreg);
+ break;
+ case 4:
+ DECODE_PRINTF("MUL\t");
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ mul_byte(*destreg); /*!!! */
+ break;
+ case 5:
+ DECODE_PRINTF("IMUL\t");
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ imul_byte(*destreg);
+ break;
+ case 6:
+ DECODE_PRINTF("DIV\t");
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ div_byte(*destreg);
+ break;
+ case 7:
+ DECODE_PRINTF("IDIV\t");
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ idiv_byte(*destreg);
+ break;
+ }
+ break; /* end mod==11 */
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xf7
+****************************************************************************/
+static void
+x86emuOp_opcF7_word_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rl, rh;
+ uint destoffset;
+
+ /* long, drawn out code follows. Double switch for a total
+ of 32 cases. */
+ START_OF_INSTR();
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0: /* mod=00 */
+ switch (rh) {
+ case 0: /* test word imm */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval, srcval;
+
+ DECODE_PRINTF("TEST\tDWORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ srcval = fetch_long_imm();
+ DECODE_PRINTF2("%x\n", srcval);
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ test_long(destval, srcval);
+ }
+ else {
+ u16 destval, srcval;
+
+ DECODE_PRINTF("TEST\tWORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ srcval = fetch_word_imm();
+ DECODE_PRINTF2("%x\n", srcval);
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ test_word(destval, srcval);
+ }
+ break;
+ case 1:
+ DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F7\n");
+ HALT_SYS();
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("NOT\tDWORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = not_long(destval);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("NOT\tWORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = not_word(destval);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 3:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("NEG\tDWORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = neg_long(destval);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("NEG\tWORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = neg_word(destval);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 4:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("MUL\tDWORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ mul_long(destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("MUL\tWORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ mul_word(destval);
+ }
+ break;
+ case 5:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("IMUL\tDWORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ imul_long(destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("IMUL\tWORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ imul_word(destval);
+ }
+ break;
+ case 6:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("DIV\tDWORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ div_long(destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("DIV\tWORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ div_word(destval);
+ }
+ break;
+ case 7:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("IDIV\tDWORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ idiv_long(destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("IDIV\tWORD PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ idiv_word(destval);
+ }
+ break;
+ }
+ break; /* end mod==00 */
+ case 1: /* mod=01 */
+ switch (rh) {
+ case 0: /* test word imm */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval, srcval;
+
+ DECODE_PRINTF("TEST\tDWORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ srcval = fetch_long_imm();
+ DECODE_PRINTF2("%x\n", srcval);
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ test_long(destval, srcval);
+ }
+ else {
+ u16 destval, srcval;
+
+ DECODE_PRINTF("TEST\tWORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ srcval = fetch_word_imm();
+ DECODE_PRINTF2("%x\n", srcval);
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ test_word(destval, srcval);
+ }
+ break;
+ case 1:
+ DECODE_PRINTF("ILLEGAL OP MOD=01 RH=01 OP=F6\n");
+ HALT_SYS();
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("NOT\tDWORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = not_long(destval);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("NOT\tWORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = not_word(destval);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 3:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("NEG\tDWORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = neg_long(destval);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("NEG\tWORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = neg_word(destval);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 4:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("MUL\tDWORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ mul_long(destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("MUL\tWORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ mul_word(destval);
+ }
+ break;
+ case 5:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("IMUL\tDWORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ imul_long(destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("IMUL\tWORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ imul_word(destval);
+ }
+ break;
+ case 6:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("DIV\tDWORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ div_long(destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("DIV\tWORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ div_word(destval);
+ }
+ break;
+ case 7:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("IDIV\tDWORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ idiv_long(destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("IDIV\tWORD PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ idiv_word(destval);
+ }
+ break;
+ }
+ break; /* end mod==01 */
+ case 2: /* mod=10 */
+ switch (rh) {
+ case 0: /* test word imm */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval, srcval;
+
+ DECODE_PRINTF("TEST\tDWORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ srcval = fetch_long_imm();
+ DECODE_PRINTF2("%x\n", srcval);
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ test_long(destval, srcval);
+ }
+ else {
+ u16 destval, srcval;
+
+ DECODE_PRINTF("TEST\tWORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ srcval = fetch_word_imm();
+ DECODE_PRINTF2("%x\n", srcval);
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ test_word(destval, srcval);
+ }
+ break;
+ case 1:
+ DECODE_PRINTF("ILLEGAL OP MOD=10 RH=01 OP=F6\n");
+ HALT_SYS();
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("NOT\tDWORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = not_long(destval);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("NOT\tWORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = not_word(destval);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 3:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("NEG\tDWORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = neg_long(destval);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("NEG\tWORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = neg_word(destval);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 4:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("MUL\tDWORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ mul_long(destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("MUL\tWORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ mul_word(destval);
+ }
+ break;
+ case 5:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("IMUL\tDWORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ imul_long(destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("IMUL\tWORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ imul_word(destval);
+ }
+ break;
+ case 6:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("DIV\tDWORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ div_long(destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("DIV\tWORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ div_word(destval);
+ }
+ break;
+ case 7:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ DECODE_PRINTF("IDIV\tDWORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ idiv_long(destval);
+ }
+ else {
+ u16 destval;
+
+ DECODE_PRINTF("IDIV\tWORD PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ idiv_word(destval);
+ }
+ break;
+ }
+ break; /* end mod==10 */
+ case 3: /* mod=11 */
+ switch (rh) {
+ case 0: /* test word imm */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+ u32 srcval;
+
+ DECODE_PRINTF("TEST\t");
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcval = fetch_long_imm();
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ test_long(*destreg, srcval);
+ }
+ else {
+ u16 *destreg;
+ u16 srcval;
+
+ DECODE_PRINTF("TEST\t");
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",");
+ srcval = fetch_word_imm();
+ DECODE_PRINTF2("%x\n", srcval);
+ TRACE_AND_STEP();
+ test_word(*destreg, srcval);
+ }
+ break;
+ case 1:
+ DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n");
+ HALT_SYS();
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+
+ DECODE_PRINTF("NOT\t");
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = not_long(*destreg);
+ }
+ else {
+ u16 *destreg;
+
+ DECODE_PRINTF("NOT\t");
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = not_word(*destreg);
+ }
+ break;
+ case 3:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+
+ DECODE_PRINTF("NEG\t");
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = neg_long(*destreg);
+ }
+ else {
+ u16 *destreg;
+
+ DECODE_PRINTF("NEG\t");
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = neg_word(*destreg);
+ }
+ break;
+ case 4:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+
+ DECODE_PRINTF("MUL\t");
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ mul_long(*destreg); /*!!! */
+ }
+ else {
+ u16 *destreg;
+
+ DECODE_PRINTF("MUL\t");
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ mul_word(*destreg); /*!!! */
+ }
+ break;
+ case 5:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+
+ DECODE_PRINTF("IMUL\t");
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ imul_long(*destreg);
+ }
+ else {
+ u16 *destreg;
+
+ DECODE_PRINTF("IMUL\t");
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ imul_word(*destreg);
+ }
+ break;
+ case 6:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+
+ DECODE_PRINTF("DIV\t");
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ div_long(*destreg);
+ }
+ else {
+ u16 *destreg;
+
+ DECODE_PRINTF("DIV\t");
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ div_word(*destreg);
+ }
+ break;
+ case 7:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+
+ DECODE_PRINTF("IDIV\t");
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ idiv_long(*destreg);
+ }
+ else {
+ u16 *destreg;
+
+ DECODE_PRINTF("IDIV\t");
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ idiv_word(*destreg);
+ }
+ break;
+ }
+ break; /* end mod==11 */
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xf8
+****************************************************************************/
+static void
+x86emuOp_clc(u8 X86EMU_UNUSED(op1))
+{
+ /* clear the carry flag. */
+ START_OF_INSTR();
+ DECODE_PRINTF("CLC\n");
+ TRACE_AND_STEP();
+ CLEAR_FLAG(F_CF);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xf9
+****************************************************************************/
+static void
+x86emuOp_stc(u8 X86EMU_UNUSED(op1))
+{
+ /* set the carry flag. */
+ START_OF_INSTR();
+ DECODE_PRINTF("STC\n");
+ TRACE_AND_STEP();
+ SET_FLAG(F_CF);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xfa
+****************************************************************************/
+static void
+x86emuOp_cli(u8 X86EMU_UNUSED(op1))
+{
+ /* clear interrupts. */
+ START_OF_INSTR();
+ DECODE_PRINTF("CLI\n");
+ TRACE_AND_STEP();
+ CLEAR_FLAG(F_IF);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xfb
+****************************************************************************/
+static void
+x86emuOp_sti(u8 X86EMU_UNUSED(op1))
+{
+ /* enable interrupts. */
+ START_OF_INSTR();
+ DECODE_PRINTF("STI\n");
+ TRACE_AND_STEP();
+ SET_FLAG(F_IF);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xfc
+****************************************************************************/
+static void
+x86emuOp_cld(u8 X86EMU_UNUSED(op1))
+{
+ /* clear interrupts. */
+ START_OF_INSTR();
+ DECODE_PRINTF("CLD\n");
+ TRACE_AND_STEP();
+ CLEAR_FLAG(F_DF);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xfd
+****************************************************************************/
+static void
+x86emuOp_std(u8 X86EMU_UNUSED(op1))
+{
+ /* clear interrupts. */
+ START_OF_INSTR();
+ DECODE_PRINTF("STD\n");
+ TRACE_AND_STEP();
+ SET_FLAG(F_DF);
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xfe
+****************************************************************************/
+static void
+x86emuOp_opcFE_byte_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rh, rl;
+ u8 destval;
+ uint destoffset;
+ u8 *destreg;
+
+ /* Yet another special case instruction. */
+ START_OF_INSTR();
+ FETCH_DECODE_MODRM(mod, rh, rl);
+#ifdef DEBUG
+ if (DEBUG_DECODE()) {
+ /* XXX DECODE_PRINTF may be changed to something more
+ general, so that it is important to leave the strings
+ in the same format, even though the result is that the
+ above test is done twice. */
+
+ switch (rh) {
+ case 0:
+ DECODE_PRINTF("INC\t");
+ break;
+ case 1:
+ DECODE_PRINTF("DEC\t");
+ break;
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ DECODE_PRINTF2("ILLEGAL OP MAJOR OP 0xFE MINOR OP %x \n", mod);
+ HALT_SYS();
+ break;
+ }
+ }
+#endif
+ switch (mod) {
+ case 0:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ switch (rh) {
+ case 0: /* inc word ptr ... */
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = inc_byte(destval);
+ store_data_byte(destoffset, destval);
+ break;
+ case 1: /* dec word ptr ... */
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = dec_byte(destval);
+ store_data_byte(destoffset, destval);
+ break;
+ }
+ break;
+ case 1:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ switch (rh) {
+ case 0:
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = inc_byte(destval);
+ store_data_byte(destoffset, destval);
+ break;
+ case 1:
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = dec_byte(destval);
+ store_data_byte(destoffset, destval);
+ break;
+ }
+ break;
+ case 2:
+ DECODE_PRINTF("BYTE PTR ");
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ switch (rh) {
+ case 0:
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = inc_byte(destval);
+ store_data_byte(destoffset, destval);
+ break;
+ case 1:
+ destval = fetch_data_byte(destoffset);
+ TRACE_AND_STEP();
+ destval = dec_byte(destval);
+ store_data_byte(destoffset, destval);
+ break;
+ }
+ break;
+ case 3:
+ destreg = DECODE_RM_BYTE_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ switch (rh) {
+ case 0:
+ TRACE_AND_STEP();
+ *destreg = inc_byte(*destreg);
+ break;
+ case 1:
+ TRACE_AND_STEP();
+ *destreg = dec_byte(*destreg);
+ break;
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0xff
+****************************************************************************/
+static void
+x86emuOp_opcFF_word_RM(u8 X86EMU_UNUSED(op1))
+{
+ int mod, rh, rl;
+ uint destoffset = 0;
+ u16 *destreg;
+ u16 destval, destval2;
+
+ /* Yet another special case instruction. */
+ START_OF_INSTR();
+ FETCH_DECODE_MODRM(mod, rh, rl);
+#ifdef DEBUG
+ if (DEBUG_DECODE()) {
+ /* XXX DECODE_PRINTF may be changed to something more
+ general, so that it is important to leave the strings
+ in the same format, even though the result is that the
+ above test is done twice. */
+
+ switch (rh) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("INC\tDWORD PTR ");
+ }
+ else {
+ DECODE_PRINTF("INC\tWORD PTR ");
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ DECODE_PRINTF("DEC\tDWORD PTR ");
+ }
+ else {
+ DECODE_PRINTF("DEC\tWORD PTR ");
+ }
+ break;
+ case 2:
+ DECODE_PRINTF("CALL\t");
+ break;
+ case 3:
+ DECODE_PRINTF("CALL\tFAR ");
+ break;
+ case 4:
+ DECODE_PRINTF("JMP\t");
+ break;
+ case 5:
+ DECODE_PRINTF("JMP\tFAR ");
+ break;
+ case 6:
+ DECODE_PRINTF("PUSH\t");
+ break;
+ case 7:
+ DECODE_PRINTF("ILLEGAL DECODING OF OPCODE FF\t");
+ HALT_SYS();
+ break;
+ }
+ }
+#endif
+ switch (mod) {
+ case 0:
+ destoffset = decode_rm00_address(rl);
+ DECODE_PRINTF("\n");
+ switch (rh) {
+ case 0: /* inc word ptr ... */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = inc_long(destval);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = inc_word(destval);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 1: /* dec word ptr ... */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = dec_long(destval);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = dec_word(destval);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 2: /* call word ptr ... */
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ push_word(M.x86.R_IP);
+ M.x86.R_IP = destval;
+ break;
+ case 3: /* call far ptr ... */
+ destval = fetch_data_word(destoffset);
+ destval2 = fetch_data_word(destoffset + 2);
+ TRACE_AND_STEP();
+ push_word(M.x86.R_CS);
+ M.x86.R_CS = destval2;
+ push_word(M.x86.R_IP);
+ M.x86.R_IP = destval;
+ break;
+ case 4: /* jmp word ptr ... */
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ M.x86.R_IP = destval;
+ break;
+ case 5: /* jmp far ptr ... */
+ destval = fetch_data_word(destoffset);
+ destval2 = fetch_data_word(destoffset + 2);
+ TRACE_AND_STEP();
+ M.x86.R_IP = destval;
+ M.x86.R_CS = destval2;
+ break;
+ case 6: /* push word ptr ... */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ push_long(destval);
+ }
+ else {
+ u16 destval;
+
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ push_word(destval);
+ }
+ break;
+ }
+ break;
+ case 1:
+ destoffset = decode_rm01_address(rl);
+ DECODE_PRINTF("\n");
+ switch (rh) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = inc_long(destval);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = inc_word(destval);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = dec_long(destval);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = dec_word(destval);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 2: /* call word ptr ... */
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ push_word(M.x86.R_IP);
+ M.x86.R_IP = destval;
+ break;
+ case 3: /* call far ptr ... */
+ destval = fetch_data_word(destoffset);
+ destval2 = fetch_data_word(destoffset + 2);
+ TRACE_AND_STEP();
+ push_word(M.x86.R_CS);
+ M.x86.R_CS = destval2;
+ push_word(M.x86.R_IP);
+ M.x86.R_IP = destval;
+ break;
+ case 4: /* jmp word ptr ... */
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ M.x86.R_IP = destval;
+ break;
+ case 5: /* jmp far ptr ... */
+ destval = fetch_data_word(destoffset);
+ destval2 = fetch_data_word(destoffset + 2);
+ TRACE_AND_STEP();
+ M.x86.R_IP = destval;
+ M.x86.R_CS = destval2;
+ break;
+ case 6: /* push word ptr ... */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ push_long(destval);
+ }
+ else {
+ u16 destval;
+
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ push_word(destval);
+ }
+ break;
+ }
+ break;
+ case 2:
+ destoffset = decode_rm10_address(rl);
+ DECODE_PRINTF("\n");
+ switch (rh) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = inc_long(destval);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = inc_word(destval);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ destval = dec_long(destval);
+ store_data_long(destoffset, destval);
+ }
+ else {
+ u16 destval;
+
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ destval = dec_word(destval);
+ store_data_word(destoffset, destval);
+ }
+ break;
+ case 2: /* call word ptr ... */
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ push_word(M.x86.R_IP);
+ M.x86.R_IP = destval;
+ break;
+ case 3: /* call far ptr ... */
+ destval = fetch_data_word(destoffset);
+ destval2 = fetch_data_word(destoffset + 2);
+ TRACE_AND_STEP();
+ push_word(M.x86.R_CS);
+ M.x86.R_CS = destval2;
+ push_word(M.x86.R_IP);
+ M.x86.R_IP = destval;
+ break;
+ case 4: /* jmp word ptr ... */
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ M.x86.R_IP = destval;
+ break;
+ case 5: /* jmp far ptr ... */
+ destval = fetch_data_word(destoffset);
+ destval2 = fetch_data_word(destoffset + 2);
+ TRACE_AND_STEP();
+ M.x86.R_IP = destval;
+ M.x86.R_CS = destval2;
+ break;
+ case 6: /* push word ptr ... */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 destval;
+
+ destval = fetch_data_long(destoffset);
+ TRACE_AND_STEP();
+ push_long(destval);
+ }
+ else {
+ u16 destval;
+
+ destval = fetch_data_word(destoffset);
+ TRACE_AND_STEP();
+ push_word(destval);
+ }
+ break;
+ }
+ break;
+ case 3:
+ switch (rh) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = inc_long(*destreg);
+ }
+ else {
+ u16 *destreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = inc_word(*destreg);
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = dec_long(*destreg);
+ }
+ else {
+ u16 *destreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ *destreg = dec_word(*destreg);
+ }
+ break;
+ case 2: /* call word ptr ... */
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ push_word(M.x86.R_IP);
+ M.x86.R_IP = *destreg;
+ break;
+ case 3: /* jmp far ptr ... */
+ DECODE_PRINTF("OPERATION UNDEFINED 0XFF \n");
+ TRACE_AND_STEP();
+ HALT_SYS();
+ break;
+
+ case 4: /* jmp ... */
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ M.x86.R_IP = (u16) (*destreg);
+ break;
+ case 5: /* jmp far ptr ... */
+ DECODE_PRINTF("OPERATION UNDEFINED 0XFF \n");
+ TRACE_AND_STEP();
+ HALT_SYS();
+ break;
+ case 6:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *destreg;
+
+ destreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ push_long(*destreg);
+ }
+ else {
+ u16 *destreg;
+
+ destreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF("\n");
+ TRACE_AND_STEP();
+ push_word(*destreg);
+ }
+ break;
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/***************************************************************************
+ * Single byte operation code table:
+ **************************************************************************/
+void (*x86emu_optab[256]) (u8) = {
+/* 0x00 */ x86emuOp_add_byte_RM_R,
+/* 0x01 */ x86emuOp_add_word_RM_R,
+/* 0x02 */ x86emuOp_add_byte_R_RM,
+/* 0x03 */ x86emuOp_add_word_R_RM,
+/* 0x04 */ x86emuOp_add_byte_AL_IMM,
+/* 0x05 */ x86emuOp_add_word_AX_IMM,
+/* 0x06 */ x86emuOp_push_ES,
+/* 0x07 */ x86emuOp_pop_ES,
+/* 0x08 */ x86emuOp_or_byte_RM_R,
+/* 0x09 */ x86emuOp_or_word_RM_R,
+/* 0x0a */ x86emuOp_or_byte_R_RM,
+/* 0x0b */ x86emuOp_or_word_R_RM,
+/* 0x0c */ x86emuOp_or_byte_AL_IMM,
+/* 0x0d */ x86emuOp_or_word_AX_IMM,
+/* 0x0e */ x86emuOp_push_CS,
+/* 0x0f */ x86emuOp_two_byte,
+/* 0x10 */ x86emuOp_adc_byte_RM_R,
+/* 0x11 */ x86emuOp_adc_word_RM_R,
+/* 0x12 */ x86emuOp_adc_byte_R_RM,
+/* 0x13 */ x86emuOp_adc_word_R_RM,
+/* 0x14 */ x86emuOp_adc_byte_AL_IMM,
+/* 0x15 */ x86emuOp_adc_word_AX_IMM,
+/* 0x16 */ x86emuOp_push_SS,
+/* 0x17 */ x86emuOp_pop_SS,
+/* 0x18 */ x86emuOp_sbb_byte_RM_R,
+/* 0x19 */ x86emuOp_sbb_word_RM_R,
+/* 0x1a */ x86emuOp_sbb_byte_R_RM,
+/* 0x1b */ x86emuOp_sbb_word_R_RM,
+/* 0x1c */ x86emuOp_sbb_byte_AL_IMM,
+/* 0x1d */ x86emuOp_sbb_word_AX_IMM,
+/* 0x1e */ x86emuOp_push_DS,
+/* 0x1f */ x86emuOp_pop_DS,
+/* 0x20 */ x86emuOp_and_byte_RM_R,
+/* 0x21 */ x86emuOp_and_word_RM_R,
+/* 0x22 */ x86emuOp_and_byte_R_RM,
+/* 0x23 */ x86emuOp_and_word_R_RM,
+/* 0x24 */ x86emuOp_and_byte_AL_IMM,
+/* 0x25 */ x86emuOp_and_word_AX_IMM,
+/* 0x26 */ x86emuOp_segovr_ES,
+/* 0x27 */ x86emuOp_daa,
+/* 0x28 */ x86emuOp_sub_byte_RM_R,
+/* 0x29 */ x86emuOp_sub_word_RM_R,
+/* 0x2a */ x86emuOp_sub_byte_R_RM,
+/* 0x2b */ x86emuOp_sub_word_R_RM,
+/* 0x2c */ x86emuOp_sub_byte_AL_IMM,
+/* 0x2d */ x86emuOp_sub_word_AX_IMM,
+/* 0x2e */ x86emuOp_segovr_CS,
+/* 0x2f */ x86emuOp_das,
+/* 0x30 */ x86emuOp_xor_byte_RM_R,
+/* 0x31 */ x86emuOp_xor_word_RM_R,
+/* 0x32 */ x86emuOp_xor_byte_R_RM,
+/* 0x33 */ x86emuOp_xor_word_R_RM,
+/* 0x34 */ x86emuOp_xor_byte_AL_IMM,
+/* 0x35 */ x86emuOp_xor_word_AX_IMM,
+/* 0x36 */ x86emuOp_segovr_SS,
+/* 0x37 */ x86emuOp_aaa,
+/* 0x38 */ x86emuOp_cmp_byte_RM_R,
+/* 0x39 */ x86emuOp_cmp_word_RM_R,
+/* 0x3a */ x86emuOp_cmp_byte_R_RM,
+/* 0x3b */ x86emuOp_cmp_word_R_RM,
+/* 0x3c */ x86emuOp_cmp_byte_AL_IMM,
+/* 0x3d */ x86emuOp_cmp_word_AX_IMM,
+/* 0x3e */ x86emuOp_segovr_DS,
+/* 0x3f */ x86emuOp_aas,
+/* 0x40 */ x86emuOp_inc_AX,
+/* 0x41 */ x86emuOp_inc_CX,
+/* 0x42 */ x86emuOp_inc_DX,
+/* 0x43 */ x86emuOp_inc_BX,
+/* 0x44 */ x86emuOp_inc_SP,
+/* 0x45 */ x86emuOp_inc_BP,
+/* 0x46 */ x86emuOp_inc_SI,
+/* 0x47 */ x86emuOp_inc_DI,
+/* 0x48 */ x86emuOp_dec_AX,
+/* 0x49 */ x86emuOp_dec_CX,
+/* 0x4a */ x86emuOp_dec_DX,
+/* 0x4b */ x86emuOp_dec_BX,
+/* 0x4c */ x86emuOp_dec_SP,
+/* 0x4d */ x86emuOp_dec_BP,
+/* 0x4e */ x86emuOp_dec_SI,
+/* 0x4f */ x86emuOp_dec_DI,
+/* 0x50 */ x86emuOp_push_AX,
+/* 0x51 */ x86emuOp_push_CX,
+/* 0x52 */ x86emuOp_push_DX,
+/* 0x53 */ x86emuOp_push_BX,
+/* 0x54 */ x86emuOp_push_SP,
+/* 0x55 */ x86emuOp_push_BP,
+/* 0x56 */ x86emuOp_push_SI,
+/* 0x57 */ x86emuOp_push_DI,
+/* 0x58 */ x86emuOp_pop_AX,
+/* 0x59 */ x86emuOp_pop_CX,
+/* 0x5a */ x86emuOp_pop_DX,
+/* 0x5b */ x86emuOp_pop_BX,
+/* 0x5c */ x86emuOp_pop_SP,
+/* 0x5d */ x86emuOp_pop_BP,
+/* 0x5e */ x86emuOp_pop_SI,
+/* 0x5f */ x86emuOp_pop_DI,
+/* 0x60 */ x86emuOp_push_all,
+/* 0x61 */ x86emuOp_pop_all,
+ /* 0x62 */ x86emuOp_illegal_op,
+ /* bound */
+ /* 0x63 */ x86emuOp_illegal_op,
+ /* arpl */
+/* 0x64 */ x86emuOp_segovr_FS,
+/* 0x65 */ x86emuOp_segovr_GS,
+/* 0x66 */ x86emuOp_prefix_data,
+/* 0x67 */ x86emuOp_prefix_addr,
+/* 0x68 */ x86emuOp_push_word_IMM,
+/* 0x69 */ x86emuOp_imul_word_IMM,
+/* 0x6a */ x86emuOp_push_byte_IMM,
+/* 0x6b */ x86emuOp_imul_byte_IMM,
+/* 0x6c */ x86emuOp_ins_byte,
+/* 0x6d */ x86emuOp_ins_word,
+/* 0x6e */ x86emuOp_outs_byte,
+/* 0x6f */ x86emuOp_outs_word,
+/* 0x70 */ x86emuOp_jump_near_O,
+/* 0x71 */ x86emuOp_jump_near_NO,
+/* 0x72 */ x86emuOp_jump_near_B,
+/* 0x73 */ x86emuOp_jump_near_NB,
+/* 0x74 */ x86emuOp_jump_near_Z,
+/* 0x75 */ x86emuOp_jump_near_NZ,
+/* 0x76 */ x86emuOp_jump_near_BE,
+/* 0x77 */ x86emuOp_jump_near_NBE,
+/* 0x78 */ x86emuOp_jump_near_S,
+/* 0x79 */ x86emuOp_jump_near_NS,
+/* 0x7a */ x86emuOp_jump_near_P,
+/* 0x7b */ x86emuOp_jump_near_NP,
+/* 0x7c */ x86emuOp_jump_near_L,
+/* 0x7d */ x86emuOp_jump_near_NL,
+/* 0x7e */ x86emuOp_jump_near_LE,
+/* 0x7f */ x86emuOp_jump_near_NLE,
+/* 0x80 */ x86emuOp_opc80_byte_RM_IMM,
+/* 0x81 */ x86emuOp_opc81_word_RM_IMM,
+/* 0x82 */ x86emuOp_opc82_byte_RM_IMM,
+/* 0x83 */ x86emuOp_opc83_word_RM_IMM,
+/* 0x84 */ x86emuOp_test_byte_RM_R,
+/* 0x85 */ x86emuOp_test_word_RM_R,
+/* 0x86 */ x86emuOp_xchg_byte_RM_R,
+/* 0x87 */ x86emuOp_xchg_word_RM_R,
+/* 0x88 */ x86emuOp_mov_byte_RM_R,
+/* 0x89 */ x86emuOp_mov_word_RM_R,
+/* 0x8a */ x86emuOp_mov_byte_R_RM,
+/* 0x8b */ x86emuOp_mov_word_R_RM,
+/* 0x8c */ x86emuOp_mov_word_RM_SR,
+/* 0x8d */ x86emuOp_lea_word_R_M,
+/* 0x8e */ x86emuOp_mov_word_SR_RM,
+/* 0x8f */ x86emuOp_pop_RM,
+/* 0x90 */ x86emuOp_nop,
+/* 0x91 */ x86emuOp_xchg_word_AX_CX,
+/* 0x92 */ x86emuOp_xchg_word_AX_DX,
+/* 0x93 */ x86emuOp_xchg_word_AX_BX,
+/* 0x94 */ x86emuOp_xchg_word_AX_SP,
+/* 0x95 */ x86emuOp_xchg_word_AX_BP,
+/* 0x96 */ x86emuOp_xchg_word_AX_SI,
+/* 0x97 */ x86emuOp_xchg_word_AX_DI,
+/* 0x98 */ x86emuOp_cbw,
+/* 0x99 */ x86emuOp_cwd,
+/* 0x9a */ x86emuOp_call_far_IMM,
+/* 0x9b */ x86emuOp_wait,
+/* 0x9c */ x86emuOp_pushf_word,
+/* 0x9d */ x86emuOp_popf_word,
+/* 0x9e */ x86emuOp_sahf,
+/* 0x9f */ x86emuOp_lahf,
+/* 0xa0 */ x86emuOp_mov_AL_M_IMM,
+/* 0xa1 */ x86emuOp_mov_AX_M_IMM,
+/* 0xa2 */ x86emuOp_mov_M_AL_IMM,
+/* 0xa3 */ x86emuOp_mov_M_AX_IMM,
+/* 0xa4 */ x86emuOp_movs_byte,
+/* 0xa5 */ x86emuOp_movs_word,
+/* 0xa6 */ x86emuOp_cmps_byte,
+/* 0xa7 */ x86emuOp_cmps_word,
+/* 0xa8 */ x86emuOp_test_AL_IMM,
+/* 0xa9 */ x86emuOp_test_AX_IMM,
+/* 0xaa */ x86emuOp_stos_byte,
+/* 0xab */ x86emuOp_stos_word,
+/* 0xac */ x86emuOp_lods_byte,
+/* 0xad */ x86emuOp_lods_word,
+/* 0xac */ x86emuOp_scas_byte,
+/* 0xad */ x86emuOp_scas_word,
+/* 0xb0 */ x86emuOp_mov_byte_AL_IMM,
+/* 0xb1 */ x86emuOp_mov_byte_CL_IMM,
+/* 0xb2 */ x86emuOp_mov_byte_DL_IMM,
+/* 0xb3 */ x86emuOp_mov_byte_BL_IMM,
+/* 0xb4 */ x86emuOp_mov_byte_AH_IMM,
+/* 0xb5 */ x86emuOp_mov_byte_CH_IMM,
+/* 0xb6 */ x86emuOp_mov_byte_DH_IMM,
+/* 0xb7 */ x86emuOp_mov_byte_BH_IMM,
+/* 0xb8 */ x86emuOp_mov_word_AX_IMM,
+/* 0xb9 */ x86emuOp_mov_word_CX_IMM,
+/* 0xba */ x86emuOp_mov_word_DX_IMM,
+/* 0xbb */ x86emuOp_mov_word_BX_IMM,
+/* 0xbc */ x86emuOp_mov_word_SP_IMM,
+/* 0xbd */ x86emuOp_mov_word_BP_IMM,
+/* 0xbe */ x86emuOp_mov_word_SI_IMM,
+/* 0xbf */ x86emuOp_mov_word_DI_IMM,
+/* 0xc0 */ x86emuOp_opcC0_byte_RM_MEM,
+/* 0xc1 */ x86emuOp_opcC1_word_RM_MEM,
+/* 0xc2 */ x86emuOp_ret_near_IMM,
+/* 0xc3 */ x86emuOp_ret_near,
+/* 0xc4 */ x86emuOp_les_R_IMM,
+/* 0xc5 */ x86emuOp_lds_R_IMM,
+/* 0xc6 */ x86emuOp_mov_byte_RM_IMM,
+/* 0xc7 */ x86emuOp_mov_word_RM_IMM,
+/* 0xc8 */ x86emuOp_enter,
+/* 0xc9 */ x86emuOp_leave,
+/* 0xca */ x86emuOp_ret_far_IMM,
+/* 0xcb */ x86emuOp_ret_far,
+/* 0xcc */ x86emuOp_int3,
+/* 0xcd */ x86emuOp_int_IMM,
+/* 0xce */ x86emuOp_into,
+/* 0xcf */ x86emuOp_iret,
+/* 0xd0 */ x86emuOp_opcD0_byte_RM_1,
+/* 0xd1 */ x86emuOp_opcD1_word_RM_1,
+/* 0xd2 */ x86emuOp_opcD2_byte_RM_CL,
+/* 0xd3 */ x86emuOp_opcD3_word_RM_CL,
+/* 0xd4 */ x86emuOp_aam,
+/* 0xd5 */ x86emuOp_aad,
+ /* 0xd6 */ x86emuOp_illegal_op,
+ /* Undocumented SETALC instruction */
+/* 0xd7 */ x86emuOp_xlat,
+/* 0xd8 */ x86emuOp_esc_coprocess_d8,
+/* 0xd9 */ x86emuOp_esc_coprocess_d9,
+/* 0xda */ x86emuOp_esc_coprocess_da,
+/* 0xdb */ x86emuOp_esc_coprocess_db,
+/* 0xdc */ x86emuOp_esc_coprocess_dc,
+/* 0xdd */ x86emuOp_esc_coprocess_dd,
+/* 0xde */ x86emuOp_esc_coprocess_de,
+/* 0xdf */ x86emuOp_esc_coprocess_df,
+/* 0xe0 */ x86emuOp_loopne,
+/* 0xe1 */ x86emuOp_loope,
+/* 0xe2 */ x86emuOp_loop,
+/* 0xe3 */ x86emuOp_jcxz,
+/* 0xe4 */ x86emuOp_in_byte_AL_IMM,
+/* 0xe5 */ x86emuOp_in_word_AX_IMM,
+/* 0xe6 */ x86emuOp_out_byte_IMM_AL,
+/* 0xe7 */ x86emuOp_out_word_IMM_AX,
+/* 0xe8 */ x86emuOp_call_near_IMM,
+/* 0xe9 */ x86emuOp_jump_near_IMM,
+/* 0xea */ x86emuOp_jump_far_IMM,
+/* 0xeb */ x86emuOp_jump_byte_IMM,
+/* 0xec */ x86emuOp_in_byte_AL_DX,
+/* 0xed */ x86emuOp_in_word_AX_DX,
+/* 0xee */ x86emuOp_out_byte_DX_AL,
+/* 0xef */ x86emuOp_out_word_DX_AX,
+/* 0xf0 */ x86emuOp_lock,
+/* 0xf1 */ x86emuOp_illegal_op,
+/* 0xf2 */ x86emuOp_repne,
+/* 0xf3 */ x86emuOp_repe,
+/* 0xf4 */ x86emuOp_halt,
+/* 0xf5 */ x86emuOp_cmc,
+/* 0xf6 */ x86emuOp_opcF6_byte_RM,
+/* 0xf7 */ x86emuOp_opcF7_word_RM,
+/* 0xf8 */ x86emuOp_clc,
+/* 0xf9 */ x86emuOp_stc,
+/* 0xfa */ x86emuOp_cli,
+/* 0xfb */ x86emuOp_sti,
+/* 0xfc */ x86emuOp_cld,
+/* 0xfd */ x86emuOp_std,
+/* 0xfe */ x86emuOp_opcFE_byte_RM,
+/* 0xff */ x86emuOp_opcFF_word_RM,
+};
diff --git a/xorg-server/hw/xfree86/x86emu/ops2.c b/xorg-server/hw/xfree86/x86emu/ops2.c
index 501d5fcb2..5ed2bf68d 100644
--- a/xorg-server/hw/xfree86/x86emu/ops2.c
+++ b/xorg-server/hw/xfree86/x86emu/ops2.c
@@ -55,14 +55,14 @@ op1 - Instruction op code
REMARKS:
Handles illegal opcodes.
****************************************************************************/
-static void x86emuOp2_illegal_op(
- u8 op2)
+static void
+x86emuOp2_illegal_op(u8 op2)
{
- START_OF_INSTR();
- DECODE_PRINTF("ILLEGAL EXTENDED X86 OPCODE\n");
- TRACE_REGS();
- printk("%04x:%04x: %02X ILLEGAL EXTENDED X86 OPCODE!\n",
- M.x86.R_CS, M.x86.R_IP-2,op2);
+ START_OF_INSTR();
+ DECODE_PRINTF("ILLEGAL EXTENDED X86 OPCODE\n");
+ TRACE_REGS();
+ printk("%04x:%04x: %02X ILLEGAL EXTENDED X86 OPCODE!\n",
+ M.x86.R_CS, M.x86.R_IP - 2, op2);
HALT_SYS();
END_OF_INSTR();
}
@@ -73,7 +73,8 @@ static void x86emuOp2_illegal_op(
REMARKS:
Handles opcode 0x0f,0x31
****************************************************************************/
-static void x86emuOp2_rdtsc(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_rdtsc(u8 X86EMU_UNUSED(op2))
{
#ifdef __HAS_LONG_LONG__
static u64 counter = 0;
@@ -107,7 +108,8 @@ static void x86emuOp2_rdtsc(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0x80-0x8F
****************************************************************************/
-static void x86emuOp2_long_jump(u8 op2)
+static void
+x86emuOp2_long_jump(u8 op2)
{
s32 target;
const char *name = NULL;
@@ -116,81 +118,81 @@ static void x86emuOp2_long_jump(u8 op2)
/* conditional jump to word offset. */
START_OF_INSTR();
switch (op2) {
- case 0x80:
+ case 0x80:
name = "JO\t";
- cond = ACCESS_FLAG(F_OF);
+ cond = ACCESS_FLAG(F_OF);
break;
- case 0x81:
+ case 0x81:
name = "JNO\t";
cond = !ACCESS_FLAG(F_OF);
break;
- case 0x82:
+ case 0x82:
name = "JB\t";
cond = ACCESS_FLAG(F_CF);
break;
- case 0x83:
+ case 0x83:
name = "JNB\t";
cond = !ACCESS_FLAG(F_CF);
break;
- case 0x84:
+ case 0x84:
name = "JZ\t";
cond = ACCESS_FLAG(F_ZF);
break;
- case 0x85:
+ case 0x85:
name = "JNZ\t";
cond = !ACCESS_FLAG(F_ZF);
break;
- case 0x86:
+ case 0x86:
name = "JBE\t";
cond = ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF);
break;
- case 0x87:
+ case 0x87:
name = "JNBE\t";
cond = !(ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF));
break;
- case 0x88:
+ case 0x88:
name = "JS\t";
cond = ACCESS_FLAG(F_SF);
break;
- case 0x89:
+ case 0x89:
name = "JNS\t";
cond = !ACCESS_FLAG(F_SF);
break;
- case 0x8a:
+ case 0x8a:
name = "JP\t";
cond = ACCESS_FLAG(F_PF);
break;
- case 0x8b:
+ case 0x8b:
name = "JNP\t";
cond = !ACCESS_FLAG(F_PF);
break;
- case 0x8c:
+ case 0x8c:
name = "JL\t";
cond = xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF));
break;
- case 0x8d:
+ case 0x8d:
name = "JNL\t";
cond = !(xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF)));
break;
- case 0x8e:
+ case 0x8e:
name = "JLE\t";
cond = (xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF)) ||
ACCESS_FLAG(F_ZF));
break;
- case 0x8f:
+ case 0x8f:
name = "JNLE\t";
cond = !(xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF)) ||
ACCESS_FLAG(F_ZF));
break;
}
DECODE_PRINTF(name);
- (void)name;
+ (void) name;
target = (s16) fetch_word_imm();
target += (s16) M.x86.R_IP;
DECODE_PRINTF2("%04x\n", target);
TRACE_AND_STEP();
if (cond)
- M.x86.R_IP = (u16)target;
+ M.x86.R_IP = (u16) target;
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
}
@@ -199,85 +201,86 @@ static void x86emuOp2_long_jump(u8 op2)
REMARKS:
Handles opcode 0x0f,0x90-0x9F
****************************************************************************/
-static void x86emuOp2_set_byte(u8 op2)
+static void
+x86emuOp2_set_byte(u8 op2)
{
int mod, rl, rh;
uint destoffset;
- u8 *destreg;
+ u8 *destreg;
const char *name = NULL;
int cond = 0;
START_OF_INSTR();
switch (op2) {
- case 0x90:
+ case 0x90:
name = "SETO\t";
- cond = ACCESS_FLAG(F_OF);
+ cond = ACCESS_FLAG(F_OF);
break;
- case 0x91:
+ case 0x91:
name = "SETNO\t";
cond = !ACCESS_FLAG(F_OF);
break;
- case 0x92:
+ case 0x92:
name = "SETB\t";
cond = ACCESS_FLAG(F_CF);
break;
- case 0x93:
+ case 0x93:
name = "SETNB\t";
cond = !ACCESS_FLAG(F_CF);
break;
- case 0x94:
+ case 0x94:
name = "SETZ\t";
cond = ACCESS_FLAG(F_ZF);
break;
- case 0x95:
+ case 0x95:
name = "SETNZ\t";
cond = !ACCESS_FLAG(F_ZF);
break;
- case 0x96:
+ case 0x96:
name = "SETBE\t";
cond = ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF);
break;
- case 0x97:
+ case 0x97:
name = "SETNBE\t";
cond = !(ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF));
break;
- case 0x98:
+ case 0x98:
name = "SETS\t";
cond = ACCESS_FLAG(F_SF);
break;
- case 0x99:
+ case 0x99:
name = "SETNS\t";
cond = !ACCESS_FLAG(F_SF);
break;
- case 0x9a:
+ case 0x9a:
name = "SETP\t";
cond = ACCESS_FLAG(F_PF);
break;
- case 0x9b:
+ case 0x9b:
name = "SETNP\t";
cond = !ACCESS_FLAG(F_PF);
break;
- case 0x9c:
+ case 0x9c:
name = "SETL\t";
cond = xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF));
break;
- case 0x9d:
+ case 0x9d:
name = "SETNL\t";
cond = xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF));
break;
- case 0x9e:
+ case 0x9e:
name = "SETLE\t";
cond = (xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF)) ||
ACCESS_FLAG(F_ZF));
break;
- case 0x9f:
+ case 0x9f:
name = "SETNLE\t";
cond = !(xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF)) ||
ACCESS_FLAG(F_ZF));
break;
}
DECODE_PRINTF(name);
- (void)name;
+ (void) name;
FETCH_DECODE_MODRM(mod, rh, rl);
switch (mod) {
case 0:
@@ -295,7 +298,7 @@ static void x86emuOp2_set_byte(u8 op2)
TRACE_AND_STEP();
store_data_byte(destoffset, cond ? 0x01 : 0x00);
break;
- case 3: /* register to register */
+ case 3: /* register to register */
destreg = DECODE_RM_BYTE_REGISTER(rl);
TRACE_AND_STEP();
*destreg = cond ? 0x01 : 0x00;
@@ -309,7 +312,8 @@ static void x86emuOp2_set_byte(u8 op2)
REMARKS:
Handles opcode 0x0f,0xa0
****************************************************************************/
-static void x86emuOp2_push_FS(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_push_FS(u8 X86EMU_UNUSED(op2))
{
START_OF_INSTR();
DECODE_PRINTF("PUSH\tFS\n");
@@ -323,7 +327,8 @@ static void x86emuOp2_push_FS(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xa1
****************************************************************************/
-static void x86emuOp2_pop_FS(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_pop_FS(u8 X86EMU_UNUSED(op2))
{
START_OF_INSTR();
DECODE_PRINTF("POP\tFS\n");
@@ -337,7 +342,8 @@ static void x86emuOp2_pop_FS(u8 X86EMU_UNUSED(op2))
REMARKS: CPUID takes EAX/ECX as inputs, writes EAX/EBX/ECX/EDX as output
Handles opcode 0x0f,0xa2
****************************************************************************/
-static void x86emuOp2_cpuid(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_cpuid(u8 X86EMU_UNUSED(op2))
{
START_OF_INSTR();
DECODE_PRINTF("CPUID\n");
@@ -351,11 +357,12 @@ static void x86emuOp2_cpuid(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xa3
****************************************************************************/
-static void x86emuOp2_bt_R(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_bt_R(u8 X86EMU_UNUSED(op2))
{
int mod, rl, rh;
uint srcoffset;
- int bit,disp;
+ int bit, disp;
START_OF_INSTR();
DECODE_PRINTF("BT\t");
@@ -371,10 +378,11 @@ static void x86emuOp2_bt_R(u8 X86EMU_UNUSED(op2))
shiftreg = DECODE_RM_LONG_REGISTER(rh);
TRACE_AND_STEP();
bit = *shiftreg & 0x1F;
- disp = (s16)*shiftreg >> 5;
- srcval = fetch_data_long(srcoffset+disp);
- CONDITIONAL_SET_FLAG(srcval & (0x1 << bit),F_CF);
- } else {
+ disp = (s16) * shiftreg >> 5;
+ srcval = fetch_data_long(srcoffset + disp);
+ CONDITIONAL_SET_FLAG(srcval & (0x1 << bit), F_CF);
+ }
+ else {
u16 srcval;
u16 *shiftreg;
@@ -383,9 +391,9 @@ static void x86emuOp2_bt_R(u8 X86EMU_UNUSED(op2))
shiftreg = DECODE_RM_WORD_REGISTER(rh);
TRACE_AND_STEP();
bit = *shiftreg & 0xF;
- disp = (s16)*shiftreg >> 4;
- srcval = fetch_data_word(srcoffset+disp);
- CONDITIONAL_SET_FLAG(srcval & (0x1 << bit),F_CF);
+ disp = (s16) * shiftreg >> 4;
+ srcval = fetch_data_word(srcoffset + disp);
+ CONDITIONAL_SET_FLAG(srcval & (0x1 << bit), F_CF);
}
break;
case 1:
@@ -398,10 +406,11 @@ static void x86emuOp2_bt_R(u8 X86EMU_UNUSED(op2))
shiftreg = DECODE_RM_LONG_REGISTER(rh);
TRACE_AND_STEP();
bit = *shiftreg & 0x1F;
- disp = (s16)*shiftreg >> 5;
- srcval = fetch_data_long(srcoffset+disp);
- CONDITIONAL_SET_FLAG(srcval & (0x1 << bit),F_CF);
- } else {
+ disp = (s16) * shiftreg >> 5;
+ srcval = fetch_data_long(srcoffset + disp);
+ CONDITIONAL_SET_FLAG(srcval & (0x1 << bit), F_CF);
+ }
+ else {
u16 srcval;
u16 *shiftreg;
@@ -410,9 +419,9 @@ static void x86emuOp2_bt_R(u8 X86EMU_UNUSED(op2))
shiftreg = DECODE_RM_WORD_REGISTER(rh);
TRACE_AND_STEP();
bit = *shiftreg & 0xF;
- disp = (s16)*shiftreg >> 4;
- srcval = fetch_data_word(srcoffset+disp);
- CONDITIONAL_SET_FLAG(srcval & (0x1 << bit),F_CF);
+ disp = (s16) * shiftreg >> 4;
+ srcval = fetch_data_word(srcoffset + disp);
+ CONDITIONAL_SET_FLAG(srcval & (0x1 << bit), F_CF);
}
break;
case 2:
@@ -425,10 +434,11 @@ static void x86emuOp2_bt_R(u8 X86EMU_UNUSED(op2))
shiftreg = DECODE_RM_LONG_REGISTER(rh);
TRACE_AND_STEP();
bit = *shiftreg & 0x1F;
- disp = (s16)*shiftreg >> 5;
- srcval = fetch_data_long(srcoffset+disp);
- CONDITIONAL_SET_FLAG(srcval & (0x1 << bit),F_CF);
- } else {
+ disp = (s16) * shiftreg >> 5;
+ srcval = fetch_data_long(srcoffset + disp);
+ CONDITIONAL_SET_FLAG(srcval & (0x1 << bit), F_CF);
+ }
+ else {
u16 srcval;
u16 *shiftreg;
@@ -437,30 +447,31 @@ static void x86emuOp2_bt_R(u8 X86EMU_UNUSED(op2))
shiftreg = DECODE_RM_WORD_REGISTER(rh);
TRACE_AND_STEP();
bit = *shiftreg & 0xF;
- disp = (s16)*shiftreg >> 4;
- srcval = fetch_data_word(srcoffset+disp);
- CONDITIONAL_SET_FLAG(srcval & (0x1 << bit),F_CF);
+ disp = (s16) * shiftreg >> 4;
+ srcval = fetch_data_word(srcoffset + disp);
+ CONDITIONAL_SET_FLAG(srcval & (0x1 << bit), F_CF);
}
break;
- case 3: /* register to register */
+ case 3: /* register to register */
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *srcreg,*shiftreg;
+ u32 *srcreg, *shiftreg;
srcreg = DECODE_RM_LONG_REGISTER(rl);
DECODE_PRINTF(",");
shiftreg = DECODE_RM_LONG_REGISTER(rh);
TRACE_AND_STEP();
bit = *shiftreg & 0x1F;
- CONDITIONAL_SET_FLAG(*srcreg & (0x1 << bit),F_CF);
- } else {
- u16 *srcreg,*shiftreg;
+ CONDITIONAL_SET_FLAG(*srcreg & (0x1 << bit), F_CF);
+ }
+ else {
+ u16 *srcreg, *shiftreg;
srcreg = DECODE_RM_WORD_REGISTER(rl);
DECODE_PRINTF(",");
shiftreg = DECODE_RM_WORD_REGISTER(rh);
TRACE_AND_STEP();
bit = *shiftreg & 0xF;
- CONDITIONAL_SET_FLAG(*srcreg & (0x1 << bit),F_CF);
+ CONDITIONAL_SET_FLAG(*srcreg & (0x1 << bit), F_CF);
}
break;
}
@@ -472,11 +483,12 @@ static void x86emuOp2_bt_R(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xa4
****************************************************************************/
-static void x86emuOp2_shld_IMM(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_shld_IMM(u8 X86EMU_UNUSED(op2))
{
int mod, rl, rh;
uint destoffset;
- u8 shift;
+ u8 shift;
START_OF_INSTR();
DECODE_PRINTF("SHLD\t");
@@ -495,9 +507,10 @@ static void x86emuOp2_shld_IMM(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF2("%d\n", shift);
TRACE_AND_STEP();
destval = fetch_data_long(destoffset);
- destval = shld_long(destval,*shiftreg,shift);
+ destval = shld_long(destval, *shiftreg, shift);
store_data_long(destoffset, destval);
- } else {
+ }
+ else {
u16 destval;
u16 *shiftreg;
@@ -509,7 +522,7 @@ static void x86emuOp2_shld_IMM(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF2("%d\n", shift);
TRACE_AND_STEP();
destval = fetch_data_word(destoffset);
- destval = shld_word(destval,*shiftreg,shift);
+ destval = shld_word(destval, *shiftreg, shift);
store_data_word(destoffset, destval);
}
break;
@@ -526,9 +539,10 @@ static void x86emuOp2_shld_IMM(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF2("%d\n", shift);
TRACE_AND_STEP();
destval = fetch_data_long(destoffset);
- destval = shld_long(destval,*shiftreg,shift);
+ destval = shld_long(destval, *shiftreg, shift);
store_data_long(destoffset, destval);
- } else {
+ }
+ else {
u16 destval;
u16 *shiftreg;
@@ -540,7 +554,7 @@ static void x86emuOp2_shld_IMM(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF2("%d\n", shift);
TRACE_AND_STEP();
destval = fetch_data_word(destoffset);
- destval = shld_word(destval,*shiftreg,shift);
+ destval = shld_word(destval, *shiftreg, shift);
store_data_word(destoffset, destval);
}
break;
@@ -557,9 +571,10 @@ static void x86emuOp2_shld_IMM(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF2("%d\n", shift);
TRACE_AND_STEP();
destval = fetch_data_long(destoffset);
- destval = shld_long(destval,*shiftreg,shift);
+ destval = shld_long(destval, *shiftreg, shift);
store_data_long(destoffset, destval);
- } else {
+ }
+ else {
u16 destval;
u16 *shiftreg;
@@ -571,13 +586,13 @@ static void x86emuOp2_shld_IMM(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF2("%d\n", shift);
TRACE_AND_STEP();
destval = fetch_data_word(destoffset);
- destval = shld_word(destval,*shiftreg,shift);
+ destval = shld_word(destval, *shiftreg, shift);
store_data_word(destoffset, destval);
}
break;
- case 3: /* register to register */
+ case 3: /* register to register */
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*shiftreg;
+ u32 *destreg, *shiftreg;
destreg = DECODE_RM_LONG_REGISTER(rl);
DECODE_PRINTF(",");
@@ -586,9 +601,10 @@ static void x86emuOp2_shld_IMM(u8 X86EMU_UNUSED(op2))
shift = fetch_byte_imm();
DECODE_PRINTF2("%d\n", shift);
TRACE_AND_STEP();
- *destreg = shld_long(*destreg,*shiftreg,shift);
- } else {
- u16 *destreg,*shiftreg;
+ *destreg = shld_long(*destreg, *shiftreg, shift);
+ }
+ else {
+ u16 *destreg, *shiftreg;
destreg = DECODE_RM_WORD_REGISTER(rl);
DECODE_PRINTF(",");
@@ -597,7 +613,7 @@ static void x86emuOp2_shld_IMM(u8 X86EMU_UNUSED(op2))
shift = fetch_byte_imm();
DECODE_PRINTF2("%d\n", shift);
TRACE_AND_STEP();
- *destreg = shld_word(*destreg,*shiftreg,shift);
+ *destreg = shld_word(*destreg, *shiftreg, shift);
}
break;
}
@@ -609,7 +625,8 @@ static void x86emuOp2_shld_IMM(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xa5
****************************************************************************/
-static void x86emuOp2_shld_CL(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_shld_CL(u8 X86EMU_UNUSED(op2))
{
int mod, rl, rh;
uint destoffset;
@@ -629,9 +646,10 @@ static void x86emuOp2_shld_CL(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF(",CL\n");
TRACE_AND_STEP();
destval = fetch_data_long(destoffset);
- destval = shld_long(destval,*shiftreg,M.x86.R_CL);
+ destval = shld_long(destval, *shiftreg, M.x86.R_CL);
store_data_long(destoffset, destval);
- } else {
+ }
+ else {
u16 destval;
u16 *shiftreg;
@@ -641,7 +659,7 @@ static void x86emuOp2_shld_CL(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF(",CL\n");
TRACE_AND_STEP();
destval = fetch_data_word(destoffset);
- destval = shld_word(destval,*shiftreg,M.x86.R_CL);
+ destval = shld_word(destval, *shiftreg, M.x86.R_CL);
store_data_word(destoffset, destval);
}
break;
@@ -656,9 +674,10 @@ static void x86emuOp2_shld_CL(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF(",CL\n");
TRACE_AND_STEP();
destval = fetch_data_long(destoffset);
- destval = shld_long(destval,*shiftreg,M.x86.R_CL);
+ destval = shld_long(destval, *shiftreg, M.x86.R_CL);
store_data_long(destoffset, destval);
- } else {
+ }
+ else {
u16 destval;
u16 *shiftreg;
@@ -668,7 +687,7 @@ static void x86emuOp2_shld_CL(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF(",CL\n");
TRACE_AND_STEP();
destval = fetch_data_word(destoffset);
- destval = shld_word(destval,*shiftreg,M.x86.R_CL);
+ destval = shld_word(destval, *shiftreg, M.x86.R_CL);
store_data_word(destoffset, destval);
}
break;
@@ -683,9 +702,10 @@ static void x86emuOp2_shld_CL(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF(",CL\n");
TRACE_AND_STEP();
destval = fetch_data_long(destoffset);
- destval = shld_long(destval,*shiftreg,M.x86.R_CL);
+ destval = shld_long(destval, *shiftreg, M.x86.R_CL);
store_data_long(destoffset, destval);
- } else {
+ }
+ else {
u16 destval;
u16 *shiftreg;
@@ -695,29 +715,30 @@ static void x86emuOp2_shld_CL(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF(",CL\n");
TRACE_AND_STEP();
destval = fetch_data_word(destoffset);
- destval = shld_word(destval,*shiftreg,M.x86.R_CL);
+ destval = shld_word(destval, *shiftreg, M.x86.R_CL);
store_data_word(destoffset, destval);
}
break;
- case 3: /* register to register */
+ case 3: /* register to register */
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*shiftreg;
+ u32 *destreg, *shiftreg;
destreg = DECODE_RM_LONG_REGISTER(rl);
DECODE_PRINTF(",");
shiftreg = DECODE_RM_LONG_REGISTER(rh);
DECODE_PRINTF(",CL\n");
TRACE_AND_STEP();
- *destreg = shld_long(*destreg,*shiftreg,M.x86.R_CL);
- } else {
- u16 *destreg,*shiftreg;
+ *destreg = shld_long(*destreg, *shiftreg, M.x86.R_CL);
+ }
+ else {
+ u16 *destreg, *shiftreg;
destreg = DECODE_RM_WORD_REGISTER(rl);
DECODE_PRINTF(",");
shiftreg = DECODE_RM_WORD_REGISTER(rh);
DECODE_PRINTF(",CL\n");
TRACE_AND_STEP();
- *destreg = shld_word(*destreg,*shiftreg,M.x86.R_CL);
+ *destreg = shld_word(*destreg, *shiftreg, M.x86.R_CL);
}
break;
}
@@ -729,7 +750,8 @@ static void x86emuOp2_shld_CL(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xa8
****************************************************************************/
-static void x86emuOp2_push_GS(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_push_GS(u8 X86EMU_UNUSED(op2))
{
START_OF_INSTR();
DECODE_PRINTF("PUSH\tGS\n");
@@ -743,7 +765,8 @@ static void x86emuOp2_push_GS(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xa9
****************************************************************************/
-static void x86emuOp2_pop_GS(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_pop_GS(u8 X86EMU_UNUSED(op2))
{
START_OF_INSTR();
DECODE_PRINTF("POP\tGS\n");
@@ -757,11 +780,12 @@ static void x86emuOp2_pop_GS(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xab
****************************************************************************/
-static void x86emuOp2_bts_R(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_bts_R(u8 X86EMU_UNUSED(op2))
{
int mod, rl, rh;
uint srcoffset;
- int bit,disp;
+ int bit, disp;
START_OF_INSTR();
DECODE_PRINTF("BTS\t");
@@ -769,7 +793,7 @@ static void x86emuOp2_bts_R(u8 X86EMU_UNUSED(op2))
switch (mod) {
case 0:
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 srcval,mask;
+ u32 srcval, mask;
u32 *shiftreg;
srcoffset = decode_rm00_address(rl);
@@ -777,13 +801,14 @@ static void x86emuOp2_bts_R(u8 X86EMU_UNUSED(op2))
shiftreg = DECODE_RM_LONG_REGISTER(rh);
TRACE_AND_STEP();
bit = *shiftreg & 0x1F;
- disp = (s16)*shiftreg >> 5;
- srcval = fetch_data_long(srcoffset+disp);
+ disp = (s16) * shiftreg >> 5;
+ srcval = fetch_data_long(srcoffset + disp);
mask = (0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- store_data_long(srcoffset+disp, srcval | mask);
- } else {
- u16 srcval,mask;
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ store_data_long(srcoffset + disp, srcval | mask);
+ }
+ else {
+ u16 srcval, mask;
u16 *shiftreg;
srcoffset = decode_rm00_address(rl);
@@ -791,16 +816,16 @@ static void x86emuOp2_bts_R(u8 X86EMU_UNUSED(op2))
shiftreg = DECODE_RM_WORD_REGISTER(rh);
TRACE_AND_STEP();
bit = *shiftreg & 0xF;
- disp = (s16)*shiftreg >> 4;
- srcval = fetch_data_word(srcoffset+disp);
- mask = (u16)(0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- store_data_word(srcoffset+disp, srcval | mask);
+ disp = (s16) * shiftreg >> 4;
+ srcval = fetch_data_word(srcoffset + disp);
+ mask = (u16) (0x1 << bit);
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ store_data_word(srcoffset + disp, srcval | mask);
}
break;
case 1:
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 srcval,mask;
+ u32 srcval, mask;
u32 *shiftreg;
srcoffset = decode_rm01_address(rl);
@@ -808,13 +833,14 @@ static void x86emuOp2_bts_R(u8 X86EMU_UNUSED(op2))
shiftreg = DECODE_RM_LONG_REGISTER(rh);
TRACE_AND_STEP();
bit = *shiftreg & 0x1F;
- disp = (s16)*shiftreg >> 5;
- srcval = fetch_data_long(srcoffset+disp);
+ disp = (s16) * shiftreg >> 5;
+ srcval = fetch_data_long(srcoffset + disp);
mask = (0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- store_data_long(srcoffset+disp, srcval | mask);
- } else {
- u16 srcval,mask;
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ store_data_long(srcoffset + disp, srcval | mask);
+ }
+ else {
+ u16 srcval, mask;
u16 *shiftreg;
srcoffset = decode_rm01_address(rl);
@@ -822,16 +848,16 @@ static void x86emuOp2_bts_R(u8 X86EMU_UNUSED(op2))
shiftreg = DECODE_RM_WORD_REGISTER(rh);
TRACE_AND_STEP();
bit = *shiftreg & 0xF;
- disp = (s16)*shiftreg >> 4;
- srcval = fetch_data_word(srcoffset+disp);
- mask = (u16)(0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- store_data_word(srcoffset+disp, srcval | mask);
+ disp = (s16) * shiftreg >> 4;
+ srcval = fetch_data_word(srcoffset + disp);
+ mask = (u16) (0x1 << bit);
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ store_data_word(srcoffset + disp, srcval | mask);
}
break;
case 2:
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 srcval,mask;
+ u32 srcval, mask;
u32 *shiftreg;
srcoffset = decode_rm10_address(rl);
@@ -839,51 +865,53 @@ static void x86emuOp2_bts_R(u8 X86EMU_UNUSED(op2))
shiftreg = DECODE_RM_LONG_REGISTER(rh);
TRACE_AND_STEP();
bit = *shiftreg & 0x1F;
- disp = (s16)*shiftreg >> 5;
- srcval = fetch_data_long(srcoffset+disp);
+ disp = (s16) * shiftreg >> 5;
+ srcval = fetch_data_long(srcoffset + disp);
mask = (0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- store_data_long(srcoffset+disp, srcval | mask);
- } else {
- u16 srcval,mask;
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ store_data_long(srcoffset + disp, srcval | mask);
+ }
+ else {
+ u16 srcval, mask;
u16 *shiftreg;
- srcoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- shiftreg = DECODE_RM_WORD_REGISTER(rh);
- TRACE_AND_STEP();
- bit = *shiftreg & 0xF;
- disp = (s16)*shiftreg >> 4;
- srcval = fetch_data_word(srcoffset+disp);
- mask = (u16)(0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- store_data_word(srcoffset+disp, srcval | mask);
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *srcreg,*shiftreg;
- u32 mask;
-
- srcreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF(",");
- shiftreg = DECODE_RM_LONG_REGISTER(rh);
- TRACE_AND_STEP();
- bit = *shiftreg & 0x1F;
- mask = (0x1 << bit);
- CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF);
- *srcreg |= mask;
- } else {
- u16 *srcreg,*shiftreg;
- u16 mask;
-
- srcreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",");
- shiftreg = DECODE_RM_WORD_REGISTER(rh);
- TRACE_AND_STEP();
- bit = *shiftreg & 0xF;
- mask = (u16)(0x1 << bit);
- CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF);
+ srcoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ shiftreg = DECODE_RM_WORD_REGISTER(rh);
+ TRACE_AND_STEP();
+ bit = *shiftreg & 0xF;
+ disp = (s16) * shiftreg >> 4;
+ srcval = fetch_data_word(srcoffset + disp);
+ mask = (u16) (0x1 << bit);
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ store_data_word(srcoffset + disp, srcval | mask);
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *srcreg, *shiftreg;
+ u32 mask;
+
+ srcreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF(",");
+ shiftreg = DECODE_RM_LONG_REGISTER(rh);
+ TRACE_AND_STEP();
+ bit = *shiftreg & 0x1F;
+ mask = (0x1 << bit);
+ CONDITIONAL_SET_FLAG(*srcreg & mask, F_CF);
+ *srcreg |= mask;
+ }
+ else {
+ u16 *srcreg, *shiftreg;
+ u16 mask;
+
+ srcreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",");
+ shiftreg = DECODE_RM_WORD_REGISTER(rh);
+ TRACE_AND_STEP();
+ bit = *shiftreg & 0xF;
+ mask = (u16) (0x1 << bit);
+ CONDITIONAL_SET_FLAG(*srcreg & mask, F_CF);
*srcreg |= mask;
}
break;
@@ -896,11 +924,12 @@ static void x86emuOp2_bts_R(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xac
****************************************************************************/
-static void x86emuOp2_shrd_IMM(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_shrd_IMM(u8 X86EMU_UNUSED(op2))
{
int mod, rl, rh;
uint destoffset;
- u8 shift;
+ u8 shift;
START_OF_INSTR();
DECODE_PRINTF("SHLD\t");
@@ -919,9 +948,10 @@ static void x86emuOp2_shrd_IMM(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF2("%d\n", shift);
TRACE_AND_STEP();
destval = fetch_data_long(destoffset);
- destval = shrd_long(destval,*shiftreg,shift);
+ destval = shrd_long(destval, *shiftreg, shift);
store_data_long(destoffset, destval);
- } else {
+ }
+ else {
u16 destval;
u16 *shiftreg;
@@ -933,7 +963,7 @@ static void x86emuOp2_shrd_IMM(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF2("%d\n", shift);
TRACE_AND_STEP();
destval = fetch_data_word(destoffset);
- destval = shrd_word(destval,*shiftreg,shift);
+ destval = shrd_word(destval, *shiftreg, shift);
store_data_word(destoffset, destval);
}
break;
@@ -950,9 +980,10 @@ static void x86emuOp2_shrd_IMM(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF2("%d\n", shift);
TRACE_AND_STEP();
destval = fetch_data_long(destoffset);
- destval = shrd_long(destval,*shiftreg,shift);
+ destval = shrd_long(destval, *shiftreg, shift);
store_data_long(destoffset, destval);
- } else {
+ }
+ else {
u16 destval;
u16 *shiftreg;
@@ -964,7 +995,7 @@ static void x86emuOp2_shrd_IMM(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF2("%d\n", shift);
TRACE_AND_STEP();
destval = fetch_data_word(destoffset);
- destval = shrd_word(destval,*shiftreg,shift);
+ destval = shrd_word(destval, *shiftreg, shift);
store_data_word(destoffset, destval);
}
break;
@@ -981,9 +1012,10 @@ static void x86emuOp2_shrd_IMM(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF2("%d\n", shift);
TRACE_AND_STEP();
destval = fetch_data_long(destoffset);
- destval = shrd_long(destval,*shiftreg,shift);
+ destval = shrd_long(destval, *shiftreg, shift);
store_data_long(destoffset, destval);
- } else {
+ }
+ else {
u16 destval;
u16 *shiftreg;
@@ -995,13 +1027,13 @@ static void x86emuOp2_shrd_IMM(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF2("%d\n", shift);
TRACE_AND_STEP();
destval = fetch_data_word(destoffset);
- destval = shrd_word(destval,*shiftreg,shift);
+ destval = shrd_word(destval, *shiftreg, shift);
store_data_word(destoffset, destval);
}
break;
- case 3: /* register to register */
+ case 3: /* register to register */
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*shiftreg;
+ u32 *destreg, *shiftreg;
destreg = DECODE_RM_LONG_REGISTER(rl);
DECODE_PRINTF(",");
@@ -1010,9 +1042,10 @@ static void x86emuOp2_shrd_IMM(u8 X86EMU_UNUSED(op2))
shift = fetch_byte_imm();
DECODE_PRINTF2("%d\n", shift);
TRACE_AND_STEP();
- *destreg = shrd_long(*destreg,*shiftreg,shift);
- } else {
- u16 *destreg,*shiftreg;
+ *destreg = shrd_long(*destreg, *shiftreg, shift);
+ }
+ else {
+ u16 *destreg, *shiftreg;
destreg = DECODE_RM_WORD_REGISTER(rl);
DECODE_PRINTF(",");
@@ -1021,7 +1054,7 @@ static void x86emuOp2_shrd_IMM(u8 X86EMU_UNUSED(op2))
shift = fetch_byte_imm();
DECODE_PRINTF2("%d\n", shift);
TRACE_AND_STEP();
- *destreg = shrd_word(*destreg,*shiftreg,shift);
+ *destreg = shrd_word(*destreg, *shiftreg, shift);
}
break;
}
@@ -1033,7 +1066,8 @@ static void x86emuOp2_shrd_IMM(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xad
****************************************************************************/
-static void x86emuOp2_shrd_CL(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_shrd_CL(u8 X86EMU_UNUSED(op2))
{
int mod, rl, rh;
uint destoffset;
@@ -1053,9 +1087,10 @@ static void x86emuOp2_shrd_CL(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF(",CL\n");
TRACE_AND_STEP();
destval = fetch_data_long(destoffset);
- destval = shrd_long(destval,*shiftreg,M.x86.R_CL);
+ destval = shrd_long(destval, *shiftreg, M.x86.R_CL);
store_data_long(destoffset, destval);
- } else {
+ }
+ else {
u16 destval;
u16 *shiftreg;
@@ -1065,7 +1100,7 @@ static void x86emuOp2_shrd_CL(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF(",CL\n");
TRACE_AND_STEP();
destval = fetch_data_word(destoffset);
- destval = shrd_word(destval,*shiftreg,M.x86.R_CL);
+ destval = shrd_word(destval, *shiftreg, M.x86.R_CL);
store_data_word(destoffset, destval);
}
break;
@@ -1080,9 +1115,10 @@ static void x86emuOp2_shrd_CL(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF(",CL\n");
TRACE_AND_STEP();
destval = fetch_data_long(destoffset);
- destval = shrd_long(destval,*shiftreg,M.x86.R_CL);
+ destval = shrd_long(destval, *shiftreg, M.x86.R_CL);
store_data_long(destoffset, destval);
- } else {
+ }
+ else {
u16 destval;
u16 *shiftreg;
@@ -1092,7 +1128,7 @@ static void x86emuOp2_shrd_CL(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF(",CL\n");
TRACE_AND_STEP();
destval = fetch_data_word(destoffset);
- destval = shrd_word(destval,*shiftreg,M.x86.R_CL);
+ destval = shrd_word(destval, *shiftreg, M.x86.R_CL);
store_data_word(destoffset, destval);
}
break;
@@ -1107,9 +1143,10 @@ static void x86emuOp2_shrd_CL(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF(",CL\n");
TRACE_AND_STEP();
destval = fetch_data_long(destoffset);
- destval = shrd_long(destval,*shiftreg,M.x86.R_CL);
+ destval = shrd_long(destval, *shiftreg, M.x86.R_CL);
store_data_long(destoffset, destval);
- } else {
+ }
+ else {
u16 destval;
u16 *shiftreg;
@@ -1119,29 +1156,30 @@ static void x86emuOp2_shrd_CL(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF(",CL\n");
TRACE_AND_STEP();
destval = fetch_data_word(destoffset);
- destval = shrd_word(destval,*shiftreg,M.x86.R_CL);
+ destval = shrd_word(destval, *shiftreg, M.x86.R_CL);
store_data_word(destoffset, destval);
}
break;
- case 3: /* register to register */
+ case 3: /* register to register */
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*shiftreg;
+ u32 *destreg, *shiftreg;
destreg = DECODE_RM_LONG_REGISTER(rl);
DECODE_PRINTF(",");
shiftreg = DECODE_RM_LONG_REGISTER(rh);
DECODE_PRINTF(",CL\n");
TRACE_AND_STEP();
- *destreg = shrd_long(*destreg,*shiftreg,M.x86.R_CL);
- } else {
- u16 *destreg,*shiftreg;
+ *destreg = shrd_long(*destreg, *shiftreg, M.x86.R_CL);
+ }
+ else {
+ u16 *destreg, *shiftreg;
destreg = DECODE_RM_WORD_REGISTER(rl);
DECODE_PRINTF(",");
shiftreg = DECODE_RM_WORD_REGISTER(rh);
DECODE_PRINTF(",CL\n");
TRACE_AND_STEP();
- *destreg = shrd_word(*destreg,*shiftreg,M.x86.R_CL);
+ *destreg = shrd_word(*destreg, *shiftreg, M.x86.R_CL);
}
break;
}
@@ -1153,7 +1191,8 @@ static void x86emuOp2_shrd_CL(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xaf
****************************************************************************/
-static void x86emuOp2_imul_R_RM(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_imul_R_RM(u8 X86EMU_UNUSED(op2))
{
int mod, rl, rh;
uint srcoffset;
@@ -1166,23 +1205,25 @@ static void x86emuOp2_imul_R_RM(u8 X86EMU_UNUSED(op2))
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
u32 *destreg;
u32 srcval;
- u32 res_lo,res_hi;
+ u32 res_lo, res_hi;
destreg = DECODE_RM_LONG_REGISTER(rh);
DECODE_PRINTF(",");
srcoffset = decode_rm00_address(rl);
srcval = fetch_data_long(srcoffset);
TRACE_AND_STEP();
- imul_long_direct(&res_lo,&res_hi,(s32)*destreg,(s32)srcval);
+ imul_long_direct(&res_lo, &res_hi, (s32) * destreg, (s32) srcval);
if (res_hi != 0) {
SET_FLAG(F_CF);
SET_FLAG(F_OF);
- } else {
+ }
+ else {
CLEAR_FLAG(F_CF);
CLEAR_FLAG(F_OF);
}
- *destreg = (u32)res_lo;
- } else {
+ *destreg = (u32) res_lo;
+ }
+ else {
u16 *destreg;
u16 srcval;
u32 res;
@@ -1192,38 +1233,41 @@ static void x86emuOp2_imul_R_RM(u8 X86EMU_UNUSED(op2))
srcoffset = decode_rm00_address(rl);
srcval = fetch_data_word(srcoffset);
TRACE_AND_STEP();
- res = (s16)*destreg * (s16)srcval;
+ res = (s16) * destreg * (s16) srcval;
if (res > 0xFFFF) {
SET_FLAG(F_CF);
SET_FLAG(F_OF);
- } else {
+ }
+ else {
CLEAR_FLAG(F_CF);
CLEAR_FLAG(F_OF);
}
- *destreg = (u16)res;
+ *destreg = (u16) res;
}
break;
case 1:
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
u32 *destreg;
u32 srcval;
- u32 res_lo,res_hi;
+ u32 res_lo, res_hi;
destreg = DECODE_RM_LONG_REGISTER(rh);
DECODE_PRINTF(",");
srcoffset = decode_rm01_address(rl);
srcval = fetch_data_long(srcoffset);
TRACE_AND_STEP();
- imul_long_direct(&res_lo,&res_hi,(s32)*destreg,(s32)srcval);
+ imul_long_direct(&res_lo, &res_hi, (s32) * destreg, (s32) srcval);
if (res_hi != 0) {
SET_FLAG(F_CF);
SET_FLAG(F_OF);
- } else {
+ }
+ else {
CLEAR_FLAG(F_CF);
CLEAR_FLAG(F_OF);
}
- *destreg = (u32)res_lo;
- } else {
+ *destreg = (u32) res_lo;
+ }
+ else {
u16 *destreg;
u16 srcval;
u32 res;
@@ -1233,38 +1277,41 @@ static void x86emuOp2_imul_R_RM(u8 X86EMU_UNUSED(op2))
srcoffset = decode_rm01_address(rl);
srcval = fetch_data_word(srcoffset);
TRACE_AND_STEP();
- res = (s16)*destreg * (s16)srcval;
+ res = (s16) * destreg * (s16) srcval;
if (res > 0xFFFF) {
SET_FLAG(F_CF);
SET_FLAG(F_OF);
- } else {
+ }
+ else {
CLEAR_FLAG(F_CF);
CLEAR_FLAG(F_OF);
}
- *destreg = (u16)res;
+ *destreg = (u16) res;
}
break;
case 2:
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
u32 *destreg;
u32 srcval;
- u32 res_lo,res_hi;
+ u32 res_lo, res_hi;
destreg = DECODE_RM_LONG_REGISTER(rh);
DECODE_PRINTF(",");
srcoffset = decode_rm10_address(rl);
srcval = fetch_data_long(srcoffset);
TRACE_AND_STEP();
- imul_long_direct(&res_lo,&res_hi,(s32)*destreg,(s32)srcval);
+ imul_long_direct(&res_lo, &res_hi, (s32) * destreg, (s32) srcval);
if (res_hi != 0) {
SET_FLAG(F_CF);
SET_FLAG(F_OF);
- } else {
+ }
+ else {
CLEAR_FLAG(F_CF);
CLEAR_FLAG(F_OF);
}
- *destreg = (u32)res_lo;
- } else {
+ *destreg = (u32) res_lo;
+ }
+ else {
u16 *destreg;
u16 srcval;
u32 res;
@@ -1274,51 +1321,55 @@ static void x86emuOp2_imul_R_RM(u8 X86EMU_UNUSED(op2))
srcoffset = decode_rm10_address(rl);
srcval = fetch_data_word(srcoffset);
TRACE_AND_STEP();
- res = (s16)*destreg * (s16)srcval;
+ res = (s16) * destreg * (s16) srcval;
if (res > 0xFFFF) {
SET_FLAG(F_CF);
SET_FLAG(F_OF);
- } else {
+ }
+ else {
CLEAR_FLAG(F_CF);
CLEAR_FLAG(F_OF);
}
- *destreg = (u16)res;
+ *destreg = (u16) res;
}
break;
- case 3: /* register to register */
+ case 3: /* register to register */
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg,*srcreg;
- u32 res_lo,res_hi;
+ u32 *destreg, *srcreg;
+ u32 res_lo, res_hi;
destreg = DECODE_RM_LONG_REGISTER(rh);
DECODE_PRINTF(",");
srcreg = DECODE_RM_LONG_REGISTER(rl);
TRACE_AND_STEP();
- imul_long_direct(&res_lo,&res_hi,(s32)*destreg,(s32)*srcreg);
+ imul_long_direct(&res_lo, &res_hi, (s32) * destreg, (s32) * srcreg);
if (res_hi != 0) {
SET_FLAG(F_CF);
SET_FLAG(F_OF);
- } else {
+ }
+ else {
CLEAR_FLAG(F_CF);
CLEAR_FLAG(F_OF);
}
- *destreg = (u32)res_lo;
- } else {
- u16 *destreg,*srcreg;
+ *destreg = (u32) res_lo;
+ }
+ else {
+ u16 *destreg, *srcreg;
u32 res;
destreg = DECODE_RM_WORD_REGISTER(rh);
DECODE_PRINTF(",");
srcreg = DECODE_RM_WORD_REGISTER(rl);
- res = (s16)*destreg * (s16)*srcreg;
+ res = (s16) * destreg * (s16) * srcreg;
if (res > 0xFFFF) {
SET_FLAG(F_CF);
SET_FLAG(F_OF);
- } else {
+ }
+ else {
CLEAR_FLAG(F_CF);
CLEAR_FLAG(F_OF);
}
- *destreg = (u16)res;
+ *destreg = (u16) res;
}
break;
}
@@ -1330,9 +1381,10 @@ static void x86emuOp2_imul_R_RM(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xb2
****************************************************************************/
-static void x86emuOp2_lss_R_IMM(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_lss_R_IMM(u8 X86EMU_UNUSED(op2))
{
- int mod, rh, rl;
+ int mod, rh, rl;
u16 *dstreg;
uint srcoffset;
@@ -1367,7 +1419,7 @@ static void x86emuOp2_lss_R_IMM(u8 X86EMU_UNUSED(op2))
*dstreg = fetch_data_word(srcoffset);
M.x86.R_SS = fetch_data_word(srcoffset + 2);
break;
- case 3: /* register to register */
+ case 3: /* register to register */
/* UNDEFINED! */
TRACE_AND_STEP();
}
@@ -1379,148 +1431,154 @@ static void x86emuOp2_lss_R_IMM(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xb3
****************************************************************************/
-static void x86emuOp2_btr_R(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_btr_R(u8 X86EMU_UNUSED(op2))
{
- int mod, rl, rh;
- uint srcoffset;
- int bit,disp;
-
- START_OF_INSTR();
- DECODE_PRINTF("BTR\t");
- FETCH_DECODE_MODRM(mod, rh, rl);
- switch (mod) {
- case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 srcval,mask;
- u32 *shiftreg;
-
- srcoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- shiftreg = DECODE_RM_LONG_REGISTER(rh);
- TRACE_AND_STEP();
- bit = *shiftreg & 0x1F;
- disp = (s16)*shiftreg >> 5;
- srcval = fetch_data_long(srcoffset+disp);
- mask = (0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- store_data_long(srcoffset+disp, srcval & ~mask);
- } else {
- u16 srcval,mask;
- u16 *shiftreg;
-
- srcoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- shiftreg = DECODE_RM_WORD_REGISTER(rh);
- TRACE_AND_STEP();
- bit = *shiftreg & 0xF;
- disp = (s16)*shiftreg >> 4;
- srcval = fetch_data_word(srcoffset+disp);
- mask = (u16)(0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- store_data_word(srcoffset+disp, (u16)(srcval & ~mask));
- }
- break;
- case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 srcval,mask;
- u32 *shiftreg;
-
- srcoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- shiftreg = DECODE_RM_LONG_REGISTER(rh);
- TRACE_AND_STEP();
- bit = *shiftreg & 0x1F;
- disp = (s16)*shiftreg >> 5;
- srcval = fetch_data_long(srcoffset+disp);
- mask = (0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- store_data_long(srcoffset+disp, srcval & ~mask);
- } else {
- u16 srcval,mask;
- u16 *shiftreg;
-
- srcoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- shiftreg = DECODE_RM_WORD_REGISTER(rh);
- TRACE_AND_STEP();
- bit = *shiftreg & 0xF;
- disp = (s16)*shiftreg >> 4;
- srcval = fetch_data_word(srcoffset+disp);
- mask = (u16)(0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- store_data_word(srcoffset+disp, (u16)(srcval & ~mask));
- }
- break;
- case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 srcval,mask;
- u32 *shiftreg;
-
- srcoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- shiftreg = DECODE_RM_LONG_REGISTER(rh);
- TRACE_AND_STEP();
- bit = *shiftreg & 0x1F;
- disp = (s16)*shiftreg >> 5;
- srcval = fetch_data_long(srcoffset+disp);
- mask = (0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- store_data_long(srcoffset+disp, srcval & ~mask);
- } else {
- u16 srcval,mask;
- u16 *shiftreg;
-
- srcoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- shiftreg = DECODE_RM_WORD_REGISTER(rh);
- TRACE_AND_STEP();
- bit = *shiftreg & 0xF;
- disp = (s16)*shiftreg >> 4;
- srcval = fetch_data_word(srcoffset+disp);
- mask = (u16)(0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- store_data_word(srcoffset+disp, (u16)(srcval & ~mask));
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *srcreg,*shiftreg;
- u32 mask;
-
- srcreg = DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF(",");
- shiftreg = DECODE_RM_LONG_REGISTER(rh);
- TRACE_AND_STEP();
- bit = *shiftreg & 0x1F;
- mask = (0x1 << bit);
- CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF);
- *srcreg &= ~mask;
- } else {
- u16 *srcreg,*shiftreg;
- u16 mask;
-
- srcreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",");
- shiftreg = DECODE_RM_WORD_REGISTER(rh);
- TRACE_AND_STEP();
- bit = *shiftreg & 0xF;
- mask = (u16)(0x1 << bit);
- CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF);
- *srcreg &= ~mask;
- }
- break;
- }
- DECODE_CLEAR_SEGOVR();
- END_OF_INSTR();
+ int mod, rl, rh;
+ uint srcoffset;
+ int bit, disp;
+
+ START_OF_INSTR();
+ DECODE_PRINTF("BTR\t");
+ FETCH_DECODE_MODRM(mod, rh, rl);
+ switch (mod) {
+ case 0:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 srcval, mask;
+ u32 *shiftreg;
+
+ srcoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ shiftreg = DECODE_RM_LONG_REGISTER(rh);
+ TRACE_AND_STEP();
+ bit = *shiftreg & 0x1F;
+ disp = (s16) * shiftreg >> 5;
+ srcval = fetch_data_long(srcoffset + disp);
+ mask = (0x1 << bit);
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ store_data_long(srcoffset + disp, srcval & ~mask);
+ }
+ else {
+ u16 srcval, mask;
+ u16 *shiftreg;
+
+ srcoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ shiftreg = DECODE_RM_WORD_REGISTER(rh);
+ TRACE_AND_STEP();
+ bit = *shiftreg & 0xF;
+ disp = (s16) * shiftreg >> 4;
+ srcval = fetch_data_word(srcoffset + disp);
+ mask = (u16) (0x1 << bit);
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ store_data_word(srcoffset + disp, (u16) (srcval & ~mask));
+ }
+ break;
+ case 1:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 srcval, mask;
+ u32 *shiftreg;
+
+ srcoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ shiftreg = DECODE_RM_LONG_REGISTER(rh);
+ TRACE_AND_STEP();
+ bit = *shiftreg & 0x1F;
+ disp = (s16) * shiftreg >> 5;
+ srcval = fetch_data_long(srcoffset + disp);
+ mask = (0x1 << bit);
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ store_data_long(srcoffset + disp, srcval & ~mask);
+ }
+ else {
+ u16 srcval, mask;
+ u16 *shiftreg;
+
+ srcoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ shiftreg = DECODE_RM_WORD_REGISTER(rh);
+ TRACE_AND_STEP();
+ bit = *shiftreg & 0xF;
+ disp = (s16) * shiftreg >> 4;
+ srcval = fetch_data_word(srcoffset + disp);
+ mask = (u16) (0x1 << bit);
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ store_data_word(srcoffset + disp, (u16) (srcval & ~mask));
+ }
+ break;
+ case 2:
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 srcval, mask;
+ u32 *shiftreg;
+
+ srcoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ shiftreg = DECODE_RM_LONG_REGISTER(rh);
+ TRACE_AND_STEP();
+ bit = *shiftreg & 0x1F;
+ disp = (s16) * shiftreg >> 5;
+ srcval = fetch_data_long(srcoffset + disp);
+ mask = (0x1 << bit);
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ store_data_long(srcoffset + disp, srcval & ~mask);
+ }
+ else {
+ u16 srcval, mask;
+ u16 *shiftreg;
+
+ srcoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ shiftreg = DECODE_RM_WORD_REGISTER(rh);
+ TRACE_AND_STEP();
+ bit = *shiftreg & 0xF;
+ disp = (s16) * shiftreg >> 4;
+ srcval = fetch_data_word(srcoffset + disp);
+ mask = (u16) (0x1 << bit);
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ store_data_word(srcoffset + disp, (u16) (srcval & ~mask));
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 *srcreg, *shiftreg;
+ u32 mask;
+
+ srcreg = DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF(",");
+ shiftreg = DECODE_RM_LONG_REGISTER(rh);
+ TRACE_AND_STEP();
+ bit = *shiftreg & 0x1F;
+ mask = (0x1 << bit);
+ CONDITIONAL_SET_FLAG(*srcreg & mask, F_CF);
+ *srcreg &= ~mask;
+ }
+ else {
+ u16 *srcreg, *shiftreg;
+ u16 mask;
+
+ srcreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",");
+ shiftreg = DECODE_RM_WORD_REGISTER(rh);
+ TRACE_AND_STEP();
+ bit = *shiftreg & 0xF;
+ mask = (u16) (0x1 << bit);
+ CONDITIONAL_SET_FLAG(*srcreg & mask, F_CF);
+ *srcreg &= ~mask;
+ }
+ break;
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
}
/****************************************************************************
REMARKS:
Handles opcode 0x0f,0xb4
****************************************************************************/
-static void x86emuOp2_lfs_R_IMM(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_lfs_R_IMM(u8 X86EMU_UNUSED(op2))
{
- int mod, rh, rl;
+ int mod, rh, rl;
u16 *dstreg;
uint srcoffset;
@@ -1555,7 +1613,7 @@ static void x86emuOp2_lfs_R_IMM(u8 X86EMU_UNUSED(op2))
*dstreg = fetch_data_word(srcoffset);
M.x86.R_FS = fetch_data_word(srcoffset + 2);
break;
- case 3: /* register to register */
+ case 3: /* register to register */
/* UNDEFINED! */
TRACE_AND_STEP();
}
@@ -1567,9 +1625,10 @@ static void x86emuOp2_lfs_R_IMM(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xb5
****************************************************************************/
-static void x86emuOp2_lgs_R_IMM(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_lgs_R_IMM(u8 X86EMU_UNUSED(op2))
{
- int mod, rh, rl;
+ int mod, rh, rl;
u16 *dstreg;
uint srcoffset;
@@ -1604,7 +1663,7 @@ static void x86emuOp2_lgs_R_IMM(u8 X86EMU_UNUSED(op2))
*dstreg = fetch_data_word(srcoffset);
M.x86.R_GS = fetch_data_word(srcoffset + 2);
break;
- case 3: /* register to register */
+ case 3: /* register to register */
/* UNDEFINED! */
TRACE_AND_STEP();
}
@@ -1616,7 +1675,8 @@ static void x86emuOp2_lgs_R_IMM(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xb6
****************************************************************************/
-static void x86emuOp2_movzx_byte_R_RM(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_movzx_byte_R_RM(u8 X86EMU_UNUSED(op2))
{
int mod, rl, rh;
uint srcoffset;
@@ -1637,7 +1697,8 @@ static void x86emuOp2_movzx_byte_R_RM(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF("\n");
TRACE_AND_STEP();
*destreg = srcval;
- } else {
+ }
+ else {
u16 *destreg;
u16 srcval;
@@ -1662,7 +1723,8 @@ static void x86emuOp2_movzx_byte_R_RM(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF("\n");
TRACE_AND_STEP();
*destreg = srcval;
- } else {
+ }
+ else {
u16 *destreg;
u16 srcval;
@@ -1687,7 +1749,8 @@ static void x86emuOp2_movzx_byte_R_RM(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF("\n");
TRACE_AND_STEP();
*destreg = srcval;
- } else {
+ }
+ else {
u16 *destreg;
u16 srcval;
@@ -1700,10 +1763,10 @@ static void x86emuOp2_movzx_byte_R_RM(u8 X86EMU_UNUSED(op2))
*destreg = srcval;
}
break;
- case 3: /* register to register */
+ case 3: /* register to register */
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
u32 *destreg;
- u8 *srcreg;
+ u8 *srcreg;
destreg = DECODE_RM_LONG_REGISTER(rh);
DECODE_PRINTF(",");
@@ -1711,9 +1774,10 @@ static void x86emuOp2_movzx_byte_R_RM(u8 X86EMU_UNUSED(op2))
DECODE_PRINTF("\n");
TRACE_AND_STEP();
*destreg = *srcreg;
- } else {
+ }
+ else {
u16 *destreg;
- u8 *srcreg;
+ u8 *srcreg;
destreg = DECODE_RM_WORD_REGISTER(rh);
DECODE_PRINTF(",");
@@ -1732,7 +1796,8 @@ static void x86emuOp2_movzx_byte_R_RM(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xb7
****************************************************************************/
-static void x86emuOp2_movzx_word_R_RM(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_movzx_word_R_RM(u8 X86EMU_UNUSED(op2))
{
int mod, rl, rh;
uint srcoffset;
@@ -1771,7 +1836,7 @@ static void x86emuOp2_movzx_word_R_RM(u8 X86EMU_UNUSED(op2))
TRACE_AND_STEP();
*destreg = srcval;
break;
- case 3: /* register to register */
+ case 3: /* register to register */
destreg = DECODE_RM_LONG_REGISTER(rh);
DECODE_PRINTF(",");
srcreg = DECODE_RM_WORD_REGISTER(rl);
@@ -1788,7 +1853,8 @@ static void x86emuOp2_movzx_word_R_RM(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xba
****************************************************************************/
-static void x86emuOp2_btX_I(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_btX_I(u8 X86EMU_UNUSED(op2))
{
int mod, rl, rh;
uint srcoffset;
@@ -1798,23 +1864,23 @@ static void x86emuOp2_btX_I(u8 X86EMU_UNUSED(op2))
FETCH_DECODE_MODRM(mod, rh, rl);
switch (rh) {
case 4:
- DECODE_PRINTF("BT\t");
- break;
+ DECODE_PRINTF("BT\t");
+ break;
case 5:
- DECODE_PRINTF("BTS\t");
- break;
+ DECODE_PRINTF("BTS\t");
+ break;
case 6:
- DECODE_PRINTF("BTR\t");
- break;
+ DECODE_PRINTF("BTR\t");
+ break;
case 7:
- DECODE_PRINTF("BTC\t");
- break;
+ DECODE_PRINTF("BTC\t");
+ break;
default:
- DECODE_PRINTF("ILLEGAL EXTENDED X86 OPCODE\n");
- TRACE_REGS();
- printk("%04x:%04x: %02X%02X ILLEGAL EXTENDED X86 OPCODE EXTENSION!\n",
- M.x86.R_CS, M.x86.R_IP-3,op2, (mod<<6)|(rh<<3)|rl);
- HALT_SYS();
+ DECODE_PRINTF("ILLEGAL EXTENDED X86 OPCODE\n");
+ TRACE_REGS();
+ printk("%04x:%04x: %02X%02X ILLEGAL EXTENDED X86 OPCODE EXTENSION!\n",
+ M.x86.R_CS, M.x86.R_IP - 3, op2, (mod << 6) | (rh << 3) | rl);
+ HALT_SYS();
}
switch (mod) {
case 0:
@@ -1828,22 +1894,23 @@ static void x86emuOp2_btX_I(u8 X86EMU_UNUSED(op2))
TRACE_AND_STEP();
bit = shift & 0x1F;
srcval = fetch_data_long(srcoffset);
- mask = (0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- switch (rh) {
- case 5:
- store_data_long(srcoffset, srcval | mask);
- break;
- case 6:
- store_data_long(srcoffset, srcval & ~mask);
- break;
- case 7:
- store_data_long(srcoffset, srcval ^ mask);
- break;
- default:
- break;
- }
- } else {
+ mask = (0x1 << bit);
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ switch (rh) {
+ case 5:
+ store_data_long(srcoffset, srcval | mask);
+ break;
+ case 6:
+ store_data_long(srcoffset, srcval & ~mask);
+ break;
+ case 7:
+ store_data_long(srcoffset, srcval ^ mask);
+ break;
+ default:
+ break;
+ }
+ }
+ else {
u16 srcval, mask;
u8 shift;
@@ -1853,21 +1920,21 @@ static void x86emuOp2_btX_I(u8 X86EMU_UNUSED(op2))
TRACE_AND_STEP();
bit = shift & 0xF;
srcval = fetch_data_word(srcoffset);
- mask = (0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- switch (rh) {
- case 5:
- store_data_word(srcoffset, srcval | mask);
- break;
- case 6:
- store_data_word(srcoffset, srcval & ~mask);
- break;
- case 7:
- store_data_word(srcoffset, srcval ^ mask);
- break;
- default:
- break;
- }
+ mask = (0x1 << bit);
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ switch (rh) {
+ case 5:
+ store_data_word(srcoffset, srcval | mask);
+ break;
+ case 6:
+ store_data_word(srcoffset, srcval & ~mask);
+ break;
+ case 7:
+ store_data_word(srcoffset, srcval ^ mask);
+ break;
+ default:
+ break;
+ }
}
break;
case 1:
@@ -1881,22 +1948,23 @@ static void x86emuOp2_btX_I(u8 X86EMU_UNUSED(op2))
TRACE_AND_STEP();
bit = shift & 0x1F;
srcval = fetch_data_long(srcoffset);
- mask = (0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- switch (rh) {
- case 5:
- store_data_long(srcoffset, srcval | mask);
- break;
- case 6:
- store_data_long(srcoffset, srcval & ~mask);
- break;
- case 7:
- store_data_long(srcoffset, srcval ^ mask);
- break;
- default:
- break;
- }
- } else {
+ mask = (0x1 << bit);
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ switch (rh) {
+ case 5:
+ store_data_long(srcoffset, srcval | mask);
+ break;
+ case 6:
+ store_data_long(srcoffset, srcval & ~mask);
+ break;
+ case 7:
+ store_data_long(srcoffset, srcval ^ mask);
+ break;
+ default:
+ break;
+ }
+ }
+ else {
u16 srcval, mask;
u8 shift;
@@ -1906,21 +1974,21 @@ static void x86emuOp2_btX_I(u8 X86EMU_UNUSED(op2))
TRACE_AND_STEP();
bit = shift & 0xF;
srcval = fetch_data_word(srcoffset);
- mask = (0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- switch (rh) {
- case 5:
- store_data_word(srcoffset, srcval | mask);
- break;
- case 6:
- store_data_word(srcoffset, srcval & ~mask);
- break;
- case 7:
- store_data_word(srcoffset, srcval ^ mask);
- break;
- default:
- break;
- }
+ mask = (0x1 << bit);
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ switch (rh) {
+ case 5:
+ store_data_word(srcoffset, srcval | mask);
+ break;
+ case 6:
+ store_data_word(srcoffset, srcval & ~mask);
+ break;
+ case 7:
+ store_data_word(srcoffset, srcval ^ mask);
+ break;
+ default:
+ break;
+ }
}
break;
case 2:
@@ -1934,22 +2002,23 @@ static void x86emuOp2_btX_I(u8 X86EMU_UNUSED(op2))
TRACE_AND_STEP();
bit = shift & 0x1F;
srcval = fetch_data_long(srcoffset);
- mask = (0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- switch (rh) {
- case 5:
- store_data_long(srcoffset, srcval | mask);
- break;
- case 6:
- store_data_long(srcoffset, srcval & ~mask);
- break;
- case 7:
- store_data_long(srcoffset, srcval ^ mask);
- break;
- default:
- break;
- }
- } else {
+ mask = (0x1 << bit);
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ switch (rh) {
+ case 5:
+ store_data_long(srcoffset, srcval | mask);
+ break;
+ case 6:
+ store_data_long(srcoffset, srcval & ~mask);
+ break;
+ case 7:
+ store_data_long(srcoffset, srcval ^ mask);
+ break;
+ default:
+ break;
+ }
+ }
+ else {
u16 srcval, mask;
u8 shift;
@@ -1959,74 +2028,75 @@ static void x86emuOp2_btX_I(u8 X86EMU_UNUSED(op2))
TRACE_AND_STEP();
bit = shift & 0xF;
srcval = fetch_data_word(srcoffset);
- mask = (0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- switch (rh) {
- case 5:
- store_data_word(srcoffset, srcval | mask);
- break;
- case 6:
- store_data_word(srcoffset, srcval & ~mask);
- break;
- case 7:
- store_data_word(srcoffset, srcval ^ mask);
- break;
- default:
- break;
- }
- }
- break;
- case 3: /* register to register */
+ mask = (0x1 << bit);
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ switch (rh) {
+ case 5:
+ store_data_word(srcoffset, srcval | mask);
+ break;
+ case 6:
+ store_data_word(srcoffset, srcval & ~mask);
+ break;
+ case 7:
+ store_data_word(srcoffset, srcval ^ mask);
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ case 3: /* register to register */
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
u32 *srcreg;
- u32 mask;
- u8 shift;
+ u32 mask;
+ u8 shift;
srcreg = DECODE_RM_LONG_REGISTER(rl);
DECODE_PRINTF(",");
shift = fetch_byte_imm();
TRACE_AND_STEP();
bit = shift & 0x1F;
- mask = (0x1 << bit);
- CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF);
- switch (rh) {
- case 5:
- *srcreg |= mask;
- break;
- case 6:
- *srcreg &= ~mask;
- break;
- case 7:
- *srcreg ^= mask;
- break;
- default:
- break;
- }
- } else {
+ mask = (0x1 << bit);
+ CONDITIONAL_SET_FLAG(*srcreg & mask, F_CF);
+ switch (rh) {
+ case 5:
+ *srcreg |= mask;
+ break;
+ case 6:
+ *srcreg &= ~mask;
+ break;
+ case 7:
+ *srcreg ^= mask;
+ break;
+ default:
+ break;
+ }
+ }
+ else {
u16 *srcreg;
- u16 mask;
- u8 shift;
+ u16 mask;
+ u8 shift;
srcreg = DECODE_RM_WORD_REGISTER(rl);
DECODE_PRINTF(",");
shift = fetch_byte_imm();
TRACE_AND_STEP();
bit = shift & 0xF;
- mask = (0x1 << bit);
- CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF);
- switch (rh) {
- case 5:
- *srcreg |= mask;
- break;
- case 6:
- *srcreg &= ~mask;
- break;
- case 7:
- *srcreg ^= mask;
- break;
- default:
- break;
- }
+ mask = (0x1 << bit);
+ CONDITIONAL_SET_FLAG(*srcreg & mask, F_CF);
+ switch (rh) {
+ case 5:
+ *srcreg |= mask;
+ break;
+ case 6:
+ *srcreg &= ~mask;
+ break;
+ case 7:
+ *srcreg ^= mask;
+ break;
+ default:
+ break;
+ }
}
break;
}
@@ -2038,11 +2108,12 @@ static void x86emuOp2_btX_I(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xbb
****************************************************************************/
-static void x86emuOp2_btc_R(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_btc_R(u8 X86EMU_UNUSED(op2))
{
int mod, rl, rh;
uint srcoffset;
- int bit,disp;
+ int bit, disp;
START_OF_INSTR();
DECODE_PRINTF("BTC\t");
@@ -2050,7 +2121,7 @@ static void x86emuOp2_btc_R(u8 X86EMU_UNUSED(op2))
switch (mod) {
case 0:
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 srcval,mask;
+ u32 srcval, mask;
u32 *shiftreg;
srcoffset = decode_rm00_address(rl);
@@ -2058,13 +2129,14 @@ static void x86emuOp2_btc_R(u8 X86EMU_UNUSED(op2))
shiftreg = DECODE_RM_LONG_REGISTER(rh);
TRACE_AND_STEP();
bit = *shiftreg & 0x1F;
- disp = (s16)*shiftreg >> 5;
- srcval = fetch_data_long(srcoffset+disp);
+ disp = (s16) * shiftreg >> 5;
+ srcval = fetch_data_long(srcoffset + disp);
mask = (0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- store_data_long(srcoffset+disp, srcval ^ mask);
- } else {
- u16 srcval,mask;
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ store_data_long(srcoffset + disp, srcval ^ mask);
+ }
+ else {
+ u16 srcval, mask;
u16 *shiftreg;
srcoffset = decode_rm00_address(rl);
@@ -2072,16 +2144,16 @@ static void x86emuOp2_btc_R(u8 X86EMU_UNUSED(op2))
shiftreg = DECODE_RM_WORD_REGISTER(rh);
TRACE_AND_STEP();
bit = *shiftreg & 0xF;
- disp = (s16)*shiftreg >> 4;
- srcval = fetch_data_word(srcoffset+disp);
- mask = (u16)(0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- store_data_word(srcoffset+disp, (u16)(srcval ^ mask));
+ disp = (s16) * shiftreg >> 4;
+ srcval = fetch_data_word(srcoffset + disp);
+ mask = (u16) (0x1 << bit);
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ store_data_word(srcoffset + disp, (u16) (srcval ^ mask));
}
break;
case 1:
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 srcval,mask;
+ u32 srcval, mask;
u32 *shiftreg;
srcoffset = decode_rm01_address(rl);
@@ -2089,13 +2161,14 @@ static void x86emuOp2_btc_R(u8 X86EMU_UNUSED(op2))
shiftreg = DECODE_RM_LONG_REGISTER(rh);
TRACE_AND_STEP();
bit = *shiftreg & 0x1F;
- disp = (s16)*shiftreg >> 5;
- srcval = fetch_data_long(srcoffset+disp);
+ disp = (s16) * shiftreg >> 5;
+ srcval = fetch_data_long(srcoffset + disp);
mask = (0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- store_data_long(srcoffset+disp, srcval ^ mask);
- } else {
- u16 srcval,mask;
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ store_data_long(srcoffset + disp, srcval ^ mask);
+ }
+ else {
+ u16 srcval, mask;
u16 *shiftreg;
srcoffset = decode_rm01_address(rl);
@@ -2103,16 +2176,16 @@ static void x86emuOp2_btc_R(u8 X86EMU_UNUSED(op2))
shiftreg = DECODE_RM_WORD_REGISTER(rh);
TRACE_AND_STEP();
bit = *shiftreg & 0xF;
- disp = (s16)*shiftreg >> 4;
- srcval = fetch_data_word(srcoffset+disp);
- mask = (u16)(0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- store_data_word(srcoffset+disp, (u16)(srcval ^ mask));
+ disp = (s16) * shiftreg >> 4;
+ srcval = fetch_data_word(srcoffset + disp);
+ mask = (u16) (0x1 << bit);
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ store_data_word(srcoffset + disp, (u16) (srcval ^ mask));
}
break;
case 2:
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 srcval,mask;
+ u32 srcval, mask;
u32 *shiftreg;
srcoffset = decode_rm10_address(rl);
@@ -2120,13 +2193,14 @@ static void x86emuOp2_btc_R(u8 X86EMU_UNUSED(op2))
shiftreg = DECODE_RM_LONG_REGISTER(rh);
TRACE_AND_STEP();
bit = *shiftreg & 0x1F;
- disp = (s16)*shiftreg >> 5;
- srcval = fetch_data_long(srcoffset+disp);
+ disp = (s16) * shiftreg >> 5;
+ srcval = fetch_data_long(srcoffset + disp);
mask = (0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- store_data_long(srcoffset+disp, srcval ^ mask);
- } else {
- u16 srcval,mask;
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ store_data_long(srcoffset + disp, srcval ^ mask);
+ }
+ else {
+ u16 srcval, mask;
u16 *shiftreg;
srcoffset = decode_rm10_address(rl);
@@ -2134,16 +2208,16 @@ static void x86emuOp2_btc_R(u8 X86EMU_UNUSED(op2))
shiftreg = DECODE_RM_WORD_REGISTER(rh);
TRACE_AND_STEP();
bit = *shiftreg & 0xF;
- disp = (s16)*shiftreg >> 4;
- srcval = fetch_data_word(srcoffset+disp);
- mask = (u16)(0x1 << bit);
- CONDITIONAL_SET_FLAG(srcval & mask,F_CF);
- store_data_word(srcoffset+disp, (u16)(srcval ^ mask));
+ disp = (s16) * shiftreg >> 4;
+ srcval = fetch_data_word(srcoffset + disp);
+ mask = (u16) (0x1 << bit);
+ CONDITIONAL_SET_FLAG(srcval & mask, F_CF);
+ store_data_word(srcoffset + disp, (u16) (srcval ^ mask));
}
break;
- case 3: /* register to register */
+ case 3: /* register to register */
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *srcreg,*shiftreg;
+ u32 *srcreg, *shiftreg;
u32 mask;
srcreg = DECODE_RM_LONG_REGISTER(rl);
@@ -2152,19 +2226,20 @@ static void x86emuOp2_btc_R(u8 X86EMU_UNUSED(op2))
TRACE_AND_STEP();
bit = *shiftreg & 0x1F;
mask = (0x1 << bit);
- CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF);
- *srcreg ^= mask;
- } else {
- u16 *srcreg,*shiftreg;
- u16 mask;
-
- srcreg = DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",");
- shiftreg = DECODE_RM_WORD_REGISTER(rh);
- TRACE_AND_STEP();
- bit = *shiftreg & 0xF;
- mask = (u16)(0x1 << bit);
- CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF);
+ CONDITIONAL_SET_FLAG(*srcreg & mask, F_CF);
+ *srcreg ^= mask;
+ }
+ else {
+ u16 *srcreg, *shiftreg;
+ u16 mask;
+
+ srcreg = DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",");
+ shiftreg = DECODE_RM_WORD_REGISTER(rh);
+ TRACE_AND_STEP();
+ bit = *shiftreg & 0xF;
+ mask = (u16) (0x1 << bit);
+ CONDITIONAL_SET_FLAG(*srcreg & mask, F_CF);
*srcreg ^= mask;
}
break;
@@ -2177,7 +2252,8 @@ static void x86emuOp2_btc_R(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xbc
****************************************************************************/
-static void x86emuOp2_bsf(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_bsf(u8 X86EMU_UNUSED(op2))
{
int mod, rl, rh;
uint srcoffset;
@@ -2185,105 +2261,117 @@ static void x86emuOp2_bsf(u8 X86EMU_UNUSED(op2))
START_OF_INSTR();
DECODE_PRINTF("BSF\t");
FETCH_DECODE_MODRM(mod, rh, rl);
- switch(mod) {
+ switch (mod) {
case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 srcval, *dstreg;
-
- srcoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- dstreg = DECODE_RM_LONG_REGISTER(rh);
- TRACE_AND_STEP();
- srcval = fetch_data_long(srcoffset);
- CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
- for(*dstreg = 0; *dstreg < 32; (*dstreg)++)
- if ((srcval >> *dstreg) & 1) break;
- } else {
- u16 srcval, *dstreg;
-
- srcoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- dstreg = DECODE_RM_WORD_REGISTER(rh);
- TRACE_AND_STEP();
- srcval = fetch_data_word(srcoffset);
- CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
- for(*dstreg = 0; *dstreg < 16; (*dstreg)++)
- if ((srcval >> *dstreg) & 1) break;
- }
- break;
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 srcval, *dstreg;
+
+ srcoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ dstreg = DECODE_RM_LONG_REGISTER(rh);
+ TRACE_AND_STEP();
+ srcval = fetch_data_long(srcoffset);
+ CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
+ for (*dstreg = 0; *dstreg < 32; (*dstreg)++)
+ if ((srcval >> *dstreg) & 1)
+ break;
+ }
+ else {
+ u16 srcval, *dstreg;
+
+ srcoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ dstreg = DECODE_RM_WORD_REGISTER(rh);
+ TRACE_AND_STEP();
+ srcval = fetch_data_word(srcoffset);
+ CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
+ for (*dstreg = 0; *dstreg < 16; (*dstreg)++)
+ if ((srcval >> *dstreg) & 1)
+ break;
+ }
+ break;
case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 srcval, *dstreg;
-
- srcoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- dstreg = DECODE_RM_LONG_REGISTER(rh);
- TRACE_AND_STEP();
- srcval = fetch_data_long(srcoffset);
- CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
- for(*dstreg = 0; *dstreg < 32; (*dstreg)++)
- if ((srcval >> *dstreg) & 1) break;
- } else {
- u16 srcval, *dstreg;
-
- srcoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- dstreg = DECODE_RM_WORD_REGISTER(rh);
- TRACE_AND_STEP();
- srcval = fetch_data_word(srcoffset);
- CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
- for(*dstreg = 0; *dstreg < 16; (*dstreg)++)
- if ((srcval >> *dstreg) & 1) break;
- }
- break;
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 srcval, *dstreg;
+
+ srcoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ dstreg = DECODE_RM_LONG_REGISTER(rh);
+ TRACE_AND_STEP();
+ srcval = fetch_data_long(srcoffset);
+ CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
+ for (*dstreg = 0; *dstreg < 32; (*dstreg)++)
+ if ((srcval >> *dstreg) & 1)
+ break;
+ }
+ else {
+ u16 srcval, *dstreg;
+
+ srcoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ dstreg = DECODE_RM_WORD_REGISTER(rh);
+ TRACE_AND_STEP();
+ srcval = fetch_data_word(srcoffset);
+ CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
+ for (*dstreg = 0; *dstreg < 16; (*dstreg)++)
+ if ((srcval >> *dstreg) & 1)
+ break;
+ }
+ break;
case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 srcval, *dstreg;
-
- srcoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- dstreg = DECODE_RM_LONG_REGISTER(rh);
- TRACE_AND_STEP();
- srcval = fetch_data_long(srcoffset);
- CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
- for(*dstreg = 0; *dstreg < 32; (*dstreg)++)
- if ((srcval >> *dstreg) & 1) break;
- } else {
- u16 srcval, *dstreg;
-
- srcoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- dstreg = DECODE_RM_WORD_REGISTER(rh);
- TRACE_AND_STEP();
- srcval = fetch_data_word(srcoffset);
- CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
- for(*dstreg = 0; *dstreg < 16; (*dstreg)++)
- if ((srcval >> *dstreg) & 1) break;
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 srcval, *dstreg;
-
- srcval = *DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF(",");
- dstreg = DECODE_RM_LONG_REGISTER(rh);
- TRACE_AND_STEP();
- CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
- for(*dstreg = 0; *dstreg < 32; (*dstreg)++)
- if ((srcval >> *dstreg) & 1) break;
- } else {
- u16 srcval, *dstreg;
-
- srcval = *DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",");
- dstreg = DECODE_RM_WORD_REGISTER(rh);
- TRACE_AND_STEP();
- CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
- for(*dstreg = 0; *dstreg < 16; (*dstreg)++)
- if ((srcval >> *dstreg) & 1) break;
- }
- break;
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 srcval, *dstreg;
+
+ srcoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ dstreg = DECODE_RM_LONG_REGISTER(rh);
+ TRACE_AND_STEP();
+ srcval = fetch_data_long(srcoffset);
+ CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
+ for (*dstreg = 0; *dstreg < 32; (*dstreg)++)
+ if ((srcval >> *dstreg) & 1)
+ break;
+ }
+ else {
+ u16 srcval, *dstreg;
+
+ srcoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ dstreg = DECODE_RM_WORD_REGISTER(rh);
+ TRACE_AND_STEP();
+ srcval = fetch_data_word(srcoffset);
+ CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
+ for (*dstreg = 0; *dstreg < 16; (*dstreg)++)
+ if ((srcval >> *dstreg) & 1)
+ break;
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 srcval, *dstreg;
+
+ srcval = *DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF(",");
+ dstreg = DECODE_RM_LONG_REGISTER(rh);
+ TRACE_AND_STEP();
+ CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
+ for (*dstreg = 0; *dstreg < 32; (*dstreg)++)
+ if ((srcval >> *dstreg) & 1)
+ break;
+ }
+ else {
+ u16 srcval, *dstreg;
+
+ srcval = *DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",");
+ dstreg = DECODE_RM_WORD_REGISTER(rh);
+ TRACE_AND_STEP();
+ CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
+ for (*dstreg = 0; *dstreg < 16; (*dstreg)++)
+ if ((srcval >> *dstreg) & 1)
+ break;
+ }
+ break;
}
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
@@ -2293,7 +2381,8 @@ static void x86emuOp2_bsf(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xbd
****************************************************************************/
-static void x86emuOp2_bsr(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_bsr(u8 X86EMU_UNUSED(op2))
{
int mod, rl, rh;
uint srcoffset;
@@ -2301,105 +2390,117 @@ static void x86emuOp2_bsr(u8 X86EMU_UNUSED(op2))
START_OF_INSTR();
DECODE_PRINTF("BSR\t");
FETCH_DECODE_MODRM(mod, rh, rl);
- switch(mod) {
+ switch (mod) {
case 0:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 srcval, *dstreg;
-
- srcoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- dstreg = DECODE_RM_LONG_REGISTER(rh);
- TRACE_AND_STEP();
- srcval = fetch_data_long(srcoffset);
- CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
- for(*dstreg = 31; *dstreg > 0; (*dstreg)--)
- if ((srcval >> *dstreg) & 1) break;
- } else {
- u16 srcval, *dstreg;
-
- srcoffset = decode_rm00_address(rl);
- DECODE_PRINTF(",");
- dstreg = DECODE_RM_WORD_REGISTER(rh);
- TRACE_AND_STEP();
- srcval = fetch_data_word(srcoffset);
- CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
- for(*dstreg = 15; *dstreg > 0; (*dstreg)--)
- if ((srcval >> *dstreg) & 1) break;
- }
- break;
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 srcval, *dstreg;
+
+ srcoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ dstreg = DECODE_RM_LONG_REGISTER(rh);
+ TRACE_AND_STEP();
+ srcval = fetch_data_long(srcoffset);
+ CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
+ for (*dstreg = 31; *dstreg > 0; (*dstreg)--)
+ if ((srcval >> *dstreg) & 1)
+ break;
+ }
+ else {
+ u16 srcval, *dstreg;
+
+ srcoffset = decode_rm00_address(rl);
+ DECODE_PRINTF(",");
+ dstreg = DECODE_RM_WORD_REGISTER(rh);
+ TRACE_AND_STEP();
+ srcval = fetch_data_word(srcoffset);
+ CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
+ for (*dstreg = 15; *dstreg > 0; (*dstreg)--)
+ if ((srcval >> *dstreg) & 1)
+ break;
+ }
+ break;
case 1:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 srcval, *dstreg;
-
- srcoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- dstreg = DECODE_RM_LONG_REGISTER(rh);
- TRACE_AND_STEP();
- srcval = fetch_data_long(srcoffset);
- CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
- for(*dstreg = 31; *dstreg > 0; (*dstreg)--)
- if ((srcval >> *dstreg) & 1) break;
- } else {
- u16 srcval, *dstreg;
-
- srcoffset = decode_rm01_address(rl);
- DECODE_PRINTF(",");
- dstreg = DECODE_RM_WORD_REGISTER(rh);
- TRACE_AND_STEP();
- srcval = fetch_data_word(srcoffset);
- CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
- for(*dstreg = 15; *dstreg > 0; (*dstreg)--)
- if ((srcval >> *dstreg) & 1) break;
- }
- break;
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 srcval, *dstreg;
+
+ srcoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ dstreg = DECODE_RM_LONG_REGISTER(rh);
+ TRACE_AND_STEP();
+ srcval = fetch_data_long(srcoffset);
+ CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
+ for (*dstreg = 31; *dstreg > 0; (*dstreg)--)
+ if ((srcval >> *dstreg) & 1)
+ break;
+ }
+ else {
+ u16 srcval, *dstreg;
+
+ srcoffset = decode_rm01_address(rl);
+ DECODE_PRINTF(",");
+ dstreg = DECODE_RM_WORD_REGISTER(rh);
+ TRACE_AND_STEP();
+ srcval = fetch_data_word(srcoffset);
+ CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
+ for (*dstreg = 15; *dstreg > 0; (*dstreg)--)
+ if ((srcval >> *dstreg) & 1)
+ break;
+ }
+ break;
case 2:
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 srcval, *dstreg;
-
- srcoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- dstreg = DECODE_RM_LONG_REGISTER(rh);
- TRACE_AND_STEP();
- srcval = fetch_data_long(srcoffset);
- CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
- for(*dstreg = 31; *dstreg > 0; (*dstreg)--)
- if ((srcval >> *dstreg) & 1) break;
- } else {
- u16 srcval, *dstreg;
-
- srcoffset = decode_rm10_address(rl);
- DECODE_PRINTF(",");
- dstreg = DECODE_RM_WORD_REGISTER(rh);
- TRACE_AND_STEP();
- srcval = fetch_data_word(srcoffset);
- CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
- for(*dstreg = 15; *dstreg > 0; (*dstreg)--)
- if ((srcval >> *dstreg) & 1) break;
- }
- break;
- case 3: /* register to register */
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 srcval, *dstreg;
-
- srcval = *DECODE_RM_LONG_REGISTER(rl);
- DECODE_PRINTF(",");
- dstreg = DECODE_RM_LONG_REGISTER(rh);
- TRACE_AND_STEP();
- CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
- for(*dstreg = 31; *dstreg > 0; (*dstreg)--)
- if ((srcval >> *dstreg) & 1) break;
- } else {
- u16 srcval, *dstreg;
-
- srcval = *DECODE_RM_WORD_REGISTER(rl);
- DECODE_PRINTF(",");
- dstreg = DECODE_RM_WORD_REGISTER(rh);
- TRACE_AND_STEP();
- CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
- for(*dstreg = 15; *dstreg > 0; (*dstreg)--)
- if ((srcval >> *dstreg) & 1) break;
- }
- break;
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 srcval, *dstreg;
+
+ srcoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ dstreg = DECODE_RM_LONG_REGISTER(rh);
+ TRACE_AND_STEP();
+ srcval = fetch_data_long(srcoffset);
+ CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
+ for (*dstreg = 31; *dstreg > 0; (*dstreg)--)
+ if ((srcval >> *dstreg) & 1)
+ break;
+ }
+ else {
+ u16 srcval, *dstreg;
+
+ srcoffset = decode_rm10_address(rl);
+ DECODE_PRINTF(",");
+ dstreg = DECODE_RM_WORD_REGISTER(rh);
+ TRACE_AND_STEP();
+ srcval = fetch_data_word(srcoffset);
+ CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
+ for (*dstreg = 15; *dstreg > 0; (*dstreg)--)
+ if ((srcval >> *dstreg) & 1)
+ break;
+ }
+ break;
+ case 3: /* register to register */
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ u32 srcval, *dstreg;
+
+ srcval = *DECODE_RM_LONG_REGISTER(rl);
+ DECODE_PRINTF(",");
+ dstreg = DECODE_RM_LONG_REGISTER(rh);
+ TRACE_AND_STEP();
+ CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
+ for (*dstreg = 31; *dstreg > 0; (*dstreg)--)
+ if ((srcval >> *dstreg) & 1)
+ break;
+ }
+ else {
+ u16 srcval, *dstreg;
+
+ srcval = *DECODE_RM_WORD_REGISTER(rl);
+ DECODE_PRINTF(",");
+ dstreg = DECODE_RM_WORD_REGISTER(rh);
+ TRACE_AND_STEP();
+ CONDITIONAL_SET_FLAG(srcval == 0, F_ZF);
+ for (*dstreg = 15; *dstreg > 0; (*dstreg)--)
+ if ((srcval >> *dstreg) & 1)
+ break;
+ }
+ break;
}
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
@@ -2409,7 +2510,8 @@ static void x86emuOp2_bsr(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xbe
****************************************************************************/
-static void x86emuOp2_movsx_byte_R_RM(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_movsx_byte_R_RM(u8 X86EMU_UNUSED(op2))
{
int mod, rl, rh;
uint srcoffset;
@@ -2426,18 +2528,19 @@ static void x86emuOp2_movsx_byte_R_RM(u8 X86EMU_UNUSED(op2))
destreg = DECODE_RM_LONG_REGISTER(rh);
DECODE_PRINTF(",");
srcoffset = decode_rm00_address(rl);
- srcval = (s32)((s8)fetch_data_byte(srcoffset));
+ srcval = (s32) ((s8) fetch_data_byte(srcoffset));
DECODE_PRINTF("\n");
TRACE_AND_STEP();
*destreg = srcval;
- } else {
+ }
+ else {
u16 *destreg;
u16 srcval;
destreg = DECODE_RM_WORD_REGISTER(rh);
DECODE_PRINTF(",");
srcoffset = decode_rm00_address(rl);
- srcval = (s16)((s8)fetch_data_byte(srcoffset));
+ srcval = (s16) ((s8) fetch_data_byte(srcoffset));
DECODE_PRINTF("\n");
TRACE_AND_STEP();
*destreg = srcval;
@@ -2451,18 +2554,19 @@ static void x86emuOp2_movsx_byte_R_RM(u8 X86EMU_UNUSED(op2))
destreg = DECODE_RM_LONG_REGISTER(rh);
DECODE_PRINTF(",");
srcoffset = decode_rm01_address(rl);
- srcval = (s32)((s8)fetch_data_byte(srcoffset));
+ srcval = (s32) ((s8) fetch_data_byte(srcoffset));
DECODE_PRINTF("\n");
TRACE_AND_STEP();
*destreg = srcval;
- } else {
+ }
+ else {
u16 *destreg;
u16 srcval;
destreg = DECODE_RM_WORD_REGISTER(rh);
DECODE_PRINTF(",");
srcoffset = decode_rm01_address(rl);
- srcval = (s16)((s8)fetch_data_byte(srcoffset));
+ srcval = (s16) ((s8) fetch_data_byte(srcoffset));
DECODE_PRINTF("\n");
TRACE_AND_STEP();
*destreg = srcval;
@@ -2476,44 +2580,46 @@ static void x86emuOp2_movsx_byte_R_RM(u8 X86EMU_UNUSED(op2))
destreg = DECODE_RM_LONG_REGISTER(rh);
DECODE_PRINTF(",");
srcoffset = decode_rm10_address(rl);
- srcval = (s32)((s8)fetch_data_byte(srcoffset));
+ srcval = (s32) ((s8) fetch_data_byte(srcoffset));
DECODE_PRINTF("\n");
TRACE_AND_STEP();
*destreg = srcval;
- } else {
+ }
+ else {
u16 *destreg;
u16 srcval;
destreg = DECODE_RM_WORD_REGISTER(rh);
DECODE_PRINTF(",");
srcoffset = decode_rm10_address(rl);
- srcval = (s16)((s8)fetch_data_byte(srcoffset));
+ srcval = (s16) ((s8) fetch_data_byte(srcoffset));
DECODE_PRINTF("\n");
TRACE_AND_STEP();
*destreg = srcval;
}
break;
- case 3: /* register to register */
+ case 3: /* register to register */
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
u32 *destreg;
- u8 *srcreg;
+ u8 *srcreg;
destreg = DECODE_RM_LONG_REGISTER(rh);
DECODE_PRINTF(",");
srcreg = DECODE_RM_BYTE_REGISTER(rl);
DECODE_PRINTF("\n");
TRACE_AND_STEP();
- *destreg = (s32)((s8)*srcreg);
- } else {
+ *destreg = (s32) ((s8) * srcreg);
+ }
+ else {
u16 *destreg;
- u8 *srcreg;
+ u8 *srcreg;
destreg = DECODE_RM_WORD_REGISTER(rh);
DECODE_PRINTF(",");
srcreg = DECODE_RM_BYTE_REGISTER(rl);
DECODE_PRINTF("\n");
TRACE_AND_STEP();
- *destreg = (s16)((s8)*srcreg);
+ *destreg = (s16) ((s8) * srcreg);
}
break;
}
@@ -2525,7 +2631,8 @@ static void x86emuOp2_movsx_byte_R_RM(u8 X86EMU_UNUSED(op2))
REMARKS:
Handles opcode 0x0f,0xbf
****************************************************************************/
-static void x86emuOp2_movsx_word_R_RM(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_movsx_word_R_RM(u8 X86EMU_UNUSED(op2))
{
int mod, rl, rh;
uint srcoffset;
@@ -2541,7 +2648,7 @@ static void x86emuOp2_movsx_word_R_RM(u8 X86EMU_UNUSED(op2))
destreg = DECODE_RM_LONG_REGISTER(rh);
DECODE_PRINTF(",");
srcoffset = decode_rm00_address(rl);
- srcval = (s32)((s16)fetch_data_word(srcoffset));
+ srcval = (s32) ((s16) fetch_data_word(srcoffset));
DECODE_PRINTF("\n");
TRACE_AND_STEP();
*destreg = srcval;
@@ -2550,7 +2657,7 @@ static void x86emuOp2_movsx_word_R_RM(u8 X86EMU_UNUSED(op2))
destreg = DECODE_RM_LONG_REGISTER(rh);
DECODE_PRINTF(",");
srcoffset = decode_rm01_address(rl);
- srcval = (s32)((s16)fetch_data_word(srcoffset));
+ srcval = (s32) ((s16) fetch_data_word(srcoffset));
DECODE_PRINTF("\n");
TRACE_AND_STEP();
*destreg = srcval;
@@ -2559,18 +2666,18 @@ static void x86emuOp2_movsx_word_R_RM(u8 X86EMU_UNUSED(op2))
destreg = DECODE_RM_LONG_REGISTER(rh);
DECODE_PRINTF(",");
srcoffset = decode_rm10_address(rl);
- srcval = (s32)((s16)fetch_data_word(srcoffset));
+ srcval = (s32) ((s16) fetch_data_word(srcoffset));
DECODE_PRINTF("\n");
TRACE_AND_STEP();
*destreg = srcval;
break;
- case 3: /* register to register */
+ case 3: /* register to register */
destreg = DECODE_RM_LONG_REGISTER(rh);
DECODE_PRINTF(",");
srcreg = DECODE_RM_WORD_REGISTER(rl);
DECODE_PRINTF("\n");
TRACE_AND_STEP();
- *destreg = (s32)((s16)*srcreg);
+ *destreg = (s32) ((s16) * srcreg);
break;
}
DECODE_CLEAR_SEGOVR();
@@ -2578,40 +2685,41 @@ static void x86emuOp2_movsx_word_R_RM(u8 X86EMU_UNUSED(op2))
}
/* Handles opcodes 0xc8-0xcf */
-static void x86emuOp2_bswap(u8 X86EMU_UNUSED(op2))
+static void
+x86emuOp2_bswap(u8 X86EMU_UNUSED(op2))
{
START_OF_INSTR();
DECODE_PRINTF("BSWAP\n");
TRACE_AND_STEP();
switch (op2) {
- case 0xc8:
- M.x86.R_EAX = bswap_32(M.x86.R_EAX);
- break;
- case 0xc9:
- M.x86.R_ECX = bswap_32(M.x86.R_ECX);
- break;
- case 0xca:
- M.x86.R_EDX = bswap_32(M.x86.R_EDX);
- break;
- case 0xcb:
- M.x86.R_EBX = bswap_32(M.x86.R_EBX);
- break;
- case 0xcc:
- M.x86.R_ESP = bswap_32(M.x86.R_ESP);
- break;
- case 0xcd:
- M.x86.R_EBP = bswap_32(M.x86.R_EBP);
- break;
- case 0xce:
- M.x86.R_ESI = bswap_32(M.x86.R_ESI);
- break;
- case 0xcf:
- M.x86.R_EDI = bswap_32(M.x86.R_EDI);
- break;
- default:
- /* can't happen */
- break;
+ case 0xc8:
+ M.x86.R_EAX = bswap_32(M.x86.R_EAX);
+ break;
+ case 0xc9:
+ M.x86.R_ECX = bswap_32(M.x86.R_ECX);
+ break;
+ case 0xca:
+ M.x86.R_EDX = bswap_32(M.x86.R_EDX);
+ break;
+ case 0xcb:
+ M.x86.R_EBX = bswap_32(M.x86.R_EBX);
+ break;
+ case 0xcc:
+ M.x86.R_ESP = bswap_32(M.x86.R_ESP);
+ break;
+ case 0xcd:
+ M.x86.R_EBP = bswap_32(M.x86.R_EBP);
+ break;
+ case 0xce:
+ M.x86.R_ESI = bswap_32(M.x86.R_ESI);
+ break;
+ case 0xcf:
+ M.x86.R_EDI = bswap_32(M.x86.R_EDI);
+ break;
+ default:
+ /* can't happen */
+ break;
}
DECODE_CLEAR_SEGOVR();
@@ -2621,25 +2729,32 @@ static void x86emuOp2_bswap(u8 X86EMU_UNUSED(op2))
/***************************************************************************
* Double byte operation code table:
**************************************************************************/
-void (*x86emu_optab2[256])(u8) =
-{
-/* 0x00 */ x86emuOp2_illegal_op, /* Group F (ring 0 PM) */
-/* 0x01 */ x86emuOp2_illegal_op, /* Group G (ring 0 PM) */
-/* 0x02 */ x86emuOp2_illegal_op, /* lar (ring 0 PM) */
-/* 0x03 */ x86emuOp2_illegal_op, /* lsl (ring 0 PM) */
+void (*x86emu_optab2[256]) (u8) = {
+ /* 0x00 */ x86emuOp2_illegal_op,
+ /* Group F (ring 0 PM) */
+ /* 0x01 */ x86emuOp2_illegal_op,
+ /* Group G (ring 0 PM) */
+ /* 0x02 */ x86emuOp2_illegal_op,
+ /* lar (ring 0 PM) */
+ /* 0x03 */ x86emuOp2_illegal_op,
+ /* lsl (ring 0 PM) */
/* 0x04 */ x86emuOp2_illegal_op,
-/* 0x05 */ x86emuOp2_illegal_op, /* loadall (undocumented) */
-/* 0x06 */ x86emuOp2_illegal_op, /* clts (ring 0 PM) */
-/* 0x07 */ x86emuOp2_illegal_op, /* loadall (undocumented) */
-/* 0x08 */ x86emuOp2_illegal_op, /* invd (ring 0 PM) */
-/* 0x09 */ x86emuOp2_illegal_op, /* wbinvd (ring 0 PM) */
+ /* 0x05 */ x86emuOp2_illegal_op,
+ /* loadall (undocumented) */
+ /* 0x06 */ x86emuOp2_illegal_op,
+ /* clts (ring 0 PM) */
+ /* 0x07 */ x86emuOp2_illegal_op,
+ /* loadall (undocumented) */
+ /* 0x08 */ x86emuOp2_illegal_op,
+ /* invd (ring 0 PM) */
+ /* 0x09 */ x86emuOp2_illegal_op,
+ /* wbinvd (ring 0 PM) */
/* 0x0a */ x86emuOp2_illegal_op,
/* 0x0b */ x86emuOp2_illegal_op,
/* 0x0c */ x86emuOp2_illegal_op,
/* 0x0d */ x86emuOp2_illegal_op,
/* 0x0e */ x86emuOp2_illegal_op,
/* 0x0f */ x86emuOp2_illegal_op,
-
/* 0x10 */ x86emuOp2_illegal_op,
/* 0x11 */ x86emuOp2_illegal_op,
/* 0x12 */ x86emuOp2_illegal_op,
@@ -2656,14 +2771,19 @@ void (*x86emu_optab2[256])(u8) =
/* 0x1d */ x86emuOp2_illegal_op,
/* 0x1e */ x86emuOp2_illegal_op,
/* 0x1f */ x86emuOp2_illegal_op,
-
-/* 0x20 */ x86emuOp2_illegal_op, /* mov reg32,creg (ring 0 PM) */
-/* 0x21 */ x86emuOp2_illegal_op, /* mov reg32,dreg (ring 0 PM) */
-/* 0x22 */ x86emuOp2_illegal_op, /* mov creg,reg32 (ring 0 PM) */
-/* 0x23 */ x86emuOp2_illegal_op, /* mov dreg,reg32 (ring 0 PM) */
-/* 0x24 */ x86emuOp2_illegal_op, /* mov reg32,treg (ring 0 PM) */
+ /* 0x20 */ x86emuOp2_illegal_op,
+ /* mov reg32,creg (ring 0 PM) */
+ /* 0x21 */ x86emuOp2_illegal_op,
+ /* mov reg32,dreg (ring 0 PM) */
+ /* 0x22 */ x86emuOp2_illegal_op,
+ /* mov creg,reg32 (ring 0 PM) */
+ /* 0x23 */ x86emuOp2_illegal_op,
+ /* mov dreg,reg32 (ring 0 PM) */
+ /* 0x24 */ x86emuOp2_illegal_op,
+ /* mov reg32,treg (ring 0 PM) */
/* 0x25 */ x86emuOp2_illegal_op,
-/* 0x26 */ x86emuOp2_illegal_op, /* mov treg,reg32 (ring 0 PM) */
+ /* 0x26 */ x86emuOp2_illegal_op,
+ /* mov treg,reg32 (ring 0 PM) */
/* 0x27 */ x86emuOp2_illegal_op,
/* 0x28 */ x86emuOp2_illegal_op,
/* 0x29 */ x86emuOp2_illegal_op,
@@ -2673,7 +2793,6 @@ void (*x86emu_optab2[256])(u8) =
/* 0x2d */ x86emuOp2_illegal_op,
/* 0x2e */ x86emuOp2_illegal_op,
/* 0x2f */ x86emuOp2_illegal_op,
-
/* 0x30 */ x86emuOp2_illegal_op,
/* 0x31 */ x86emuOp2_rdtsc,
/* 0x32 */ x86emuOp2_illegal_op,
@@ -2690,7 +2809,6 @@ void (*x86emu_optab2[256])(u8) =
/* 0x3d */ x86emuOp2_illegal_op,
/* 0x3e */ x86emuOp2_illegal_op,
/* 0x3f */ x86emuOp2_illegal_op,
-
/* 0x40 */ x86emuOp2_illegal_op,
/* 0x41 */ x86emuOp2_illegal_op,
/* 0x42 */ x86emuOp2_illegal_op,
@@ -2707,7 +2825,6 @@ void (*x86emu_optab2[256])(u8) =
/* 0x4d */ x86emuOp2_illegal_op,
/* 0x4e */ x86emuOp2_illegal_op,
/* 0x4f */ x86emuOp2_illegal_op,
-
/* 0x50 */ x86emuOp2_illegal_op,
/* 0x51 */ x86emuOp2_illegal_op,
/* 0x52 */ x86emuOp2_illegal_op,
@@ -2724,7 +2841,6 @@ void (*x86emu_optab2[256])(u8) =
/* 0x5d */ x86emuOp2_illegal_op,
/* 0x5e */ x86emuOp2_illegal_op,
/* 0x5f */ x86emuOp2_illegal_op,
-
/* 0x60 */ x86emuOp2_illegal_op,
/* 0x61 */ x86emuOp2_illegal_op,
/* 0x62 */ x86emuOp2_illegal_op,
@@ -2741,7 +2857,6 @@ void (*x86emu_optab2[256])(u8) =
/* 0x6d */ x86emuOp2_illegal_op,
/* 0x6e */ x86emuOp2_illegal_op,
/* 0x6f */ x86emuOp2_illegal_op,
-
/* 0x70 */ x86emuOp2_illegal_op,
/* 0x71 */ x86emuOp2_illegal_op,
/* 0x72 */ x86emuOp2_illegal_op,
@@ -2758,7 +2873,6 @@ void (*x86emu_optab2[256])(u8) =
/* 0x7d */ x86emuOp2_illegal_op,
/* 0x7e */ x86emuOp2_illegal_op,
/* 0x7f */ x86emuOp2_illegal_op,
-
/* 0x80 */ x86emuOp2_long_jump,
/* 0x81 */ x86emuOp2_long_jump,
/* 0x82 */ x86emuOp2_long_jump,
@@ -2775,7 +2889,6 @@ void (*x86emu_optab2[256])(u8) =
/* 0x8d */ x86emuOp2_long_jump,
/* 0x8e */ x86emuOp2_long_jump,
/* 0x8f */ x86emuOp2_long_jump,
-
/* 0x90 */ x86emuOp2_set_byte,
/* 0x91 */ x86emuOp2_set_byte,
/* 0x92 */ x86emuOp2_set_byte,
@@ -2792,7 +2905,6 @@ void (*x86emu_optab2[256])(u8) =
/* 0x9d */ x86emuOp2_set_byte,
/* 0x9e */ x86emuOp2_set_byte,
/* 0x9f */ x86emuOp2_set_byte,
-
/* 0xa0 */ x86emuOp2_push_FS,
/* 0xa1 */ x86emuOp2_pop_FS,
/* 0xa2 */ x86emuOp2_cpuid,
@@ -2809,9 +2921,10 @@ void (*x86emu_optab2[256])(u8) =
/* 0xad */ x86emuOp2_shrd_CL,
/* 0xae */ x86emuOp2_illegal_op,
/* 0xaf */ x86emuOp2_imul_R_RM,
-
-/* 0xb0 */ x86emuOp2_illegal_op, /* TODO: cmpxchg */
-/* 0xb1 */ x86emuOp2_illegal_op, /* TODO: cmpxchg */
+ /* 0xb0 */ x86emuOp2_illegal_op,
+ /* TODO: cmpxchg */
+ /* 0xb1 */ x86emuOp2_illegal_op,
+ /* TODO: cmpxchg */
/* 0xb2 */ x86emuOp2_lss_R_IMM,
/* 0xb3 */ x86emuOp2_btr_R,
/* 0xb4 */ x86emuOp2_lfs_R_IMM,
@@ -2826,9 +2939,10 @@ void (*x86emu_optab2[256])(u8) =
/* 0xbd */ x86emuOp2_bsr,
/* 0xbe */ x86emuOp2_movsx_byte_R_RM,
/* 0xbf */ x86emuOp2_movsx_word_R_RM,
-
-/* 0xc0 */ x86emuOp2_illegal_op, /* TODO: xadd */
-/* 0xc1 */ x86emuOp2_illegal_op, /* TODO: xadd */
+ /* 0xc0 */ x86emuOp2_illegal_op,
+ /* TODO: xadd */
+ /* 0xc1 */ x86emuOp2_illegal_op,
+ /* TODO: xadd */
/* 0xc2 */ x86emuOp2_illegal_op,
/* 0xc3 */ x86emuOp2_illegal_op,
/* 0xc4 */ x86emuOp2_illegal_op,
@@ -2843,7 +2957,6 @@ void (*x86emu_optab2[256])(u8) =
/* 0xcd */ x86emuOp2_bswap,
/* 0xce */ x86emuOp2_bswap,
/* 0xcf */ x86emuOp2_bswap,
-
/* 0xd0 */ x86emuOp2_illegal_op,
/* 0xd1 */ x86emuOp2_illegal_op,
/* 0xd2 */ x86emuOp2_illegal_op,
@@ -2860,7 +2973,6 @@ void (*x86emu_optab2[256])(u8) =
/* 0xdd */ x86emuOp2_illegal_op,
/* 0xde */ x86emuOp2_illegal_op,
/* 0xdf */ x86emuOp2_illegal_op,
-
/* 0xe0 */ x86emuOp2_illegal_op,
/* 0xe1 */ x86emuOp2_illegal_op,
/* 0xe2 */ x86emuOp2_illegal_op,
@@ -2877,7 +2989,6 @@ void (*x86emu_optab2[256])(u8) =
/* 0xed */ x86emuOp2_illegal_op,
/* 0xee */ x86emuOp2_illegal_op,
/* 0xef */ x86emuOp2_illegal_op,
-
/* 0xf0 */ x86emuOp2_illegal_op,
/* 0xf1 */ x86emuOp2_illegal_op,
/* 0xf2 */ x86emuOp2_illegal_op,
diff --git a/xorg-server/hw/xfree86/x86emu/prim_ops.c b/xorg-server/hw/xfree86/x86emu/prim_ops.c
index 4a6ac5deb..24f76b47f 100644
--- a/xorg-server/hw/xfree86/x86emu/prim_ops.c
+++ b/xorg-server/hw/xfree86/x86emu/prim_ops.c
@@ -103,23 +103,22 @@
#include "x86emu/x86emui.h"
#if defined(__GNUC__)
-# if defined (__i386__) || defined(__i386) || defined(__AMD64__) || defined(__amd64__)
-# include "x86emu/prim_x86_gcc.h"
-# endif
+#if defined (__i386__) || defined(__i386) || defined(__AMD64__) || defined(__amd64__)
+#include "x86emu/prim_x86_gcc.h"
+#endif
#endif
/*------------------------- Global Variables ------------------------------*/
-static u32 x86emu_parity_tab[8] =
-{
- 0x96696996,
- 0x69969669,
- 0x69969669,
- 0x96696996,
- 0x69969669,
- 0x96696996,
- 0x96696996,
- 0x69969669,
+static u32 x86emu_parity_tab[8] = {
+ 0x96696996,
+ 0x69969669,
+ 0x69969669,
+ 0x96696996,
+ 0x69969669,
+ 0x96696996,
+ 0x96696996,
+ 0x69969669,
};
#define PARITY(x) (((x86emu_parity_tab[(x) / 32] >> ((x) % 32)) & 1) == 0)
@@ -131,88 +130,96 @@ static u32 x86emu_parity_tab[8] =
REMARKS:
Implements the AAA instruction and side effects.
****************************************************************************/
-u16 aaa_word(u16 d)
+u16
+aaa_word(u16 d)
{
- u16 res;
- if ((d & 0xf) > 0x9 || ACCESS_FLAG(F_AF)) {
- d += 0x6;
- d += 0x100;
- SET_FLAG(F_AF);
- SET_FLAG(F_CF);
- } else {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_AF);
- }
- res = (u16)(d & 0xFF0F);
- CLEAR_FLAG(F_SF);
- CONDITIONAL_SET_FLAG(res == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- return res;
+ u16 res;
+
+ if ((d & 0xf) > 0x9 || ACCESS_FLAG(F_AF)) {
+ d += 0x6;
+ d += 0x100;
+ SET_FLAG(F_AF);
+ SET_FLAG(F_CF);
+ }
+ else {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_AF);
+ }
+ res = (u16) (d & 0xFF0F);
+ CLEAR_FLAG(F_SF);
+ CONDITIONAL_SET_FLAG(res == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ return res;
}
/****************************************************************************
REMARKS:
Implements the AAA instruction and side effects.
****************************************************************************/
-u16 aas_word(u16 d)
+u16
+aas_word(u16 d)
{
- u16 res;
- if ((d & 0xf) > 0x9 || ACCESS_FLAG(F_AF)) {
- d -= 0x6;
- d -= 0x100;
- SET_FLAG(F_AF);
- SET_FLAG(F_CF);
- } else {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_AF);
- }
- res = (u16)(d & 0xFF0F);
- CLEAR_FLAG(F_SF);
- CONDITIONAL_SET_FLAG(res == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- return res;
+ u16 res;
+
+ if ((d & 0xf) > 0x9 || ACCESS_FLAG(F_AF)) {
+ d -= 0x6;
+ d -= 0x100;
+ SET_FLAG(F_AF);
+ SET_FLAG(F_CF);
+ }
+ else {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_AF);
+ }
+ res = (u16) (d & 0xFF0F);
+ CLEAR_FLAG(F_SF);
+ CONDITIONAL_SET_FLAG(res == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ return res;
}
/****************************************************************************
REMARKS:
Implements the AAD instruction and side effects.
****************************************************************************/
-u16 aad_word(u16 d)
+u16
+aad_word(u16 d)
{
- u16 l;
- u8 hb, lb;
+ u16 l;
+ u8 hb, lb;
- hb = (u8)((d >> 8) & 0xff);
- lb = (u8)((d & 0xff));
- l = (u16)((lb + 10 * hb) & 0xFF);
+ hb = (u8) ((d >> 8) & 0xff);
+ lb = (u8) ((d & 0xff));
+ l = (u16) ((lb + 10 * hb) & 0xFF);
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_AF);
- CLEAR_FLAG(F_OF);
- CONDITIONAL_SET_FLAG(l & 0x80, F_SF);
- CONDITIONAL_SET_FLAG(l == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(l & 0xff), F_PF);
- return l;
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_AF);
+ CLEAR_FLAG(F_OF);
+ CONDITIONAL_SET_FLAG(l & 0x80, F_SF);
+ CONDITIONAL_SET_FLAG(l == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(l & 0xff), F_PF);
+ return l;
}
/****************************************************************************
REMARKS:
Implements the AAM instruction and side effects.
****************************************************************************/
-u16 aam_word(u8 d)
+u16
+aam_word(u8 d)
{
u16 h, l;
- h = (u16)(d / 10);
- l = (u16)(d % 10);
- l |= (u16)(h << 8);
+ h = (u16) (d / 10);
+ l = (u16) (d % 10);
+ l |= (u16) (h << 8);
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_AF);
- CLEAR_FLAG(F_OF);
- CONDITIONAL_SET_FLAG(l & 0x80, F_SF);
- CONDITIONAL_SET_FLAG(l == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(l & 0xff), F_PF);
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_AF);
+ CLEAR_FLAG(F_OF);
+ CONDITIONAL_SET_FLAG(l & 0x80, F_SF);
+ CONDITIONAL_SET_FLAG(l == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(l & 0xff), F_PF);
return l;
}
@@ -220,155 +227,161 @@ u16 aam_word(u8 d)
REMARKS:
Implements the ADC instruction and side effects.
****************************************************************************/
-u8 adc_byte(u8 d, u8 s)
+u8
+adc_byte(u8 d, u8 s)
{
- register u32 res; /* all operands in native machine order */
- register u32 cc;
+ register u32 res; /* all operands in native machine order */
+ register u32 cc;
- if (ACCESS_FLAG(F_CF))
- res = 1 + d + s;
- else
- res = d + s;
+ if (ACCESS_FLAG(F_CF))
+ res = 1 + d + s;
+ else
+ res = d + s;
- CONDITIONAL_SET_FLAG(res & 0x100, F_CF);
- CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ CONDITIONAL_SET_FLAG(res & 0x100, F_CF);
+ CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- /* calculate the carry chain SEE NOTE AT TOP. */
- cc = (s & d) | ((~res) & (s | d));
- CONDITIONAL_SET_FLAG(XOR2(cc >> 6), F_OF);
- CONDITIONAL_SET_FLAG(cc & 0x8, F_AF);
- return (u8)res;
+ /* calculate the carry chain SEE NOTE AT TOP. */
+ cc = (s & d) | ((~res) & (s | d));
+ CONDITIONAL_SET_FLAG(XOR2(cc >> 6), F_OF);
+ CONDITIONAL_SET_FLAG(cc & 0x8, F_AF);
+ return (u8) res;
}
/****************************************************************************
REMARKS:
Implements the ADC instruction and side effects.
****************************************************************************/
-u16 adc_word(u16 d, u16 s)
+u16
+adc_word(u16 d, u16 s)
{
- register u32 res; /* all operands in native machine order */
- register u32 cc;
+ register u32 res; /* all operands in native machine order */
+ register u32 cc;
- if (ACCESS_FLAG(F_CF))
- res = 1 + d + s;
- else
- res = d + s;
+ if (ACCESS_FLAG(F_CF))
+ res = 1 + d + s;
+ else
+ res = d + s;
- CONDITIONAL_SET_FLAG(res & 0x10000, F_CF);
- CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ CONDITIONAL_SET_FLAG(res & 0x10000, F_CF);
+ CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- /* calculate the carry chain SEE NOTE AT TOP. */
- cc = (s & d) | ((~res) & (s | d));
- CONDITIONAL_SET_FLAG(XOR2(cc >> 14), F_OF);
- CONDITIONAL_SET_FLAG(cc & 0x8, F_AF);
- return (u16)res;
+ /* calculate the carry chain SEE NOTE AT TOP. */
+ cc = (s & d) | ((~res) & (s | d));
+ CONDITIONAL_SET_FLAG(XOR2(cc >> 14), F_OF);
+ CONDITIONAL_SET_FLAG(cc & 0x8, F_AF);
+ return (u16) res;
}
/****************************************************************************
REMARKS:
Implements the ADC instruction and side effects.
****************************************************************************/
-u32 adc_long(u32 d, u32 s)
+u32
+adc_long(u32 d, u32 s)
{
- register u32 lo; /* all operands in native machine order */
- register u32 hi;
- register u32 res;
- register u32 cc;
+ register u32 lo; /* all operands in native machine order */
+ register u32 hi;
+ register u32 res;
+ register u32 cc;
- if (ACCESS_FLAG(F_CF)) {
- lo = 1 + (d & 0xFFFF) + (s & 0xFFFF);
- res = 1 + d + s;
- }
- else {
- lo = (d & 0xFFFF) + (s & 0xFFFF);
- res = d + s;
- }
- hi = (lo >> 16) + (d >> 16) + (s >> 16);
+ if (ACCESS_FLAG(F_CF)) {
+ lo = 1 + (d & 0xFFFF) + (s & 0xFFFF);
+ res = 1 + d + s;
+ }
+ else {
+ lo = (d & 0xFFFF) + (s & 0xFFFF);
+ res = d + s;
+ }
+ hi = (lo >> 16) + (d >> 16) + (s >> 16);
- CONDITIONAL_SET_FLAG(hi & 0x10000, F_CF);
- CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ CONDITIONAL_SET_FLAG(hi & 0x10000, F_CF);
+ CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- /* calculate the carry chain SEE NOTE AT TOP. */
- cc = (s & d) | ((~res) & (s | d));
- CONDITIONAL_SET_FLAG(XOR2(cc >> 30), F_OF);
- CONDITIONAL_SET_FLAG(cc & 0x8, F_AF);
- return res;
+ /* calculate the carry chain SEE NOTE AT TOP. */
+ cc = (s & d) | ((~res) & (s | d));
+ CONDITIONAL_SET_FLAG(XOR2(cc >> 30), F_OF);
+ CONDITIONAL_SET_FLAG(cc & 0x8, F_AF);
+ return res;
}
/****************************************************************************
REMARKS:
Implements the ADD instruction and side effects.
****************************************************************************/
-u8 add_byte(u8 d, u8 s)
+u8
+add_byte(u8 d, u8 s)
{
- register u32 res; /* all operands in native machine order */
- register u32 cc;
+ register u32 res; /* all operands in native machine order */
+ register u32 cc;
- res = d + s;
- CONDITIONAL_SET_FLAG(res & 0x100, F_CF);
- CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ res = d + s;
+ CONDITIONAL_SET_FLAG(res & 0x100, F_CF);
+ CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- /* calculate the carry chain SEE NOTE AT TOP. */
- cc = (s & d) | ((~res) & (s | d));
- CONDITIONAL_SET_FLAG(XOR2(cc >> 6), F_OF);
- CONDITIONAL_SET_FLAG(cc & 0x8, F_AF);
- return (u8)res;
+ /* calculate the carry chain SEE NOTE AT TOP. */
+ cc = (s & d) | ((~res) & (s | d));
+ CONDITIONAL_SET_FLAG(XOR2(cc >> 6), F_OF);
+ CONDITIONAL_SET_FLAG(cc & 0x8, F_AF);
+ return (u8) res;
}
/****************************************************************************
REMARKS:
Implements the ADD instruction and side effects.
****************************************************************************/
-u16 add_word(u16 d, u16 s)
+u16
+add_word(u16 d, u16 s)
{
- register u32 res; /* all operands in native machine order */
- register u32 cc;
+ register u32 res; /* all operands in native machine order */
+ register u32 cc;
- res = d + s;
- CONDITIONAL_SET_FLAG(res & 0x10000, F_CF);
- CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ res = d + s;
+ CONDITIONAL_SET_FLAG(res & 0x10000, F_CF);
+ CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- /* calculate the carry chain SEE NOTE AT TOP. */
- cc = (s & d) | ((~res) & (s | d));
- CONDITIONAL_SET_FLAG(XOR2(cc >> 14), F_OF);
- CONDITIONAL_SET_FLAG(cc & 0x8, F_AF);
- return (u16)res;
+ /* calculate the carry chain SEE NOTE AT TOP. */
+ cc = (s & d) | ((~res) & (s | d));
+ CONDITIONAL_SET_FLAG(XOR2(cc >> 14), F_OF);
+ CONDITIONAL_SET_FLAG(cc & 0x8, F_AF);
+ return (u16) res;
}
/****************************************************************************
REMARKS:
Implements the ADD instruction and side effects.
****************************************************************************/
-u32 add_long(u32 d, u32 s)
+u32
+add_long(u32 d, u32 s)
{
- register u32 lo; /* all operands in native machine order */
- register u32 hi;
- register u32 res;
- register u32 cc;
+ register u32 lo; /* all operands in native machine order */
+ register u32 hi;
+ register u32 res;
+ register u32 cc;
- lo = (d & 0xFFFF) + (s & 0xFFFF);
- res = d + s;
- hi = (lo >> 16) + (d >> 16) + (s >> 16);
+ lo = (d & 0xFFFF) + (s & 0xFFFF);
+ res = d + s;
+ hi = (lo >> 16) + (d >> 16) + (s >> 16);
- CONDITIONAL_SET_FLAG(hi & 0x10000, F_CF);
- CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ CONDITIONAL_SET_FLAG(hi & 0x10000, F_CF);
+ CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
/* calculate the carry chain SEE NOTE AT TOP. */
cc = (s & d) | ((~res) & (s | d));
- CONDITIONAL_SET_FLAG(XOR2(cc >> 30), F_OF);
- CONDITIONAL_SET_FLAG(cc & 0x8, F_AF);
+ CONDITIONAL_SET_FLAG(XOR2(cc >> 30), F_OF);
+ CONDITIONAL_SET_FLAG(cc & 0x8, F_AF);
return res;
}
@@ -377,39 +390,41 @@ u32 add_long(u32 d, u32 s)
REMARKS:
Implements the AND instruction and side effects.
****************************************************************************/
-u8 and_byte(u8 d, u8 s)
+u8
+and_byte(u8 d, u8 s)
{
- register u8 res; /* all operands in native machine order */
+ register u8 res; /* all operands in native machine order */
- res = d & s;
+ res = d & s;
- /* set the flags */
- CLEAR_FLAG(F_OF);
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_AF);
- CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
- CONDITIONAL_SET_FLAG(res == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res), F_PF);
- return res;
+ /* set the flags */
+ CLEAR_FLAG(F_OF);
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_AF);
+ CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
+ CONDITIONAL_SET_FLAG(res == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res), F_PF);
+ return res;
}
/****************************************************************************
REMARKS:
Implements the AND instruction and side effects.
****************************************************************************/
-u16 and_word(u16 d, u16 s)
+u16
+and_word(u16 d, u16 s)
{
- register u16 res; /* all operands in native machine order */
+ register u16 res; /* all operands in native machine order */
res = d & s;
/* set the flags */
- CLEAR_FLAG(F_OF);
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_AF);
- CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
- CONDITIONAL_SET_FLAG(res == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ CLEAR_FLAG(F_OF);
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_AF);
+ CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
+ CONDITIONAL_SET_FLAG(res == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
return res;
}
@@ -417,433 +432,456 @@ u16 and_word(u16 d, u16 s)
REMARKS:
Implements the AND instruction and side effects.
****************************************************************************/
-u32 and_long(u32 d, u32 s)
+u32
+and_long(u32 d, u32 s)
{
- register u32 res; /* all operands in native machine order */
+ register u32 res; /* all operands in native machine order */
- res = d & s;
+ res = d & s;
- /* set the flags */
- CLEAR_FLAG(F_OF);
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_AF);
- CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
- CONDITIONAL_SET_FLAG(res == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- return res;
+ /* set the flags */
+ CLEAR_FLAG(F_OF);
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_AF);
+ CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
+ CONDITIONAL_SET_FLAG(res == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ return res;
}
/****************************************************************************
REMARKS:
Implements the CMP instruction and side effects.
****************************************************************************/
-u8 cmp_byte(u8 d, u8 s)
+u8
+cmp_byte(u8 d, u8 s)
{
- register u32 res; /* all operands in native machine order */
- register u32 bc;
+ register u32 res; /* all operands in native machine order */
+ register u32 bc;
- res = d - s;
- CLEAR_FLAG(F_CF);
- CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
- CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ res = d - s;
+ CLEAR_FLAG(F_CF);
+ CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
+ CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- /* calculate the borrow chain. See note at top */
- bc = (res & (~d | s)) | (~d & s);
- CONDITIONAL_SET_FLAG(bc & 0x80, F_CF);
- CONDITIONAL_SET_FLAG(XOR2(bc >> 6), F_OF);
- CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
- return d;
+ /* calculate the borrow chain. See note at top */
+ bc = (res & (~d | s)) | (~d & s);
+ CONDITIONAL_SET_FLAG(bc & 0x80, F_CF);
+ CONDITIONAL_SET_FLAG(XOR2(bc >> 6), F_OF);
+ CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
+ return d;
}
/****************************************************************************
REMARKS:
Implements the CMP instruction and side effects.
****************************************************************************/
-u16 cmp_word(u16 d, u16 s)
+u16
+cmp_word(u16 d, u16 s)
{
- register u32 res; /* all operands in native machine order */
- register u32 bc;
+ register u32 res; /* all operands in native machine order */
+ register u32 bc;
- res = d - s;
- CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
- CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ res = d - s;
+ CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
+ CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- /* calculate the borrow chain. See note at top */
+ /* calculate the borrow chain. See note at top */
bc = (res & (~d | s)) | (~d & s);
- CONDITIONAL_SET_FLAG(bc & 0x8000, F_CF);
- CONDITIONAL_SET_FLAG(XOR2(bc >> 14), F_OF);
- CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
- return d;
+ CONDITIONAL_SET_FLAG(bc & 0x8000, F_CF);
+ CONDITIONAL_SET_FLAG(XOR2(bc >> 14), F_OF);
+ CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
+ return d;
}
/****************************************************************************
REMARKS:
Implements the CMP instruction and side effects.
****************************************************************************/
-u32 cmp_long(u32 d, u32 s)
+u32
+cmp_long(u32 d, u32 s)
{
- register u32 res; /* all operands in native machine order */
- register u32 bc;
+ register u32 res; /* all operands in native machine order */
+ register u32 bc;
- res = d - s;
- CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
- CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ res = d - s;
+ CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
+ CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- /* calculate the borrow chain. See note at top */
- bc = (res & (~d | s)) | (~d & s);
- CONDITIONAL_SET_FLAG(bc & 0x80000000, F_CF);
- CONDITIONAL_SET_FLAG(XOR2(bc >> 30), F_OF);
- CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
- return d;
+ /* calculate the borrow chain. See note at top */
+ bc = (res & (~d | s)) | (~d & s);
+ CONDITIONAL_SET_FLAG(bc & 0x80000000, F_CF);
+ CONDITIONAL_SET_FLAG(XOR2(bc >> 30), F_OF);
+ CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
+ return d;
}
/****************************************************************************
REMARKS:
Implements the DAA instruction and side effects.
****************************************************************************/
-u8 daa_byte(u8 d)
+u8
+daa_byte(u8 d)
{
- u32 res = d;
- if ((d & 0xf) > 9 || ACCESS_FLAG(F_AF)) {
- res += 6;
- SET_FLAG(F_AF);
- }
- if (res > 0x9F || ACCESS_FLAG(F_CF)) {
- res += 0x60;
- SET_FLAG(F_CF);
- }
- CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
- CONDITIONAL_SET_FLAG((res & 0xFF) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- return (u8)res;
+ u32 res = d;
+
+ if ((d & 0xf) > 9 || ACCESS_FLAG(F_AF)) {
+ res += 6;
+ SET_FLAG(F_AF);
+ }
+ if (res > 0x9F || ACCESS_FLAG(F_CF)) {
+ res += 0x60;
+ SET_FLAG(F_CF);
+ }
+ CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
+ CONDITIONAL_SET_FLAG((res & 0xFF) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ return (u8) res;
}
/****************************************************************************
REMARKS:
Implements the DAS instruction and side effects.
****************************************************************************/
-u8 das_byte(u8 d)
+u8
+das_byte(u8 d)
{
- if ((d & 0xf) > 9 || ACCESS_FLAG(F_AF)) {
- d -= 6;
- SET_FLAG(F_AF);
- }
- if (d > 0x9F || ACCESS_FLAG(F_CF)) {
- d -= 0x60;
- SET_FLAG(F_CF);
- }
- CONDITIONAL_SET_FLAG(d & 0x80, F_SF);
- CONDITIONAL_SET_FLAG(d == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(d & 0xff), F_PF);
- return d;
+ if ((d & 0xf) > 9 || ACCESS_FLAG(F_AF)) {
+ d -= 6;
+ SET_FLAG(F_AF);
+ }
+ if (d > 0x9F || ACCESS_FLAG(F_CF)) {
+ d -= 0x60;
+ SET_FLAG(F_CF);
+ }
+ CONDITIONAL_SET_FLAG(d & 0x80, F_SF);
+ CONDITIONAL_SET_FLAG(d == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(d & 0xff), F_PF);
+ return d;
}
/****************************************************************************
REMARKS:
Implements the DEC instruction and side effects.
****************************************************************************/
-u8 dec_byte(u8 d)
+u8
+dec_byte(u8 d)
{
- register u32 res; /* all operands in native machine order */
+ register u32 res; /* all operands in native machine order */
register u32 bc;
res = d - 1;
- CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
- CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
+ CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- /* calculate the borrow chain. See note at top */
- /* based on sub_byte, uses s==1. */
- bc = (res & (~d | 1)) | (~d & 1);
- /* carry flag unchanged */
- CONDITIONAL_SET_FLAG(XOR2(bc >> 6), F_OF);
- CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
- return (u8)res;
+ /* calculate the borrow chain. See note at top */
+ /* based on sub_byte, uses s==1. */
+ bc = (res & (~d | 1)) | (~d & 1);
+ /* carry flag unchanged */
+ CONDITIONAL_SET_FLAG(XOR2(bc >> 6), F_OF);
+ CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
+ return (u8) res;
}
/****************************************************************************
REMARKS:
Implements the DEC instruction and side effects.
****************************************************************************/
-u16 dec_word(u16 d)
+u16
+dec_word(u16 d)
{
- register u32 res; /* all operands in native machine order */
+ register u32 res; /* all operands in native machine order */
register u32 bc;
res = d - 1;
- CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
- CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
+ CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
/* calculate the borrow chain. See note at top */
/* based on the sub_byte routine, with s==1 */
bc = (res & (~d | 1)) | (~d & 1);
/* carry flag unchanged */
- CONDITIONAL_SET_FLAG(XOR2(bc >> 14), F_OF);
- CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
- return (u16)res;
+ CONDITIONAL_SET_FLAG(XOR2(bc >> 14), F_OF);
+ CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
+ return (u16) res;
}
/****************************************************************************
REMARKS:
Implements the DEC instruction and side effects.
****************************************************************************/
-u32 dec_long(u32 d)
+u32
+dec_long(u32 d)
{
- register u32 res; /* all operands in native machine order */
+ register u32 res; /* all operands in native machine order */
register u32 bc;
res = d - 1;
- CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
- CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
+ CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
/* calculate the borrow chain. See note at top */
- bc = (res & (~d | 1)) | (~d & 1);
- /* carry flag unchanged */
- CONDITIONAL_SET_FLAG(XOR2(bc >> 30), F_OF);
- CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
- return res;
+ bc = (res & (~d | 1)) | (~d & 1);
+ /* carry flag unchanged */
+ CONDITIONAL_SET_FLAG(XOR2(bc >> 30), F_OF);
+ CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
+ return res;
}
/****************************************************************************
REMARKS:
Implements the INC instruction and side effects.
****************************************************************************/
-u8 inc_byte(u8 d)
+u8
+inc_byte(u8 d)
{
- register u32 res; /* all operands in native machine order */
- register u32 cc;
+ register u32 res; /* all operands in native machine order */
+ register u32 cc;
- res = d + 1;
- CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ res = d + 1;
+ CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- /* calculate the carry chain SEE NOTE AT TOP. */
- cc = ((1 & d) | (~res)) & (1 | d);
- CONDITIONAL_SET_FLAG(XOR2(cc >> 6), F_OF);
- CONDITIONAL_SET_FLAG(cc & 0x8, F_AF);
- return (u8)res;
+ /* calculate the carry chain SEE NOTE AT TOP. */
+ cc = ((1 & d) | (~res)) & (1 | d);
+ CONDITIONAL_SET_FLAG(XOR2(cc >> 6), F_OF);
+ CONDITIONAL_SET_FLAG(cc & 0x8, F_AF);
+ return (u8) res;
}
/****************************************************************************
REMARKS:
Implements the INC instruction and side effects.
****************************************************************************/
-u16 inc_word(u16 d)
+u16
+inc_word(u16 d)
{
- register u32 res; /* all operands in native machine order */
- register u32 cc;
+ register u32 res; /* all operands in native machine order */
+ register u32 cc;
- res = d + 1;
- CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ res = d + 1;
+ CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- /* calculate the carry chain SEE NOTE AT TOP. */
- cc = (1 & d) | ((~res) & (1 | d));
- CONDITIONAL_SET_FLAG(XOR2(cc >> 14), F_OF);
- CONDITIONAL_SET_FLAG(cc & 0x8, F_AF);
- return (u16)res;
+ /* calculate the carry chain SEE NOTE AT TOP. */
+ cc = (1 & d) | ((~res) & (1 | d));
+ CONDITIONAL_SET_FLAG(XOR2(cc >> 14), F_OF);
+ CONDITIONAL_SET_FLAG(cc & 0x8, F_AF);
+ return (u16) res;
}
/****************************************************************************
REMARKS:
Implements the INC instruction and side effects.
****************************************************************************/
-u32 inc_long(u32 d)
+u32
+inc_long(u32 d)
{
- register u32 res; /* all operands in native machine order */
- register u32 cc;
+ register u32 res; /* all operands in native machine order */
+ register u32 cc;
- res = d + 1;
- CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ res = d + 1;
+ CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- /* calculate the carry chain SEE NOTE AT TOP. */
- cc = (1 & d) | ((~res) & (1 | d));
- CONDITIONAL_SET_FLAG(XOR2(cc >> 30), F_OF);
- CONDITIONAL_SET_FLAG(cc & 0x8, F_AF);
- return res;
+ /* calculate the carry chain SEE NOTE AT TOP. */
+ cc = (1 & d) | ((~res) & (1 | d));
+ CONDITIONAL_SET_FLAG(XOR2(cc >> 30), F_OF);
+ CONDITIONAL_SET_FLAG(cc & 0x8, F_AF);
+ return res;
}
/****************************************************************************
REMARKS:
Implements the OR instruction and side effects.
****************************************************************************/
-u8 or_byte(u8 d, u8 s)
+u8
+or_byte(u8 d, u8 s)
{
- register u8 res; /* all operands in native machine order */
+ register u8 res; /* all operands in native machine order */
- res = d | s;
- CLEAR_FLAG(F_OF);
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_AF);
- CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
- CONDITIONAL_SET_FLAG(res == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res), F_PF);
- return res;
+ res = d | s;
+ CLEAR_FLAG(F_OF);
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_AF);
+ CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
+ CONDITIONAL_SET_FLAG(res == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res), F_PF);
+ return res;
}
/****************************************************************************
REMARKS:
Implements the OR instruction and side effects.
****************************************************************************/
-u16 or_word(u16 d, u16 s)
+u16
+or_word(u16 d, u16 s)
{
- register u16 res; /* all operands in native machine order */
+ register u16 res; /* all operands in native machine order */
- res = d | s;
- /* set the carry flag to be bit 8 */
- CLEAR_FLAG(F_OF);
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_AF);
- CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
- CONDITIONAL_SET_FLAG(res == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- return res;
+ res = d | s;
+ /* set the carry flag to be bit 8 */
+ CLEAR_FLAG(F_OF);
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_AF);
+ CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
+ CONDITIONAL_SET_FLAG(res == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ return res;
}
/****************************************************************************
REMARKS:
Implements the OR instruction and side effects.
****************************************************************************/
-u32 or_long(u32 d, u32 s)
+u32
+or_long(u32 d, u32 s)
{
- register u32 res; /* all operands in native machine order */
+ register u32 res; /* all operands in native machine order */
- res = d | s;
+ res = d | s;
- /* set the carry flag to be bit 8 */
- CLEAR_FLAG(F_OF);
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_AF);
- CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
- CONDITIONAL_SET_FLAG(res == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- return res;
+ /* set the carry flag to be bit 8 */
+ CLEAR_FLAG(F_OF);
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_AF);
+ CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
+ CONDITIONAL_SET_FLAG(res == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ return res;
}
/****************************************************************************
REMARKS:
Implements the OR instruction and side effects.
****************************************************************************/
-u8 neg_byte(u8 s)
+u8
+neg_byte(u8 s)
{
register u8 res;
register u8 bc;
- CONDITIONAL_SET_FLAG(s != 0, F_CF);
- res = (u8)-s;
- CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res), F_PF);
- /* calculate the borrow chain --- modified such that d=0.
- substitutiing d=0 into bc= res&(~d|s)|(~d&s);
- (the one used for sub) and simplifying, since ~d=0xff...,
- ~d|s == 0xffff..., and res&0xfff... == res. Similarly
- ~d&s == s. So the simplified result is: */
- bc = res | s;
- CONDITIONAL_SET_FLAG(XOR2(bc >> 6), F_OF);
- CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
- return res;
+ CONDITIONAL_SET_FLAG(s != 0, F_CF);
+ res = (u8) - s;
+ CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res), F_PF);
+ /* calculate the borrow chain --- modified such that d=0.
+ substitutiing d=0 into bc= res&(~d|s)|(~d&s);
+ (the one used for sub) and simplifying, since ~d=0xff...,
+ ~d|s == 0xffff..., and res&0xfff... == res. Similarly
+ ~d&s == s. So the simplified result is: */
+ bc = res | s;
+ CONDITIONAL_SET_FLAG(XOR2(bc >> 6), F_OF);
+ CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
+ return res;
}
/****************************************************************************
REMARKS:
Implements the OR instruction and side effects.
****************************************************************************/
-u16 neg_word(u16 s)
-{
- register u16 res;
- register u16 bc;
-
- CONDITIONAL_SET_FLAG(s != 0, F_CF);
- res = (u16)-s;
- CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
-
- /* calculate the borrow chain --- modified such that d=0.
- substitutiing d=0 into bc= res&(~d|s)|(~d&s);
- (the one used for sub) and simplifying, since ~d=0xff...,
- ~d|s == 0xffff..., and res&0xfff... == res. Similarly
- ~d&s == s. So the simplified result is: */
- bc = res | s;
- CONDITIONAL_SET_FLAG(XOR2(bc >> 14), F_OF);
- CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
- return res;
+u16
+neg_word(u16 s)
+{
+ register u16 res;
+ register u16 bc;
+
+ CONDITIONAL_SET_FLAG(s != 0, F_CF);
+ res = (u16) - s;
+ CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+
+ /* calculate the borrow chain --- modified such that d=0.
+ substitutiing d=0 into bc= res&(~d|s)|(~d&s);
+ (the one used for sub) and simplifying, since ~d=0xff...,
+ ~d|s == 0xffff..., and res&0xfff... == res. Similarly
+ ~d&s == s. So the simplified result is: */
+ bc = res | s;
+ CONDITIONAL_SET_FLAG(XOR2(bc >> 14), F_OF);
+ CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
+ return res;
}
/****************************************************************************
REMARKS:
Implements the OR instruction and side effects.
****************************************************************************/
-u32 neg_long(u32 s)
+u32
+neg_long(u32 s)
{
- register u32 res;
- register u32 bc;
-
- CONDITIONAL_SET_FLAG(s != 0, F_CF);
- res = (u32)-s;
- CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ register u32 res;
+ register u32 bc;
- /* calculate the borrow chain --- modified such that d=0.
- substitutiing d=0 into bc= res&(~d|s)|(~d&s);
- (the one used for sub) and simplifying, since ~d=0xff...,
- ~d|s == 0xffff..., and res&0xfff... == res. Similarly
- ~d&s == s. So the simplified result is: */
- bc = res | s;
- CONDITIONAL_SET_FLAG(XOR2(bc >> 30), F_OF);
- CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
- return res;
+ CONDITIONAL_SET_FLAG(s != 0, F_CF);
+ res = (u32) - s;
+ CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+
+ /* calculate the borrow chain --- modified such that d=0.
+ substitutiing d=0 into bc= res&(~d|s)|(~d&s);
+ (the one used for sub) and simplifying, since ~d=0xff...,
+ ~d|s == 0xffff..., and res&0xfff... == res. Similarly
+ ~d&s == s. So the simplified result is: */
+ bc = res | s;
+ CONDITIONAL_SET_FLAG(XOR2(bc >> 30), F_OF);
+ CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
+ return res;
}
/****************************************************************************
REMARKS:
Implements the NOT instruction and side effects.
****************************************************************************/
-u8 not_byte(u8 s)
+u8
+not_byte(u8 s)
{
- return ~s;
+ return ~s;
}
/****************************************************************************
REMARKS:
Implements the NOT instruction and side effects.
****************************************************************************/
-u16 not_word(u16 s)
+u16
+not_word(u16 s)
{
- return ~s;
+ return ~s;
}
/****************************************************************************
REMARKS:
Implements the NOT instruction and side effects.
****************************************************************************/
-u32 not_long(u32 s)
+u32
+not_long(u32 s)
{
- return ~s;
+ return ~s;
}
/****************************************************************************
REMARKS:
Implements the RCL instruction and side effects.
****************************************************************************/
-u8 rcl_byte(u8 d, u8 s)
+u8
+rcl_byte(u8 d, u8 s)
{
register unsigned int res, cnt, mask, cf;
/* s is the rotate distance. It varies from 0 - 8. */
- /* have
+ /* have
CF B_7 B_6 B_5 B_4 B_3 B_2 B_1 B_0
@@ -867,9 +905,9 @@ u8 rcl_byte(u8 d, u8 s)
2) B_(7) .. B_(n) <- b_(8-(n+1)) .. b_0
3) B_(n-1) <- cf
4) B_(n-2) .. B_0 <- b_7 .. b_(8-(n-1))
- */
- res = d;
- if ((cnt = s % 9) != 0) {
+ */
+ res = d;
+ if ((cnt = s % 9) != 0) {
/* extract the new CARRY FLAG. */
/* CF <- b_(8-n) */
cf = (d >> (8 - cnt)) & 0x1;
@@ -878,7 +916,7 @@ u8 rcl_byte(u8 d, u8 s)
into the range B_7 .. B_cnt */
/* B_(7) .. B_(n) <- b_(8-(n+1)) .. b_0 */
/* note that the right hand side done by the mask */
- res = (d << cnt) & 0xff;
+ res = (d << cnt) & 0xff;
/* now the high stuff which rotated around
into the positions B_cnt-2 .. B_0 */
@@ -890,81 +928,81 @@ u8 rcl_byte(u8 d, u8 s)
res |= (d >> (9 - cnt)) & mask;
/* if the carry flag was set, or it in. */
- if (ACCESS_FLAG(F_CF)) { /* carry flag is set */
+ if (ACCESS_FLAG(F_CF)) { /* carry flag is set */
/* B_(n-1) <- cf */
res |= 1 << (cnt - 1);
}
/* set the new carry flag, based on the variable "cf" */
- CONDITIONAL_SET_FLAG(cf, F_CF);
+ CONDITIONAL_SET_FLAG(cf, F_CF);
/* OVERFLOW is set *IFF* cnt==1, then it is the
xor of CF and the most significant bit. Blecck. */
/* parenthesized this expression since it appears to
be causing OF to be misset */
- CONDITIONAL_SET_FLAG(cnt == 1 && XOR2(cf + ((res >> 6) & 0x2)),
- F_OF);
+ CONDITIONAL_SET_FLAG(cnt == 1 && XOR2(cf + ((res >> 6) & 0x2)), F_OF);
}
- return (u8)res;
+ return (u8) res;
}
/****************************************************************************
REMARKS:
Implements the RCL instruction and side effects.
****************************************************************************/
-u16 rcl_word(u16 d, u8 s)
+u16
+rcl_word(u16 d, u8 s)
{
- register unsigned int res, cnt, mask, cf;
+ register unsigned int res, cnt, mask, cf;
- res = d;
- if ((cnt = s % 17) != 0) {
- cf = (d >> (16 - cnt)) & 0x1;
- res = (d << cnt) & 0xffff;
- mask = (1 << (cnt - 1)) - 1;
- res |= (d >> (17 - cnt)) & mask;
- if (ACCESS_FLAG(F_CF)) {
- res |= 1 << (cnt - 1);
- }
- CONDITIONAL_SET_FLAG(cf, F_CF);
- CONDITIONAL_SET_FLAG(cnt == 1 && XOR2(cf + ((res >> 14) & 0x2)),
- F_OF);
- }
- return (u16)res;
+ res = d;
+ if ((cnt = s % 17) != 0) {
+ cf = (d >> (16 - cnt)) & 0x1;
+ res = (d << cnt) & 0xffff;
+ mask = (1 << (cnt - 1)) - 1;
+ res |= (d >> (17 - cnt)) & mask;
+ if (ACCESS_FLAG(F_CF)) {
+ res |= 1 << (cnt - 1);
+ }
+ CONDITIONAL_SET_FLAG(cf, F_CF);
+ CONDITIONAL_SET_FLAG(cnt == 1 && XOR2(cf + ((res >> 14) & 0x2)), F_OF);
+ }
+ return (u16) res;
}
/****************************************************************************
REMARKS:
Implements the RCL instruction and side effects.
****************************************************************************/
-u32 rcl_long(u32 d, u8 s)
+u32
+rcl_long(u32 d, u8 s)
{
- register u32 res, cnt, mask, cf;
+ register u32 res, cnt, mask, cf;
- res = d;
- if ((cnt = s % 33) != 0) {
- cf = (d >> (32 - cnt)) & 0x1;
- res = (d << cnt) & 0xffffffff;
- mask = (1 << (cnt - 1)) - 1;
- res |= (d >> (33 - cnt)) & mask;
- if (ACCESS_FLAG(F_CF)) { /* carry flag is set */
- res |= 1 << (cnt - 1);
- }
- CONDITIONAL_SET_FLAG(cf, F_CF);
- CONDITIONAL_SET_FLAG(cnt == 1 && XOR2(cf + ((res >> 30) & 0x2)),
- F_OF);
- }
- return res;
+ res = d;
+ if ((cnt = s % 33) != 0) {
+ cf = (d >> (32 - cnt)) & 0x1;
+ res = (d << cnt) & 0xffffffff;
+ mask = (1 << (cnt - 1)) - 1;
+ res |= (d >> (33 - cnt)) & mask;
+ if (ACCESS_FLAG(F_CF)) { /* carry flag is set */
+ res |= 1 << (cnt - 1);
+ }
+ CONDITIONAL_SET_FLAG(cf, F_CF);
+ CONDITIONAL_SET_FLAG(cnt == 1 && XOR2(cf + ((res >> 30) & 0x2)), F_OF);
+ }
+ return res;
}
/****************************************************************************
REMARKS:
Implements the RCR instruction and side effects.
****************************************************************************/
-u8 rcr_byte(u8 d, u8 s)
+u8
+rcr_byte(u8 d, u8 s)
{
- u32 res, cnt;
- u32 mask, cf, ocf = 0;
+ u32 res, cnt;
+ u32 mask, cf, ocf = 0;
- /* rotate right through carry */
+ /* rotate right through carry */
/*
s is the rotate distance. It varies from 0 - 8.
d is the byte object rotated.
@@ -985,9 +1023,9 @@ u8 rcr_byte(u8 d, u8 s)
2) B_(8-(n+1)) .. B_(0) <- b_(7) .. b_(n)
3) B_(8-n) <- cf
4) B_(7) .. B_(8-(n-1)) <- b_(n-2) .. b_(0)
- */
- res = d;
- if ((cnt = s % 9) != 0) {
+ */
+ res = d;
+ if ((cnt = s % 9) != 0) {
/* extract the new CARRY FLAG. */
/* CF <- b_(n-1) */
if (cnt == 1) {
@@ -996,11 +1034,12 @@ u8 rcr_byte(u8 d, u8 s)
0 if flag not set
non-zero if flag is set.
doing access_flag(..) != 0 casts that into either
- 0..1 in any representation of the flags register
+ 0..1 in any representation of the flags register
(i.e. packed bit array or unpacked.)
*/
- ocf = ACCESS_FLAG(F_CF) != 0;
- } else
+ ocf = ACCESS_FLAG(F_CF) != 0;
+ }
+ else
cf = (d >> (cnt - 1)) & 0x1;
/* B_(8-(n+1)) .. B_(0) <- b_(7) .. b_n */
@@ -1022,93 +1061,95 @@ u8 rcr_byte(u8 d, u8 s)
res |= (d << (9 - cnt));
/* if the carry flag was set, or it in. */
- if (ACCESS_FLAG(F_CF)) { /* carry flag is set */
+ if (ACCESS_FLAG(F_CF)) { /* carry flag is set */
/* B_(8-n) <- cf */
res |= 1 << (8 - cnt);
}
/* set the new carry flag, based on the variable "cf" */
- CONDITIONAL_SET_FLAG(cf, F_CF);
+ CONDITIONAL_SET_FLAG(cf, F_CF);
/* OVERFLOW is set *IFF* cnt==1, then it is the
xor of CF and the most significant bit. Blecck. */
/* parenthesized... */
- if (cnt == 1) {
- CONDITIONAL_SET_FLAG(XOR2(ocf + ((d >> 6) & 0x2)),
- F_OF);
- }
- }
- return (u8)res;
+ if (cnt == 1) {
+ CONDITIONAL_SET_FLAG(XOR2(ocf + ((d >> 6) & 0x2)), F_OF);
+ }
+ }
+ return (u8) res;
}
/****************************************************************************
REMARKS:
Implements the RCR instruction and side effects.
****************************************************************************/
-u16 rcr_word(u16 d, u8 s)
+u16
+rcr_word(u16 d, u8 s)
{
- u32 res, cnt;
- u32 mask, cf, ocf = 0;
+ u32 res, cnt;
+ u32 mask, cf, ocf = 0;
- /* rotate right through carry */
- res = d;
- if ((cnt = s % 17) != 0) {
- if (cnt == 1) {
- cf = d & 0x1;
- ocf = ACCESS_FLAG(F_CF) != 0;
- } else
- cf = (d >> (cnt - 1)) & 0x1;
- mask = (1 << (16 - cnt)) - 1;
- res = (d >> cnt) & mask;
- res |= (d << (17 - cnt));
- if (ACCESS_FLAG(F_CF)) {
- res |= 1 << (16 - cnt);
- }
- CONDITIONAL_SET_FLAG(cf, F_CF);
- if (cnt == 1) {
- CONDITIONAL_SET_FLAG(XOR2(ocf + ((d >> 14) & 0x2)),
- F_OF);
- }
- }
- return (u16)res;
+ /* rotate right through carry */
+ res = d;
+ if ((cnt = s % 17) != 0) {
+ if (cnt == 1) {
+ cf = d & 0x1;
+ ocf = ACCESS_FLAG(F_CF) != 0;
+ }
+ else
+ cf = (d >> (cnt - 1)) & 0x1;
+ mask = (1 << (16 - cnt)) - 1;
+ res = (d >> cnt) & mask;
+ res |= (d << (17 - cnt));
+ if (ACCESS_FLAG(F_CF)) {
+ res |= 1 << (16 - cnt);
+ }
+ CONDITIONAL_SET_FLAG(cf, F_CF);
+ if (cnt == 1) {
+ CONDITIONAL_SET_FLAG(XOR2(ocf + ((d >> 14) & 0x2)), F_OF);
+ }
+ }
+ return (u16) res;
}
/****************************************************************************
REMARKS:
Implements the RCR instruction and side effects.
****************************************************************************/
-u32 rcr_long(u32 d, u8 s)
-{
- u32 res, cnt;
- u32 mask, cf, ocf = 0;
-
- /* rotate right through carry */
- res = d;
- if ((cnt = s % 33) != 0) {
- if (cnt == 1) {
- cf = d & 0x1;
- ocf = ACCESS_FLAG(F_CF) != 0;
- } else
- cf = (d >> (cnt - 1)) & 0x1;
- mask = (1 << (32 - cnt)) - 1;
- res = (d >> cnt) & mask;
- if (cnt != 1)
- res |= (d << (33 - cnt));
- if (ACCESS_FLAG(F_CF)) { /* carry flag is set */
- res |= 1 << (32 - cnt);
- }
- CONDITIONAL_SET_FLAG(cf, F_CF);
- if (cnt == 1) {
- CONDITIONAL_SET_FLAG(XOR2(ocf + ((d >> 30) & 0x2)),
- F_OF);
- }
- }
- return res;
+u32
+rcr_long(u32 d, u8 s)
+{
+ u32 res, cnt;
+ u32 mask, cf, ocf = 0;
+
+ /* rotate right through carry */
+ res = d;
+ if ((cnt = s % 33) != 0) {
+ if (cnt == 1) {
+ cf = d & 0x1;
+ ocf = ACCESS_FLAG(F_CF) != 0;
+ }
+ else
+ cf = (d >> (cnt - 1)) & 0x1;
+ mask = (1 << (32 - cnt)) - 1;
+ res = (d >> cnt) & mask;
+ if (cnt != 1)
+ res |= (d << (33 - cnt));
+ if (ACCESS_FLAG(F_CF)) { /* carry flag is set */
+ res |= 1 << (32 - cnt);
+ }
+ CONDITIONAL_SET_FLAG(cf, F_CF);
+ if (cnt == 1) {
+ CONDITIONAL_SET_FLAG(XOR2(ocf + ((d >> 30) & 0x2)), F_OF);
+ }
+ }
+ return res;
}
/****************************************************************************
REMARKS:
Implements the ROL instruction and side effects.
****************************************************************************/
-u8 rol_byte(u8 d, u8 s)
+u8
+rol_byte(u8 d, u8 s)
{
register unsigned int res, cnt, mask;
@@ -1127,87 +1168,90 @@ u8 rol_byte(u8 d, u8 s)
IF n > 0
1) B_(7) .. B_(n) <- b_(8-(n+1)) .. b_(0)
2) B_(n-1) .. B_(0) <- b_(7) .. b_(8-n)
- */
+ */
res = d;
- if ((cnt = s % 8) != 0) {
- /* B_(7) .. B_(n) <- b_(8-(n+1)) .. b_(0) */
- res = (d << cnt);
+ if ((cnt = s % 8) != 0) {
+ /* B_(7) .. B_(n) <- b_(8-(n+1)) .. b_(0) */
+ res = (d << cnt);
- /* B_(n-1) .. B_(0) <- b_(7) .. b_(8-n) */
- mask = (1 << cnt) - 1;
- res |= (d >> (8 - cnt)) & mask;
+ /* B_(n-1) .. B_(0) <- b_(7) .. b_(8-n) */
+ mask = (1 << cnt) - 1;
+ res |= (d >> (8 - cnt)) & mask;
- /* set the new carry flag, Note that it is the low order
- bit of the result!!! */
- CONDITIONAL_SET_FLAG(res & 0x1, F_CF);
- /* OVERFLOW is set *IFF* s==1, then it is the
- xor of CF and the most significant bit. Blecck. */
- CONDITIONAL_SET_FLAG(s == 1 &&
- XOR2((res & 0x1) + ((res >> 6) & 0x2)),
- F_OF);
- } if (s != 0) {
- /* set the new carry flag, Note that it is the low order
- bit of the result!!! */
- CONDITIONAL_SET_FLAG(res & 0x1, F_CF);
- }
- return (u8)res;
+ /* set the new carry flag, Note that it is the low order
+ bit of the result!!! */
+ CONDITIONAL_SET_FLAG(res & 0x1, F_CF);
+ /* OVERFLOW is set *IFF* s==1, then it is the
+ xor of CF and the most significant bit. Blecck. */
+ CONDITIONAL_SET_FLAG(s == 1 &&
+ XOR2((res & 0x1) + ((res >> 6) & 0x2)), F_OF);
+ }
+ if (s != 0) {
+ /* set the new carry flag, Note that it is the low order
+ bit of the result!!! */
+ CONDITIONAL_SET_FLAG(res & 0x1, F_CF);
+ }
+ return (u8) res;
}
/****************************************************************************
REMARKS:
Implements the ROL instruction and side effects.
****************************************************************************/
-u16 rol_word(u16 d, u8 s)
+u16
+rol_word(u16 d, u8 s)
{
register unsigned int res, cnt, mask;
- res = d;
- if ((cnt = s % 16) != 0) {
- res = (d << cnt);
- mask = (1 << cnt) - 1;
- res |= (d >> (16 - cnt)) & mask;
- CONDITIONAL_SET_FLAG(res & 0x1, F_CF);
- CONDITIONAL_SET_FLAG(s == 1 &&
- XOR2((res & 0x1) + ((res >> 14) & 0x2)),
- F_OF);
- } if (s != 0) {
- /* set the new carry flag, Note that it is the low order
- bit of the result!!! */
- CONDITIONAL_SET_FLAG(res & 0x1, F_CF);
- }
- return (u16)res;
+ res = d;
+ if ((cnt = s % 16) != 0) {
+ res = (d << cnt);
+ mask = (1 << cnt) - 1;
+ res |= (d >> (16 - cnt)) & mask;
+ CONDITIONAL_SET_FLAG(res & 0x1, F_CF);
+ CONDITIONAL_SET_FLAG(s == 1 &&
+ XOR2((res & 0x1) + ((res >> 14) & 0x2)), F_OF);
+ }
+ if (s != 0) {
+ /* set the new carry flag, Note that it is the low order
+ bit of the result!!! */
+ CONDITIONAL_SET_FLAG(res & 0x1, F_CF);
+ }
+ return (u16) res;
}
/****************************************************************************
REMARKS:
Implements the ROL instruction and side effects.
****************************************************************************/
-u32 rol_long(u32 d, u8 s)
+u32
+rol_long(u32 d, u8 s)
{
register u32 res, cnt, mask;
- res = d;
- if ((cnt = s % 32) != 0) {
- res = (d << cnt);
- mask = (1 << cnt) - 1;
- res |= (d >> (32 - cnt)) & mask;
- CONDITIONAL_SET_FLAG(res & 0x1, F_CF);
- CONDITIONAL_SET_FLAG(s == 1 &&
- XOR2((res & 0x1) + ((res >> 30) & 0x2)),
- F_OF);
- } if (s != 0) {
- /* set the new carry flag, Note that it is the low order
- bit of the result!!! */
- CONDITIONAL_SET_FLAG(res & 0x1, F_CF);
- }
- return res;
+ res = d;
+ if ((cnt = s % 32) != 0) {
+ res = (d << cnt);
+ mask = (1 << cnt) - 1;
+ res |= (d >> (32 - cnt)) & mask;
+ CONDITIONAL_SET_FLAG(res & 0x1, F_CF);
+ CONDITIONAL_SET_FLAG(s == 1 &&
+ XOR2((res & 0x1) + ((res >> 30) & 0x2)), F_OF);
+ }
+ if (s != 0) {
+ /* set the new carry flag, Note that it is the low order
+ bit of the result!!! */
+ CONDITIONAL_SET_FLAG(res & 0x1, F_CF);
+ }
+ return res;
}
/****************************************************************************
REMARKS:
Implements the ROR instruction and side effects.
****************************************************************************/
-u8 ror_byte(u8 d, u8 s)
+u8
+ror_byte(u8 d, u8 s)
{
register unsigned int res, cnt, mask;
@@ -1225,9 +1269,9 @@ u8 ror_byte(u8 d, u8 s)
IF n > 0
1) B_(8-(n+1)) .. B_(0) <- b_(7) .. b_(n)
2) B_(7) .. B_(8-n) <- b_(n-1) .. b_(0)
- */
- res = d;
- if ((cnt = s % 8) != 0) { /* not a typo, do nada if cnt==0 */
+ */
+ res = d;
+ if ((cnt = s % 8) != 0) { /* not a typo, do nada if cnt==0 */
/* B_(7) .. B_(8-n) <- b_(n-1) .. b_(0) */
res = (d << (8 - cnt));
@@ -1237,291 +1281,317 @@ u8 ror_byte(u8 d, u8 s)
/* set the new carry flag, Note that it is the low order
bit of the result!!! */
- CONDITIONAL_SET_FLAG(res & 0x80, F_CF);
- /* OVERFLOW is set *IFF* s==1, then it is the
+ CONDITIONAL_SET_FLAG(res & 0x80, F_CF);
+ /* OVERFLOW is set *IFF* s==1, then it is the
xor of the two most significant bits. Blecck. */
- CONDITIONAL_SET_FLAG(s == 1 && XOR2(res >> 6), F_OF);
- } else if (s != 0) {
- /* set the new carry flag, Note that it is the low order
- bit of the result!!! */
- CONDITIONAL_SET_FLAG(res & 0x80, F_CF);
- }
- return (u8)res;
+ CONDITIONAL_SET_FLAG(s == 1 && XOR2(res >> 6), F_OF);
+ }
+ else if (s != 0) {
+ /* set the new carry flag, Note that it is the low order
+ bit of the result!!! */
+ CONDITIONAL_SET_FLAG(res & 0x80, F_CF);
+ }
+ return (u8) res;
}
/****************************************************************************
REMARKS:
Implements the ROR instruction and side effects.
****************************************************************************/
-u16 ror_word(u16 d, u8 s)
+u16
+ror_word(u16 d, u8 s)
{
register unsigned int res, cnt, mask;
- res = d;
- if ((cnt = s % 16) != 0) {
- res = (d << (16 - cnt));
- mask = (1 << (16 - cnt)) - 1;
- res |= (d >> (cnt)) & mask;
- CONDITIONAL_SET_FLAG(res & 0x8000, F_CF);
- CONDITIONAL_SET_FLAG(s == 1 && XOR2(res >> 14), F_OF);
- } else if (s != 0) {
- /* set the new carry flag, Note that it is the low order
- bit of the result!!! */
- CONDITIONAL_SET_FLAG(res & 0x8000, F_CF);
- }
- return (u16)res;
+ res = d;
+ if ((cnt = s % 16) != 0) {
+ res = (d << (16 - cnt));
+ mask = (1 << (16 - cnt)) - 1;
+ res |= (d >> (cnt)) & mask;
+ CONDITIONAL_SET_FLAG(res & 0x8000, F_CF);
+ CONDITIONAL_SET_FLAG(s == 1 && XOR2(res >> 14), F_OF);
+ }
+ else if (s != 0) {
+ /* set the new carry flag, Note that it is the low order
+ bit of the result!!! */
+ CONDITIONAL_SET_FLAG(res & 0x8000, F_CF);
+ }
+ return (u16) res;
}
/****************************************************************************
REMARKS:
Implements the ROR instruction and side effects.
****************************************************************************/
-u32 ror_long(u32 d, u8 s)
+u32
+ror_long(u32 d, u8 s)
{
- register u32 res, cnt, mask;
+ register u32 res, cnt, mask;
- res = d;
- if ((cnt = s % 32) != 0) {
- res = (d << (32 - cnt));
- mask = (1 << (32 - cnt)) - 1;
- res |= (d >> (cnt)) & mask;
- CONDITIONAL_SET_FLAG(res & 0x80000000, F_CF);
- CONDITIONAL_SET_FLAG(s == 1 && XOR2(res >> 30), F_OF);
- } else if (s != 0) {
- /* set the new carry flag, Note that it is the low order
- bit of the result!!! */
- CONDITIONAL_SET_FLAG(res & 0x80000000, F_CF);
- }
- return res;
+ res = d;
+ if ((cnt = s % 32) != 0) {
+ res = (d << (32 - cnt));
+ mask = (1 << (32 - cnt)) - 1;
+ res |= (d >> (cnt)) & mask;
+ CONDITIONAL_SET_FLAG(res & 0x80000000, F_CF);
+ CONDITIONAL_SET_FLAG(s == 1 && XOR2(res >> 30), F_OF);
+ }
+ else if (s != 0) {
+ /* set the new carry flag, Note that it is the low order
+ bit of the result!!! */
+ CONDITIONAL_SET_FLAG(res & 0x80000000, F_CF);
+ }
+ return res;
}
/****************************************************************************
REMARKS:
Implements the SHL instruction and side effects.
****************************************************************************/
-u8 shl_byte(u8 d, u8 s)
+u8
+shl_byte(u8 d, u8 s)
{
- unsigned int cnt, res, cf;
-
- if (s < 8) {
- cnt = s % 8;
+ unsigned int cnt, res, cf;
- /* last bit shifted out goes into carry flag */
- if (cnt > 0) {
- res = d << cnt;
- cf = d & (1 << (8 - cnt));
- CONDITIONAL_SET_FLAG(cf, F_CF);
- CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- } else {
- res = (u8) d;
- }
+ if (s < 8) {
+ cnt = s % 8;
+
+ /* last bit shifted out goes into carry flag */
+ if (cnt > 0) {
+ res = d << cnt;
+ cf = d & (1 << (8 - cnt));
+ CONDITIONAL_SET_FLAG(cf, F_CF);
+ CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ }
+ else {
+ res = (u8) d;
+ }
- if (cnt == 1) {
- /* Needs simplification. */
- CONDITIONAL_SET_FLAG(
- (((res & 0x80) == 0x80) ^
- (ACCESS_FLAG(F_CF) != 0)),
- /* was (M.x86.R_FLG&F_CF)==F_CF)), */
- F_OF);
- } else {
- CLEAR_FLAG(F_OF);
- }
- } else {
- res = 0;
- CONDITIONAL_SET_FLAG((d << (s-1)) & 0x80, F_CF);
- CLEAR_FLAG(F_OF);
- CLEAR_FLAG(F_SF);
- SET_FLAG(F_PF);
- SET_FLAG(F_ZF);
+ if (cnt == 1) {
+ /* Needs simplification. */
+ CONDITIONAL_SET_FLAG((((res & 0x80) == 0x80) ^
+ (ACCESS_FLAG(F_CF) != 0)),
+ /* was (M.x86.R_FLG&F_CF)==F_CF)), */
+ F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_OF);
+ }
}
- return (u8)res;
+ else {
+ res = 0;
+ CONDITIONAL_SET_FLAG((d << (s - 1)) & 0x80, F_CF);
+ CLEAR_FLAG(F_OF);
+ CLEAR_FLAG(F_SF);
+ SET_FLAG(F_PF);
+ SET_FLAG(F_ZF);
+ }
+ return (u8) res;
}
/****************************************************************************
REMARKS:
Implements the SHL instruction and side effects.
****************************************************************************/
-u16 shl_word(u16 d, u8 s)
+u16
+shl_word(u16 d, u8 s)
{
unsigned int cnt, res, cf;
- if (s < 16) {
- cnt = s % 16;
- if (cnt > 0) {
- res = d << cnt;
- cf = d & (1 << (16 - cnt));
- CONDITIONAL_SET_FLAG(cf, F_CF);
- CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- } else {
- res = (u16) d;
- }
-
- if (cnt == 1) {
- CONDITIONAL_SET_FLAG(
- (((res & 0x8000) == 0x8000) ^
- (ACCESS_FLAG(F_CF) != 0)),
- F_OF);
- } else {
- CLEAR_FLAG(F_OF);
- }
- } else {
- res = 0;
- CONDITIONAL_SET_FLAG((d << (s-1)) & 0x8000, F_CF);
- CLEAR_FLAG(F_OF);
- CLEAR_FLAG(F_SF);
- SET_FLAG(F_PF);
- SET_FLAG(F_ZF);
- }
- return (u16)res;
+ if (s < 16) {
+ cnt = s % 16;
+ if (cnt > 0) {
+ res = d << cnt;
+ cf = d & (1 << (16 - cnt));
+ CONDITIONAL_SET_FLAG(cf, F_CF);
+ CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ }
+ else {
+ res = (u16) d;
+ }
+
+ if (cnt == 1) {
+ CONDITIONAL_SET_FLAG((((res & 0x8000) == 0x8000) ^
+ (ACCESS_FLAG(F_CF) != 0)), F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_OF);
+ }
+ }
+ else {
+ res = 0;
+ CONDITIONAL_SET_FLAG((d << (s - 1)) & 0x8000, F_CF);
+ CLEAR_FLAG(F_OF);
+ CLEAR_FLAG(F_SF);
+ SET_FLAG(F_PF);
+ SET_FLAG(F_ZF);
+ }
+ return (u16) res;
}
/****************************************************************************
REMARKS:
Implements the SHL instruction and side effects.
****************************************************************************/
-u32 shl_long(u32 d, u8 s)
-{
- unsigned int cnt, res, cf;
-
- if (s < 32) {
- cnt = s % 32;
- if (cnt > 0) {
- res = d << cnt;
- cf = d & (1 << (32 - cnt));
- CONDITIONAL_SET_FLAG(cf, F_CF);
- CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- } else {
- res = d;
- }
- if (cnt == 1) {
- CONDITIONAL_SET_FLAG((((res & 0x80000000) == 0x80000000) ^
- (ACCESS_FLAG(F_CF) != 0)), F_OF);
- } else {
- CLEAR_FLAG(F_OF);
- }
- } else {
- res = 0;
- CONDITIONAL_SET_FLAG((d << (s-1)) & 0x80000000, F_CF);
- CLEAR_FLAG(F_OF);
- CLEAR_FLAG(F_SF);
- SET_FLAG(F_PF);
- SET_FLAG(F_ZF);
- }
- return res;
+u32
+shl_long(u32 d, u8 s)
+{
+ unsigned int cnt, res, cf;
+
+ if (s < 32) {
+ cnt = s % 32;
+ if (cnt > 0) {
+ res = d << cnt;
+ cf = d & (1 << (32 - cnt));
+ CONDITIONAL_SET_FLAG(cf, F_CF);
+ CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ }
+ else {
+ res = d;
+ }
+ if (cnt == 1) {
+ CONDITIONAL_SET_FLAG((((res & 0x80000000) == 0x80000000) ^
+ (ACCESS_FLAG(F_CF) != 0)), F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_OF);
+ }
+ }
+ else {
+ res = 0;
+ CONDITIONAL_SET_FLAG((d << (s - 1)) & 0x80000000, F_CF);
+ CLEAR_FLAG(F_OF);
+ CLEAR_FLAG(F_SF);
+ SET_FLAG(F_PF);
+ SET_FLAG(F_ZF);
+ }
+ return res;
}
/****************************************************************************
REMARKS:
Implements the SHR instruction and side effects.
****************************************************************************/
-u8 shr_byte(u8 d, u8 s)
-{
- unsigned int cnt, res, cf;
-
- if (s < 8) {
- cnt = s % 8;
- if (cnt > 0) {
- cf = d & (1 << (cnt - 1));
- res = d >> cnt;
- CONDITIONAL_SET_FLAG(cf, F_CF);
- CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- } else {
- res = (u8) d;
- }
-
- if (cnt == 1) {
- CONDITIONAL_SET_FLAG(XOR2(res >> 6), F_OF);
- } else {
- CLEAR_FLAG(F_OF);
- }
- } else {
- res = 0;
- CONDITIONAL_SET_FLAG((d >> (s-1)) & 0x1, F_CF);
- CLEAR_FLAG(F_OF);
- CLEAR_FLAG(F_SF);
- SET_FLAG(F_PF);
- SET_FLAG(F_ZF);
- }
- return (u8)res;
+u8
+shr_byte(u8 d, u8 s)
+{
+ unsigned int cnt, res, cf;
+
+ if (s < 8) {
+ cnt = s % 8;
+ if (cnt > 0) {
+ cf = d & (1 << (cnt - 1));
+ res = d >> cnt;
+ CONDITIONAL_SET_FLAG(cf, F_CF);
+ CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ }
+ else {
+ res = (u8) d;
+ }
+
+ if (cnt == 1) {
+ CONDITIONAL_SET_FLAG(XOR2(res >> 6), F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_OF);
+ }
+ }
+ else {
+ res = 0;
+ CONDITIONAL_SET_FLAG((d >> (s - 1)) & 0x1, F_CF);
+ CLEAR_FLAG(F_OF);
+ CLEAR_FLAG(F_SF);
+ SET_FLAG(F_PF);
+ SET_FLAG(F_ZF);
+ }
+ return (u8) res;
}
/****************************************************************************
REMARKS:
Implements the SHR instruction and side effects.
****************************************************************************/
-u16 shr_word(u16 d, u8 s)
+u16
+shr_word(u16 d, u8 s)
{
- unsigned int cnt, res, cf;
+ unsigned int cnt, res, cf;
- if (s < 16) {
- cnt = s % 16;
- if (cnt > 0) {
- cf = d & (1 << (cnt - 1));
- res = d >> cnt;
- CONDITIONAL_SET_FLAG(cf, F_CF);
- CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- } else {
- res = d;
- }
+ if (s < 16) {
+ cnt = s % 16;
+ if (cnt > 0) {
+ cf = d & (1 << (cnt - 1));
+ res = d >> cnt;
+ CONDITIONAL_SET_FLAG(cf, F_CF);
+ CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ }
+ else {
+ res = d;
+ }
- if (cnt == 1) {
- CONDITIONAL_SET_FLAG(XOR2(res >> 14), F_OF);
- } else {
- CLEAR_FLAG(F_OF);
+ if (cnt == 1) {
+ CONDITIONAL_SET_FLAG(XOR2(res >> 14), F_OF);
}
- } else {
- res = 0;
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- SET_FLAG(F_ZF);
- CLEAR_FLAG(F_SF);
- CLEAR_FLAG(F_PF);
+ else {
+ CLEAR_FLAG(F_OF);
+ }
+ }
+ else {
+ res = 0;
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ SET_FLAG(F_ZF);
+ CLEAR_FLAG(F_SF);
+ CLEAR_FLAG(F_PF);
}
- return (u16)res;
+ return (u16) res;
}
/****************************************************************************
REMARKS:
Implements the SHR instruction and side effects.
****************************************************************************/
-u32 shr_long(u32 d, u8 s)
+u32
+shr_long(u32 d, u8 s)
{
- unsigned int cnt, res, cf;
+ unsigned int cnt, res, cf;
- if (s < 32) {
- cnt = s % 32;
- if (cnt > 0) {
- cf = d & (1 << (cnt - 1));
- res = d >> cnt;
- CONDITIONAL_SET_FLAG(cf, F_CF);
- CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- } else {
+ if (s < 32) {
+ cnt = s % 32;
+ if (cnt > 0) {
+ cf = d & (1 << (cnt - 1));
+ res = d >> cnt;
+ CONDITIONAL_SET_FLAG(cf, F_CF);
+ CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ }
+ else {
res = d;
}
if (cnt == 1) {
- CONDITIONAL_SET_FLAG(XOR2(res >> 30), F_OF);
- } else {
- CLEAR_FLAG(F_OF);
+ CONDITIONAL_SET_FLAG(XOR2(res >> 30), F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_OF);
}
- } else {
+ }
+ else {
res = 0;
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- SET_FLAG(F_ZF);
- CLEAR_FLAG(F_SF);
- CLEAR_FLAG(F_PF);
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ SET_FLAG(F_ZF);
+ CLEAR_FLAG(F_SF);
+ CLEAR_FLAG(F_PF);
}
return res;
}
@@ -1530,592 +1600,634 @@ u32 shr_long(u32 d, u8 s)
REMARKS:
Implements the SAR instruction and side effects.
****************************************************************************/
-u8 sar_byte(u8 d, u8 s)
+u8
+sar_byte(u8 d, u8 s)
{
- unsigned int cnt, res, cf, mask, sf;
+ unsigned int cnt, res, cf, mask, sf;
- res = d;
- sf = d & 0x80;
+ res = d;
+ sf = d & 0x80;
cnt = s % 8;
- if (cnt > 0 && cnt < 8) {
- mask = (1 << (8 - cnt)) - 1;
- cf = d & (1 << (cnt - 1));
- res = (d >> cnt) & mask;
- CONDITIONAL_SET_FLAG(cf, F_CF);
- if (sf) {
- res |= ~mask;
- }
- CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
- } else if (cnt >= 8) {
+ if (cnt > 0 && cnt < 8) {
+ mask = (1 << (8 - cnt)) - 1;
+ cf = d & (1 << (cnt - 1));
+ res = (d >> cnt) & mask;
+ CONDITIONAL_SET_FLAG(cf, F_CF);
+ if (sf) {
+ res |= ~mask;
+ }
+ CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
+ }
+ else if (cnt >= 8) {
if (sf) {
res = 0xff;
- SET_FLAG(F_CF);
- CLEAR_FLAG(F_ZF);
- SET_FLAG(F_SF);
- SET_FLAG(F_PF);
- } else {
- res = 0;
- CLEAR_FLAG(F_CF);
- SET_FLAG(F_ZF);
- CLEAR_FLAG(F_SF);
- CLEAR_FLAG(F_PF);
- }
- }
- return (u8)res;
+ SET_FLAG(F_CF);
+ CLEAR_FLAG(F_ZF);
+ SET_FLAG(F_SF);
+ SET_FLAG(F_PF);
+ }
+ else {
+ res = 0;
+ CLEAR_FLAG(F_CF);
+ SET_FLAG(F_ZF);
+ CLEAR_FLAG(F_SF);
+ CLEAR_FLAG(F_PF);
+ }
+ }
+ return (u8) res;
}
/****************************************************************************
REMARKS:
Implements the SAR instruction and side effects.
****************************************************************************/
-u16 sar_word(u16 d, u8 s)
+u16
+sar_word(u16 d, u8 s)
{
unsigned int cnt, res, cf, mask, sf;
sf = d & 0x8000;
cnt = s % 16;
- res = d;
- if (cnt > 0 && cnt < 16) {
+ res = d;
+ if (cnt > 0 && cnt < 16) {
mask = (1 << (16 - cnt)) - 1;
cf = d & (1 << (cnt - 1));
res = (d >> cnt) & mask;
- CONDITIONAL_SET_FLAG(cf, F_CF);
+ CONDITIONAL_SET_FLAG(cf, F_CF);
if (sf) {
res |= ~mask;
}
- CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- } else if (cnt >= 16) {
+ CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ }
+ else if (cnt >= 16) {
if (sf) {
res = 0xffff;
- SET_FLAG(F_CF);
- CLEAR_FLAG(F_ZF);
- SET_FLAG(F_SF);
- SET_FLAG(F_PF);
- } else {
+ SET_FLAG(F_CF);
+ CLEAR_FLAG(F_ZF);
+ SET_FLAG(F_SF);
+ SET_FLAG(F_PF);
+ }
+ else {
res = 0;
- CLEAR_FLAG(F_CF);
- SET_FLAG(F_ZF);
- CLEAR_FLAG(F_SF);
- CLEAR_FLAG(F_PF);
+ CLEAR_FLAG(F_CF);
+ SET_FLAG(F_ZF);
+ CLEAR_FLAG(F_SF);
+ CLEAR_FLAG(F_PF);
}
}
- return (u16)res;
+ return (u16) res;
}
/****************************************************************************
REMARKS:
Implements the SAR instruction and side effects.
****************************************************************************/
-u32 sar_long(u32 d, u8 s)
+u32
+sar_long(u32 d, u8 s)
{
u32 cnt, res, cf, mask, sf;
sf = d & 0x80000000;
cnt = s % 32;
- res = d;
- if (cnt > 0 && cnt < 32) {
+ res = d;
+ if (cnt > 0 && cnt < 32) {
mask = (1 << (32 - cnt)) - 1;
- cf = d & (1 << (cnt - 1));
+ cf = d & (1 << (cnt - 1));
res = (d >> cnt) & mask;
- CONDITIONAL_SET_FLAG(cf, F_CF);
+ CONDITIONAL_SET_FLAG(cf, F_CF);
if (sf) {
res |= ~mask;
}
- CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- } else if (cnt >= 32) {
+ CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ }
+ else if (cnt >= 32) {
if (sf) {
res = 0xffffffff;
- SET_FLAG(F_CF);
- CLEAR_FLAG(F_ZF);
- SET_FLAG(F_SF);
- SET_FLAG(F_PF);
- } else {
- res = 0;
- CLEAR_FLAG(F_CF);
- SET_FLAG(F_ZF);
- CLEAR_FLAG(F_SF);
- CLEAR_FLAG(F_PF);
- }
- }
- return res;
+ SET_FLAG(F_CF);
+ CLEAR_FLAG(F_ZF);
+ SET_FLAG(F_SF);
+ SET_FLAG(F_PF);
+ }
+ else {
+ res = 0;
+ CLEAR_FLAG(F_CF);
+ SET_FLAG(F_ZF);
+ CLEAR_FLAG(F_SF);
+ CLEAR_FLAG(F_PF);
+ }
+ }
+ return res;
}
/****************************************************************************
REMARKS:
Implements the SHLD instruction and side effects.
****************************************************************************/
-u16 shld_word (u16 d, u16 fill, u8 s)
-{
- unsigned int cnt, res, cf;
-
- if (s < 16) {
- cnt = s % 16;
- if (cnt > 0) {
- res = (d << cnt) | (fill >> (16-cnt));
- cf = d & (1 << (16 - cnt));
- CONDITIONAL_SET_FLAG(cf, F_CF);
- CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- } else {
- res = d;
- }
- if (cnt == 1) {
- CONDITIONAL_SET_FLAG((((res & 0x8000) == 0x8000) ^
- (ACCESS_FLAG(F_CF) != 0)), F_OF);
- } else {
- CLEAR_FLAG(F_OF);
- }
- } else {
- res = 0;
- CONDITIONAL_SET_FLAG((d << (s-1)) & 0x8000, F_CF);
- CLEAR_FLAG(F_OF);
- CLEAR_FLAG(F_SF);
- SET_FLAG(F_PF);
- SET_FLAG(F_ZF);
- }
- return (u16)res;
+u16
+shld_word(u16 d, u16 fill, u8 s)
+{
+ unsigned int cnt, res, cf;
+
+ if (s < 16) {
+ cnt = s % 16;
+ if (cnt > 0) {
+ res = (d << cnt) | (fill >> (16 - cnt));
+ cf = d & (1 << (16 - cnt));
+ CONDITIONAL_SET_FLAG(cf, F_CF);
+ CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ }
+ else {
+ res = d;
+ }
+ if (cnt == 1) {
+ CONDITIONAL_SET_FLAG((((res & 0x8000) == 0x8000) ^
+ (ACCESS_FLAG(F_CF) != 0)), F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_OF);
+ }
+ }
+ else {
+ res = 0;
+ CONDITIONAL_SET_FLAG((d << (s - 1)) & 0x8000, F_CF);
+ CLEAR_FLAG(F_OF);
+ CLEAR_FLAG(F_SF);
+ SET_FLAG(F_PF);
+ SET_FLAG(F_ZF);
+ }
+ return (u16) res;
}
/****************************************************************************
REMARKS:
Implements the SHLD instruction and side effects.
****************************************************************************/
-u32 shld_long (u32 d, u32 fill, u8 s)
-{
- unsigned int cnt, res, cf;
-
- if (s < 32) {
- cnt = s % 32;
- if (cnt > 0) {
- res = (d << cnt) | (fill >> (32-cnt));
- cf = d & (1 << (32 - cnt));
- CONDITIONAL_SET_FLAG(cf, F_CF);
- CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- } else {
- res = d;
- }
- if (cnt == 1) {
- CONDITIONAL_SET_FLAG((((res & 0x80000000) == 0x80000000) ^
- (ACCESS_FLAG(F_CF) != 0)), F_OF);
- } else {
- CLEAR_FLAG(F_OF);
- }
- } else {
- res = 0;
- CONDITIONAL_SET_FLAG((d << (s-1)) & 0x80000000, F_CF);
- CLEAR_FLAG(F_OF);
- CLEAR_FLAG(F_SF);
- SET_FLAG(F_PF);
- SET_FLAG(F_ZF);
- }
- return res;
+u32
+shld_long(u32 d, u32 fill, u8 s)
+{
+ unsigned int cnt, res, cf;
+
+ if (s < 32) {
+ cnt = s % 32;
+ if (cnt > 0) {
+ res = (d << cnt) | (fill >> (32 - cnt));
+ cf = d & (1 << (32 - cnt));
+ CONDITIONAL_SET_FLAG(cf, F_CF);
+ CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ }
+ else {
+ res = d;
+ }
+ if (cnt == 1) {
+ CONDITIONAL_SET_FLAG((((res & 0x80000000) == 0x80000000) ^
+ (ACCESS_FLAG(F_CF) != 0)), F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_OF);
+ }
+ }
+ else {
+ res = 0;
+ CONDITIONAL_SET_FLAG((d << (s - 1)) & 0x80000000, F_CF);
+ CLEAR_FLAG(F_OF);
+ CLEAR_FLAG(F_SF);
+ SET_FLAG(F_PF);
+ SET_FLAG(F_ZF);
+ }
+ return res;
}
/****************************************************************************
REMARKS:
Implements the SHRD instruction and side effects.
****************************************************************************/
-u16 shrd_word (u16 d, u16 fill, u8 s)
+u16
+shrd_word(u16 d, u16 fill, u8 s)
{
- unsigned int cnt, res, cf;
+ unsigned int cnt, res, cf;
- if (s < 16) {
- cnt = s % 16;
- if (cnt > 0) {
- cf = d & (1 << (cnt - 1));
- res = (d >> cnt) | (fill << (16 - cnt));
- CONDITIONAL_SET_FLAG(cf, F_CF);
- CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- } else {
- res = d;
- }
+ if (s < 16) {
+ cnt = s % 16;
+ if (cnt > 0) {
+ cf = d & (1 << (cnt - 1));
+ res = (d >> cnt) | (fill << (16 - cnt));
+ CONDITIONAL_SET_FLAG(cf, F_CF);
+ CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ }
+ else {
+ res = d;
+ }
- if (cnt == 1) {
- CONDITIONAL_SET_FLAG(XOR2(res >> 14), F_OF);
- } else {
- CLEAR_FLAG(F_OF);
+ if (cnt == 1) {
+ CONDITIONAL_SET_FLAG(XOR2(res >> 14), F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_OF);
}
- } else {
- res = 0;
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- SET_FLAG(F_ZF);
- CLEAR_FLAG(F_SF);
- CLEAR_FLAG(F_PF);
}
- return (u16)res;
+ else {
+ res = 0;
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ SET_FLAG(F_ZF);
+ CLEAR_FLAG(F_SF);
+ CLEAR_FLAG(F_PF);
+ }
+ return (u16) res;
}
/****************************************************************************
REMARKS:
Implements the SHRD instruction and side effects.
****************************************************************************/
-u32 shrd_long (u32 d, u32 fill, u8 s)
+u32
+shrd_long(u32 d, u32 fill, u8 s)
{
- unsigned int cnt, res, cf;
+ unsigned int cnt, res, cf;
- if (s < 32) {
- cnt = s % 32;
- if (cnt > 0) {
- cf = d & (1 << (cnt - 1));
- res = (d >> cnt) | (fill << (32 - cnt));
- CONDITIONAL_SET_FLAG(cf, F_CF);
- CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- } else {
- res = d;
- }
- if (cnt == 1) {
- CONDITIONAL_SET_FLAG(XOR2(res >> 30), F_OF);
- } else {
- CLEAR_FLAG(F_OF);
+ if (s < 32) {
+ cnt = s % 32;
+ if (cnt > 0) {
+ cf = d & (1 << (cnt - 1));
+ res = (d >> cnt) | (fill << (32 - cnt));
+ CONDITIONAL_SET_FLAG(cf, F_CF);
+ CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
}
- } else {
- res = 0;
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- SET_FLAG(F_ZF);
- CLEAR_FLAG(F_SF);
- CLEAR_FLAG(F_PF);
+ else {
+ res = d;
+ }
+ if (cnt == 1) {
+ CONDITIONAL_SET_FLAG(XOR2(res >> 30), F_OF);
+ }
+ else {
+ CLEAR_FLAG(F_OF);
+ }
+ }
+ else {
+ res = 0;
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ SET_FLAG(F_ZF);
+ CLEAR_FLAG(F_SF);
+ CLEAR_FLAG(F_PF);
}
- return res;
+ return res;
}
/****************************************************************************
REMARKS:
Implements the SBB instruction and side effects.
****************************************************************************/
-u8 sbb_byte(u8 d, u8 s)
+u8
+sbb_byte(u8 d, u8 s)
{
- register u32 res; /* all operands in native machine order */
+ register u32 res; /* all operands in native machine order */
register u32 bc;
- if (ACCESS_FLAG(F_CF))
- res = d - s - 1;
- else
- res = d - s;
- CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
- CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ if (ACCESS_FLAG(F_CF))
+ res = d - s - 1;
+ else
+ res = d - s;
+ CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
+ CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- /* calculate the borrow chain. See note at top */
- bc = (res & (~d | s)) | (~d & s);
- CONDITIONAL_SET_FLAG(bc & 0x80, F_CF);
- CONDITIONAL_SET_FLAG(XOR2(bc >> 6), F_OF);
- CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
- return (u8)res;
+ /* calculate the borrow chain. See note at top */
+ bc = (res & (~d | s)) | (~d & s);
+ CONDITIONAL_SET_FLAG(bc & 0x80, F_CF);
+ CONDITIONAL_SET_FLAG(XOR2(bc >> 6), F_OF);
+ CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
+ return (u8) res;
}
/****************************************************************************
REMARKS:
Implements the SBB instruction and side effects.
****************************************************************************/
-u16 sbb_word(u16 d, u16 s)
+u16
+sbb_word(u16 d, u16 s)
{
- register u32 res; /* all operands in native machine order */
+ register u32 res; /* all operands in native machine order */
register u32 bc;
- if (ACCESS_FLAG(F_CF))
+ if (ACCESS_FLAG(F_CF))
res = d - s - 1;
else
res = d - s;
- CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
- CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
+ CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- /* calculate the borrow chain. See note at top */
- bc = (res & (~d | s)) | (~d & s);
- CONDITIONAL_SET_FLAG(bc & 0x8000, F_CF);
- CONDITIONAL_SET_FLAG(XOR2(bc >> 14), F_OF);
- CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
- return (u16)res;
+ /* calculate the borrow chain. See note at top */
+ bc = (res & (~d | s)) | (~d & s);
+ CONDITIONAL_SET_FLAG(bc & 0x8000, F_CF);
+ CONDITIONAL_SET_FLAG(XOR2(bc >> 14), F_OF);
+ CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
+ return (u16) res;
}
/****************************************************************************
REMARKS:
Implements the SBB instruction and side effects.
****************************************************************************/
-u32 sbb_long(u32 d, u32 s)
+u32
+sbb_long(u32 d, u32 s)
{
- register u32 res; /* all operands in native machine order */
- register u32 bc;
+ register u32 res; /* all operands in native machine order */
+ register u32 bc;
- if (ACCESS_FLAG(F_CF))
+ if (ACCESS_FLAG(F_CF))
res = d - s - 1;
else
res = d - s;
- CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
- CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
+ CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- /* calculate the borrow chain. See note at top */
- bc = (res & (~d | s)) | (~d & s);
- CONDITIONAL_SET_FLAG(bc & 0x80000000, F_CF);
- CONDITIONAL_SET_FLAG(XOR2(bc >> 30), F_OF);
- CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
- return res;
+ /* calculate the borrow chain. See note at top */
+ bc = (res & (~d | s)) | (~d & s);
+ CONDITIONAL_SET_FLAG(bc & 0x80000000, F_CF);
+ CONDITIONAL_SET_FLAG(XOR2(bc >> 30), F_OF);
+ CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
+ return res;
}
/****************************************************************************
REMARKS:
Implements the SUB instruction and side effects.
****************************************************************************/
-u8 sub_byte(u8 d, u8 s)
+u8
+sub_byte(u8 d, u8 s)
{
- register u32 res; /* all operands in native machine order */
- register u32 bc;
+ register u32 res; /* all operands in native machine order */
+ register u32 bc;
- res = d - s;
- CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
- CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ res = d - s;
+ CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
+ CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- /* calculate the borrow chain. See note at top */
- bc = (res & (~d | s)) | (~d & s);
- CONDITIONAL_SET_FLAG(bc & 0x80, F_CF);
- CONDITIONAL_SET_FLAG(XOR2(bc >> 6), F_OF);
- CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
- return (u8)res;
+ /* calculate the borrow chain. See note at top */
+ bc = (res & (~d | s)) | (~d & s);
+ CONDITIONAL_SET_FLAG(bc & 0x80, F_CF);
+ CONDITIONAL_SET_FLAG(XOR2(bc >> 6), F_OF);
+ CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
+ return (u8) res;
}
/****************************************************************************
REMARKS:
Implements the SUB instruction and side effects.
****************************************************************************/
-u16 sub_word(u16 d, u16 s)
+u16
+sub_word(u16 d, u16 s)
{
- register u32 res; /* all operands in native machine order */
+ register u32 res; /* all operands in native machine order */
register u32 bc;
res = d - s;
- CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
- CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
+ CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- /* calculate the borrow chain. See note at top */
- bc = (res & (~d | s)) | (~d & s);
- CONDITIONAL_SET_FLAG(bc & 0x8000, F_CF);
- CONDITIONAL_SET_FLAG(XOR2(bc >> 14), F_OF);
- CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
- return (u16)res;
+ /* calculate the borrow chain. See note at top */
+ bc = (res & (~d | s)) | (~d & s);
+ CONDITIONAL_SET_FLAG(bc & 0x8000, F_CF);
+ CONDITIONAL_SET_FLAG(XOR2(bc >> 14), F_OF);
+ CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
+ return (u16) res;
}
/****************************************************************************
REMARKS:
Implements the SUB instruction and side effects.
****************************************************************************/
-u32 sub_long(u32 d, u32 s)
+u32
+sub_long(u32 d, u32 s)
{
- register u32 res; /* all operands in native machine order */
- register u32 bc;
+ register u32 res; /* all operands in native machine order */
+ register u32 bc;
- res = d - s;
- CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
- CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ res = d - s;
+ CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
+ CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- /* calculate the borrow chain. See note at top */
- bc = (res & (~d | s)) | (~d & s);
- CONDITIONAL_SET_FLAG(bc & 0x80000000, F_CF);
- CONDITIONAL_SET_FLAG(XOR2(bc >> 30), F_OF);
- CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
- return res;
+ /* calculate the borrow chain. See note at top */
+ bc = (res & (~d | s)) | (~d & s);
+ CONDITIONAL_SET_FLAG(bc & 0x80000000, F_CF);
+ CONDITIONAL_SET_FLAG(XOR2(bc >> 30), F_OF);
+ CONDITIONAL_SET_FLAG(bc & 0x8, F_AF);
+ return res;
}
/****************************************************************************
REMARKS:
Implements the TEST instruction and side effects.
****************************************************************************/
-void test_byte(u8 d, u8 s)
+void
+test_byte(u8 d, u8 s)
{
- register u32 res; /* all operands in native machine order */
+ register u32 res; /* all operands in native machine order */
res = d & s;
- CLEAR_FLAG(F_OF);
- CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
- CONDITIONAL_SET_FLAG(res == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ CLEAR_FLAG(F_OF);
+ CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
+ CONDITIONAL_SET_FLAG(res == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
/* AF == dont care */
- CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_CF);
}
/****************************************************************************
REMARKS:
Implements the TEST instruction and side effects.
****************************************************************************/
-void test_word(u16 d, u16 s)
+void
+test_word(u16 d, u16 s)
{
- register u32 res; /* all operands in native machine order */
+ register u32 res; /* all operands in native machine order */
- res = d & s;
+ res = d & s;
- CLEAR_FLAG(F_OF);
- CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
- CONDITIONAL_SET_FLAG(res == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- /* AF == dont care */
- CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
+ CONDITIONAL_SET_FLAG(res == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ /* AF == dont care */
+ CLEAR_FLAG(F_CF);
}
/****************************************************************************
REMARKS:
Implements the TEST instruction and side effects.
****************************************************************************/
-void test_long(u32 d, u32 s)
+void
+test_long(u32 d, u32 s)
{
- register u32 res; /* all operands in native machine order */
+ register u32 res; /* all operands in native machine order */
- res = d & s;
+ res = d & s;
- CLEAR_FLAG(F_OF);
- CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
- CONDITIONAL_SET_FLAG(res == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- /* AF == dont care */
- CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
+ CONDITIONAL_SET_FLAG(res == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ /* AF == dont care */
+ CLEAR_FLAG(F_CF);
}
/****************************************************************************
REMARKS:
Implements the XOR instruction and side effects.
****************************************************************************/
-u8 xor_byte(u8 d, u8 s)
+u8
+xor_byte(u8 d, u8 s)
{
- register u8 res; /* all operands in native machine order */
+ register u8 res; /* all operands in native machine order */
- res = d ^ s;
- CLEAR_FLAG(F_OF);
- CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
- CONDITIONAL_SET_FLAG(res == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res), F_PF);
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_AF);
- return res;
+ res = d ^ s;
+ CLEAR_FLAG(F_OF);
+ CONDITIONAL_SET_FLAG(res & 0x80, F_SF);
+ CONDITIONAL_SET_FLAG(res == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res), F_PF);
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_AF);
+ return res;
}
/****************************************************************************
REMARKS:
Implements the XOR instruction and side effects.
****************************************************************************/
-u16 xor_word(u16 d, u16 s)
+u16
+xor_word(u16 d, u16 s)
{
- register u16 res; /* all operands in native machine order */
+ register u16 res; /* all operands in native machine order */
- res = d ^ s;
- CLEAR_FLAG(F_OF);
- CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
- CONDITIONAL_SET_FLAG(res == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_AF);
- return res;
+ res = d ^ s;
+ CLEAR_FLAG(F_OF);
+ CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
+ CONDITIONAL_SET_FLAG(res == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_AF);
+ return res;
}
/****************************************************************************
REMARKS:
Implements the XOR instruction and side effects.
****************************************************************************/
-u32 xor_long(u32 d, u32 s)
+u32
+xor_long(u32 d, u32 s)
{
- register u32 res; /* all operands in native machine order */
+ register u32 res; /* all operands in native machine order */
- res = d ^ s;
- CLEAR_FLAG(F_OF);
- CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
- CONDITIONAL_SET_FLAG(res == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_AF);
- return res;
+ res = d ^ s;
+ CLEAR_FLAG(F_OF);
+ CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
+ CONDITIONAL_SET_FLAG(res == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_AF);
+ return res;
}
/****************************************************************************
REMARKS:
Implements the IMUL instruction and side effects.
****************************************************************************/
-void imul_byte(u8 s)
+void
+imul_byte(u8 s)
{
- s16 res = (s16)((s8)M.x86.R_AL * (s8)s);
+ s16 res = (s16) ((s8) M.x86.R_AL * (s8) s);
- M.x86.R_AX = res;
- if (((M.x86.R_AL & 0x80) == 0 && M.x86.R_AH == 0x00) ||
- ((M.x86.R_AL & 0x80) != 0 && M.x86.R_AH == 0xFF)) {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- } else {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
- }
+ M.x86.R_AX = res;
+ if (((M.x86.R_AL & 0x80) == 0 && M.x86.R_AH == 0x00) ||
+ ((M.x86.R_AL & 0x80) != 0 && M.x86.R_AH == 0xFF)) {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ else {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
+ }
}
/****************************************************************************
REMARKS:
Implements the IMUL instruction and side effects.
****************************************************************************/
-void imul_word(u16 s)
+void
+imul_word(u16 s)
{
- s32 res = (s16)M.x86.R_AX * (s16)s;
+ s32 res = (s16) M.x86.R_AX * (s16) s;
- M.x86.R_AX = (u16)res;
- M.x86.R_DX = (u16)(res >> 16);
- if (((M.x86.R_AX & 0x8000) == 0 && M.x86.R_DX == 0x00) ||
- ((M.x86.R_AX & 0x8000) != 0 && M.x86.R_DX == 0xFF)) {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- } else {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
- }
+ M.x86.R_AX = (u16) res;
+ M.x86.R_DX = (u16) (res >> 16);
+ if (((M.x86.R_AX & 0x8000) == 0 && M.x86.R_DX == 0x00) ||
+ ((M.x86.R_AX & 0x8000) != 0 && M.x86.R_DX == 0xFF)) {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ else {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
+ }
}
/****************************************************************************
REMARKS:
Implements the IMUL instruction and side effects.
****************************************************************************/
-void imul_long_direct(u32 *res_lo, u32* res_hi,u32 d, u32 s)
+void
+imul_long_direct(u32 * res_lo, u32 * res_hi, u32 d, u32 s)
{
#ifdef __HAS_LONG_LONG__
- s64 res = (s64)(s32)d * (s32)s;
+ s64 res = (s64) (s32) d * (s32) s;
- *res_lo = (u32)res;
- *res_hi = (u32)(res >> 32);
+ *res_lo = (u32) res;
+ *res_hi = (u32) (res >> 32);
#else
- u32 d_lo,d_hi,d_sign;
- u32 s_lo,s_hi,s_sign;
- u32 rlo_lo,rlo_hi,rhi_lo;
-
- if ((d_sign = d & 0x80000000) != 0)
- d = -d;
- d_lo = d & 0xFFFF;
- d_hi = d >> 16;
- if ((s_sign = s & 0x80000000) != 0)
- s = -s;
- s_lo = s & 0xFFFF;
- s_hi = s >> 16;
- rlo_lo = d_lo * s_lo;
- rlo_hi = (d_hi * s_lo + d_lo * s_hi) + (rlo_lo >> 16);
- rhi_lo = d_hi * s_hi + (rlo_hi >> 16);
- *res_lo = (rlo_hi << 16) | (rlo_lo & 0xFFFF);
- *res_hi = rhi_lo;
- if (d_sign != s_sign) {
- d = ~*res_lo;
- s = (((d & 0xFFFF) + 1) >> 16) + (d >> 16);
- *res_lo = ~*res_lo+1;
- *res_hi = ~*res_hi+(s >> 16);
- }
+ u32 d_lo, d_hi, d_sign;
+ u32 s_lo, s_hi, s_sign;
+ u32 rlo_lo, rlo_hi, rhi_lo;
+
+ if ((d_sign = d & 0x80000000) != 0)
+ d = -d;
+ d_lo = d & 0xFFFF;
+ d_hi = d >> 16;
+ if ((s_sign = s & 0x80000000) != 0)
+ s = -s;
+ s_lo = s & 0xFFFF;
+ s_hi = s >> 16;
+ rlo_lo = d_lo * s_lo;
+ rlo_hi = (d_hi * s_lo + d_lo * s_hi) + (rlo_lo >> 16);
+ rhi_lo = d_hi * s_hi + (rlo_hi >> 16);
+ *res_lo = (rlo_hi << 16) | (rlo_lo & 0xFFFF);
+ *res_hi = rhi_lo;
+ if (d_sign != s_sign) {
+ d = ~*res_lo;
+ s = (((d & 0xFFFF) + 1) >> 16) + (d >> 16);
+ *res_lo = ~*res_lo + 1;
+ *res_hi = ~*res_hi + (s >> 16);
+ }
#endif
}
@@ -2123,53 +2235,59 @@ void imul_long_direct(u32 *res_lo, u32* res_hi,u32 d, u32 s)
REMARKS:
Implements the IMUL instruction and side effects.
****************************************************************************/
-void imul_long(u32 s)
+void
+imul_long(u32 s)
{
- imul_long_direct(&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,s);
- if (((M.x86.R_EAX & 0x80000000) == 0 && M.x86.R_EDX == 0x00) ||
- ((M.x86.R_EAX & 0x80000000) != 0 && M.x86.R_EDX == 0xFF)) {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- } else {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
- }
+ imul_long_direct(&M.x86.R_EAX, &M.x86.R_EDX, M.x86.R_EAX, s);
+ if (((M.x86.R_EAX & 0x80000000) == 0 && M.x86.R_EDX == 0x00) ||
+ ((M.x86.R_EAX & 0x80000000) != 0 && M.x86.R_EDX == 0xFF)) {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ else {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
+ }
}
/****************************************************************************
REMARKS:
Implements the MUL instruction and side effects.
****************************************************************************/
-void mul_byte(u8 s)
+void
+mul_byte(u8 s)
{
- u16 res = (u16)(M.x86.R_AL * s);
+ u16 res = (u16) (M.x86.R_AL * s);
- M.x86.R_AX = res;
- if (M.x86.R_AH == 0) {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- } else {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
- }
+ M.x86.R_AX = res;
+ if (M.x86.R_AH == 0) {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ else {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
+ }
}
/****************************************************************************
REMARKS:
Implements the MUL instruction and side effects.
****************************************************************************/
-void mul_word(u16 s)
+void
+mul_word(u16 s)
{
- u32 res = M.x86.R_AX * s;
+ u32 res = M.x86.R_AX * s;
- M.x86.R_AX = (u16)res;
- M.x86.R_DX = (u16)(res >> 16);
- if (M.x86.R_DX == 0) {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- } else {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
+ M.x86.R_AX = (u16) res;
+ M.x86.R_DX = (u16) (res >> 16);
+ if (M.x86.R_DX == 0) {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ else {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
}
}
@@ -2177,36 +2295,38 @@ void mul_word(u16 s)
REMARKS:
Implements the MUL instruction and side effects.
****************************************************************************/
-void mul_long(u32 s)
+void
+mul_long(u32 s)
{
#ifdef __HAS_LONG_LONG__
- u64 res = (u64)M.x86.R_EAX * s;
+ u64 res = (u64) M.x86.R_EAX * s;
- M.x86.R_EAX = (u32)res;
- M.x86.R_EDX = (u32)(res >> 32);
+ M.x86.R_EAX = (u32) res;
+ M.x86.R_EDX = (u32) (res >> 32);
#else
- u32 a,a_lo,a_hi;
- u32 s_lo,s_hi;
- u32 rlo_lo,rlo_hi,rhi_lo;
-
- a = M.x86.R_EAX;
- a_lo = a & 0xFFFF;
- a_hi = a >> 16;
- s_lo = s & 0xFFFF;
- s_hi = s >> 16;
- rlo_lo = a_lo * s_lo;
- rlo_hi = (a_hi * s_lo + a_lo * s_hi) + (rlo_lo >> 16);
- rhi_lo = a_hi * s_hi + (rlo_hi >> 16);
- M.x86.R_EAX = (rlo_hi << 16) | (rlo_lo & 0xFFFF);
- M.x86.R_EDX = rhi_lo;
+ u32 a, a_lo, a_hi;
+ u32 s_lo, s_hi;
+ u32 rlo_lo, rlo_hi, rhi_lo;
+
+ a = M.x86.R_EAX;
+ a_lo = a & 0xFFFF;
+ a_hi = a >> 16;
+ s_lo = s & 0xFFFF;
+ s_hi = s >> 16;
+ rlo_lo = a_lo * s_lo;
+ rlo_hi = (a_hi * s_lo + a_lo * s_hi) + (rlo_lo >> 16);
+ rhi_lo = a_hi * s_hi + (rlo_hi >> 16);
+ M.x86.R_EAX = (rlo_hi << 16) | (rlo_lo & 0xFFFF);
+ M.x86.R_EDX = rhi_lo;
#endif
- if (M.x86.R_EDX == 0) {
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_OF);
- } else {
- SET_FLAG(F_CF);
- SET_FLAG(F_OF);
+ if (M.x86.R_EDX == 0) {
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_OF);
+ }
+ else {
+ SET_FLAG(F_CF);
+ SET_FLAG(F_OF);
}
}
@@ -2214,309 +2334,319 @@ void mul_long(u32 s)
REMARKS:
Implements the IDIV instruction and side effects.
****************************************************************************/
-void idiv_byte(u8 s)
+void
+idiv_byte(u8 s)
{
s32 dvd, div, mod;
- dvd = (s16)M.x86.R_AX;
- if (s == 0) {
- x86emu_intr_raise(0);
+ dvd = (s16) M.x86.R_AX;
+ if (s == 0) {
+ x86emu_intr_raise(0);
+ return;
+ }
+ div = dvd / (s8) s;
+ mod = dvd % (s8) s;
+ if (abs(div) > 0x7f) {
+ x86emu_intr_raise(0);
return;
- }
- div = dvd / (s8)s;
- mod = dvd % (s8)s;
- if (abs(div) > 0x7f) {
- x86emu_intr_raise(0);
- return;
- }
- M.x86.R_AL = (s8) div;
- M.x86.R_AH = (s8) mod;
+ }
+ M.x86.R_AL = (s8) div;
+ M.x86.R_AH = (s8) mod;
}
/****************************************************************************
REMARKS:
Implements the IDIV instruction and side effects.
****************************************************************************/
-void idiv_word(u16 s)
+void
+idiv_word(u16 s)
{
- s32 dvd, div, mod;
+ s32 dvd, div, mod;
- dvd = (((s32)M.x86.R_DX) << 16) | M.x86.R_AX;
- if (s == 0) {
- x86emu_intr_raise(0);
- return;
- }
- div = dvd / (s16)s;
- mod = dvd % (s16)s;
- if (abs(div) > 0x7fff) {
- x86emu_intr_raise(0);
- return;
- }
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_SF);
- CONDITIONAL_SET_FLAG(div == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF);
+ dvd = (((s32) M.x86.R_DX) << 16) | M.x86.R_AX;
+ if (s == 0) {
+ x86emu_intr_raise(0);
+ return;
+ }
+ div = dvd / (s16) s;
+ mod = dvd % (s16) s;
+ if (abs(div) > 0x7fff) {
+ x86emu_intr_raise(0);
+ return;
+ }
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_SF);
+ CONDITIONAL_SET_FLAG(div == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF);
- M.x86.R_AX = (u16)div;
- M.x86.R_DX = (u16)mod;
+ M.x86.R_AX = (u16) div;
+ M.x86.R_DX = (u16) mod;
}
/****************************************************************************
REMARKS:
Implements the IDIV instruction and side effects.
****************************************************************************/
-void idiv_long(u32 s)
+void
+idiv_long(u32 s)
{
#ifdef __HAS_LONG_LONG__
- s64 dvd, div, mod;
-
- dvd = (((s64)M.x86.R_EDX) << 32) | M.x86.R_EAX;
- if (s == 0) {
- x86emu_intr_raise(0);
- return;
- }
- div = dvd / (s32)s;
- mod = dvd % (s32)s;
- if (abs(div) > 0x7fffffff) {
- x86emu_intr_raise(0);
- return;
- }
+ s64 dvd, div, mod;
+
+ dvd = (((s64) M.x86.R_EDX) << 32) | M.x86.R_EAX;
+ if (s == 0) {
+ x86emu_intr_raise(0);
+ return;
+ }
+ div = dvd / (s32) s;
+ mod = dvd % (s32) s;
+ if (abs(div) > 0x7fffffff) {
+ x86emu_intr_raise(0);
+ return;
+ }
#else
- s32 div = 0, mod;
- s32 h_dvd = M.x86.R_EDX;
- u32 l_dvd = M.x86.R_EAX;
- u32 abs_s = s & 0x7FFFFFFF;
- u32 abs_h_dvd = h_dvd & 0x7FFFFFFF;
- u32 h_s = abs_s >> 1;
- u32 l_s = abs_s << 31;
- int counter = 31;
- int carry;
-
- if (s == 0) {
- x86emu_intr_raise(0);
- return;
- }
- do {
- div <<= 1;
- carry = (l_dvd >= l_s) ? 0 : 1;
-
- if (abs_h_dvd < (h_s + carry)) {
- h_s >>= 1;
- l_s = abs_s << (--counter);
- continue;
- } else {
- abs_h_dvd -= (h_s + carry);
- l_dvd = carry ? ((0xFFFFFFFF - l_s) + l_dvd + 1)
- : (l_dvd - l_s);
- h_s >>= 1;
- l_s = abs_s << (--counter);
- div |= 1;
- continue;
- }
-
- } while (counter > -1);
- /* overflow */
- if (abs_h_dvd || (l_dvd > abs_s)) {
- x86emu_intr_raise(0);
- return;
- }
- /* sign */
- div |= ((h_dvd & 0x10000000) ^ (s & 0x10000000));
- mod = l_dvd;
+ s32 div = 0, mod;
+ s32 h_dvd = M.x86.R_EDX;
+ u32 l_dvd = M.x86.R_EAX;
+ u32 abs_s = s & 0x7FFFFFFF;
+ u32 abs_h_dvd = h_dvd & 0x7FFFFFFF;
+ u32 h_s = abs_s >> 1;
+ u32 l_s = abs_s << 31;
+ int counter = 31;
+ int carry;
+
+ if (s == 0) {
+ x86emu_intr_raise(0);
+ return;
+ }
+ do {
+ div <<= 1;
+ carry = (l_dvd >= l_s) ? 0 : 1;
+
+ if (abs_h_dvd < (h_s + carry)) {
+ h_s >>= 1;
+ l_s = abs_s << (--counter);
+ continue;
+ }
+ else {
+ abs_h_dvd -= (h_s + carry);
+ l_dvd = carry ? ((0xFFFFFFFF - l_s) + l_dvd + 1)
+ : (l_dvd - l_s);
+ h_s >>= 1;
+ l_s = abs_s << (--counter);
+ div |= 1;
+ continue;
+ }
+
+ } while (counter > -1);
+ /* overflow */
+ if (abs_h_dvd || (l_dvd > abs_s)) {
+ x86emu_intr_raise(0);
+ return;
+ }
+ /* sign */
+ div |= ((h_dvd & 0x10000000) ^ (s & 0x10000000));
+ mod = l_dvd;
#endif
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_AF);
- CLEAR_FLAG(F_SF);
- SET_FLAG(F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF);
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_AF);
+ CLEAR_FLAG(F_SF);
+ SET_FLAG(F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF);
- M.x86.R_EAX = (u32)div;
- M.x86.R_EDX = (u32)mod;
+ M.x86.R_EAX = (u32) div;
+ M.x86.R_EDX = (u32) mod;
}
/****************************************************************************
REMARKS:
Implements the DIV instruction and side effects.
****************************************************************************/
-void div_byte(u8 s)
+void
+div_byte(u8 s)
{
- u32 dvd, div, mod;
+ u32 dvd, div, mod;
- dvd = M.x86.R_AX;
+ dvd = M.x86.R_AX;
if (s == 0) {
- x86emu_intr_raise(0);
+ x86emu_intr_raise(0);
return;
}
- div = dvd / (u8)s;
- mod = dvd % (u8)s;
- if (abs(div) > 0xff) {
- x86emu_intr_raise(0);
+ div = dvd / (u8) s;
+ mod = dvd % (u8) s;
+ if (abs(div) > 0xff) {
+ x86emu_intr_raise(0);
return;
- }
- M.x86.R_AL = (u8)div;
- M.x86.R_AH = (u8)mod;
+ }
+ M.x86.R_AL = (u8) div;
+ M.x86.R_AH = (u8) mod;
}
/****************************************************************************
REMARKS:
Implements the DIV instruction and side effects.
****************************************************************************/
-void div_word(u16 s)
+void
+div_word(u16 s)
{
- u32 dvd, div, mod;
+ u32 dvd, div, mod;
- dvd = (((u32)M.x86.R_DX) << 16) | M.x86.R_AX;
- if (s == 0) {
- x86emu_intr_raise(0);
+ dvd = (((u32) M.x86.R_DX) << 16) | M.x86.R_AX;
+ if (s == 0) {
+ x86emu_intr_raise(0);
return;
}
- div = dvd / (u16)s;
- mod = dvd % (u16)s;
- if (abs(div) > 0xffff) {
- x86emu_intr_raise(0);
- return;
- }
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_SF);
- CONDITIONAL_SET_FLAG(div == 0, F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF);
+ div = dvd / (u16) s;
+ mod = dvd % (u16) s;
+ if (abs(div) > 0xffff) {
+ x86emu_intr_raise(0);
+ return;
+ }
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_SF);
+ CONDITIONAL_SET_FLAG(div == 0, F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF);
- M.x86.R_AX = (u16)div;
- M.x86.R_DX = (u16)mod;
+ M.x86.R_AX = (u16) div;
+ M.x86.R_DX = (u16) mod;
}
/****************************************************************************
REMARKS:
Implements the DIV instruction and side effects.
****************************************************************************/
-void div_long(u32 s)
+void
+div_long(u32 s)
{
#ifdef __HAS_LONG_LONG__
- u64 dvd, div, mod;
-
- dvd = (((u64)M.x86.R_EDX) << 32) | M.x86.R_EAX;
- if (s == 0) {
- x86emu_intr_raise(0);
- return;
- }
- div = dvd / (u32)s;
- mod = dvd % (u32)s;
- if (abs(div) > 0xffffffff) {
- x86emu_intr_raise(0);
- return;
- }
+ u64 dvd, div, mod;
+
+ dvd = (((u64) M.x86.R_EDX) << 32) | M.x86.R_EAX;
+ if (s == 0) {
+ x86emu_intr_raise(0);
+ return;
+ }
+ div = dvd / (u32) s;
+ mod = dvd % (u32) s;
+ if (abs(div) > 0xffffffff) {
+ x86emu_intr_raise(0);
+ return;
+ }
#else
- s32 div = 0, mod;
- s32 h_dvd = M.x86.R_EDX;
- u32 l_dvd = M.x86.R_EAX;
-
- u32 h_s = s;
- u32 l_s = 0;
- int counter = 32;
- int carry;
-
- if (s == 0) {
- x86emu_intr_raise(0);
- return;
- }
- do {
- div <<= 1;
- carry = (l_dvd >= l_s) ? 0 : 1;
-
- if (h_dvd < (h_s + carry)) {
- h_s >>= 1;
- l_s = s << (--counter);
- continue;
- } else {
- h_dvd -= (h_s + carry);
- l_dvd = carry ? ((0xFFFFFFFF - l_s) + l_dvd + 1)
- : (l_dvd - l_s);
- h_s >>= 1;
- l_s = s << (--counter);
- div |= 1;
- continue;
- }
-
- } while (counter > -1);
- /* overflow */
- if (h_dvd || (l_dvd > s)) {
- x86emu_intr_raise(0);
- return;
- }
- mod = l_dvd;
+ s32 div = 0, mod;
+ s32 h_dvd = M.x86.R_EDX;
+ u32 l_dvd = M.x86.R_EAX;
+
+ u32 h_s = s;
+ u32 l_s = 0;
+ int counter = 32;
+ int carry;
+
+ if (s == 0) {
+ x86emu_intr_raise(0);
+ return;
+ }
+ do {
+ div <<= 1;
+ carry = (l_dvd >= l_s) ? 0 : 1;
+
+ if (h_dvd < (h_s + carry)) {
+ h_s >>= 1;
+ l_s = s << (--counter);
+ continue;
+ }
+ else {
+ h_dvd -= (h_s + carry);
+ l_dvd = carry ? ((0xFFFFFFFF - l_s) + l_dvd + 1)
+ : (l_dvd - l_s);
+ h_s >>= 1;
+ l_s = s << (--counter);
+ div |= 1;
+ continue;
+ }
+
+ } while (counter > -1);
+ /* overflow */
+ if (h_dvd || (l_dvd > s)) {
+ x86emu_intr_raise(0);
+ return;
+ }
+ mod = l_dvd;
#endif
- CLEAR_FLAG(F_CF);
- CLEAR_FLAG(F_AF);
- CLEAR_FLAG(F_SF);
- SET_FLAG(F_ZF);
- CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF);
+ CLEAR_FLAG(F_CF);
+ CLEAR_FLAG(F_AF);
+ CLEAR_FLAG(F_SF);
+ SET_FLAG(F_ZF);
+ CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF);
- M.x86.R_EAX = (u32)div;
- M.x86.R_EDX = (u32)mod;
+ M.x86.R_EAX = (u32) div;
+ M.x86.R_EDX = (u32) mod;
}
/****************************************************************************
REMARKS:
Implements the IN string instruction and side effects.
****************************************************************************/
-void ins(int size)
+void
+ins(int size)
{
- int inc = size;
+ int inc = size;
- if (ACCESS_FLAG(F_DF)) {
- inc = -size;
- }
- if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
+ if (ACCESS_FLAG(F_DF)) {
+ inc = -size;
+ }
+ if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
/* dont care whether REPE or REPNE */
/* in until CX is ZERO. */
- u32 count = ((M.x86.mode & SYSMODE_PREFIX_DATA) ?
- M.x86.R_ECX : M.x86.R_CX);
+ u32 count = ((M.x86.mode & SYSMODE_PREFIX_DATA) ?
+ M.x86.R_ECX : M.x86.R_CX);
switch (size) {
- case 1:
+ case 1:
while (count--) {
- store_data_byte_abs(M.x86.R_ES, M.x86.R_DI,
- (*sys_inb)(M.x86.R_DX));
- M.x86.R_DI += inc;
+ store_data_byte_abs(M.x86.R_ES, M.x86.R_DI,
+ (*sys_inb) (M.x86.R_DX));
+ M.x86.R_DI += inc;
}
break;
- case 2:
+ case 2:
while (count--) {
- store_data_word_abs(M.x86.R_ES, M.x86.R_DI,
- (*sys_inw)(M.x86.R_DX));
- M.x86.R_DI += inc;
+ store_data_word_abs(M.x86.R_ES, M.x86.R_DI,
+ (*sys_inw) (M.x86.R_DX));
+ M.x86.R_DI += inc;
}
break;
- case 4:
+ case 4:
while (count--) {
- store_data_long_abs(M.x86.R_ES, M.x86.R_DI,
- (*sys_inl)(M.x86.R_DX));
- M.x86.R_DI += inc;
+ store_data_long_abs(M.x86.R_ES, M.x86.R_DI,
+ (*sys_inl) (M.x86.R_DX));
+ M.x86.R_DI += inc;
break;
}
}
- M.x86.R_CX = 0;
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_ECX = 0;
+ M.x86.R_CX = 0;
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_ECX = 0;
}
- M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
- } else {
+ M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
+ }
+ else {
switch (size) {
- case 1:
- store_data_byte_abs(M.x86.R_ES, M.x86.R_DI,
- (*sys_inb)(M.x86.R_DX));
+ case 1:
+ store_data_byte_abs(M.x86.R_ES, M.x86.R_DI,
+ (*sys_inb) (M.x86.R_DX));
break;
- case 2:
- store_data_word_abs(M.x86.R_ES, M.x86.R_DI,
- (*sys_inw)(M.x86.R_DX));
+ case 2:
+ store_data_word_abs(M.x86.R_ES, M.x86.R_DI,
+ (*sys_inw) (M.x86.R_DX));
break;
- case 4:
- store_data_long_abs(M.x86.R_ES, M.x86.R_DI,
- (*sys_inl)(M.x86.R_DX));
+ case 4:
+ store_data_long_abs(M.x86.R_ES, M.x86.R_DI,
+ (*sys_inl) (M.x86.R_DX));
break;
}
- M.x86.R_DI += inc;
+ M.x86.R_DI += inc;
}
}
@@ -2524,63 +2654,65 @@ void ins(int size)
REMARKS:
Implements the OUT string instruction and side effects.
****************************************************************************/
-void outs(int size)
+void
+outs(int size)
{
int inc = size;
- if (ACCESS_FLAG(F_DF)) {
+ if (ACCESS_FLAG(F_DF)) {
inc = -size;
}
- if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
+ if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
/* dont care whether REPE or REPNE */
/* out until CX is ZERO. */
- u32 count = ((M.x86.mode & SYSMODE_PREFIX_DATA) ?
- M.x86.R_ECX : M.x86.R_CX);
+ u32 count = ((M.x86.mode & SYSMODE_PREFIX_DATA) ?
+ M.x86.R_ECX : M.x86.R_CX);
switch (size) {
- case 1:
+ case 1:
while (count--) {
- (*sys_outb)(M.x86.R_DX,
- fetch_data_byte_abs(M.x86.R_ES, M.x86.R_SI));
- M.x86.R_SI += inc;
+ (*sys_outb) (M.x86.R_DX,
+ fetch_data_byte_abs(M.x86.R_ES, M.x86.R_SI));
+ M.x86.R_SI += inc;
}
break;
- case 2:
+ case 2:
while (count--) {
- (*sys_outw)(M.x86.R_DX,
- fetch_data_word_abs(M.x86.R_ES, M.x86.R_SI));
- M.x86.R_SI += inc;
+ (*sys_outw) (M.x86.R_DX,
+ fetch_data_word_abs(M.x86.R_ES, M.x86.R_SI));
+ M.x86.R_SI += inc;
}
break;
- case 4:
+ case 4:
while (count--) {
- (*sys_outl)(M.x86.R_DX,
- fetch_data_long_abs(M.x86.R_ES, M.x86.R_SI));
- M.x86.R_SI += inc;
+ (*sys_outl) (M.x86.R_DX,
+ fetch_data_long_abs(M.x86.R_ES, M.x86.R_SI));
+ M.x86.R_SI += inc;
break;
}
}
- M.x86.R_CX = 0;
- if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- M.x86.R_ECX = 0;
+ M.x86.R_CX = 0;
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ M.x86.R_ECX = 0;
}
- M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
- } else {
+ M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
+ }
+ else {
switch (size) {
- case 1:
- (*sys_outb)(M.x86.R_DX,
- fetch_data_byte_abs(M.x86.R_ES, M.x86.R_SI));
+ case 1:
+ (*sys_outb) (M.x86.R_DX,
+ fetch_data_byte_abs(M.x86.R_ES, M.x86.R_SI));
break;
- case 2:
- (*sys_outw)(M.x86.R_DX,
- fetch_data_word_abs(M.x86.R_ES, M.x86.R_SI));
+ case 2:
+ (*sys_outw) (M.x86.R_DX,
+ fetch_data_word_abs(M.x86.R_ES, M.x86.R_SI));
break;
- case 4:
- (*sys_outl)(M.x86.R_DX,
- fetch_data_long_abs(M.x86.R_ES, M.x86.R_SI));
+ case 4:
+ (*sys_outl) (M.x86.R_DX,
+ fetch_data_long_abs(M.x86.R_ES, M.x86.R_SI));
break;
}
- M.x86.R_SI += inc;
+ M.x86.R_SI += inc;
}
}
@@ -2591,11 +2723,12 @@ addr - Address to fetch word from
REMARKS:
Fetches a word from emulator memory using an absolute address.
****************************************************************************/
-u16 mem_access_word(int addr)
+u16
+mem_access_word(int addr)
{
-DB( if (CHECK_MEM_ACCESS())
- x86emu_check_mem_access(addr);)
- return (*sys_rdw)(addr);
+ DB(if (CHECK_MEM_ACCESS())
+ x86emu_check_mem_access(addr);)
+ return (*sys_rdw) (addr);
}
/****************************************************************************
@@ -2604,12 +2737,13 @@ Pushes a word onto the stack.
NOTE: Do not inline this, as (*sys_wrX) is already inline!
****************************************************************************/
-void push_word(u16 w)
+void
+push_word(u16 w)
{
-DB( if (CHECK_SP_ACCESS())
- x86emu_check_sp_access();)
- M.x86.R_SP -= 2;
- (*sys_wrw)(((u32)M.x86.R_SS << 4) + M.x86.R_SP, w);
+ DB(if (CHECK_SP_ACCESS())
+ x86emu_check_sp_access();)
+ M.x86.R_SP -= 2;
+ (*sys_wrw) (((u32) M.x86.R_SS << 4) + M.x86.R_SP, w);
}
/****************************************************************************
@@ -2618,12 +2752,13 @@ Pushes a long onto the stack.
NOTE: Do not inline this, as (*sys_wrX) is already inline!
****************************************************************************/
-void push_long(u32 w)
+void
+push_long(u32 w)
{
-DB( if (CHECK_SP_ACCESS())
- x86emu_check_sp_access();)
- M.x86.R_SP -= 4;
- (*sys_wrl)(((u32)M.x86.R_SS << 4) + M.x86.R_SP, w);
+ DB(if (CHECK_SP_ACCESS())
+ x86emu_check_sp_access();)
+ M.x86.R_SP -= 4;
+ (*sys_wrl) (((u32) M.x86.R_SS << 4) + M.x86.R_SP, w);
}
/****************************************************************************
@@ -2632,15 +2767,16 @@ Pops a word from the stack.
NOTE: Do not inline this, as (*sys_rdX) is already inline!
****************************************************************************/
-u16 pop_word(void)
+u16
+pop_word(void)
{
- register u16 res;
+ register u16 res;
-DB( if (CHECK_SP_ACCESS())
- x86emu_check_sp_access();)
- res = (*sys_rdw)(((u32)M.x86.R_SS << 4) + M.x86.R_SP);
- M.x86.R_SP += 2;
- return res;
+ DB(if (CHECK_SP_ACCESS())
+ x86emu_check_sp_access();)
+ res = (*sys_rdw) (((u32) M.x86.R_SS << 4) + M.x86.R_SP);
+ M.x86.R_SP += 2;
+ return res;
}
/****************************************************************************
@@ -2649,14 +2785,15 @@ Pops a long from the stack.
NOTE: Do not inline this, as (*sys_rdX) is already inline!
****************************************************************************/
-u32 pop_long(void)
+u32
+pop_long(void)
{
register u32 res;
-DB( if (CHECK_SP_ACCESS())
- x86emu_check_sp_access();)
- res = (*sys_rdl)(((u32)M.x86.R_SS << 4) + M.x86.R_SP);
- M.x86.R_SP += 4;
+ DB(if (CHECK_SP_ACCESS())
+ x86emu_check_sp_access();)
+ res = (*sys_rdl) (((u32) M.x86.R_SS << 4) + M.x86.R_SP);
+ M.x86.R_SP += 4;
return res;
}
@@ -2664,7 +2801,8 @@ DB( if (CHECK_SP_ACCESS())
REMARKS:
CPUID takes EAX/ECX as inputs, writes EAX/EBX/ECX/EDX as output
****************************************************************************/
-void cpuid (void)
+void
+cpuid(void)
{
u32 feature = M.x86.R_EAX;
@@ -2674,15 +2812,15 @@ void cpuid (void)
* first two features, and the results of those are sanitized.
*/
if (feature <= 1)
- hw_cpuid(&M.x86.R_EAX, &M.x86.R_EBX, &M.x86.R_ECX, &M.x86.R_EDX);
+ hw_cpuid(&M.x86.R_EAX, &M.x86.R_EBX, &M.x86.R_ECX, &M.x86.R_EDX);
#endif
switch (feature) {
case 0:
/* Regardless if we have real data from the hardware, the emulator
- * will only support upto feature 1, which we set in register EAX.
- * Registers EBX:EDX:ECX contain a string identifying the CPU.
- */
+ * will only support upto feature 1, which we set in register EAX.
+ * Registers EBX:EDX:ECX contain a string identifying the CPU.
+ */
M.x86.R_EAX = 1;
#ifndef X86EMU_HAS_HW_CPUID
/* EBX:EDX:ECX = "GenuineIntel" */
@@ -2694,24 +2832,24 @@ void cpuid (void)
case 1:
#ifndef X86EMU_HAS_HW_CPUID
/* If we don't have x86 compatible hardware, we return values from an
- * Intel 486dx4; which was one of the first processors to have CPUID.
- */
+ * Intel 486dx4; which was one of the first processors to have CPUID.
+ */
M.x86.R_EAX = 0x00000480;
M.x86.R_EBX = 0x00000000;
M.x86.R_ECX = 0x00000000;
- M.x86.R_EDX = 0x00000002; /* VME */
+ M.x86.R_EDX = 0x00000002; /* VME */
#else
/* In the case that we have hardware CPUID instruction, we make sure
- * that the features reported are limited to TSC and VME.
- */
+ * that the features reported are limited to TSC and VME.
+ */
M.x86.R_EDX &= 0x00000012;
#endif
break;
default:
/* Finally, we don't support any additional features. Most CPUs
- * return all zeros when queried for invalid or unsupported feature
- * numbers.
- */
+ * return all zeros when queried for invalid or unsupported feature
+ * numbers.
+ */
M.x86.R_EAX = 0;
M.x86.R_EBX = 0;
M.x86.R_ECX = 0;
@@ -2719,4 +2857,3 @@ void cpuid (void)
break;
}
}
-
diff --git a/xorg-server/hw/xfree86/x86emu/sys.c b/xorg-server/hw/xfree86/x86emu/sys.c
index f389767f1..c514ddeea 100644
--- a/xorg-server/hw/xfree86/x86emu/sys.c
+++ b/xorg-server/hw/xfree86/x86emu/sys.c
@@ -47,101 +47,131 @@
#include "x86emu/prim_ops.h"
#ifndef NO_SYS_HEADERS
#include <string.h>
-#endif
+#endif
-# ifdef __GNUC__
+#ifdef __GNUC__
/* Define some packed structures to use with unaligned accesses */
-struct __una_u64 { u64 x __attribute__((packed)); };
-struct __una_u32 { u32 x __attribute__((packed)); };
-struct __una_u16 { u16 x __attribute__((packed)); };
+struct __una_u64 {
+ u64 x __attribute__ ((packed));
+};
+struct __una_u32 {
+ u32 x __attribute__ ((packed));
+};
+struct __una_u16 {
+ u16 x __attribute__ ((packed));
+};
/* Elemental unaligned loads */
-static __inline__ u64 ldq_u(u64 *p)
+static __inline__ u64
+ldq_u(u64 * p)
{
- const struct __una_u64 *ptr = (const struct __una_u64 *) p;
- return ptr->x;
+ const struct __una_u64 *ptr = (const struct __una_u64 *) p;
+
+ return ptr->x;
}
-static __inline__ u32 ldl_u(u32 *p)
+static __inline__ u32
+ldl_u(u32 * p)
{
- const struct __una_u32 *ptr = (const struct __una_u32 *) p;
- return ptr->x;
+ const struct __una_u32 *ptr = (const struct __una_u32 *) p;
+
+ return ptr->x;
}
-static __inline__ u16 ldw_u(u16 *p)
+static __inline__ u16
+ldw_u(u16 * p)
{
- const struct __una_u16 *ptr = (const struct __una_u16 *) p;
- return ptr->x;
+ const struct __una_u16 *ptr = (const struct __una_u16 *) p;
+
+ return ptr->x;
}
/* Elemental unaligned stores */
-static __inline__ void stq_u(u64 val, u64 *p)
+static __inline__ void
+stq_u(u64 val, u64 * p)
{
- struct __una_u64 *ptr = (struct __una_u64 *) p;
- ptr->x = val;
+ struct __una_u64 *ptr = (struct __una_u64 *) p;
+
+ ptr->x = val;
}
-static __inline__ void stl_u(u32 val, u32 *p)
+static __inline__ void
+stl_u(u32 val, u32 * p)
{
- struct __una_u32 *ptr = (struct __una_u32 *) p;
- ptr->x = val;
+ struct __una_u32 *ptr = (struct __una_u32 *) p;
+
+ ptr->x = val;
}
-static __inline__ void stw_u(u16 val, u16 *p)
+static __inline__ void
+stw_u(u16 val, u16 * p)
{
- struct __una_u16 *ptr = (struct __una_u16 *) p;
- ptr->x = val;
+ struct __una_u16 *ptr = (struct __una_u16 *) p;
+
+ ptr->x = val;
}
-# else /* !__GNUC__ */
+#else /* !__GNUC__ */
-static __inline__ u64 ldq_u(u64 *p)
+static __inline__ u64
+ldq_u(u64 * p)
{
- u64 ret;
- memmove(&ret, p, sizeof(*p));
- return ret;
+ u64 ret;
+
+ memmove(&ret, p, sizeof(*p));
+ return ret;
}
-static __inline__ u32 ldl_u(u32 *p)
+static __inline__ u32
+ldl_u(u32 * p)
{
- u32 ret;
- memmove(&ret, p, sizeof(*p));
- return ret;
+ u32 ret;
+
+ memmove(&ret, p, sizeof(*p));
+ return ret;
}
-static __inline__ u16 ldw_u(u16 *p)
+static __inline__ u16
+ldw_u(u16 * p)
{
- u16 ret;
- memmove(&ret, p, sizeof(*p));
- return ret;
+ u16 ret;
+
+ memmove(&ret, p, sizeof(*p));
+ return ret;
}
-static __inline__ void stq_u(u64 val, u64 *p)
+static __inline__ void
+stq_u(u64 val, u64 * p)
{
- u64 tmp = val;
- memmove(p, &tmp, sizeof(*p));
+ u64 tmp = val;
+
+ memmove(p, &tmp, sizeof(*p));
}
-static __inline__ void stl_u(u32 val, u32 *p)
+static __inline__ void
+stl_u(u32 val, u32 * p)
{
- u32 tmp = val;
- memmove(p, &tmp, sizeof(*p));
+ u32 tmp = val;
+
+ memmove(p, &tmp, sizeof(*p));
}
-static __inline__ void stw_u(u16 val, u16 *p)
+static __inline__ void
+stw_u(u16 val, u16 * p)
{
- u16 tmp = val;
- memmove(p, &tmp, sizeof(*p));
+ u16 tmp = val;
+
+ memmove(p, &tmp, sizeof(*p));
}
-# endif /* __GNUC__ */
+#endif /* __GNUC__ */
/*------------------------- Global Variables ------------------------------*/
-X86EMU_sysEnv _X86EMU_env; /* Global emulator machine state */
-X86EMU_intrFuncs _X86EMU_intrTab[256];
+X86EMU_sysEnv _X86EMU_env; /* Global emulator machine state */
+X86EMU_intrFuncs _X86EMU_intrTab[256];
/*----------------------------- Implementation ----------------------------*/
@@ -155,19 +185,20 @@ Byte value read from emulator memory.
REMARKS:
Reads a byte value from the emulator memory.
****************************************************************************/
-u8 X86API rdb(
- u32 addr)
+u8 X86API
+rdb(u32 addr)
{
- u8 val;
-
- if (addr > M.mem_size - 1) {
- DB(printk("mem_read: address %#lx out of range!\n", addr);)
- HALT_SYS();
- }
- val = *(u8*)(M.mem_base + addr);
-DB( if (DEBUG_MEM_TRACE())
- printk("%#08x 1 -> %#x\n", addr, val);)
- return val;
+ u8 val;
+
+ if (addr > M.mem_size - 1) {
+ DB(printk("mem_read: address %#lx out of range!\n", addr);
+ )
+ HALT_SYS();
+ }
+ val = *(u8 *) (M.mem_base + addr);
+ DB(if (DEBUG_MEM_TRACE())
+ printk("%#08x 1 -> %#x\n", addr, val);)
+ return val;
}
/****************************************************************************
@@ -180,26 +211,27 @@ Word value read from emulator memory.
REMARKS:
Reads a word value from the emulator memory.
****************************************************************************/
-u16 X86API rdw(
- u32 addr)
+u16 X86API
+rdw(u32 addr)
{
- u16 val = 0;
+ u16 val = 0;
- if (addr > M.mem_size - 2) {
- DB(printk("mem_read: address %#lx out of range!\n", addr);)
- HALT_SYS();
- }
+ if (addr > M.mem_size - 2) {
+ DB(printk("mem_read: address %#lx out of range!\n", addr);
+ )
+ HALT_SYS();
+ }
#ifdef __BIG_ENDIAN__
- if (addr & 0x1) {
- val = (*(u8*)(M.mem_base + addr) |
- (*(u8*)(M.mem_base + addr + 1) << 8));
- }
- else
+ if (addr & 0x1) {
+ val = (*(u8 *) (M.mem_base + addr) |
+ (*(u8 *) (M.mem_base + addr + 1) << 8));
+ }
+ else
#endif
- val = ldw_u((u16*)(M.mem_base + addr));
- DB( if (DEBUG_MEM_TRACE())
- printk("%#08x 2 -> %#x\n", addr, val);)
- return val;
+ val = ldw_u((u16 *) (M.mem_base + addr));
+ DB(if (DEBUG_MEM_TRACE())
+ printk("%#08x 2 -> %#x\n", addr, val);)
+ return val;
}
/****************************************************************************
@@ -211,28 +243,29 @@ Long value read from emulator memory.
REMARKS:
Reads a long value from the emulator memory.
****************************************************************************/
-u32 X86API rdl(
- u32 addr)
+u32 X86API
+rdl(u32 addr)
{
- u32 val = 0;
+ u32 val = 0;
- if (addr > M.mem_size - 4) {
- DB(printk("mem_read: address %#lx out of range!\n", addr);)
- HALT_SYS();
- }
+ if (addr > M.mem_size - 4) {
+ DB(printk("mem_read: address %#lx out of range!\n", addr);
+ )
+ HALT_SYS();
+ }
#ifdef __BIG_ENDIAN__
- if (addr & 0x3) {
- val = (*(u8*)(M.mem_base + addr + 0) |
- (*(u8*)(M.mem_base + addr + 1) << 8) |
- (*(u8*)(M.mem_base + addr + 2) << 16) |
- (*(u8*)(M.mem_base + addr + 3) << 24));
- }
- else
+ if (addr & 0x3) {
+ val = (*(u8 *) (M.mem_base + addr + 0) |
+ (*(u8 *) (M.mem_base + addr + 1) << 8) |
+ (*(u8 *) (M.mem_base + addr + 2) << 16) |
+ (*(u8 *) (M.mem_base + addr + 3) << 24));
+ }
+ else
#endif
- val = ldl_u((u32*)(M.mem_base + addr));
-DB( if (DEBUG_MEM_TRACE())
- printk("%#08x 4 -> %#x\n", addr, val);)
- return val;
+ val = ldl_u((u32 *) (M.mem_base + addr));
+ DB(if (DEBUG_MEM_TRACE())
+ printk("%#08x 4 -> %#x\n", addr, val);)
+ return val;
}
/****************************************************************************
@@ -243,17 +276,17 @@ val - Value to store
REMARKS:
Writes a byte value to emulator memory.
****************************************************************************/
-void X86API wrb(
- u32 addr,
- u8 val)
+void X86API
+wrb(u32 addr, u8 val)
{
-DB( if (DEBUG_MEM_TRACE())
- printk("%#08x 1 <- %#x\n", addr, val);)
- if (addr > M.mem_size - 1) {
- DB(printk("mem_write: address %#lx out of range!\n", addr);)
- HALT_SYS();
- }
- *(u8*)(M.mem_base + addr) = val;
+ DB(if (DEBUG_MEM_TRACE())
+ printk("%#08x 1 <- %#x\n", addr, val);)
+ if (addr > M.mem_size - 1) {
+ DB(printk("mem_write: address %#lx out of range!\n", addr);
+ )
+ HALT_SYS();
+ }
+ *(u8 *) (M.mem_base + addr) = val;
}
/****************************************************************************
@@ -264,24 +297,24 @@ val - Value to store
REMARKS:
Writes a word value to emulator memory.
****************************************************************************/
-void X86API wrw(
- u32 addr,
- u16 val)
+void X86API
+wrw(u32 addr, u16 val)
{
-DB( if (DEBUG_MEM_TRACE())
- printk("%#08x 2 <- %#x\n", addr, val);)
- if (addr > M.mem_size - 2) {
- DB(printk("mem_write: address %#lx out of range!\n", addr);)
- HALT_SYS();
- }
+ DB(if (DEBUG_MEM_TRACE())
+ printk("%#08x 2 <- %#x\n", addr, val);)
+ if (addr > M.mem_size - 2) {
+ DB(printk("mem_write: address %#lx out of range!\n", addr);
+ )
+ HALT_SYS();
+ }
#ifdef __BIG_ENDIAN__
- if (addr & 0x1) {
- *(u8*)(M.mem_base + addr + 0) = (val >> 0) & 0xff;
- *(u8*)(M.mem_base + addr + 1) = (val >> 8) & 0xff;
- }
- else
+ if (addr & 0x1) {
+ *(u8 *) (M.mem_base + addr + 0) = (val >> 0) & 0xff;
+ *(u8 *) (M.mem_base + addr + 1) = (val >> 8) & 0xff;
+ }
+ else
#endif
- stw_u(val,(u16*)(M.mem_base + addr));
+ stw_u(val, (u16 *) (M.mem_base + addr));
}
/****************************************************************************
@@ -292,26 +325,26 @@ val - Value to store
REMARKS:
Writes a long value to emulator memory.
****************************************************************************/
-void X86API wrl(
- u32 addr,
- u32 val)
+void X86API
+wrl(u32 addr, u32 val)
{
-DB( if (DEBUG_MEM_TRACE())
- printk("%#08x 4 <- %#x\n", addr, val);)
- if (addr > M.mem_size - 4) {
- DB(printk("mem_write: address %#lx out of range!\n", addr);)
- HALT_SYS();
- }
+ DB(if (DEBUG_MEM_TRACE())
+ printk("%#08x 4 <- %#x\n", addr, val);)
+ if (addr > M.mem_size - 4) {
+ DB(printk("mem_write: address %#lx out of range!\n", addr);
+ )
+ HALT_SYS();
+ }
#ifdef __BIG_ENDIAN__
- if (addr & 0x1) {
- *(u8*)(M.mem_base + addr + 0) = (val >> 0) & 0xff;
- *(u8*)(M.mem_base + addr + 1) = (val >> 8) & 0xff;
- *(u8*)(M.mem_base + addr + 2) = (val >> 16) & 0xff;
- *(u8*)(M.mem_base + addr + 3) = (val >> 24) & 0xff;
- }
- else
+ if (addr & 0x1) {
+ *(u8 *) (M.mem_base + addr + 0) = (val >> 0) & 0xff;
+ *(u8 *) (M.mem_base + addr + 1) = (val >> 8) & 0xff;
+ *(u8 *) (M.mem_base + addr + 2) = (val >> 16) & 0xff;
+ *(u8 *) (M.mem_base + addr + 3) = (val >> 24) & 0xff;
+ }
+ else
#endif
- stl_u(val,(u32*)(M.mem_base + addr));
+ stl_u(val, (u32 *) (M.mem_base + addr));
}
/****************************************************************************
@@ -322,12 +355,12 @@ RETURN:
REMARKS:
Default PIO byte read function. Doesn't perform real inb.
****************************************************************************/
-static u8 X86API p_inb(
- X86EMU_pioAddr addr)
+static u8 X86API
+p_inb(X86EMU_pioAddr addr)
{
-DB( if (DEBUG_IO_TRACE())
- printk("inb %#04x \n", addr);)
- return 0;
+ DB(if (DEBUG_IO_TRACE())
+ printk("inb %#04x \n", addr);)
+ return 0;
}
/****************************************************************************
@@ -338,12 +371,12 @@ RETURN:
REMARKS:
Default PIO word read function. Doesn't perform real inw.
****************************************************************************/
-static u16 X86API p_inw(
- X86EMU_pioAddr addr)
+static u16 X86API
+p_inw(X86EMU_pioAddr addr)
{
-DB( if (DEBUG_IO_TRACE())
- printk("inw %#04x \n", addr);)
- return 0;
+ DB(if (DEBUG_IO_TRACE())
+ printk("inw %#04x \n", addr);)
+ return 0;
}
/****************************************************************************
@@ -354,12 +387,12 @@ RETURN:
REMARKS:
Default PIO long read function. Doesn't perform real inl.
****************************************************************************/
-static u32 X86API p_inl(
- X86EMU_pioAddr addr)
+static u32 X86API
+p_inl(X86EMU_pioAddr addr)
{
-DB( if (DEBUG_IO_TRACE())
- printk("inl %#04x \n", addr);)
- return 0;
+ DB(if (DEBUG_IO_TRACE())
+ printk("inl %#04x \n", addr);)
+ return 0;
}
/****************************************************************************
@@ -369,13 +402,12 @@ val - Value to store
REMARKS:
Default PIO byte write function. Doesn't perform real outb.
****************************************************************************/
-static void X86API p_outb(
- X86EMU_pioAddr addr,
- u8 val)
+static void X86API
+p_outb(X86EMU_pioAddr addr, u8 val)
{
-DB( if (DEBUG_IO_TRACE())
- printk("outb %#02x -> %#04x \n", val, addr);)
- return;
+ DB(if (DEBUG_IO_TRACE())
+ printk("outb %#02x -> %#04x \n", val, addr);)
+ return;
}
/****************************************************************************
@@ -385,13 +417,12 @@ val - Value to store
REMARKS:
Default PIO word write function. Doesn't perform real outw.
****************************************************************************/
-static void X86API p_outw(
- X86EMU_pioAddr addr,
- u16 val)
+static void X86API
+p_outw(X86EMU_pioAddr addr, u16 val)
{
-DB( if (DEBUG_IO_TRACE())
- printk("outw %#04x -> %#04x \n", val, addr);)
- return;
+ DB(if (DEBUG_IO_TRACE())
+ printk("outw %#04x -> %#04x \n", val, addr);)
+ return;
}
/****************************************************************************
@@ -401,29 +432,29 @@ val - Value to store
REMARKS:
Default PIO ;ong write function. Doesn't perform real outl.
****************************************************************************/
-static void X86API p_outl(
- X86EMU_pioAddr addr,
- u32 val)
+static void X86API
+p_outl(X86EMU_pioAddr addr, u32 val)
{
-DB( if (DEBUG_IO_TRACE())
- printk("outl %#08x -> %#04x \n", val, addr);)
- return;
+ DB(if (DEBUG_IO_TRACE())
+ printk("outl %#08x -> %#04x \n", val, addr);)
+ return;
}
/*------------------------- Global Variables ------------------------------*/
-u8 (X86APIP sys_rdb)(u32 addr) = rdb;
-u16 (X86APIP sys_rdw)(u32 addr) = rdw;
-u32 (X86APIP sys_rdl)(u32 addr) = rdl;
-void (X86APIP sys_wrb)(u32 addr,u8 val) = wrb;
-void (X86APIP sys_wrw)(u32 addr,u16 val) = wrw;
-void (X86APIP sys_wrl)(u32 addr,u32 val) = wrl;
-u8 (X86APIP sys_inb)(X86EMU_pioAddr addr) = p_inb;
-u16 (X86APIP sys_inw)(X86EMU_pioAddr addr) = p_inw;
-u32 (X86APIP sys_inl)(X86EMU_pioAddr addr) = p_inl;
-void (X86APIP sys_outb)(X86EMU_pioAddr addr, u8 val) = p_outb;
-void (X86APIP sys_outw)(X86EMU_pioAddr addr, u16 val) = p_outw;
-void (X86APIP sys_outl)(X86EMU_pioAddr addr, u32 val) = p_outl;
+u8(X86APIP sys_rdb) (u32 addr) = rdb;
+u16(X86APIP sys_rdw) (u32 addr) = rdw;
+u32(X86APIP sys_rdl) (u32 addr) = rdl;
+void (X86APIP sys_wrb) (u32 addr, u8 val) = wrb;
+void (X86APIP sys_wrw) (u32 addr, u16 val) = wrw;
+void (X86APIP sys_wrl) (u32 addr, u32 val) = wrl;
+
+u8(X86APIP sys_inb) (X86EMU_pioAddr addr) = p_inb;
+u16(X86APIP sys_inw) (X86EMU_pioAddr addr) = p_inw;
+u32(X86APIP sys_inl) (X86EMU_pioAddr addr) = p_inl;
+void (X86APIP sys_outb) (X86EMU_pioAddr addr, u8 val) = p_outb;
+void (X86APIP sys_outw) (X86EMU_pioAddr addr, u16 val) = p_outw;
+void (X86APIP sys_outl) (X86EMU_pioAddr addr, u32 val) = p_outl;
/*----------------------------- Setup -------------------------------------*/
@@ -436,8 +467,8 @@ This function is used to set the pointers to functions which access
memory space, allowing the user application to override these functions
and hook them out as necessary for their application.
****************************************************************************/
-void X86EMU_setupMemFuncs(
- X86EMU_memFuncs *funcs)
+void
+X86EMU_setupMemFuncs(X86EMU_memFuncs * funcs)
{
sys_rdb = funcs->rdb;
sys_rdw = funcs->rdw;
@@ -456,8 +487,8 @@ This function is used to set the pointers to functions which access
I/O space, allowing the user application to override these functions
and hook them out as necessary for their application.
****************************************************************************/
-void X86EMU_setupPioFuncs(
- X86EMU_pioFuncs *funcs)
+void
+X86EMU_setupPioFuncs(X86EMU_pioFuncs * funcs)
{
sys_inb = funcs->inb;
sys_inw = funcs->inw;
@@ -480,17 +511,17 @@ in the emulator via the interrupt vector table. This allows the application
to get control when the code being emulated executes specific software
interrupts.
****************************************************************************/
-void X86EMU_setupIntrFuncs(
- X86EMU_intrFuncs funcs[])
+void
+X86EMU_setupIntrFuncs(X86EMU_intrFuncs funcs[])
{
int i;
-
- for (i=0; i < 256; i++)
- _X86EMU_intrTab[i] = NULL;
- if (funcs) {
- for (i = 0; i < 256; i++)
- _X86EMU_intrTab[i] = funcs[i];
- }
+
+ for (i = 0; i < 256; i++)
+ _X86EMU_intrTab[i] = NULL;
+ if (funcs) {
+ for (i = 0; i < 256; i++)
+ _X86EMU_intrTab[i] = funcs[i];
+ }
}
/****************************************************************************
@@ -505,15 +536,15 @@ so that the code in the emulator will continue processing the software
interrupt as per normal. This essentially allows system code to actively
hook and handle certain software interrupts as necessary.
****************************************************************************/
-void X86EMU_prepareForInt(
- int num)
+void
+X86EMU_prepareForInt(int num)
{
- push_word((u16)M.x86.R_FLG);
+ push_word((u16) M.x86.R_FLG);
CLEAR_FLAG(F_IF);
CLEAR_FLAG(F_TF);
push_word(M.x86.R_CS);
M.x86.R_CS = mem_access_word(num * 4 + 2);
push_word(M.x86.R_IP);
M.x86.R_IP = mem_access_word(num * 4);
- M.x86.intr = 0;
+ M.x86.intr = 0;
}
diff --git a/xorg-server/hw/xfree86/x86emu/validate.c b/xorg-server/hw/xfree86/x86emu/validate.c
index b8c4d12d1..4c36e1df5 100644
--- a/xorg-server/hw/xfree86/x86emu/validate.c
+++ b/xorg-server/hw/xfree86/x86emu/validate.c
@@ -591,58 +591,62 @@
printk("passed\n"); \
}
-void printk(const char *fmt, ...)
+void
+printk(const char *fmt, ...)
{
va_list argptr;
+
va_start(argptr, fmt);
vfprintf(stdout, fmt, argptr);
fflush(stdout);
va_end(argptr);
}
-char * print_flags(char *buf,ulong flags)
+char *
+print_flags(char *buf, ulong flags)
{
char *separator = "";
buf[0] = 0;
if (flags & F_CF) {
- strcat(buf,separator);
- strcat(buf,"CF");
+ strcat(buf, separator);
+ strcat(buf, "CF");
separator = ",";
- }
+ }
if (flags & F_PF) {
- strcat(buf,separator);
- strcat(buf,"PF");
+ strcat(buf, separator);
+ strcat(buf, "PF");
separator = ",";
- }
+ }
if (flags & F_AF) {
- strcat(buf,separator);
- strcat(buf,"AF");
+ strcat(buf, separator);
+ strcat(buf, "AF");
separator = ",";
- }
+ }
if (flags & F_ZF) {
- strcat(buf,separator);
- strcat(buf,"ZF");
+ strcat(buf, separator);
+ strcat(buf, "ZF");
separator = ",";
- }
+ }
if (flags & F_SF) {
- strcat(buf,separator);
- strcat(buf,"SF");
+ strcat(buf, separator);
+ strcat(buf, "SF");
separator = ",";
- }
+ }
if (flags & F_OF) {
- strcat(buf,separator);
- strcat(buf,"OF");
+ strcat(buf, separator);
+ strcat(buf, "OF");
separator = ",";
- }
+ }
if (separator[0] == 0)
- strcpy(buf,"None");
+ strcpy(buf, "None");
return buf;
}
-int main(int argc)
+int
+main(int argc)
{
- ulong def_flags;
+ ulong def_flags;
int trace = false;
if (argc > 1)
diff --git a/xorg-server/hw/xfree86/x86emu/x86emu/prim_x86_gcc.h b/xorg-server/hw/xfree86/x86emu/x86emu/prim_x86_gcc.h
index 4c850a1bd..646ec9def 100644
--- a/xorg-server/hw/xfree86/x86emu/x86emu/prim_x86_gcc.h
+++ b/xorg-server/hw/xfree86/x86emu/x86emu/prim_x86_gcc.h
@@ -49,31 +49,29 @@
#if defined(__PIC__) && defined(__i386__)
#define X86EMU_HAS_HW_CPUID 1
-static inline void hw_cpuid (u32 *a, u32 *b, u32 *c, u32 *d)
+static inline void
+hw_cpuid(u32 * a, u32 * b, u32 * c, u32 * d)
{
- __asm__ __volatile__ ("pushl %%ebx \n\t"
- "cpuid \n\t"
- "movl %%ebx, %1 \n\t"
- "popl %%ebx \n\t"
- : "=a" (*a), "=r" (*b),
- "=c" (*c), "=d" (*d)
- : "a" (*a), "c" (*c)
- : "cc");
+ __asm__ __volatile__("pushl %%ebx \n\t"
+ "cpuid \n\t"
+ "movl %%ebx, %1 \n\t"
+ "popl %%ebx \n\t":"=a"(*a), "=r"(*b),
+ "=c"(*c), "=d"(*d)
+ :"a"(*a), "c"(*c)
+ :"cc");
}
-#else /* ! (__PIC__ && __i386__) */
+#else /* ! (__PIC__ && __i386__) */
#define x86EMU_HAS_HW_CPUID 1
-static inline void hw_cpuid (u32 *a, u32 *b, u32 *c, u32 *d)
+static inline void
+hw_cpuid(u32 * a, u32 * b, u32 * c, u32 * d)
{
- __asm__ __volatile__ ("cpuid"
- : "=a" (*a), "=b" (*b),
- "=c" (*c), "=d" (*d)
- : "a" (*a), "c" (*c)
- : "cc");
+ __asm__ __volatile__("cpuid":"=a"(*a), "=b"(*b), "=c"(*c), "=d"(*d)
+ :"a"(*a), "c"(*c)
+ :"cc");
}
-#endif /* __PIC__ && __i386__ */
+#endif /* __PIC__ && __i386__ */
-
-#endif /* __X86EMU_PRIM_X86_GCC_H */
+#endif /* __X86EMU_PRIM_X86_GCC_H */
diff --git a/xorg-server/hw/xfree86/xaa/xaa.h b/xorg-server/hw/xfree86/xaa/xaa.h
index 6e5a2389a..b530037c9 100644
--- a/xorg-server/hw/xfree86/xaa/xaa.h
+++ b/xorg-server/hw/xfree86/xaa/xaa.h
@@ -1,1394 +1,1038 @@
-
-#ifndef _XAA_H
-#define _XAA_H
-
-#define XAA_VERSION_MAJOR 1
-#define XAA_VERSION_MINOR 2
-#define XAA_VERSION_RELEASE 1
-
-/*
-
- ******** OPERATION SPECIFIC FLAGS *********
-
- **** solid/dashed line flags ****
-
---------- --------
-23 LINE_PATTERN_LSBFIRST_MSBJUSTIFIED
-22 LINE_PATTERN_LSBFIRST_LSBJUSTIFIED
-21 LINE_PATTERN_MSBFIRST_MSBJUSTIFIED
-20 LINE_PATTERN_MSBFIRST_LSBJUSTIFIED
-19 LINE_PATTERN_POWER_OF_2_ONLY
-18 LINE_LIMIT_COORDS
-17 .
-16 .
---------- -------
-
- **** screen to screen copy flags ****
-
---------- --------
-23 ONLY_LEFT_TO_RIGHT_BITBLT
-22 ONLY_TWO_BITBLT_DIRECTIONS
-21 .
-20 .
-19 .
-18 .
-17 .
-16 .
---------- -------
-
- **** clipping flags ****
-
---------- --------
-23 .
-22 HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND
-21 HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY
-20 HARDWARE_CLIP_MONO_8x8_FILL
-19 HARDWARE_CLIP_COLOR_8x8_FILL
-18 HARDWARE_CLIP_SOLID_FILL
-17 HARDWARE_CLIP_DASHED_LINE
-16 HARDWARE_CLIP_SOLID_LINE
---------- -------
-
-
- **** hardware pattern flags ****
-
---------- --------
-23 .
-22 .
-21 HARDWARE_PATTERN_SCREEN_ORIGIN
-20 .
-19 .
-18 .
-17 HARDWARE_PATTERN_PROGRAMMED_ORIGIN
-16 HARDWARE_PATTERN_PROGRAMMED_BITS
---------- -------
-
- **** write pixmap flags ****
-
---------- --------
-23 .
-22 .
-21 .
-20 .
-19 .
-18 .
-17 .
-16 CONVERT_32BPP_TO_24BPP
---------- -------
-
-
- ******** GENERIC FLAGS *********
-
---------- -------
-15 SYNC_AFTER_COLOR_EXPAND
-14 CPU_TRANSFER_PAD_QWORD
-13 .
-12 LEFT_EDGE_CLIPPING_NEGATIVE_X
-11 LEFT_EDGE_CLIPPING
-10 CPU_TRANSFER_BASE_FIXED
- 9 BIT_ORDER_IN_BYTE_MSBFIRST
- 8 TRANSPARENCY_GXCOPY_ONLY
---------- -------
- 7 NO_TRANSPARENCY
- 6 TRANSPARENCY_ONLY
- 5 ROP_NEEDS_SOURCE
- 4 TRIPLE_BITS_24BPP
- 3 RGB_EQUAL
- 2 NO_PLANEMASK
- 1 NO_GXCOPY
- 0 GXCOPY_ONLY
---------- -------
-
-
-*/
-
-#include "gcstruct.h"
-#include "pixmapstr.h"
-#include "xf86str.h"
-#include "regionstr.h"
-#include "xf86fbman.h"
-
-#include "picturestr.h"
-
-/* Flags */
-#define PIXMAP_CACHE 0x00000001
-#define MICROSOFT_ZERO_LINE_BIAS 0x00000002
-#define OFFSCREEN_PIXMAPS 0x00000004
-#define LINEAR_FRAMEBUFFER 0x00000008
-
-
-/* GC fg, bg, and planemask restrictions */
-#define GXCOPY_ONLY 0x00000001
-#define NO_GXCOPY 0x00000002
-#define NO_PLANEMASK 0x00000004
-#define RGB_EQUAL 0x00000008
-#define TRIPLE_BITS_24BPP 0x00000010
-#define ROP_NEEDS_SOURCE 0x00000020
-
-/* transparency restrictions */
-#define TRANSPARENCY_ONLY 0x00000040
-#define NO_TRANSPARENCY 0x00000080
-#define TRANSPARENCY_GXCOPY_ONLY 0x00000100
-
-/* bit order restrictions */
-#define BIT_ORDER_IN_BYTE_MSBFIRST 0x00000200
-#define BIT_ORDER_IN_BYTE_LSBFIRST 0x00000000
-
-/* transfer base restriction */
-#define CPU_TRANSFER_BASE_FIXED 0x00000400
-
-/* skipleft restrictions */
-#define LEFT_EDGE_CLIPPING 0x00000800
-#define LEFT_EDGE_CLIPPING_NEGATIVE_X 0x00001000
-
-/* data padding */
-#define CPU_TRANSFER_PAD_DWORD 0x00000000
-#define CPU_TRANSFER_PAD_QWORD 0x00004000
-#define SCANLINE_PAD_DWORD 0x00000000
-
-#define SYNC_AFTER_COLOR_EXPAND 0x00008000
-#define SYNC_AFTER_IMAGE_WRITE SYNC_AFTER_COLOR_EXPAND
-
-/* hardware pattern */
-#define HARDWARE_PATTERN_PROGRAMMED_BITS 0x00010000
-#define HARDWARE_PATTERN_PROGRAMMED_ORIGIN 0x00020000
-#define HARDWARE_PATTERN_SCREEN_ORIGIN 0x00200000
-
-/* copyarea flags */
-#define ONLY_TWO_BITBLT_DIRECTIONS 0x00400000
-#define ONLY_LEFT_TO_RIGHT_BITBLT 0x00800000
-
-/* line flags */
-#define LINE_PATTERN_LSBFIRST_MSBJUSTIFIED 0x00800000
-#define LINE_PATTERN_LSBFIRST_LSBJUSTIFIED 0x00400000
-#define LINE_PATTERN_MSBFIRST_MSBJUSTIFIED 0x00200000
-#define LINE_PATTERN_MSBFIRST_LSBJUSTIFIED 0x00100000
-#define LINE_PATTERN_POWER_OF_2_ONLY 0x00080000
-#define LINE_LIMIT_COORDS 0x00040000
-
-/* clipping flags */
-#define HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND 0x00400000
-#define HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY 0x00200000
-#define HARDWARE_CLIP_MONO_8x8_FILL 0x00100000
-#define HARDWARE_CLIP_COLOR_8x8_FILL 0x00080000
-#define HARDWARE_CLIP_SOLID_FILL 0x00040000
-#define HARDWARE_CLIP_DASHED_LINE 0x00020000
-#define HARDWARE_CLIP_SOLID_LINE 0x00010000
-
-#define HARDWARE_CLIP_LINE 0x00000000
-
-
-/* image write flags */
-#define CONVERT_32BPP_TO_24BPP 0x00010000
-
-/* pixmap cache flags */
-#define CACHE_MONO_8x8 0x00000001
-#define CACHE_COLOR_8x8 0x00000002
-#define DO_NOT_BLIT_STIPPLES 0x00000004
-#define DO_NOT_TILE_MONO_DATA 0x00000008
-#define DO_NOT_TILE_COLOR_DATA 0x00000010
-
-
-#define DEGREES_0 0
-#define DEGREES_90 1
-#define DEGREES_180 2
-#define DEGREES_270 3
-
-#define OMIT_LAST 1
-
-/* render flags */
-
-#define XAA_RENDER_POWER_OF_2_TILE_ONLY 0x00000008
-#define XAA_RENDER_NO_SRC_ALPHA 0x00000004
-#define XAA_RENDER_IMPRECISE_ONLY 0x00000002
-#define XAA_RENDER_NO_TILE 0x00000001
-
-#define XAA_RENDER_REPEAT 0x00000001
-
-typedef void (* ValidateGCProcPtr)(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw
-);
-
-typedef struct {
- unsigned char *bits;
- int width;
- int height;
- int yoff;
- int srcwidth;
- int start;
- int end;
-} NonTEGlyphInfo, *NonTEGlyphPtr;
-
-
-typedef struct {
- int x;
- int y;
- int w;
- int h;
- int orig_w;
- int orig_h;
- unsigned long serialNumber;
- int pat0;
- int pat1;
- int fg;
- int bg;
- int trans_color;
- DDXPointPtr offsets;
- DevUnion devPrivate;
-} XAACacheInfoRec, *XAACacheInfoPtr;
-
-
-typedef struct _PixmapLink {
- PixmapPtr pPix;
- struct _PixmapLink *next;
- FBAreaPtr area;
-} PixmapLink, *PixmapLinkPtr;
-
-typedef struct _XAAInfoRec {
- ScrnInfoPtr pScrn;
- int Flags;
-
- void (*Sync)(
- ScrnInfoPtr pScrn
- );
-
- /* Restore Accel State is a driver callback that is used
- * when another screen on the same device has been active.
- * This allows multihead on a single device to work.
- * If The entityProp has IS_SHARED_ACCEL defined then this
- * function is required.
- */
-
- void (*RestoreAccelState)(
- ScrnInfoPtr pScrn
- );
-
- /***************** Low Level *****************/
-
-/* Blits */
- void (*SetupForScreenToScreenCopy)(
- ScrnInfoPtr pScrn,
- int xdir, int ydir,
- int rop,
- unsigned int planemask,
- int trans_color
- );
- int ScreenToScreenCopyFlags;
-
- void (*SubsequentScreenToScreenCopy)(
- ScrnInfoPtr pScrn,
- int xsrc, int ysrc,
- int xdst, int ydst,
- int w, int h
- );
-
-
-/* Solid fills */
- void (*SetupForSolidFill)(
- ScrnInfoPtr pScrn,
- int color,
- int rop,
- unsigned int planemask
- );
- int SolidFillFlags;
-
- void (*SubsequentSolidFillRect)(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h
- );
-
- void (*SubsequentSolidFillTrap)(
- ScrnInfoPtr pScrn,
- int y, int h,
- int left, int dxL, int dyL, int eL,
- int right, int dxR, int dyR, int eR
- );
-
-
-/* Solid lines */
-
- void (*SetupForSolidLine)(
- ScrnInfoPtr pScrn,
- int color,
- int rop,
- unsigned int planemask
- );
- int SolidLineFlags;
-
- void (*SubsequentSolidTwoPointLine)(
- ScrnInfoPtr pScrn,
- int xa, int ya, int xb, int yb, int flags
- );
-
- void (*SubsequentSolidBresenhamLine)(
- ScrnInfoPtr pScrn,
- int x, int y, int absmaj, int absmin, int err, int len, int octant
- );
- int SolidBresenhamLineErrorTermBits;
-
- void (*SubsequentSolidHorVertLine)(
- ScrnInfoPtr pScrn,
- int x, int y, int len, int dir
- );
-
-/* Dashed lines */
-
- void (*SetupForDashedLine)(
- ScrnInfoPtr pScrn,
- int fg, int bg,
- int rop,
- unsigned int planemask,
- int length,
- unsigned char *pattern
- );
- int DashedLineFlags;
- int DashPatternMaxLength;
-
- void (*SubsequentDashedTwoPointLine)(
- ScrnInfoPtr pScrn,
- int xa, int ya, int xb, int yb, int flags, int phase
- );
-
- void (*SubsequentDashedBresenhamLine)(
- ScrnInfoPtr pScrn,
- int x, int y, int absmaj, int absmin, int err, int len, int flags,
- int phase
- );
- int DashedBresenhamLineErrorTermBits;
-
-/* Clipper */
-
- void (*SetClippingRectangle) (
- ScrnInfoPtr pScrn,
- int left, int top, int right, int bottom
- );
- int ClippingFlags;
-
- void (*DisableClipping)(ScrnInfoPtr pScrn);
-
-/* 8x8 mono pattern fills */
- void (*SetupForMono8x8PatternFill)(
- ScrnInfoPtr pScrn,
- int patx, int paty,
- int fg, int bg,
- int rop,
- unsigned int planemask
- );
- int Mono8x8PatternFillFlags;
-
- void (*SubsequentMono8x8PatternFillRect)(
- ScrnInfoPtr pScrn,
- int patx, int paty,
- int x, int y, int w, int h
- );
-
- void (*SubsequentMono8x8PatternFillTrap)(
- ScrnInfoPtr pScrn,
- int patx, int paty,
- int y, int h,
- int left, int dxL, int dyL, int eL,
- int right, int dxR, int dyR, int eR
- );
-
-/* 8x8 color pattern fills */
-
- void (*SetupForColor8x8PatternFill)(
- ScrnInfoPtr pScrn,
- int patx, int paty,
- int rop,
- unsigned int planemask,
- int transparency_color
- );
- int Color8x8PatternFillFlags;
-
- void (*SubsequentColor8x8PatternFillRect)(
- ScrnInfoPtr pScrn,
- int patx, int paty,
- int x, int y, int w, int h
- );
-
- void (*SubsequentColor8x8PatternFillTrap)(
- ScrnInfoPtr pScrn,
- int patx, int paty,
- int y, int h,
- int left, int dxL, int dyL, int eL,
- int right, int dxR, int dyR, int eR
- );
-
-
-/* Color expansion */
-
- void (*SetupForCPUToScreenColorExpandFill)(
- ScrnInfoPtr pScrn,
- int fg, int bg,
- int rop,
- unsigned int planemask
- );
- int CPUToScreenColorExpandFillFlags;
-
- void (*SubsequentCPUToScreenColorExpandFill)(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- int skipleft
- );
-
- unsigned char *ColorExpandBase;
- int ColorExpandRange;
-
-
-/* Scanline color expansion */
-
- void (*SetupForScanlineCPUToScreenColorExpandFill)(
- ScrnInfoPtr pScrn,
- int fg, int bg,
- int rop,
- unsigned int planemask
- );
- int ScanlineCPUToScreenColorExpandFillFlags;
-
- void (*SubsequentScanlineCPUToScreenColorExpandFill)(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- int skipleft
- );
-
- void (*SubsequentColorExpandScanline)(
- ScrnInfoPtr pScrn,
- int bufno
- );
-
- int NumScanlineColorExpandBuffers;
- unsigned char **ScanlineColorExpandBuffers;
-
-/* Screen to screen color expansion */
-
- void (*SetupForScreenToScreenColorExpandFill) (
- ScrnInfoPtr pScrn,
- int fg, int bg,
- int rop,
- unsigned int planemask
- );
- int ScreenToScreenColorExpandFillFlags;
-
- void (*SubsequentScreenToScreenColorExpandFill)(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- int srcx, int srcy, int skipleft
- );
-
-
-/* Image transfers */
-
- void (*SetupForImageWrite)(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int transparency_color,
- int bpp, int depth
- );
- int ImageWriteFlags;
-
- void (*SubsequentImageWriteRect)(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- int skipleft
- );
- unsigned char *ImageWriteBase;
- int ImageWriteRange;
-
-/* Scanline Image transfers */
-
- void (*SetupForScanlineImageWrite)(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int transparency_color,
- int bpp, int depth
- );
- int ScanlineImageWriteFlags;
-
- void (*SubsequentScanlineImageWriteRect)(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- int skipleft
- );
-
- void (*SubsequentImageWriteScanline) (
- ScrnInfoPtr pScrn,
- int bufno
- );
-
- int NumScanlineImageWriteBuffers;
- unsigned char **ScanlineImageWriteBuffers;
-
- /* Image Reads - OBSOLETE AND NOT USED */
-
- void (*SetupForImageRead) (
- ScrnInfoPtr pScrn,
- int bpp, int depth
- );
- int ImageReadFlags;
-
- unsigned char *ImageReadBase;
- int ImageReadRange;
-
- void (*SubsequentImageReadRect)(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h
- );
-
-
- /***************** Mid Level *****************/
- void (*ScreenToScreenBitBlt)(
- ScrnInfoPtr pScrn,
- int nbox,
- DDXPointPtr pptSrc,
- BoxPtr pbox,
- int xdir, int ydir,
- int alu,
- unsigned int planmask
- );
- int ScreenToScreenBitBltFlags;
-
- void (*WriteBitmap) (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
- );
- int WriteBitmapFlags;
-
- void (*FillSolidRects)(
- ScrnInfoPtr pScrn,
- int fg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox
- );
- int FillSolidRectsFlags;
-
- void (*FillMono8x8PatternRects)(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int pat0, int pat1,
- int xorg, int yorg
- );
- int FillMono8x8PatternRectsFlags;
-
- void (*FillColor8x8PatternRects)(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- XAACacheInfoPtr pCache
- );
- int FillColor8x8PatternRectsFlags;
-
- void (*FillCacheBltRects)(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- XAACacheInfoPtr pCache
- );
- int FillCacheBltRectsFlags;
-
- void (*FillColorExpandRects)(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
- );
- int FillColorExpandRectsFlags;
-
- void (*FillCacheExpandRects)(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
- );
- int FillCacheExpandRectsFlags;
-
- void (*FillImageWriteRects)(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
- );
- int FillImageWriteRectsFlags;
-
-
- void (*FillSolidSpans)(
- ScrnInfoPtr pScrn,
- int fg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr points,
- int *widths,
- int fSorted
- );
- int FillSolidSpansFlags;
-
- void (*FillMono8x8PatternSpans)(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr points,
- int *widths,
- int fSorted,
- int pat0, int pat1,
- int xorg, int yorg
- );
- int FillMono8x8PatternSpansFlags;
-
- void (*FillColor8x8PatternSpans)(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr points,
- int *widths,
- int fSorted,
- XAACacheInfoPtr pCache,
- int xorg, int yorg
- );
- int FillColor8x8PatternSpansFlags;
-
- void (*FillCacheBltSpans)(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr points,
- int *widths,
- int fSorted,
- XAACacheInfoPtr pCache,
- int xorg, int yorg
- );
- int FillCacheBltSpansFlags;
-
- void (*FillColorExpandSpans)(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr points,
- int *widths,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
- );
- int FillColorExpandSpansFlags;
-
- void (*FillCacheExpandSpans)(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
- );
- int FillCacheExpandSpansFlags;
-
- void (*TEGlyphRenderer)(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
- );
- int TEGlyphRendererFlags;
-
- void (*NonTEGlyphRenderer)(
- ScrnInfoPtr pScrn,
- int x, int y, int n,
- NonTEGlyphPtr glyphs,
- BoxPtr pbox,
- int fg, int rop,
- unsigned int planemask
- );
- int NonTEGlyphRendererFlags;
-
- void (*WritePixmap) (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int rop,
- unsigned int planemask,
- int transparency_color,
- int bpp, int depth
- );
- int WritePixmapFlags;
-
- void (*ReadPixmap) (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *dst,
- int dstwidth,
- int bpp, int depth
- );
- int ReadPixmapFlags;
-
- /***************** GC Level *****************/
- RegionPtr (*CopyArea)(
- DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GC *pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty
- );
- int CopyAreaFlags;
-
- RegionPtr (*CopyPlane)(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GCPtr pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty,
- unsigned long bitPlane
- );
- int CopyPlaneFlags;
-
- void (*PushPixelsSolid) (
- GCPtr pGC,
- PixmapPtr pBitMap,
- DrawablePtr pDrawable,
- int dx, int dy,
- int xOrg, int yOrg
- );
- int PushPixelsFlags;
-
- /** PolyFillRect **/
-
- void (*PolyFillRectSolid)(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nrectFill,
- xRectangle *prectInit
- );
- int PolyFillRectSolidFlags;
-
- void (*PolyFillRectStippled)(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nrectFill,
- xRectangle *prectInit
- );
- int PolyFillRectStippledFlags;
-
- void (*PolyFillRectOpaqueStippled)(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nrectFill,
- xRectangle *prectInit
- );
- int PolyFillRectOpaqueStippledFlags;
-
- void (*PolyFillRectTiled)(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nrectFill,
- xRectangle *prectInit
- );
- int PolyFillRectTiledFlags;
-
- /** FillSpans **/
-
- void (*FillSpansSolid)(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nInit,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted
- );
- int FillSpansSolidFlags;
-
- void (*FillSpansStippled)(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nInit,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted
- );
- int FillSpansStippledFlags;
-
- void (*FillSpansOpaqueStippled)(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nInit,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted
- );
- int FillSpansOpaqueStippledFlags;
-
- void (*FillSpansTiled)(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nInit,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted
- );
- int FillSpansTiledFlags;
-
- int (*PolyText8TE) (
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- char *chars
- );
- int PolyText8TEFlags;
-
- int (*PolyText16TE) (
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- unsigned short *chars
- );
- int PolyText16TEFlags;
-
- void (*ImageText8TE) (
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- char *chars
- );
- int ImageText8TEFlags;
-
- void (*ImageText16TE) (
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- unsigned short *chars
- );
- int ImageText16TEFlags;
-
- void (*ImageGlyphBltTE) (
- DrawablePtr pDrawable,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase
- );
- int ImageGlyphBltTEFlags;
-
- void (*PolyGlyphBltTE) (
- DrawablePtr pDrawable,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase
- );
- int PolyGlyphBltTEFlags;
-
- int (*PolyText8NonTE) (
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- char *chars
- );
- int PolyText8NonTEFlags;
-
- int (*PolyText16NonTE) (
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- unsigned short *chars
- );
- int PolyText16NonTEFlags;
-
- void (*ImageText8NonTE) (
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- char *chars
- );
- int ImageText8NonTEFlags;
-
- void (*ImageText16NonTE) (
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- unsigned short *chars
- );
- int ImageText16NonTEFlags;
-
- void (*ImageGlyphBltNonTE) (
- DrawablePtr pDrawable,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase
- );
- int ImageGlyphBltNonTEFlags;
-
- void (*PolyGlyphBltNonTE) (
- DrawablePtr pDrawable,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase
- );
- int PolyGlyphBltNonTEFlags;
-
- void (*PolyRectangleThinSolid)(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int nRectsInit,
- xRectangle *pRectsInit
- );
- int PolyRectangleThinSolidFlags;
-
- void (*PolylinesWideSolid)(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr pPts
- );
- int PolylinesWideSolidFlags;
-
- void (*PolylinesThinSolid)(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr pPts
- );
- int PolylinesThinSolidFlags;
-
- void (*PolySegmentThinSolid)(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int nseg,
- xSegment *pSeg
- );
- int PolySegmentThinSolidFlags;
-
- void (*PolylinesThinDashed)(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr pPts
- );
- int PolylinesThinDashedFlags;
-
- void (*PolySegmentThinDashed)(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int nseg,
- xSegment *pSeg
- );
- int PolySegmentThinDashedFlags;
-
- void (*FillPolygonSolid)(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
- );
- int FillPolygonSolidFlags;
-
- void (*FillPolygonStippled)(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
- );
- int FillPolygonStippledFlags;
-
- void (*FillPolygonOpaqueStippled)(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
- );
- int FillPolygonOpaqueStippledFlags;
-
- void (*FillPolygonTiled)(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
- );
- int FillPolygonTiledFlags;
-
- void (*PolyFillArcSolid)(
- DrawablePtr pDraw,
- GCPtr pGC,
- int narcs,
- xArc *parcs
- );
- int PolyFillArcSolidFlags;
-
- void (*PutImage)(
- DrawablePtr pDraw,
- GCPtr pGC,
- int depth,
- int x,
- int y,
- int w,
- int h,
- int leftPad,
- int format,
- char *pImage
- );
- int PutImageFlags;
-
- /* Validation masks */
-
- unsigned long FillSpansMask;
- ValidateGCProcPtr ValidateFillSpans;
- unsigned long SetSpansMask;
- ValidateGCProcPtr ValidateSetSpans;
- unsigned long PutImageMask;
- ValidateGCProcPtr ValidatePutImage;
- unsigned long CopyAreaMask;
- ValidateGCProcPtr ValidateCopyArea;
- unsigned long CopyPlaneMask;
- ValidateGCProcPtr ValidateCopyPlane;
- unsigned long PolyPointMask;
- ValidateGCProcPtr ValidatePolyPoint;
- unsigned long PolylinesMask;
- ValidateGCProcPtr ValidatePolylines;
- unsigned long PolySegmentMask;
- ValidateGCProcPtr ValidatePolySegment;
- unsigned long PolyRectangleMask;
- ValidateGCProcPtr ValidatePolyRectangle;
- unsigned long PolyArcMask;
- ValidateGCProcPtr ValidatePolyArc;
- unsigned long FillPolygonMask;
- ValidateGCProcPtr ValidateFillPolygon;
- unsigned long PolyFillRectMask;
- ValidateGCProcPtr ValidatePolyFillRect;
- unsigned long PolyFillArcMask;
- ValidateGCProcPtr ValidatePolyFillArc;
- unsigned long PolyText8Mask;
- ValidateGCProcPtr ValidatePolyText8;
- unsigned long PolyText16Mask;
- ValidateGCProcPtr ValidatePolyText16;
- unsigned long ImageText8Mask;
- ValidateGCProcPtr ValidateImageText8;
- unsigned long ImageText16Mask;
- ValidateGCProcPtr ValidateImageText16;
- unsigned long PolyGlyphBltMask;
- ValidateGCProcPtr ValidatePolyGlyphBlt;
- unsigned long ImageGlyphBltMask;
- ValidateGCProcPtr ValidateImageGlyphBlt;
- unsigned long PushPixelsMask;
- ValidateGCProcPtr ValidatePushPixels;
-
- void (*ComputeDash)(GCPtr pGC);
-
- /* Pixmap Cache */
-
- int PixmapCacheFlags;
- Bool UsingPixmapCache;
- Bool CanDoMono8x8;
- Bool CanDoColor8x8;
-
- void (*InitPixmapCache)(
- ScreenPtr pScreen,
- RegionPtr areas,
- pointer data
- );
- void (*ClosePixmapCache)(
- ScreenPtr pScreen
- );
-
- int (*StippledFillChooser)(GCPtr pGC);
- int (*OpaqueStippledFillChooser)(GCPtr pGC);
- int (*TiledFillChooser)(GCPtr pGC);
-
- int CachePixelGranularity;
- int MaxCacheableTileWidth;
- int MaxCacheableTileHeight;
- int MaxCacheableStippleWidth;
- int MaxCacheableStippleHeight;
-
- XAACacheInfoPtr (*CacheTile)(
- ScrnInfoPtr Scrn, PixmapPtr pPix
- );
- XAACacheInfoPtr (*CacheStipple)(
- ScrnInfoPtr Scrn, PixmapPtr pPix,
- int fg, int bg
- );
- XAACacheInfoPtr (*CacheMonoStipple)(
- ScrnInfoPtr Scrn, PixmapPtr pPix
- );
- XAACacheInfoPtr (*CacheMono8x8Pattern)(
- ScrnInfoPtr Scrn, int pat0, int pat1
- );
- XAACacheInfoPtr (*CacheColor8x8Pattern)(
- ScrnInfoPtr Scrn, PixmapPtr pPix,
- int fg, int bg
- );
-
-
- int MonoPatternPitch;
- int CacheWidthMono8x8Pattern;
- int CacheHeightMono8x8Pattern;
-
- int ColorPatternPitch;
- int CacheWidthColor8x8Pattern;
- int CacheHeightColor8x8Pattern;
-
- int CacheColorExpandDensity;
-
- void (*WriteBitmapToCache) (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int fg, int bg
- );
- void (*WritePixmapToCache) (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int bpp, int depth
- );
- void (*WriteMono8x8PatternToCache)(
- ScrnInfoPtr pScrn,
- XAACacheInfoPtr pCache
- );
- void (*WriteColor8x8PatternToCache)(
- ScrnInfoPtr pScrn,
- PixmapPtr pPix,
- XAACacheInfoPtr pCache
- );
-
- char* PixmapCachePrivate;
-
- /* Miscellaneous */
-
- GC ScratchGC;
- int PreAllocSize;
- unsigned char *PreAllocMem;
-
- CharInfoPtr CharInfo[255];
- NonTEGlyphInfo GlyphInfo[255];
-
- unsigned int FullPlanemask; /* deprecated */
-
- PixmapLinkPtr OffscreenPixmaps;
- int maxOffPixWidth;
- int maxOffPixHeight;
-
- XAACacheInfoRec ScratchCacheInfoRec;
-
- BoxPtr ClipBox;
-
- Bool NeedToSync;
-
- char *dgaSaves;
-
- /* These can be supplied to override the defaults */
-
- GetImageProcPtr GetImage;
- GetSpansProcPtr GetSpans;
- CopyWindowProcPtr CopyWindow;
-
- unsigned int offscreenDepths;
- Bool offscreenDepthsInitialized;
-
- CARD32 FullPlanemasks[32];
-
- Bool (*Composite) (
- CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst,
- CARD16 width,
- CARD16 height
- );
-
- Bool (*Glyphs) (
- CARD8 op,
- PicturePtr pSrc,
- PicturePtr pDst,
- PictFormatPtr maskFormat,
- INT16 xSrc,
- INT16 ySrc,
- int nlist,
- GlyphListPtr list,
- GlyphPtr *glyphs
- );
-
- /* The old SetupForCPUToScreenAlphaTexture function is no longer used because
- * it doesn't pass in enough information to write a conforming
- * implementation. See SetupForCPUToScreenAlphaTexture2.
- */
- Bool (*SetupForCPUToScreenAlphaTexture) (
- ScrnInfoPtr pScrn,
- int op,
- CARD16 red,
- CARD16 green,
- CARD16 blue,
- CARD16 alpha,
- int alphaType,
- CARD8 *alphaPtr,
- int alphaPitch,
- int width,
- int height,
- int flags
- );
- void (*SubsequentCPUToScreenAlphaTexture) (
- ScrnInfoPtr pScrn,
- int dstx,
- int dsty,
- int srcx,
- int srcy,
- int width,
- int height
- );
- int CPUToScreenAlphaTextureFlags;
- CARD32 * CPUToScreenAlphaTextureFormats;
-
- /* The old SetupForCPUToScreenTexture function is no longer used because
- * it doesn't pass in enough information to write a conforming
- * implementation. See SetupForCPUToScreenTexture2.
- */
- Bool (*SetupForCPUToScreenTexture) (
- ScrnInfoPtr pScrn,
- int op,
- int texType,
- CARD8 *texPtr,
- int texPitch,
- int width,
- int height,
- int flags
- );
- void (*SubsequentCPUToScreenTexture) (
- ScrnInfoPtr pScrn,
- int dstx,
- int dsty,
- int srcx,
- int srcy,
- int width,
- int height
- );
- int CPUToScreenTextureFlags;
- CARD32 * CPUToScreenTextureFormats;
-
-
- /* these were added for 4.3.0 */
- BoxRec SolidLineLimits;
- BoxRec DashedLineLimits;
-
- /* These were added for X.Org 6.8.0 */
- Bool (*SetupForCPUToScreenAlphaTexture2) (
- ScrnInfoPtr pScrn,
- int op,
- CARD16 red,
- CARD16 green,
- CARD16 blue,
- CARD16 alpha,
- CARD32 maskFormat,
- CARD32 dstFormat,
- CARD8 *alphaPtr,
- int alphaPitch,
- int width,
- int height,
- int flags
- );
- CARD32 *CPUToScreenAlphaTextureDstFormats;
-
- Bool (*SetupForCPUToScreenTexture2) (
- ScrnInfoPtr pScrn,
- int op,
- CARD32 srcFormat,
- CARD32 dstFormat,
- CARD8 *texPtr,
- int texPitch,
- int width,
- int height,
- int flags
- );
- CARD32 *CPUToScreenTextureDstFormats;
-} XAAInfoRec, *XAAInfoRecPtr;
-
-#define SET_SYNC_FLAG(infoRec) (infoRec)->NeedToSync = TRUE
-
-
-extern _X_EXPORT Bool
-XAAInit(
- ScreenPtr pScreen,
- XAAInfoRecPtr infoRec
-);
-
-extern _X_EXPORT XAAInfoRecPtr XAACreateInfoRec(void);
-
-extern _X_EXPORT void
-XAADestroyInfoRec(
- XAAInfoRecPtr infoRec
-);
-
-typedef void (*DepthChangeFuncPtr) (ScrnInfoPtr pScrn, int depth);
-
-extern _X_EXPORT Bool
-XAAInitDualFramebufferOverlay(
- ScreenPtr pScreen,
- DepthChangeFuncPtr callback
-);
-
-#endif /* _XAA_H */
+
+#ifndef _XAA_H
+#define _XAA_H
+
+#define XAA_VERSION_MAJOR 1
+#define XAA_VERSION_MINOR 2
+#define XAA_VERSION_RELEASE 1
+
+/*
+
+ ******** OPERATION SPECIFIC FLAGS *********
+
+ **** solid/dashed line flags ****
+
+--------- --------
+23 LINE_PATTERN_LSBFIRST_MSBJUSTIFIED
+22 LINE_PATTERN_LSBFIRST_LSBJUSTIFIED
+21 LINE_PATTERN_MSBFIRST_MSBJUSTIFIED
+20 LINE_PATTERN_MSBFIRST_LSBJUSTIFIED
+19 LINE_PATTERN_POWER_OF_2_ONLY
+18 LINE_LIMIT_COORDS
+17 .
+16 .
+--------- -------
+
+ **** screen to screen copy flags ****
+
+--------- --------
+23 ONLY_LEFT_TO_RIGHT_BITBLT
+22 ONLY_TWO_BITBLT_DIRECTIONS
+21 .
+20 .
+19 .
+18 .
+17 .
+16 .
+--------- -------
+
+ **** clipping flags ****
+
+--------- --------
+23 .
+22 HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND
+21 HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY
+20 HARDWARE_CLIP_MONO_8x8_FILL
+19 HARDWARE_CLIP_COLOR_8x8_FILL
+18 HARDWARE_CLIP_SOLID_FILL
+17 HARDWARE_CLIP_DASHED_LINE
+16 HARDWARE_CLIP_SOLID_LINE
+--------- -------
+
+ **** hardware pattern flags ****
+
+--------- --------
+23 .
+22 .
+21 HARDWARE_PATTERN_SCREEN_ORIGIN
+20 .
+19 .
+18 .
+17 HARDWARE_PATTERN_PROGRAMMED_ORIGIN
+16 HARDWARE_PATTERN_PROGRAMMED_BITS
+--------- -------
+
+ **** write pixmap flags ****
+
+--------- --------
+23 .
+22 .
+21 .
+20 .
+19 .
+18 .
+17 .
+16 CONVERT_32BPP_TO_24BPP
+--------- -------
+
+ ******** GENERIC FLAGS *********
+
+--------- -------
+15 SYNC_AFTER_COLOR_EXPAND
+14 CPU_TRANSFER_PAD_QWORD
+13 .
+12 LEFT_EDGE_CLIPPING_NEGATIVE_X
+11 LEFT_EDGE_CLIPPING
+10 CPU_TRANSFER_BASE_FIXED
+ 9 BIT_ORDER_IN_BYTE_MSBFIRST
+ 8 TRANSPARENCY_GXCOPY_ONLY
+--------- -------
+ 7 NO_TRANSPARENCY
+ 6 TRANSPARENCY_ONLY
+ 5 ROP_NEEDS_SOURCE
+ 4 TRIPLE_BITS_24BPP
+ 3 RGB_EQUAL
+ 2 NO_PLANEMASK
+ 1 NO_GXCOPY
+ 0 GXCOPY_ONLY
+--------- -------
+
+
+*/
+
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "xf86str.h"
+#include "regionstr.h"
+#include "xf86fbman.h"
+
+#include "picturestr.h"
+
+/* Flags */
+#define PIXMAP_CACHE 0x00000001
+#define MICROSOFT_ZERO_LINE_BIAS 0x00000002
+#define OFFSCREEN_PIXMAPS 0x00000004
+#define LINEAR_FRAMEBUFFER 0x00000008
+
+/* GC fg, bg, and planemask restrictions */
+#define GXCOPY_ONLY 0x00000001
+#define NO_GXCOPY 0x00000002
+#define NO_PLANEMASK 0x00000004
+#define RGB_EQUAL 0x00000008
+#define TRIPLE_BITS_24BPP 0x00000010
+#define ROP_NEEDS_SOURCE 0x00000020
+
+/* transparency restrictions */
+#define TRANSPARENCY_ONLY 0x00000040
+#define NO_TRANSPARENCY 0x00000080
+#define TRANSPARENCY_GXCOPY_ONLY 0x00000100
+
+/* bit order restrictions */
+#define BIT_ORDER_IN_BYTE_MSBFIRST 0x00000200
+#define BIT_ORDER_IN_BYTE_LSBFIRST 0x00000000
+
+/* transfer base restriction */
+#define CPU_TRANSFER_BASE_FIXED 0x00000400
+
+/* skipleft restrictions */
+#define LEFT_EDGE_CLIPPING 0x00000800
+#define LEFT_EDGE_CLIPPING_NEGATIVE_X 0x00001000
+
+/* data padding */
+#define CPU_TRANSFER_PAD_DWORD 0x00000000
+#define CPU_TRANSFER_PAD_QWORD 0x00004000
+#define SCANLINE_PAD_DWORD 0x00000000
+
+#define SYNC_AFTER_COLOR_EXPAND 0x00008000
+#define SYNC_AFTER_IMAGE_WRITE SYNC_AFTER_COLOR_EXPAND
+
+/* hardware pattern */
+#define HARDWARE_PATTERN_PROGRAMMED_BITS 0x00010000
+#define HARDWARE_PATTERN_PROGRAMMED_ORIGIN 0x00020000
+#define HARDWARE_PATTERN_SCREEN_ORIGIN 0x00200000
+
+/* copyarea flags */
+#define ONLY_TWO_BITBLT_DIRECTIONS 0x00400000
+#define ONLY_LEFT_TO_RIGHT_BITBLT 0x00800000
+
+/* line flags */
+#define LINE_PATTERN_LSBFIRST_MSBJUSTIFIED 0x00800000
+#define LINE_PATTERN_LSBFIRST_LSBJUSTIFIED 0x00400000
+#define LINE_PATTERN_MSBFIRST_MSBJUSTIFIED 0x00200000
+#define LINE_PATTERN_MSBFIRST_LSBJUSTIFIED 0x00100000
+#define LINE_PATTERN_POWER_OF_2_ONLY 0x00080000
+#define LINE_LIMIT_COORDS 0x00040000
+
+/* clipping flags */
+#define HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND 0x00400000
+#define HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY 0x00200000
+#define HARDWARE_CLIP_MONO_8x8_FILL 0x00100000
+#define HARDWARE_CLIP_COLOR_8x8_FILL 0x00080000
+#define HARDWARE_CLIP_SOLID_FILL 0x00040000
+#define HARDWARE_CLIP_DASHED_LINE 0x00020000
+#define HARDWARE_CLIP_SOLID_LINE 0x00010000
+
+#define HARDWARE_CLIP_LINE 0x00000000
+
+/* image write flags */
+#define CONVERT_32BPP_TO_24BPP 0x00010000
+
+/* pixmap cache flags */
+#define CACHE_MONO_8x8 0x00000001
+#define CACHE_COLOR_8x8 0x00000002
+#define DO_NOT_BLIT_STIPPLES 0x00000004
+#define DO_NOT_TILE_MONO_DATA 0x00000008
+#define DO_NOT_TILE_COLOR_DATA 0x00000010
+
+#define DEGREES_0 0
+#define DEGREES_90 1
+#define DEGREES_180 2
+#define DEGREES_270 3
+
+#define OMIT_LAST 1
+
+/* render flags */
+
+#define XAA_RENDER_POWER_OF_2_TILE_ONLY 0x00000008
+#define XAA_RENDER_NO_SRC_ALPHA 0x00000004
+#define XAA_RENDER_IMPRECISE_ONLY 0x00000002
+#define XAA_RENDER_NO_TILE 0x00000001
+
+#define XAA_RENDER_REPEAT 0x00000001
+
+typedef void (*ValidateGCProcPtr) (GCPtr pGC,
+ unsigned long changes, DrawablePtr pDraw);
+
+typedef struct {
+ unsigned char *bits;
+ int width;
+ int height;
+ int yoff;
+ int srcwidth;
+ int start;
+ int end;
+} NonTEGlyphInfo, *NonTEGlyphPtr;
+
+typedef struct {
+ int x;
+ int y;
+ int w;
+ int h;
+ int orig_w;
+ int orig_h;
+ unsigned long serialNumber;
+ int pat0;
+ int pat1;
+ int fg;
+ int bg;
+ int trans_color;
+ DDXPointPtr offsets;
+ DevUnion devPrivate;
+} XAACacheInfoRec, *XAACacheInfoPtr;
+
+typedef struct _PixmapLink {
+ PixmapPtr pPix;
+ struct _PixmapLink *next;
+ FBAreaPtr area;
+} PixmapLink, *PixmapLinkPtr;
+
+typedef struct _XAAInfoRec {
+ ScrnInfoPtr pScrn;
+ int Flags;
+
+ void (*Sync) (ScrnInfoPtr pScrn);
+
+ /* Restore Accel State is a driver callback that is used
+ * when another screen on the same device has been active.
+ * This allows multihead on a single device to work.
+ * If The entityProp has IS_SHARED_ACCEL defined then this
+ * function is required.
+ */
+
+ void (*RestoreAccelState) (ScrnInfoPtr pScrn);
+
+ /***************** Low Level *****************/
+
+/* Blits */
+ void (*SetupForScreenToScreenCopy) (ScrnInfoPtr pScrn,
+ int xdir, int ydir,
+ int rop,
+ unsigned int planemask,
+ int trans_color);
+ int ScreenToScreenCopyFlags;
+
+ void (*SubsequentScreenToScreenCopy) (ScrnInfoPtr pScrn,
+ int xsrc, int ysrc,
+ int xdst, int ydst, int w, int h);
+
+/* Solid fills */
+ void (*SetupForSolidFill) (ScrnInfoPtr pScrn,
+ int color, int rop, unsigned int planemask);
+ int SolidFillFlags;
+
+ void (*SubsequentSolidFillRect) (ScrnInfoPtr pScrn,
+ int x, int y, int w, int h);
+
+ void (*SubsequentSolidFillTrap) (ScrnInfoPtr pScrn,
+ int y, int h,
+ int left, int dxL, int dyL, int eL,
+ int right, int dxR, int dyR, int eR);
+
+/* Solid lines */
+
+ void (*SetupForSolidLine) (ScrnInfoPtr pScrn,
+ int color, int rop, unsigned int planemask);
+ int SolidLineFlags;
+
+ void (*SubsequentSolidTwoPointLine) (ScrnInfoPtr pScrn,
+ int xa, int ya, int xb, int yb,
+ int flags);
+
+ void (*SubsequentSolidBresenhamLine) (ScrnInfoPtr pScrn,
+ int x, int y, int absmaj, int absmin,
+ int err, int len, int octant);
+ int SolidBresenhamLineErrorTermBits;
+
+ void (*SubsequentSolidHorVertLine) (ScrnInfoPtr pScrn,
+ int x, int y, int len, int dir);
+
+/* Dashed lines */
+
+ void (*SetupForDashedLine) (ScrnInfoPtr pScrn,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask,
+ int length, unsigned char *pattern);
+ int DashedLineFlags;
+ int DashPatternMaxLength;
+
+ void (*SubsequentDashedTwoPointLine) (ScrnInfoPtr pScrn,
+ int xa, int ya, int xb, int yb,
+ int flags, int phase);
+
+ void (*SubsequentDashedBresenhamLine) (ScrnInfoPtr pScrn,
+ int x, int y, int absmaj, int absmin,
+ int err, int len, int flags,
+ int phase);
+ int DashedBresenhamLineErrorTermBits;
+
+/* Clipper */
+
+ void (*SetClippingRectangle) (ScrnInfoPtr pScrn,
+ int left, int top, int right, int bottom);
+ int ClippingFlags;
+
+ void (*DisableClipping) (ScrnInfoPtr pScrn);
+
+/* 8x8 mono pattern fills */
+ void (*SetupForMono8x8PatternFill) (ScrnInfoPtr pScrn,
+ int patx, int paty,
+ int fg, int bg,
+ int rop, unsigned int planemask);
+ int Mono8x8PatternFillFlags;
+
+ void (*SubsequentMono8x8PatternFillRect) (ScrnInfoPtr pScrn,
+ int patx, int paty,
+ int x, int y, int w, int h);
+
+ void (*SubsequentMono8x8PatternFillTrap) (ScrnInfoPtr pScrn,
+ int patx, int paty,
+ int y, int h,
+ int left, int dxL, int dyL,
+ int eL, int right, int dxR,
+ int dyR, int eR);
+
+/* 8x8 color pattern fills */
+
+ void (*SetupForColor8x8PatternFill) (ScrnInfoPtr pScrn,
+ int patx, int paty,
+ int rop,
+ unsigned int planemask,
+ int transparency_color);
+ int Color8x8PatternFillFlags;
+
+ void (*SubsequentColor8x8PatternFillRect) (ScrnInfoPtr pScrn,
+ int patx, int paty,
+ int x, int y, int w, int h);
+
+ void (*SubsequentColor8x8PatternFillTrap) (ScrnInfoPtr pScrn,
+ int patx, int paty,
+ int y, int h,
+ int left, int dxL, int dyL,
+ int eL, int right, int dxR,
+ int dyR, int eR);
+
+/* Color expansion */
+
+ void (*SetupForCPUToScreenColorExpandFill) (ScrnInfoPtr pScrn,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask);
+ int CPUToScreenColorExpandFillFlags;
+
+ void (*SubsequentCPUToScreenColorExpandFill) (ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ int skipleft);
+
+ unsigned char *ColorExpandBase;
+ int ColorExpandRange;
+
+/* Scanline color expansion */
+
+ void (*SetupForScanlineCPUToScreenColorExpandFill) (ScrnInfoPtr pScrn,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask);
+ int ScanlineCPUToScreenColorExpandFillFlags;
+
+ void (*SubsequentScanlineCPUToScreenColorExpandFill) (ScrnInfoPtr pScrn,
+ int x, int y, int w,
+ int h, int skipleft);
+
+ void (*SubsequentColorExpandScanline) (ScrnInfoPtr pScrn, int bufno);
+
+ int NumScanlineColorExpandBuffers;
+ unsigned char **ScanlineColorExpandBuffers;
+
+/* Screen to screen color expansion */
+
+ void (*SetupForScreenToScreenColorExpandFill) (ScrnInfoPtr pScrn,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask);
+ int ScreenToScreenColorExpandFillFlags;
+
+ void (*SubsequentScreenToScreenColorExpandFill) (ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ int srcx, int srcy,
+ int skipleft);
+
+/* Image transfers */
+
+ void (*SetupForImageWrite) (ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int transparency_color, int bpp, int depth);
+ int ImageWriteFlags;
+
+ void (*SubsequentImageWriteRect) (ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft);
+ unsigned char *ImageWriteBase;
+ int ImageWriteRange;
+
+/* Scanline Image transfers */
+
+ void (*SetupForScanlineImageWrite) (ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int transparency_color,
+ int bpp, int depth);
+ int ScanlineImageWriteFlags;
+
+ void (*SubsequentScanlineImageWriteRect) (ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ int skipleft);
+
+ void (*SubsequentImageWriteScanline) (ScrnInfoPtr pScrn, int bufno);
+
+ int NumScanlineImageWriteBuffers;
+ unsigned char **ScanlineImageWriteBuffers;
+
+ /* Image Reads - OBSOLETE AND NOT USED */
+
+ void (*SetupForImageRead) (ScrnInfoPtr pScrn, int bpp, int depth);
+ int ImageReadFlags;
+
+ unsigned char *ImageReadBase;
+ int ImageReadRange;
+
+ void (*SubsequentImageReadRect) (ScrnInfoPtr pScrn,
+ int x, int y, int w, int h);
+
+ /***************** Mid Level *****************/
+ void (*ScreenToScreenBitBlt) (ScrnInfoPtr pScrn,
+ int nbox,
+ DDXPointPtr pptSrc,
+ BoxPtr pbox,
+ int xdir, int ydir,
+ int alu, unsigned int planmask);
+ int ScreenToScreenBitBltFlags;
+
+ void (*WriteBitmap) (ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg, int rop, unsigned int planemask);
+ int WriteBitmapFlags;
+
+ void (*FillSolidRects) (ScrnInfoPtr pScrn,
+ int fg, int rop,
+ unsigned int planemask, int nBox, BoxPtr pBox);
+ int FillSolidRectsFlags;
+
+ void (*FillMono8x8PatternRects) (ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int pat0, int pat1, int xorg, int yorg);
+ int FillMono8x8PatternRectsFlags;
+
+ void (*FillColor8x8PatternRects) (ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ XAACacheInfoPtr pCache);
+ int FillColor8x8PatternRectsFlags;
+
+ void (*FillCacheBltRects) (ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg, XAACacheInfoPtr pCache);
+ int FillCacheBltRectsFlags;
+
+ void (*FillColorExpandRects) (ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg, PixmapPtr pPix);
+ int FillColorExpandRectsFlags;
+
+ void (*FillCacheExpandRects) (ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg, PixmapPtr pPix);
+ int FillCacheExpandRectsFlags;
+
+ void (*FillImageWriteRects) (ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg, PixmapPtr pPix);
+ int FillImageWriteRectsFlags;
+
+ void (*FillSolidSpans) (ScrnInfoPtr pScrn,
+ int fg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr points, int *widths, int fSorted);
+ int FillSolidSpansFlags;
+
+ void (*FillMono8x8PatternSpans) (ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr points,
+ int *widths,
+ int fSorted,
+ int pat0, int pat1, int xorg, int yorg);
+ int FillMono8x8PatternSpansFlags;
+
+ void (*FillColor8x8PatternSpans) (ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr points,
+ int *widths,
+ int fSorted,
+ XAACacheInfoPtr pCache,
+ int xorg, int yorg);
+ int FillColor8x8PatternSpansFlags;
+
+ void (*FillCacheBltSpans) (ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr points,
+ int *widths,
+ int fSorted,
+ XAACacheInfoPtr pCache, int xorg, int yorg);
+ int FillCacheBltSpansFlags;
+
+ void (*FillColorExpandSpans) (ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr points,
+ int *widths,
+ int fSorted,
+ int xorg, int yorg, PixmapPtr pPix);
+ int FillColorExpandSpansFlags;
+
+ void (*FillCacheExpandSpans) (ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg, PixmapPtr pPix);
+ int FillCacheExpandSpansFlags;
+
+ void (*TEGlyphRenderer) (ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft,
+ int startline, unsigned int **glyphs,
+ int glyphWidth, int fg, int bg, int rop,
+ unsigned planemask);
+ int TEGlyphRendererFlags;
+
+ void (*NonTEGlyphRenderer) (ScrnInfoPtr pScrn,
+ int x, int y, int n,
+ NonTEGlyphPtr glyphs,
+ BoxPtr pbox,
+ int fg, int rop, unsigned int planemask);
+ int NonTEGlyphRendererFlags;
+
+ void (*WritePixmap) (ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int rop,
+ unsigned int planemask,
+ int transparency_color, int bpp, int depth);
+ int WritePixmapFlags;
+
+ void (*ReadPixmap) (ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *dst, int dstwidth, int bpp, int depth);
+ int ReadPixmapFlags;
+
+ /***************** GC Level *****************/
+ RegionPtr (*CopyArea) (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GC * pGC,
+ int srcx, int srcy,
+ int width, int height, int dstx, int dsty);
+ int CopyAreaFlags;
+
+ RegionPtr (*CopyPlane) (DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx, int srcy,
+ int width, int height,
+ int dstx, int dsty, unsigned long bitPlane);
+ int CopyPlaneFlags;
+
+ void (*PushPixelsSolid) (GCPtr pGC,
+ PixmapPtr pBitMap,
+ DrawablePtr pDrawable,
+ int dx, int dy, int xOrg, int yOrg);
+ int PushPixelsFlags;
+
+ /** PolyFillRect **/
+
+ void (*PolyFillRectSolid) (DrawablePtr pDraw,
+ GCPtr pGC, int nrectFill, xRectangle *prectInit);
+ int PolyFillRectSolidFlags;
+
+ void (*PolyFillRectStippled) (DrawablePtr pDraw,
+ GCPtr pGC,
+ int nrectFill, xRectangle *prectInit);
+ int PolyFillRectStippledFlags;
+
+ void (*PolyFillRectOpaqueStippled) (DrawablePtr pDraw,
+ GCPtr pGC,
+ int nrectFill, xRectangle *prectInit);
+ int PolyFillRectOpaqueStippledFlags;
+
+ void (*PolyFillRectTiled) (DrawablePtr pDraw,
+ GCPtr pGC, int nrectFill, xRectangle *prectInit);
+ int PolyFillRectTiledFlags;
+
+ /** FillSpans **/
+
+ void (*FillSpansSolid) (DrawablePtr pDraw,
+ GCPtr pGC,
+ int nInit,
+ DDXPointPtr ppt, int *pwidth, int fSorted);
+ int FillSpansSolidFlags;
+
+ void (*FillSpansStippled) (DrawablePtr pDraw,
+ GCPtr pGC,
+ int nInit,
+ DDXPointPtr ppt, int *pwidth, int fSorted);
+ int FillSpansStippledFlags;
+
+ void (*FillSpansOpaqueStippled) (DrawablePtr pDraw,
+ GCPtr pGC,
+ int nInit,
+ DDXPointPtr ppt, int *pwidth, int fSorted);
+ int FillSpansOpaqueStippledFlags;
+
+ void (*FillSpansTiled) (DrawablePtr pDraw,
+ GCPtr pGC,
+ int nInit,
+ DDXPointPtr ppt, int *pwidth, int fSorted);
+ int FillSpansTiledFlags;
+
+ int (*PolyText8TE) (DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars);
+ int PolyText8TEFlags;
+
+ int (*PolyText16TE) (DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y, int count, unsigned short *chars);
+ int PolyText16TEFlags;
+
+ void (*ImageText8TE) (DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars);
+ int ImageText8TEFlags;
+
+ void (*ImageText16TE) (DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y, int count, unsigned short *chars);
+ int ImageText16TEFlags;
+
+ void (*ImageGlyphBltTE) (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase);
+ int ImageGlyphBltTEFlags;
+
+ void (*PolyGlyphBltTE) (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase);
+ int PolyGlyphBltTEFlags;
+
+ int (*PolyText8NonTE) (DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars);
+ int PolyText8NonTEFlags;
+
+ int (*PolyText16NonTE) (DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y, int count, unsigned short *chars);
+ int PolyText16NonTEFlags;
+
+ void (*ImageText8NonTE) (DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars);
+ int ImageText8NonTEFlags;
+
+ void (*ImageText16NonTE) (DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y, int count, unsigned short *chars);
+ int ImageText16NonTEFlags;
+
+ void (*ImageGlyphBltNonTE) (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase);
+ int ImageGlyphBltNonTEFlags;
+
+ void (*PolyGlyphBltNonTE) (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase);
+ int PolyGlyphBltNonTEFlags;
+
+ void (*PolyRectangleThinSolid) (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nRectsInit, xRectangle *pRectsInit);
+ int PolyRectangleThinSolidFlags;
+
+ void (*PolylinesWideSolid) (DrawablePtr pDrawable,
+ GCPtr pGC, int mode, int npt, DDXPointPtr pPts);
+ int PolylinesWideSolidFlags;
+
+ void (*PolylinesThinSolid) (DrawablePtr pDrawable,
+ GCPtr pGC, int mode, int npt, DDXPointPtr pPts);
+ int PolylinesThinSolidFlags;
+
+ void (*PolySegmentThinSolid) (DrawablePtr pDrawable,
+ GCPtr pGC, int nseg, xSegment * pSeg);
+ int PolySegmentThinSolidFlags;
+
+ void (*PolylinesThinDashed) (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode, int npt, DDXPointPtr pPts);
+ int PolylinesThinDashedFlags;
+
+ void (*PolySegmentThinDashed) (DrawablePtr pDrawable,
+ GCPtr pGC, int nseg, xSegment * pSeg);
+ int PolySegmentThinDashedFlags;
+
+ void (*FillPolygonSolid) (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int shape,
+ int mode, int count, DDXPointPtr ptsIn);
+ int FillPolygonSolidFlags;
+
+ void (*FillPolygonStippled) (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int shape,
+ int mode, int count, DDXPointPtr ptsIn);
+ int FillPolygonStippledFlags;
+
+ void (*FillPolygonOpaqueStippled) (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int shape,
+ int mode, int count, DDXPointPtr ptsIn);
+ int FillPolygonOpaqueStippledFlags;
+
+ void (*FillPolygonTiled) (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int shape,
+ int mode, int count, DDXPointPtr ptsIn);
+ int FillPolygonTiledFlags;
+
+ void (*PolyFillArcSolid) (DrawablePtr pDraw,
+ GCPtr pGC, int narcs, xArc * parcs);
+ int PolyFillArcSolidFlags;
+
+ void (*PutImage) (DrawablePtr pDraw,
+ GCPtr pGC,
+ int depth,
+ int x,
+ int y,
+ int w, int h, int leftPad, int format, char *pImage);
+ int PutImageFlags;
+
+ /* Validation masks */
+
+ unsigned long FillSpansMask;
+ ValidateGCProcPtr ValidateFillSpans;
+ unsigned long SetSpansMask;
+ ValidateGCProcPtr ValidateSetSpans;
+ unsigned long PutImageMask;
+ ValidateGCProcPtr ValidatePutImage;
+ unsigned long CopyAreaMask;
+ ValidateGCProcPtr ValidateCopyArea;
+ unsigned long CopyPlaneMask;
+ ValidateGCProcPtr ValidateCopyPlane;
+ unsigned long PolyPointMask;
+ ValidateGCProcPtr ValidatePolyPoint;
+ unsigned long PolylinesMask;
+ ValidateGCProcPtr ValidatePolylines;
+ unsigned long PolySegmentMask;
+ ValidateGCProcPtr ValidatePolySegment;
+ unsigned long PolyRectangleMask;
+ ValidateGCProcPtr ValidatePolyRectangle;
+ unsigned long PolyArcMask;
+ ValidateGCProcPtr ValidatePolyArc;
+ unsigned long FillPolygonMask;
+ ValidateGCProcPtr ValidateFillPolygon;
+ unsigned long PolyFillRectMask;
+ ValidateGCProcPtr ValidatePolyFillRect;
+ unsigned long PolyFillArcMask;
+ ValidateGCProcPtr ValidatePolyFillArc;
+ unsigned long PolyText8Mask;
+ ValidateGCProcPtr ValidatePolyText8;
+ unsigned long PolyText16Mask;
+ ValidateGCProcPtr ValidatePolyText16;
+ unsigned long ImageText8Mask;
+ ValidateGCProcPtr ValidateImageText8;
+ unsigned long ImageText16Mask;
+ ValidateGCProcPtr ValidateImageText16;
+ unsigned long PolyGlyphBltMask;
+ ValidateGCProcPtr ValidatePolyGlyphBlt;
+ unsigned long ImageGlyphBltMask;
+ ValidateGCProcPtr ValidateImageGlyphBlt;
+ unsigned long PushPixelsMask;
+ ValidateGCProcPtr ValidatePushPixels;
+
+ void (*ComputeDash) (GCPtr pGC);
+
+ /* Pixmap Cache */
+
+ int PixmapCacheFlags;
+ Bool UsingPixmapCache;
+ Bool CanDoMono8x8;
+ Bool CanDoColor8x8;
+
+ void (*InitPixmapCache) (ScreenPtr pScreen, RegionPtr areas, pointer data);
+ void (*ClosePixmapCache) (ScreenPtr pScreen);
+
+ int (*StippledFillChooser) (GCPtr pGC);
+ int (*OpaqueStippledFillChooser) (GCPtr pGC);
+ int (*TiledFillChooser) (GCPtr pGC);
+
+ int CachePixelGranularity;
+ int MaxCacheableTileWidth;
+ int MaxCacheableTileHeight;
+ int MaxCacheableStippleWidth;
+ int MaxCacheableStippleHeight;
+
+ XAACacheInfoPtr(*CacheTile) (ScrnInfoPtr Scrn, PixmapPtr pPix);
+ XAACacheInfoPtr(*CacheStipple) (ScrnInfoPtr Scrn, PixmapPtr pPix,
+ int fg, int bg);
+ XAACacheInfoPtr(*CacheMonoStipple) (ScrnInfoPtr Scrn, PixmapPtr pPix);
+ XAACacheInfoPtr(*CacheMono8x8Pattern) (ScrnInfoPtr Scrn, int pat0,
+ int pat1);
+ XAACacheInfoPtr(*CacheColor8x8Pattern) (ScrnInfoPtr Scrn, PixmapPtr pPix,
+ int fg, int bg);
+
+ int MonoPatternPitch;
+ int CacheWidthMono8x8Pattern;
+ int CacheHeightMono8x8Pattern;
+
+ int ColorPatternPitch;
+ int CacheWidthColor8x8Pattern;
+ int CacheHeightColor8x8Pattern;
+
+ int CacheColorExpandDensity;
+
+ void (*WriteBitmapToCache) (ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth, int fg, int bg);
+ void (*WritePixmapToCache) (ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth, int bpp, int depth);
+ void (*WriteMono8x8PatternToCache) (ScrnInfoPtr pScrn,
+ XAACacheInfoPtr pCache);
+ void (*WriteColor8x8PatternToCache) (ScrnInfoPtr pScrn,
+ PixmapPtr pPix,
+ XAACacheInfoPtr pCache);
+
+ char *PixmapCachePrivate;
+
+ /* Miscellaneous */
+
+ GC ScratchGC;
+ int PreAllocSize;
+ unsigned char *PreAllocMem;
+
+ CharInfoPtr CharInfo[255];
+ NonTEGlyphInfo GlyphInfo[255];
+
+ unsigned int FullPlanemask; /* deprecated */
+
+ PixmapLinkPtr OffscreenPixmaps;
+ int maxOffPixWidth;
+ int maxOffPixHeight;
+
+ XAACacheInfoRec ScratchCacheInfoRec;
+
+ BoxPtr ClipBox;
+
+ Bool NeedToSync;
+
+ char *dgaSaves;
+
+ /* These can be supplied to override the defaults */
+
+ GetImageProcPtr GetImage;
+ GetSpansProcPtr GetSpans;
+ CopyWindowProcPtr CopyWindow;
+
+ unsigned int offscreenDepths;
+ Bool offscreenDepthsInitialized;
+
+ CARD32 FullPlanemasks[32];
+
+ Bool (*Composite) (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
+
+ Bool (*Glyphs) (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int nlist, GlyphListPtr list, GlyphPtr * glyphs);
+
+ /* The old SetupForCPUToScreenAlphaTexture function is no longer used because
+ * it doesn't pass in enough information to write a conforming
+ * implementation. See SetupForCPUToScreenAlphaTexture2.
+ */
+ Bool (*SetupForCPUToScreenAlphaTexture) (ScrnInfoPtr pScrn,
+ int op,
+ CARD16 red,
+ CARD16 green,
+ CARD16 blue,
+ CARD16 alpha,
+ int alphaType,
+ CARD8 *alphaPtr,
+ int alphaPitch,
+ int width, int height, int flags);
+ void (*SubsequentCPUToScreenAlphaTexture) (ScrnInfoPtr pScrn,
+ int dstx,
+ int dsty,
+ int srcx,
+ int srcy, int width, int height);
+ int CPUToScreenAlphaTextureFlags;
+ CARD32 *CPUToScreenAlphaTextureFormats;
+
+ /* The old SetupForCPUToScreenTexture function is no longer used because
+ * it doesn't pass in enough information to write a conforming
+ * implementation. See SetupForCPUToScreenTexture2.
+ */
+ Bool (*SetupForCPUToScreenTexture) (ScrnInfoPtr pScrn,
+ int op,
+ int texType,
+ CARD8 *texPtr,
+ int texPitch,
+ int width, int height, int flags);
+ void (*SubsequentCPUToScreenTexture) (ScrnInfoPtr pScrn,
+ int dstx,
+ int dsty,
+ int srcx,
+ int srcy, int width, int height);
+ int CPUToScreenTextureFlags;
+ CARD32 *CPUToScreenTextureFormats;
+
+ /* these were added for 4.3.0 */
+ BoxRec SolidLineLimits;
+ BoxRec DashedLineLimits;
+
+ /* These were added for X.Org 6.8.0 */
+ Bool (*SetupForCPUToScreenAlphaTexture2) (ScrnInfoPtr pScrn,
+ int op,
+ CARD16 red,
+ CARD16 green,
+ CARD16 blue,
+ CARD16 alpha,
+ CARD32 maskFormat,
+ CARD32 dstFormat,
+ CARD8 *alphaPtr,
+ int alphaPitch,
+ int width, int height, int flags);
+ CARD32 *CPUToScreenAlphaTextureDstFormats;
+
+ Bool (*SetupForCPUToScreenTexture2) (ScrnInfoPtr pScrn,
+ int op,
+ CARD32 srcFormat,
+ CARD32 dstFormat,
+ CARD8 *texPtr,
+ int texPitch,
+ int width, int height, int flags);
+ CARD32 *CPUToScreenTextureDstFormats;
+} XAAInfoRec, *XAAInfoRecPtr;
+
+#define SET_SYNC_FLAG(infoRec) (infoRec)->NeedToSync = TRUE
+
+extern _X_EXPORT Bool
+ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec);
+
+extern _X_EXPORT XAAInfoRecPtr XAACreateInfoRec(void);
+
+extern _X_EXPORT void
+ XAADestroyInfoRec(XAAInfoRecPtr infoRec);
+
+typedef void (*DepthChangeFuncPtr) (ScrnInfoPtr pScrn, int depth);
+
+extern _X_EXPORT Bool
+ XAAInitDualFramebufferOverlay(ScreenPtr pScreen, DepthChangeFuncPtr callback);
+
+#endif /* _XAA_H */
diff --git a/xorg-server/hw/xfree86/xaa/xaaBitBlt.c b/xorg-server/hw/xfree86/xaa/xaaBitBlt.c
index 126a4ee65..c1595c497 100644
--- a/xorg-server/hw/xfree86/xaa/xaaBitBlt.c
+++ b/xorg-server/hw/xfree86/xaa/xaaBitBlt.c
@@ -1,221 +1,229 @@
-
-/*
- This is a lighter version of cfbBitBlt. We calculate the boxes
- when accelerating pixmap->screen and screen->screen copies.
- We also pass the GC to the doBitBlt function so that it has access
- to the fg and bg so CopyPlane can use this.
-*/
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "mi.h"
-#include "pixmapstr.h"
-#include "gcstruct.h"
-#include "windowstr.h"
-#include "xaalocal.h"
-
-
-RegionPtr
-XAABitBlt(
- DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GC *pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty,
- void (*doBitBlt)(DrawablePtr, DrawablePtr, GCPtr, RegionPtr, DDXPointPtr),
- unsigned long bitPlane )
-{
-
- RegionPtr prgnSrcClip = NULL; /* may be a new region, or just a copy */
- RegionPtr prgnExposed;
- Bool freeSrcClip = FALSE;
- RegionRec rgnDst;
- DDXPointPtr pptSrc, ppt;
- DDXPointRec origDest;
- BoxPtr pbox;
- BoxRec fastBox;
- int i, dx, dy, numRects;
- xRectangle origSource;
- int fastClip = 0; /* for fast clipping with pixmap source */
- int fastExpose = 0; /* for fast exposures with pixmap source */
-
- origSource.x = srcx;
- origSource.y = srcy;
- origSource.width = width;
- origSource.height = height;
- origDest.x = dstx;
- origDest.y = dsty;
-
- if (pSrcDrawable->pScreen->SourceValidate) {
- (*pSrcDrawable->pScreen->SourceValidate) (
- pSrcDrawable, srcx, srcy, width, height,
- pGC->subWindowMode);
- }
-
- srcx += pSrcDrawable->x;
- srcy += pSrcDrawable->y;
-
- /* clip the source */
- if (pSrcDrawable->type == DRAWABLE_PIXMAP) {
- if ((pSrcDrawable == pDstDrawable) && (pGC->clientClipType == CT_NONE))
- prgnSrcClip = pGC->pCompositeClip;
- else
- fastClip = 1;
- } else { /* Window */
- if (pGC->subWindowMode == IncludeInferiors) {
- if (!((WindowPtr) pSrcDrawable)->parent) {
- /*
- * special case bitblt from root window in
- * IncludeInferiors mode; just like from a pixmap
- */
- fastClip = 1;
- } else if ((pSrcDrawable == pDstDrawable) &&
- (pGC->clientClipType == CT_NONE)) {
- prgnSrcClip = pGC->pCompositeClip;
- } else {
- prgnSrcClip = NotClippedByChildren((WindowPtr)pSrcDrawable);
- freeSrcClip = TRUE;
- }
- } else {
- prgnSrcClip = &((WindowPtr)pSrcDrawable)->clipList;
- }
- }
-
- fastBox.x1 = srcx;
- fastBox.y1 = srcy;
- fastBox.x2 = srcx + width;
- fastBox.y2 = srcy + height;
-
- /* Don't create a source region if we are doing a fast clip */
- if (fastClip) {
- fastExpose = 1;
- /*
- * clip the source; if regions extend beyond the source size,
- * make sure exposure events get sent
- */
- if (fastBox.x1 < pSrcDrawable->x) {
- fastBox.x1 = pSrcDrawable->x;
- fastExpose = 0;
- }
- if (fastBox.y1 < pSrcDrawable->y) {
- fastBox.y1 = pSrcDrawable->y;
- fastExpose = 0;
- }
- if (fastBox.x2 > pSrcDrawable->x + (int) pSrcDrawable->width) {
- fastBox.x2 = pSrcDrawable->x + (int) pSrcDrawable->width;
- fastExpose = 0;
- }
- if (fastBox.y2 > pSrcDrawable->y + (int) pSrcDrawable->height) {
- fastBox.y2 = pSrcDrawable->y + (int) pSrcDrawable->height;
- fastExpose = 0;
- }
- } else {
- RegionInit(&rgnDst, &fastBox, 1);
- RegionIntersect(&rgnDst, &rgnDst, prgnSrcClip);
- }
-
- dstx += pDstDrawable->x;
- dsty += pDstDrawable->y;
-
- if (pDstDrawable->type == DRAWABLE_WINDOW) {
- if (!((WindowPtr)pDstDrawable)->realized) {
- if (!fastClip)
- RegionUninit(&rgnDst);
- if (freeSrcClip)
- RegionDestroy(prgnSrcClip);
- return NULL;
- }
- }
-
- dx = srcx - dstx;
- dy = srcy - dsty;
-
- /* Translate and clip the dst to the destination composite clip */
- if (fastClip) {
- RegionPtr cclip;
-
- /* Translate the region directly */
- fastBox.x1 -= dx;
- fastBox.x2 -= dx;
- fastBox.y1 -= dy;
- fastBox.y2 -= dy;
-
- /* If the destination composite clip is one rectangle we can
- do the clip directly. Otherwise we have to create a full
- blown region and call intersect */
-
- cclip = pGC->pCompositeClip;
- if (RegionNumRects(cclip) == 1) {
- BoxPtr pBox = RegionRects(cclip);
-
- if (fastBox.x1 < pBox->x1) fastBox.x1 = pBox->x1;
- if (fastBox.x2 > pBox->x2) fastBox.x2 = pBox->x2;
- if (fastBox.y1 < pBox->y1) fastBox.y1 = pBox->y1;
- if (fastBox.y2 > pBox->y2) fastBox.y2 = pBox->y2;
-
- /* Check to see if the region is empty */
- if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2) {
- RegionNull(&rgnDst);
- } else {
- RegionInit(&rgnDst, &fastBox, 1);
- }
- } else {
- /* We must turn off fastClip now, since we must create
- a full blown region. It is intersected with the
- composite clip below. */
- fastClip = 0;
- RegionInit(&rgnDst, &fastBox,1);
- }
- } else {
- RegionTranslate(&rgnDst, -dx, -dy);
- }
-
- if (!fastClip) {
- RegionIntersect(&rgnDst, &rgnDst,
- pGC->pCompositeClip);
- }
-
- /* Do bit blitting */
- numRects = RegionNumRects(&rgnDst);
- if (numRects && width && height) {
- if(!(pptSrc = (DDXPointPtr)malloc(numRects *
- sizeof(DDXPointRec)))) {
- RegionUninit(&rgnDst);
- if (freeSrcClip)
- RegionDestroy(prgnSrcClip);
- return NULL;
- }
- pbox = RegionRects(&rgnDst);
- ppt = pptSrc;
- for (i = numRects; --i >= 0; pbox++, ppt++) {
- ppt->x = pbox->x1 + dx;
- ppt->y = pbox->y1 + dy;
- }
-
- (*doBitBlt) (pSrcDrawable, pDstDrawable, pGC, &rgnDst, pptSrc);
- free(pptSrc);
- }
-
- prgnExposed = NULL;
- if (pGC->fExpose) {
- /* Pixmap sources generate a NoExposed (we return NULL to do this) */
- if (!fastExpose)
- prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC,
- origSource.x, origSource.y,
- (int)origSource.width,
- (int)origSource.height,
- origDest.x, origDest.y, bitPlane);
- }
- RegionUninit(&rgnDst);
- if (freeSrcClip)
- RegionDestroy(prgnSrcClip);
- return prgnExposed;
-}
+
+/*
+ This is a lighter version of cfbBitBlt. We calculate the boxes
+ when accelerating pixmap->screen and screen->screen copies.
+ We also pass the GC to the doBitBlt function so that it has access
+ to the fg and bg so CopyPlane can use this.
+*/
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "mi.h"
+#include "pixmapstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "xaalocal.h"
+
+RegionPtr
+XAABitBlt(DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GC * pGC,
+ int srcx, int srcy,
+ int width, int height,
+ int dstx, int dsty,
+ void (*doBitBlt) (DrawablePtr, DrawablePtr, GCPtr, RegionPtr,
+ DDXPointPtr), unsigned long bitPlane)
+{
+
+ RegionPtr prgnSrcClip = NULL; /* may be a new region, or just a copy */
+ RegionPtr prgnExposed;
+ Bool freeSrcClip = FALSE;
+ RegionRec rgnDst;
+ DDXPointPtr pptSrc, ppt;
+ DDXPointRec origDest;
+ BoxPtr pbox;
+ BoxRec fastBox;
+ int i, dx, dy, numRects;
+ xRectangle origSource;
+ int fastClip = 0; /* for fast clipping with pixmap source */
+ int fastExpose = 0; /* for fast exposures with pixmap source */
+
+ origSource.x = srcx;
+ origSource.y = srcy;
+ origSource.width = width;
+ origSource.height = height;
+ origDest.x = dstx;
+ origDest.y = dsty;
+
+ if (pSrcDrawable->pScreen->SourceValidate) {
+ (*pSrcDrawable->pScreen->SourceValidate) (pSrcDrawable, srcx, srcy,
+ width, height,
+ pGC->subWindowMode);
+ }
+
+ srcx += pSrcDrawable->x;
+ srcy += pSrcDrawable->y;
+
+ /* clip the source */
+ if (pSrcDrawable->type == DRAWABLE_PIXMAP) {
+ if ((pSrcDrawable == pDstDrawable) && (pGC->clientClipType == CT_NONE))
+ prgnSrcClip = pGC->pCompositeClip;
+ else
+ fastClip = 1;
+ }
+ else { /* Window */
+ if (pGC->subWindowMode == IncludeInferiors) {
+ if (!((WindowPtr) pSrcDrawable)->parent) {
+ /*
+ * special case bitblt from root window in
+ * IncludeInferiors mode; just like from a pixmap
+ */
+ fastClip = 1;
+ }
+ else if ((pSrcDrawable == pDstDrawable) &&
+ (pGC->clientClipType == CT_NONE)) {
+ prgnSrcClip = pGC->pCompositeClip;
+ }
+ else {
+ prgnSrcClip = NotClippedByChildren((WindowPtr) pSrcDrawable);
+ freeSrcClip = TRUE;
+ }
+ }
+ else {
+ prgnSrcClip = &((WindowPtr) pSrcDrawable)->clipList;
+ }
+ }
+
+ fastBox.x1 = srcx;
+ fastBox.y1 = srcy;
+ fastBox.x2 = srcx + width;
+ fastBox.y2 = srcy + height;
+
+ /* Don't create a source region if we are doing a fast clip */
+ if (fastClip) {
+ fastExpose = 1;
+ /*
+ * clip the source; if regions extend beyond the source size,
+ * make sure exposure events get sent
+ */
+ if (fastBox.x1 < pSrcDrawable->x) {
+ fastBox.x1 = pSrcDrawable->x;
+ fastExpose = 0;
+ }
+ if (fastBox.y1 < pSrcDrawable->y) {
+ fastBox.y1 = pSrcDrawable->y;
+ fastExpose = 0;
+ }
+ if (fastBox.x2 > pSrcDrawable->x + (int) pSrcDrawable->width) {
+ fastBox.x2 = pSrcDrawable->x + (int) pSrcDrawable->width;
+ fastExpose = 0;
+ }
+ if (fastBox.y2 > pSrcDrawable->y + (int) pSrcDrawable->height) {
+ fastBox.y2 = pSrcDrawable->y + (int) pSrcDrawable->height;
+ fastExpose = 0;
+ }
+ }
+ else {
+ RegionInit(&rgnDst, &fastBox, 1);
+ RegionIntersect(&rgnDst, &rgnDst, prgnSrcClip);
+ }
+
+ dstx += pDstDrawable->x;
+ dsty += pDstDrawable->y;
+
+ if (pDstDrawable->type == DRAWABLE_WINDOW) {
+ if (!((WindowPtr) pDstDrawable)->realized) {
+ if (!fastClip)
+ RegionUninit(&rgnDst);
+ if (freeSrcClip)
+ RegionDestroy(prgnSrcClip);
+ return NULL;
+ }
+ }
+
+ dx = srcx - dstx;
+ dy = srcy - dsty;
+
+ /* Translate and clip the dst to the destination composite clip */
+ if (fastClip) {
+ RegionPtr cclip;
+
+ /* Translate the region directly */
+ fastBox.x1 -= dx;
+ fastBox.x2 -= dx;
+ fastBox.y1 -= dy;
+ fastBox.y2 -= dy;
+
+ /* If the destination composite clip is one rectangle we can
+ do the clip directly. Otherwise we have to create a full
+ blown region and call intersect */
+
+ cclip = pGC->pCompositeClip;
+ if (RegionNumRects(cclip) == 1) {
+ BoxPtr pBox = RegionRects(cclip);
+
+ if (fastBox.x1 < pBox->x1)
+ fastBox.x1 = pBox->x1;
+ if (fastBox.x2 > pBox->x2)
+ fastBox.x2 = pBox->x2;
+ if (fastBox.y1 < pBox->y1)
+ fastBox.y1 = pBox->y1;
+ if (fastBox.y2 > pBox->y2)
+ fastBox.y2 = pBox->y2;
+
+ /* Check to see if the region is empty */
+ if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2) {
+ RegionNull(&rgnDst);
+ }
+ else {
+ RegionInit(&rgnDst, &fastBox, 1);
+ }
+ }
+ else {
+ /* We must turn off fastClip now, since we must create
+ a full blown region. It is intersected with the
+ composite clip below. */
+ fastClip = 0;
+ RegionInit(&rgnDst, &fastBox, 1);
+ }
+ }
+ else {
+ RegionTranslate(&rgnDst, -dx, -dy);
+ }
+
+ if (!fastClip) {
+ RegionIntersect(&rgnDst, &rgnDst, pGC->pCompositeClip);
+ }
+
+ /* Do bit blitting */
+ numRects = RegionNumRects(&rgnDst);
+ if (numRects && width && height) {
+ if (!(pptSrc = (DDXPointPtr) malloc(numRects * sizeof(DDXPointRec)))) {
+ RegionUninit(&rgnDst);
+ if (freeSrcClip)
+ RegionDestroy(prgnSrcClip);
+ return NULL;
+ }
+ pbox = RegionRects(&rgnDst);
+ ppt = pptSrc;
+ for (i = numRects; --i >= 0; pbox++, ppt++) {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ }
+
+ (*doBitBlt) (pSrcDrawable, pDstDrawable, pGC, &rgnDst, pptSrc);
+ free(pptSrc);
+ }
+
+ prgnExposed = NULL;
+ if (pGC->fExpose) {
+ /* Pixmap sources generate a NoExposed (we return NULL to do this) */
+ if (!fastExpose)
+ prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC,
+ origSource.x, origSource.y,
+ (int) origSource.width,
+ (int) origSource.height,
+ origDest.x, origDest.y, bitPlane);
+ }
+ RegionUninit(&rgnDst);
+ if (freeSrcClip)
+ RegionDestroy(prgnSrcClip);
+ return prgnExposed;
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaBitmap.c b/xorg-server/hw/xfree86/xaa/xaaBitmap.c
index f7ae78d3f..45d5a09be 100644
--- a/xorg-server/hw/xfree86/xaa/xaaBitmap.c
+++ b/xorg-server/hw/xfree86/xaa/xaaBitmap.c
@@ -1,5 +1,4 @@
-
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
@@ -9,241 +8,236 @@
#include "xaacexp.h"
#include "xf86.h"
-
/********** byte swapping ***************/
-
#ifdef FIXEDBASE
-# define DEST(i) *dest
-# define RETURN(i) return(dest)
+#define DEST(i) *dest
+#define RETURN(i) return(dest)
#else
-# define DEST(i) dest[i]
-# define RETURN(i) return(dest + i)
+#define DEST(i) dest[i]
+#define RETURN(i) return(dest + i)
#endif
#ifdef MSBFIRST
-# define SOURCE(i) SWAP_BITS_IN_BYTES(src[i])
+#define SOURCE(i) SWAP_BITS_IN_BYTES(src[i])
#else
-# define SOURCE(i) src[i]
+#define SOURCE(i) src[i]
#endif
-
-typedef CARD32 *(* BitmapScanlineProcPtr)(CARD32 *, CARD32 *, int, int);
+typedef CARD32 *(*BitmapScanlineProcPtr) (CARD32 *, CARD32 *, int, int);
#ifdef TRIPLE_BITS
-static CARD32*
-BitmapScanline(
- CARD32 *src, CARD32 *base,
- int count, int skipleft )
+static CARD32 *
+BitmapScanline(CARD32 *src, CARD32 *base, int count, int skipleft)
{
- CARD32 bits;
-
- while(count >= 3) {
- bits = *src;
- WRITE_BITS3(bits);
- src++;
- count -= 3;
- }
- if (count == 2) {
- bits = *src;
- WRITE_BITS2(bits);
- } else if (count == 1) {
- bits = *src;
- WRITE_BITS1(bits);
- }
-
- return base;
+ CARD32 bits;
+
+ while (count >= 3) {
+ bits = *src;
+ WRITE_BITS3(bits);
+ src++;
+ count -= 3;
+ }
+ if (count == 2) {
+ bits = *src;
+ WRITE_BITS2(bits);
+ }
+ else if (count == 1) {
+ bits = *src;
+ WRITE_BITS1(bits);
+ }
+
+ return base;
}
-static CARD32*
-BitmapScanline_Inverted(
- CARD32 *src, CARD32 *base,
- int count, int skipleft )
+static CARD32 *
+BitmapScanline_Inverted(CARD32 *src, CARD32 *base, int count, int skipleft)
{
- CARD32 bits;
-
- while(count >= 3) {
- bits = ~(*src);
- WRITE_BITS3(bits);
- src++;
- count -= 3;
- }
- if (count == 2) {
- bits = ~(*src);
- WRITE_BITS2(bits);
- } else if (count == 1) {
- bits = ~(*src);
- WRITE_BITS1(bits);
- }
-
- return base;
-}
+ CARD32 bits;
+ while (count >= 3) {
+ bits = ~(*src);
+ WRITE_BITS3(bits);
+ src++;
+ count -= 3;
+ }
+ if (count == 2) {
+ bits = ~(*src);
+ WRITE_BITS2(bits);
+ }
+ else if (count == 1) {
+ bits = ~(*src);
+ WRITE_BITS1(bits);
+ }
-static CARD32*
-BitmapScanline_Shifted(
- CARD32 *src, CARD32 *base,
- int count, int skipleft )
+ return base;
+}
+
+static CARD32 *
+BitmapScanline_Shifted(CARD32 *src, CARD32 *base, int count, int skipleft)
{
- CARD32 bits;
-
- while(count >= 3) {
- bits = SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft));
- WRITE_BITS3(bits);
- src++;
- count -= 3;
- }
- if (count == 2) {
- bits = SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft));
- WRITE_BITS2(bits);
- } else if (count == 1) {
- bits = SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft));
- WRITE_BITS1(bits);
- }
-
- return base;
+ CARD32 bits;
+
+ while (count >= 3) {
+ bits = SHIFT_R(*src, skipleft) | SHIFT_L(*(src + 1), (32 - skipleft));
+ WRITE_BITS3(bits);
+ src++;
+ count -= 3;
+ }
+ if (count == 2) {
+ bits = SHIFT_R(*src, skipleft) | SHIFT_L(*(src + 1), (32 - skipleft));
+ WRITE_BITS2(bits);
+ }
+ else if (count == 1) {
+ bits = SHIFT_R(*src, skipleft) | SHIFT_L(*(src + 1), (32 - skipleft));
+ WRITE_BITS1(bits);
+ }
+
+ return base;
}
-static CARD32*
-BitmapScanline_Shifted_Inverted(
- CARD32 *src, CARD32 *base,
- int count, int skipleft )
+static CARD32 *
+BitmapScanline_Shifted_Inverted(CARD32 *src, CARD32 *base,
+ int count, int skipleft)
{
- CARD32 bits;
-
- while(count >= 3) {
- bits = ~(SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft)));
- WRITE_BITS3(bits);
- src++;
- count -= 3;
- }
- if (count == 2) {
- bits = ~(SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft)));
- WRITE_BITS2(bits);
- } else if (count == 1) {
- bits = ~(SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft)));
- WRITE_BITS1(bits);
- }
-
- return base;
+ CARD32 bits;
+
+ while (count >= 3) {
+ bits =
+ ~(SHIFT_R(*src, skipleft) | SHIFT_L(*(src + 1), (32 - skipleft)));
+ WRITE_BITS3(bits);
+ src++;
+ count -= 3;
+ }
+ if (count == 2) {
+ bits =
+ ~(SHIFT_R(*src, skipleft) | SHIFT_L(*(src + 1), (32 - skipleft)));
+ WRITE_BITS2(bits);
+ }
+ else if (count == 1) {
+ bits =
+ ~(SHIFT_R(*src, skipleft) | SHIFT_L(*(src + 1), (32 - skipleft)));
+ WRITE_BITS1(bits);
+ }
+
+ return base;
}
#define BitmapScanline_Shifted_Careful BitmapScanline_Shifted
#define BitmapScanline_Shifted_Inverted_Careful BitmapScanline_Shifted_Inverted
#else
-static CARD32*
-BitmapScanline(
- CARD32 *src, CARD32 *dest,
- int count, int skipleft )
+static CARD32 *
+BitmapScanline(CARD32 *src, CARD32 *dest, int count, int skipleft)
{
- while(count >= 4) {
- DEST(0) = SOURCE(0);
- DEST(1) = SOURCE(1);
- DEST(2) = SOURCE(2);
- DEST(3) = SOURCE(3);
- count -= 4;
- src += 4;
+ while (count >= 4) {
+ DEST(0) = SOURCE(0);
+ DEST(1) = SOURCE(1);
+ DEST(2) = SOURCE(2);
+ DEST(3) = SOURCE(3);
+ count -= 4;
+ src += 4;
#ifndef FIXEDBASE
- dest += 4;
+ dest += 4;
#endif
- }
-
- if(!count) return dest;
- DEST(0) = SOURCE(0);
- if(count == 1) RETURN(1);
- DEST(1) = SOURCE(1);
- if(count == 2) RETURN(2);
- DEST(2) = SOURCE(2);
- RETURN(3);
+ }
+
+ if (!count)
+ return dest;
+ DEST(0) = SOURCE(0);
+ if (count == 1)
+ RETURN(1);
+ DEST(1) = SOURCE(1);
+ if (count == 2)
+ RETURN(2);
+ DEST(2) = SOURCE(2);
+ RETURN(3);
}
-static CARD32*
-BitmapScanline_Inverted(
- CARD32 *src, CARD32 *dest,
- int count, int skipleft )
+static CARD32 *
+BitmapScanline_Inverted(CARD32 *src, CARD32 *dest, int count, int skipleft)
{
- while(count >= 4) {
- DEST(0) = ~SOURCE(0);
- DEST(1) = ~SOURCE(1);
- DEST(2) = ~SOURCE(2);
- DEST(3) = ~SOURCE(3);
- count -= 4;
- src += 4;
+ while (count >= 4) {
+ DEST(0) = ~SOURCE(0);
+ DEST(1) = ~SOURCE(1);
+ DEST(2) = ~SOURCE(2);
+ DEST(3) = ~SOURCE(3);
+ count -= 4;
+ src += 4;
#ifndef FIXEDBASE
- dest += 4;
+ dest += 4;
#endif
- }
-
- if(!count) return dest;
- DEST(0) = ~SOURCE(0);
- if(count == 1) RETURN(1);
- DEST(1) = ~SOURCE(1);
- if(count == 2) RETURN(2);
- DEST(2) = ~SOURCE(2);
- RETURN(3);
-}
+ }
+ if (!count)
+ return dest;
+ DEST(0) = ~SOURCE(0);
+ if (count == 1)
+ RETURN(1);
+ DEST(1) = ~SOURCE(1);
+ if (count == 2)
+ RETURN(2);
+ DEST(2) = ~SOURCE(2);
+ RETURN(3);
+}
-static CARD32*
-BitmapScanline_Shifted(
- CARD32 *bits, CARD32 *base,
- int count, int skipleft )
+static CARD32 *
+BitmapScanline_Shifted(CARD32 *bits, CARD32 *base, int count, int skipleft)
{
- while(count--) {
- register CARD32 tmp = SHIFT_R(*bits,skipleft) |
- SHIFT_L(*(bits + 1),(32 - skipleft));
- WRITE_BITS(tmp);
- bits++;
- }
- return base;
+ while (count--) {
+ register CARD32 tmp = SHIFT_R(*bits, skipleft) |
+ SHIFT_L(*(bits + 1), (32 - skipleft));
+ WRITE_BITS(tmp);
+ bits++;
+ }
+ return base;
}
-static CARD32*
-BitmapScanline_Shifted_Inverted(
- CARD32 *bits, CARD32 *base,
- int count, int skipleft )
+static CARD32 *
+BitmapScanline_Shifted_Inverted(CARD32 *bits, CARD32 *base,
+ int count, int skipleft)
{
- while(count--) {
- register CARD32 tmp = ~(SHIFT_R(*bits,skipleft) |
- SHIFT_L(*(bits + 1),(32 - skipleft)));
- WRITE_BITS(tmp);
- bits++;
- }
- return base;
+ while (count--) {
+ register CARD32 tmp = ~(SHIFT_R(*bits, skipleft) |
+ SHIFT_L(*(bits + 1), (32 - skipleft)));
+ WRITE_BITS(tmp);
+ bits++;
+ }
+ return base;
}
-static CARD32*
-BitmapScanline_Shifted_Careful(
- CARD32 *bits, CARD32 *base,
- int count, int skipleft )
+static CARD32 *
+BitmapScanline_Shifted_Careful(CARD32 *bits, CARD32 *base,
+ int count, int skipleft)
{
- register CARD32 tmp;
- while(--count) {
- tmp = SHIFT_R(*bits,skipleft) | SHIFT_L(*(bits + 1),(32 - skipleft));
- WRITE_BITS(tmp);
- bits++;
- }
- tmp = SHIFT_R(*bits,skipleft);
- WRITE_BITS(tmp);
-
- return base;
+ register CARD32 tmp;
+
+ while (--count) {
+ tmp = SHIFT_R(*bits, skipleft) | SHIFT_L(*(bits + 1), (32 - skipleft));
+ WRITE_BITS(tmp);
+ bits++;
+ }
+ tmp = SHIFT_R(*bits, skipleft);
+ WRITE_BITS(tmp);
+
+ return base;
}
-static CARD32*
-BitmapScanline_Shifted_Inverted_Careful(
- CARD32 *bits, CARD32 *base,
- int count, int skipleft )
+static CARD32 *
+BitmapScanline_Shifted_Inverted_Careful(CARD32 *bits, CARD32 *base,
+ int count, int skipleft)
{
- register CARD32 tmp;
- while(--count) {
- tmp = ~(SHIFT_R(*bits,skipleft) | SHIFT_L(*(bits + 1),(32 - skipleft)));
- WRITE_BITS(tmp);
- bits++;
- }
- tmp = ~(SHIFT_R(*bits,skipleft));
- WRITE_BITS(tmp);
- return base;
+ register CARD32 tmp;
+
+ while (--count) {
+ tmp =
+ ~(SHIFT_R(*bits, skipleft) | SHIFT_L(*(bits + 1), (32 - skipleft)));
+ WRITE_BITS(tmp);
+ bits++;
+ }
+ tmp = ~(SHIFT_R(*bits, skipleft));
+ WRITE_BITS(tmp);
+ return base;
}
#endif
@@ -253,26 +247,23 @@ BitmapScanline_Shifted_Inverted_Careful(
the fill in two passes, inverting the source on the second pass.
For GXcopy we can fill the backing rectangle as a solid rect and
avoid the invert.
-*/
+*/
void
#ifdef TRIPLE_BITS
-EXPNAME(XAAWriteBitmapColorExpand3)(
+ EXPNAME(XAAWriteBitmapColorExpand3) (
#else
-EXPNAME(XAAWriteBitmapColorExpand)(
+ EXPNAME(XAAWriteBitmapColorExpand) (
#endif
- ScrnInfoPtr pScrn,
- int x, int y, int w, int H,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-)
-{
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int H,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop, unsigned int planemask) {
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- CARD32* base;
+ CARD32 *base;
unsigned char *srcp = src;
int SecondPassColor = -1;
int shift = 0, dwords;
@@ -282,44 +273,49 @@ EXPNAME(XAAWriteBitmapColorExpand)(
int h = H;
#ifdef TRIPLE_BITS
- if((bg != -1) &&
- ((infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) ||
- ((infoRec->CPUToScreenColorExpandFillFlags & RGB_EQUAL) &&
- (!CHECK_RGB_EQUAL(bg))))) {
+ if ((bg != -1) &&
+ ((infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) ||
+ ((infoRec->CPUToScreenColorExpandFillFlags & RGB_EQUAL) &&
+ (!CHECK_RGB_EQUAL(bg))))) {
#else
- if((bg != -1) &&
- (infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) {
+ if ((bg != -1) &&
+ (infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) {
#endif
- if((rop == GXcopy) && infoRec->SetupForSolidFill) {
- (*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask);
- (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h);
- } else SecondPassColor = bg;
- bg = -1;
+ if ((rop == GXcopy) && infoRec->SetupForSolidFill) {
+ (*infoRec->SetupForSolidFill) (pScrn, bg, rop, planemask);
+ (*infoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h);
+ }
+ else
+ SecondPassColor = bg;
+ bg = -1;
}
#ifdef TRIPLE_BITS
- if(skipleft) {
+ if (skipleft) {
#else
- if(skipleft &&
- (!(infoRec->CPUToScreenColorExpandFillFlags & LEFT_EDGE_CLIPPING) ||
- (!(infoRec->CPUToScreenColorExpandFillFlags & LEFT_EDGE_CLIPPING_NEGATIVE_X) &&
- (skipleft > x)))) {
+ if (skipleft &&
+ (!(infoRec->CPUToScreenColorExpandFillFlags & LEFT_EDGE_CLIPPING) ||
+ (!(infoRec->
+ CPUToScreenColorExpandFillFlags & LEFT_EDGE_CLIPPING_NEGATIVE_X) &&
+ (skipleft > x)))) {
#endif
- if((skipleft + ((w + 31) & ~31)) > ((skipleft + w + 31) & ~31)) {
- /* don't read past the end */
- firstFunc = BitmapScanline_Shifted_Careful;
- secondFunc = BitmapScanline_Shifted_Inverted_Careful;
- } else {
- firstFunc = BitmapScanline_Shifted;
- secondFunc = BitmapScanline_Shifted_Inverted;
- }
- shift = skipleft;
- skipleft = 0;
- } else {
- firstFunc = BitmapScanline;
- secondFunc = BitmapScanline_Inverted;
- w += skipleft;
- x -= skipleft;
+ if ((skipleft + ((w + 31) & ~31)) > ((skipleft + w + 31) & ~31)) {
+ /* don't read past the end */
+ firstFunc = BitmapScanline_Shifted_Careful;
+ secondFunc = BitmapScanline_Shifted_Inverted_Careful;
+ }
+ else {
+ firstFunc = BitmapScanline_Shifted;
+ secondFunc = BitmapScanline_Shifted_Inverted;
+ }
+ shift = skipleft;
+ skipleft = 0;
+ }
+ else {
+ firstFunc = BitmapScanline;
+ secondFunc = BitmapScanline_Inverted;
+ w += skipleft;
+ x -= skipleft;
}
#ifdef TRIPLE_BITS
@@ -328,69 +324,68 @@ EXPNAME(XAAWriteBitmapColorExpand)(
dwords = (w + 31) >> 5;
#endif
-SECOND_PASS:
+ SECOND_PASS:
- flag = (infoRec->CPUToScreenColorExpandFillFlags
- & CPU_TRANSFER_PAD_QWORD) && ((dwords * h) & 0x01);
- (*infoRec->SetupForCPUToScreenColorExpandFill)(
- pScrn, fg, bg, rop, planemask);
- (*infoRec->SubsequentCPUToScreenColorExpandFill)(
- pScrn, x, y, w, h, skipleft);
+ flag = (infoRec->CPUToScreenColorExpandFillFlags
+ & CPU_TRANSFER_PAD_QWORD) && ((dwords * h) & 0x01);
+ (*infoRec->SetupForCPUToScreenColorExpandFill) (pScrn, fg, bg, rop,
+ planemask);
+ (*infoRec->SubsequentCPUToScreenColorExpandFill) (pScrn, x, y, w, h,
+ skipleft);
- base = (CARD32*)infoRec->ColorExpandBase;
+ base = (CARD32 *) infoRec->ColorExpandBase;
#ifndef FIXEDBASE
- if((dwords * h) <= infoRec->ColorExpandRange)
- while(h--) {
- base = (*firstFunc)((CARD32*)srcp, base, dwords, shift);
- srcp += srcwidth;
- }
+ if ((dwords * h) <= infoRec->ColorExpandRange)
+ while (h--) {
+ base = (*firstFunc) ((CARD32 *) srcp, base, dwords, shift);
+ srcp += srcwidth;
+ }
else
#endif
- while(h--) {
- (*firstFunc)((CARD32*)srcp, base, dwords, shift);
- srcp += srcwidth;
- }
-
- if(flag){
- base = (CARD32*)infoRec->ColorExpandBase;
- base[0] = 0x00000000;
+ while (h--) {
+ (*firstFunc) ((CARD32 *) srcp, base, dwords, shift);
+ srcp += srcwidth;
+ }
+
+ if (flag) {
+ base = (CARD32 *) infoRec->ColorExpandBase;
+ base[0] = 0x00000000;
}
- if(SecondPassColor != -1) {
- h = H; /* Reset height */
- fg = SecondPassColor;
- SecondPassColor = -1;
- firstFunc = secondFunc;
- srcp = src;
- goto SECOND_PASS;
+ if (SecondPassColor != -1) {
+ h = H; /* Reset height */
+ fg = SecondPassColor;
+ SecondPassColor = -1;
+ firstFunc = secondFunc;
+ srcp = src;
+ goto SECOND_PASS;
}
- if(infoRec->CPUToScreenColorExpandFillFlags & SYNC_AFTER_COLOR_EXPAND)
- (*infoRec->Sync)(pScrn);
- else SET_SYNC_FLAG(infoRec);
+ if (infoRec->CPUToScreenColorExpandFillFlags & SYNC_AFTER_COLOR_EXPAND)
+ (*infoRec->Sync) (pScrn);
+ else
+ SET_SYNC_FLAG(infoRec);
}
#ifndef FIXEDBASE
void
#ifdef TRIPLE_BITS
-EXPNAME(XAAWriteBitmapScanlineColorExpand3)(
+ EXPNAME(XAAWriteBitmapScanlineColorExpand3) (
#else
-EXPNAME(XAAWriteBitmapScanlineColorExpand)(
+ EXPNAME(XAAWriteBitmapScanlineColorExpand) (
#endif
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-)
-{
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask) {
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- CARD32* base;
+ CARD32 *base;
unsigned char *srcp = src;
int SecondPassColor = -1;
int shift = 0, dwords, bufferNo;
@@ -398,45 +393,50 @@ EXPNAME(XAAWriteBitmapScanlineColorExpand)(
BitmapScanlineProcPtr secondFunc;
#ifdef TRIPLE_BITS
- if((bg != -1) &&
- ((infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)
- || ((infoRec->ScanlineCPUToScreenColorExpandFillFlags & RGB_EQUAL) &&
- (!CHECK_RGB_EQUAL(bg))))) {
+ if ((bg != -1) &&
+ ((infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)
+ || ((infoRec->ScanlineCPUToScreenColorExpandFillFlags & RGB_EQUAL) &&
+ (!CHECK_RGB_EQUAL(bg))))) {
#else
- if((bg != -1) &&
- (infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)){
+ if ((bg != -1) &&
+ (infoRec->
+ ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) {
#endif
- if((rop == GXcopy) && infoRec->SetupForSolidFill) {
- (*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask);
- (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h);
- } else SecondPassColor = bg;
- bg = -1;
+ if ((rop == GXcopy) && infoRec->SetupForSolidFill) {
+ (*infoRec->SetupForSolidFill) (pScrn, bg, rop, planemask);
+ (*infoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h);
+ }
+ else
+ SecondPassColor = bg;
+ bg = -1;
}
#ifdef TRIPLE_BITS
- if(skipleft) {
+ if (skipleft) {
#else
- if(skipleft &&
- (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
- LEFT_EDGE_CLIPPING) ||
- (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
- LEFT_EDGE_CLIPPING_NEGATIVE_X) && (skipleft > x)))) {
+ if (skipleft &&
+ (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
+ LEFT_EDGE_CLIPPING) ||
+ (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
+ LEFT_EDGE_CLIPPING_NEGATIVE_X) && (skipleft > x)))) {
#endif
- if((skipleft + ((w + 31) & ~31)) > ((skipleft + w + 31) & ~31)) {
- /* don't read past the end */
- firstFunc = BitmapScanline_Shifted_Careful;
- secondFunc = BitmapScanline_Shifted_Inverted_Careful;
- } else {
- firstFunc = BitmapScanline_Shifted;
- secondFunc = BitmapScanline_Shifted_Inverted;
- }
- shift = skipleft;
- skipleft = 0;
- } else {
- firstFunc = BitmapScanline;
- secondFunc = BitmapScanline_Inverted;
- w += skipleft;
- x -= skipleft;
+ if ((skipleft + ((w + 31) & ~31)) > ((skipleft + w + 31) & ~31)) {
+ /* don't read past the end */
+ firstFunc = BitmapScanline_Shifted_Careful;
+ secondFunc = BitmapScanline_Shifted_Inverted_Careful;
+ }
+ else {
+ firstFunc = BitmapScanline_Shifted;
+ secondFunc = BitmapScanline_Shifted_Inverted;
+ }
+ shift = skipleft;
+ skipleft = 0;
+ }
+ else {
+ firstFunc = BitmapScanline;
+ secondFunc = BitmapScanline_Inverted;
+ w += skipleft;
+ x -= skipleft;
}
#ifdef TRIPLE_BITS
@@ -445,29 +445,30 @@ EXPNAME(XAAWriteBitmapScanlineColorExpand)(
dwords = (w + 31) >> 5;
#endif
-SECOND_PASS:
+ SECOND_PASS:
- (*infoRec->SetupForScanlineCPUToScreenColorExpandFill)(pScrn, fg, bg, rop, planemask);
- (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)(
- pScrn, x, y, w, h, skipleft);
+ (*infoRec->SetupForScanlineCPUToScreenColorExpandFill) (pScrn, fg, bg, rop,
+ planemask);
+ (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill) (pScrn, x, y, w, h,
+ skipleft);
bufferNo = 0;
- while(h--) {
- base = (CARD32*)infoRec->ScanlineColorExpandBuffers[bufferNo];
- (*firstFunc)((CARD32*)srcp, base, dwords, shift);
- (*infoRec->SubsequentColorExpandScanline)(pScrn, bufferNo++);
- srcp += srcwidth;
- if(bufferNo >= infoRec->NumScanlineColorExpandBuffers)
- bufferNo = 0;
+ while (h--) {
+ base = (CARD32 *) infoRec->ScanlineColorExpandBuffers[bufferNo];
+ (*firstFunc) ((CARD32 *) srcp, base, dwords, shift);
+ (*infoRec->SubsequentColorExpandScanline) (pScrn, bufferNo++);
+ srcp += srcwidth;
+ if (bufferNo >= infoRec->NumScanlineColorExpandBuffers)
+ bufferNo = 0;
}
- if(SecondPassColor != -1) {
- fg = SecondPassColor;
- SecondPassColor = -1;
- firstFunc = secondFunc;
- srcp = src;
- goto SECOND_PASS;
+ if (SecondPassColor != -1) {
+ fg = SecondPassColor;
+ SecondPassColor = -1;
+ firstFunc = secondFunc;
+ srcp = src;
+ goto SECOND_PASS;
}
SET_SYNC_FLAG(infoRec);
diff --git a/xorg-server/hw/xfree86/xaa/xaaCpyArea.c b/xorg-server/hw/xfree86/xaa/xaaCpyArea.c
index 5e594633d..0b11b810e 100644
--- a/xorg-server/hw/xfree86/xaa/xaaCpyArea.c
+++ b/xorg-server/hw/xfree86/xaa/xaaCpyArea.c
@@ -1,387 +1,409 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-#include "migc.h"
-#include "gcstruct.h"
-#include "pixmapstr.h"
-
-/*
- Written mostly by Harm Hanemaayer (H.Hanemaayer@inter.nl.net).
- */
-
-
-RegionPtr
-XAACopyArea(
- DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GC *pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-
- if(pDstDrawable->type == DRAWABLE_WINDOW) {
- if((pSrcDrawable->type == DRAWABLE_WINDOW) ||
- IS_OFFSCREEN_PIXMAP(pSrcDrawable)){
- if(infoRec->ScreenToScreenBitBlt &&
- CHECK_ROP(pGC,infoRec->ScreenToScreenBitBltFlags) &&
- CHECK_ROPSRC(pGC,infoRec->ScreenToScreenBitBltFlags) &&
- CHECK_PLANEMASK(pGC,infoRec->ScreenToScreenBitBltFlags))
- return (XAABitBlt( pSrcDrawable, pDstDrawable,
- pGC, srcx, srcy, width, height, dstx, dsty,
- XAADoBitBlt, 0L));
- } else {
- if(infoRec->WritePixmap &&
- ((pDstDrawable->bitsPerPixel == pSrcDrawable->bitsPerPixel) ||
- ((pDstDrawable->bitsPerPixel == 24) &&
- (pSrcDrawable->bitsPerPixel == 32) &&
- (infoRec->WritePixmapFlags & CONVERT_32BPP_TO_24BPP))) &&
- CHECK_ROP(pGC,infoRec->WritePixmapFlags) &&
- CHECK_ROPSRC(pGC,infoRec->WritePixmapFlags) &&
- CHECK_PLANEMASK(pGC,infoRec->WritePixmapFlags) &&
- CHECK_NO_GXCOPY(pGC,infoRec->WritePixmapFlags))
- return (XAABitBlt( pSrcDrawable, pDstDrawable,
- pGC, srcx, srcy, width, height, dstx, dsty,
- XAADoImageWrite, 0L));
- }
- } else if(IS_OFFSCREEN_PIXMAP(pDstDrawable)){
- if((pSrcDrawable->type == DRAWABLE_WINDOW) ||
- IS_OFFSCREEN_PIXMAP(pSrcDrawable)){
- if(infoRec->ScreenToScreenBitBlt &&
- CHECK_ROP(pGC,infoRec->ScreenToScreenBitBltFlags) &&
- CHECK_ROPSRC(pGC,infoRec->ScreenToScreenBitBltFlags) &&
- CHECK_PLANEMASK(pGC,infoRec->ScreenToScreenBitBltFlags))
- return (XAABitBlt( pSrcDrawable, pDstDrawable,
- pGC, srcx, srcy, width, height, dstx, dsty,
- XAADoBitBlt, 0L));
- }
- }
-
- return (XAAFallbackOps.CopyArea(pSrcDrawable, pDstDrawable, pGC,
- srcx, srcy, width, height, dstx, dsty));
-}
-
-
-void
-XAADoBitBlt(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GC *pGC,
- RegionPtr prgnDst,
- DDXPointPtr pptSrc )
-{
- int nbox, careful;
- BoxPtr pbox, pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2;
- DDXPointPtr pptTmp, pptNew1, pptNew2;
- int xdir, ydir;
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-
- /* XXX we have to err on the side of safety when both are windows,
- * because we don't know if IncludeInferiors is being used.
- */
- careful = ((pSrc == pDst) ||
- ((pSrc->type == DRAWABLE_WINDOW) &&
- (pDst->type == DRAWABLE_WINDOW)));
-
- pbox = RegionRects(prgnDst);
- nbox = RegionNumRects(prgnDst);
-
- pboxNew1 = NULL;
- pptNew1 = NULL;
- pboxNew2 = NULL;
- pptNew2 = NULL;
- if (careful && (pptSrc->y < pbox->y1)) {
- /* walk source botttom to top */
- ydir = -1;
-
- if (nbox > 1) {
- /* keep ordering in each band, reverse order of bands */
- pboxNew1 = (BoxPtr)malloc(sizeof(BoxRec) * nbox);
- if(!pboxNew1)
- return;
- pptNew1 = (DDXPointPtr)malloc(sizeof(DDXPointRec) * nbox);
- if(!pptNew1) {
- free(pboxNew1);
- return;
- }
- pboxBase = pboxNext = pbox+nbox-1;
- while (pboxBase >= pbox) {
- while ((pboxNext >= pbox) &&
- (pboxBase->y1 == pboxNext->y1))
- pboxNext--;
- pboxTmp = pboxNext+1;
- pptTmp = pptSrc + (pboxTmp - pbox);
- while (pboxTmp <= pboxBase) {
- *pboxNew1++ = *pboxTmp++;
- *pptNew1++ = *pptTmp++;
- }
- pboxBase = pboxNext;
- }
- pboxNew1 -= nbox;
- pbox = pboxNew1;
- pptNew1 -= nbox;
- pptSrc = pptNew1;
- }
- } else {
- /* walk source top to bottom */
- ydir = 1;
- }
-
- if (careful && (pptSrc->x < pbox->x1)) {
- /* walk source right to left */
- xdir = -1;
-
- if (nbox > 1) {
- /* reverse order of rects in each band */
- pboxNew2 = (BoxPtr)malloc(sizeof(BoxRec) * nbox);
- pptNew2 = (DDXPointPtr)malloc(sizeof(DDXPointRec) * nbox);
- if(!pboxNew2 || !pptNew2) {
- free(pptNew2);
- free(pboxNew2);
- if (pboxNew1) {
- free(pptNew1);
- free(pboxNew1);
- }
- return;
- }
- pboxBase = pboxNext = pbox;
- while (pboxBase < pbox+nbox) {
- while ((pboxNext < pbox+nbox) &&
- (pboxNext->y1 == pboxBase->y1))
- pboxNext++;
- pboxTmp = pboxNext;
- pptTmp = pptSrc + (pboxTmp - pbox);
- while (pboxTmp != pboxBase) {
- *pboxNew2++ = *--pboxTmp;
- *pptNew2++ = *--pptTmp;
- }
- pboxBase = pboxNext;
- }
- pboxNew2 -= nbox;
- pbox = pboxNew2;
- pptNew2 -= nbox;
- pptSrc = pptNew2;
- }
- } else {
- /* walk source left to right */
- xdir = 1;
- }
-
- (*infoRec->ScreenToScreenBitBlt)(infoRec->pScrn, nbox, pptSrc, pbox,
- xdir, ydir, pGC->alu, pGC->planemask);
-
- if (pboxNew2) {
- free(pptNew2);
- free(pboxNew2);
- }
- if (pboxNew1) {
- free(pptNew1);
- free(pboxNew1);
- }
-
-}
-
-void
-XAADoImageWrite(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GC *pGC,
- RegionPtr prgnDst,
- DDXPointPtr pptSrc )
-{
- int srcwidth;
- unsigned char* psrcBase; /* start of image */
- unsigned char* srcPntr; /* index into the image */
- BoxPtr pbox = RegionRects(prgnDst);
- int nbox = RegionNumRects(prgnDst);
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int Bpp = pSrc->bitsPerPixel >> 3;
-
- psrcBase = (unsigned char *)((PixmapPtr)pSrc)->devPrivate.ptr;
- srcwidth = (int)((PixmapPtr)pSrc)->devKind;
-
- for(; nbox; pbox++, pptSrc++, nbox--) {
- srcPntr = psrcBase + (pptSrc->y * srcwidth) + (pptSrc->x * Bpp);
-
- (*infoRec->WritePixmap)(infoRec->pScrn, pbox->x1, pbox->y1,
- pbox->x2 - pbox->x1, pbox->y2 - pbox->y1, srcPntr, srcwidth,
- pGC->alu, pGC->planemask, -1, pSrc->bitsPerPixel, pSrc->depth);
- }
-}
-
-
-void
-XAADoImageRead(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GC *pGC,
- RegionPtr prgnDst,
- DDXPointPtr pptSrc )
-{
- int dstwidth;
- unsigned char* pdstBase; /* start of image */
- unsigned char* dstPntr; /* index into the image */
- BoxPtr pbox = RegionRects(prgnDst);
- int nbox = RegionNumRects(prgnDst);
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int Bpp = pSrc->bitsPerPixel >> 3; /* wouldn't get here unless both
- src and dst have same bpp */
-
- pdstBase = (unsigned char *)((PixmapPtr)pDst)->devPrivate.ptr;
- dstwidth = (int)((PixmapPtr)pDst)->devKind;
-
- for(; nbox; pbox++, pptSrc++, nbox--) {
- dstPntr = pdstBase + (pbox->y1 * dstwidth) + (pbox->x1 * Bpp);
-
- (*infoRec->ReadPixmap)(infoRec->pScrn, pptSrc->x, pptSrc->y,
- pbox->x2 - pbox->x1, pbox->y2 - pbox->y1, dstPntr, dstwidth,
- pSrc->bitsPerPixel, pSrc->depth);
- }
-}
-
-
-void
-XAAScreenToScreenBitBlt(
- ScrnInfoPtr pScrn,
- int nbox,
- DDXPointPtr pptSrc,
- BoxPtr pbox,
- int xdir, int ydir,
- int alu,
- unsigned int planemask )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int dirsetup;
-
- if ((!(infoRec->CopyAreaFlags & ONLY_TWO_BITBLT_DIRECTIONS)
- || (xdir == ydir)) &&
- (!(infoRec->CopyAreaFlags & ONLY_LEFT_TO_RIGHT_BITBLT)
- || (xdir == 1))) {
- (*infoRec->SetupForScreenToScreenCopy)(pScrn,
- xdir, ydir, alu, planemask, -1);
- for (; nbox; pbox++, pptSrc++, nbox--)
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn,pptSrc->x, pptSrc->y,
- pbox->x1, pbox->y1, pbox->x2 - pbox->x1, pbox->y2 - pbox->y1);
- SET_SYNC_FLAG(infoRec);
- return;
- }
-
- if (infoRec->CopyAreaFlags & ONLY_LEFT_TO_RIGHT_BITBLT) {
- /*
- * This is the case of a chip that only supports xdir = 1,
- * with ydir = 1 or ydir = -1, but we have xdir = -1.
- */
- (*infoRec->SetupForScreenToScreenCopy)(pScrn,
- 1, ydir, alu, planemask, -1);
- for (; nbox; pbox++, pptSrc++, nbox--)
- if (pptSrc->y != pbox->y1 || pptSrc->x >= pbox->x1)
- /* No problem. Do a xdir = 1 blit instead. */
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
- pptSrc->x, pptSrc->y, pbox->x1, pbox->y1,
- pbox->x2 - pbox->x1, pbox->y2 - pbox->y1);
- else
- {
- /*
- * This is the difficult case. Needs striping into
- * non-overlapping horizontal chunks.
- */
- int stripeWidth, w, fullStripes, extra, i;
- stripeWidth = 16;
- w = pbox->x2 - pbox->x1;
- if (pbox->x1 - pptSrc->x < stripeWidth)
- stripeWidth = pbox->x1 - pptSrc->x;
- fullStripes = w / stripeWidth;
- extra = w % stripeWidth;
-
- /* First, take care of the little bit on the far right */
- if (extra)
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
- pptSrc->x + fullStripes * stripeWidth, pptSrc->y,
- pbox->x1 + fullStripes * stripeWidth, pbox->y1,
- extra, pbox->y2 - pbox->y1);
-
- /* Now, take care of the rest of the blit */
- for (i = fullStripes - 1; i >= 0; i--)
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
- pptSrc->x + i * stripeWidth, pptSrc->y,
- pbox->x1 + i * stripeWidth, pbox->y1,
- stripeWidth, pbox->y2 - pbox->y1);
- }
- SET_SYNC_FLAG(infoRec);
- return;
- }
-
- /*
- * Now the case of a chip that only supports xdir = ydir = 1 or
- * xdir = ydir = -1, but we have xdir != ydir.
- */
- dirsetup = 0; /* No direction set up yet. */
- for (; nbox; pbox++, pptSrc++, nbox--) {
- if (xdir == 1 && pptSrc->y != pbox->y1) {
- /* Do a xdir = ydir = -1 blit instead. */
- if (dirsetup != -1) {
- (*infoRec->SetupForScreenToScreenCopy)(pScrn,
- -1, -1, alu, planemask, -1);
- dirsetup = -1;
- }
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn,pptSrc->x, pptSrc->y,
- pbox->x1, pbox->y1, pbox->x2 - pbox->x1, pbox->y2 - pbox->y1);
- }
- else if (xdir == -1 && pptSrc->y != pbox->y1) {
- /* Do a xdir = ydir = 1 blit instead. */
- if (dirsetup != 1) {
- (*infoRec->SetupForScreenToScreenCopy)(pScrn,
- 1, 1, alu, planemask, -1);
- dirsetup = 1;
- }
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn,pptSrc->x, pptSrc->y,
- pbox->x1, pbox->y1, pbox->x2 - pbox->x1, pbox->y2 - pbox->y1);
- }
- else
- if (xdir == 1) {
- /*
- * xdir = 1, ydir = -1.
- * Perform line-by-line xdir = ydir = 1 blits, going up.
- */
- int i;
- if (dirsetup != 1) {
- (*infoRec->SetupForScreenToScreenCopy)(pScrn,
- 1, 1, alu, planemask, -1);
- dirsetup = 1;
- }
- for (i = pbox->y2 - pbox->y1 - 1; i >= 0; i--)
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
- pptSrc->x, pptSrc->y + i, pbox->x1, pbox->y1 + i,
- pbox->x2 - pbox->x1, 1);
- }
- else {
- /*
- * xdir = -1, ydir = 1.
- * Perform line-by-line xdir = ydir = -1 blits, going down.
- */
- int i;
- if (dirsetup != -1) {
- (*infoRec->SetupForScreenToScreenCopy)(pScrn,
- -1, -1, alu, planemask, -1);
- dirsetup = -1;
- }
- for (i = 0; i < pbox->y2 - pbox->y1; i++)
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
- pptSrc->x, pptSrc->y + i, pbox->x1, pbox->y1 + i,
- pbox->x2 - pbox->x1, 1);
- }
- } /* next box */
- SET_SYNC_FLAG(infoRec);
-}
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "migc.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+
+/*
+ Written mostly by Harm Hanemaayer (H.Hanemaayer@inter.nl.net).
+ */
+
+RegionPtr
+XAACopyArea(DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GC * pGC,
+ int srcx, int srcy, int width, int height, int dstx, int dsty)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
+ if (pDstDrawable->type == DRAWABLE_WINDOW) {
+ if ((pSrcDrawable->type == DRAWABLE_WINDOW) ||
+ IS_OFFSCREEN_PIXMAP(pSrcDrawable)) {
+ if (infoRec->ScreenToScreenBitBlt &&
+ CHECK_ROP(pGC, infoRec->ScreenToScreenBitBltFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->ScreenToScreenBitBltFlags) &&
+ CHECK_PLANEMASK(pGC, infoRec->ScreenToScreenBitBltFlags))
+ return (XAABitBlt(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty,
+ XAADoBitBlt, 0L));
+ }
+ else {
+ if (infoRec->WritePixmap &&
+ ((pDstDrawable->bitsPerPixel == pSrcDrawable->bitsPerPixel) ||
+ ((pDstDrawable->bitsPerPixel == 24) &&
+ (pSrcDrawable->bitsPerPixel == 32) &&
+ (infoRec->WritePixmapFlags & CONVERT_32BPP_TO_24BPP))) &&
+ CHECK_ROP(pGC, infoRec->WritePixmapFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->WritePixmapFlags) &&
+ CHECK_PLANEMASK(pGC, infoRec->WritePixmapFlags) &&
+ CHECK_NO_GXCOPY(pGC, infoRec->WritePixmapFlags))
+ return (XAABitBlt(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty,
+ XAADoImageWrite, 0L));
+ }
+ }
+ else if (IS_OFFSCREEN_PIXMAP(pDstDrawable)) {
+ if ((pSrcDrawable->type == DRAWABLE_WINDOW) ||
+ IS_OFFSCREEN_PIXMAP(pSrcDrawable)) {
+ if (infoRec->ScreenToScreenBitBlt &&
+ CHECK_ROP(pGC, infoRec->ScreenToScreenBitBltFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->ScreenToScreenBitBltFlags) &&
+ CHECK_PLANEMASK(pGC, infoRec->ScreenToScreenBitBltFlags))
+ return (XAABitBlt(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty,
+ XAADoBitBlt, 0L));
+ }
+ }
+
+ return (XAAFallbackOps.CopyArea(pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height, dstx, dsty));
+}
+
+void
+XAADoBitBlt(DrawablePtr pSrc,
+ DrawablePtr pDst, GC * pGC, RegionPtr prgnDst, DDXPointPtr pptSrc)
+{
+ int nbox, careful;
+ BoxPtr pbox, pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2;
+ DDXPointPtr pptTmp, pptNew1, pptNew2;
+ int xdir, ydir;
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
+ /* XXX we have to err on the side of safety when both are windows,
+ * because we don't know if IncludeInferiors is being used.
+ */
+ careful = ((pSrc == pDst) ||
+ ((pSrc->type == DRAWABLE_WINDOW) &&
+ (pDst->type == DRAWABLE_WINDOW)));
+
+ pbox = RegionRects(prgnDst);
+ nbox = RegionNumRects(prgnDst);
+
+ pboxNew1 = NULL;
+ pptNew1 = NULL;
+ pboxNew2 = NULL;
+ pptNew2 = NULL;
+ if (careful && (pptSrc->y < pbox->y1)) {
+ /* walk source botttom to top */
+ ydir = -1;
+
+ if (nbox > 1) {
+ /* keep ordering in each band, reverse order of bands */
+ pboxNew1 = (BoxPtr) malloc(sizeof(BoxRec) * nbox);
+ if (!pboxNew1)
+ return;
+ pptNew1 = (DDXPointPtr) malloc(sizeof(DDXPointRec) * nbox);
+ if (!pptNew1) {
+ free(pboxNew1);
+ return;
+ }
+ pboxBase = pboxNext = pbox + nbox - 1;
+ while (pboxBase >= pbox) {
+ while ((pboxNext >= pbox) && (pboxBase->y1 == pboxNext->y1))
+ pboxNext--;
+ pboxTmp = pboxNext + 1;
+ pptTmp = pptSrc + (pboxTmp - pbox);
+ while (pboxTmp <= pboxBase) {
+ *pboxNew1++ = *pboxTmp++;
+ *pptNew1++ = *pptTmp++;
+ }
+ pboxBase = pboxNext;
+ }
+ pboxNew1 -= nbox;
+ pbox = pboxNew1;
+ pptNew1 -= nbox;
+ pptSrc = pptNew1;
+ }
+ }
+ else {
+ /* walk source top to bottom */
+ ydir = 1;
+ }
+
+ if (careful && (pptSrc->x < pbox->x1)) {
+ /* walk source right to left */
+ xdir = -1;
+
+ if (nbox > 1) {
+ /* reverse order of rects in each band */
+ pboxNew2 = (BoxPtr) malloc(sizeof(BoxRec) * nbox);
+ pptNew2 = (DDXPointPtr) malloc(sizeof(DDXPointRec) * nbox);
+ if (!pboxNew2 || !pptNew2) {
+ free(pptNew2);
+ free(pboxNew2);
+ if (pboxNew1) {
+ free(pptNew1);
+ free(pboxNew1);
+ }
+ return;
+ }
+ pboxBase = pboxNext = pbox;
+ while (pboxBase < pbox + nbox) {
+ while ((pboxNext < pbox + nbox) &&
+ (pboxNext->y1 == pboxBase->y1))
+ pboxNext++;
+ pboxTmp = pboxNext;
+ pptTmp = pptSrc + (pboxTmp - pbox);
+ while (pboxTmp != pboxBase) {
+ *pboxNew2++ = *--pboxTmp;
+ *pptNew2++ = *--pptTmp;
+ }
+ pboxBase = pboxNext;
+ }
+ pboxNew2 -= nbox;
+ pbox = pboxNew2;
+ pptNew2 -= nbox;
+ pptSrc = pptNew2;
+ }
+ }
+ else {
+ /* walk source left to right */
+ xdir = 1;
+ }
+
+ (*infoRec->ScreenToScreenBitBlt) (infoRec->pScrn, nbox, pptSrc, pbox,
+ xdir, ydir, pGC->alu, pGC->planemask);
+
+ if (pboxNew2) {
+ free(pptNew2);
+ free(pboxNew2);
+ }
+ if (pboxNew1) {
+ free(pptNew1);
+ free(pboxNew1);
+ }
+
+}
+
+void
+XAADoImageWrite(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GC * pGC, RegionPtr prgnDst, DDXPointPtr pptSrc)
+{
+ int srcwidth;
+ unsigned char *psrcBase; /* start of image */
+ unsigned char *srcPntr; /* index into the image */
+ BoxPtr pbox = RegionRects(prgnDst);
+ int nbox = RegionNumRects(prgnDst);
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int Bpp = pSrc->bitsPerPixel >> 3;
+
+ psrcBase = (unsigned char *) ((PixmapPtr) pSrc)->devPrivate.ptr;
+ srcwidth = (int) ((PixmapPtr) pSrc)->devKind;
+
+ for (; nbox; pbox++, pptSrc++, nbox--) {
+ srcPntr = psrcBase + (pptSrc->y * srcwidth) + (pptSrc->x * Bpp);
+
+ (*infoRec->WritePixmap) (infoRec->pScrn, pbox->x1, pbox->y1,
+ pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
+ srcPntr, srcwidth, pGC->alu, pGC->planemask,
+ -1, pSrc->bitsPerPixel, pSrc->depth);
+ }
+}
+
+void
+XAADoImageRead(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GC * pGC, RegionPtr prgnDst, DDXPointPtr pptSrc)
+{
+ int dstwidth;
+ unsigned char *pdstBase; /* start of image */
+ unsigned char *dstPntr; /* index into the image */
+ BoxPtr pbox = RegionRects(prgnDst);
+ int nbox = RegionNumRects(prgnDst);
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int Bpp = pSrc->bitsPerPixel >> 3; /* wouldn't get here unless both
+ src and dst have same bpp */
+
+ pdstBase = (unsigned char *) ((PixmapPtr) pDst)->devPrivate.ptr;
+ dstwidth = (int) ((PixmapPtr) pDst)->devKind;
+
+ for (; nbox; pbox++, pptSrc++, nbox--) {
+ dstPntr = pdstBase + (pbox->y1 * dstwidth) + (pbox->x1 * Bpp);
+
+ (*infoRec->ReadPixmap) (infoRec->pScrn, pptSrc->x, pptSrc->y,
+ pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
+ dstPntr, dstwidth, pSrc->bitsPerPixel,
+ pSrc->depth);
+ }
+}
+
+void
+XAAScreenToScreenBitBlt(ScrnInfoPtr pScrn,
+ int nbox,
+ DDXPointPtr pptSrc,
+ BoxPtr pbox,
+ int xdir, int ydir, int alu, unsigned int planemask)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int dirsetup;
+
+ if ((!(infoRec->CopyAreaFlags & ONLY_TWO_BITBLT_DIRECTIONS)
+ || (xdir == ydir)) &&
+ (!(infoRec->CopyAreaFlags & ONLY_LEFT_TO_RIGHT_BITBLT)
+ || (xdir == 1))) {
+ (*infoRec->SetupForScreenToScreenCopy) (pScrn,
+ xdir, ydir, alu, planemask, -1);
+ for (; nbox; pbox++, pptSrc++, nbox--)
+ (*infoRec->SubsequentScreenToScreenCopy) (pScrn, pptSrc->x,
+ pptSrc->y, pbox->x1,
+ pbox->y1,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+ SET_SYNC_FLAG(infoRec);
+ return;
+ }
+
+ if (infoRec->CopyAreaFlags & ONLY_LEFT_TO_RIGHT_BITBLT) {
+ /*
+ * This is the case of a chip that only supports xdir = 1,
+ * with ydir = 1 or ydir = -1, but we have xdir = -1.
+ */
+ (*infoRec->SetupForScreenToScreenCopy) (pScrn,
+ 1, ydir, alu, planemask, -1);
+ for (; nbox; pbox++, pptSrc++, nbox--)
+ if (pptSrc->y != pbox->y1 || pptSrc->x >= pbox->x1)
+ /* No problem. Do a xdir = 1 blit instead. */
+ (*infoRec->SubsequentScreenToScreenCopy) (pScrn,
+ pptSrc->x, pptSrc->y,
+ pbox->x1, pbox->y1,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+ else {
+ /*
+ * This is the difficult case. Needs striping into
+ * non-overlapping horizontal chunks.
+ */
+ int stripeWidth, w, fullStripes, extra, i;
+
+ stripeWidth = 16;
+ w = pbox->x2 - pbox->x1;
+ if (pbox->x1 - pptSrc->x < stripeWidth)
+ stripeWidth = pbox->x1 - pptSrc->x;
+ fullStripes = w / stripeWidth;
+ extra = w % stripeWidth;
+
+ /* First, take care of the little bit on the far right */
+ if (extra)
+ (*infoRec->SubsequentScreenToScreenCopy) (pScrn,
+ pptSrc->x +
+ fullStripes *
+ stripeWidth,
+ pptSrc->y,
+ pbox->x1 +
+ fullStripes *
+ stripeWidth,
+ pbox->y1, extra,
+ pbox->y2 -
+ pbox->y1);
+
+ /* Now, take care of the rest of the blit */
+ for (i = fullStripes - 1; i >= 0; i--)
+ (*infoRec->SubsequentScreenToScreenCopy) (pScrn,
+ pptSrc->x +
+ i * stripeWidth,
+ pptSrc->y,
+ pbox->x1 +
+ i * stripeWidth,
+ pbox->y1,
+ stripeWidth,
+ pbox->y2 -
+ pbox->y1);
+ }
+ SET_SYNC_FLAG(infoRec);
+ return;
+ }
+
+ /*
+ * Now the case of a chip that only supports xdir = ydir = 1 or
+ * xdir = ydir = -1, but we have xdir != ydir.
+ */
+ dirsetup = 0; /* No direction set up yet. */
+ for (; nbox; pbox++, pptSrc++, nbox--) {
+ if (xdir == 1 && pptSrc->y != pbox->y1) {
+ /* Do a xdir = ydir = -1 blit instead. */
+ if (dirsetup != -1) {
+ (*infoRec->SetupForScreenToScreenCopy) (pScrn,
+ -1, -1, alu, planemask,
+ -1);
+ dirsetup = -1;
+ }
+ (*infoRec->SubsequentScreenToScreenCopy) (pScrn, pptSrc->x,
+ pptSrc->y, pbox->x1,
+ pbox->y1,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+ }
+ else if (xdir == -1 && pptSrc->y != pbox->y1) {
+ /* Do a xdir = ydir = 1 blit instead. */
+ if (dirsetup != 1) {
+ (*infoRec->SetupForScreenToScreenCopy) (pScrn,
+ 1, 1, alu, planemask,
+ -1);
+ dirsetup = 1;
+ }
+ (*infoRec->SubsequentScreenToScreenCopy) (pScrn, pptSrc->x,
+ pptSrc->y, pbox->x1,
+ pbox->y1,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+ }
+ else if (xdir == 1) {
+ /*
+ * xdir = 1, ydir = -1.
+ * Perform line-by-line xdir = ydir = 1 blits, going up.
+ */
+ int i;
+
+ if (dirsetup != 1) {
+ (*infoRec->SetupForScreenToScreenCopy) (pScrn,
+ 1, 1, alu, planemask,
+ -1);
+ dirsetup = 1;
+ }
+ for (i = pbox->y2 - pbox->y1 - 1; i >= 0; i--)
+ (*infoRec->SubsequentScreenToScreenCopy) (pScrn,
+ pptSrc->x,
+ pptSrc->y + i,
+ pbox->x1,
+ pbox->y1 + i,
+ pbox->x2 - pbox->x1,
+ 1);
+ }
+ else {
+ /*
+ * xdir = -1, ydir = 1.
+ * Perform line-by-line xdir = ydir = -1 blits, going down.
+ */
+ int i;
+
+ if (dirsetup != -1) {
+ (*infoRec->SetupForScreenToScreenCopy) (pScrn,
+ -1, -1, alu, planemask,
+ -1);
+ dirsetup = -1;
+ }
+ for (i = 0; i < pbox->y2 - pbox->y1; i++)
+ (*infoRec->SubsequentScreenToScreenCopy) (pScrn,
+ pptSrc->x,
+ pptSrc->y + i,
+ pbox->x1,
+ pbox->y1 + i,
+ pbox->x2 - pbox->x1,
+ 1);
+ }
+ } /* next box */
+ SET_SYNC_FLAG(infoRec);
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaCpyPlane.c b/xorg-server/hw/xfree86/xaa/xaaCpyPlane.c
index 2d036c936..b9197e41f 100644
--- a/xorg-server/hw/xfree86/xaa/xaaCpyPlane.c
+++ b/xorg-server/hw/xfree86/xaa/xaaCpyPlane.c
@@ -1,208 +1,204 @@
-
-/*
- A CopyPlane function that handles bitmap->screen copies and
- sends anything else to the Fallback.
-
- Also, a PushPixels for solid fill styles.
-
- Written by Mark Vojkovich (markv@valinux.com)
-
-*/
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <string.h>
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-#include "servermd.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "mi.h"
-#include "pixmapstr.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-#include "xaawrap.h"
-
-static void XAACopyPlane1toNColorExpand(DrawablePtr pSrc, DrawablePtr pDst,
- GCPtr pGC, RegionPtr rgnDst,
- DDXPointPtr pptSrc);
-static void XAACopyPlaneNtoNColorExpand(DrawablePtr pSrc, DrawablePtr pDst,
- GCPtr pGC, RegionPtr rgnDst,
- DDXPointPtr pptSrc);
-
-
-static unsigned long TmpBitPlane;
-
-RegionPtr
-XAACopyPlaneColorExpansion(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GCPtr pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty,
- unsigned long bitPlane
-){
- if((pSrc->type == DRAWABLE_PIXMAP) && !XAA_DEPTH_BUG(pGC)) {
- if(pSrc->bitsPerPixel == 1) {
- return(XAABitBlt(pSrc, pDst, pGC, srcx, srcy,
- width, height, dstx, dsty,
- XAACopyPlane1toNColorExpand, bitPlane));
- } else if(bitPlane < (1 << pDst->depth)){
- TmpBitPlane = bitPlane;
- return(XAABitBlt(pSrc, pDst, pGC, srcx, srcy,
- width, height, dstx, dsty,
- XAACopyPlaneNtoNColorExpand, bitPlane));
- }
- }
-
- return (XAAFallbackOps.CopyPlane(pSrc, pDst, pGC, srcx, srcy,
- width, height, dstx, dsty, bitPlane));
-}
-
-
-static void
-XAACopyPlane1toNColorExpand(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GCPtr pGC,
- RegionPtr rgnDst,
- DDXPointPtr pptSrc )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- BoxPtr pbox = RegionRects(rgnDst);
- int numrects = RegionNumRects(rgnDst);
- unsigned char *src = ((PixmapPtr)pSrc)->devPrivate.ptr;
- int srcwidth = ((PixmapPtr)pSrc)->devKind;
-
- while(numrects--) {
- (*infoRec->WriteBitmap)(infoRec->pScrn, pbox->x1, pbox->y1,
- pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
- src + (srcwidth * pptSrc->y) + ((pptSrc->x >> 5) << 2),
- srcwidth, pptSrc->x & 31,
- pGC->fgPixel, pGC->bgPixel, pGC->alu, pGC->planemask);
- pbox++; pptSrc++;
- }
-}
-
-
-static void
-XAACopyPlaneNtoNColorExpand(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GCPtr pGC,
- RegionPtr rgnDst,
- DDXPointPtr pptSrc
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- BoxPtr pbox = RegionRects(rgnDst);
- int numrects = RegionNumRects(rgnDst);
- unsigned char *src = ((PixmapPtr)pSrc)->devPrivate.ptr;
- unsigned char *data, *srcPtr, *dataPtr;
- int srcwidth = ((PixmapPtr)pSrc)->devKind;
- int pitch, width, height, h, i, index, offset;
- int Bpp = pSrc->bitsPerPixel >> 3;
- unsigned long mask = TmpBitPlane;
-
- if(TmpBitPlane < (1 << 8)) {
- offset = 0;
- } else if(TmpBitPlane < (1 << 16)) {
- offset = 1;
- mask >>= 8;
- } else if(TmpBitPlane < (1 << 24)) {
- offset = 2;
- mask >>= 16;
- } else {
- offset = 3;
- mask >>= 24;
- }
-
- if(IS_OFFSCREEN_PIXMAP(pSrc))
- SYNC_CHECK(pSrc);
-
- while(numrects--) {
- width = pbox->x2 - pbox->x1;
- h = height = pbox->y2 - pbox->y1;
- pitch = BitmapBytePad(width);
-
- if(!(data = calloc(height, pitch)))
- goto ALLOC_FAILED;
-
- dataPtr = data;
- srcPtr = ((pptSrc->y) * srcwidth) + src +
- ((pptSrc->x) * Bpp) + offset;
-
- while(h--) {
- for(i = index = 0; i < width; i++, index += Bpp) {
- if(mask & srcPtr[index])
- dataPtr[i >> 3] |= (1 << (i & 7));
- }
- dataPtr += pitch;
- srcPtr += srcwidth;
- }
-
- (*infoRec->WriteBitmap)(infoRec->pScrn,
- pbox->x1, pbox->y1, width, height, data, pitch, 0,
- pGC->fgPixel, pGC->bgPixel, pGC->alu, pGC->planemask);
-
- free(data);
-
-ALLOC_FAILED:
-
- pbox++; pptSrc++;
- }
-}
-
-void
-XAAPushPixelsSolidColorExpansion(
- GCPtr pGC,
- PixmapPtr pBitMap,
- DrawablePtr pDraw,
- int dx, int dy,
- int xOrg, int yOrg )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int MaxBoxes = RegionNumRects(pGC->pCompositeClip);
- BoxPtr pbox, pClipBoxes;
- int nboxes, srcx, srcy;
- xRectangle TheRect;
- unsigned char *src = pBitMap->devPrivate.ptr;
- int srcwidth = pBitMap->devKind;
-
- if(!RegionNumRects(pGC->pCompositeClip))
- return;
-
- TheRect.x = xOrg;
- TheRect.y = yOrg;
- TheRect.width = dx;
- TheRect.height = dy;
-
- if(MaxBoxes > (infoRec->PreAllocSize/sizeof(BoxRec))) {
- pClipBoxes = malloc(MaxBoxes * sizeof(BoxRec));
- if(!pClipBoxes) return;
- } else pClipBoxes = (BoxPtr)infoRec->PreAllocMem;
-
- nboxes = XAAGetRectClipBoxes(pGC, pClipBoxes, 1, &TheRect);
- pbox = pClipBoxes;
-
- while(nboxes--) {
- srcx = pbox->x1 - xOrg;
- srcy = pbox->y1 - yOrg;
- (*infoRec->WriteBitmap)(infoRec->pScrn, pbox->x1, pbox->y1,
- pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
- src + (srcwidth * srcy) + ((srcx >> 5) << 2),
- srcwidth, srcx & 31,
- pGC->fgPixel, -1, pGC->alu, pGC->planemask);
- pbox++;
- }
-
- if(pClipBoxes != (BoxPtr)infoRec->PreAllocMem)
- free(pClipBoxes);
-}
-
+
+/*
+ A CopyPlane function that handles bitmap->screen copies and
+ sends anything else to the Fallback.
+
+ Also, a PushPixels for solid fill styles.
+
+ Written by Mark Vojkovich (markv@valinux.com)
+
+*/
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <string.h>
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "servermd.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "mi.h"
+#include "pixmapstr.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "xaawrap.h"
+
+static void XAACopyPlane1toNColorExpand(DrawablePtr pSrc, DrawablePtr pDst,
+ GCPtr pGC, RegionPtr rgnDst,
+ DDXPointPtr pptSrc);
+static void XAACopyPlaneNtoNColorExpand(DrawablePtr pSrc, DrawablePtr pDst,
+ GCPtr pGC, RegionPtr rgnDst,
+ DDXPointPtr pptSrc);
+
+static unsigned long TmpBitPlane;
+
+RegionPtr
+XAACopyPlaneColorExpansion(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx, int srcy,
+ int width, int height,
+ int dstx, int dsty, unsigned long bitPlane)
+{
+ if ((pSrc->type == DRAWABLE_PIXMAP) && !XAA_DEPTH_BUG(pGC)) {
+ if (pSrc->bitsPerPixel == 1) {
+ return (XAABitBlt(pSrc, pDst, pGC, srcx, srcy,
+ width, height, dstx, dsty,
+ XAACopyPlane1toNColorExpand, bitPlane));
+ }
+ else if (bitPlane < (1 << pDst->depth)) {
+ TmpBitPlane = bitPlane;
+ return (XAABitBlt(pSrc, pDst, pGC, srcx, srcy,
+ width, height, dstx, dsty,
+ XAACopyPlaneNtoNColorExpand, bitPlane));
+ }
+ }
+
+ return (XAAFallbackOps.CopyPlane(pSrc, pDst, pGC, srcx, srcy,
+ width, height, dstx, dsty, bitPlane));
+}
+
+static void
+XAACopyPlane1toNColorExpand(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC, RegionPtr rgnDst, DDXPointPtr pptSrc)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ BoxPtr pbox = RegionRects(rgnDst);
+ int numrects = RegionNumRects(rgnDst);
+ unsigned char *src = ((PixmapPtr) pSrc)->devPrivate.ptr;
+ int srcwidth = ((PixmapPtr) pSrc)->devKind;
+
+ while (numrects--) {
+ (*infoRec->WriteBitmap) (infoRec->pScrn, pbox->x1, pbox->y1,
+ pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
+ src + (srcwidth * pptSrc->y) +
+ ((pptSrc->x >> 5) << 2), srcwidth,
+ pptSrc->x & 31, pGC->fgPixel, pGC->bgPixel,
+ pGC->alu, pGC->planemask);
+ pbox++;
+ pptSrc++;
+ }
+}
+
+static void
+XAACopyPlaneNtoNColorExpand(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC, RegionPtr rgnDst, DDXPointPtr pptSrc)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ BoxPtr pbox = RegionRects(rgnDst);
+ int numrects = RegionNumRects(rgnDst);
+ unsigned char *src = ((PixmapPtr) pSrc)->devPrivate.ptr;
+ unsigned char *data, *srcPtr, *dataPtr;
+ int srcwidth = ((PixmapPtr) pSrc)->devKind;
+ int pitch, width, height, h, i, index, offset;
+ int Bpp = pSrc->bitsPerPixel >> 3;
+ unsigned long mask = TmpBitPlane;
+
+ if (TmpBitPlane < (1 << 8)) {
+ offset = 0;
+ }
+ else if (TmpBitPlane < (1 << 16)) {
+ offset = 1;
+ mask >>= 8;
+ }
+ else if (TmpBitPlane < (1 << 24)) {
+ offset = 2;
+ mask >>= 16;
+ }
+ else {
+ offset = 3;
+ mask >>= 24;
+ }
+
+ if (IS_OFFSCREEN_PIXMAP(pSrc))
+ SYNC_CHECK(pSrc);
+
+ while (numrects--) {
+ width = pbox->x2 - pbox->x1;
+ h = height = pbox->y2 - pbox->y1;
+ pitch = BitmapBytePad(width);
+
+ if (!(data = calloc(height, pitch)))
+ goto ALLOC_FAILED;
+
+ dataPtr = data;
+ srcPtr = ((pptSrc->y) * srcwidth) + src + ((pptSrc->x) * Bpp) + offset;
+
+ while (h--) {
+ for (i = index = 0; i < width; i++, index += Bpp) {
+ if (mask & srcPtr[index])
+ dataPtr[i >> 3] |= (1 << (i & 7));
+ }
+ dataPtr += pitch;
+ srcPtr += srcwidth;
+ }
+
+ (*infoRec->WriteBitmap) (infoRec->pScrn,
+ pbox->x1, pbox->y1, width, height, data, pitch,
+ 0, pGC->fgPixel, pGC->bgPixel, pGC->alu,
+ pGC->planemask);
+
+ free(data);
+
+ ALLOC_FAILED:
+
+ pbox++;
+ pptSrc++;
+ }
+}
+
+void
+XAAPushPixelsSolidColorExpansion(GCPtr pGC,
+ PixmapPtr pBitMap,
+ DrawablePtr pDraw,
+ int dx, int dy, int xOrg, int yOrg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int MaxBoxes = RegionNumRects(pGC->pCompositeClip);
+ BoxPtr pbox, pClipBoxes;
+ int nboxes, srcx, srcy;
+ xRectangle TheRect;
+ unsigned char *src = pBitMap->devPrivate.ptr;
+ int srcwidth = pBitMap->devKind;
+
+ if (!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ TheRect.x = xOrg;
+ TheRect.y = yOrg;
+ TheRect.width = dx;
+ TheRect.height = dy;
+
+ if (MaxBoxes > (infoRec->PreAllocSize / sizeof(BoxRec))) {
+ pClipBoxes = malloc(MaxBoxes * sizeof(BoxRec));
+ if (!pClipBoxes)
+ return;
+ }
+ else
+ pClipBoxes = (BoxPtr) infoRec->PreAllocMem;
+
+ nboxes = XAAGetRectClipBoxes(pGC, pClipBoxes, 1, &TheRect);
+ pbox = pClipBoxes;
+
+ while (nboxes--) {
+ srcx = pbox->x1 - xOrg;
+ srcy = pbox->y1 - yOrg;
+ (*infoRec->WriteBitmap) (infoRec->pScrn, pbox->x1, pbox->y1,
+ pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
+ src + (srcwidth * srcy) + ((srcx >> 5) << 2),
+ srcwidth, srcx & 31,
+ pGC->fgPixel, -1, pGC->alu, pGC->planemask);
+ pbox++;
+ }
+
+ if (pClipBoxes != (BoxPtr) infoRec->PreAllocMem)
+ free(pClipBoxes);
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaCpyWin.c b/xorg-server/hw/xfree86/xaa/xaaCpyWin.c
index d8608b095..e851f4a37 100644
--- a/xorg-server/hw/xfree86/xaa/xaaCpyWin.c
+++ b/xorg-server/hw/xfree86/xaa/xaaCpyWin.c
@@ -1,82 +1,78 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-#include "gcstruct.h"
-#include "pixmapstr.h"
-#include "xaawrap.h"
-
-/*
- Written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net).
-*/
-
-void
-XAACopyWindow(
- WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgnSrc )
-{
- DDXPointPtr pptSrc, ppt;
- RegionRec rgnDst;
- BoxPtr pbox;
- int dx, dy, nbox;
- WindowPtr pwinRoot;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- XAAInfoRecPtr infoRec =
- GET_XAAINFORECPTR_FROM_DRAWABLE((&pWin->drawable));
-
- if (!infoRec->pScrn->vtSema || !infoRec->ScreenToScreenBitBlt) {
- XAA_SCREEN_PROLOGUE (pScreen, CopyWindow);
- if(infoRec->pScrn->vtSema && infoRec->NeedToSync) {
- (*infoRec->Sync)(infoRec->pScrn);
- infoRec->NeedToSync = FALSE;
- }
- (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
- XAA_SCREEN_EPILOGUE (pScreen, CopyWindow, XAACopyWindow);
- return;
- }
-
- pwinRoot = pScreen->root;
-
- RegionNull(&rgnDst);
-
- dx = ptOldOrg.x - pWin->drawable.x;
- dy = ptOldOrg.y - pWin->drawable.y;
- RegionTranslate(prgnSrc, -dx, -dy);
- RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
-
- pbox = RegionRects(&rgnDst);
- nbox = RegionNumRects(&rgnDst);
- if(!nbox ||
- !(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))) {
- RegionUninit(&rgnDst);
- return;
- }
- ppt = pptSrc;
-
- while(nbox--) {
- ppt->x = pbox->x1 + dx;
- ppt->y = pbox->y1 + dy;
- ppt++; pbox++;
- }
-
- infoRec->ScratchGC.planemask = ~0L;
- infoRec->ScratchGC.alu = GXcopy;
-
- XAADoBitBlt((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
- &(infoRec->ScratchGC), &rgnDst, pptSrc);
-
- free(pptSrc);
- RegionUninit(&rgnDst);
-}
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "xaawrap.h"
+
+/*
+ Written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net).
+*/
+
+void
+XAACopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ DDXPointPtr pptSrc, ppt;
+ RegionRec rgnDst;
+ BoxPtr pbox;
+ int dx, dy, nbox;
+ WindowPtr pwinRoot;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_DRAWABLE((&pWin->drawable));
+
+ if (!infoRec->pScrn->vtSema || !infoRec->ScreenToScreenBitBlt) {
+ XAA_SCREEN_PROLOGUE(pScreen, CopyWindow);
+ if (infoRec->pScrn->vtSema && infoRec->NeedToSync) {
+ (*infoRec->Sync) (infoRec->pScrn);
+ infoRec->NeedToSync = FALSE;
+ }
+ (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
+ XAA_SCREEN_EPILOGUE(pScreen, CopyWindow, XAACopyWindow);
+ return;
+ }
+
+ pwinRoot = pScreen->root;
+
+ RegionNull(&rgnDst);
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ RegionTranslate(prgnSrc, -dx, -dy);
+ RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
+
+ pbox = RegionRects(&rgnDst);
+ nbox = RegionNumRects(&rgnDst);
+ if (!nbox || !(pptSrc = (DDXPointPtr) malloc(nbox * sizeof(DDXPointRec)))) {
+ RegionUninit(&rgnDst);
+ return;
+ }
+ ppt = pptSrc;
+
+ while (nbox--) {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ ppt++;
+ pbox++;
+ }
+
+ infoRec->ScratchGC.planemask = ~0L;
+ infoRec->ScratchGC.alu = GXcopy;
+
+ XAADoBitBlt((DrawablePtr) pwinRoot, (DrawablePtr) pwinRoot,
+ &(infoRec->ScratchGC), &rgnDst, pptSrc);
+
+ free(pptSrc);
+ RegionUninit(&rgnDst);
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaDashLine.c b/xorg-server/hw/xfree86/xaa/xaaDashLine.c
index adae2e583..c7e52cd0b 100644
--- a/xorg-server/hw/xfree86/xaa/xaaDashLine.c
+++ b/xorg-server/hw/xfree86/xaa/xaaDashLine.c
@@ -1,334 +1,353 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <stdlib.h>
-
-#include <X11/X.h>
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "miline.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-
-
-void
-#ifdef POLYSEGMENT
-XAAPolySegmentDashed(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int nseg,
- xSegment *pSeg
-#else
-XAAPolyLinesDashed(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int mode, /* Origin or Previous */
- int npt, /* number of points */
- DDXPointPtr pptInit
-#endif
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates,
- XAAGetGCKey());
- BoxPtr pboxInit = RegionRects(pGC->pCompositeClip);
- int nboxInit = RegionNumRects(pGC->pCompositeClip);
- unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
- int xorg = pDrawable->x;
- int yorg = pDrawable->y;
- int nbox;
- BoxPtr pbox;
-#ifndef POLYSEGMENT
- DDXPointPtr ppt;
-#endif
- unsigned int oc1, oc2;
- int dmin, dmaj, e, octant;
- int x1, x2, y1, y2, tmp, len, offset;
- int PatternLength, PatternOffset;
-
- if(!nboxInit)
- return;
-
- if (infoRec->DashedLineFlags & LINE_LIMIT_COORDS) {
- int minValX = infoRec->DashedLineLimits.x1;
- int maxValX = infoRec->DashedLineLimits.x2;
- int minValY = infoRec->DashedLineLimits.y1;
- int maxValY = infoRec->DashedLineLimits.y2;
-#ifdef POLYSEGMENT
- int n = nseg;
- xSegment *s = pSeg;
-
- while (n--)
-#else
- int n = npt;
- int xorgtmp = xorg;
- int yorgtmp = yorg;
-
- ppt = pptInit;
- x2 = ppt->x + xorgtmp;
- y2 = ppt->y + yorgtmp;
- while (--n)
-#endif
- {
-#ifdef POLYSEGMENT
- x1 = s->x1 + xorg;
- y1 = s->y1 + yorg;
- x2 = s->x2 + xorg;
- y2 = s->y2 + yorg;
- s++;
-#else
- x1 = x2;
- y1 = y2;
- ++ppt;
- if (mode == CoordModePrevious) {
- xorgtmp = x1;
- yorgtmp = y1;
- }
- x2 = ppt->x + xorgtmp;
- y2 = ppt->y + yorgtmp;
-#endif
- if (x1 > maxValX || x1 < minValX ||
- x2 > maxValX || x2 < minValX ||
- y1 > maxValY || y1 < minValY ||
- y2 > maxValY || y2 < minValY) {
-#ifdef POLYSEGMENT
- XAAFallbackOps.PolySegment(pDrawable, pGC, nseg, pSeg);
-#else
- XAAFallbackOps.Polylines(pDrawable, pGC, mode, npt, pptInit);
-#endif
- return;
- }
- }
- }
-
- PatternLength = pGCPriv->DashLength;
- PatternOffset = pGC->dashOffset % PatternLength;
-
- (*infoRec->SetupForDashedLine)(infoRec->pScrn, pGC->fgPixel,
- (pGC->lineStyle == LineDoubleDash) ? pGC->bgPixel : -1,
- pGC->alu, pGC->planemask, PatternLength, pGCPriv->DashPattern);
-
-
-#ifdef POLYSEGMENT
- while (nseg--)
-#else
- ppt = pptInit;
- x2 = ppt->x + xorg;
- y2 = ppt->y + yorg;
- while(--npt)
-#endif
- {
- nbox = nboxInit;
- pbox = pboxInit;
-
-#ifdef POLYSEGMENT
- x1 = pSeg->x1 + xorg;
- y1 = pSeg->y1 + yorg;
- x2 = pSeg->x2 + xorg;
- y2 = pSeg->y2 + yorg;
- pSeg++;
-#else
- x1 = x2;
- y1 = y2;
- ++ppt;
- if (mode == CoordModePrevious) {
- xorg = x1;
- yorg = y1;
- }
- x2 = ppt->x + xorg;
- y2 = ppt->y + yorg;
-#endif
-
-
- if (infoRec->SubsequentDashedBresenhamLine) {
- if((dmaj = x2 - x1) < 0) {
- dmaj = -dmaj;
- octant = XDECREASING;
- } else octant = 0;
-
- if((dmin = y2 - y1) < 0) {
- dmin = -dmin;
- octant |= YDECREASING;
- }
-
- if(dmin >= dmaj){
- tmp = dmin; dmin = dmaj; dmaj = tmp;
- octant |= YMAJOR;
- }
-
- e = -dmaj - ((bias >> octant) & 1);
- len = dmaj;
- dmin <<= 1;
- dmaj <<= 1;
- } else { /* Muffle compiler */
- dmin = dmaj = e = octant = len = 0;
- }
-
- while(nbox--) {
- oc1 = oc2 = 0;
- OUTCODES(oc1, x1, y1, pbox);
- OUTCODES(oc2, x2, y2, pbox);
- if (!(oc1 | oc2)) { /* uncliped */
- if(infoRec->SubsequentDashedTwoPointLine) {
- (*infoRec->SubsequentDashedTwoPointLine)(
- infoRec->pScrn, x1, y1, x2, y2,
-#ifdef POLYSEGMENT
- (pGC->capStyle != CapNotLast) ? 0 :
-#endif
- OMIT_LAST, PatternOffset);
- } else {
- (*infoRec->SubsequentDashedBresenhamLine)(
- infoRec->pScrn, x1, y1, dmaj, dmin, e,
-#ifdef POLYSEGMENT
- (pGC->capStyle != CapNotLast) ? (len+1) :
-#endif
- len, octant, PatternOffset);
- }
- break;
- } else if (oc1 & oc2) { /* completely clipped */
- pbox++;
- } else if (infoRec->ClippingFlags & HARDWARE_CLIP_DASHED_LINE) {
- (*infoRec->SetClippingRectangle)(infoRec->pScrn,
- pbox->x1, pbox->y1, pbox->x2 - 1, pbox->y2 - 1);
-
- if(infoRec->SubsequentDashedBresenhamLine) {
- (*infoRec->SubsequentDashedBresenhamLine)(
- infoRec->pScrn, x1, y1, dmaj, dmin, e,
-#ifdef POLYSEGMENT
- (pGC->capStyle != CapNotLast) ? (len+1) :
-#endif
- len, octant, PatternOffset);
- } else {
- (*infoRec->SubsequentDashedTwoPointLine)(
- infoRec->pScrn, x1, y1, x2, y2,
-#ifdef POLYSEGMENT
- (pGC->capStyle != CapNotLast) ? 0 :
-#endif
- OMIT_LAST, PatternOffset
- );
- }
- (*infoRec->DisableClipping)(infoRec->pScrn);
- pbox++;
- } else {
- int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
- int clip1 = 0, clip2 = 0;
- int err, adx, ady;
-
- if(octant & YMAJOR) {
- ady = dmaj >> 1;
- adx = dmin >> 1;
- } else {
- ady = dmin >> 1;
- adx = dmaj >> 1;
- }
-
- if (miZeroClipLine(pbox->x1, pbox->y1,
- pbox->x2 - 1, pbox->y2 - 1,
- &new_x1, &new_y1, &new_x2, &new_y2,
- adx, ady, &clip1, &clip2,
- octant, bias, oc1, oc2) == -1)
- {
- pbox++;
- continue;
- }
-
- if (octant & YMAJOR)
- len = abs(new_y2 - new_y1);
- else
- len = abs(new_x2 - new_x1);
-#ifdef POLYSEGMENT
- if (clip2 != 0 || pGC->capStyle != CapNotLast)
- len++;
-#else
- len += (clip2 != 0);
-#endif
- if (len) {
- int abserr, clipdx, clipdy;
- /* unwind bresenham error term to first point */
- if (clip1) {
- clipdx = abs(new_x1 - x1);
- clipdy = abs(new_y1 - y1);
-
- if (octant & YMAJOR)
- err = e + clipdy*dmin - clipdx*dmaj;
- else
- err = e + clipdx*dmin - clipdy*dmaj;
- } else
- err = e;
-
-#define range infoRec->DashedBresenhamLineErrorTermBits
- abserr = abs(err);
- while((abserr & range) ||
- (dmaj & range) ||
- (dmin & range)) {
- dmin >>= 1;
- dmaj >>= 1;
- abserr >>= 1;
- err /= 2;
- }
-
- if(octant & YMAJOR)
- offset = abs(new_y1 - y1);
- else
- offset = abs(new_x1 - x1);
-
- offset += PatternOffset;
- offset %= PatternLength;
-
- (*infoRec->SubsequentDashedBresenhamLine)(
- infoRec->pScrn, new_x1, new_y1,
- dmaj, dmin, err, len, octant, offset);
- }
- pbox++;
- }
- } /* while (nbox--) */
-#ifndef POLYSEGMENT
- len = abs(y2 - y1);
- tmp = abs(x2 - x1);
- PatternOffset += (len > tmp) ? len : tmp;
- PatternOffset %= PatternLength;
-#endif
- } /* while (nline--) */
-
-#ifndef POLYSEGMENT
- /* paint the last point if the end style isn't CapNotLast.
- (Assume that a projecting, butt, or round cap that is one
- pixel wide is the same as the single pixel of the endpoint.)
- */
-
- if ((pGC->capStyle != CapNotLast) &&
- ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
- (ppt->y + yorg != pptInit->y + pDrawable->y) ||
- (ppt == pptInit + 1)))
- {
- nbox = nboxInit;
- pbox = pboxInit;
- while (nbox--) {
- if ((x2 >= pbox->x1) && (y2 >= pbox->y1) &&
- (x2 < pbox->x2) && (y2 < pbox->y2))
- {
- if(infoRec->SubsequentDashedTwoPointLine) {
- (*infoRec->SubsequentDashedTwoPointLine)(
- infoRec->pScrn, x2, y2, x2, y2, 0,
- PatternOffset);
- } else {
- (*infoRec->SubsequentDashedBresenhamLine)(
- infoRec->pScrn, x2, y2, 2, 0, -1,
- 1, 0, PatternOffset);
- }
- break;
- } else
- pbox++;
- }
- }
-#endif
-
- SET_SYNC_FLAG(infoRec);
-}
-
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include <X11/X.h>
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "miline.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+
+void
+#ifdef POLYSEGMENT
+ XAAPolySegmentDashed(DrawablePtr pDrawable,
+ GCPtr pGC, int nseg, xSegment * pSeg
+#else
+XAAPolyLinesDashed(DrawablePtr pDrawable, GCPtr pGC, int mode, /* Origin or Previous */
+ int npt, /* number of points */
+ DDXPointPtr pptInit
+#endif
+ )
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAAGCPtr pGCPriv = (XAAGCPtr) dixLookupPrivate(&pGC->devPrivates,
+ XAAGetGCKey());
+ BoxPtr pboxInit = RegionRects(pGC->pCompositeClip);
+ int nboxInit = RegionNumRects(pGC->pCompositeClip);
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+ int xorg = pDrawable->x;
+ int yorg = pDrawable->y;
+ int nbox;
+ BoxPtr pbox;
+
+#ifndef POLYSEGMENT
+ DDXPointPtr ppt;
+#endif
+ unsigned int oc1, oc2;
+ int dmin, dmaj, e, octant;
+ int x1, x2, y1, y2, tmp, len, offset;
+ int PatternLength, PatternOffset;
+
+ if (!nboxInit)
+ return;
+
+ if (infoRec->DashedLineFlags & LINE_LIMIT_COORDS) {
+ int minValX = infoRec->DashedLineLimits.x1;
+ int maxValX = infoRec->DashedLineLimits.x2;
+ int minValY = infoRec->DashedLineLimits.y1;
+ int maxValY = infoRec->DashedLineLimits.y2;
+
+#ifdef POLYSEGMENT
+ int n = nseg;
+ xSegment *s = pSeg;
+
+ while (n--)
+#else
+ int n = npt;
+ int xorgtmp = xorg;
+ int yorgtmp = yorg;
+
+ ppt = pptInit;
+ x2 = ppt->x + xorgtmp;
+ y2 = ppt->y + yorgtmp;
+ while (--n)
+#endif
+ {
+#ifdef POLYSEGMENT
+ x1 = s->x1 + xorg;
+ y1 = s->y1 + yorg;
+ x2 = s->x2 + xorg;
+ y2 = s->y2 + yorg;
+ s++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious) {
+ xorgtmp = x1;
+ yorgtmp = y1;
+ }
+ x2 = ppt->x + xorgtmp;
+ y2 = ppt->y + yorgtmp;
+#endif
+ if (x1 > maxValX || x1 < minValX ||
+ x2 > maxValX || x2 < minValX ||
+ y1 > maxValY || y1 < minValY || y2 > maxValY || y2 < minValY) {
+#ifdef POLYSEGMENT
+ XAAFallbackOps.PolySegment(pDrawable, pGC, nseg, pSeg);
+#else
+ XAAFallbackOps.Polylines(pDrawable, pGC, mode, npt, pptInit);
+#endif
+ return;
+ }
+ }
+ }
+
+ PatternLength = pGCPriv->DashLength;
+ PatternOffset = pGC->dashOffset % PatternLength;
+
+ (*infoRec->SetupForDashedLine) (infoRec->pScrn, pGC->fgPixel,
+ (pGC->lineStyle ==
+ LineDoubleDash) ? pGC->bgPixel : -1,
+ pGC->alu, pGC->planemask, PatternLength,
+ pGCPriv->DashPattern);
+
+#ifdef POLYSEGMENT
+ while (nseg--)
+#else
+ ppt = pptInit;
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+ while (--npt)
+#endif
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+
+#ifdef POLYSEGMENT
+ x1 = pSeg->x1 + xorg;
+ y1 = pSeg->y1 + yorg;
+ x2 = pSeg->x2 + xorg;
+ y2 = pSeg->y2 + yorg;
+ pSeg++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious) {
+ xorg = x1;
+ yorg = y1;
+ }
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+#endif
+
+ if (infoRec->SubsequentDashedBresenhamLine) {
+ if ((dmaj = x2 - x1) < 0) {
+ dmaj = -dmaj;
+ octant = XDECREASING;
+ }
+ else
+ octant = 0;
+
+ if ((dmin = y2 - y1) < 0) {
+ dmin = -dmin;
+ octant |= YDECREASING;
+ }
+
+ if (dmin >= dmaj) {
+ tmp = dmin;
+ dmin = dmaj;
+ dmaj = tmp;
+ octant |= YMAJOR;
+ }
+
+ e = -dmaj - ((bias >> octant) & 1);
+ len = dmaj;
+ dmin <<= 1;
+ dmaj <<= 1;
+ }
+ else { /* Muffle compiler */
+ dmin = dmaj = e = octant = len = 0;
+ }
+
+ while (nbox--) {
+ oc1 = oc2 = 0;
+ OUTCODES(oc1, x1, y1, pbox);
+ OUTCODES(oc2, x2, y2, pbox);
+ if (!(oc1 | oc2)) { /* uncliped */
+ if (infoRec->SubsequentDashedTwoPointLine) {
+ (*infoRec->SubsequentDashedTwoPointLine) (infoRec->pScrn,
+ x1, y1, x2, y2,
+#ifdef POLYSEGMENT
+ (pGC->capStyle !=
+ CapNotLast) ? 0 :
+#endif
+ OMIT_LAST,
+ PatternOffset);
+ }
+ else {
+ (*infoRec->SubsequentDashedBresenhamLine) (infoRec->pScrn,
+ x1, y1, dmaj,
+ dmin, e,
+#ifdef POLYSEGMENT
+ (pGC->capStyle !=
+ CapNotLast)
+ ? (len + 1) :
+#endif
+ len, octant,
+ PatternOffset);
+ }
+ break;
+ }
+ else if (oc1 & oc2) { /* completely clipped */
+ pbox++;
+ }
+ else if (infoRec->ClippingFlags & HARDWARE_CLIP_DASHED_LINE) {
+ (*infoRec->SetClippingRectangle) (infoRec->pScrn,
+ pbox->x1, pbox->y1,
+ pbox->x2 - 1, pbox->y2 - 1);
+
+ if (infoRec->SubsequentDashedBresenhamLine) {
+ (*infoRec->SubsequentDashedBresenhamLine) (infoRec->pScrn,
+ x1, y1, dmaj,
+ dmin, e,
+#ifdef POLYSEGMENT
+ (pGC->capStyle !=
+ CapNotLast)
+ ? (len + 1) :
+#endif
+ len, octant,
+ PatternOffset);
+ }
+ else {
+ (*infoRec->SubsequentDashedTwoPointLine) (infoRec->pScrn,
+ x1, y1, x2, y2,
+#ifdef POLYSEGMENT
+ (pGC->capStyle !=
+ CapNotLast) ? 0 :
+#endif
+ OMIT_LAST,
+ PatternOffset);
+ }
+ (*infoRec->DisableClipping) (infoRec->pScrn);
+ pbox++;
+ }
+ else {
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+ int clip1 = 0, clip2 = 0;
+ int err, adx, ady;
+
+ if (octant & YMAJOR) {
+ ady = dmaj >> 1;
+ adx = dmin >> 1;
+ }
+ else {
+ ady = dmin >> 1;
+ adx = dmaj >> 1;
+ }
+
+ if (miZeroClipLine(pbox->x1, pbox->y1,
+ pbox->x2 - 1, pbox->y2 - 1,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady, &clip1, &clip2,
+ octant, bias, oc1, oc2) == -1) {
+ pbox++;
+ continue;
+ }
+
+ if (octant & YMAJOR)
+ len = abs(new_y2 - new_y1);
+ else
+ len = abs(new_x2 - new_x1);
+#ifdef POLYSEGMENT
+ if (clip2 != 0 || pGC->capStyle != CapNotLast)
+ len++;
+#else
+ len += (clip2 != 0);
+#endif
+ if (len) {
+ int abserr, clipdx, clipdy;
+
+ /* unwind bresenham error term to first point */
+ if (clip1) {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+
+ if (octant & YMAJOR)
+ err = e + clipdy * dmin - clipdx * dmaj;
+ else
+ err = e + clipdx * dmin - clipdy * dmaj;
+ }
+ else
+ err = e;
+
+#define range infoRec->DashedBresenhamLineErrorTermBits
+ abserr = abs(err);
+ while ((abserr & range) || (dmaj & range) || (dmin & range)) {
+ dmin >>= 1;
+ dmaj >>= 1;
+ abserr >>= 1;
+ err /= 2;
+ }
+
+ if (octant & YMAJOR)
+ offset = abs(new_y1 - y1);
+ else
+ offset = abs(new_x1 - x1);
+
+ offset += PatternOffset;
+ offset %= PatternLength;
+
+ (*infoRec->SubsequentDashedBresenhamLine) (infoRec->pScrn,
+ new_x1, new_y1,
+ dmaj, dmin, err,
+ len, octant,
+ offset);
+ }
+ pbox++;
+ }
+ } /* while (nbox--) */
+#ifndef POLYSEGMENT
+ len = abs(y2 - y1);
+ tmp = abs(x2 - x1);
+ PatternOffset += (len > tmp) ? len : tmp;
+ PatternOffset %= PatternLength;
+#endif
+ } /* while (nline--) */
+
+#ifndef POLYSEGMENT
+ /* paint the last point if the end style isn't CapNotLast.
+ (Assume that a projecting, butt, or round cap that is one
+ pixel wide is the same as the single pixel of the endpoint.)
+ */
+
+ if ((pGC->capStyle != CapNotLast) &&
+ ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
+ (ppt->y + yorg != pptInit->y + pDrawable->y) ||
+ (ppt == pptInit + 1))) {
+ nbox = nboxInit;
+ pbox = pboxInit;
+ while (nbox--) {
+ if ((x2 >= pbox->x1) && (y2 >= pbox->y1) &&
+ (x2 < pbox->x2) && (y2 < pbox->y2)) {
+ if (infoRec->SubsequentDashedTwoPointLine) {
+ (*infoRec->SubsequentDashedTwoPointLine) (infoRec->pScrn,
+ x2, y2, x2, y2, 0,
+ PatternOffset);
+ }
+ else {
+ (*infoRec->SubsequentDashedBresenhamLine) (infoRec->pScrn,
+ x2, y2, 2, 0, -1,
+ 1, 0,
+ PatternOffset);
+ }
+ break;
+ }
+ else
+ pbox++;
+ }
+ }
+#endif
+
+ SET_SYNC_FLAG(infoRec);
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaFallback.c b/xorg-server/hw/xfree86/xaa/xaaFallback.c
index 744fd0a21..f7604ef90 100644
--- a/xorg-server/hw/xfree86/xaa/xaaFallback.c
+++ b/xorg-server/hw/xfree86/xaa/xaaFallback.c
@@ -1,351 +1,281 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-#include "gcstruct.h"
-#include "pixmapstr.h"
-#include "xaawrap.h"
-
-
-
-static void
-XAAFillSpansFallback(
- DrawablePtr pDraw,
- GC *pGC,
- int nInit,
- DDXPointPtr pptInit,
- int *pwidthInit,
- int fSorted )
-{
- XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
- SYNC_CHECK(pGC);
- (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
- XAA_GC_OP_EPILOGUE(pGC);
-}
-
-static void
-XAASetSpansFallback(
- DrawablePtr pDraw,
- GCPtr pGC,
- char *pcharsrc,
- register DDXPointPtr ppt,
- int *pwidth,
- int nspans,
- int fSorted )
-{
- XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
- SYNC_CHECK(pGC);
- (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted);
- XAA_GC_OP_EPILOGUE(pGC);
-}
-
-static void
-XAAPutImageFallback(
- DrawablePtr pDraw,
- GCPtr pGC,
- int depth,
- int x, int y, int w, int h,
- int leftPad,
- int format,
- char *pImage )
-{
- XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
- SYNC_CHECK(pGC);
- (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h,
- leftPad, format, pImage);
- XAA_GC_OP_EPILOGUE(pGC);
-}
-
-static RegionPtr
-XAACopyAreaFallback(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GC *pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty )
-{
- RegionPtr ret;
-
- XAA_GC_OP_PROLOGUE(pGC);
- if((pSrc->type == DRAWABLE_WINDOW) || (pDst->type == DRAWABLE_WINDOW) ||
- IS_OFFSCREEN_PIXMAP(pSrc) || IS_OFFSCREEN_PIXMAP(pDst)) {
- SYNC_CHECK(pGC);
- }
- ret = (*pGC->ops->CopyArea)(pSrc, pDst,
- pGC, srcx, srcy, width, height, dstx, dsty);
- XAA_GC_OP_EPILOGUE(pGC);
- return ret;
-}
-
-static RegionPtr
-XAACopyPlaneFallback(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GCPtr pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty,
- unsigned long bitPlane )
-{
- RegionPtr ret;
-
- XAA_GC_OP_PROLOGUE(pGC);
- if((pSrc->type == DRAWABLE_WINDOW) || (pDst->type == DRAWABLE_WINDOW) ||
- IS_OFFSCREEN_PIXMAP(pSrc) || IS_OFFSCREEN_PIXMAP(pDst)) {
- SYNC_CHECK(pGC);
- }
- ret = (*pGC->ops->CopyPlane)(pSrc, pDst,
- pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
- XAA_GC_OP_EPILOGUE(pGC);
- return ret;
-}
-
-static void
-XAAPolyPointFallback(
- DrawablePtr pDraw,
- GCPtr pGC,
- int mode,
- int npt,
- xPoint *pptInit )
-{
- XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
- SYNC_CHECK(pGC);
- (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit);
- XAA_GC_OP_EPILOGUE(pGC);
-}
-
-
-static void
-XAAPolylinesFallback(
- DrawablePtr pDraw,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr pptInit )
-{
- XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
- SYNC_CHECK(pGC);
- (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit);
- XAA_GC_OP_EPILOGUE(pGC);
-}
-
-static void
-XAAPolySegmentFallback(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nseg,
- xSegment *pSeg )
-{
- XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
- SYNC_CHECK(pGC);
- (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg);
- XAA_GC_OP_EPILOGUE(pGC);
-}
-
-static void
-XAAPolyRectangleFallback(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nRectsInit,
- xRectangle *pRectsInit )
-{
- XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
- SYNC_CHECK(pGC);
- (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit);
- XAA_GC_OP_EPILOGUE(pGC);
-}
-
-static void
-XAAPolyArcFallback(
- DrawablePtr pDraw,
- GCPtr pGC,
- int narcs,
- xArc *parcs )
-{
- XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
- SYNC_CHECK(pGC);
- (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs);
- XAA_GC_OP_EPILOGUE(pGC);
-}
-
-static void
-XAAFillPolygonFallback(
- DrawablePtr pDraw,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn )
-{
- XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
- SYNC_CHECK(pGC);
- (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn);
- XAA_GC_OP_EPILOGUE(pGC);
-}
-
-
-static void
-XAAPolyFillRectFallback(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nrectFill,
- xRectangle *prectInit )
-{
- XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
- SYNC_CHECK(pGC);
- (*pGC->ops->PolyFillRect)(pDraw, pGC, nrectFill, prectInit);
- XAA_GC_OP_EPILOGUE(pGC);
-}
-
-
-static void
-XAAPolyFillArcFallback(
- DrawablePtr pDraw,
- GCPtr pGC,
- int narcs,
- xArc *parcs )
-{
- XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
- SYNC_CHECK(pGC);
- (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs);
- XAA_GC_OP_EPILOGUE(pGC);
-}
-
-static int
-XAAPolyText8Fallback(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- char *chars )
-{
- int ret;
-
- XAA_GC_OP_PROLOGUE(pGC);
- SYNC_CHECK(pGC);
- ret = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars);
- XAA_GC_OP_EPILOGUE(pGC);
- return ret;
-}
-
-static int
-XAAPolyText16Fallback(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- unsigned short *chars )
-{
- int ret;
-
- XAA_GC_OP_PROLOGUE(pGC);
- SYNC_CHECK(pGC);
- ret = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars);
- XAA_GC_OP_EPILOGUE(pGC);
- return ret;
-}
-
-static void
-XAAImageText8Fallback(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- char *chars )
-{
- XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
- SYNC_CHECK(pGC);
- (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars);
- XAA_GC_OP_EPILOGUE(pGC);
-}
-
-static void
-XAAImageText16Fallback(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- unsigned short *chars )
-{
- XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
- SYNC_CHECK(pGC);
- (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars);
- XAA_GC_OP_EPILOGUE(pGC);
-}
-
-
-static void
-XAAImageGlyphBltFallback(
- DrawablePtr pDraw,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase )
-{
- XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
- SYNC_CHECK(pGC);
- (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph, ppci, pglyphBase);
- XAA_GC_OP_EPILOGUE(pGC);
-}
-
-static void
-XAAPolyGlyphBltFallback(
- DrawablePtr pDraw,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase )
-{
- XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
- SYNC_CHECK(pGC);
- (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph, ppci, pglyphBase);
- XAA_GC_OP_EPILOGUE(pGC);
-}
-
-static void
-XAAPushPixelsFallback(
- GCPtr pGC,
- PixmapPtr pBitMap,
- DrawablePtr pDraw,
- int dx, int dy, int xOrg, int yOrg )
-{
- XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
- SYNC_CHECK(pGC);
- (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
- XAA_GC_OP_EPILOGUE(pGC);
-}
-
-GCOps XAAFallbackOps = {
- XAAFillSpansFallback, XAASetSpansFallback,
- XAAPutImageFallback, XAACopyAreaFallback,
- XAACopyPlaneFallback, XAAPolyPointFallback,
- XAAPolylinesFallback, XAAPolySegmentFallback,
- XAAPolyRectangleFallback, XAAPolyArcFallback,
- XAAFillPolygonFallback, XAAPolyFillRectFallback,
- XAAPolyFillArcFallback, XAAPolyText8Fallback,
- XAAPolyText16Fallback, XAAImageText8Fallback,
- XAAImageText16Fallback, XAAImageGlyphBltFallback,
- XAAPolyGlyphBltFallback, XAAPushPixelsFallback,
-};
-
-GCOps *XAAGetFallbackOps(void)
-{
- return &XAAFallbackOps;
-}
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "xaawrap.h"
+
+static void
+XAAFillSpansFallback(DrawablePtr pDraw,
+ GC * pGC,
+ int nInit,
+ DDXPointPtr pptInit, int *pwidthInit, int fSorted)
+{
+ XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
+ SYNC_CHECK(pGC);
+ (*pGC->ops->FillSpans) (pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
+ XAA_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+XAASetSpansFallback(DrawablePtr pDraw,
+ GCPtr pGC,
+ char *pcharsrc,
+ register DDXPointPtr ppt,
+ int *pwidth, int nspans, int fSorted)
+{
+ XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
+ SYNC_CHECK(pGC);
+ (*pGC->ops->SetSpans) (pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted);
+ XAA_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+XAAPutImageFallback(DrawablePtr pDraw,
+ GCPtr pGC,
+ int depth,
+ int x, int y, int w, int h,
+ int leftPad, int format, char *pImage)
+{
+ XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
+ SYNC_CHECK(pGC);
+ (*pGC->ops->PutImage) (pDraw, pGC, depth, x, y, w, h,
+ leftPad, format, pImage);
+ XAA_GC_OP_EPILOGUE(pGC);
+}
+
+static RegionPtr
+XAACopyAreaFallback(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GC * pGC,
+ int srcx, int srcy,
+ int width, int height, int dstx, int dsty)
+{
+ RegionPtr ret;
+
+ XAA_GC_OP_PROLOGUE(pGC);
+ if ((pSrc->type == DRAWABLE_WINDOW) || (pDst->type == DRAWABLE_WINDOW) ||
+ IS_OFFSCREEN_PIXMAP(pSrc) || IS_OFFSCREEN_PIXMAP(pDst)) {
+ SYNC_CHECK(pGC);
+ }
+ ret = (*pGC->ops->CopyArea) (pSrc, pDst,
+ pGC, srcx, srcy, width, height, dstx, dsty);
+ XAA_GC_OP_EPILOGUE(pGC);
+ return ret;
+}
+
+static RegionPtr
+XAACopyPlaneFallback(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx, int srcy,
+ int width, int height,
+ int dstx, int dsty, unsigned long bitPlane)
+{
+ RegionPtr ret;
+
+ XAA_GC_OP_PROLOGUE(pGC);
+ if ((pSrc->type == DRAWABLE_WINDOW) || (pDst->type == DRAWABLE_WINDOW) ||
+ IS_OFFSCREEN_PIXMAP(pSrc) || IS_OFFSCREEN_PIXMAP(pDst)) {
+ SYNC_CHECK(pGC);
+ }
+ ret = (*pGC->ops->CopyPlane) (pSrc, pDst,
+ pGC, srcx, srcy, width, height, dstx, dsty,
+ bitPlane);
+ XAA_GC_OP_EPILOGUE(pGC);
+ return ret;
+}
+
+static void
+XAAPolyPointFallback(DrawablePtr pDraw,
+ GCPtr pGC, int mode, int npt, xPoint * pptInit)
+{
+ XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
+ SYNC_CHECK(pGC);
+ (*pGC->ops->PolyPoint) (pDraw, pGC, mode, npt, pptInit);
+ XAA_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+XAAPolylinesFallback(DrawablePtr pDraw,
+ GCPtr pGC, int mode, int npt, DDXPointPtr pptInit)
+{
+ XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
+ SYNC_CHECK(pGC);
+ (*pGC->ops->Polylines) (pDraw, pGC, mode, npt, pptInit);
+ XAA_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+XAAPolySegmentFallback(DrawablePtr pDraw, GCPtr pGC, int nseg, xSegment * pSeg)
+{
+ XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
+ SYNC_CHECK(pGC);
+ (*pGC->ops->PolySegment) (pDraw, pGC, nseg, pSeg);
+ XAA_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+XAAPolyRectangleFallback(DrawablePtr pDraw,
+ GCPtr pGC, int nRectsInit, xRectangle *pRectsInit)
+{
+ XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
+ SYNC_CHECK(pGC);
+ (*pGC->ops->PolyRectangle) (pDraw, pGC, nRectsInit, pRectsInit);
+ XAA_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+XAAPolyArcFallback(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
+{
+ XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
+ SYNC_CHECK(pGC);
+ (*pGC->ops->PolyArc) (pDraw, pGC, narcs, parcs);
+ XAA_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+XAAFillPolygonFallback(DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape, int mode, int count, DDXPointPtr ptsIn)
+{
+ XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
+ SYNC_CHECK(pGC);
+ (*pGC->ops->FillPolygon) (pDraw, pGC, shape, mode, count, ptsIn);
+ XAA_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+XAAPolyFillRectFallback(DrawablePtr pDraw,
+ GCPtr pGC, int nrectFill, xRectangle *prectInit)
+{
+ XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
+ SYNC_CHECK(pGC);
+ (*pGC->ops->PolyFillRect) (pDraw, pGC, nrectFill, prectInit);
+ XAA_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+XAAPolyFillArcFallback(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
+{
+ XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
+ SYNC_CHECK(pGC);
+ (*pGC->ops->PolyFillArc) (pDraw, pGC, narcs, parcs);
+ XAA_GC_OP_EPILOGUE(pGC);
+}
+
+static int
+XAAPolyText8Fallback(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars)
+{
+ int ret;
+
+ XAA_GC_OP_PROLOGUE(pGC);
+ SYNC_CHECK(pGC);
+ ret = (*pGC->ops->PolyText8) (pDraw, pGC, x, y, count, chars);
+ XAA_GC_OP_EPILOGUE(pGC);
+ return ret;
+}
+
+static int
+XAAPolyText16Fallback(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, unsigned short *chars)
+{
+ int ret;
+
+ XAA_GC_OP_PROLOGUE(pGC);
+ SYNC_CHECK(pGC);
+ ret = (*pGC->ops->PolyText16) (pDraw, pGC, x, y, count, chars);
+ XAA_GC_OP_EPILOGUE(pGC);
+ return ret;
+}
+
+static void
+XAAImageText8Fallback(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars)
+{
+ XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
+ SYNC_CHECK(pGC);
+ (*pGC->ops->ImageText8) (pDraw, pGC, x, y, count, chars);
+ XAA_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+XAAImageText16Fallback(DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y, int count, unsigned short *chars)
+{
+ XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
+ SYNC_CHECK(pGC);
+ (*pGC->ops->ImageText16) (pDraw, pGC, x, y, count, chars);
+ XAA_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+XAAImageGlyphBltFallback(DrawablePtr pDraw,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase)
+{
+ XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
+ SYNC_CHECK(pGC);
+ (*pGC->ops->ImageGlyphBlt) (pDraw, pGC, xInit, yInit, nglyph, ppci,
+ pglyphBase);
+ XAA_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+XAAPolyGlyphBltFallback(DrawablePtr pDraw,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase)
+{
+ XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
+ SYNC_CHECK(pGC);
+ (*pGC->ops->PolyGlyphBlt) (pDraw, pGC, xInit, yInit, nglyph, ppci,
+ pglyphBase);
+ XAA_GC_OP_EPILOGUE(pGC);
+}
+
+static void
+XAAPushPixelsFallback(GCPtr pGC,
+ PixmapPtr pBitMap,
+ DrawablePtr pDraw, int dx, int dy, int xOrg, int yOrg)
+{
+ XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC);
+ SYNC_CHECK(pGC);
+ (*pGC->ops->PushPixels) (pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
+ XAA_GC_OP_EPILOGUE(pGC);
+}
+
+GCOps XAAFallbackOps = {
+ XAAFillSpansFallback, XAASetSpansFallback,
+ XAAPutImageFallback, XAACopyAreaFallback,
+ XAACopyPlaneFallback, XAAPolyPointFallback,
+ XAAPolylinesFallback, XAAPolySegmentFallback,
+ XAAPolyRectangleFallback, XAAPolyArcFallback,
+ XAAFillPolygonFallback, XAAPolyFillRectFallback,
+ XAAPolyFillArcFallback, XAAPolyText8Fallback,
+ XAAPolyText16Fallback, XAAImageText8Fallback,
+ XAAImageText16Fallback, XAAImageGlyphBltFallback,
+ XAAPolyGlyphBltFallback, XAAPushPixelsFallback,
+};
+
+GCOps *
+XAAGetFallbackOps(void)
+{
+ return &XAAFallbackOps;
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaFillArc.c b/xorg-server/hw/xfree86/xaa/xaaFillArc.c
index 824d2af1d..fb7e7201f 100644
--- a/xorg-server/hw/xfree86/xaa/xaaFillArc.c
+++ b/xorg-server/hw/xfree86/xaa/xaaFillArc.c
@@ -1,213 +1,202 @@
-/*
- * Copyright 1996 The XFree86 Project
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * HARM HANEMAAYER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net).
- */
-
-/*
- * Filled solid arcs, based on cfbfillarc.c.
- *
- * Fill arc using calls to low-level span fill. Because the math for
- * each span can be done concurrently with the drawing of the span
- * with a graphics coprocessor operation, this is faster than just
- * using miPolyFillArc, which first calculates all the spans and then
- * calls FillSpans.
- *
- * Clipped arcs are dispatched to FillSpans.
- */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <limits.h>
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-#include "mifillarc.h"
-#include "mi.h"
-
-/*
- * This is based on the integer-math versions from mi. Perhaps on a
- * Pentium, the floating-point (double)-math version is faster.
- */
-
-static void
-XAAFillEllipseSolid(DrawablePtr pDraw, GCPtr pGC, xArc *arc)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- register int x, y, e;
- int yk, xk, ym, xm, dx, dy, xorg, yorg;
- int slw;
- miFillArcRec info;
-
- (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu,
- pGC->planemask);
-
- miFillArcSetup(arc, &info);
- MIFILLARCSETUP();
- if (pGC->miTranslate)
- {
- xorg += pDraw->x;
- yorg += pDraw->y;
- }
- while (y > 0)
- {
- MIFILLARCSTEP(slw);
- if (slw > 0) {
- (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, xorg - x,
- yorg - y, slw, 1);
- if (miFillArcLower(slw))
- (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
- xorg - x, yorg + y + dy, slw, 1);
- }
- }
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
-#define ADDSPAN(l,r) \
- if (r >= l) \
- (*infoRec->SubsequentSolidFillRect)( \
- infoRec->pScrn, l, ya, r - l + 1, 1);
-
-#define ADDSLICESPANS(flip) \
- if (!flip) \
- { \
- ADDSPAN(xl, xr); \
- } \
- else \
- { \
- xc = xorg - x; \
- ADDSPAN(xc, xr); \
- xc += slw - 1; \
- ADDSPAN(xl, xc); \
- }
-
-static void
-XAAFillArcSliceSolid(DrawablePtr pDraw, GCPtr pGC, xArc *arc)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int yk, xk, ym, xm, dx, dy, xorg, yorg, slw;
- register int x, y, e;
- miFillArcRec info;
- miArcSliceRec slice;
- int ya, xl, xr, xc;
-
- (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu,
- pGC->planemask);
-
- miFillArcSetup(arc, &info);
- miFillArcSliceSetup(arc, &slice, pGC);
- MIFILLARCSETUP();
- slw = arc->height;
- if (slice.flip_top || slice.flip_bot)
- slw += (arc->height >> 1) + 1;
- if (pGC->miTranslate)
- {
- xorg += pDraw->x;
- yorg += pDraw->y;
- slice.edge1.x += pDraw->x;
- slice.edge2.x += pDraw->x;
- }
- while (y > 0)
- {
- MIFILLARCSTEP(slw);
- MIARCSLICESTEP(slice.edge1);
- MIARCSLICESTEP(slice.edge2);
- if (miFillSliceUpper(slice))
- {
- ya = yorg - y;
- MIARCSLICEUPPER(xl, xr, slice, slw);
-
- ADDSLICESPANS(slice.flip_top);
- }
- if (miFillSliceLower(slice))
- {
- ya = yorg + y + dy;
- MIARCSLICELOWER(xl, xr, slice, slw);
- ADDSLICESPANS(slice.flip_bot);
- }
- }
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
-void
-XAAPolyFillArcSolid(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs)
-{
- register xArc *arc;
- register int i;
- int x2, y2;
- BoxRec box;
- RegionPtr cclip;
-
- cclip = pGC->pCompositeClip;
-
- if(!RegionNumRects(cclip))
- return;
-
- for (arc = parcs, i = narcs; --i >= 0; arc++)
- {
- if (miFillArcEmpty(arc))
- continue;
- if (miCanFillArc(arc))
- {
- box.x1 = arc->x + pDraw->x;
- box.y1 = arc->y + pDraw->y;
- /*
- * Because box.x2 and box.y2 get truncated to 16 bits, and the
- * RECT_IN_REGION test treats the resulting number as a signed
- * integer, the RECT_IN_REGION test alone can go the wrong way.
- * This can result in a server crash because the rendering
- * routines in this file deal directly with cpu addresses
- * of pixels to be stored, and do not clip or otherwise check
- * that all such addresses are within their respective pixmaps.
- * So we only allow the RECT_IN_REGION test to be used for
- * values that can be expressed correctly in a signed short.
- */
- x2 = box.x1 + (int)arc->width + 1;
- box.x2 = x2;
- y2 = box.y1 + (int)arc->height + 1;
- box.y2 = y2;
- if ( (x2 <= SHRT_MAX) && (y2 <= SHRT_MAX) &&
- (RegionContainsRect(cclip, &box) == rgnIN) )
- {
- if ((arc->angle2 >= FULLCIRCLE) ||
- (arc->angle2 <= -FULLCIRCLE))
- XAAFillEllipseSolid(pDraw, pGC, arc);
- else
- XAAFillArcSliceSolid(pDraw, pGC, arc);
- continue;
- }
- }
- miPolyFillArc(pDraw, pGC, 1, arc);
- }
-}
+/*
+ * Copyright 1996 The XFree86 Project
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * HARM HANEMAAYER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net).
+ */
+
+/*
+ * Filled solid arcs, based on cfbfillarc.c.
+ *
+ * Fill arc using calls to low-level span fill. Because the math for
+ * each span can be done concurrently with the drawing of the span
+ * with a graphics coprocessor operation, this is faster than just
+ * using miPolyFillArc, which first calculates all the spans and then
+ * calls FillSpans.
+ *
+ * Clipped arcs are dispatched to FillSpans.
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <limits.h>
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "mifillarc.h"
+#include "mi.h"
+
+/*
+ * This is based on the integer-math versions from mi. Perhaps on a
+ * Pentium, the floating-point (double)-math version is faster.
+ */
+
+static void
+XAAFillEllipseSolid(DrawablePtr pDraw, GCPtr pGC, xArc * arc)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ register int x, y, e;
+ int yk, xk, ym, xm, dx, dy, xorg, yorg;
+ int slw;
+ miFillArcRec info;
+
+ (*infoRec->SetupForSolidFill) (infoRec->pScrn, pGC->fgPixel, pGC->alu,
+ pGC->planemask);
+
+ miFillArcSetup(arc, &info);
+ MIFILLARCSETUP();
+ if (pGC->miTranslate) {
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ }
+ while (y > 0) {
+ MIFILLARCSTEP(slw);
+ if (slw > 0) {
+ (*infoRec->SubsequentSolidFillRect) (infoRec->pScrn, xorg - x,
+ yorg - y, slw, 1);
+ if (miFillArcLower(slw))
+ (*infoRec->SubsequentSolidFillRect) (infoRec->pScrn,
+ xorg - x, yorg + y + dy,
+ slw, 1);
+ }
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+#define ADDSPAN(l,r) \
+ if (r >= l) \
+ (*infoRec->SubsequentSolidFillRect)( \
+ infoRec->pScrn, l, ya, r - l + 1, 1);
+
+#define ADDSLICESPANS(flip) \
+ if (!flip) \
+ { \
+ ADDSPAN(xl, xr); \
+ } \
+ else \
+ { \
+ xc = xorg - x; \
+ ADDSPAN(xc, xr); \
+ xc += slw - 1; \
+ ADDSPAN(xl, xc); \
+ }
+
+static void
+XAAFillArcSliceSolid(DrawablePtr pDraw, GCPtr pGC, xArc * arc)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int yk, xk, ym, xm, dx, dy, xorg, yorg, slw;
+ register int x, y, e;
+ miFillArcRec info;
+ miArcSliceRec slice;
+ int ya, xl, xr, xc;
+
+ (*infoRec->SetupForSolidFill) (infoRec->pScrn, pGC->fgPixel, pGC->alu,
+ pGC->planemask);
+
+ miFillArcSetup(arc, &info);
+ miFillArcSliceSetup(arc, &slice, pGC);
+ MIFILLARCSETUP();
+ slw = arc->height;
+ if (slice.flip_top || slice.flip_bot)
+ slw += (arc->height >> 1) + 1;
+ if (pGC->miTranslate) {
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ slice.edge1.x += pDraw->x;
+ slice.edge2.x += pDraw->x;
+ }
+ while (y > 0) {
+ MIFILLARCSTEP(slw);
+ MIARCSLICESTEP(slice.edge1);
+ MIARCSLICESTEP(slice.edge2);
+ if (miFillSliceUpper(slice)) {
+ ya = yorg - y;
+ MIARCSLICEUPPER(xl, xr, slice, slw);
+
+ ADDSLICESPANS(slice.flip_top);
+ }
+ if (miFillSliceLower(slice)) {
+ ya = yorg + y + dy;
+ MIARCSLICELOWER(xl, xr, slice, slw);
+ ADDSLICESPANS(slice.flip_bot);
+ }
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+void
+XAAPolyFillArcSolid(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
+{
+ register xArc *arc;
+ register int i;
+ int x2, y2;
+ BoxRec box;
+ RegionPtr cclip;
+
+ cclip = pGC->pCompositeClip;
+
+ if (!RegionNumRects(cclip))
+ return;
+
+ for (arc = parcs, i = narcs; --i >= 0; arc++) {
+ if (miFillArcEmpty(arc))
+ continue;
+ if (miCanFillArc(arc)) {
+ box.x1 = arc->x + pDraw->x;
+ box.y1 = arc->y + pDraw->y;
+ /*
+ * Because box.x2 and box.y2 get truncated to 16 bits, and the
+ * RECT_IN_REGION test treats the resulting number as a signed
+ * integer, the RECT_IN_REGION test alone can go the wrong way.
+ * This can result in a server crash because the rendering
+ * routines in this file deal directly with cpu addresses
+ * of pixels to be stored, and do not clip or otherwise check
+ * that all such addresses are within their respective pixmaps.
+ * So we only allow the RECT_IN_REGION test to be used for
+ * values that can be expressed correctly in a signed short.
+ */
+ x2 = box.x1 + (int) arc->width + 1;
+ box.x2 = x2;
+ y2 = box.y1 + (int) arc->height + 1;
+ box.y2 = y2;
+ if ((x2 <= SHRT_MAX) && (y2 <= SHRT_MAX) &&
+ (RegionContainsRect(cclip, &box) == rgnIN)) {
+ if ((arc->angle2 >= FULLCIRCLE) || (arc->angle2 <= -FULLCIRCLE))
+ XAAFillEllipseSolid(pDraw, pGC, arc);
+ else
+ XAAFillArcSliceSolid(pDraw, pGC, arc);
+ continue;
+ }
+ }
+ miPolyFillArc(pDraw, pGC, 1, arc);
+ }
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaFillPoly.c b/xorg-server/hw/xfree86/xaa/xaaFillPoly.c
index b8347b336..0cdedf57e 100644
--- a/xorg-server/hw/xfree86/xaa/xaaFillPoly.c
+++ b/xorg-server/hw/xfree86/xaa/xaaFillPoly.c
@@ -1,962 +1,991 @@
-
-/*
- * Copyright 1996 The XFree86 Project
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * HARM HANEMAAYER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Written by Mark Vojkovich. Loosly based on an original version
- * written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net) which
- * only did solid rectangles and didn't have trapezoid support.
- *
- */
-
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "xf86str.h"
-#include "mi.h"
-#include "micoord.h"
-
-#include "xaa.h"
-#include "xaalocal.h"
-
-#define POLY_USE_MI 0
-#define POLY_FULLY_CLIPPED 1
-#define POLY_IS_EASY 2
-
-
-#define Setup(c,x,vertex,dx,dy,e,sign,step,DX) {\
- x = intToX(vertex); \
- if ((dy = intToY(c) - y)) { \
- DX = dx = intToX(c) - x; \
- step = 0; \
- if (dx >= 0) \
- { \
- e = 0; \
- sign = 1; \
- if (dx >= dy) {\
- step = dx / dy; \
- dx %= dy; \
- } \
- } \
- else \
- { \
- e = 1 - dy; \
- sign = -1; \
- dx = -dx; \
- if (dx >= dy) { \
- step = - (dx / dy); \
- dx %= dy; \
- } \
- } \
- } \
- x += origin; \
- vertex = c; \
-}
-
-#define Step(x,dx,dy,e,sign,step) {\
- x += step; \
- if ((e += dx) > 0) \
- { \
- x += sign; \
- e -= dy; \
- } \
-}
-
-#define FixError(x, dx, dy, e, sign, step, h) { \
- e += (h) * dx; \
- x += (h) * step; \
- if(e > 0) { \
- x += e * sign/dy; \
- e %= dy; \
- if(e) { \
- x += sign; \
- e -= dy; \
- } \
- } \
-}
-
-
-/*
- XAAIsEasyPoly -
-
- Checks CoordModeOrigin one rect polygons to see if we need
- to use Mi.
- Returns: POLY_USE_MI, POLY_FULLY_CLIPPED or POLY_IS_EASY
- as well as the pointer to the "top" point and the y
- extents.
-*/
-
-int
-XAAIsEasyPolygon(
- DDXPointPtr ptsIn,
- int count,
- BoxPtr extents,
- int origin,
- DDXPointPtr *topPoint, /* return */
- int *topY, int *bottomY, /* return */
- int shape
-){
- int c = 0, vertex1, vertex2;
-
- *topY = 32767;
- *bottomY = 0;
-
- origin -= (origin & 0x8000) << 1;
- vertex1 = extents->x1 - origin;
- vertex2 = extents->x2 - origin /* - 0x00010001 */;
- /* I think this was an error in cfb ^ */
-
- if (shape == Convex) {
- while (count--) {
- c = *((int*)ptsIn);
- if (((c - vertex1) | (vertex2 - c)) & 0x80008000)
- return POLY_USE_MI;
-
- c = intToY(c);
- if (c < *topY) {
- *topY = c;
- *topPoint = ptsIn;
- }
- ptsIn++;
- if (c > *bottomY) *bottomY = c;
- }
- } else {
- int yFlip = 0;
- int dx2, dx1, x1, x2;
-
- x2 = x1 = -1;
- dx2 = dx1 = 1;
-
- while (count--) {
- c = *((int*)ptsIn);
- if (((c - vertex1) | (vertex2 - c)) & 0x80008000)
- return POLY_USE_MI;
- c = intToY(c);
- if (c < *topY) {
- *topY = c;
- *topPoint = ptsIn;
- }
- ptsIn++;
- if (c > *bottomY) *bottomY = c;
- if (c == x1)
- continue;
- if (dx1 > 0) {
- if (x2 < 0) x2 = c;
- else dx2 = dx1 = (c - x1) >> 31;
- } else if ((c - x1) >> 31 != dx1) {
- dx1 = ~dx1;
- yFlip++;
- }
- x1 = c;
- }
- x1 = (x2 - c) >> 31;
- if (x1 != dx1) yFlip++;
- if (x1 != dx2) yFlip++;
- if (yFlip != 2) {
- if(*topY == *bottomY)
- return POLY_FULLY_CLIPPED;
- else
- return POLY_USE_MI;
- }
- }
- if (*topY == *bottomY)
- return POLY_FULLY_CLIPPED;
-
- return POLY_IS_EASY;
-}
-
-void
-XAAFillPolygonSolid(
- DrawablePtr pDraw,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int origin, vertex1, vertex2;
- int *vertex1p, *vertex2p, *endp;
- int x1 = 0, x2 = 0;
- int dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0;
- int DX1 = 0, DX2 = 0, e1 = 0, e2 = 0;
- int step1 = 0, step2 = 0, sign1 = 0, sign2 = 0;
- int c, y, maxy, h, yoffset;
- DDXPointPtr topPoint;
-
- if(!RegionNumRects(pGC->pCompositeClip))
- return;
-
- if (mode == CoordModePrevious) {
- register DDXPointPtr ppt = ptsIn + 1;
-
- for (origin = 1; origin < count; origin++, ppt++) {
- ppt->x += (ppt-1)->x;
- ppt->y += (ppt-1)->y;
- }
- mode = CoordModeOrigin;
- }
-
- if (RegionNumRects(pGC->pCompositeClip) != 1) {
- miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
- return;
- }
-
- origin = coordToInt(pDraw->x, pDraw->y);
-
- switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents,
- origin, &topPoint, &y, &maxy, shape) ) {
- case POLY_USE_MI:
- miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
- case POLY_FULLY_CLIPPED:
- return;
- }
-
- endp = (int*)ptsIn + count;
- vertex2p = vertex1p = (int *)topPoint;
- origin = pDraw->x;
- yoffset = pDraw->y;
- vertex2 = vertex1 = *vertex2p++;
- if (vertex2p == endp)
- vertex2p = (int *) ptsIn;
-
- (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu,
- pGC->planemask);
-
- while(1) {
- if (y == intToY(vertex1)) {
- do {
- if (vertex1p == (int *) ptsIn)
- vertex1p = endp;
- c = *--vertex1p;
- Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1,DX1)
- } while (y >= intToY(vertex1));
- h = dy1;
- } else {
- Step(x1,dx1,dy1,e1,sign1,step1)
- h = intToY(vertex1) - y;
- }
- if (y == intToY(vertex2)) {
- do {
- c = *vertex2p++;
- if (vertex2p == endp)
- vertex2p = (int *) ptsIn;
- Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2,DX2)
- } while (y >= intToY(vertex2));
- if (dy2 < h)
- h = dy2;
- } else {
- Step(x2,dx2,dy2,e2,sign2,step2)
- if ((c = (intToY(vertex2) - y)) < h)
- h = c;
- }
-
- /* fill spans for this segment */
- if(DX1 | DX2) {
- if(infoRec->SubsequentSolidFillTrap && (h > 6)) {
- if(x1 == x2) {
- while(x1 == x2) {
- y++;
- if (!--h) break;
- Step(x1,dx1,dy1,e1,sign1,step1)
- Step(x2,dx2,dy2,e2,sign2,step2)
- }
- if(y == maxy) break;
- if(!h) continue;
- }
-
- if(x1 < x2)
- (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn,
- y + yoffset, h,
- x1, DX1, dy1, e1,
- x2 - 1, DX2, dy2, e2);
- else
- (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn,
- y + yoffset, h,
- x2, DX2, dy2, e2,
- x1 - 1, DX1, dy1, e1);
- y += h;
- if(--h) {
- FixError(x1,dx1,dy1,e1,sign1,step1,h);
- FixError(x2,dx2,dy2,e2,sign2,step2,h);
- h = 0;
- }
- } else {
- while(1) {
- if (x2 > x1)
- (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
- x1, y + yoffset, x2 - x1, 1);
- else if (x1 > x2)
- (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
- x2, y + yoffset, x1 - x2, 1);
- y++;
- if (!--h) break;
- Step(x1,dx1,dy1,e1,sign1,step1)
- Step(x2,dx2,dy2,e2,sign2,step2)
- }
- }
- } else {
- if (x2 > x1)
- (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
- x1, y + yoffset, x2 - x1, h);
- else if (x1 > x2)
- (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
- x2, y + yoffset, x1 - x2, h);
-
- y += h;
- h = 0;
- }
- if (y == maxy) break;
- }
- SET_SYNC_FLAG(infoRec);
-}
-
-
-
-
-void
-XAAFillPolygonHelper(
- ScrnInfoPtr pScrn,
- DDXPointPtr ptsIn,
- int count,
- DDXPointPtr topPoint,
- int y,
- int maxy,
- int origin,
- RectFuncPtr RectFunc,
- TrapFuncPtr TrapFunc,
- int xorg,
- int yorg,
- XAACacheInfoPtr pCache
-){
- int *vertex1p, *vertex2p, *endp;
- int vertex1, vertex2;
- int x1 = 0, x2 = 0;
- int dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0;
- int DX1 = 0, DX2 = 0, e1 = 0, e2 = 0;
- int step1 = 0, step2 = 0, sign1 = 0, sign2 = 0;
- int c, h, yoffset;
-
-
- endp = (int*)ptsIn + count;
- vertex2p = vertex1p = (int *)topPoint;
- yoffset = intToY(origin);
- origin = intToX(origin);
- vertex2 = vertex1 = *vertex2p++;
- if (vertex2p == endp)
- vertex2p = (int *)ptsIn;
-
- while(1) {
- if (y == intToY(vertex1)) {
- do {
- if (vertex1p == (int *) ptsIn)
- vertex1p = endp;
- c = *--vertex1p;
- Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1,DX1)
- } while (y >= intToY(vertex1));
- h = dy1;
- } else {
- Step(x1,dx1,dy1,e1,sign1,step1)
- h = intToY(vertex1) - y;
- }
- if (y == intToY(vertex2)) {
- do {
- c = *vertex2p++;
- if (vertex2p == endp)
- vertex2p = (int *) ptsIn;
- Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2,DX2)
- } while (y >= intToY(vertex2));
- if (dy2 < h)
- h = dy2;
- } else {
- Step(x2,dx2,dy2,e2,sign2,step2)
- if ((c = (intToY(vertex2) - y)) < h)
- h = c;
- }
-
- /* fill spans for this segment */
- if(DX1 | DX2) {
- if(TrapFunc && (h > 6)) {
- if(x1 == x2) {
- while(x1 == x2) {
- y++;
- if (!--h) break;
- Step(x1,dx1,dy1,e1,sign1,step1)
- Step(x2,dx2,dy2,e2,sign2,step2)
- }
- if(y == maxy) break;
- if(!h) continue;
- }
-
- if(x1 < x2)
- (*TrapFunc)(pScrn, y + yoffset, h,
- x1, DX1, dy1, e1,
- x2 - 1, DX2, dy2, e2, xorg, yorg, pCache);
- else
- (*TrapFunc)(pScrn, y + yoffset, h,
- x2, DX2, dy2, e2,
- x1 - 1, DX1, dy1, e1, xorg, yorg, pCache);
- y += h;
- if(--h) {
- FixError(x1,dx1,dy1,e1,sign1,step1,h);
- FixError(x2,dx2,dy2,e2,sign2,step2,h);
- h = 0;
- }
- } else {
- while(1) {
- if (x2 > x1)
- (*RectFunc)(pScrn,
- x1, y + yoffset, x2 - x1, 1, xorg, yorg, pCache);
- else if (x1 > x2)
- (*RectFunc)(pScrn,
- x2, y + yoffset, x1 - x2, 1, xorg, yorg, pCache);
- y++;
- if (!--h) break;
- Step(x1,dx1,dy1,e1,sign1,step1)
- Step(x2,dx2,dy2,e2,sign2,step2)
- }
- }
- } else {
- if (x2 > x1)
- (*RectFunc)(pScrn,
- x1, y + yoffset, x2 - x1, h, xorg, yorg, pCache);
- else if (x1 > x2)
- (*RectFunc)(pScrn,
- x2, y + yoffset, x1 - x2, h, xorg, yorg, pCache);
-
- y += h;
- h = 0;
- }
- if (y == maxy) break;
- }
-}
-
- /*****************\
- | Solid Helpers |
- \*****************/
-
-static void
-SolidTrapHelper(
- ScrnInfoPtr pScrn,
- int y, int h,
- int x1, int dx1, int dy1, int e1,
- int x2, int dx2, int dy2, int e2,
- int xorg, int yorg,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
-
- (*infoRec->SubsequentSolidFillTrap) (pScrn,
- y, h, x1, dx1, dy1, e1, x2, dx2, dy2, e2);
-}
-
-static void
-SolidRectHelper (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- int xorg, int yorg,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
-
- (*infoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h);
-}
-
-
- /*********************\
- | Mono 8x8 Patterns |
- \*********************/
-
-static void
-Mono8x8PatternTrapHelper_ScreenOrigin(
- ScrnInfoPtr pScrn,
- int y, int h,
- int x1, int dx1, int dy1, int e1,
- int x2, int dx2, int dy2, int e2,
- int xorg, int yorg,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
-
- (*infoRec->SubsequentMono8x8PatternFillTrap) (pScrn, xorg, yorg,
- y, h, x1, dx1, dy1, e1, x2, dx2, dy2, e2);
-}
-
-static void
-Mono8x8PatternRectHelper_ScreenOrigin (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- int xorg, int yorg,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
-
- (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn, xorg, yorg,
- x, y, w, h);
-}
-
-static void
-Mono8x8PatternRectHelper (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- int xorg, int yorg,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
-
- xorg = (x - xorg) & 0x07;
- yorg = (y - yorg) & 0x07;
-
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- if(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_BITS) {
- int patx = pCache->pat0;
- int paty = pCache->pat1;
- XAARotateMonoPattern(&patx, &paty, xorg, yorg,
- (infoRec->Mono8x8PatternFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST));
- xorg = patx; yorg = paty;
- } else {
- int slot = (yorg << 3) + xorg;
- xorg = pCache->x + pCache->offsets[slot].x;
- yorg = pCache->y + pCache->offsets[slot].y;
- }
- }
-
-
- (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn, xorg, yorg,
- x, y, w, h);
-}
-
-
-
- /****************\
- | Cache Expand |
- \****************/
-
-
-static void
-CacheExpandRectHelper (
- ScrnInfoPtr pScrn,
- int X, int Y, int Width, int Height,
- int xorg, int yorg,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int x, phaseY, phaseX, skipleft, w, blit_w, blit_h;
- int cacheWidth;
-
- cacheWidth = (pCache->w * pScrn->bitsPerPixel) /
- infoRec->CacheColorExpandDensity;
-
- phaseY = (Y - yorg) % pCache->orig_h;
- if(phaseY < 0) phaseY += pCache->orig_h;
- phaseX = (X - xorg) % pCache->orig_w;
- if(phaseX < 0) phaseX += pCache->orig_w;
-
- while(1) {
- w = Width; skipleft = phaseX; x = X;
- blit_h = pCache->h - phaseY;
- if(blit_h > Height) blit_h = Height;
-
- while(1) {
- blit_w = cacheWidth - skipleft;
- if(blit_w > w) blit_w = w;
- (*infoRec->SubsequentScreenToScreenColorExpandFill)(
- pScrn, x, Y, blit_w, blit_h,
- pCache->x, pCache->y + phaseY, skipleft);
- w -= blit_w;
- if(!w) break;
- x += blit_w;
- skipleft = (skipleft + blit_w) % pCache->orig_w;
- }
- Height -= blit_h;
- if(!Height) break;
- Y += blit_h;
- phaseY = (phaseY + blit_h) % pCache->orig_h;
- }
-}
-
-
-
- /**************\
- | Cache Blit |
- \**************/
-
-
-static void
-CacheBltRectHelper (
- ScrnInfoPtr pScrn,
- int X, int Y, int Width, int Height,
- int xorg, int yorg,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int x, phaseY, phaseX, skipleft, w, blit_w, blit_h;
-
- phaseY = (Y - yorg) % pCache->orig_h;
- if(phaseY < 0) phaseY += pCache->orig_h;
- phaseX = (X - xorg) % pCache->orig_w;
- if(phaseX < 0) phaseX += pCache->orig_w;
-
- while(1) {
- w = Width; skipleft = phaseX; x = X;
- blit_h = pCache->h - phaseY;
- if(blit_h > Height) blit_h = Height;
-
- while(1) {
- blit_w = pCache->w - skipleft;
- if(blit_w > w) blit_w = w;
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
- pCache->x + skipleft, pCache->y + phaseY,
- x, Y, blit_w, blit_h);
- w -= blit_w;
- if(!w) break;
- x += blit_w;
- skipleft = (skipleft + blit_w) % pCache->orig_w;
- }
- Height -= blit_h;
- if(!Height) break;
- Y += blit_h;
- phaseY = (phaseY + blit_h) % pCache->orig_h;
- }
-}
-
-
- /**********************\
- | Stippled Polygons |
- \**********************/
-
-
-void
-XAAFillPolygonStippled(
- DrawablePtr pDraw,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
- int origin, type, patx, paty, fg, bg;
- int y, maxy, xorg, yorg;
- DDXPointPtr topPoint;
- XAACacheInfoPtr pCache = NULL;
- RectFuncPtr RectFunc = NULL;
- TrapFuncPtr TrapFunc = NULL;
-
- if(!RegionNumRects(pGC->pCompositeClip))
- return;
-
- if (mode == CoordModePrevious) {
- register DDXPointPtr ppt = ptsIn + 1;
-
- for (origin = 1; origin < count; origin++, ppt++) {
- ppt->x += (ppt-1)->x;
- ppt->y += (ppt-1)->y;
- }
- mode = CoordModeOrigin;
- }
-
- if (RegionNumRects(pGC->pCompositeClip) != 1) {
- miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
- return;
- }
-
-
- if(pGC->fillStyle == FillStippled) {
- type = (*infoRec->StippledFillChooser)(pGC);
- fg = pGC->fgPixel; bg = -1;
- } else {
- type = (*infoRec->OpaqueStippledFillChooser)(pGC);
- fg = pGC->fgPixel; bg = pGC->bgPixel;
- }
-
-
- if(!type) {
- (*XAAFallbackOps.FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn);
- return;
- }
-
- if((type == DO_COLOR_EXPAND) || (type == DO_COLOR_8x8)) {
- miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
- return;
- }
-
- origin = pDraw->x;
-
- switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents,
- origin, &topPoint, &y, &maxy, shape) ) {
- case POLY_USE_MI:
- miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
- case POLY_FULLY_CLIPPED:
- return;
- }
-
- xorg = (pDraw->x + pGC->patOrg.x);
- yorg = (pDraw->y + pGC->patOrg.y);
-
-
- if((fg == bg) && (bg != -1) && infoRec->SetupForSolidFill) {
-
- (*infoRec->SetupForSolidFill)(infoRec->pScrn, fg,
- pGC->alu, pGC->planemask);
-
- RectFunc = SolidRectHelper;
- TrapFunc = infoRec->SubsequentSolidFillTrap ? SolidTrapHelper : NULL;
- } else
- switch(type) {
- case DO_MONO_8x8:
- patx = pPriv->pattern0; paty = pPriv->pattern1;
- if(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_SCREEN_ORIGIN) {
- xorg = (-xorg) & 0x07; yorg = (-yorg) & 0x07;
- if(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_BITS) {
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
- XAARotateMonoPattern(&patx, &paty, xorg, yorg,
- (infoRec->Mono8x8PatternFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST));
- xorg = patx; yorg = paty;
- }
- } else {
- XAACacheInfoPtr pCache = (*infoRec->CacheMono8x8Pattern)(
- infoRec->pScrn, patx, paty);
- patx = pCache->x; paty = pCache->y;
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- int slot = (yorg << 3) + xorg;
- patx += pCache->offsets[slot].x;
- paty += pCache->offsets[slot].y;
- xorg = patx; yorg = paty;
- }
- }
- RectFunc = Mono8x8PatternRectHelper_ScreenOrigin;
- if(infoRec->SubsequentMono8x8PatternFillTrap)
- TrapFunc = Mono8x8PatternTrapHelper_ScreenOrigin;
- } else { /* !HARDWARE_PATTERN_SCREEN_ORIGIN */
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_BITS)){
- pCache = (*infoRec->CacheMono8x8Pattern)(
- infoRec->pScrn, patx, paty);
- patx = pCache->x; paty = pCache->y;
- } else {
- pCache = &(infoRec->ScratchCacheInfoRec);
- pCache->pat0 = patx;
- pCache->pat1 = paty;
- }
- RectFunc = Mono8x8PatternRectHelper;
- }
-
- (*infoRec->SetupForMono8x8PatternFill)(infoRec->pScrn,
- patx, paty, fg, bg, pGC->alu, pGC->planemask);
- break;
- case DO_CACHE_EXPAND:
- pCache = (*infoRec->CacheMonoStipple)(infoRec->pScrn, pGC->stipple);
-
- (*infoRec->SetupForScreenToScreenColorExpandFill)(
- infoRec->pScrn, fg, bg, pGC->alu, pGC->planemask);
-
- RectFunc = CacheExpandRectHelper;
- break;
- case DO_CACHE_BLT:
- pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple,
- fg, bg);
- (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1,
- pGC->alu, pGC->planemask, pCache->trans_color);
-
- RectFunc = CacheBltRectHelper;
- break;
- default:
- return;
- }
-
-
- XAAFillPolygonHelper(infoRec->pScrn, ptsIn, count, topPoint,
- y, maxy, origin, RectFunc, TrapFunc, xorg, yorg, pCache);
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
-
-
- /*******************\
- | Tiled Polygons |
- \*******************/
-
-
-void
-XAAFillPolygonTiled(
- DrawablePtr pDraw,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
- int origin, type, patx, paty;
- int y, maxy, xorg, yorg;
- DDXPointPtr topPoint;
- XAACacheInfoPtr pCache = NULL;
- RectFuncPtr RectFunc = NULL;
- TrapFuncPtr TrapFunc = NULL;
-
- if(!RegionNumRects(pGC->pCompositeClip))
- return;
-
- if (mode == CoordModePrevious) {
- register DDXPointPtr ppt = ptsIn + 1;
-
- for (origin = 1; origin < count; origin++, ppt++) {
- ppt->x += (ppt-1)->x;
- ppt->y += (ppt-1)->y;
- }
- mode = CoordModeOrigin;
- }
-
- if (RegionNumRects(pGC->pCompositeClip) != 1) {
- miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
- return;
- }
-
-
- type = (*infoRec->TiledFillChooser)(pGC);
-
- if(!type || (type == DO_IMAGE_WRITE)) {
- (*XAAFallbackOps.FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn);
- return;
- }
-
- if(type == DO_COLOR_8x8) {
- miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
- return;
- }
-
- origin = pDraw->x;
-
- switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents,
- origin, &topPoint, &y, &maxy, shape) ) {
- case POLY_USE_MI:
- miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
- case POLY_FULLY_CLIPPED:
- return;
- }
-
- xorg = (pDraw->x + pGC->patOrg.x);
- yorg = (pDraw->y + pGC->patOrg.y);
-
- switch(type) {
- case DO_MONO_8x8:
- patx = pPriv->pattern0; paty = pPriv->pattern1;
- if(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_SCREEN_ORIGIN) {
- xorg = (-xorg) & 0x07; yorg = (-yorg) & 0x07;
- if(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_BITS) {
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
- XAARotateMonoPattern(&patx, &paty, xorg, yorg,
- (infoRec->Mono8x8PatternFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST));
- xorg = patx; yorg = paty;
- }
- } else {
- XAACacheInfoPtr pCache = (*infoRec->CacheMono8x8Pattern)(
- infoRec->pScrn, patx, paty);
- patx = pCache->x; paty = pCache->y;
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- int slot = (yorg << 3) + xorg;
- patx += pCache->offsets[slot].x;
- paty += pCache->offsets[slot].y;
- xorg = patx; yorg = paty;
- }
- }
- RectFunc = Mono8x8PatternRectHelper_ScreenOrigin;
- if(infoRec->SubsequentMono8x8PatternFillTrap)
- TrapFunc = Mono8x8PatternTrapHelper_ScreenOrigin;
- } else { /* !HARDWARE_PATTERN_SCREEN_ORIGIN */
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_BITS)){
- pCache = (*infoRec->CacheMono8x8Pattern)(
- infoRec->pScrn, patx, paty);
- patx = pCache->x; paty = pCache->y;
- }
- else {
- pCache = &(infoRec->ScratchCacheInfoRec);
- pCache->pat0 = patx;
- pCache->pat1 = paty;
- }
- RectFunc = Mono8x8PatternRectHelper;
- }
-
- (*infoRec->SetupForMono8x8PatternFill)(infoRec->pScrn,
- patx, paty, pPriv->fg, pPriv->bg, pGC->alu, pGC->planemask);
- break;
- case DO_CACHE_BLT:
- pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap);
- (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1,
- pGC->alu, pGC->planemask, -1);
-
- RectFunc = CacheBltRectHelper;
- break;
- case DO_PIXMAP_COPY:
- pCache = &(infoRec->ScratchCacheInfoRec);
- pCache->x = pPriv->offscreenArea->box.x1;
- pCache->y = pPriv->offscreenArea->box.y1;
- pCache->w = pCache->orig_w =
- pPriv->offscreenArea->box.x2 - pCache->x;
- pCache->h = pCache->orig_h =
- pPriv->offscreenArea->box.y2 - pCache->y;
-
- (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1,
- pGC->alu, pGC->planemask, -1);
-
- RectFunc = CacheBltRectHelper;
- break;
- default:
- return;
- }
-
- XAAFillPolygonHelper(infoRec->pScrn, ptsIn, count, topPoint,
- y, maxy, origin, RectFunc, TrapFunc, xorg, yorg, pCache);
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
+
+/*
+ * Copyright 1996 The XFree86 Project
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * HARM HANEMAAYER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Written by Mark Vojkovich. Loosly based on an original version
+ * written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net) which
+ * only did solid rectangles and didn't have trapezoid support.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "xf86str.h"
+#include "mi.h"
+#include "micoord.h"
+
+#include "xaa.h"
+#include "xaalocal.h"
+
+#define POLY_USE_MI 0
+#define POLY_FULLY_CLIPPED 1
+#define POLY_IS_EASY 2
+
+#define Setup(c,x,vertex,dx,dy,e,sign,step,DX) {\
+ x = intToX(vertex); \
+ if ((dy = intToY(c) - y)) { \
+ DX = dx = intToX(c) - x; \
+ step = 0; \
+ if (dx >= 0) \
+ { \
+ e = 0; \
+ sign = 1; \
+ if (dx >= dy) {\
+ step = dx / dy; \
+ dx %= dy; \
+ } \
+ } \
+ else \
+ { \
+ e = 1 - dy; \
+ sign = -1; \
+ dx = -dx; \
+ if (dx >= dy) { \
+ step = - (dx / dy); \
+ dx %= dy; \
+ } \
+ } \
+ } \
+ x += origin; \
+ vertex = c; \
+}
+
+#define Step(x,dx,dy,e,sign,step) {\
+ x += step; \
+ if ((e += dx) > 0) \
+ { \
+ x += sign; \
+ e -= dy; \
+ } \
+}
+
+#define FixError(x, dx, dy, e, sign, step, h) { \
+ e += (h) * dx; \
+ x += (h) * step; \
+ if(e > 0) { \
+ x += e * sign/dy; \
+ e %= dy; \
+ if(e) { \
+ x += sign; \
+ e -= dy; \
+ } \
+ } \
+}
+
+/*
+ XAAIsEasyPoly -
+
+ Checks CoordModeOrigin one rect polygons to see if we need
+ to use Mi.
+ Returns: POLY_USE_MI, POLY_FULLY_CLIPPED or POLY_IS_EASY
+ as well as the pointer to the "top" point and the y
+ extents.
+*/
+
+int
+XAAIsEasyPolygon(DDXPointPtr ptsIn, int count, BoxPtr extents, int origin, DDXPointPtr * topPoint, /* return */
+ int *topY, int *bottomY, /* return */
+ int shape)
+{
+ int c = 0, vertex1, vertex2;
+
+ *topY = 32767;
+ *bottomY = 0;
+
+ origin -= (origin & 0x8000) << 1;
+ vertex1 = extents->x1 - origin;
+ vertex2 = extents->x2 - origin /* - 0x00010001 */ ;
+ /* I think this was an error in cfb ^ */
+
+ if (shape == Convex) {
+ while (count--) {
+ c = *((int *) ptsIn);
+ if (((c - vertex1) | (vertex2 - c)) & 0x80008000)
+ return POLY_USE_MI;
+
+ c = intToY(c);
+ if (c < *topY) {
+ *topY = c;
+ *topPoint = ptsIn;
+ }
+ ptsIn++;
+ if (c > *bottomY)
+ *bottomY = c;
+ }
+ }
+ else {
+ int yFlip = 0;
+ int dx2, dx1, x1, x2;
+
+ x2 = x1 = -1;
+ dx2 = dx1 = 1;
+
+ while (count--) {
+ c = *((int *) ptsIn);
+ if (((c - vertex1) | (vertex2 - c)) & 0x80008000)
+ return POLY_USE_MI;
+ c = intToY(c);
+ if (c < *topY) {
+ *topY = c;
+ *topPoint = ptsIn;
+ }
+ ptsIn++;
+ if (c > *bottomY)
+ *bottomY = c;
+ if (c == x1)
+ continue;
+ if (dx1 > 0) {
+ if (x2 < 0)
+ x2 = c;
+ else
+ dx2 = dx1 = (c - x1) >> 31;
+ }
+ else if ((c - x1) >> 31 != dx1) {
+ dx1 = ~dx1;
+ yFlip++;
+ }
+ x1 = c;
+ }
+ x1 = (x2 - c) >> 31;
+ if (x1 != dx1)
+ yFlip++;
+ if (x1 != dx2)
+ yFlip++;
+ if (yFlip != 2) {
+ if (*topY == *bottomY)
+ return POLY_FULLY_CLIPPED;
+ else
+ return POLY_USE_MI;
+ }
+ }
+ if (*topY == *bottomY)
+ return POLY_FULLY_CLIPPED;
+
+ return POLY_IS_EASY;
+}
+
+void
+XAAFillPolygonSolid(DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape, int mode, int count, DDXPointPtr ptsIn)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int origin, vertex1, vertex2;
+ int *vertex1p, *vertex2p, *endp;
+ int x1 = 0, x2 = 0;
+ int dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0;
+ int DX1 = 0, DX2 = 0, e1 = 0, e2 = 0;
+ int step1 = 0, step2 = 0, sign1 = 0, sign2 = 0;
+ int c, y, maxy, h, yoffset;
+ DDXPointPtr topPoint;
+
+ if (!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ if (mode == CoordModePrevious) {
+ register DDXPointPtr ppt = ptsIn + 1;
+
+ for (origin = 1; origin < count; origin++, ppt++) {
+ ppt->x += (ppt - 1)->x;
+ ppt->y += (ppt - 1)->y;
+ }
+ mode = CoordModeOrigin;
+ }
+
+ if (RegionNumRects(pGC->pCompositeClip) != 1) {
+ miFillPolygon(pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+ origin = coordToInt(pDraw->x, pDraw->y);
+
+ switch (XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents,
+ origin, &topPoint, &y, &maxy, shape)) {
+ case POLY_USE_MI:
+ miFillPolygon(pDraw, pGC, shape, mode, count, ptsIn);
+ case POLY_FULLY_CLIPPED:
+ return;
+ }
+
+ endp = (int *) ptsIn + count;
+ vertex2p = vertex1p = (int *) topPoint;
+ origin = pDraw->x;
+ yoffset = pDraw->y;
+ vertex2 = vertex1 = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *) ptsIn;
+
+ (*infoRec->SetupForSolidFill) (infoRec->pScrn, pGC->fgPixel, pGC->alu,
+ pGC->planemask);
+
+ while (1) {
+ if (y == intToY(vertex1)) {
+ do {
+ if (vertex1p == (int *) ptsIn)
+ vertex1p = endp;
+ c = *--vertex1p;
+ Setup(c, x1, vertex1, dx1, dy1, e1, sign1, step1, DX1)
+ } while (y >= intToY(vertex1));
+ h = dy1;
+ }
+ else {
+ Step(x1, dx1, dy1, e1, sign1, step1)
+ h = intToY(vertex1) - y;
+ }
+ if (y == intToY(vertex2)) {
+ do {
+ c = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *) ptsIn;
+ Setup(c, x2, vertex2, dx2, dy2, e2, sign2, step2, DX2)
+ } while (y >= intToY(vertex2));
+ if (dy2 < h)
+ h = dy2;
+ }
+ else {
+ Step(x2, dx2, dy2, e2, sign2, step2)
+ if ((c = (intToY(vertex2) - y)) < h)
+ h = c;
+ }
+
+ /* fill spans for this segment */
+ if (DX1 | DX2) {
+ if (infoRec->SubsequentSolidFillTrap && (h > 6)) {
+ if (x1 == x2) {
+ while (x1 == x2) {
+ y++;
+ if (!--h)
+ break;
+ Step(x1, dx1, dy1, e1, sign1, step1)
+ Step(x2, dx2, dy2, e2, sign2, step2)
+ }
+ if (y == maxy)
+ break;
+ if (!h)
+ continue;
+ }
+
+ if (x1 < x2)
+ (*infoRec->SubsequentSolidFillTrap) (infoRec->pScrn,
+ y + yoffset, h,
+ x1, DX1, dy1, e1,
+ x2 - 1, DX2, dy2, e2);
+ else
+ (*infoRec->SubsequentSolidFillTrap) (infoRec->pScrn,
+ y + yoffset, h,
+ x2, DX2, dy2, e2,
+ x1 - 1, DX1, dy1, e1);
+ y += h;
+ if (--h) {
+ FixError(x1, dx1, dy1, e1, sign1, step1, h);
+ FixError(x2, dx2, dy2, e2, sign2, step2, h);
+ h = 0;
+ }
+ }
+ else {
+ while (1) {
+ if (x2 > x1)
+ (*infoRec->SubsequentSolidFillRect) (infoRec->pScrn,
+ x1, y + yoffset,
+ x2 - x1, 1);
+ else if (x1 > x2)
+ (*infoRec->SubsequentSolidFillRect) (infoRec->pScrn,
+ x2, y + yoffset,
+ x1 - x2, 1);
+ y++;
+ if (!--h)
+ break;
+ Step(x1, dx1, dy1, e1, sign1, step1)
+ Step(x2, dx2, dy2, e2, sign2, step2)
+ }
+ }
+ }
+ else {
+ if (x2 > x1)
+ (*infoRec->SubsequentSolidFillRect) (infoRec->pScrn,
+ x1, y + yoffset, x2 - x1,
+ h);
+ else if (x1 > x2)
+ (*infoRec->SubsequentSolidFillRect) (infoRec->pScrn,
+ x2, y + yoffset, x1 - x2,
+ h);
+
+ y += h;
+ h = 0;
+ }
+ if (y == maxy)
+ break;
+ }
+ SET_SYNC_FLAG(infoRec);
+}
+
+void
+XAAFillPolygonHelper(ScrnInfoPtr pScrn,
+ DDXPointPtr ptsIn,
+ int count,
+ DDXPointPtr topPoint,
+ int y,
+ int maxy,
+ int origin,
+ RectFuncPtr RectFunc,
+ TrapFuncPtr TrapFunc,
+ int xorg, int yorg, XAACacheInfoPtr pCache)
+{
+ int *vertex1p, *vertex2p, *endp;
+ int vertex1, vertex2;
+ int x1 = 0, x2 = 0;
+ int dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0;
+ int DX1 = 0, DX2 = 0, e1 = 0, e2 = 0;
+ int step1 = 0, step2 = 0, sign1 = 0, sign2 = 0;
+ int c, h, yoffset;
+
+ endp = (int *) ptsIn + count;
+ vertex2p = vertex1p = (int *) topPoint;
+ yoffset = intToY(origin);
+ origin = intToX(origin);
+ vertex2 = vertex1 = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *) ptsIn;
+
+ while (1) {
+ if (y == intToY(vertex1)) {
+ do {
+ if (vertex1p == (int *) ptsIn)
+ vertex1p = endp;
+ c = *--vertex1p;
+ Setup(c, x1, vertex1, dx1, dy1, e1, sign1, step1, DX1)
+ } while (y >= intToY(vertex1));
+ h = dy1;
+ }
+ else {
+ Step(x1, dx1, dy1, e1, sign1, step1)
+ h = intToY(vertex1) - y;
+ }
+ if (y == intToY(vertex2)) {
+ do {
+ c = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *) ptsIn;
+ Setup(c, x2, vertex2, dx2, dy2, e2, sign2, step2, DX2)
+ } while (y >= intToY(vertex2));
+ if (dy2 < h)
+ h = dy2;
+ }
+ else {
+ Step(x2, dx2, dy2, e2, sign2, step2)
+ if ((c = (intToY(vertex2) - y)) < h)
+ h = c;
+ }
+
+ /* fill spans for this segment */
+ if (DX1 | DX2) {
+ if (TrapFunc && (h > 6)) {
+ if (x1 == x2) {
+ while (x1 == x2) {
+ y++;
+ if (!--h)
+ break;
+ Step(x1, dx1, dy1, e1, sign1, step1)
+ Step(x2, dx2, dy2, e2, sign2, step2)
+ }
+ if (y == maxy)
+ break;
+ if (!h)
+ continue;
+ }
+
+ if (x1 < x2)
+ (*TrapFunc) (pScrn, y + yoffset, h,
+ x1, DX1, dy1, e1,
+ x2 - 1, DX2, dy2, e2, xorg, yorg, pCache);
+ else
+ (*TrapFunc) (pScrn, y + yoffset, h,
+ x2, DX2, dy2, e2,
+ x1 - 1, DX1, dy1, e1, xorg, yorg, pCache);
+ y += h;
+ if (--h) {
+ FixError(x1, dx1, dy1, e1, sign1, step1, h);
+ FixError(x2, dx2, dy2, e2, sign2, step2, h);
+ h = 0;
+ }
+ }
+ else {
+ while (1) {
+ if (x2 > x1)
+ (*RectFunc) (pScrn,
+ x1, y + yoffset, x2 - x1, 1, xorg, yorg,
+ pCache);
+ else if (x1 > x2)
+ (*RectFunc) (pScrn,
+ x2, y + yoffset, x1 - x2, 1, xorg, yorg,
+ pCache);
+ y++;
+ if (!--h)
+ break;
+ Step(x1, dx1, dy1, e1, sign1, step1)
+ Step(x2, dx2, dy2, e2, sign2, step2)
+ }
+ }
+ }
+ else {
+ if (x2 > x1)
+ (*RectFunc) (pScrn,
+ x1, y + yoffset, x2 - x1, h, xorg, yorg, pCache);
+ else if (x1 > x2)
+ (*RectFunc) (pScrn,
+ x2, y + yoffset, x1 - x2, h, xorg, yorg, pCache);
+
+ y += h;
+ h = 0;
+ }
+ if (y == maxy)
+ break;
+ }
+}
+
+ /*****************\
+ | Solid Helpers |
+ \*****************/
+
+static void
+SolidTrapHelper(ScrnInfoPtr pScrn,
+ int y, int h,
+ int x1, int dx1, int dy1, int e1,
+ int x2, int dx2, int dy2, int e2,
+ int xorg, int yorg, XAACacheInfoPtr pCache)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->SubsequentSolidFillTrap) (pScrn,
+ y, h, x1, dx1, dy1, e1, x2, dx2, dy2,
+ e2);
+}
+
+static void
+SolidRectHelper(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ int xorg, int yorg, XAACacheInfoPtr pCache)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h);
+}
+
+ /*********************\
+ | Mono 8x8 Patterns |
+ \*********************/
+
+static void
+Mono8x8PatternTrapHelper_ScreenOrigin(ScrnInfoPtr pScrn,
+ int y, int h,
+ int x1, int dx1, int dy1, int e1,
+ int x2, int dx2, int dy2, int e2,
+ int xorg, int yorg,
+ XAACacheInfoPtr pCache)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->SubsequentMono8x8PatternFillTrap) (pScrn, xorg, yorg,
+ y, h, x1, dx1, dy1, e1, x2,
+ dx2, dy2, e2);
+}
+
+static void
+Mono8x8PatternRectHelper_ScreenOrigin(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ int xorg, int yorg,
+ XAACacheInfoPtr pCache)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn, xorg, yorg,
+ x, y, w, h);
+}
+
+static void
+Mono8x8PatternRectHelper(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ int xorg, int yorg, XAACacheInfoPtr pCache)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ xorg = (x - xorg) & 0x07;
+ yorg = (y - yorg) & 0x07;
+
+ if (!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+ if (infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ int patx = pCache->pat0;
+ int paty = pCache->pat1;
+
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx;
+ yorg = paty;
+ }
+ else {
+ int slot = (yorg << 3) + xorg;
+
+ xorg = pCache->x + pCache->offsets[slot].x;
+ yorg = pCache->y + pCache->offsets[slot].y;
+ }
+ }
+
+ (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn, xorg, yorg,
+ x, y, w, h);
+}
+
+ /****************\
+ | Cache Expand |
+ \****************/
+
+static void
+CacheExpandRectHelper(ScrnInfoPtr pScrn,
+ int X, int Y, int Width, int Height,
+ int xorg, int yorg, XAACacheInfoPtr pCache)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, phaseY, phaseX, skipleft, w, blit_w, blit_h;
+ int cacheWidth;
+
+ cacheWidth = (pCache->w * pScrn->bitsPerPixel) /
+ infoRec->CacheColorExpandDensity;
+
+ phaseY = (Y - yorg) % pCache->orig_h;
+ if (phaseY < 0)
+ phaseY += pCache->orig_h;
+ phaseX = (X - xorg) % pCache->orig_w;
+ if (phaseX < 0)
+ phaseX += pCache->orig_w;
+
+ while (1) {
+ w = Width;
+ skipleft = phaseX;
+ x = X;
+ blit_h = pCache->h - phaseY;
+ if (blit_h > Height)
+ blit_h = Height;
+
+ while (1) {
+ blit_w = cacheWidth - skipleft;
+ if (blit_w > w)
+ blit_w = w;
+ (*infoRec->SubsequentScreenToScreenColorExpandFill) (pScrn, x, Y,
+ blit_w, blit_h,
+ pCache->x,
+ pCache->y +
+ phaseY,
+ skipleft);
+ w -= blit_w;
+ if (!w)
+ break;
+ x += blit_w;
+ skipleft = (skipleft + blit_w) % pCache->orig_w;
+ }
+ Height -= blit_h;
+ if (!Height)
+ break;
+ Y += blit_h;
+ phaseY = (phaseY + blit_h) % pCache->orig_h;
+ }
+}
+
+ /**************\
+ | Cache Blit |
+ \**************/
+
+static void
+CacheBltRectHelper(ScrnInfoPtr pScrn,
+ int X, int Y, int Width, int Height,
+ int xorg, int yorg, XAACacheInfoPtr pCache)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, phaseY, phaseX, skipleft, w, blit_w, blit_h;
+
+ phaseY = (Y - yorg) % pCache->orig_h;
+ if (phaseY < 0)
+ phaseY += pCache->orig_h;
+ phaseX = (X - xorg) % pCache->orig_w;
+ if (phaseX < 0)
+ phaseX += pCache->orig_w;
+
+ while (1) {
+ w = Width;
+ skipleft = phaseX;
+ x = X;
+ blit_h = pCache->h - phaseY;
+ if (blit_h > Height)
+ blit_h = Height;
+
+ while (1) {
+ blit_w = pCache->w - skipleft;
+ if (blit_w > w)
+ blit_w = w;
+ (*infoRec->SubsequentScreenToScreenCopy) (pScrn,
+ pCache->x + skipleft,
+ pCache->y + phaseY, x, Y,
+ blit_w, blit_h);
+ w -= blit_w;
+ if (!w)
+ break;
+ x += blit_w;
+ skipleft = (skipleft + blit_w) % pCache->orig_w;
+ }
+ Height -= blit_h;
+ if (!Height)
+ break;
+ Y += blit_h;
+ phaseY = (phaseY + blit_h) % pCache->orig_h;
+ }
+}
+
+ /**********************\
+ | Stippled Polygons |
+ \**********************/
+
+void
+XAAFillPolygonStippled(DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape, int mode, int count, DDXPointPtr ptsIn)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
+ int origin, type, patx, paty, fg, bg;
+ int y, maxy, xorg, yorg;
+ DDXPointPtr topPoint;
+ XAACacheInfoPtr pCache = NULL;
+ RectFuncPtr RectFunc = NULL;
+ TrapFuncPtr TrapFunc = NULL;
+
+ if (!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ if (mode == CoordModePrevious) {
+ register DDXPointPtr ppt = ptsIn + 1;
+
+ for (origin = 1; origin < count; origin++, ppt++) {
+ ppt->x += (ppt - 1)->x;
+ ppt->y += (ppt - 1)->y;
+ }
+ mode = CoordModeOrigin;
+ }
+
+ if (RegionNumRects(pGC->pCompositeClip) != 1) {
+ miFillPolygon(pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+ if (pGC->fillStyle == FillStippled) {
+ type = (*infoRec->StippledFillChooser) (pGC);
+ fg = pGC->fgPixel;
+ bg = -1;
+ }
+ else {
+ type = (*infoRec->OpaqueStippledFillChooser) (pGC);
+ fg = pGC->fgPixel;
+ bg = pGC->bgPixel;
+ }
+
+ if (!type) {
+ (*XAAFallbackOps.FillPolygon) (pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+ if ((type == DO_COLOR_EXPAND) || (type == DO_COLOR_8x8)) {
+ miFillPolygon(pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+ origin = pDraw->x;
+
+ switch (XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents,
+ origin, &topPoint, &y, &maxy, shape)) {
+ case POLY_USE_MI:
+ miFillPolygon(pDraw, pGC, shape, mode, count, ptsIn);
+ case POLY_FULLY_CLIPPED:
+ return;
+ }
+
+ xorg = (pDraw->x + pGC->patOrg.x);
+ yorg = (pDraw->y + pGC->patOrg.y);
+
+ if ((fg == bg) && (bg != -1) && infoRec->SetupForSolidFill) {
+
+ (*infoRec->SetupForSolidFill) (infoRec->pScrn, fg,
+ pGC->alu, pGC->planemask);
+
+ RectFunc = SolidRectHelper;
+ TrapFunc = infoRec->SubsequentSolidFillTrap ? SolidTrapHelper : NULL;
+ }
+ else
+ switch (type) {
+ case DO_MONO_8x8:
+ patx = pPriv->pattern0;
+ paty = pPriv->pattern1;
+ if (infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_SCREEN_ORIGIN) {
+ xorg = (-xorg) & 0x07;
+ yorg = (-yorg) & 0x07;
+ if (infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ if (!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx;
+ yorg = paty;
+ }
+ }
+ else {
+ XAACacheInfoPtr pCache =
+ (*infoRec->CacheMono8x8Pattern) (infoRec->pScrn, patx,
+ paty);
+ patx = pCache->x;
+ paty = pCache->y;
+ if (!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+ int slot = (yorg << 3) + xorg;
+
+ patx += pCache->offsets[slot].x;
+ paty += pCache->offsets[slot].y;
+ xorg = patx;
+ yorg = paty;
+ }
+ }
+ RectFunc = Mono8x8PatternRectHelper_ScreenOrigin;
+ if (infoRec->SubsequentMono8x8PatternFillTrap)
+ TrapFunc = Mono8x8PatternTrapHelper_ScreenOrigin;
+ }
+ else { /* !HARDWARE_PATTERN_SCREEN_ORIGIN */
+ if (!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_BITS)) {
+ pCache =
+ (*infoRec->CacheMono8x8Pattern) (infoRec->pScrn, patx,
+ paty);
+ patx = pCache->x;
+ paty = pCache->y;
+ }
+ else {
+ pCache = &(infoRec->ScratchCacheInfoRec);
+ pCache->pat0 = patx;
+ pCache->pat1 = paty;
+ }
+ RectFunc = Mono8x8PatternRectHelper;
+ }
+
+ (*infoRec->SetupForMono8x8PatternFill) (infoRec->pScrn,
+ patx, paty, fg, bg,
+ pGC->alu, pGC->planemask);
+ break;
+ case DO_CACHE_EXPAND:
+ pCache =
+ (*infoRec->CacheMonoStipple) (infoRec->pScrn, pGC->stipple);
+
+ (*infoRec->SetupForScreenToScreenColorExpandFill) (infoRec->pScrn,
+ fg, bg, pGC->alu,
+ pGC->planemask);
+
+ RectFunc = CacheExpandRectHelper;
+ break;
+ case DO_CACHE_BLT:
+ pCache = (*infoRec->CacheStipple) (infoRec->pScrn, pGC->stipple,
+ fg, bg);
+ (*infoRec->SetupForScreenToScreenCopy) (infoRec->pScrn, 1, 1,
+ pGC->alu, pGC->planemask,
+ pCache->trans_color);
+
+ RectFunc = CacheBltRectHelper;
+ break;
+ default:
+ return;
+ }
+
+ XAAFillPolygonHelper(infoRec->pScrn, ptsIn, count, topPoint,
+ y, maxy, origin, RectFunc, TrapFunc, xorg, yorg,
+ pCache);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+ /*******************\
+ | Tiled Polygons |
+ \*******************/
+
+void
+XAAFillPolygonTiled(DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape, int mode, int count, DDXPointPtr ptsIn)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
+ int origin, type, patx, paty;
+ int y, maxy, xorg, yorg;
+ DDXPointPtr topPoint;
+ XAACacheInfoPtr pCache = NULL;
+ RectFuncPtr RectFunc = NULL;
+ TrapFuncPtr TrapFunc = NULL;
+
+ if (!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ if (mode == CoordModePrevious) {
+ register DDXPointPtr ppt = ptsIn + 1;
+
+ for (origin = 1; origin < count; origin++, ppt++) {
+ ppt->x += (ppt - 1)->x;
+ ppt->y += (ppt - 1)->y;
+ }
+ mode = CoordModeOrigin;
+ }
+
+ if (RegionNumRects(pGC->pCompositeClip) != 1) {
+ miFillPolygon(pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+ type = (*infoRec->TiledFillChooser) (pGC);
+
+ if (!type || (type == DO_IMAGE_WRITE)) {
+ (*XAAFallbackOps.FillPolygon) (pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+ if (type == DO_COLOR_8x8) {
+ miFillPolygon(pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+ origin = pDraw->x;
+
+ switch (XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents,
+ origin, &topPoint, &y, &maxy, shape)) {
+ case POLY_USE_MI:
+ miFillPolygon(pDraw, pGC, shape, mode, count, ptsIn);
+ case POLY_FULLY_CLIPPED:
+ return;
+ }
+
+ xorg = (pDraw->x + pGC->patOrg.x);
+ yorg = (pDraw->y + pGC->patOrg.y);
+
+ switch (type) {
+ case DO_MONO_8x8:
+ patx = pPriv->pattern0;
+ paty = pPriv->pattern1;
+ if (infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) {
+ xorg = (-xorg) & 0x07;
+ yorg = (-yorg) & 0x07;
+ if (infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ if (!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx;
+ yorg = paty;
+ }
+ }
+ else {
+ XAACacheInfoPtr pCache =
+ (*infoRec->CacheMono8x8Pattern) (infoRec->pScrn, patx,
+ paty);
+ patx = pCache->x;
+ paty = pCache->y;
+ if (!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+ int slot = (yorg << 3) + xorg;
+
+ patx += pCache->offsets[slot].x;
+ paty += pCache->offsets[slot].y;
+ xorg = patx;
+ yorg = paty;
+ }
+ }
+ RectFunc = Mono8x8PatternRectHelper_ScreenOrigin;
+ if (infoRec->SubsequentMono8x8PatternFillTrap)
+ TrapFunc = Mono8x8PatternTrapHelper_ScreenOrigin;
+ }
+ else { /* !HARDWARE_PATTERN_SCREEN_ORIGIN */
+ if (!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_BITS)) {
+ pCache =
+ (*infoRec->CacheMono8x8Pattern) (infoRec->pScrn, patx,
+ paty);
+ patx = pCache->x;
+ paty = pCache->y;
+ }
+ else {
+ pCache = &(infoRec->ScratchCacheInfoRec);
+ pCache->pat0 = patx;
+ pCache->pat1 = paty;
+ }
+ RectFunc = Mono8x8PatternRectHelper;
+ }
+
+ (*infoRec->SetupForMono8x8PatternFill) (infoRec->pScrn,
+ patx, paty, pPriv->fg,
+ pPriv->bg, pGC->alu,
+ pGC->planemask);
+ break;
+ case DO_CACHE_BLT:
+ pCache = (*infoRec->CacheTile) (infoRec->pScrn, pGC->tile.pixmap);
+ (*infoRec->SetupForScreenToScreenCopy) (infoRec->pScrn, 1, 1,
+ pGC->alu, pGC->planemask, -1);
+
+ RectFunc = CacheBltRectHelper;
+ break;
+ case DO_PIXMAP_COPY:
+ pCache = &(infoRec->ScratchCacheInfoRec);
+ pCache->x = pPriv->offscreenArea->box.x1;
+ pCache->y = pPriv->offscreenArea->box.y1;
+ pCache->w = pCache->orig_w = pPriv->offscreenArea->box.x2 - pCache->x;
+ pCache->h = pCache->orig_h = pPriv->offscreenArea->box.y2 - pCache->y;
+
+ (*infoRec->SetupForScreenToScreenCopy) (infoRec->pScrn, 1, 1,
+ pGC->alu, pGC->planemask, -1);
+
+ RectFunc = CacheBltRectHelper;
+ break;
+ default:
+ return;
+ }
+
+ XAAFillPolygonHelper(infoRec->pScrn, ptsIn, count, topPoint,
+ y, maxy, origin, RectFunc, TrapFunc, xorg, yorg,
+ pCache);
+
+ SET_SYNC_FLAG(infoRec);
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaFillRect.c b/xorg-server/hw/xfree86/xaa/xaaFillRect.c
index 724ff37a2..ec0fb9df7 100644
--- a/xorg-server/hw/xfree86/xaa/xaaFillRect.c
+++ b/xorg-server/hw/xfree86/xaa/xaaFillRect.c
@@ -1,1095 +1,1101 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-
-
-static void XAARenderSolidRects(GCPtr, int, BoxPtr, int, int);
-static void XAARenderColor8x8Rects(GCPtr, int, BoxPtr, int, int);
-static void XAARenderMono8x8Rects(GCPtr, int, BoxPtr, int, int);
-static void XAARenderColorExpandRects(GCPtr, int, BoxPtr, int, int);
-static void XAARenderCacheExpandRects(GCPtr, int, BoxPtr, int, int);
-static void XAARenderCacheBltRects(GCPtr, int, BoxPtr, int, int);
-static void XAARenderImageWriteRects(GCPtr, int, BoxPtr, int, int);
-static void XAARenderPixmapCopyRects(GCPtr, int, BoxPtr, int, int);
-
-void
-XAAPolyFillRect(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nrectFill, /* number of rectangles to fill */
- xRectangle *prectInit /* Pointer to first rectangle to fill */
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int xorg = pDraw->x;
- int yorg = pDraw->y;
- int type = 0;
- ClipAndRenderRectsFunc function;
-
- if((nrectFill <= 0) || !pGC->planemask)
- return;
-
- if(!RegionNumRects(pGC->pCompositeClip))
- return;
-
- switch(pGC->fillStyle) {
- case FillSolid:
- type = DO_SOLID;
- break;
- case FillStippled:
- type = (*infoRec->StippledFillChooser)(pGC);
- break;
- case FillOpaqueStippled:
- if((pGC->fgPixel == pGC->bgPixel) && infoRec->FillSolidRects &&
- CHECK_PLANEMASK(pGC,infoRec->FillSolidRectsFlags) &&
- CHECK_ROP(pGC,infoRec->FillSolidRectsFlags) &&
- CHECK_ROPSRC(pGC,infoRec->FillSolidRectsFlags) &&
- CHECK_FG(pGC,infoRec->FillSolidRectsFlags))
- type = DO_SOLID;
- else
- type = (*infoRec->OpaqueStippledFillChooser)(pGC);
- break;
- case FillTiled:
- type = (*infoRec->TiledFillChooser)(pGC);
- break;
- }
-
- switch(type) {
- case DO_SOLID:
- function = XAARenderSolidRects;
- break;
- case DO_COLOR_8x8:
- function = XAARenderColor8x8Rects;
- break;
- case DO_MONO_8x8:
- function = XAARenderMono8x8Rects;
- break;
- case DO_CACHE_BLT:
- function = XAARenderCacheBltRects;
- break;
- case DO_COLOR_EXPAND:
- function = XAARenderColorExpandRects;
- break;
- case DO_CACHE_EXPAND:
- function = XAARenderCacheExpandRects;
- break;
- case DO_IMAGE_WRITE:
- function = XAARenderImageWriteRects;
- break;
- case DO_PIXMAP_COPY:
- function = XAARenderPixmapCopyRects;
- break;
- default:
- (*XAAFallbackOps.PolyFillRect)(pDraw, pGC, nrectFill, prectInit);
- return;
- }
-
- if(xorg | yorg) {
- int n = nrectFill;
- xRectangle *prect = prectInit;
-
- while(n--) {
- prect->x += xorg;
- prect->y += yorg;
- prect++;
- }
- }
-
-
- XAAClipAndRenderRects(pGC, function, nrectFill, prectInit, xorg, yorg);
-}
-
-
-
- /*********************\
- | Solid Rects |
- \*********************/
-
-static void
-XAARenderSolidRects(
- GCPtr pGC,
- int nboxes,
- BoxPtr pClipBoxes,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-
- (*infoRec->FillSolidRects) (infoRec->pScrn,
- pGC->fgPixel, pGC->alu, pGC->planemask, nboxes, pClipBoxes);
-}
-
-
- /************************\
- | Mono 8x8 Rects |
- \************************/
-
-static void
-XAARenderMono8x8Rects(
- GCPtr pGC,
- int nboxes,
- BoxPtr pClipBoxes,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAAPixmapPtr pPriv;
- int fg, bg;
-
- switch(pGC->fillStyle) {
- case FillStippled:
- pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
- fg = pGC->fgPixel; bg = -1;
- break;
- case FillOpaqueStippled:
- pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
- fg = pGC->fgPixel; bg = pGC->bgPixel;
- break;
- case FillTiled:
- pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
- fg = pPriv->fg; bg = pPriv->bg;
- break;
- default: /* Muffle compiler */
- pPriv = NULL; /* Kaboom */
- fg = -1; bg = -1;
- break;
- }
-
- (*infoRec->FillMono8x8PatternRects) (infoRec->pScrn,
- fg, bg, pGC->alu, pGC->planemask,
- nboxes, pClipBoxes, pPriv->pattern0, pPriv->pattern1,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y));
-}
-
- /*************************\
- | Color 8x8 Rects |
- \*************************/
-
-static void
-XAARenderColor8x8Rects(
- GCPtr pGC,
- int nboxes,
- BoxPtr pClipBoxes,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAACacheInfoPtr pCache;
- PixmapPtr pPix;
- int fg, bg;
-
- switch(pGC->fillStyle) {
- case FillStippled:
- pPix = pGC->stipple;
- fg = pGC->fgPixel; bg = -1;
- break;
- case FillOpaqueStippled:
- pPix = pGC->stipple;
- fg = pGC->fgPixel; bg = pGC->bgPixel;
- break;
- case FillTiled:
- pPix = pGC->tile.pixmap;
- fg = -1; bg = -1;
- break;
- default: /* Muffle compiler */
- pPix = NULL;
- fg = -1; bg = -1;
- break;
- }
-
- pCache = (*infoRec->CacheColor8x8Pattern)(infoRec->pScrn, pPix, fg, bg);
- (*infoRec->FillColor8x8PatternRects) (infoRec->pScrn,
- pGC->alu, pGC->planemask, nboxes, pClipBoxes,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), pCache);
-}
-
-
- /****************************\
- | Color Expand Rects |
- \****************************/
-
-static void
-XAARenderColorExpandRects(
- GCPtr pGC,
- int nboxes,
- BoxPtr pClipBoxes,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int fg, bg;
-
- switch(pGC->fillStyle) {
- case FillStippled:
- fg = pGC->fgPixel; bg = -1;
- break;
- case FillOpaqueStippled:
- fg = pGC->fgPixel; bg = pGC->bgPixel;
- break;
- default: /* Muffle compiler */
- fg = -1; bg = -1;
- break;
- }
-
- (*infoRec->FillColorExpandRects) (infoRec->pScrn, fg, bg,
- pGC->alu, pGC->planemask, nboxes, pClipBoxes,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
- pGC->stipple);
-}
-
-
- /*************************\
- | Cache Blt Rects |
- \*************************/
-
-static void
-XAARenderCacheBltRects(
- GCPtr pGC,
- int nboxes,
- BoxPtr pClipBoxes,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAACacheInfoPtr pCache;
-
- switch(pGC->fillStyle) {
- case FillStippled:
- pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple,
- pGC->fgPixel, -1);
- break;
- case FillOpaqueStippled:
- pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple,
- pGC->fgPixel, pGC->bgPixel);
- break;
- case FillTiled:
- pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap);
- break;
- default: /* Muffle compiler */
- pCache = NULL;
- break;
- }
-
- (*infoRec->FillCacheBltRects) (infoRec->pScrn, pGC->alu,
- pGC->planemask, nboxes, pClipBoxes,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), pCache);
-}
-
-
- /****************************\
- | Cache Expand Rects |
- \****************************/
-
-static void
-XAARenderCacheExpandRects(
- GCPtr pGC,
- int nboxes,
- BoxPtr pClipBoxes,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int fg, bg;
-
- switch(pGC->fillStyle) {
- case FillStippled:
- fg = pGC->fgPixel; bg = -1;
- break;
- case FillOpaqueStippled:
- fg = pGC->fgPixel; bg = pGC->bgPixel;
- break;
- default: /* Muffle compiler */
- fg = -1; bg = -1;
- break;
- }
-
- (*infoRec->FillCacheExpandRects) (infoRec->pScrn, fg, bg,
- pGC->alu, pGC->planemask, nboxes, pClipBoxes,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
- pGC->stipple);
-}
-
-
-
- /***************************\
- | Image Write Rects |
- \***************************/
-
-static void
-XAARenderImageWriteRects(
- GCPtr pGC,
- int nboxes,
- BoxPtr pClipBoxes,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-
- (*infoRec->FillImageWriteRects) (infoRec->pScrn, pGC->alu,
- pGC->planemask, nboxes, pClipBoxes,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
- pGC->tile.pixmap);
-}
-
-
-
- /***************************\
- | Pixmap Copy Rects |
- \***************************/
-
-static void
-XAARenderPixmapCopyRects(
- GCPtr pGC,
- int nboxes,
- BoxPtr pClipBoxes,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec);
- XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
-
- pCache->x = pPriv->offscreenArea->box.x1;
- pCache->y = pPriv->offscreenArea->box.y1;
- pCache->w = pCache->orig_w =
- pPriv->offscreenArea->box.x2 - pCache->x;
- pCache->h = pCache->orig_h =
- pPriv->offscreenArea->box.y2 - pCache->y;
- pCache->trans_color = -1;
-
- (*infoRec->FillCacheBltRects) (infoRec->pScrn, pGC->alu,
- pGC->planemask, nboxes, pClipBoxes,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
- pCache);
-}
-
-
-
- /************\
- | Solid |
- \************/
-
-void
-XAAFillSolidRects(
- ScrnInfoPtr pScrn,
- int fg, int rop,
- unsigned int planemask,
- int nBox, /* number of rectangles to fill */
- BoxPtr pBox /* Pointer to first rectangle to fill */
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
-
- (*infoRec->SetupForSolidFill)(pScrn, fg, rop, planemask);
- while(nBox--) {
- (*infoRec->SubsequentSolidFillRect)(pScrn, pBox->x1, pBox->y1,
- pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
- pBox++;
- }
- SET_SYNC_FLAG(infoRec);
-}
-
-
-
-
- /*********************\
- | 8x8 Mono Patterns |
- \*********************/
-
-
-void
-XAAFillMono8x8PatternRectsScreenOrigin(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int pattern0, int pattern1,
- int xorigin, int yorigin
-)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int patx = pattern0, paty = pattern1;
- int xorg = (-xorigin) & 0x07;
- int yorg = (-yorigin) & 0x07;
-
-
- if(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS) {
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- XAARotateMonoPattern(&patx, &paty, xorg, yorg,
- (infoRec->Mono8x8PatternFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST));
- xorg = patx; yorg = paty;
- }
- } else {
- XAACacheInfoPtr pCache =
- (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1);
- patx = pCache->x; paty = pCache->y;
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- int slot = (yorg << 3) + xorg;
- patx += pCache->offsets[slot].x;
- paty += pCache->offsets[slot].y;
- xorg = patx; yorg = paty;
- }
- }
-
- (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty,
- fg, bg, rop, planemask);
-
- while(nBox--) {
- (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn,
- xorg, yorg, pBox->x1, pBox->y1,
- pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
- pBox++;
- }
- SET_SYNC_FLAG(infoRec);
-}
-
-void
-XAAFillMono8x8PatternRects(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int pattern0, int pattern1,
- int xorigin, int yorigin
-)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int patx = pattern0, paty = pattern1;
- int xorg, yorg;
- XAACacheInfoPtr pCache = NULL;
-
-
- if(!(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS)){
- pCache = (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1);
- patx = pCache->x; paty = pCache->y;
- }
-
-
- (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty,
- fg, bg, rop, planemask);
-
-
- while(nBox--) {
- xorg = (pBox->x1 - xorigin) & 0x07;
- yorg = (pBox->y1 - yorigin) & 0x07;
-
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- if(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_BITS) {
- patx = pattern0; paty = pattern1;
- XAARotateMonoPattern(&patx, &paty, xorg, yorg,
- (infoRec->Mono8x8PatternFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST));
- xorg = patx; yorg = paty;
- } else {
- int slot = (yorg << 3) + xorg;
- xorg = patx + pCache->offsets[slot].x;
- yorg = paty + pCache->offsets[slot].y;
- }
- }
-
- (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn,
- xorg, yorg, pBox->x1, pBox->y1,
- pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
- pBox++;
- }
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
- /**********************\
- | 8x8 Color Patterns |
- \**********************/
-
-
-void
-XAAFillColor8x8PatternRectsScreenOrigin(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorigin, int yorigin,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int patx = pCache->x, paty = pCache->y;
- int xorg = (-xorigin) & 0x07;
- int yorg = (-yorigin) & 0x07;
-
- if(!(infoRec->Color8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- int slot = (yorg << 3) + xorg;
- paty += pCache->offsets[slot].y;
- patx += pCache->offsets[slot].x;
- xorg = patx; yorg = paty;
- }
-
- (*infoRec->SetupForColor8x8PatternFill)(pScrn, patx, paty,
- rop, planemask, pCache->trans_color);
-
- while(nBox--) {
- (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn,
- xorg, yorg, pBox->x1, pBox->y1,
- pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
- pBox++;
- }
- SET_SYNC_FLAG(infoRec);
-}
-
-void
-XAAFillColor8x8PatternRects(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorigin, int yorigin,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int xorg, yorg;
-
- (*infoRec->SetupForColor8x8PatternFill)(pScrn, pCache->x, pCache->y,
- rop, planemask, pCache->trans_color);
-
- while(nBox--) {
- xorg = (pBox->x1 - xorigin) & 0x07;
- yorg = (pBox->y1 - yorigin) & 0x07;
-
- if(!(infoRec->Color8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- int slot = (yorg << 3) + xorg;
- yorg = pCache->y + pCache->offsets[slot].y;
- xorg = pCache->x + pCache->offsets[slot].x;
- }
-
- (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn,
- xorg, yorg, pBox->x1, pBox->y1,
- pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
- pBox++;
- }
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
- /***************\
- | Cache Blits |
- \***************/
-
-void
-XAAFillCacheBltRects(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int x, y, phaseY, phaseX, skipleft, height, width, w, blit_w, blit_h;
-
- (*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, rop, planemask,
- pCache->trans_color);
-
- while(nBox--) {
- y = pBox->y1;
- phaseY = (y - yorg) % pCache->orig_h;
- if(phaseY < 0) phaseY += pCache->orig_h;
- phaseX = (pBox->x1 - xorg) % pCache->orig_w;
- if(phaseX < 0) phaseX += pCache->orig_w;
- height = pBox->y2 - y;
- width = pBox->x2 - pBox->x1;
-
-#if 0
- if (rop == GXcopy) {
- while(1) {
- w = width; skipleft = phaseX; x = pBox->x1;
- blit_h = pCache->h - phaseY;
- if(blit_h > height) blit_h = height;
-
- while(1) {
- blit_w = pCache->w - skipleft;
- if(blit_w > w) blit_w = w;
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
- pCache->x + skipleft, pCache->y + phaseY,
- x, y, blit_w, blit_h);
- w -= blit_w;
- if(!w) break;
- x += blit_w;
- skipleft = (skipleft + blit_w) % pCache->orig_w;
- if(blit_w >= pCache->orig_w) break;
- }
-
- /* Expand horizontally */
- if (w) {
- skipleft -= phaseX;
- if (skipleft < 0) skipleft += pCache->orig_w;
- blit_w = x - pBox->x1 - skipleft;
- while(w) {
- if (blit_w > w) blit_w = w;
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
- pBox->x1 + skipleft, y, x, y, blit_w, blit_h);
- w -= blit_w;
- x += blit_w;
- blit_w <<= 1;
- }
- }
-
- height -= blit_h;
- if(!height) break;
- y += blit_h;
- phaseY = (phaseY + blit_h) % pCache->orig_h;
- if(blit_h >= pCache->orig_h) break;
- }
-
- /* Expand vertically */
- if (height) {
- blit_w = pBox->x2 - pBox->x1;
- phaseY -= (pBox->y1 - yorg) % pCache->orig_h;
- if (phaseY < 0) phaseY += pCache->orig_h;
- blit_h = y - pBox->y1 - phaseY;
- while(height) {
- if (blit_h > height) blit_h = height;
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn, pBox->x1,
- pBox->y1 + phaseY, pBox->x1, y, blit_w, blit_h);
- height -= blit_h;
- y += blit_h;
- blit_h <<= 1;
- }
- }
- } else
-#endif
- {
- while(1) {
- w = width; skipleft = phaseX; x = pBox->x1;
- blit_h = pCache->h - phaseY;
- if(blit_h > height) blit_h = height;
-
- while(1) {
- blit_w = pCache->w - skipleft;
- if(blit_w > w) blit_w = w;
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
- pCache->x + skipleft, pCache->y + phaseY,
- x, y, blit_w, blit_h);
- w -= blit_w;
- if(!w) break;
- x += blit_w;
- skipleft = (skipleft + blit_w) % pCache->orig_w;
- }
- height -= blit_h;
- if(!height) break;
- y += blit_h;
- phaseY = (phaseY + blit_h) % pCache->orig_h;
- }
- }
- pBox++;
- }
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
-
-
- /*******************\
- | Cache Expansion |
- \*******************/
-
-
-
-void
-XAAFillCacheExpandRects(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int x, y, phaseY, phaseX, skipleft, height, width, w, blit_w, blit_h;
- int cacheWidth;
- XAACacheInfoPtr pCache;
-
- pCache = (*infoRec->CacheMonoStipple)(pScrn, pPix);
-
- cacheWidth = (pCache->w * pScrn->bitsPerPixel) /
- infoRec->CacheColorExpandDensity;
-
- (*infoRec->SetupForScreenToScreenColorExpandFill)(pScrn, fg, bg, rop,
- planemask);
-
- while(nBox--) {
- y = pBox->y1;
- phaseY = (y - yorg) % pCache->orig_h;
- if(phaseY < 0) phaseY += pCache->orig_h;
- phaseX = (pBox->x1 - xorg) % pCache->orig_w;
- if(phaseX < 0) phaseX += pCache->orig_w;
- height = pBox->y2 - y;
- width = pBox->x2 - pBox->x1;
-
- while(1) {
- w = width; skipleft = phaseX; x = pBox->x1;
- blit_h = pCache->h - phaseY;
- if(blit_h > height) blit_h = height;
-
- while(1) {
- blit_w = cacheWidth - skipleft;
- if(blit_w > w) blit_w = w;
- (*infoRec->SubsequentScreenToScreenColorExpandFill)(
- pScrn, x, y, blit_w, blit_h,
- pCache->x, pCache->y + phaseY, skipleft);
- w -= blit_w;
- if(!w) break;
- x += blit_w;
- skipleft = (skipleft + blit_w) % pCache->orig_w;
- }
- height -= blit_h;
- if(!height) break;
- y += blit_h;
- phaseY = (phaseY + blit_h) % pCache->orig_h;
- }
- pBox++;
- }
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
- /******************\
- | Image Writes |
- \******************/
-
-
-
-/* This requires all LEFT_EDGE clipping. You get too many problems
- with reading past the edge of the pattern otherwise */
-
-static void
-WriteColumn(
- ScrnInfoPtr pScrn,
- unsigned char *pSrc,
- int x, int y, int w, int h,
- int xoff, int yoff,
- int pHeight,
- int srcwidth,
- int Bpp
-) {
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- unsigned char *src;
- Bool PlusOne = FALSE;
- int skipleft, dwords;
-
- pSrc += (Bpp * xoff);
-
- if((skipleft = (long)pSrc & 0x03L)) {
- if(Bpp == 3)
- skipleft = 4 - skipleft;
- else
- skipleft /= Bpp;
-
- x -= skipleft;
- w += skipleft;
-
- if(Bpp == 3)
- pSrc -= 3 * skipleft;
- else /* is this Alpha friendly ? */
- pSrc = (unsigned char*)((long)pSrc & ~0x03L);
- }
-
- src = pSrc + (yoff * srcwidth);
-
- dwords = bytes_to_int32(w * Bpp);
-
- if((infoRec->ImageWriteFlags & CPU_TRANSFER_PAD_QWORD) &&
- ((dwords * h) & 0x01)) {
- PlusOne = TRUE;
- }
-
- (*infoRec->SubsequentImageWriteRect)(pScrn, x, y, w, h, skipleft);
-
- if(dwords > infoRec->ImageWriteRange) {
- while(h--) {
- XAAMoveDWORDS_FixedBase((CARD32*)infoRec->ImageWriteBase,
- (CARD32*)src, dwords);
- src += srcwidth;
- yoff++;
- if(yoff >= pHeight) {
- yoff = 0;
- src = pSrc;
- }
- }
- } else {
- if(srcwidth == (dwords << 2)) {
- int maxLines = infoRec->ImageWriteRange/dwords;
- int step;
-
- while(h) {
- step = pHeight - yoff;
- if(step > maxLines) step = maxLines;
- if(step > h) step = h;
-
- XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase,
- (CARD32*)src, dwords * step);
-
- src += (srcwidth * step);
- yoff += step;
- if(yoff >= pHeight) {
- yoff = 0;
- src = pSrc;
- }
- h -= step;
- }
- } else {
- while(h--) {
- XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase,
- (CARD32*)src, dwords);
- src += srcwidth;
- yoff++;
- if(yoff >= pHeight) {
- yoff = 0;
- src = pSrc;
- }
- }
- }
- }
-
- if(PlusOne) {
- CARD32* base = (CARD32*)infoRec->ImageWriteBase;
- *base = 0x00000000;
- }
-}
-
-void
-XAAFillImageWriteRects(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int x, phaseY, phaseX, height, width, blit_w;
- int pHeight = pPix->drawable.height;
- int pWidth = pPix->drawable.width;
- int Bpp = pPix->drawable.bitsPerPixel >> 3;
- int srcwidth = pPix->devKind;
-
- (*infoRec->SetupForImageWrite)(pScrn, rop, planemask, -1,
- pPix->drawable.bitsPerPixel, pPix->drawable.depth);
-
- while(nBox--) {
- x = pBox->x1;
- phaseY = (pBox->y1 - yorg) % pHeight;
- if(phaseY < 0) phaseY += pHeight;
- phaseX = (x - xorg) % pWidth;
- if(phaseX < 0) phaseX += pWidth;
- height = pBox->y2 - pBox->y1;
- width = pBox->x2 - x;
-
- while(1) {
- blit_w = pWidth - phaseX;
- if(blit_w > width) blit_w = width;
-
- WriteColumn(pScrn, pPix->devPrivate.ptr, x, pBox->y1,
- blit_w, height, phaseX, phaseY, pHeight, srcwidth, Bpp);
-
- width -= blit_w;
- if(!width) break;
- x += blit_w;
- phaseX = (phaseX + blit_w) % pWidth;
- }
- pBox++;
- }
-
- if(infoRec->ImageWriteFlags & SYNC_AFTER_IMAGE_WRITE)
- (*infoRec->Sync)(pScrn);
- else SET_SYNC_FLAG(infoRec);
-}
-
-
- /*************\
- | Utilities |
- \*************/
-
-
-void
-XAAClipAndRenderRects(
- GCPtr pGC,
- ClipAndRenderRectsFunc BoxFunc,
- int nrectFill,
- xRectangle *prect,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int Right, Bottom, MaxBoxes;
- BoxPtr pextent, pboxClipped, pboxClippedBase;
-
- MaxBoxes = infoRec->PreAllocSize/sizeof(BoxRec);
- pboxClippedBase = (BoxPtr)infoRec->PreAllocMem;
- pboxClipped = pboxClippedBase;
-
- if (RegionNumRects(pGC->pCompositeClip) == 1) {
- pextent = RegionRects(pGC->pCompositeClip);
- while (nrectFill--) {
- pboxClipped->x1 = max(pextent->x1, prect->x);
- pboxClipped->y1 = max(pextent->y1, prect->y);
-
- Right = (int)prect->x + (int)prect->width;
- pboxClipped->x2 = min(pextent->x2, Right);
-
- Bottom = (int)prect->y + (int)prect->height;
- pboxClipped->y2 = min(pextent->y2, Bottom);
-
- prect++;
- if ((pboxClipped->x1 < pboxClipped->x2) &&
- (pboxClipped->y1 < pboxClipped->y2)) {
- pboxClipped++;
- if(pboxClipped >= (pboxClippedBase + MaxBoxes)) {
- (*BoxFunc)(pGC, MaxBoxes, pboxClippedBase, xorg, yorg);
- pboxClipped = pboxClippedBase;
- }
- }
- }
- } else {
- pextent = RegionExtents(pGC->pCompositeClip);
- while (nrectFill--) {
- int n;
- BoxRec box, *pbox;
-
- box.x1 = max(pextent->x1, prect->x);
- box.y1 = max(pextent->y1, prect->y);
-
- Right = (int)prect->x + (int)prect->width;
- box.x2 = min(pextent->x2, Right);
-
- Bottom = (int)prect->y + (int)prect->height;
- box.y2 = min(pextent->y2, Bottom);
-
- prect++;
-
- if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
- continue;
-
- n = RegionNumRects (pGC->pCompositeClip);
- pbox = RegionRects(pGC->pCompositeClip);
-
- /* clip the rectangle to each box in the clip region
- this is logically equivalent to calling Intersect()
- */
- while(n--) {
- pboxClipped->x1 = max(box.x1, pbox->x1);
- pboxClipped->y1 = max(box.y1, pbox->y1);
- pboxClipped->x2 = min(box.x2, pbox->x2);
- pboxClipped->y2 = min(box.y2, pbox->y2);
- pbox++;
-
- /* see if clipping left anything */
- if(pboxClipped->x1 < pboxClipped->x2 &&
- pboxClipped->y1 < pboxClipped->y2) {
- pboxClipped++;
- if(pboxClipped >= (pboxClippedBase + MaxBoxes)) {
- (*BoxFunc)(pGC, MaxBoxes, pboxClippedBase, xorg, yorg);
- pboxClipped = pboxClippedBase;
- }
- }
- }
- }
- }
-
- if(pboxClipped != pboxClippedBase)
- (*BoxFunc)(pGC, pboxClipped - pboxClippedBase, pboxClippedBase,
- xorg, yorg);
-}
-
-
-int
-XAAGetRectClipBoxes(
- GCPtr pGC,
- BoxPtr pboxClippedBase,
- int nrectFill,
- xRectangle *prectInit
-){
- int Right, Bottom;
- BoxPtr pextent, pboxClipped = pboxClippedBase;
- xRectangle *prect = prectInit;
- RegionPtr prgnClip = pGC->pCompositeClip;
-
- if (RegionNumRects(prgnClip) == 1) {
- pextent = RegionRects(prgnClip);
- while (nrectFill--) {
- pboxClipped->x1 = max(pextent->x1, prect->x);
- pboxClipped->y1 = max(pextent->y1, prect->y);
-
- Right = (int)prect->x + (int)prect->width;
- pboxClipped->x2 = min(pextent->x2, Right);
-
- Bottom = (int)prect->y + (int)prect->height;
- pboxClipped->y2 = min(pextent->y2, Bottom);
-
- prect++;
- if ((pboxClipped->x1 < pboxClipped->x2) &&
- (pboxClipped->y1 < pboxClipped->y2)) {
- pboxClipped++;
- }
- }
- } else {
- pextent = RegionExtents(prgnClip);
- while (nrectFill--) {
- int n;
- BoxRec box, *pbox;
-
- box.x1 = max(pextent->x1, prect->x);
- box.y1 = max(pextent->y1, prect->y);
-
- Right = (int)prect->x + (int)prect->width;
- box.x2 = min(pextent->x2, Right);
-
- Bottom = (int)prect->y + (int)prect->height;
- box.y2 = min(pextent->y2, Bottom);
-
- prect++;
-
- if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
- continue;
-
- n = RegionNumRects (prgnClip);
- pbox = RegionRects(prgnClip);
-
- /* clip the rectangle to each box in the clip region
- this is logically equivalent to calling Intersect()
- */
- while(n--) {
- pboxClipped->x1 = max(box.x1, pbox->x1);
- pboxClipped->y1 = max(box.y1, pbox->y1);
- pboxClipped->x2 = min(box.x2, pbox->x2);
- pboxClipped->y2 = min(box.y2, pbox->y2);
- pbox++;
-
- /* see if clipping left anything */
- if(pboxClipped->x1 < pboxClipped->x2 &&
- pboxClipped->y1 < pboxClipped->y2) {
- pboxClipped++;
- }
- }
- }
- }
-
- return pboxClipped - pboxClippedBase;
-}
-
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+
+static void XAARenderSolidRects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderColor8x8Rects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderMono8x8Rects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderColorExpandRects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderCacheExpandRects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderCacheBltRects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderImageWriteRects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderPixmapCopyRects(GCPtr, int, BoxPtr, int, int);
+
+void
+XAAPolyFillRect(DrawablePtr pDraw, GCPtr pGC, int nrectFill, /* number of rectangles to fill */
+ xRectangle *prectInit /* Pointer to first rectangle to fill */
+ )
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int xorg = pDraw->x;
+ int yorg = pDraw->y;
+ int type = 0;
+ ClipAndRenderRectsFunc function;
+
+ if ((nrectFill <= 0) || !pGC->planemask)
+ return;
+
+ if (!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ switch (pGC->fillStyle) {
+ case FillSolid:
+ type = DO_SOLID;
+ break;
+ case FillStippled:
+ type = (*infoRec->StippledFillChooser) (pGC);
+ break;
+ case FillOpaqueStippled:
+ if ((pGC->fgPixel == pGC->bgPixel) && infoRec->FillSolidRects &&
+ CHECK_PLANEMASK(pGC, infoRec->FillSolidRectsFlags) &&
+ CHECK_ROP(pGC, infoRec->FillSolidRectsFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->FillSolidRectsFlags) &&
+ CHECK_FG(pGC, infoRec->FillSolidRectsFlags))
+ type = DO_SOLID;
+ else
+ type = (*infoRec->OpaqueStippledFillChooser) (pGC);
+ break;
+ case FillTiled:
+ type = (*infoRec->TiledFillChooser) (pGC);
+ break;
+ }
+
+ switch (type) {
+ case DO_SOLID:
+ function = XAARenderSolidRects;
+ break;
+ case DO_COLOR_8x8:
+ function = XAARenderColor8x8Rects;
+ break;
+ case DO_MONO_8x8:
+ function = XAARenderMono8x8Rects;
+ break;
+ case DO_CACHE_BLT:
+ function = XAARenderCacheBltRects;
+ break;
+ case DO_COLOR_EXPAND:
+ function = XAARenderColorExpandRects;
+ break;
+ case DO_CACHE_EXPAND:
+ function = XAARenderCacheExpandRects;
+ break;
+ case DO_IMAGE_WRITE:
+ function = XAARenderImageWriteRects;
+ break;
+ case DO_PIXMAP_COPY:
+ function = XAARenderPixmapCopyRects;
+ break;
+ default:
+ (*XAAFallbackOps.PolyFillRect) (pDraw, pGC, nrectFill, prectInit);
+ return;
+ }
+
+ if (xorg | yorg) {
+ int n = nrectFill;
+ xRectangle *prect = prectInit;
+
+ while (n--) {
+ prect->x += xorg;
+ prect->y += yorg;
+ prect++;
+ }
+ }
+
+ XAAClipAndRenderRects(pGC, function, nrectFill, prectInit, xorg, yorg);
+}
+
+ /*********************\
+ | Solid Rects |
+ \*********************/
+
+static void
+XAARenderSolidRects(GCPtr pGC,
+ int nboxes, BoxPtr pClipBoxes, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
+ (*infoRec->FillSolidRects) (infoRec->pScrn,
+ pGC->fgPixel, pGC->alu, pGC->planemask, nboxes,
+ pClipBoxes);
+}
+
+ /************************\
+ | Mono 8x8 Rects |
+ \************************/
+
+static void
+XAARenderMono8x8Rects(GCPtr pGC,
+ int nboxes, BoxPtr pClipBoxes, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAAPixmapPtr pPriv;
+ int fg, bg;
+
+ switch (pGC->fillStyle) {
+ case FillStippled:
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
+ fg = pGC->fgPixel;
+ bg = -1;
+ break;
+ case FillOpaqueStippled:
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
+ fg = pGC->fgPixel;
+ bg = pGC->bgPixel;
+ break;
+ case FillTiled:
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
+ fg = pPriv->fg;
+ bg = pPriv->bg;
+ break;
+ default: /* Muffle compiler */
+ pPriv = NULL; /* Kaboom */
+ fg = -1;
+ bg = -1;
+ break;
+ }
+
+ (*infoRec->FillMono8x8PatternRects) (infoRec->pScrn,
+ fg, bg, pGC->alu, pGC->planemask,
+ nboxes, pClipBoxes, pPriv->pattern0,
+ pPriv->pattern1,
+ (xorg + pGC->patOrg.x),
+ (yorg + pGC->patOrg.y));
+}
+
+ /*************************\
+ | Color 8x8 Rects |
+ \*************************/
+
+static void
+XAARenderColor8x8Rects(GCPtr pGC,
+ int nboxes, BoxPtr pClipBoxes, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAACacheInfoPtr pCache;
+ PixmapPtr pPix;
+ int fg, bg;
+
+ switch (pGC->fillStyle) {
+ case FillStippled:
+ pPix = pGC->stipple;
+ fg = pGC->fgPixel;
+ bg = -1;
+ break;
+ case FillOpaqueStippled:
+ pPix = pGC->stipple;
+ fg = pGC->fgPixel;
+ bg = pGC->bgPixel;
+ break;
+ case FillTiled:
+ pPix = pGC->tile.pixmap;
+ fg = -1;
+ bg = -1;
+ break;
+ default: /* Muffle compiler */
+ pPix = NULL;
+ fg = -1;
+ bg = -1;
+ break;
+ }
+
+ pCache = (*infoRec->CacheColor8x8Pattern) (infoRec->pScrn, pPix, fg, bg);
+ (*infoRec->FillColor8x8PatternRects) (infoRec->pScrn,
+ pGC->alu, pGC->planemask, nboxes,
+ pClipBoxes, (xorg + pGC->patOrg.x),
+ (yorg + pGC->patOrg.y), pCache);
+}
+
+ /****************************\
+ | Color Expand Rects |
+ \****************************/
+
+static void
+XAARenderColorExpandRects(GCPtr pGC,
+ int nboxes, BoxPtr pClipBoxes, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int fg, bg;
+
+ switch (pGC->fillStyle) {
+ case FillStippled:
+ fg = pGC->fgPixel;
+ bg = -1;
+ break;
+ case FillOpaqueStippled:
+ fg = pGC->fgPixel;
+ bg = pGC->bgPixel;
+ break;
+ default: /* Muffle compiler */
+ fg = -1;
+ bg = -1;
+ break;
+ }
+
+ (*infoRec->FillColorExpandRects) (infoRec->pScrn, fg, bg,
+ pGC->alu, pGC->planemask, nboxes,
+ pClipBoxes, (xorg + pGC->patOrg.x),
+ (yorg + pGC->patOrg.y), pGC->stipple);
+}
+
+ /*************************\
+ | Cache Blt Rects |
+ \*************************/
+
+static void
+XAARenderCacheBltRects(GCPtr pGC,
+ int nboxes, BoxPtr pClipBoxes, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAACacheInfoPtr pCache;
+
+ switch (pGC->fillStyle) {
+ case FillStippled:
+ pCache = (*infoRec->CacheStipple) (infoRec->pScrn, pGC->stipple,
+ pGC->fgPixel, -1);
+ break;
+ case FillOpaqueStippled:
+ pCache = (*infoRec->CacheStipple) (infoRec->pScrn, pGC->stipple,
+ pGC->fgPixel, pGC->bgPixel);
+ break;
+ case FillTiled:
+ pCache = (*infoRec->CacheTile) (infoRec->pScrn, pGC->tile.pixmap);
+ break;
+ default: /* Muffle compiler */
+ pCache = NULL;
+ break;
+ }
+
+ (*infoRec->FillCacheBltRects) (infoRec->pScrn, pGC->alu,
+ pGC->planemask, nboxes, pClipBoxes,
+ (xorg + pGC->patOrg.x),
+ (yorg + pGC->patOrg.y), pCache);
+}
+
+ /****************************\
+ | Cache Expand Rects |
+ \****************************/
+
+static void
+XAARenderCacheExpandRects(GCPtr pGC,
+ int nboxes, BoxPtr pClipBoxes, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int fg, bg;
+
+ switch (pGC->fillStyle) {
+ case FillStippled:
+ fg = pGC->fgPixel;
+ bg = -1;
+ break;
+ case FillOpaqueStippled:
+ fg = pGC->fgPixel;
+ bg = pGC->bgPixel;
+ break;
+ default: /* Muffle compiler */
+ fg = -1;
+ bg = -1;
+ break;
+ }
+
+ (*infoRec->FillCacheExpandRects) (infoRec->pScrn, fg, bg,
+ pGC->alu, pGC->planemask, nboxes,
+ pClipBoxes, (xorg + pGC->patOrg.x),
+ (yorg + pGC->patOrg.y), pGC->stipple);
+}
+
+ /***************************\
+ | Image Write Rects |
+ \***************************/
+
+static void
+XAARenderImageWriteRects(GCPtr pGC,
+ int nboxes, BoxPtr pClipBoxes, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
+ (*infoRec->FillImageWriteRects) (infoRec->pScrn, pGC->alu,
+ pGC->planemask, nboxes, pClipBoxes,
+ (xorg + pGC->patOrg.x),
+ (yorg + pGC->patOrg.y), pGC->tile.pixmap);
+}
+
+ /***************************\
+ | Pixmap Copy Rects |
+ \***************************/
+
+static void
+XAARenderPixmapCopyRects(GCPtr pGC,
+ int nboxes, BoxPtr pClipBoxes, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec);
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
+
+ pCache->x = pPriv->offscreenArea->box.x1;
+ pCache->y = pPriv->offscreenArea->box.y1;
+ pCache->w = pCache->orig_w = pPriv->offscreenArea->box.x2 - pCache->x;
+ pCache->h = pCache->orig_h = pPriv->offscreenArea->box.y2 - pCache->y;
+ pCache->trans_color = -1;
+
+ (*infoRec->FillCacheBltRects) (infoRec->pScrn, pGC->alu,
+ pGC->planemask, nboxes, pClipBoxes,
+ (xorg + pGC->patOrg.x),
+ (yorg + pGC->patOrg.y), pCache);
+}
+
+ /************\
+ | Solid |
+ \************/
+
+void
+XAAFillSolidRects(ScrnInfoPtr pScrn, int fg, int rop, unsigned int planemask, int nBox, /* number of rectangles to fill */
+ BoxPtr pBox /* Pointer to first rectangle to fill */
+ )
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->SetupForSolidFill) (pScrn, fg, rop, planemask);
+ while (nBox--) {
+ (*infoRec->SubsequentSolidFillRect) (pScrn, pBox->x1, pBox->y1,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1);
+ pBox++;
+ }
+ SET_SYNC_FLAG(infoRec);
+}
+
+ /*********************\
+ | 8x8 Mono Patterns |
+ \*********************/
+
+void
+XAAFillMono8x8PatternRectsScreenOrigin(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int pattern0, int pattern1,
+ int xorigin, int yorigin)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int patx = pattern0, paty = pattern1;
+ int xorg = (-xorigin) & 0x07;
+ int yorg = (-yorigin) & 0x07;
+
+ if (infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ if (!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx;
+ yorg = paty;
+ }
+ }
+ else {
+ XAACacheInfoPtr pCache =
+ (*infoRec->CacheMono8x8Pattern) (pScrn, pattern0, pattern1);
+ patx = pCache->x;
+ paty = pCache->y;
+ if (!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+ int slot = (yorg << 3) + xorg;
+
+ patx += pCache->offsets[slot].x;
+ paty += pCache->offsets[slot].y;
+ xorg = patx;
+ yorg = paty;
+ }
+ }
+
+ (*infoRec->SetupForMono8x8PatternFill) (pScrn, patx, paty,
+ fg, bg, rop, planemask);
+
+ while (nBox--) {
+ (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn,
+ xorg, yorg, pBox->x1,
+ pBox->y1,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1);
+ pBox++;
+ }
+ SET_SYNC_FLAG(infoRec);
+}
+
+void
+XAAFillMono8x8PatternRects(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int pattern0, int pattern1, int xorigin, int yorigin)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int patx = pattern0, paty = pattern1;
+ int xorg, yorg;
+ XAACacheInfoPtr pCache = NULL;
+
+ if (!(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS)) {
+ pCache = (*infoRec->CacheMono8x8Pattern) (pScrn, pattern0, pattern1);
+ patx = pCache->x;
+ paty = pCache->y;
+ }
+
+ (*infoRec->SetupForMono8x8PatternFill) (pScrn, patx, paty,
+ fg, bg, rop, planemask);
+
+ while (nBox--) {
+ xorg = (pBox->x1 - xorigin) & 0x07;
+ yorg = (pBox->y1 - yorigin) & 0x07;
+
+ if (!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+ if (infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ patx = pattern0;
+ paty = pattern1;
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx;
+ yorg = paty;
+ }
+ else {
+ int slot = (yorg << 3) + xorg;
+
+ xorg = patx + pCache->offsets[slot].x;
+ yorg = paty + pCache->offsets[slot].y;
+ }
+ }
+
+ (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn,
+ xorg, yorg, pBox->x1,
+ pBox->y1,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1);
+ pBox++;
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+ /**********************\
+ | 8x8 Color Patterns |
+ \**********************/
+
+void
+XAAFillColor8x8PatternRectsScreenOrigin(ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorigin, int yorigin,
+ XAACacheInfoPtr pCache)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int patx = pCache->x, paty = pCache->y;
+ int xorg = (-xorigin) & 0x07;
+ int yorg = (-yorigin) & 0x07;
+
+ if (!(infoRec->Color8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+ int slot = (yorg << 3) + xorg;
+
+ paty += pCache->offsets[slot].y;
+ patx += pCache->offsets[slot].x;
+ xorg = patx;
+ yorg = paty;
+ }
+
+ (*infoRec->SetupForColor8x8PatternFill) (pScrn, patx, paty,
+ rop, planemask,
+ pCache->trans_color);
+
+ while (nBox--) {
+ (*infoRec->SubsequentColor8x8PatternFillRect) (pScrn,
+ xorg, yorg, pBox->x1,
+ pBox->y1,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1);
+ pBox++;
+ }
+ SET_SYNC_FLAG(infoRec);
+}
+
+void
+XAAFillColor8x8PatternRects(ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorigin, int yorigin, XAACacheInfoPtr pCache)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int xorg, yorg;
+
+ (*infoRec->SetupForColor8x8PatternFill) (pScrn, pCache->x, pCache->y,
+ rop, planemask,
+ pCache->trans_color);
+
+ while (nBox--) {
+ xorg = (pBox->x1 - xorigin) & 0x07;
+ yorg = (pBox->y1 - yorigin) & 0x07;
+
+ if (!(infoRec->Color8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+ int slot = (yorg << 3) + xorg;
+
+ yorg = pCache->y + pCache->offsets[slot].y;
+ xorg = pCache->x + pCache->offsets[slot].x;
+ }
+
+ (*infoRec->SubsequentColor8x8PatternFillRect) (pScrn,
+ xorg, yorg, pBox->x1,
+ pBox->y1,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1);
+ pBox++;
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+ /***************\
+ | Cache Blits |
+ \***************/
+
+void
+XAAFillCacheBltRects(ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox, int xorg, int yorg, XAACacheInfoPtr pCache)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, y, phaseY, phaseX, skipleft, height, width, w, blit_w, blit_h;
+
+ (*infoRec->SetupForScreenToScreenCopy) (pScrn, 1, 1, rop, planemask,
+ pCache->trans_color);
+
+ while (nBox--) {
+ y = pBox->y1;
+ phaseY = (y - yorg) % pCache->orig_h;
+ if (phaseY < 0)
+ phaseY += pCache->orig_h;
+ phaseX = (pBox->x1 - xorg) % pCache->orig_w;
+ if (phaseX < 0)
+ phaseX += pCache->orig_w;
+ height = pBox->y2 - y;
+ width = pBox->x2 - pBox->x1;
+
+#if 0
+ if (rop == GXcopy) {
+ while (1) {
+ w = width;
+ skipleft = phaseX;
+ x = pBox->x1;
+ blit_h = pCache->h - phaseY;
+ if (blit_h > height)
+ blit_h = height;
+
+ while (1) {
+ blit_w = pCache->w - skipleft;
+ if (blit_w > w)
+ blit_w = w;
+ (*infoRec->SubsequentScreenToScreenCopy) (pScrn,
+ pCache->x +
+ skipleft,
+ pCache->y +
+ phaseY, x, y,
+ blit_w, blit_h);
+ w -= blit_w;
+ if (!w)
+ break;
+ x += blit_w;
+ skipleft = (skipleft + blit_w) % pCache->orig_w;
+ if (blit_w >= pCache->orig_w)
+ break;
+ }
+
+ /* Expand horizontally */
+ if (w) {
+ skipleft -= phaseX;
+ if (skipleft < 0)
+ skipleft += pCache->orig_w;
+ blit_w = x - pBox->x1 - skipleft;
+ while (w) {
+ if (blit_w > w)
+ blit_w = w;
+ (*infoRec->SubsequentScreenToScreenCopy) (pScrn,
+ pBox->x1 +
+ skipleft, y,
+ x, y, blit_w,
+ blit_h);
+ w -= blit_w;
+ x += blit_w;
+ blit_w <<= 1;
+ }
+ }
+
+ height -= blit_h;
+ if (!height)
+ break;
+ y += blit_h;
+ phaseY = (phaseY + blit_h) % pCache->orig_h;
+ if (blit_h >= pCache->orig_h)
+ break;
+ }
+
+ /* Expand vertically */
+ if (height) {
+ blit_w = pBox->x2 - pBox->x1;
+ phaseY -= (pBox->y1 - yorg) % pCache->orig_h;
+ if (phaseY < 0)
+ phaseY += pCache->orig_h;
+ blit_h = y - pBox->y1 - phaseY;
+ while (height) {
+ if (blit_h > height)
+ blit_h = height;
+ (*infoRec->SubsequentScreenToScreenCopy) (pScrn, pBox->x1,
+ pBox->y1 + phaseY,
+ pBox->x1, y,
+ blit_w, blit_h);
+ height -= blit_h;
+ y += blit_h;
+ blit_h <<= 1;
+ }
+ }
+ }
+ else
+#endif
+ {
+ while (1) {
+ w = width;
+ skipleft = phaseX;
+ x = pBox->x1;
+ blit_h = pCache->h - phaseY;
+ if (blit_h > height)
+ blit_h = height;
+
+ while (1) {
+ blit_w = pCache->w - skipleft;
+ if (blit_w > w)
+ blit_w = w;
+ (*infoRec->SubsequentScreenToScreenCopy) (pScrn,
+ pCache->x +
+ skipleft,
+ pCache->y +
+ phaseY, x, y,
+ blit_w, blit_h);
+ w -= blit_w;
+ if (!w)
+ break;
+ x += blit_w;
+ skipleft = (skipleft + blit_w) % pCache->orig_w;
+ }
+ height -= blit_h;
+ if (!height)
+ break;
+ y += blit_h;
+ phaseY = (phaseY + blit_h) % pCache->orig_h;
+ }
+ }
+ pBox++;
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+ /*******************\
+ | Cache Expansion |
+ \*******************/
+
+void
+XAAFillCacheExpandRects(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox, int xorg, int yorg, PixmapPtr pPix)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, y, phaseY, phaseX, skipleft, height, width, w, blit_w, blit_h;
+ int cacheWidth;
+ XAACacheInfoPtr pCache;
+
+ pCache = (*infoRec->CacheMonoStipple) (pScrn, pPix);
+
+ cacheWidth = (pCache->w * pScrn->bitsPerPixel) /
+ infoRec->CacheColorExpandDensity;
+
+ (*infoRec->SetupForScreenToScreenColorExpandFill) (pScrn, fg, bg, rop,
+ planemask);
+
+ while (nBox--) {
+ y = pBox->y1;
+ phaseY = (y - yorg) % pCache->orig_h;
+ if (phaseY < 0)
+ phaseY += pCache->orig_h;
+ phaseX = (pBox->x1 - xorg) % pCache->orig_w;
+ if (phaseX < 0)
+ phaseX += pCache->orig_w;
+ height = pBox->y2 - y;
+ width = pBox->x2 - pBox->x1;
+
+ while (1) {
+ w = width;
+ skipleft = phaseX;
+ x = pBox->x1;
+ blit_h = pCache->h - phaseY;
+ if (blit_h > height)
+ blit_h = height;
+
+ while (1) {
+ blit_w = cacheWidth - skipleft;
+ if (blit_w > w)
+ blit_w = w;
+ (*infoRec->SubsequentScreenToScreenColorExpandFill) (pScrn, x,
+ y, blit_w,
+ blit_h,
+ pCache->x,
+ pCache->y +
+ phaseY,
+ skipleft);
+ w -= blit_w;
+ if (!w)
+ break;
+ x += blit_w;
+ skipleft = (skipleft + blit_w) % pCache->orig_w;
+ }
+ height -= blit_h;
+ if (!height)
+ break;
+ y += blit_h;
+ phaseY = (phaseY + blit_h) % pCache->orig_h;
+ }
+ pBox++;
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+ /******************\
+ | Image Writes |
+ \******************/
+
+/* This requires all LEFT_EDGE clipping. You get too many problems
+ with reading past the edge of the pattern otherwise */
+
+static void
+WriteColumn(ScrnInfoPtr pScrn,
+ unsigned char *pSrc,
+ int x, int y, int w, int h,
+ int xoff, int yoff, int pHeight, int srcwidth, int Bpp)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ unsigned char *src;
+ Bool PlusOne = FALSE;
+ int skipleft, dwords;
+
+ pSrc += (Bpp * xoff);
+
+ if ((skipleft = (long) pSrc & 0x03L)) {
+ if (Bpp == 3)
+ skipleft = 4 - skipleft;
+ else
+ skipleft /= Bpp;
+
+ x -= skipleft;
+ w += skipleft;
+
+ if (Bpp == 3)
+ pSrc -= 3 * skipleft;
+ else /* is this Alpha friendly ? */
+ pSrc = (unsigned char *) ((long) pSrc & ~0x03L);
+ }
+
+ src = pSrc + (yoff * srcwidth);
+
+ dwords = bytes_to_int32(w * Bpp);
+
+ if ((infoRec->ImageWriteFlags & CPU_TRANSFER_PAD_QWORD) &&
+ ((dwords * h) & 0x01)) {
+ PlusOne = TRUE;
+ }
+
+ (*infoRec->SubsequentImageWriteRect) (pScrn, x, y, w, h, skipleft);
+
+ if (dwords > infoRec->ImageWriteRange) {
+ while (h--) {
+ XAAMoveDWORDS_FixedBase((CARD32 *) infoRec->ImageWriteBase,
+ (CARD32 *) src, dwords);
+ src += srcwidth;
+ yoff++;
+ if (yoff >= pHeight) {
+ yoff = 0;
+ src = pSrc;
+ }
+ }
+ }
+ else {
+ if (srcwidth == (dwords << 2)) {
+ int maxLines = infoRec->ImageWriteRange / dwords;
+ int step;
+
+ while (h) {
+ step = pHeight - yoff;
+ if (step > maxLines)
+ step = maxLines;
+ if (step > h)
+ step = h;
+
+ XAAMoveDWORDS((CARD32 *) infoRec->ImageWriteBase,
+ (CARD32 *) src, dwords * step);
+
+ src += (srcwidth * step);
+ yoff += step;
+ if (yoff >= pHeight) {
+ yoff = 0;
+ src = pSrc;
+ }
+ h -= step;
+ }
+ }
+ else {
+ while (h--) {
+ XAAMoveDWORDS((CARD32 *) infoRec->ImageWriteBase,
+ (CARD32 *) src, dwords);
+ src += srcwidth;
+ yoff++;
+ if (yoff >= pHeight) {
+ yoff = 0;
+ src = pSrc;
+ }
+ }
+ }
+ }
+
+ if (PlusOne) {
+ CARD32 *base = (CARD32 *) infoRec->ImageWriteBase;
+
+ *base = 0x00000000;
+ }
+}
+
+void
+XAAFillImageWriteRects(ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox, int xorg, int yorg, PixmapPtr pPix)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, phaseY, phaseX, height, width, blit_w;
+ int pHeight = pPix->drawable.height;
+ int pWidth = pPix->drawable.width;
+ int Bpp = pPix->drawable.bitsPerPixel >> 3;
+ int srcwidth = pPix->devKind;
+
+ (*infoRec->SetupForImageWrite) (pScrn, rop, planemask, -1,
+ pPix->drawable.bitsPerPixel,
+ pPix->drawable.depth);
+
+ while (nBox--) {
+ x = pBox->x1;
+ phaseY = (pBox->y1 - yorg) % pHeight;
+ if (phaseY < 0)
+ phaseY += pHeight;
+ phaseX = (x - xorg) % pWidth;
+ if (phaseX < 0)
+ phaseX += pWidth;
+ height = pBox->y2 - pBox->y1;
+ width = pBox->x2 - x;
+
+ while (1) {
+ blit_w = pWidth - phaseX;
+ if (blit_w > width)
+ blit_w = width;
+
+ WriteColumn(pScrn, pPix->devPrivate.ptr, x, pBox->y1,
+ blit_w, height, phaseX, phaseY, pHeight, srcwidth, Bpp);
+
+ width -= blit_w;
+ if (!width)
+ break;
+ x += blit_w;
+ phaseX = (phaseX + blit_w) % pWidth;
+ }
+ pBox++;
+ }
+
+ if (infoRec->ImageWriteFlags & SYNC_AFTER_IMAGE_WRITE)
+ (*infoRec->Sync) (pScrn);
+ else
+ SET_SYNC_FLAG(infoRec);
+}
+
+ /*************\
+ | Utilities |
+ \*************/
+
+void
+XAAClipAndRenderRects(GCPtr pGC,
+ ClipAndRenderRectsFunc BoxFunc,
+ int nrectFill, xRectangle *prect, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int Right, Bottom, MaxBoxes;
+ BoxPtr pextent, pboxClipped, pboxClippedBase;
+
+ MaxBoxes = infoRec->PreAllocSize / sizeof(BoxRec);
+ pboxClippedBase = (BoxPtr) infoRec->PreAllocMem;
+ pboxClipped = pboxClippedBase;
+
+ if (RegionNumRects(pGC->pCompositeClip) == 1) {
+ pextent = RegionRects(pGC->pCompositeClip);
+ while (nrectFill--) {
+ pboxClipped->x1 = max(pextent->x1, prect->x);
+ pboxClipped->y1 = max(pextent->y1, prect->y);
+
+ Right = (int) prect->x + (int) prect->width;
+ pboxClipped->x2 = min(pextent->x2, Right);
+
+ Bottom = (int) prect->y + (int) prect->height;
+ pboxClipped->y2 = min(pextent->y2, Bottom);
+
+ prect++;
+ if ((pboxClipped->x1 < pboxClipped->x2) &&
+ (pboxClipped->y1 < pboxClipped->y2)) {
+ pboxClipped++;
+ if (pboxClipped >= (pboxClippedBase + MaxBoxes)) {
+ (*BoxFunc) (pGC, MaxBoxes, pboxClippedBase, xorg, yorg);
+ pboxClipped = pboxClippedBase;
+ }
+ }
+ }
+ }
+ else {
+ pextent = RegionExtents(pGC->pCompositeClip);
+ while (nrectFill--) {
+ int n;
+ BoxRec box, *pbox;
+
+ box.x1 = max(pextent->x1, prect->x);
+ box.y1 = max(pextent->y1, prect->y);
+
+ Right = (int) prect->x + (int) prect->width;
+ box.x2 = min(pextent->x2, Right);
+
+ Bottom = (int) prect->y + (int) prect->height;
+ box.y2 = min(pextent->y2, Bottom);
+
+ prect++;
+
+ if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
+ continue;
+
+ n = RegionNumRects(pGC->pCompositeClip);
+ pbox = RegionRects(pGC->pCompositeClip);
+
+ /* clip the rectangle to each box in the clip region
+ this is logically equivalent to calling Intersect()
+ */
+ while (n--) {
+ pboxClipped->x1 = max(box.x1, pbox->x1);
+ pboxClipped->y1 = max(box.y1, pbox->y1);
+ pboxClipped->x2 = min(box.x2, pbox->x2);
+ pboxClipped->y2 = min(box.y2, pbox->y2);
+ pbox++;
+
+ /* see if clipping left anything */
+ if (pboxClipped->x1 < pboxClipped->x2 &&
+ pboxClipped->y1 < pboxClipped->y2) {
+ pboxClipped++;
+ if (pboxClipped >= (pboxClippedBase + MaxBoxes)) {
+ (*BoxFunc) (pGC, MaxBoxes, pboxClippedBase, xorg, yorg);
+ pboxClipped = pboxClippedBase;
+ }
+ }
+ }
+ }
+ }
+
+ if (pboxClipped != pboxClippedBase)
+ (*BoxFunc) (pGC, pboxClipped - pboxClippedBase, pboxClippedBase,
+ xorg, yorg);
+}
+
+int
+XAAGetRectClipBoxes(GCPtr pGC,
+ BoxPtr pboxClippedBase,
+ int nrectFill, xRectangle *prectInit)
+{
+ int Right, Bottom;
+ BoxPtr pextent, pboxClipped = pboxClippedBase;
+ xRectangle *prect = prectInit;
+ RegionPtr prgnClip = pGC->pCompositeClip;
+
+ if (RegionNumRects(prgnClip) == 1) {
+ pextent = RegionRects(prgnClip);
+ while (nrectFill--) {
+ pboxClipped->x1 = max(pextent->x1, prect->x);
+ pboxClipped->y1 = max(pextent->y1, prect->y);
+
+ Right = (int) prect->x + (int) prect->width;
+ pboxClipped->x2 = min(pextent->x2, Right);
+
+ Bottom = (int) prect->y + (int) prect->height;
+ pboxClipped->y2 = min(pextent->y2, Bottom);
+
+ prect++;
+ if ((pboxClipped->x1 < pboxClipped->x2) &&
+ (pboxClipped->y1 < pboxClipped->y2)) {
+ pboxClipped++;
+ }
+ }
+ }
+ else {
+ pextent = RegionExtents(prgnClip);
+ while (nrectFill--) {
+ int n;
+ BoxRec box, *pbox;
+
+ box.x1 = max(pextent->x1, prect->x);
+ box.y1 = max(pextent->y1, prect->y);
+
+ Right = (int) prect->x + (int) prect->width;
+ box.x2 = min(pextent->x2, Right);
+
+ Bottom = (int) prect->y + (int) prect->height;
+ box.y2 = min(pextent->y2, Bottom);
+
+ prect++;
+
+ if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
+ continue;
+
+ n = RegionNumRects(prgnClip);
+ pbox = RegionRects(prgnClip);
+
+ /* clip the rectangle to each box in the clip region
+ this is logically equivalent to calling Intersect()
+ */
+ while (n--) {
+ pboxClipped->x1 = max(box.x1, pbox->x1);
+ pboxClipped->y1 = max(box.y1, pbox->y1);
+ pboxClipped->x2 = min(box.x2, pbox->x2);
+ pboxClipped->y2 = min(box.y2, pbox->y2);
+ pbox++;
+
+ /* see if clipping left anything */
+ if (pboxClipped->x1 < pboxClipped->x2 &&
+ pboxClipped->y1 < pboxClipped->y2) {
+ pboxClipped++;
+ }
+ }
+ }
+ }
+
+ return pboxClipped - pboxClippedBase;
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaGC.c b/xorg-server/hw/xfree86/xaa/xaaGC.c
index 1bc35d9f3..d55f1e445 100644
--- a/xorg-server/hw/xfree86/xaa/xaaGC.c
+++ b/xorg-server/hw/xfree86/xaa/xaaGC.c
@@ -37,614 +37,528 @@ extern GCOps XAAPixmapOps;
Bool
XAACreateGC(GCPtr pGC)
{
- ScreenPtr pScreen = pGC->pScreen;
- XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates,
- XAAGetGCKey());
- Bool ret;
-
- XAA_SCREEN_PROLOGUE(pScreen,CreateGC);
-
- if((ret = (*pScreen->CreateGC)(pGC))) {
- pGCPriv->wrapOps = NULL;
- pGCPriv->wrapFuncs = pGC->funcs;
- pGCPriv->XAAOps = &XAAFallbackOps;
- pGC->funcs = &XAAGCFuncs;
+ ScreenPtr pScreen = pGC->pScreen;
+ XAAGCPtr pGCPriv = (XAAGCPtr) dixLookupPrivate(&pGC->devPrivates,
+ XAAGetGCKey());
+ Bool ret;
+
+ XAA_SCREEN_PROLOGUE(pScreen, CreateGC);
+
+ if ((ret = (*pScreen->CreateGC) (pGC))) {
+ pGCPriv->wrapOps = NULL;
+ pGCPriv->wrapFuncs = pGC->funcs;
+ pGCPriv->XAAOps = &XAAFallbackOps;
+ pGC->funcs = &XAAGCFuncs;
}
-
- XAA_SCREEN_EPILOGUE(pScreen,CreateGC,XAACreateGC);
+
+ XAA_SCREEN_EPILOGUE(pScreen, CreateGC, XAACreateGC);
return ret;
}
-
static void
-XAAValidateGC(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw
-){
+XAAValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDraw)
+{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
XAA_GC_FUNC_PROLOGUE(pGC);
- (*pGC->funcs->ValidateGC)(pGC, changes, pDraw);
+ (*pGC->funcs->ValidateGC) (pGC, changes, pDraw);
- if((changes & GCPlaneMask) &&
- ((pGC->planemask & infoRec->FullPlanemasks[pGC->depth - 1]) ==
- infoRec->FullPlanemasks[pGC->depth - 1]))
- {
- pGC->planemask = ~0;
+ if ((changes & GCPlaneMask) &&
+ ((pGC->planemask & infoRec->FullPlanemasks[pGC->depth - 1]) ==
+ infoRec->FullPlanemasks[pGC->depth - 1])) {
+ pGC->planemask = ~0;
}
- if(pGC->depth != 32) {
- /* 0xffffffff is reserved for transparency */
- if(pGC->bgPixel == 0xffffffff)
- pGC->bgPixel = 0x7fffffff;
- if(pGC->fgPixel == 0xffffffff)
- pGC->fgPixel = 0x7fffffff;
+ if (pGC->depth != 32) {
+ /* 0xffffffff is reserved for transparency */
+ if (pGC->bgPixel == 0xffffffff)
+ pGC->bgPixel = 0x7fffffff;
+ if (pGC->fgPixel == 0xffffffff)
+ pGC->fgPixel = 0x7fffffff;
}
- if((pDraw->type == DRAWABLE_PIXMAP) && !IS_OFFSCREEN_PIXMAP(pDraw)){
- pGCPriv->flags = OPS_ARE_PIXMAP;
+ if ((pDraw->type == DRAWABLE_PIXMAP) && !IS_OFFSCREEN_PIXMAP(pDraw)) {
+ pGCPriv->flags = OPS_ARE_PIXMAP;
pGCPriv->changes |= changes;
- /* make sure we're not using videomemory pixmaps to render
- onto system memory drawables */
+ /* make sure we're not using videomemory pixmaps to render
+ onto system memory drawables */
- if((pGC->fillStyle == FillTiled) &&
- IS_OFFSCREEN_PIXMAP(pGC->tile.pixmap) &&
- !OFFSCREEN_PIXMAP_LOCKED(pGC->tile.pixmap)) {
+ if ((pGC->fillStyle == FillTiled) &&
+ IS_OFFSCREEN_PIXMAP(pGC->tile.pixmap) &&
+ !OFFSCREEN_PIXMAP_LOCKED(pGC->tile.pixmap)) {
- XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
- FBAreaPtr area = pPriv->offscreenArea;
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
+ FBAreaPtr area = pPriv->offscreenArea;
- XAARemoveAreaCallback(area); /* clobbers pPriv->offscreenArea */
- xf86FreeOffscreenArea(area);
- }
- }
- else if(!infoRec->pScrn->vtSema && (pDraw->type == DRAWABLE_WINDOW)) {
- pGCPriv->flags = 0;
+ XAARemoveAreaCallback(area); /* clobbers pPriv->offscreenArea */
+ xf86FreeOffscreenArea(area);
+ }
+ }
+ else if (!infoRec->pScrn->vtSema && (pDraw->type == DRAWABLE_WINDOW)) {
+ pGCPriv->flags = 0;
pGCPriv->changes |= changes;
}
else {
- if(!(pGCPriv->flags & OPS_ARE_ACCEL)) {
- changes |= pGCPriv->changes;
- pGCPriv->changes = 0;
- }
- pGCPriv->flags = OPS_ARE_ACCEL;
+ if (!(pGCPriv->flags & OPS_ARE_ACCEL)) {
+ changes |= pGCPriv->changes;
+ pGCPriv->changes = 0;
+ }
+ pGCPriv->flags = OPS_ARE_ACCEL;
#if 1
- /* Ugh. If we can't use the blitter on offscreen pixmaps used
- as tiles, then we need to move them out as cfb can't handle
- tiles with non-zero origins */
+ /* Ugh. If we can't use the blitter on offscreen pixmaps used
+ as tiles, then we need to move them out as cfb can't handle
+ tiles with non-zero origins */
- if((pGC->fillStyle == FillTiled) &&
- IS_OFFSCREEN_PIXMAP(pGC->tile.pixmap) &&
- (DO_PIXMAP_COPY != (*infoRec->TiledFillChooser)(pGC))) {
+ if ((pGC->fillStyle == FillTiled) &&
+ IS_OFFSCREEN_PIXMAP(pGC->tile.pixmap) &&
+ (DO_PIXMAP_COPY != (*infoRec->TiledFillChooser) (pGC))) {
- XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
- FBAreaPtr area = pPriv->offscreenArea;
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
+ FBAreaPtr area = pPriv->offscreenArea;
- XAARemoveAreaCallback(area); /* clobbers pPriv->offscreenArea */
- xf86FreeOffscreenArea(area);
- }
+ XAARemoveAreaCallback(area); /* clobbers pPriv->offscreenArea */
+ xf86FreeOffscreenArea(area);
+ }
#endif
}
XAA_GC_FUNC_EPILOGUE(pGC);
- if(!(pGCPriv->flags & OPS_ARE_ACCEL)) return;
+ if (!(pGCPriv->flags & OPS_ARE_ACCEL))
+ return;
+
+ if ((changes & GCTile) && !pGC->tileIsPixel && pGC->tile.pixmap) {
+ XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
- if((changes & GCTile) && !pGC->tileIsPixel && pGC->tile.pixmap){
- XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
-
- if(pixPriv->flags & DIRTY) {
- pixPriv->flags &= ~(DIRTY | REDUCIBILITY_MASK);
- pGC->tile.pixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
- }
+ if (pixPriv->flags & DIRTY) {
+ pixPriv->flags &= ~(DIRTY | REDUCIBILITY_MASK);
+ pGC->tile.pixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ }
}
- if((changes & GCStipple) && pGC->stipple){
- XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
-
- if(pixPriv->flags & DIRTY) {
- pixPriv->flags &= ~(DIRTY | REDUCIBILITY_MASK);
- pGC->stipple->drawable.serialNumber = NEXT_SERIAL_NUMBER;
- }
+ if ((changes & GCStipple) && pGC->stipple) {
+ XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
+
+ if (pixPriv->flags & DIRTY) {
+ pixPriv->flags &= ~(DIRTY | REDUCIBILITY_MASK);
+ pGC->stipple->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ }
}
/* If our Ops are still the default ones we need to allocate new ones */
- if(pGC->ops == &XAAFallbackOps) {
- if(!(pGCPriv->XAAOps = malloc(sizeof(GCOps)))) {
- pGCPriv->XAAOps = &XAAFallbackOps;
- return;
- }
- /* make a modifiable copy of the default ops */
- memcpy(pGCPriv->XAAOps, &XAAFallbackOps, sizeof(GCOps));
- pGC->ops = pGCPriv->XAAOps;
- changes = ~0;
+ if (pGC->ops == &XAAFallbackOps) {
+ if (!(pGCPriv->XAAOps = malloc(sizeof(GCOps)))) {
+ pGCPriv->XAAOps = &XAAFallbackOps;
+ return;
+ }
+ /* make a modifiable copy of the default ops */
+ memcpy(pGCPriv->XAAOps, &XAAFallbackOps, sizeof(GCOps));
+ pGC->ops = pGCPriv->XAAOps;
+ changes = ~0;
}
- if(!changes) return;
+ if (!changes)
+ return;
- if((changes & GCDashList) && infoRec->ComputeDash)
- infoRec->ComputeDash(pGC);
+ if ((changes & GCDashList) && infoRec->ComputeDash)
+ infoRec->ComputeDash(pGC);
- if(changes & infoRec->FillSpansMask)
- (*infoRec->ValidateFillSpans)(pGC, changes, pDraw);
+ if (changes & infoRec->FillSpansMask)
+ (*infoRec->ValidateFillSpans) (pGC, changes, pDraw);
- if(changes & infoRec->SetSpansMask)
- (*infoRec->ValidateSetSpans)(pGC, changes, pDraw);
+ if (changes & infoRec->SetSpansMask)
+ (*infoRec->ValidateSetSpans) (pGC, changes, pDraw);
- if(changes & infoRec->PutImageMask)
- (*infoRec->ValidatePutImage)(pGC, changes, pDraw);
+ if (changes & infoRec->PutImageMask)
+ (*infoRec->ValidatePutImage) (pGC, changes, pDraw);
- if(changes & infoRec->CopyAreaMask)
- (*infoRec->ValidateCopyArea)(pGC, changes, pDraw);
+ if (changes & infoRec->CopyAreaMask)
+ (*infoRec->ValidateCopyArea) (pGC, changes, pDraw);
- if(changes & infoRec->CopyPlaneMask)
- (*infoRec->ValidateCopyPlane)(pGC, changes, pDraw);
+ if (changes & infoRec->CopyPlaneMask)
+ (*infoRec->ValidateCopyPlane) (pGC, changes, pDraw);
- if(changes & infoRec->PolyPointMask)
- (*infoRec->ValidatePolyPoint)(pGC, changes, pDraw);
+ if (changes & infoRec->PolyPointMask)
+ (*infoRec->ValidatePolyPoint) (pGC, changes, pDraw);
- if(changes & infoRec->PolylinesMask)
- (*infoRec->ValidatePolylines)(pGC, changes, pDraw);
+ if (changes & infoRec->PolylinesMask)
+ (*infoRec->ValidatePolylines) (pGC, changes, pDraw);
- if(changes & infoRec->PolySegmentMask)
- (*infoRec->ValidatePolySegment)(pGC, changes, pDraw);
+ if (changes & infoRec->PolySegmentMask)
+ (*infoRec->ValidatePolySegment) (pGC, changes, pDraw);
- if(changes & infoRec->PolyRectangleMask)
- (*infoRec->ValidatePolyRectangle)(pGC, changes, pDraw);
+ if (changes & infoRec->PolyRectangleMask)
+ (*infoRec->ValidatePolyRectangle) (pGC, changes, pDraw);
- if(changes & infoRec->PolyArcMask)
- (*infoRec->ValidatePolyArc)(pGC, changes, pDraw);
+ if (changes & infoRec->PolyArcMask)
+ (*infoRec->ValidatePolyArc) (pGC, changes, pDraw);
- if(changes & infoRec->FillPolygonMask)
- (*infoRec->ValidateFillPolygon)(pGC, changes, pDraw);
+ if (changes & infoRec->FillPolygonMask)
+ (*infoRec->ValidateFillPolygon) (pGC, changes, pDraw);
- if(changes & infoRec->PolyFillRectMask)
- (*infoRec->ValidatePolyFillRect)(pGC, changes, pDraw);
-
- if(changes & infoRec->PolyFillArcMask)
- (*infoRec->ValidatePolyFillArc)(pGC, changes, pDraw);
+ if (changes & infoRec->PolyFillRectMask)
+ (*infoRec->ValidatePolyFillRect) (pGC, changes, pDraw);
- if(changes & infoRec->PolyGlyphBltMask)
- (*infoRec->ValidatePolyGlyphBlt)(pGC, changes, pDraw);
+ if (changes & infoRec->PolyFillArcMask)
+ (*infoRec->ValidatePolyFillArc) (pGC, changes, pDraw);
- if(changes & infoRec->ImageGlyphBltMask)
- (*infoRec->ValidateImageGlyphBlt)(pGC, changes, pDraw);
+ if (changes & infoRec->PolyGlyphBltMask)
+ (*infoRec->ValidatePolyGlyphBlt) (pGC, changes, pDraw);
- if(changes & infoRec->PolyText8Mask)
- (*infoRec->ValidatePolyText8)(pGC, changes, pDraw);
-
- if(changes & infoRec->PolyText16Mask)
- (*infoRec->ValidatePolyText16)(pGC, changes, pDraw);
+ if (changes & infoRec->ImageGlyphBltMask)
+ (*infoRec->ValidateImageGlyphBlt) (pGC, changes, pDraw);
- if(changes & infoRec->ImageText8Mask)
- (*infoRec->ValidateImageText8)(pGC, changes, pDraw);
-
- if(changes & infoRec->ImageText16Mask)
- (*infoRec->ValidateImageText16)(pGC, changes, pDraw);
-
- if(changes & infoRec->PushPixelsMask)
- (*infoRec->ValidatePushPixels)(pGC, changes, pDraw);
-}
+ if (changes & infoRec->PolyText8Mask)
+ (*infoRec->ValidatePolyText8) (pGC, changes, pDraw);
+ if (changes & infoRec->PolyText16Mask)
+ (*infoRec->ValidatePolyText16) (pGC, changes, pDraw);
+
+ if (changes & infoRec->ImageText8Mask)
+ (*infoRec->ValidateImageText8) (pGC, changes, pDraw);
+
+ if (changes & infoRec->ImageText16Mask)
+ (*infoRec->ValidateImageText16) (pGC, changes, pDraw);
+
+ if (changes & infoRec->PushPixelsMask)
+ (*infoRec->ValidatePushPixels) (pGC, changes, pDraw);
+}
static void
XAADestroyGC(GCPtr pGC)
{
- XAA_GC_FUNC_PROLOGUE (pGC);
-
- if(pGCPriv->XAAOps != &XAAFallbackOps)
- free(pGCPriv->XAAOps);
+ XAA_GC_FUNC_PROLOGUE(pGC);
+
+ if (pGCPriv->XAAOps != &XAAFallbackOps)
+ free(pGCPriv->XAAOps);
free(pGCPriv->DashPattern);
pGCPriv->flags = 0;
- (*pGC->funcs->DestroyGC)(pGC);
- XAA_GC_FUNC_EPILOGUE (pGC);
+ (*pGC->funcs->DestroyGC) (pGC);
+ XAA_GC_FUNC_EPILOGUE(pGC);
}
static void
-XAAChangeGC (
- GCPtr pGC,
- unsigned long mask
-)
+XAAChangeGC(GCPtr pGC, unsigned long mask)
{
- XAA_GC_FUNC_PROLOGUE (pGC);
+ XAA_GC_FUNC_PROLOGUE(pGC);
(*pGC->funcs->ChangeGC) (pGC, mask);
- XAA_GC_FUNC_EPILOGUE (pGC);
+ XAA_GC_FUNC_EPILOGUE(pGC);
- /* we have to assume that shared memory pixmaps are dirty
- because we can't wrap all operations on them */
+ /* we have to assume that shared memory pixmaps are dirty
+ because we can't wrap all operations on them */
- if((mask & GCTile) && !pGC->tileIsPixel &&
- PIXMAP_IS_SHARED(pGC->tile.pixmap))
- {
- XAAPixmapPtr pPixPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
- pPixPriv->flags |= DIRTY;
+ if ((mask & GCTile) && !pGC->tileIsPixel &&
+ PIXMAP_IS_SHARED(pGC->tile.pixmap)) {
+ XAAPixmapPtr pPixPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
+
+ pPixPriv->flags |= DIRTY;
}
- if((mask & GCStipple) && PIXMAP_IS_SHARED(pGC->stipple)){
- XAAPixmapPtr pPixPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
- pPixPriv->flags |= DIRTY;
+ if ((mask & GCStipple) && PIXMAP_IS_SHARED(pGC->stipple)) {
+ XAAPixmapPtr pPixPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
+
+ pPixPriv->flags |= DIRTY;
}
}
static void
-XAACopyGC (
- GCPtr pGCSrc,
- unsigned long mask,
- GCPtr pGCDst)
+XAACopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
{
- XAA_GC_FUNC_PROLOGUE (pGCDst);
+ XAA_GC_FUNC_PROLOGUE(pGCDst);
(*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
- XAA_GC_FUNC_EPILOGUE (pGCDst);
+ XAA_GC_FUNC_EPILOGUE(pGCDst);
}
+
static void
-XAAChangeClip (
- GCPtr pGC,
- int type,
- pointer pvalue,
- int nrects )
+XAAChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects)
{
- XAA_GC_FUNC_PROLOGUE (pGC);
+ XAA_GC_FUNC_PROLOGUE(pGC);
(*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
- XAA_GC_FUNC_EPILOGUE (pGC);
+ XAA_GC_FUNC_EPILOGUE(pGC);
}
static void
XAACopyClip(GCPtr pgcDst, GCPtr pgcSrc)
{
- XAA_GC_FUNC_PROLOGUE (pgcDst);
- (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
- XAA_GC_FUNC_EPILOGUE (pgcDst);
+ XAA_GC_FUNC_PROLOGUE(pgcDst);
+ (*pgcDst->funcs->CopyClip) (pgcDst, pgcSrc);
+ XAA_GC_FUNC_EPILOGUE(pgcDst);
}
static void
XAADestroyClip(GCPtr pGC)
{
- XAA_GC_FUNC_PROLOGUE (pGC);
- (* pGC->funcs->DestroyClip)(pGC);
- XAA_GC_FUNC_EPILOGUE (pGC);
+ XAA_GC_FUNC_PROLOGUE(pGC);
+ (*pGC->funcs->DestroyClip) (pGC);
+ XAA_GC_FUNC_EPILOGUE(pGC);
}
-
-/**** Pixmap Wrappers ****/
-
+/**** Pixmap Wrappers ****/
static void
-XAAFillSpansPixmap(
- DrawablePtr pDraw,
- GC *pGC,
- int nInit,
- DDXPointPtr pptInit,
- int *pwidthInit,
- int fSorted
-){
- XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
+XAAFillSpansPixmap(DrawablePtr pDraw,
+ GC * pGC,
+ int nInit, DDXPointPtr pptInit, int *pwidthInit, int fSorted)
+{
+ XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->FillSpans) (pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
XAA_PIXMAP_OP_EPILOGUE(pGC);
}
static void
-XAASetSpansPixmap(
- DrawablePtr pDraw,
- GCPtr pGC,
- char *pcharsrc,
- register DDXPointPtr ppt,
- int *pwidth,
- int nspans,
- int fSorted
-){
+XAASetSpansPixmap(DrawablePtr pDraw,
+ GCPtr pGC,
+ char *pcharsrc,
+ register DDXPointPtr ppt,
+ int *pwidth, int nspans, int fSorted)
+{
XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted);
+ (*pGC->ops->SetSpans) (pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted);
XAA_PIXMAP_OP_EPILOGUE(pGC);
}
static void
-XAAPutImagePixmap(
- DrawablePtr pDraw,
- GCPtr pGC,
- int depth,
- int x, int y, int w, int h,
- int leftPad,
- int format,
- char *pImage
-){
+XAAPutImagePixmap(DrawablePtr pDraw,
+ GCPtr pGC,
+ int depth,
+ int x, int y, int w, int h,
+ int leftPad, int format, char *pImage)
+{
XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h,
- leftPad, format, pImage);
+ (*pGC->ops->PutImage) (pDraw, pGC, depth, x, y, w, h,
+ leftPad, format, pImage);
XAA_PIXMAP_OP_EPILOGUE(pGC);
}
static RegionPtr
-XAACopyAreaPixmap(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GC *pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty
-){
+XAACopyAreaPixmap(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GC * pGC,
+ int srcx, int srcy, int width, int height, int dstx, int dsty)
+{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
RegionPtr ret;
- if(infoRec->pScrn->vtSema &&
- ((pSrc->type == DRAWABLE_WINDOW) || IS_OFFSCREEN_PIXMAP(pSrc)))
- {
- if(infoRec->ReadPixmap && (pGC->alu == GXcopy) &&
- (pSrc->bitsPerPixel == pDst->bitsPerPixel) &&
- ((pGC->planemask & infoRec->FullPlanemasks[pSrc->depth - 1])
- == infoRec->FullPlanemasks[pSrc->depth - 1]))
- {
- XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pDst));
- pixPriv->flags |= DIRTY;
-
- return (XAABitBlt( pSrc, pDst, pGC,
- srcx, srcy, width, height, dstx, dsty,
- XAADoImageRead, 0L));
- } else
- if(infoRec->NeedToSync) {
- (*infoRec->Sync)(infoRec->pScrn);
- infoRec->NeedToSync = FALSE;
- }
- }
+ if (infoRec->pScrn->vtSema &&
+ ((pSrc->type == DRAWABLE_WINDOW) || IS_OFFSCREEN_PIXMAP(pSrc))) {
+ if (infoRec->ReadPixmap && (pGC->alu == GXcopy) &&
+ (pSrc->bitsPerPixel == pDst->bitsPerPixel) &&
+ ((pGC->planemask & infoRec->FullPlanemasks[pSrc->depth - 1])
+ == infoRec->FullPlanemasks[pSrc->depth - 1])) {
+ XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE((PixmapPtr) (pDst));
+
+ pixPriv->flags |= DIRTY;
+
+ return (XAABitBlt(pSrc, pDst, pGC,
+ srcx, srcy, width, height, dstx, dsty,
+ XAADoImageRead, 0L));
+ }
+ else if (infoRec->NeedToSync) {
+ (*infoRec->Sync) (infoRec->pScrn);
+ infoRec->NeedToSync = FALSE;
+ }
+ }
{
- XAA_PIXMAP_OP_PROLOGUE(pGC, pDst);
- ret = (*pGC->ops->CopyArea)(pSrc, pDst,
- pGC, srcx, srcy, width, height, dstx, dsty);
- XAA_PIXMAP_OP_EPILOGUE(pGC);
+ XAA_PIXMAP_OP_PROLOGUE(pGC, pDst);
+ ret = (*pGC->ops->CopyArea) (pSrc, pDst,
+ pGC, srcx, srcy, width, height, dstx,
+ dsty);
+ XAA_PIXMAP_OP_EPILOGUE(pGC);
}
return ret;
}
static RegionPtr
-XAACopyPlanePixmap(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GCPtr pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty,
- unsigned long bitPlane
-){
+XAACopyPlanePixmap(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx, int srcy,
+ int width, int height,
+ int dstx, int dsty, unsigned long bitPlane)
+{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
RegionPtr ret;
XAA_PIXMAP_OP_PROLOGUE(pGC, pDst);
- if(infoRec->pScrn->vtSema &&
- ((pSrc->type == DRAWABLE_WINDOW) || IS_OFFSCREEN_PIXMAP(pSrc))){
- if(infoRec->NeedToSync) {
- (*infoRec->Sync)(infoRec->pScrn);
- infoRec->NeedToSync = FALSE;
- }
- }
+ if (infoRec->pScrn->vtSema &&
+ ((pSrc->type == DRAWABLE_WINDOW) || IS_OFFSCREEN_PIXMAP(pSrc))) {
+ if (infoRec->NeedToSync) {
+ (*infoRec->Sync) (infoRec->pScrn);
+ infoRec->NeedToSync = FALSE;
+ }
+ }
- ret = (*pGC->ops->CopyPlane)(pSrc, pDst,
- pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
+ ret = (*pGC->ops->CopyPlane) (pSrc, pDst,
+ pGC, srcx, srcy, width, height, dstx, dsty,
+ bitPlane);
XAA_PIXMAP_OP_EPILOGUE(pGC);
return ret;
}
static void
-XAAPolyPointPixmap(
- DrawablePtr pDraw,
- GCPtr pGC,
- int mode,
- int npt,
- xPoint *pptInit
-){
+XAAPolyPointPixmap(DrawablePtr pDraw,
+ GCPtr pGC, int mode, int npt, xPoint * pptInit)
+{
XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit);
+ (*pGC->ops->PolyPoint) (pDraw, pGC, mode, npt, pptInit);
XAA_PIXMAP_OP_EPILOGUE(pGC);
}
-
static void
-XAAPolylinesPixmap(
- DrawablePtr pDraw,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr pptInit
-){
+XAAPolylinesPixmap(DrawablePtr pDraw,
+ GCPtr pGC, int mode, int npt, DDXPointPtr pptInit)
+{
XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit);
+ (*pGC->ops->Polylines) (pDraw, pGC, mode, npt, pptInit);
XAA_PIXMAP_OP_EPILOGUE(pGC);
}
-static void
-XAAPolySegmentPixmap(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nseg,
- xSegment *pSeg
-){
+static void
+XAAPolySegmentPixmap(DrawablePtr pDraw, GCPtr pGC, int nseg, xSegment * pSeg)
+{
XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg);
+ (*pGC->ops->PolySegment) (pDraw, pGC, nseg, pSeg);
XAA_PIXMAP_OP_EPILOGUE(pGC);
}
static void
-XAAPolyRectanglePixmap(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nRectsInit,
- xRectangle *pRectsInit
-){
+XAAPolyRectanglePixmap(DrawablePtr pDraw,
+ GCPtr pGC, int nRectsInit, xRectangle *pRectsInit)
+{
XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit);
+ (*pGC->ops->PolyRectangle) (pDraw, pGC, nRectsInit, pRectsInit);
XAA_PIXMAP_OP_EPILOGUE(pGC);
}
static void
-XAAPolyArcPixmap(
- DrawablePtr pDraw,
- GCPtr pGC,
- int narcs,
- xArc *parcs
-){
+XAAPolyArcPixmap(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
+{
XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs);
+ (*pGC->ops->PolyArc) (pDraw, pGC, narcs, parcs);
XAA_PIXMAP_OP_EPILOGUE(pGC);
}
static void
-XAAFillPolygonPixmap(
- DrawablePtr pDraw,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
-){
+XAAFillPolygonPixmap(DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape, int mode, int count, DDXPointPtr ptsIn)
+{
XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn);
+ (*pGC->ops->FillPolygon) (pDraw, pGC, shape, mode, count, ptsIn);
XAA_PIXMAP_OP_EPILOGUE(pGC);
}
-
-static void
-XAAPolyFillRectPixmap(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nrectFill,
- xRectangle *prectInit
-){
+static void
+XAAPolyFillRectPixmap(DrawablePtr pDraw,
+ GCPtr pGC, int nrectFill, xRectangle *prectInit)
+{
XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->PolyFillRect)(pDraw, pGC, nrectFill, prectInit);
+ (*pGC->ops->PolyFillRect) (pDraw, pGC, nrectFill, prectInit);
XAA_PIXMAP_OP_EPILOGUE(pGC);
}
-
static void
-XAAPolyFillArcPixmap(
- DrawablePtr pDraw,
- GCPtr pGC,
- int narcs,
- xArc *parcs
-){
+XAAPolyFillArcPixmap(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
+{
XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs);
+ (*pGC->ops->PolyFillArc) (pDraw, pGC, narcs, parcs);
XAA_PIXMAP_OP_EPILOGUE(pGC);
}
static int
-XAAPolyText8Pixmap(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- char *chars
-){
+XAAPolyText8Pixmap(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars)
+{
int ret;
XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw);
- ret = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars);
+ ret = (*pGC->ops->PolyText8) (pDraw, pGC, x, y, count, chars);
XAA_PIXMAP_OP_EPILOGUE(pGC);
return ret;
}
static int
-XAAPolyText16Pixmap(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- unsigned short *chars
-){
+XAAPolyText16Pixmap(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, unsigned short *chars)
+{
int ret;
XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw);
- ret = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars);
+ ret = (*pGC->ops->PolyText16) (pDraw, pGC, x, y, count, chars);
XAA_PIXMAP_OP_EPILOGUE(pGC);
return ret;
}
static void
-XAAImageText8Pixmap(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- char *chars
-){
+XAAImageText8Pixmap(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars)
+{
XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars);
+ (*pGC->ops->ImageText8) (pDraw, pGC, x, y, count, chars);
XAA_PIXMAP_OP_EPILOGUE(pGC);
}
+
static void
-XAAImageText16Pixmap(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- unsigned short *chars
-){
+XAAImageText16Pixmap(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, unsigned short *chars)
+{
XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars);
+ (*pGC->ops->ImageText16) (pDraw, pGC, x, y, count, chars);
XAA_PIXMAP_OP_EPILOGUE(pGC);
}
-
static void
-XAAImageGlyphBltPixmap(
- DrawablePtr pDraw,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase
-){
+XAAImageGlyphBltPixmap(DrawablePtr pDraw,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase)
+{
XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph,
- ppci, pglyphBase);
+ (*pGC->ops->ImageGlyphBlt) (pDraw, pGC, xInit, yInit, nglyph,
+ ppci, pglyphBase);
XAA_PIXMAP_OP_EPILOGUE(pGC);
}
static void
-XAAPolyGlyphBltPixmap(
- DrawablePtr pDraw,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase
-){
+XAAPolyGlyphBltPixmap(DrawablePtr pDraw,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase)
+{
XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph,
- ppci, pglyphBase);
+ (*pGC->ops->PolyGlyphBlt) (pDraw, pGC, xInit, yInit, nglyph,
+ ppci, pglyphBase);
XAA_PIXMAP_OP_EPILOGUE(pGC);
}
static void
-XAAPushPixelsPixmap(
- GCPtr pGC,
- PixmapPtr pBitMap,
- DrawablePtr pDraw,
- int dx, int dy, int xOrg, int yOrg
-){
+XAAPushPixelsPixmap(GCPtr pGC,
+ PixmapPtr pBitMap,
+ DrawablePtr pDraw, int dx, int dy, int xOrg, int yOrg)
+{
XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw);
- (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
+ (*pGC->ops->PushPixels) (pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
XAA_PIXMAP_OP_EPILOGUE(pGC);
}
GCOps XAAPixmapOps = {
- XAAFillSpansPixmap, XAASetSpansPixmap,
- XAAPutImagePixmap, XAACopyAreaPixmap,
- XAACopyPlanePixmap, XAAPolyPointPixmap,
- XAAPolylinesPixmap, XAAPolySegmentPixmap,
- XAAPolyRectanglePixmap, XAAPolyArcPixmap,
- XAAFillPolygonPixmap, XAAPolyFillRectPixmap,
- XAAPolyFillArcPixmap, XAAPolyText8Pixmap,
- XAAPolyText16Pixmap, XAAImageText8Pixmap,
- XAAImageText16Pixmap, XAAImageGlyphBltPixmap,
+ XAAFillSpansPixmap, XAASetSpansPixmap,
+ XAAPutImagePixmap, XAACopyAreaPixmap,
+ XAACopyPlanePixmap, XAAPolyPointPixmap,
+ XAAPolylinesPixmap, XAAPolySegmentPixmap,
+ XAAPolyRectanglePixmap, XAAPolyArcPixmap,
+ XAAFillPolygonPixmap, XAAPolyFillRectPixmap,
+ XAAPolyFillArcPixmap, XAAPolyText8Pixmap,
+ XAAPolyText16Pixmap, XAAImageText8Pixmap,
+ XAAImageText16Pixmap, XAAImageGlyphBltPixmap,
XAAPolyGlyphBltPixmap, XAAPushPixelsPixmap,
};
diff --git a/xorg-server/hw/xfree86/xaa/xaaGCmisc.c b/xorg-server/hw/xfree86/xaa/xaaGCmisc.c
index 5823cc064..ca69aae74 100644
--- a/xorg-server/hw/xfree86/xaa/xaaGCmisc.c
+++ b/xorg-server/hw/xfree86/xaa/xaaGCmisc.c
@@ -20,162 +20,149 @@
#include "pixmapstr.h"
void
-XAAValidateCopyArea(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw )
+XAAValidateCopyArea(GCPtr pGC, unsigned long changes, DrawablePtr pDraw)
{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-
- if(infoRec->CopyArea &&
- CHECK_PLANEMASK(pGC,infoRec->CopyAreaFlags) &&
- CHECK_ROP(pGC,infoRec->CopyAreaFlags) &&
- CHECK_ROPSRC(pGC,infoRec->CopyAreaFlags)
- )
- pGC->ops->CopyArea = infoRec->CopyArea;
- else
- pGC->ops->CopyArea = XAAFallbackOps.CopyArea;
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
+ if (infoRec->CopyArea &&
+ CHECK_PLANEMASK(pGC, infoRec->CopyAreaFlags) &&
+ CHECK_ROP(pGC, infoRec->CopyAreaFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->CopyAreaFlags)
+ )
+ pGC->ops->CopyArea = infoRec->CopyArea;
+ else
+ pGC->ops->CopyArea = XAAFallbackOps.CopyArea;
}
void
-XAAValidatePutImage(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw )
+XAAValidatePutImage(GCPtr pGC, unsigned long changes, DrawablePtr pDraw)
{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-
- if(infoRec->PutImage &&
- CHECK_PLANEMASK(pGC,infoRec->PutImageFlags) &&
- CHECK_ROP(pGC,infoRec->PutImageFlags) &&
- CHECK_ROPSRC(pGC,infoRec->PutImageFlags) &&
- CHECK_COLORS(pGC,infoRec->PutImageFlags)
- )
- pGC->ops->PutImage = infoRec->PutImage;
- else
- pGC->ops->PutImage = XAAFallbackOps.PutImage;
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
+ if (infoRec->PutImage &&
+ CHECK_PLANEMASK(pGC, infoRec->PutImageFlags) &&
+ CHECK_ROP(pGC, infoRec->PutImageFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->PutImageFlags) &&
+ CHECK_COLORS(pGC, infoRec->PutImageFlags)
+ )
+ pGC->ops->PutImage = infoRec->PutImage;
+ else
+ pGC->ops->PutImage = XAAFallbackOps.PutImage;
}
void
-XAAValidateCopyPlane(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw )
+XAAValidateCopyPlane(GCPtr pGC, unsigned long changes, DrawablePtr pDraw)
{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-
- if(infoRec->CopyPlane &&
- CHECK_PLANEMASK(pGC,infoRec->CopyPlaneFlags) &&
- CHECK_ROP(pGC,infoRec->CopyPlaneFlags) &&
- CHECK_ROPSRC(pGC,infoRec->CopyPlaneFlags) &&
- CHECK_COLORS(pGC,infoRec->CopyPlaneFlags)
- )
- pGC->ops->CopyPlane = infoRec->CopyPlane;
- else
- pGC->ops->CopyPlane = XAAFallbackOps.CopyPlane;
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
+ if (infoRec->CopyPlane &&
+ CHECK_PLANEMASK(pGC, infoRec->CopyPlaneFlags) &&
+ CHECK_ROP(pGC, infoRec->CopyPlaneFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->CopyPlaneFlags) &&
+ CHECK_COLORS(pGC, infoRec->CopyPlaneFlags)
+ )
+ pGC->ops->CopyPlane = infoRec->CopyPlane;
+ else
+ pGC->ops->CopyPlane = XAAFallbackOps.CopyPlane;
}
void
-XAAValidatePushPixels(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw )
+XAAValidatePushPixels(GCPtr pGC, unsigned long changes, DrawablePtr pDraw)
{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-
- if(infoRec->PushPixelsSolid &&
- (pGC->fillStyle == FillSolid) &&
- CHECK_PLANEMASK(pGC,infoRec->PushPixelsFlags) &&
- CHECK_ROP(pGC,infoRec->PushPixelsFlags) &&
- CHECK_ROPSRC(pGC,infoRec->PushPixelsFlags) &&
- CHECK_FG(pGC,infoRec->PushPixelsFlags) &&
- (!(infoRec->PushPixelsFlags & TRANSPARENCY_GXCOPY_ONLY) ||
- (pGC->alu == GXcopy))
- )
- pGC->ops->PushPixels = infoRec->PushPixelsSolid;
- else
- pGC->ops->PushPixels = XAAFallbackOps.PushPixels;
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
+ if (infoRec->PushPixelsSolid &&
+ (pGC->fillStyle == FillSolid) &&
+ CHECK_PLANEMASK(pGC, infoRec->PushPixelsFlags) &&
+ CHECK_ROP(pGC, infoRec->PushPixelsFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->PushPixelsFlags) &&
+ CHECK_FG(pGC, infoRec->PushPixelsFlags) &&
+ (!(infoRec->PushPixelsFlags & TRANSPARENCY_GXCOPY_ONLY) ||
+ (pGC->alu == GXcopy))
+ )
+ pGC->ops->PushPixels = infoRec->PushPixelsSolid;
+ else
+ pGC->ops->PushPixels = XAAFallbackOps.PushPixels;
}
-
/* We make the assumption that the FillSpans, PolyFillRect, FillPolygon
and PolyFillArc functions are linked in a way that they all have
the same rop/color/planemask restrictions. If the driver provides
a GC level replacement for these, it will need to supply a new
Validate functions if it breaks this assumption */
-
void
-XAAValidateFillSpans(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw )
+XAAValidateFillSpans(GCPtr pGC, unsigned long changes, DrawablePtr pDraw)
{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-
- if(pGC->fillStyle != FillTiled) changes &= ~GCTile;
- if((pGC->fillStyle == FillTiled) || (pGC->fillStyle == FillSolid))
- changes &= ~GCStipple;
- if(!changes) return;
-
-
- pGC->ops->FillSpans = XAAFallbackOps.FillSpans;
- pGC->ops->PolyFillRect = XAAFallbackOps.PolyFillRect;
- pGC->ops->FillPolygon = XAAFallbackOps.FillPolygon;
- pGC->ops->PolyFillArc = XAAFallbackOps.PolyFillArc;
-
- switch(pGC->fillStyle){
- case FillSolid:
- if(infoRec->FillSpansSolid &&
- CHECK_PLANEMASK(pGC,infoRec->FillSpansSolidFlags) &&
- CHECK_ROP(pGC,infoRec->FillSpansSolidFlags) &&
- CHECK_ROPSRC(pGC,infoRec->FillSpansSolidFlags) &&
- CHECK_FG(pGC,infoRec->FillSpansSolidFlags)
- ) {
- pGC->ops->FillSpans = infoRec->FillSpansSolid;
- pGC->ops->PolyFillRect = infoRec->PolyFillRectSolid;
- pGC->ops->FillPolygon = infoRec->FillPolygonSolid;
- pGC->ops->PolyFillArc = infoRec->PolyFillArcSolid;
- }
- break;
- /* The [Stippled/OpaqueStippled/Tiled]FillChooser
- functions do the validating */
- case FillStippled:
- if(infoRec->FillSpansStippled) {
- pGC->ops->FillSpans = infoRec->FillSpansStippled;
- pGC->ops->PolyFillRect = infoRec->PolyFillRectStippled;
- if(infoRec->FillPolygonStippled)
- pGC->ops->FillPolygon = infoRec->FillPolygonStippled;
- else pGC->ops->FillPolygon = miFillPolygon;
- pGC->ops->PolyFillArc = miPolyFillArc;
- }
- break;
- case FillOpaqueStippled:
- if(infoRec->FillSpansOpaqueStippled) {
- pGC->ops->FillSpans = infoRec->FillSpansOpaqueStippled;
- pGC->ops->PolyFillRect = infoRec->PolyFillRectOpaqueStippled;
- if(infoRec->FillPolygonOpaqueStippled)
- pGC->ops->FillPolygon = infoRec->FillPolygonOpaqueStippled;
- else pGC->ops->FillPolygon = miFillPolygon;
- pGC->ops->PolyFillArc = miPolyFillArc;
- }
- break;
- case FillTiled:
- if(infoRec->FillSpansTiled) {
- pGC->ops->FillSpans = infoRec->FillSpansTiled;
- pGC->ops->PolyFillRect = infoRec->PolyFillRectTiled;
- if(infoRec->FillPolygonTiled)
- pGC->ops->FillPolygon = infoRec->FillPolygonTiled;
- else pGC->ops->FillPolygon = miFillPolygon;
- pGC->ops->PolyFillArc = miPolyFillArc;
- }
- break;
- default: return;
- }
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
+ if (pGC->fillStyle != FillTiled)
+ changes &= ~GCTile;
+ if ((pGC->fillStyle == FillTiled) || (pGC->fillStyle == FillSolid))
+ changes &= ~GCStipple;
+ if (!changes)
+ return;
+
+ pGC->ops->FillSpans = XAAFallbackOps.FillSpans;
+ pGC->ops->PolyFillRect = XAAFallbackOps.PolyFillRect;
+ pGC->ops->FillPolygon = XAAFallbackOps.FillPolygon;
+ pGC->ops->PolyFillArc = XAAFallbackOps.PolyFillArc;
+
+ switch (pGC->fillStyle) {
+ case FillSolid:
+ if (infoRec->FillSpansSolid &&
+ CHECK_PLANEMASK(pGC, infoRec->FillSpansSolidFlags) &&
+ CHECK_ROP(pGC, infoRec->FillSpansSolidFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->FillSpansSolidFlags) &&
+ CHECK_FG(pGC, infoRec->FillSpansSolidFlags)
+ ) {
+ pGC->ops->FillSpans = infoRec->FillSpansSolid;
+ pGC->ops->PolyFillRect = infoRec->PolyFillRectSolid;
+ pGC->ops->FillPolygon = infoRec->FillPolygonSolid;
+ pGC->ops->PolyFillArc = infoRec->PolyFillArcSolid;
+ }
+ break;
+ /* The [Stippled/OpaqueStippled/Tiled]FillChooser
+ functions do the validating */
+ case FillStippled:
+ if (infoRec->FillSpansStippled) {
+ pGC->ops->FillSpans = infoRec->FillSpansStippled;
+ pGC->ops->PolyFillRect = infoRec->PolyFillRectStippled;
+ if (infoRec->FillPolygonStippled)
+ pGC->ops->FillPolygon = infoRec->FillPolygonStippled;
+ else
+ pGC->ops->FillPolygon = miFillPolygon;
+ pGC->ops->PolyFillArc = miPolyFillArc;
+ }
+ break;
+ case FillOpaqueStippled:
+ if (infoRec->FillSpansOpaqueStippled) {
+ pGC->ops->FillSpans = infoRec->FillSpansOpaqueStippled;
+ pGC->ops->PolyFillRect = infoRec->PolyFillRectOpaqueStippled;
+ if (infoRec->FillPolygonOpaqueStippled)
+ pGC->ops->FillPolygon = infoRec->FillPolygonOpaqueStippled;
+ else
+ pGC->ops->FillPolygon = miFillPolygon;
+ pGC->ops->PolyFillArc = miPolyFillArc;
+ }
+ break;
+ case FillTiled:
+ if (infoRec->FillSpansTiled) {
+ pGC->ops->FillSpans = infoRec->FillSpansTiled;
+ pGC->ops->PolyFillRect = infoRec->PolyFillRectTiled;
+ if (infoRec->FillPolygonTiled)
+ pGC->ops->FillPolygon = infoRec->FillPolygonTiled;
+ else
+ pGC->ops->FillPolygon = miFillPolygon;
+ pGC->ops->PolyFillArc = miPolyFillArc;
+ }
+ break;
+ default:
+ return;
+ }
}
-
/* We make the assumption that these Text8/16 and GlyphBlt functions
are linked in a way that they all have the same rop/color/planemask
restrictions. If the driver provides a GC level replacement for
@@ -183,247 +170,243 @@ XAAValidateFillSpans(
this assumption */
void
-XAAValidatePolyGlyphBlt(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw )
+XAAValidatePolyGlyphBlt(GCPtr pGC, unsigned long changes, DrawablePtr pDraw)
{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- Bool BigFont = FALSE;
-
- pGC->ops->PolyText8 = XAAFallbackOps.PolyText8;
- pGC->ops->PolyText16 = XAAFallbackOps.PolyText16;
- pGC->ops->PolyGlyphBlt = XAAFallbackOps.PolyGlyphBlt;
-
- if(!pGC->font) return;
- if(pGC->fillStyle != FillSolid) return;
-
- if((FONTMAXBOUNDS(pGC->font, rightSideBearing) -
- FONTMINBOUNDS(pGC->font, leftSideBearing) > 32))
- BigFont = TRUE;
-
- /* no funny business */
- if((FONTMINBOUNDS(pGC->font, characterWidth) <= 0) ||
- ((FONTASCENT(pGC->font) + FONTDESCENT(pGC->font)) <= 0))
- return;
-
- /* Check for TE Fonts */
- if(!TERMINALFONT(pGC->font) || BigFont) {
- if(infoRec->PolyGlyphBltNonTE &&
- CHECK_PLANEMASK(pGC,infoRec->PolyGlyphBltNonTEFlags) &&
- CHECK_ROP(pGC,infoRec->PolyGlyphBltNonTEFlags) &&
- CHECK_ROPSRC(pGC,infoRec->PolyGlyphBltNonTEFlags) &&
- CHECK_FG(pGC,infoRec->PolyGlyphBltNonTEFlags) &&
- (!(infoRec->PolyGlyphBltNonTEFlags & TRANSPARENCY_GXCOPY_ONLY) ||
- (pGC->alu == GXcopy))
- ) {
- pGC->ops->PolyText8 = infoRec->PolyText8NonTE;
- pGC->ops->PolyText16 = infoRec->PolyText16NonTE;
- pGC->ops->PolyGlyphBlt = infoRec->PolyGlyphBltNonTE;
- }
- } else {
- if(infoRec->PolyGlyphBltTE &&
- CHECK_PLANEMASK(pGC,infoRec->PolyGlyphBltTEFlags) &&
- CHECK_ROP(pGC,infoRec->PolyGlyphBltTEFlags) &&
- CHECK_ROPSRC(pGC,infoRec->PolyGlyphBltNonTEFlags) &&
- CHECK_FG(pGC,infoRec->PolyGlyphBltTEFlags) &&
- (!(infoRec->PolyGlyphBltTEFlags & TRANSPARENCY_GXCOPY_ONLY) ||
- (pGC->alu == GXcopy))
- ) {
- pGC->ops->PolyText8 = infoRec->PolyText8TE;
- pGC->ops->PolyText16 = infoRec->PolyText16TE;
- pGC->ops->PolyGlyphBlt = infoRec->PolyGlyphBltTE;
- }
- }
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ Bool BigFont = FALSE;
+
+ pGC->ops->PolyText8 = XAAFallbackOps.PolyText8;
+ pGC->ops->PolyText16 = XAAFallbackOps.PolyText16;
+ pGC->ops->PolyGlyphBlt = XAAFallbackOps.PolyGlyphBlt;
+
+ if (!pGC->font)
+ return;
+ if (pGC->fillStyle != FillSolid)
+ return;
+
+ if ((FONTMAXBOUNDS(pGC->font, rightSideBearing) -
+ FONTMINBOUNDS(pGC->font, leftSideBearing) > 32))
+ BigFont = TRUE;
+
+ /* no funny business */
+ if ((FONTMINBOUNDS(pGC->font, characterWidth) <= 0) ||
+ ((FONTASCENT(pGC->font) + FONTDESCENT(pGC->font)) <= 0))
+ return;
+
+ /* Check for TE Fonts */
+ if (!TERMINALFONT(pGC->font) || BigFont) {
+ if (infoRec->PolyGlyphBltNonTE &&
+ CHECK_PLANEMASK(pGC, infoRec->PolyGlyphBltNonTEFlags) &&
+ CHECK_ROP(pGC, infoRec->PolyGlyphBltNonTEFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->PolyGlyphBltNonTEFlags) &&
+ CHECK_FG(pGC, infoRec->PolyGlyphBltNonTEFlags) &&
+ (!(infoRec->PolyGlyphBltNonTEFlags & TRANSPARENCY_GXCOPY_ONLY) ||
+ (pGC->alu == GXcopy))
+ ) {
+ pGC->ops->PolyText8 = infoRec->PolyText8NonTE;
+ pGC->ops->PolyText16 = infoRec->PolyText16NonTE;
+ pGC->ops->PolyGlyphBlt = infoRec->PolyGlyphBltNonTE;
+ }
+ }
+ else {
+ if (infoRec->PolyGlyphBltTE &&
+ CHECK_PLANEMASK(pGC, infoRec->PolyGlyphBltTEFlags) &&
+ CHECK_ROP(pGC, infoRec->PolyGlyphBltTEFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->PolyGlyphBltNonTEFlags) &&
+ CHECK_FG(pGC, infoRec->PolyGlyphBltTEFlags) &&
+ (!(infoRec->PolyGlyphBltTEFlags & TRANSPARENCY_GXCOPY_ONLY) ||
+ (pGC->alu == GXcopy))
+ ) {
+ pGC->ops->PolyText8 = infoRec->PolyText8TE;
+ pGC->ops->PolyText16 = infoRec->PolyText16TE;
+ pGC->ops->PolyGlyphBlt = infoRec->PolyGlyphBltTE;
+ }
+ }
}
void
-XAAValidateImageGlyphBlt(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw )
+XAAValidateImageGlyphBlt(GCPtr pGC, unsigned long changes, DrawablePtr pDraw)
{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- Bool BigFont = FALSE;
-
- pGC->ops->ImageText8 = XAAFallbackOps.ImageText8;
- pGC->ops->ImageText16 = XAAFallbackOps.ImageText16;
- pGC->ops->ImageGlyphBlt = XAAFallbackOps.ImageGlyphBlt;
-
- if(!pGC->font) return;
-
- if((FONTMAXBOUNDS(pGC->font, rightSideBearing) -
- FONTMINBOUNDS(pGC->font, leftSideBearing) > 32))
- BigFont = TRUE;
-
- /* no funny business */
- if((FONTMINBOUNDS(pGC->font, characterWidth) <= 0) ||
- ((FONTASCENT(pGC->font) + FONTDESCENT(pGC->font)) <= 0))
- return;
-
-
- /* Check for TE Fonts */
- if(!TERMINALFONT(pGC->font) || BigFont || (pGC->depth == 32)) {
- if(infoRec->ImageGlyphBltNonTE &&
- CHECK_PLANEMASK(pGC,infoRec->ImageGlyphBltNonTEFlags) &&
- CHECK_FG(pGC,infoRec->ImageGlyphBltNonTEFlags) &&
- infoRec->SetupForSolidFill &&
- CHECK_PLANEMASK(pGC,infoRec->SolidFillFlags) &&
- CHECK_BG(pGC,infoRec->SolidFillFlags))
- {
- pGC->ops->ImageText8 = infoRec->ImageText8NonTE;
- pGC->ops->ImageText16 = infoRec->ImageText16NonTE;
- pGC->ops->ImageGlyphBlt = infoRec->ImageGlyphBltNonTE;
- }
- } else if(infoRec->ImageGlyphBltTE &&
- CHECK_PLANEMASK(pGC,infoRec->ImageGlyphBltTEFlags)){
- if(!(infoRec->ImageGlyphBltTEFlags & TRANSPARENCY_ONLY) &&
- CHECK_COLORS(pGC,infoRec->ImageGlyphBltTEFlags))
- {
- pGC->ops->ImageText8 = infoRec->ImageText8TE;
- pGC->ops->ImageText16 = infoRec->ImageText16TE;
- pGC->ops->ImageGlyphBlt = infoRec->ImageGlyphBltTE;
- } else {
- if(CHECK_FG(pGC,infoRec->ImageGlyphBltTEFlags) &&
- infoRec->SetupForSolidFill &&
- CHECK_PLANEMASK(pGC,infoRec->SolidFillFlags) &&
- CHECK_BG(pGC,infoRec->SolidFillFlags))
- {
- pGC->ops->ImageText8 = infoRec->ImageText8TE;
- pGC->ops->ImageText16 = infoRec->ImageText16TE;
- pGC->ops->ImageGlyphBlt = infoRec->ImageGlyphBltTE;
- }
- }
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ Bool BigFont = FALSE;
+
+ pGC->ops->ImageText8 = XAAFallbackOps.ImageText8;
+ pGC->ops->ImageText16 = XAAFallbackOps.ImageText16;
+ pGC->ops->ImageGlyphBlt = XAAFallbackOps.ImageGlyphBlt;
+
+ if (!pGC->font)
+ return;
+
+ if ((FONTMAXBOUNDS(pGC->font, rightSideBearing) -
+ FONTMINBOUNDS(pGC->font, leftSideBearing) > 32))
+ BigFont = TRUE;
+
+ /* no funny business */
+ if ((FONTMINBOUNDS(pGC->font, characterWidth) <= 0) ||
+ ((FONTASCENT(pGC->font) + FONTDESCENT(pGC->font)) <= 0))
+ return;
+
+ /* Check for TE Fonts */
+ if (!TERMINALFONT(pGC->font) || BigFont || (pGC->depth == 32)) {
+ if (infoRec->ImageGlyphBltNonTE &&
+ CHECK_PLANEMASK(pGC, infoRec->ImageGlyphBltNonTEFlags) &&
+ CHECK_FG(pGC, infoRec->ImageGlyphBltNonTEFlags) &&
+ infoRec->SetupForSolidFill &&
+ CHECK_PLANEMASK(pGC, infoRec->SolidFillFlags) &&
+ CHECK_BG(pGC, infoRec->SolidFillFlags)) {
+ pGC->ops->ImageText8 = infoRec->ImageText8NonTE;
+ pGC->ops->ImageText16 = infoRec->ImageText16NonTE;
+ pGC->ops->ImageGlyphBlt = infoRec->ImageGlyphBltNonTE;
+ }
+ }
+ else if (infoRec->ImageGlyphBltTE &&
+ CHECK_PLANEMASK(pGC, infoRec->ImageGlyphBltTEFlags)) {
+ if (!(infoRec->ImageGlyphBltTEFlags & TRANSPARENCY_ONLY) &&
+ CHECK_COLORS(pGC, infoRec->ImageGlyphBltTEFlags)) {
+ pGC->ops->ImageText8 = infoRec->ImageText8TE;
+ pGC->ops->ImageText16 = infoRec->ImageText16TE;
+ pGC->ops->ImageGlyphBlt = infoRec->ImageGlyphBltTE;
+ }
+ else {
+ if (CHECK_FG(pGC, infoRec->ImageGlyphBltTEFlags) &&
+ infoRec->SetupForSolidFill &&
+ CHECK_PLANEMASK(pGC, infoRec->SolidFillFlags) &&
+ CHECK_BG(pGC, infoRec->SolidFillFlags)) {
+ pGC->ops->ImageText8 = infoRec->ImageText8TE;
+ pGC->ops->ImageText16 = infoRec->ImageText16TE;
+ pGC->ops->ImageGlyphBlt = infoRec->ImageGlyphBltTE;
+ }
+ }
}
}
-
void
-XAAValidatePolylines(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw )
+XAAValidatePolylines(GCPtr pGC, unsigned long changes, DrawablePtr pDraw)
{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates,
- XAAGetGCKey());
-
- if(pGC->lineStyle == LineSolid) changes &= ~GCDashList;
- if(!changes) return;
-
- pGC->ops->PolySegment = XAAFallbackOps.PolySegment;
- pGC->ops->Polylines = XAAFallbackOps.Polylines;
- pGC->ops->PolyRectangle = XAAFallbackOps.PolyRectangle;
- pGC->ops->PolyArc = XAAFallbackOps.PolyArc;
-
- if((pGC->ops->FillSpans != XAAFallbackOps.FillSpans) &&
- (pGC->lineWidth > 0)){
-
- pGC->ops->PolyArc = miPolyArc;
- pGC->ops->PolySegment = miPolySegment;
- pGC->ops->PolyRectangle = miPolyRectangle;
- if(pGC->lineStyle == LineSolid)
- pGC->ops->Polylines = miWideLine;
- else
- pGC->ops->Polylines = miWideDash;
- }
-
- if((pGC->lineWidth == 0) && (pGC->fillStyle == FillSolid)) {
-
- if(pGC->lineStyle == LineSolid) {
-
- if(infoRec->PolyRectangleThinSolid &&
- CHECK_PLANEMASK(pGC,infoRec->PolyRectangleThinSolidFlags) &&
- CHECK_ROP(pGC,infoRec->PolyRectangleThinSolidFlags) &&
- CHECK_ROPSRC(pGC,infoRec->PolyRectangleThinSolidFlags) &&
- CHECK_FG(pGC,infoRec->PolyRectangleThinSolidFlags)) {
-
- pGC->ops->PolyRectangle = infoRec->PolyRectangleThinSolid;
- }
-
- if(infoRec->PolySegmentThinSolid &&
- CHECK_PLANEMASK(pGC,infoRec->PolySegmentThinSolidFlags) &&
- CHECK_ROP(pGC,infoRec->PolySegmentThinSolidFlags) &&
- CHECK_ROPSRC(pGC,infoRec->PolySegmentThinSolidFlags) &&
- CHECK_FG(pGC,infoRec->PolySegmentThinSolidFlags)) {
-
- pGC->ops->PolySegment = infoRec->PolySegmentThinSolid;
- }
-
- if(infoRec->PolylinesThinSolid &&
- CHECK_PLANEMASK(pGC,infoRec->PolylinesThinSolidFlags) &&
- CHECK_ROP(pGC,infoRec->PolylinesThinSolidFlags) &&
- CHECK_ROPSRC(pGC,infoRec->PolylinesThinSolidFlags) &&
- CHECK_FG(pGC,infoRec->PolylinesThinSolidFlags)) {
-
- pGC->ops->Polylines = infoRec->PolylinesThinSolid;
- }
- } else if((pGC->lineStyle == LineOnOffDash) && pGCPriv->DashPattern){
-
- if(infoRec->PolySegmentThinDashed &&
- !(infoRec->PolySegmentThinDashedFlags & NO_TRANSPARENCY) &&
- ((pGC->alu == GXcopy) || !(infoRec->PolySegmentThinDashedFlags &
- TRANSPARENCY_GXCOPY_ONLY)) &&
- CHECK_PLANEMASK(pGC,infoRec->PolySegmentThinDashedFlags) &&
- CHECK_ROP(pGC,infoRec->PolySegmentThinDashedFlags) &&
- CHECK_ROPSRC(pGC,infoRec->PolySegmentThinDashedFlags) &&
- CHECK_FG(pGC,infoRec->PolySegmentThinDashedFlags)) {
-
- pGC->ops->PolySegment = infoRec->PolySegmentThinDashed;
- }
-
- if(infoRec->PolylinesThinDashed &&
- !(infoRec->PolylinesThinDashedFlags & NO_TRANSPARENCY) &&
- ((pGC->alu == GXcopy) || !(infoRec->PolylinesThinDashedFlags &
- TRANSPARENCY_GXCOPY_ONLY)) &&
- CHECK_PLANEMASK(pGC,infoRec->PolylinesThinDashedFlags) &&
- CHECK_ROP(pGC,infoRec->PolylinesThinDashedFlags) &&
- CHECK_ROPSRC(pGC,infoRec->PolylinesThinDashedFlags) &&
- CHECK_FG(pGC,infoRec->PolylinesThinDashedFlags)) {
-
- pGC->ops->Polylines = infoRec->PolylinesThinDashed;
- }
-
- if(pGC->ops->Polylines != XAAFallbackOps.Polylines)
- pGC->ops->PolyRectangle = miPolyRectangle;
-
- } else if(pGCPriv->DashPattern && (pGC->depth != 32)) {
- /* LineDoubleDash */
- if(infoRec->PolySegmentThinDashed &&
- !(infoRec->PolySegmentThinDashedFlags & TRANSPARENCY_ONLY) &&
- CHECK_PLANEMASK(pGC,infoRec->PolySegmentThinDashedFlags) &&
- CHECK_ROP(pGC,infoRec->PolySegmentThinDashedFlags) &&
- CHECK_ROPSRC(pGC,infoRec->PolySegmentThinDashedFlags) &&
- CHECK_COLORS(pGC,infoRec->PolySegmentThinDashedFlags)) {
-
- pGC->ops->PolySegment = infoRec->PolySegmentThinDashed;
- }
-
- if(infoRec->PolylinesThinDashed &&
- !(infoRec->PolylinesThinDashedFlags & TRANSPARENCY_ONLY) &&
- CHECK_PLANEMASK(pGC,infoRec->PolylinesThinDashedFlags) &&
- CHECK_ROP(pGC,infoRec->PolylinesThinDashedFlags) &&
- CHECK_ROPSRC(pGC,infoRec->PolylinesThinDashedFlags) &&
- CHECK_COLORS(pGC,infoRec->PolylinesThinDashedFlags)) {
-
- pGC->ops->Polylines = infoRec->PolylinesThinDashed;
- }
-
- if(pGC->ops->Polylines != XAAFallbackOps.Polylines)
- pGC->ops->PolyRectangle = miPolyRectangle;
-
- }
- }
-
- if(infoRec->PolylinesWideSolid &&
- (pGC->lineWidth > 0) &&
- (pGC->fillStyle == FillSolid) &&
- (pGC->lineStyle == LineSolid) &&
- CHECK_PLANEMASK(pGC,infoRec->PolylinesWideSolidFlags) &&
- CHECK_ROP(pGC,infoRec->PolylinesWideSolidFlags) &&
- CHECK_ROPSRC(pGC,infoRec->PolylinesWideSolidFlags) &&
- CHECK_FG(pGC,infoRec->PolylinesWideSolidFlags)) {
-
- pGC->ops->Polylines = infoRec->PolylinesWideSolid;
- }
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAAGCPtr pGCPriv = (XAAGCPtr) dixLookupPrivate(&pGC->devPrivates,
+ XAAGetGCKey());
+
+ if (pGC->lineStyle == LineSolid)
+ changes &= ~GCDashList;
+ if (!changes)
+ return;
+
+ pGC->ops->PolySegment = XAAFallbackOps.PolySegment;
+ pGC->ops->Polylines = XAAFallbackOps.Polylines;
+ pGC->ops->PolyRectangle = XAAFallbackOps.PolyRectangle;
+ pGC->ops->PolyArc = XAAFallbackOps.PolyArc;
+
+ if ((pGC->ops->FillSpans != XAAFallbackOps.FillSpans) &&
+ (pGC->lineWidth > 0)) {
+
+ pGC->ops->PolyArc = miPolyArc;
+ pGC->ops->PolySegment = miPolySegment;
+ pGC->ops->PolyRectangle = miPolyRectangle;
+ if (pGC->lineStyle == LineSolid)
+ pGC->ops->Polylines = miWideLine;
+ else
+ pGC->ops->Polylines = miWideDash;
+ }
+
+ if ((pGC->lineWidth == 0) && (pGC->fillStyle == FillSolid)) {
+
+ if (pGC->lineStyle == LineSolid) {
+
+ if (infoRec->PolyRectangleThinSolid &&
+ CHECK_PLANEMASK(pGC, infoRec->PolyRectangleThinSolidFlags) &&
+ CHECK_ROP(pGC, infoRec->PolyRectangleThinSolidFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->PolyRectangleThinSolidFlags) &&
+ CHECK_FG(pGC, infoRec->PolyRectangleThinSolidFlags)) {
+
+ pGC->ops->PolyRectangle = infoRec->PolyRectangleThinSolid;
+ }
+
+ if (infoRec->PolySegmentThinSolid &&
+ CHECK_PLANEMASK(pGC, infoRec->PolySegmentThinSolidFlags) &&
+ CHECK_ROP(pGC, infoRec->PolySegmentThinSolidFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->PolySegmentThinSolidFlags) &&
+ CHECK_FG(pGC, infoRec->PolySegmentThinSolidFlags)) {
+
+ pGC->ops->PolySegment = infoRec->PolySegmentThinSolid;
+ }
+
+ if (infoRec->PolylinesThinSolid &&
+ CHECK_PLANEMASK(pGC, infoRec->PolylinesThinSolidFlags) &&
+ CHECK_ROP(pGC, infoRec->PolylinesThinSolidFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->PolylinesThinSolidFlags) &&
+ CHECK_FG(pGC, infoRec->PolylinesThinSolidFlags)) {
+
+ pGC->ops->Polylines = infoRec->PolylinesThinSolid;
+ }
+ }
+ else if ((pGC->lineStyle == LineOnOffDash) && pGCPriv->DashPattern) {
+
+ if (infoRec->PolySegmentThinDashed &&
+ !(infoRec->PolySegmentThinDashedFlags & NO_TRANSPARENCY) &&
+ ((pGC->alu == GXcopy) || !(infoRec->PolySegmentThinDashedFlags &
+ TRANSPARENCY_GXCOPY_ONLY)) &&
+ CHECK_PLANEMASK(pGC, infoRec->PolySegmentThinDashedFlags) &&
+ CHECK_ROP(pGC, infoRec->PolySegmentThinDashedFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->PolySegmentThinDashedFlags) &&
+ CHECK_FG(pGC, infoRec->PolySegmentThinDashedFlags)) {
+
+ pGC->ops->PolySegment = infoRec->PolySegmentThinDashed;
+ }
+
+ if (infoRec->PolylinesThinDashed &&
+ !(infoRec->PolylinesThinDashedFlags & NO_TRANSPARENCY) &&
+ ((pGC->alu == GXcopy) || !(infoRec->PolylinesThinDashedFlags &
+ TRANSPARENCY_GXCOPY_ONLY)) &&
+ CHECK_PLANEMASK(pGC, infoRec->PolylinesThinDashedFlags) &&
+ CHECK_ROP(pGC, infoRec->PolylinesThinDashedFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->PolylinesThinDashedFlags) &&
+ CHECK_FG(pGC, infoRec->PolylinesThinDashedFlags)) {
+
+ pGC->ops->Polylines = infoRec->PolylinesThinDashed;
+ }
+
+ if (pGC->ops->Polylines != XAAFallbackOps.Polylines)
+ pGC->ops->PolyRectangle = miPolyRectangle;
+
+ }
+ else if (pGCPriv->DashPattern && (pGC->depth != 32)) {
+ /* LineDoubleDash */
+ if (infoRec->PolySegmentThinDashed &&
+ !(infoRec->PolySegmentThinDashedFlags & TRANSPARENCY_ONLY) &&
+ CHECK_PLANEMASK(pGC, infoRec->PolySegmentThinDashedFlags) &&
+ CHECK_ROP(pGC, infoRec->PolySegmentThinDashedFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->PolySegmentThinDashedFlags) &&
+ CHECK_COLORS(pGC, infoRec->PolySegmentThinDashedFlags)) {
+
+ pGC->ops->PolySegment = infoRec->PolySegmentThinDashed;
+ }
+
+ if (infoRec->PolylinesThinDashed &&
+ !(infoRec->PolylinesThinDashedFlags & TRANSPARENCY_ONLY) &&
+ CHECK_PLANEMASK(pGC, infoRec->PolylinesThinDashedFlags) &&
+ CHECK_ROP(pGC, infoRec->PolylinesThinDashedFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->PolylinesThinDashedFlags) &&
+ CHECK_COLORS(pGC, infoRec->PolylinesThinDashedFlags)) {
+
+ pGC->ops->Polylines = infoRec->PolylinesThinDashed;
+ }
+
+ if (pGC->ops->Polylines != XAAFallbackOps.Polylines)
+ pGC->ops->PolyRectangle = miPolyRectangle;
+
+ }
+ }
+
+ if (infoRec->PolylinesWideSolid &&
+ (pGC->lineWidth > 0) &&
+ (pGC->fillStyle == FillSolid) &&
+ (pGC->lineStyle == LineSolid) &&
+ CHECK_PLANEMASK(pGC, infoRec->PolylinesWideSolidFlags) &&
+ CHECK_ROP(pGC, infoRec->PolylinesWideSolidFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->PolylinesWideSolidFlags) &&
+ CHECK_FG(pGC, infoRec->PolylinesWideSolidFlags)) {
+
+ pGC->ops->Polylines = infoRec->PolylinesWideSolid;
+ }
}
diff --git a/xorg-server/hw/xfree86/xaa/xaaImage.c b/xorg-server/hw/xfree86/xaa/xaaImage.c
index 1967c5e0e..4457c9efa 100644
--- a/xorg-server/hw/xfree86/xaa/xaaImage.c
+++ b/xorg-server/hw/xfree86/xaa/xaaImage.c
@@ -1,521 +1,534 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-#include "servermd.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "mi.h"
-#include "pixmapstr.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-
-void XAAMoveDWORDS_FixedBase(
- register CARD32* dest,
- register CARD32* src,
- register int dwords )
-{
- while(dwords & ~0x03) {
- *dest = *src;
- *dest = *(src + 1);
- *dest = *(src + 2);
- *dest = *(src + 3);
- dwords -= 4;
- src += 4;
- }
-
- if(!dwords) return;
- *dest = *src;
- if(dwords == 1) return;
- *dest = *(src + 1);
- if(dwords == 2) return;
- *dest = *(src + 2);
-}
-
-void XAAMoveDWORDS(
- register CARD32* dest,
- register CARD32* src,
- register int dwords )
-{
- while(dwords & ~0x03) {
- *dest = *src;
- *(dest + 1) = *(src + 1);
- *(dest + 2) = *(src + 2);
- *(dest + 3) = *(src + 3);
- src += 4;
- dest += 4;
- dwords -= 4;
- }
- if(!dwords) return;
- *dest = *src;
- if(dwords == 1) return;
- *(dest + 1) = *(src + 1);
- if(dwords == 2) return;
- *(dest + 2) = *(src + 2);
-}
-
-void XAAMoveDWORDS_FixedSrc(
- register CARD32* dest,
- register CARD32* src,
- register int dwords )
-{
- while(dwords & ~0x03) {
- *dest = *src;
- *(dest + 1) = *src;
- *(dest + 2) = *src;
- *(dest + 3) = *src;
- dest += 4;
- dwords -= 4;
- }
- if(!dwords) return;
- *dest = *src;
- if(dwords == 1) return;
- *(dest + 1) = *src;
- if(dwords == 2) return;
- *(dest + 2) = *src;
-}
-
-static void
-XAAWritePixmap32To24(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *srcInit,
- int srcwidth, /* bytes */
- int rop,
- unsigned int planemask,
- int trans
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int count, dwords = bytes_to_int32(w * 3);
- CARD32 *src, *dst;
- Bool PlusOne = FALSE;
-
- if((infoRec->ImageWriteFlags & CPU_TRANSFER_PAD_QWORD) &&
- ((dwords * h) & 0x01)) {
- PlusOne = TRUE;
- }
-
- (*infoRec->SetupForImageWrite)(pScrn, rop, planemask, trans, 24, 24);
- (*infoRec->SubsequentImageWriteRect)(pScrn, x, y, w, h, 0);
-
- if(dwords > infoRec->ImageWriteRange) {
- dst = (CARD32*)infoRec->ImageWriteBase;
- while(h--) {
- src = (CARD32*)srcInit;
- count = w;
-
- while(count >= 4) {
- *dst = (src[0] & 0x00ffffff) | (src[1] << 24);
- *dst = ((src[1] >> 8) & 0x0000ffff) | (src[2] << 16);
- *dst = ((src[2] >> 16) & 0x000000ff) | (src[3] << 8);
- src += 4;
- count -= 4;
- }
- switch(count) {
- case 0: break;
- case 1: *dst = src[0];
- break;
- case 2: *dst = (src[0] & 0x00ffffff) | (src[1] << 24);
- *dst = src[1] >> 8;
- break;
- default: *dst = (src[0] & 0x00ffffff) | (src[1] << 24);
- *dst = ((src[1] >> 8) & 0x0000ffff) | (src[2] << 16);
- *dst = src[2] >> 16;
- break;
- }
- srcInit += srcwidth;
- }
- } else {
- while(h--) {
- dst = (CARD32*)infoRec->ImageWriteBase;
- src = (CARD32*)srcInit;
- count = w;
-
- while(count >= 4) {
- dst[0] = (src[0] & 0x00ffffff) | (src[1] << 24);
- dst[1] = ((src[1] >> 8) & 0x0000ffff) | (src[2] << 16);
- dst[2] = ((src[2] >> 16) & 0x000000ff) | (src[3] << 8);
- dst += 3;
- src += 4;
- count -= 4;
- }
- switch(count) {
- case 0: break;
- case 1: dst[0] = src[0];
- break;
- case 2: dst[0] = (src[0] & 0x00ffffff) | (src[1] << 24);
- dst[1] = src[1] >> 8;
- break;
- default: dst[0] = (src[0] & 0x00ffffff) | (src[1] << 24);
- dst[1] = ((src[1] >> 8) & 0x0000ffff) | (src[2] << 16);
- dst[2] = src[2] >> 16;
- break;
- }
- srcInit += srcwidth;
- }
- }
-
- if(PlusOne) {
- CARD32* base = (CARD32*)infoRec->ImageWriteBase;
- *base = 0x00000000;
- }
-
- if(infoRec->ImageWriteFlags & SYNC_AFTER_IMAGE_WRITE)
- (*infoRec->Sync)(pScrn);
- else SET_SYNC_FLAG(infoRec);
-
-}
-
-void
-XAAWritePixmap (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth, /* bytes */
- int rop,
- unsigned int planemask,
- int trans,
- int bpp, int depth
-){
- XAAInfoRecPtr infoRec;
- int dwords, skipleft, Bpp;
- Bool beCareful, PlusOne;
-
- if((bpp == 32) && (pScrn->bitsPerPixel == 24)) {
- XAAWritePixmap32To24(pScrn, x, y, w, h, src, srcwidth,
- rop, planemask, trans);
- return;
- }
-
- infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- beCareful = PlusOne = FALSE;
- Bpp = bpp >> 3;
-
- if((skipleft = (long)src & 0x03L)) {
- if(!(infoRec->ImageWriteFlags & LEFT_EDGE_CLIPPING)) {
- skipleft = 0;
- beCareful = TRUE;
- goto BAD_ALIGNMENT;
- }
-
- if(Bpp == 3)
- skipleft = 4 - skipleft;
- else
- skipleft /= Bpp;
-
- if((x < skipleft) && !(infoRec->ImageWriteFlags &
- LEFT_EDGE_CLIPPING_NEGATIVE_X)) {
- skipleft = 0;
- beCareful = TRUE;
- goto BAD_ALIGNMENT;
- }
-
- x -= skipleft;
- w += skipleft;
-
- if(Bpp == 3)
- src -= 3 * skipleft;
- else /* is this Alpha friendly ? */
- src = (unsigned char*)((long)src & ~0x03L);
- }
-
-BAD_ALIGNMENT:
-
- dwords = bytes_to_int32(w * Bpp);
-
- if((infoRec->ImageWriteFlags & CPU_TRANSFER_PAD_QWORD) &&
- ((dwords * h) & 0x01)) {
- PlusOne = TRUE;
- }
-
-
- (*infoRec->SetupForImageWrite)(pScrn, rop, planemask, trans, bpp, depth);
- (*infoRec->SubsequentImageWriteRect)(pScrn, x, y, w, h, skipleft);
-
- if(beCareful) {
- /* in cases with bad alignment we have to be careful not
- to read beyond the end of the source */
- if(((x * Bpp) + (dwords << 2)) > srcwidth) h--;
- else beCareful = FALSE;
- }
-
- if(dwords > infoRec->ImageWriteRange) {
- while(h--) {
- XAAMoveDWORDS_FixedBase((CARD32*)infoRec->ImageWriteBase,
- (CARD32*)src, dwords);
- src += srcwidth;
- }
- if(beCareful) {
- int shift = ((long)src & 0x03L) << 3;
- if(--dwords)
- XAAMoveDWORDS_FixedBase((CARD32*)infoRec->ImageWriteBase,
- (CARD32*)src, dwords);
- src = (unsigned char*)((long)(src + (dwords << 2)) & ~0x03L);
- *((CARD32*)infoRec->ImageWriteBase) = *((CARD32*)src) >> shift;
- }
- } else {
- if(srcwidth == (dwords << 2)) {
- int decrement = infoRec->ImageWriteRange/dwords;
-
- while(h > decrement) {
- XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase,
- (CARD32*)src, dwords * decrement);
- src += (srcwidth * decrement);
- h -= decrement;
- }
- if(h) {
- XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase,
- (CARD32*)src, dwords * h);
- if(beCareful) src += (srcwidth * h);
- }
- } else {
- while(h--) {
- XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase,
- (CARD32*)src, dwords);
- src += srcwidth;
- }
- }
-
- if(beCareful) {
- int shift = ((long)src & 0x03L) << 3;
- if(--dwords)
- XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase,
- (CARD32*)src, dwords);
- src = (unsigned char*)((long)(src + (dwords << 2)) & ~0x03L);
-
- ((CARD32*)infoRec->ImageWriteBase)[dwords] =
- *((CARD32*)src) >> shift;
- }
- }
-
- if(PlusOne) {
- CARD32* base = (CARD32*)infoRec->ImageWriteBase;
- *base = 0x00000000;
- }
-
- if(infoRec->ImageWriteFlags & SYNC_AFTER_IMAGE_WRITE)
- (*infoRec->Sync)(pScrn);
- else SET_SYNC_FLAG(infoRec);
-}
-
-
-void
-XAAWritePixmapScanline (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth, /* bytes */
- int rop,
- unsigned int planemask,
- int trans,
- int bpp, int depth
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int dwords, skipleft, bufferNo = 0, Bpp = bpp >> 3;
- Bool beCareful = FALSE;
- CARD32* base;
-
- if((skipleft = (long)src & 0x03L)) {
- if(!(infoRec->ScanlineImageWriteFlags & LEFT_EDGE_CLIPPING)) {
- skipleft = 0;
- beCareful = TRUE;
- goto BAD_ALIGNMENT;
- }
-
- if(Bpp == 3)
- skipleft = 4 - skipleft;
- else
- skipleft /= Bpp;
-
- if((x < skipleft) && !(infoRec->ScanlineImageWriteFlags &
- LEFT_EDGE_CLIPPING_NEGATIVE_X)) {
- skipleft = 0;
- beCareful = TRUE;
- goto BAD_ALIGNMENT;
- }
-
- x -= skipleft;
- w += skipleft;
-
- if(Bpp == 3)
- src -= 3 * skipleft;
- else
- src = (unsigned char*)((long)src & ~0x03L);
- }
-
-BAD_ALIGNMENT:
-
- dwords = bytes_to_int32(w * Bpp);
-
- (*infoRec->SetupForScanlineImageWrite)(
- pScrn, rop, planemask, trans, bpp, depth);
- (*infoRec->SubsequentScanlineImageWriteRect)(pScrn, x, y, w, h, skipleft);
-
- if(beCareful) {
- /* in cases with bad alignment we have to be careful not
- to read beyond the end of the source */
- if(((x * Bpp) + (dwords << 2)) > srcwidth) h--;
- else beCareful = FALSE;
- }
-
- while(h--) {
- base = (CARD32*)infoRec->ScanlineImageWriteBuffers[bufferNo];
- XAAMoveDWORDS(base, (CARD32*)src, dwords);
- (*infoRec->SubsequentImageWriteScanline)(pScrn, bufferNo++);
- src += srcwidth;
- if(bufferNo >= infoRec->NumScanlineImageWriteBuffers)
- bufferNo = 0;
- }
-
- if(beCareful) {
- int shift = ((long)src & 0x03L) << 3;
- base = (CARD32*)infoRec->ScanlineImageWriteBuffers[bufferNo];
- if(--dwords)
- XAAMoveDWORDS(base,(CARD32*)src, dwords);
- src = (unsigned char*)((long)(src + (dwords << 2)) & ~0x03L);
-
- base[dwords] = *((CARD32*)src) >> shift;
- (*infoRec->SubsequentImageWriteScanline)(pScrn, bufferNo);
- }
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
-void
-XAAPutImage(
- DrawablePtr pDraw,
- GCPtr pGC,
- int depth,
- int x,
- int y,
- int w,
- int h,
- int leftPad,
- int format,
- char *pImage
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int bpp = BitsPerPixel(depth);
- Bool depthBug = FALSE;
- if(!w || !h) return;
-
- if(!RegionNumRects(pGC->pCompositeClip))
- return;
-
- depthBug = XAA_DEPTH_BUG(pGC);
-
- if(((format == ZPixmap) && infoRec->WritePixmap &&
- ((pDraw->bitsPerPixel == bpp) ||
- ((pDraw->bitsPerPixel == 24) && (bpp == 32) &&
- (infoRec->WritePixmapFlags & CONVERT_32BPP_TO_24BPP))) &&
- CHECK_ROP(pGC,infoRec->WritePixmapFlags) &&
- CHECK_ROPSRC(pGC,infoRec->WritePixmapFlags) &&
- CHECK_PLANEMASK(pGC,infoRec->WritePixmapFlags) &&
- CHECK_NO_GXCOPY(pGC,infoRec->WritePixmapFlags)) ||
- ((format == XYBitmap) && !depthBug && infoRec->WriteBitmap &&
- CHECK_ROP(pGC,infoRec->WriteBitmapFlags) &&
- CHECK_ROPSRC(pGC,infoRec->WriteBitmapFlags) &&
- CHECK_PLANEMASK(pGC,infoRec->WriteBitmapFlags) &&
- CHECK_COLORS(pGC,infoRec->WriteBitmapFlags) &&
- !(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY)) ||
- ((format == XYPixmap) && !depthBug && infoRec->WriteBitmap &&
- CHECK_ROP(pGC,infoRec->WriteBitmapFlags) &&
- CHECK_ROPSRC(pGC,infoRec->WriteBitmapFlags) &&
- !(infoRec->WriteBitmapFlags & NO_PLANEMASK) &&
- !(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY))){
-
- int MaxBoxes = RegionNumRects(pGC->pCompositeClip);
- BoxPtr pbox, pClipBoxes;
- int nboxes, srcx, srcy, srcwidth;
- xRectangle TheRect;
-
- TheRect.x = pDraw->x + x;
- TheRect.y = pDraw->y + y;
- TheRect.width = w;
- TheRect.height = h;
-
- if(MaxBoxes > (infoRec->PreAllocSize/sizeof(BoxRec))) {
- pClipBoxes = malloc(MaxBoxes * sizeof(BoxRec));
- if(!pClipBoxes) return;
- } else pClipBoxes = (BoxPtr)infoRec->PreAllocMem;
-
- nboxes = XAAGetRectClipBoxes(pGC, pClipBoxes, 1, &TheRect);
- pbox = pClipBoxes;
-
- if(format == XYBitmap) {
- srcwidth = BitmapBytePad(leftPad + w);
- while(nboxes--) {
- srcx = pbox->x1 - TheRect.x + leftPad;
- srcy = pbox->y1 - TheRect.y;
- (*infoRec->WriteBitmap)(infoRec->pScrn, pbox->x1, pbox->y1,
- pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
- (unsigned char*)pImage +
- (srcwidth * srcy) + ((srcx >> 5) << 2),
- srcwidth, srcx & 31, pGC->fgPixel, pGC->bgPixel,
- pGC->alu, pGC->planemask);
- pbox++;
- }
- } else if(format == ZPixmap) {
- int Bpp = bpp >> 3;
- srcwidth = PixmapBytePad(leftPad + w, depth);
- while(nboxes--) {
- srcx = pbox->x1 - TheRect.x + leftPad;
- srcy = pbox->y1 - TheRect.y;
- (*infoRec->WritePixmap)(infoRec->pScrn, pbox->x1, pbox->y1,
- pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
- (unsigned char*)pImage +
- (srcwidth * srcy) + (srcx * Bpp),
- srcwidth, pGC->alu, pGC->planemask, -1,
- Bpp << 3, depth);
- pbox++;
- }
- } else { /* XYPixmap */
- int depth = pGC->depth;
- int numBox, increment;
- unsigned long i, mask;
- BoxPtr pntBox;
-
- srcwidth = BitmapBytePad(w + leftPad);
- increment = h * srcwidth;
- i = 1 << (depth - 1);
- mask = ~0;
-
- if((infoRec->pScrn->overlayFlags & OVERLAY_8_32_PLANAR) &&
- (pGC->depth == 8)){
- i = 0x80000000; mask = 0xff000000;
- }
-
- for(; i & mask; i >>= 1, pImage += increment) {
- if(i & pGC->planemask) {
- pntBox = pbox;
- numBox = nboxes;
- while(numBox--) {
- srcx = pntBox->x1 - TheRect.x + leftPad;
- srcy = pntBox->y1 - TheRect.y;
- (*infoRec->WriteBitmap)(infoRec->pScrn,
- pntBox->x1, pntBox->y1,
- pntBox->x2 - pntBox->x1,
- pntBox->y2 - pntBox->y1,
- (unsigned char*)pImage +
- (srcwidth * srcy) + ((srcx >> 5) << 2),
- srcwidth, srcx & 31, ~0, 0, pGC->alu, i);
- pntBox++;
- }
- }
- }
-
- }
-
- if(pClipBoxes != (BoxPtr)infoRec->PreAllocMem)
- free(pClipBoxes);
- } else
- XAAFallbackOps.PutImage(pDraw, pGC, depth, x, y, w, h, leftPad,
- format, pImage);
-}
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "servermd.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "mi.h"
+#include "pixmapstr.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+
+void
+XAAMoveDWORDS_FixedBase(register CARD32 *dest,
+ register CARD32 *src, register int dwords)
+{
+ while (dwords & ~0x03) {
+ *dest = *src;
+ *dest = *(src + 1);
+ *dest = *(src + 2);
+ *dest = *(src + 3);
+ dwords -= 4;
+ src += 4;
+ }
+
+ if (!dwords)
+ return;
+ *dest = *src;
+ if (dwords == 1)
+ return;
+ *dest = *(src + 1);
+ if (dwords == 2)
+ return;
+ *dest = *(src + 2);
+}
+
+void
+XAAMoveDWORDS(register CARD32 *dest, register CARD32 *src, register int dwords)
+{
+ while (dwords & ~0x03) {
+ *dest = *src;
+ *(dest + 1) = *(src + 1);
+ *(dest + 2) = *(src + 2);
+ *(dest + 3) = *(src + 3);
+ src += 4;
+ dest += 4;
+ dwords -= 4;
+ }
+ if (!dwords)
+ return;
+ *dest = *src;
+ if (dwords == 1)
+ return;
+ *(dest + 1) = *(src + 1);
+ if (dwords == 2)
+ return;
+ *(dest + 2) = *(src + 2);
+}
+
+void
+XAAMoveDWORDS_FixedSrc(register CARD32 *dest,
+ register CARD32 *src, register int dwords)
+{
+ while (dwords & ~0x03) {
+ *dest = *src;
+ *(dest + 1) = *src;
+ *(dest + 2) = *src;
+ *(dest + 3) = *src;
+ dest += 4;
+ dwords -= 4;
+ }
+ if (!dwords)
+ return;
+ *dest = *src;
+ if (dwords == 1)
+ return;
+ *(dest + 1) = *src;
+ if (dwords == 2)
+ return;
+ *(dest + 2) = *src;
+}
+
+static void
+XAAWritePixmap32To24(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *srcInit, int srcwidth, /* bytes */
+ int rop, unsigned int planemask, int trans)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int count, dwords = bytes_to_int32(w * 3);
+ CARD32 *src, *dst;
+ Bool PlusOne = FALSE;
+
+ if ((infoRec->ImageWriteFlags & CPU_TRANSFER_PAD_QWORD) &&
+ ((dwords * h) & 0x01)) {
+ PlusOne = TRUE;
+ }
+
+ (*infoRec->SetupForImageWrite) (pScrn, rop, planemask, trans, 24, 24);
+ (*infoRec->SubsequentImageWriteRect) (pScrn, x, y, w, h, 0);
+
+ if (dwords > infoRec->ImageWriteRange) {
+ dst = (CARD32 *) infoRec->ImageWriteBase;
+ while (h--) {
+ src = (CARD32 *) srcInit;
+ count = w;
+
+ while (count >= 4) {
+ *dst = (src[0] & 0x00ffffff) | (src[1] << 24);
+ *dst = ((src[1] >> 8) & 0x0000ffff) | (src[2] << 16);
+ *dst = ((src[2] >> 16) & 0x000000ff) | (src[3] << 8);
+ src += 4;
+ count -= 4;
+ }
+ switch (count) {
+ case 0:
+ break;
+ case 1:
+ *dst = src[0];
+ break;
+ case 2:
+ *dst = (src[0] & 0x00ffffff) | (src[1] << 24);
+ *dst = src[1] >> 8;
+ break;
+ default:
+ *dst = (src[0] & 0x00ffffff) | (src[1] << 24);
+ *dst = ((src[1] >> 8) & 0x0000ffff) | (src[2] << 16);
+ *dst = src[2] >> 16;
+ break;
+ }
+ srcInit += srcwidth;
+ }
+ }
+ else {
+ while (h--) {
+ dst = (CARD32 *) infoRec->ImageWriteBase;
+ src = (CARD32 *) srcInit;
+ count = w;
+
+ while (count >= 4) {
+ dst[0] = (src[0] & 0x00ffffff) | (src[1] << 24);
+ dst[1] = ((src[1] >> 8) & 0x0000ffff) | (src[2] << 16);
+ dst[2] = ((src[2] >> 16) & 0x000000ff) | (src[3] << 8);
+ dst += 3;
+ src += 4;
+ count -= 4;
+ }
+ switch (count) {
+ case 0:
+ break;
+ case 1:
+ dst[0] = src[0];
+ break;
+ case 2:
+ dst[0] = (src[0] & 0x00ffffff) | (src[1] << 24);
+ dst[1] = src[1] >> 8;
+ break;
+ default:
+ dst[0] = (src[0] & 0x00ffffff) | (src[1] << 24);
+ dst[1] = ((src[1] >> 8) & 0x0000ffff) | (src[2] << 16);
+ dst[2] = src[2] >> 16;
+ break;
+ }
+ srcInit += srcwidth;
+ }
+ }
+
+ if (PlusOne) {
+ CARD32 *base = (CARD32 *) infoRec->ImageWriteBase;
+
+ *base = 0x00000000;
+ }
+
+ if (infoRec->ImageWriteFlags & SYNC_AFTER_IMAGE_WRITE)
+ (*infoRec->Sync) (pScrn);
+ else
+ SET_SYNC_FLAG(infoRec);
+
+}
+
+void
+XAAWritePixmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, /* bytes */
+ int rop, unsigned int planemask, int trans, int bpp, int depth)
+{
+ XAAInfoRecPtr infoRec;
+ int dwords, skipleft, Bpp;
+ Bool beCareful, PlusOne;
+
+ if ((bpp == 32) && (pScrn->bitsPerPixel == 24)) {
+ XAAWritePixmap32To24(pScrn, x, y, w, h, src, srcwidth,
+ rop, planemask, trans);
+ return;
+ }
+
+ infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ beCareful = PlusOne = FALSE;
+ Bpp = bpp >> 3;
+
+ if ((skipleft = (long) src & 0x03L)) {
+ if (!(infoRec->ImageWriteFlags & LEFT_EDGE_CLIPPING)) {
+ skipleft = 0;
+ beCareful = TRUE;
+ goto BAD_ALIGNMENT;
+ }
+
+ if (Bpp == 3)
+ skipleft = 4 - skipleft;
+ else
+ skipleft /= Bpp;
+
+ if ((x < skipleft) && !(infoRec->ImageWriteFlags &
+ LEFT_EDGE_CLIPPING_NEGATIVE_X)) {
+ skipleft = 0;
+ beCareful = TRUE;
+ goto BAD_ALIGNMENT;
+ }
+
+ x -= skipleft;
+ w += skipleft;
+
+ if (Bpp == 3)
+ src -= 3 * skipleft;
+ else /* is this Alpha friendly ? */
+ src = (unsigned char *) ((long) src & ~0x03L);
+ }
+
+ BAD_ALIGNMENT:
+
+ dwords = bytes_to_int32(w * Bpp);
+
+ if ((infoRec->ImageWriteFlags & CPU_TRANSFER_PAD_QWORD) &&
+ ((dwords * h) & 0x01)) {
+ PlusOne = TRUE;
+ }
+
+ (*infoRec->SetupForImageWrite) (pScrn, rop, planemask, trans, bpp, depth);
+ (*infoRec->SubsequentImageWriteRect) (pScrn, x, y, w, h, skipleft);
+
+ if (beCareful) {
+ /* in cases with bad alignment we have to be careful not
+ to read beyond the end of the source */
+ if (((x * Bpp) + (dwords << 2)) > srcwidth)
+ h--;
+ else
+ beCareful = FALSE;
+ }
+
+ if (dwords > infoRec->ImageWriteRange) {
+ while (h--) {
+ XAAMoveDWORDS_FixedBase((CARD32 *) infoRec->ImageWriteBase,
+ (CARD32 *) src, dwords);
+ src += srcwidth;
+ }
+ if (beCareful) {
+ int shift = ((long) src & 0x03L) << 3;
+
+ if (--dwords)
+ XAAMoveDWORDS_FixedBase((CARD32 *) infoRec->ImageWriteBase,
+ (CARD32 *) src, dwords);
+ src = (unsigned char *) ((long) (src + (dwords << 2)) & ~0x03L);
+ *((CARD32 *) infoRec->ImageWriteBase) = *((CARD32 *) src) >> shift;
+ }
+ }
+ else {
+ if (srcwidth == (dwords << 2)) {
+ int decrement = infoRec->ImageWriteRange / dwords;
+
+ while (h > decrement) {
+ XAAMoveDWORDS((CARD32 *) infoRec->ImageWriteBase,
+ (CARD32 *) src, dwords * decrement);
+ src += (srcwidth * decrement);
+ h -= decrement;
+ }
+ if (h) {
+ XAAMoveDWORDS((CARD32 *) infoRec->ImageWriteBase,
+ (CARD32 *) src, dwords * h);
+ if (beCareful)
+ src += (srcwidth * h);
+ }
+ }
+ else {
+ while (h--) {
+ XAAMoveDWORDS((CARD32 *) infoRec->ImageWriteBase,
+ (CARD32 *) src, dwords);
+ src += srcwidth;
+ }
+ }
+
+ if (beCareful) {
+ int shift = ((long) src & 0x03L) << 3;
+
+ if (--dwords)
+ XAAMoveDWORDS((CARD32 *) infoRec->ImageWriteBase,
+ (CARD32 *) src, dwords);
+ src = (unsigned char *) ((long) (src + (dwords << 2)) & ~0x03L);
+
+ ((CARD32 *) infoRec->ImageWriteBase)[dwords] =
+ *((CARD32 *) src) >> shift;
+ }
+ }
+
+ if (PlusOne) {
+ CARD32 *base = (CARD32 *) infoRec->ImageWriteBase;
+
+ *base = 0x00000000;
+ }
+
+ if (infoRec->ImageWriteFlags & SYNC_AFTER_IMAGE_WRITE)
+ (*infoRec->Sync) (pScrn);
+ else
+ SET_SYNC_FLAG(infoRec);
+}
+
+void
+XAAWritePixmapScanline(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, /* bytes */
+ int rop,
+ unsigned int planemask, int trans, int bpp, int depth)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int dwords, skipleft, bufferNo = 0, Bpp = bpp >> 3;
+ Bool beCareful = FALSE;
+ CARD32 *base;
+
+ if ((skipleft = (long) src & 0x03L)) {
+ if (!(infoRec->ScanlineImageWriteFlags & LEFT_EDGE_CLIPPING)) {
+ skipleft = 0;
+ beCareful = TRUE;
+ goto BAD_ALIGNMENT;
+ }
+
+ if (Bpp == 3)
+ skipleft = 4 - skipleft;
+ else
+ skipleft /= Bpp;
+
+ if ((x < skipleft) && !(infoRec->ScanlineImageWriteFlags &
+ LEFT_EDGE_CLIPPING_NEGATIVE_X)) {
+ skipleft = 0;
+ beCareful = TRUE;
+ goto BAD_ALIGNMENT;
+ }
+
+ x -= skipleft;
+ w += skipleft;
+
+ if (Bpp == 3)
+ src -= 3 * skipleft;
+ else
+ src = (unsigned char *) ((long) src & ~0x03L);
+ }
+
+ BAD_ALIGNMENT:
+
+ dwords = bytes_to_int32(w * Bpp);
+
+ (*infoRec->SetupForScanlineImageWrite) (pScrn, rop, planemask, trans, bpp,
+ depth);
+ (*infoRec->SubsequentScanlineImageWriteRect) (pScrn, x, y, w, h, skipleft);
+
+ if (beCareful) {
+ /* in cases with bad alignment we have to be careful not
+ to read beyond the end of the source */
+ if (((x * Bpp) + (dwords << 2)) > srcwidth)
+ h--;
+ else
+ beCareful = FALSE;
+ }
+
+ while (h--) {
+ base = (CARD32 *) infoRec->ScanlineImageWriteBuffers[bufferNo];
+ XAAMoveDWORDS(base, (CARD32 *) src, dwords);
+ (*infoRec->SubsequentImageWriteScanline) (pScrn, bufferNo++);
+ src += srcwidth;
+ if (bufferNo >= infoRec->NumScanlineImageWriteBuffers)
+ bufferNo = 0;
+ }
+
+ if (beCareful) {
+ int shift = ((long) src & 0x03L) << 3;
+
+ base = (CARD32 *) infoRec->ScanlineImageWriteBuffers[bufferNo];
+ if (--dwords)
+ XAAMoveDWORDS(base, (CARD32 *) src, dwords);
+ src = (unsigned char *) ((long) (src + (dwords << 2)) & ~0x03L);
+
+ base[dwords] = *((CARD32 *) src) >> shift;
+ (*infoRec->SubsequentImageWriteScanline) (pScrn, bufferNo);
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+void
+XAAPutImage(DrawablePtr pDraw,
+ GCPtr pGC,
+ int depth,
+ int x, int y, int w, int h, int leftPad, int format, char *pImage)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int bpp = BitsPerPixel(depth);
+ Bool depthBug = FALSE;
+
+ if (!w || !h)
+ return;
+
+ if (!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ depthBug = XAA_DEPTH_BUG(pGC);
+
+ if (((format == ZPixmap) && infoRec->WritePixmap &&
+ ((pDraw->bitsPerPixel == bpp) ||
+ ((pDraw->bitsPerPixel == 24) && (bpp == 32) &&
+ (infoRec->WritePixmapFlags & CONVERT_32BPP_TO_24BPP))) &&
+ CHECK_ROP(pGC, infoRec->WritePixmapFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->WritePixmapFlags) &&
+ CHECK_PLANEMASK(pGC, infoRec->WritePixmapFlags) &&
+ CHECK_NO_GXCOPY(pGC, infoRec->WritePixmapFlags)) ||
+ ((format == XYBitmap) && !depthBug && infoRec->WriteBitmap &&
+ CHECK_ROP(pGC, infoRec->WriteBitmapFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->WriteBitmapFlags) &&
+ CHECK_PLANEMASK(pGC, infoRec->WriteBitmapFlags) &&
+ CHECK_COLORS(pGC, infoRec->WriteBitmapFlags) &&
+ !(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY)) ||
+ ((format == XYPixmap) && !depthBug && infoRec->WriteBitmap &&
+ CHECK_ROP(pGC, infoRec->WriteBitmapFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->WriteBitmapFlags) &&
+ !(infoRec->WriteBitmapFlags & NO_PLANEMASK) &&
+ !(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY))) {
+
+ int MaxBoxes = RegionNumRects(pGC->pCompositeClip);
+ BoxPtr pbox, pClipBoxes;
+ int nboxes, srcx, srcy, srcwidth;
+ xRectangle TheRect;
+
+ TheRect.x = pDraw->x + x;
+ TheRect.y = pDraw->y + y;
+ TheRect.width = w;
+ TheRect.height = h;
+
+ if (MaxBoxes > (infoRec->PreAllocSize / sizeof(BoxRec))) {
+ pClipBoxes = malloc(MaxBoxes * sizeof(BoxRec));
+ if (!pClipBoxes)
+ return;
+ }
+ else
+ pClipBoxes = (BoxPtr) infoRec->PreAllocMem;
+
+ nboxes = XAAGetRectClipBoxes(pGC, pClipBoxes, 1, &TheRect);
+ pbox = pClipBoxes;
+
+ if (format == XYBitmap) {
+ srcwidth = BitmapBytePad(leftPad + w);
+ while (nboxes--) {
+ srcx = pbox->x1 - TheRect.x + leftPad;
+ srcy = pbox->y1 - TheRect.y;
+ (*infoRec->WriteBitmap) (infoRec->pScrn, pbox->x1, pbox->y1,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1,
+ (unsigned char *) pImage +
+ (srcwidth * srcy) + ((srcx >> 5) << 2),
+ srcwidth, srcx & 31, pGC->fgPixel,
+ pGC->bgPixel, pGC->alu,
+ pGC->planemask);
+ pbox++;
+ }
+ }
+ else if (format == ZPixmap) {
+ int Bpp = bpp >> 3;
+
+ srcwidth = PixmapBytePad(leftPad + w, depth);
+ while (nboxes--) {
+ srcx = pbox->x1 - TheRect.x + leftPad;
+ srcy = pbox->y1 - TheRect.y;
+ (*infoRec->WritePixmap) (infoRec->pScrn, pbox->x1, pbox->y1,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1,
+ (unsigned char *) pImage +
+ (srcwidth * srcy) + (srcx * Bpp),
+ srcwidth, pGC->alu, pGC->planemask, -1,
+ Bpp << 3, depth);
+ pbox++;
+ }
+ }
+ else { /* XYPixmap */
+ int depth = pGC->depth;
+ int numBox, increment;
+ unsigned long i, mask;
+ BoxPtr pntBox;
+
+ srcwidth = BitmapBytePad(w + leftPad);
+ increment = h * srcwidth;
+ i = 1 << (depth - 1);
+ mask = ~0;
+
+ if ((infoRec->pScrn->overlayFlags & OVERLAY_8_32_PLANAR) &&
+ (pGC->depth == 8)) {
+ i = 0x80000000;
+ mask = 0xff000000;
+ }
+
+ for (; i & mask; i >>= 1, pImage += increment) {
+ if (i & pGC->planemask) {
+ pntBox = pbox;
+ numBox = nboxes;
+ while (numBox--) {
+ srcx = pntBox->x1 - TheRect.x + leftPad;
+ srcy = pntBox->y1 - TheRect.y;
+ (*infoRec->WriteBitmap) (infoRec->pScrn,
+ pntBox->x1, pntBox->y1,
+ pntBox->x2 - pntBox->x1,
+ pntBox->y2 - pntBox->y1,
+ (unsigned char *) pImage +
+ (srcwidth * srcy) +
+ ((srcx >> 5) << 2), srcwidth,
+ srcx & 31, ~0, 0, pGC->alu, i);
+ pntBox++;
+ }
+ }
+ }
+
+ }
+
+ if (pClipBoxes != (BoxPtr) infoRec->PreAllocMem)
+ free(pClipBoxes);
+ }
+ else
+ XAAFallbackOps.PutImage(pDraw, pGC, depth, x, y, w, h, leftPad,
+ format, pImage);
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaInit.c b/xorg-server/hw/xfree86/xaa/xaaInit.c
index ff1dd3d8b..661fa90ab 100644
--- a/xorg-server/hw/xfree86/xaa/xaaInit.c
+++ b/xorg-server/hw/xfree86/xaa/xaaInit.c
@@ -1,635 +1,637 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "windowstr.h"
-#include "xf86str.h"
-#include "mi.h"
-#include "miline.h"
-#include "xaa.h"
-#include "xaalocal.h"
-#include "xaawrap.h"
-#include "xf86fbman.h"
-#include "servermd.h"
-#ifdef COMPOSITE
-#include "cw.h"
-#endif
-
-#define MAX_PREALLOC_MEM 65536 /* MUST be >= 1024 */
-
-#define MIN_OFFPIX_SIZE (320*200)
-
-static Bool XAACloseScreen(int i, ScreenPtr pScreen);
-static void XAAGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h,
- unsigned int format, unsigned long planemask,
- char *pdstLine);
-static void XAAGetSpans(DrawablePtr pDrawable, int wMax, DDXPointPtr ppt,
- int *pwidth, int nspans, char *pdstStart);
-static PixmapPtr XAACreatePixmap(ScreenPtr pScreen, int w, int h, int depth,
- unsigned usage_hint);
-static Bool XAADestroyPixmap(PixmapPtr pPixmap);
-static Bool XAAEnterVT (int index, int flags);
-static void XAALeaveVT (int index, int flags);
-static int XAASetDGAMode(int index, int num, DGADevicePtr devRet);
-static void XAAEnableDisableFBAccess (int index, Bool enable);
-static Bool XAAChangeWindowAttributes (WindowPtr pWin, unsigned long mask);
-
-static DevPrivateKeyRec XAAScreenKeyRec;
-#define XAAScreenKey (&XAAScreenKeyRec)
-static DevPrivateKeyRec XAAGCKeyRec;
-#define XAAGCKey (&XAAGCKeyRec)
-static DevPrivateKeyRec XAAPixmapKeyRec;
-#define XAAPixmapKey (&XAAPixmapKeyRec)
-
-DevPrivateKey XAAGetScreenKey(void) {
- return XAAScreenKey;
-}
-
-DevPrivateKey XAAGetGCKey(void) {
- return XAAGCKey;
-}
-
-DevPrivateKey XAAGetPixmapKey(void) {
- return XAAPixmapKey;
-}
-
-/* temp kludge */
-static Bool SwitchedOut = FALSE;
-
-XAAInfoRecPtr
-XAACreateInfoRec(void)
-{
- XAAInfoRecPtr infoRec;
-
- infoRec = calloc(1, sizeof(XAAInfoRec));
- if(infoRec)
- infoRec->CachePixelGranularity = -1;
-
- return infoRec;
-}
-
-void
-XAADestroyInfoRec(XAAInfoRecPtr infoRec)
-{
- if(!infoRec) return;
-
- if(infoRec->ClosePixmapCache)
- (*infoRec->ClosePixmapCache)(infoRec->pScrn->pScreen);
-
- free(infoRec->PreAllocMem);
-
- free(infoRec->PixmapCachePrivate);
-
- free(infoRec);
-}
-
-
-Bool
-XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- XAAScreenPtr pScreenPriv;
- int i;
- PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
-
- /* Return successfully if no acceleration wanted */
- if (!infoRec)
- return TRUE;
-
- if (!dixRegisterPrivateKey(&XAAGCKeyRec, PRIVATE_GC, sizeof(XAAGCRec)))
- return FALSE;
-
- if (!dixRegisterPrivateKey(&XAAPixmapKeyRec, PRIVATE_PIXMAP, sizeof(XAAPixmapRec)))
- return FALSE;
-
- if (!dixRegisterPrivateKey(&XAAScreenKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
-
- if (!(pScreenPriv = malloc(sizeof(XAAScreenRec))))
- return FALSE;
-
- dixSetPrivate(&pScreen->devPrivates, XAAScreenKey, pScreenPriv);
-
- if(!xf86FBManagerRunning(pScreen))
- infoRec->Flags &= ~(PIXMAP_CACHE | OFFSCREEN_PIXMAPS);
- if(!(infoRec->Flags & LINEAR_FRAMEBUFFER))
- infoRec->Flags &= ~OFFSCREEN_PIXMAPS;
-
- if(!infoRec->FullPlanemask) { /* for backwards compatibility */
- infoRec->FullPlanemask = (1 << pScrn->depth) - 1;
- infoRec->FullPlanemasks[pScrn->depth - 1] = infoRec->FullPlanemask;
- }
-
- for(i = 0; i < 32; i++) {
- if(!infoRec->FullPlanemasks[i]) /* keep any set by caller */
- infoRec->FullPlanemasks[i] = (1 << (i+1)) - 1;
- }
-
- if(!XAAInitAccel(pScreen, infoRec)) return FALSE;
- pScreenPriv->AccelInfoRec = infoRec;
- infoRec->ScratchGC.pScreen = pScreen;
-
-
- if(!infoRec->GetImage)
- infoRec->GetImage = XAAGetImage;
- if(!infoRec->GetSpans)
- infoRec->GetSpans = XAAGetSpans;
- if(!infoRec->CopyWindow)
- infoRec->CopyWindow = XAACopyWindow;
-
- pScreenPriv->CreateGC = pScreen->CreateGC;
- pScreen->CreateGC = XAACreateGC;
- pScreenPriv->CloseScreen = pScreen->CloseScreen;
- pScreen->CloseScreen = XAACloseScreen;
- pScreenPriv->GetImage = pScreen->GetImage;
- pScreen->GetImage = infoRec->GetImage;
- pScreenPriv->GetSpans = pScreen->GetSpans;
- pScreen->GetSpans = infoRec->GetSpans;
- pScreenPriv->CopyWindow = pScreen->CopyWindow;
- pScreen->CopyWindow = infoRec->CopyWindow;
- pScreenPriv->CreatePixmap = pScreen->CreatePixmap;
- pScreen->CreatePixmap = XAACreatePixmap;
- pScreenPriv->DestroyPixmap = pScreen->DestroyPixmap;
- pScreen->DestroyPixmap = XAADestroyPixmap;
- pScreenPriv->ChangeWindowAttributes = pScreen->ChangeWindowAttributes;
- pScreen->ChangeWindowAttributes = XAAChangeWindowAttributes;
-
- pScreenPriv->EnterVT = pScrn->EnterVT;
- pScrn->EnterVT = XAAEnterVT;
- pScreenPriv->LeaveVT = pScrn->LeaveVT;
- pScrn->LeaveVT = XAALeaveVT;
- pScreenPriv->SetDGAMode = pScrn->SetDGAMode;
- pScrn->SetDGAMode = XAASetDGAMode;
- pScreenPriv->EnableDisableFBAccess = pScrn->EnableDisableFBAccess;
- pScrn->EnableDisableFBAccess = XAAEnableDisableFBAccess;
-
- pScreenPriv->WindowExposures = pScreen->WindowExposures;
- if (ps)
- {
- pScreenPriv->Composite = ps->Composite;
- ps->Composite = XAAComposite;
- pScreenPriv->Glyphs = ps->Glyphs;
- ps->Glyphs = XAAGlyphs;
- }
- if(pScrn->overlayFlags & OVERLAY_8_32_PLANAR)
- XAASetupOverlay8_32Planar(pScreen);
-
- infoRec->PreAllocMem = malloc(MAX_PREALLOC_MEM);
- if(infoRec->PreAllocMem)
- infoRec->PreAllocSize = MAX_PREALLOC_MEM;
-
- if(infoRec->Flags & PIXMAP_CACHE)
- xf86RegisterFreeBoxCallback(pScreen, infoRec->InitPixmapCache,
- (pointer)infoRec);
-
- if(infoRec->Flags & MICROSOFT_ZERO_LINE_BIAS)
- miSetZeroLineBias(pScreen, OCTANT1 | OCTANT2 | OCTANT3 | OCTANT4);
-
-#ifdef COMPOSITE
- /* Initialize the composite wrapper. This needs to happen after the
- * wrapping above (so it comes before us), but before all other extensions,
- * so it doesn't confuse them. (particularly damage).
- */
- miInitializeCompositeWrapper(pScreen);
-#endif
-
- return TRUE;
-}
-
-
-
-static Bool
-XAACloseScreen (int i, ScreenPtr pScreen)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- XAAScreenPtr pScreenPriv =
- (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
-
- pScrn->EnterVT = pScreenPriv->EnterVT;
- pScrn->LeaveVT = pScreenPriv->LeaveVT;
- pScrn->EnableDisableFBAccess = pScreenPriv->EnableDisableFBAccess;
-
- pScreen->CreateGC = pScreenPriv->CreateGC;
- pScreen->CloseScreen = pScreenPriv->CloseScreen;
- pScreen->GetImage = pScreenPriv->GetImage;
- pScreen->GetSpans = pScreenPriv->GetSpans;
- pScreen->CopyWindow = pScreenPriv->CopyWindow;
- pScreen->WindowExposures = pScreenPriv->WindowExposures;
- pScreen->CreatePixmap = pScreenPriv->CreatePixmap;
- pScreen->DestroyPixmap = pScreenPriv->DestroyPixmap;
- pScreen->ChangeWindowAttributes = pScreenPriv->ChangeWindowAttributes;
-
- /* We leave it up to the client to free the XAAInfoRec */
-
- free((pointer) pScreenPriv);
-
- return (*pScreen->CloseScreen) (i, pScreen);
-}
-
-static void
-XAAGetImage (
- DrawablePtr pDraw,
- int sx, int sy, int w, int h,
- unsigned int format,
- unsigned long planemask,
- char *pdstLine
-)
-{
- ScreenPtr pScreen = pDraw->pScreen;
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
- ScrnInfoPtr pScrn = infoRec->pScrn;
-
- if(pScrn->vtSema &&
- ((pDraw->type == DRAWABLE_WINDOW) || IS_OFFSCREEN_PIXMAP(pDraw)))
- {
- if(infoRec->ReadPixmap && (format == ZPixmap) &&
- ((planemask & infoRec->FullPlanemasks[pDraw->depth - 1]) ==
- infoRec->FullPlanemasks[pDraw->depth - 1]) &&
- (pDraw->bitsPerPixel == BitsPerPixel(pDraw->depth)))
- {
- (*infoRec->ReadPixmap)(pScrn,
- sx + pDraw->x, sy + pDraw->y, w, h,
- (unsigned char *)pdstLine,
- PixmapBytePad(w, pDraw->depth),
- pDraw->bitsPerPixel, pDraw->depth);
- return;
- }
- SYNC_CHECK(pDraw);
- }
-
- XAA_SCREEN_PROLOGUE (pScreen, GetImage);
- (*pScreen->GetImage) (pDraw, sx, sy, w, h, format, planemask, pdstLine);
- XAA_SCREEN_EPILOGUE (pScreen, GetImage, XAAGetImage);
-}
-
-static void
-XAAGetSpans (
- DrawablePtr pDraw,
- int wMax,
- DDXPointPtr ppt,
- int *pwidth,
- int nspans,
- char *pdstStart
-)
-{
- ScreenPtr pScreen = pDraw->pScreen;
- XAA_SCREEN_PROLOGUE (pScreen, GetSpans);
- if(xf86Screens[pScreen->myNum]->vtSema &&
- ((pDraw->type == DRAWABLE_WINDOW) || IS_OFFSCREEN_PIXMAP(pDraw))) {
- SYNC_CHECK(pDraw);
- }
- (*pScreen->GetSpans) (pDraw, wMax, ppt, pwidth, nspans, pdstStart);
- XAA_SCREEN_EPILOGUE (pScreen, GetSpans, XAAGetSpans);
-}
-
-
-static int
-XAAPixmapBPP (ScreenPtr pScreen, int depth)
-{
- PixmapPtr pPix;
- int bpp;
- DestroyPixmapProcPtr destroyPixmap;
-
- XAA_SCREEN_PROLOGUE (pScreen, CreatePixmap);
- pPix = (*pScreen->CreatePixmap) (pScreen, 1, 1, depth,
- CREATE_PIXMAP_USAGE_SCRATCH);
- XAA_SCREEN_EPILOGUE (pScreen, CreatePixmap, XAACreatePixmap);
- if (!pPix)
- return 0;
- bpp = pPix->drawable.bitsPerPixel;
- destroyPixmap = pScreen->DestroyPixmap;
- XAA_SCREEN_PROLOGUE (pScreen, DestroyPixmap);
- (*pScreen->DestroyPixmap) (pPix);
- XAA_SCREEN_EPILOGUE (pScreen, DestroyPixmap, destroyPixmap);
- return bpp;
-}
-
-static void
-XAAInitializeOffscreenDepths (ScreenPtr pScreen)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- int d, dep;
-
- infoRec->offscreenDepthsInitialized = TRUE;
- infoRec->offscreenDepths = 0;
- if (infoRec->Flags & OFFSCREEN_PIXMAPS) {
- for (d = 0; d < pScreen->numDepths; d++) {
- dep = pScreen->allowedDepths[d].depth;
- if (XAAPixmapBPP (pScreen, dep) == pScrn->bitsPerPixel)
- infoRec->offscreenDepths |= (1 << (dep - 1));
- }
- }
-}
-
-static PixmapPtr
-XAACreatePixmap(ScreenPtr pScreen, int w, int h, int depth, unsigned usage_hint)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- XAAPixmapPtr pPriv;
- PixmapPtr pPix = NULL;
- int size = w * h;
-
- if (w > 32767 || h > 32767)
- return NullPixmap;
-
- if (!infoRec->offscreenDepthsInitialized)
- XAAInitializeOffscreenDepths (pScreen);
-
- if(pScrn->vtSema &&
- (usage_hint != CREATE_PIXMAP_USAGE_GLYPH_PICTURE) &&
- (infoRec->offscreenDepths & (1 << (depth - 1))) &&
- (size >= MIN_OFFPIX_SIZE) && !SwitchedOut &&
- (!infoRec->maxOffPixWidth || (w <= infoRec->maxOffPixWidth)) &&
- (!infoRec->maxOffPixHeight || (h <= infoRec->maxOffPixHeight)) )
- {
- PixmapLinkPtr pLink;
- PixmapPtr pScreenPix;
- FBAreaPtr area;
- int gran = 0;
-
- switch(pScrn->bitsPerPixel) {
- case 24:
- case 8: gran = 4; break;
- case 16: gran = 2; break;
- case 32: gran = 1; break;
- default: break;
- }
-
- if(BITMAP_SCANLINE_PAD == 64)
- gran *= 2;
-
- if(!(area = xf86AllocateOffscreenArea(pScreen, w, h, gran, 0,
- XAARemoveAreaCallback, NULL))) {
- goto BAILOUT;
- }
-
- if(!(pLink = malloc(sizeof(PixmapLink)))) {
- xf86FreeOffscreenArea(area);
- goto BAILOUT;
- }
-
- XAA_SCREEN_PROLOGUE (pScreen, CreatePixmap);
- pPix = (*pScreen->CreatePixmap) (pScreen, 0, 0, depth, usage_hint);
- XAA_SCREEN_EPILOGUE (pScreen, CreatePixmap, XAACreatePixmap);
-
- if (!pPix) {
- free(pLink);
- xf86FreeOffscreenArea(area);
- goto BAILOUT;
- }
-
- pScreenPix = (*pScreen->GetScreenPixmap)(pScreen);
-
- pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
- pPix->drawable.x = area->box.x1;
- pPix->drawable.y = area->box.y1;
- pPix->drawable.width = w;
- pPix->drawable.height = h;
- pPix->drawable.bitsPerPixel = pScrn->bitsPerPixel;
- pPix->devKind = pScreenPix->devKind;
- pPix->devPrivate.ptr = pScreenPix->devPrivate.ptr;
- area->devPrivate.ptr = pPix;
-
- pPriv->flags = OFFSCREEN;
- pPriv->offscreenArea = area;
- pPriv->freeData = FALSE;
-
- pLink->next = infoRec->OffscreenPixmaps;
- pLink->pPix = pPix;
- infoRec->OffscreenPixmaps = pLink;
- return pPix;
- }
-BAILOUT:
- XAA_SCREEN_PROLOGUE (pScreen, CreatePixmap);
- pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth, usage_hint);
- XAA_SCREEN_EPILOGUE (pScreen, CreatePixmap, XAACreatePixmap);
-
- if(pPix) {
- pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
- pPriv->flags = 0;
- pPriv->offscreenArea = NULL;
- pPriv->freeData = FALSE;
- if(!w || !h) /* either scratch or shared memory */
- pPriv->flags |= SHARED_PIXMAP;
- }
-
- return pPix;
-}
-
-static Bool
-XAADestroyPixmap(PixmapPtr pPix)
-{
- ScreenPtr pScreen = pPix->drawable.pScreen;
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
- XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
- Bool ret;
-
- if(pPix->refcnt == 1) {
- if(pPriv->flags & OFFSCREEN) {
- if(pPriv->flags & DGA_PIXMAP)
- free(pPriv->offscreenArea);
- else {
- FBAreaPtr area = pPriv->offscreenArea;
- PixmapLinkPtr pLink = infoRec->OffscreenPixmaps;
- PixmapLinkPtr prev = NULL;
-
- while(pLink->pPix != pPix) {
- prev = pLink;
- pLink = pLink->next;
- }
-
- if(prev) prev->next = pLink->next;
- else infoRec->OffscreenPixmaps = pLink->next;
-
- if(!area) area = pLink->area;
-
- xf86FreeOffscreenArea(area);
- pPriv->offscreenArea = NULL;
- free(pLink);
- }
- }
-
- if(pPriv->freeData) { /* pixmaps that were once in video ram */
- free(pPix->devPrivate.ptr);
- pPix->devPrivate.ptr = NULL;
- }
- }
-
- XAA_SCREEN_PROLOGUE (pScreen, DestroyPixmap);
- ret = (*pScreen->DestroyPixmap) (pPix);
- XAA_SCREEN_EPILOGUE (pScreen, DestroyPixmap, XAADestroyPixmap);
-
- return ret;
-}
-
-static Bool
-XAAChangeWindowAttributes (WindowPtr pWin, unsigned long mask)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- Bool ret;
-
- XAA_SCREEN_PROLOGUE (pScreen, ChangeWindowAttributes);
- ret = (*pScreen->ChangeWindowAttributes) (pWin, mask);
- XAA_SCREEN_EPILOGUE (pScreen, ChangeWindowAttributes, XAAChangeWindowAttributes);
-
- /* we have to assume that shared memory pixmaps are dirty
- because we can't wrap operations on them */
-
- if((mask & CWBackPixmap) && (pWin->backgroundState == BackgroundPixmap) &&
- PIXMAP_IS_SHARED(pWin->background.pixmap))
- {
- XAAPixmapPtr pPixPriv = XAA_GET_PIXMAP_PRIVATE(pWin->background.pixmap);
- pPixPriv->flags |= DIRTY;
- }
- if((mask & CWBorderPixmap) && !(pWin->borderIsPixel) &&
- PIXMAP_IS_SHARED(pWin->border.pixmap))
- {
- XAAPixmapPtr pPixPriv = XAA_GET_PIXMAP_PRIVATE(pWin->border.pixmap);
- pPixPriv->flags |= DIRTY;
- }
-
- return ret;
-}
-
-
-
-/* These two aren't really needed for anything */
-
-static Bool
-XAAEnterVT(int index, int flags)
-{
- ScrnInfoPtr pScrn = xf86Screens[index];
- Bool ret;
- ScreenPtr pScreen = screenInfo.screens[index];
- XAAScreenPtr pScreenPriv =
- (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
-
- pScrn->EnterVT = pScreenPriv->EnterVT;
- ret = ((*pScreenPriv->EnterVT)(index, flags));
- pScreenPriv->EnterVT = pScrn->EnterVT;
- pScrn->EnterVT = XAAEnterVT;
- return ret;
-}
-
-static void
-XAALeaveVT(int index, int flags)
-{
- ScrnInfoPtr pScrn = xf86Screens[index];
- ScreenPtr pScreen = screenInfo.screens[index];
- XAAScreenPtr pScreenPriv =
- (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
- XAAInfoRecPtr infoRec = pScreenPriv->AccelInfoRec;
-
- if(infoRec->NeedToSync) {
- (*infoRec->Sync)(infoRec->pScrn);
- infoRec->NeedToSync = FALSE;
- }
-
- pScrn->LeaveVT = pScreenPriv->LeaveVT;
- (*pScreenPriv->LeaveVT)(index, flags);
- pScreenPriv->LeaveVT = pScrn->LeaveVT;
- pScrn->LeaveVT = XAALeaveVT;
-}
-
-typedef struct {
- Bool UsingPixmapCache;
- Bool CanDoColor8x8;
- Bool CanDoMono8x8;
-} SavedCacheState, *SavedCacheStatePtr;
-
-static int
-XAASetDGAMode(int index, int num, DGADevicePtr devRet)
-{
- ScreenPtr pScreen = screenInfo.screens[index];
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
- XAAScreenPtr pScreenPriv =
- (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
- int ret;
-
- if (!num && infoRec->dgaSaves) { /* restore old pixmap cache state */
- SavedCacheStatePtr state = (SavedCacheStatePtr)infoRec->dgaSaves;
-
- infoRec->UsingPixmapCache = state->UsingPixmapCache;
- infoRec->CanDoColor8x8 = state->CanDoColor8x8;
- infoRec->CanDoMono8x8 = state->CanDoMono8x8;
- free(infoRec->dgaSaves);
- infoRec->dgaSaves = NULL;
- }
-
- ret = (*pScreenPriv->SetDGAMode)(index, num, devRet);
- if(ret != Success) return ret;
-
- if(num && devRet->pPix) { /* accelerate this pixmap */
- XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE(devRet->pPix);
- FBAreaPtr area;
-
- if((area = malloc(sizeof(FBArea)))) {
- area->pScreen = pScreen;
- area->box.x1 = 0;
- area->box.x2 = 0;
- area->box.y1 = devRet->mode->pixmapWidth;
- area->box.y2 = devRet->mode->pixmapHeight;
- area->granularity = 0;
- area->MoveAreaCallback = 0;
- area->RemoveAreaCallback = 0;
- area->devPrivate.ptr = 0;
-
- pixPriv->flags |= OFFSCREEN | DGA_PIXMAP;
- pixPriv->offscreenArea = area;
-
- if(!infoRec->dgaSaves) { /* save pixmap cache state */
- SavedCacheStatePtr state = malloc(sizeof(SavedCacheState));
-
- state->UsingPixmapCache = infoRec->UsingPixmapCache;
- state->CanDoColor8x8 = infoRec->CanDoColor8x8;
- state->CanDoMono8x8 = infoRec->CanDoMono8x8;
- infoRec->dgaSaves = (char*)state;
-
- infoRec->UsingPixmapCache = FALSE;
- if(infoRec->PixmapCacheFlags & CACHE_MONO_8x8)
- infoRec->CanDoMono8x8 = FALSE;
- if(infoRec->PixmapCacheFlags & CACHE_COLOR_8x8)
- infoRec->CanDoColor8x8 = FALSE;
- }
- }
- }
-
- return ret;
-}
-
-
-
-static void
-XAAEnableDisableFBAccess (int index, Bool enable)
-{
- ScreenPtr pScreen = screenInfo.screens[index];
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
- XAAScreenPtr pScreenPriv =
- (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
-
- if(!enable) {
- if((infoRec->Flags & OFFSCREEN_PIXMAPS) && (infoRec->OffscreenPixmaps))
- XAAMoveOutOffscreenPixmaps(pScreen);
- if(infoRec->Flags & PIXMAP_CACHE)
- XAAInvalidatePixmapCache(pScreen);
- SwitchedOut = TRUE;
- }
-
- (*pScreenPriv->EnableDisableFBAccess)(index, enable);
-
- if(enable) {
- if((infoRec->Flags & OFFSCREEN_PIXMAPS) && (infoRec->OffscreenPixmaps))
- XAAMoveInOffscreenPixmaps(pScreen);
- SwitchedOut = FALSE;
- }
-}
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "xf86str.h"
+#include "mi.h"
+#include "miline.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "xaawrap.h"
+#include "xf86fbman.h"
+#include "servermd.h"
+#ifdef COMPOSITE
+#include "cw.h"
+#endif
+
+#define MAX_PREALLOC_MEM 65536 /* MUST be >= 1024 */
+
+#define MIN_OFFPIX_SIZE (320*200)
+
+static Bool XAACloseScreen(int i, ScreenPtr pScreen);
+static void XAAGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h,
+ unsigned int format, unsigned long planemask,
+ char *pdstLine);
+static void XAAGetSpans(DrawablePtr pDrawable, int wMax, DDXPointPtr ppt,
+ int *pwidth, int nspans, char *pdstStart);
+static PixmapPtr XAACreatePixmap(ScreenPtr pScreen, int w, int h, int depth,
+ unsigned usage_hint);
+static Bool XAADestroyPixmap(PixmapPtr pPixmap);
+static Bool XAAEnterVT(int index, int flags);
+static void XAALeaveVT(int index, int flags);
+static int XAASetDGAMode(int index, int num, DGADevicePtr devRet);
+static void XAAEnableDisableFBAccess(int index, Bool enable);
+static Bool XAAChangeWindowAttributes(WindowPtr pWin, unsigned long mask);
+
+static DevPrivateKeyRec XAAScreenKeyRec;
+
+#define XAAScreenKey (&XAAScreenKeyRec)
+static DevPrivateKeyRec XAAGCKeyRec;
+
+#define XAAGCKey (&XAAGCKeyRec)
+static DevPrivateKeyRec XAAPixmapKeyRec;
+
+#define XAAPixmapKey (&XAAPixmapKeyRec)
+
+DevPrivateKey
+XAAGetScreenKey(void)
+{
+ return XAAScreenKey;
+}
+
+DevPrivateKey
+XAAGetGCKey(void)
+{
+ return XAAGCKey;
+}
+
+DevPrivateKey
+XAAGetPixmapKey(void)
+{
+ return XAAPixmapKey;
+}
+
+/* temp kludge */
+static Bool SwitchedOut = FALSE;
+
+XAAInfoRecPtr
+XAACreateInfoRec(void)
+{
+ XAAInfoRecPtr infoRec;
+
+ infoRec = calloc(1, sizeof(XAAInfoRec));
+ if (infoRec)
+ infoRec->CachePixelGranularity = -1;
+
+ return infoRec;
+}
+
+void
+XAADestroyInfoRec(XAAInfoRecPtr infoRec)
+{
+ if (!infoRec)
+ return;
+
+ if (infoRec->ClosePixmapCache)
+ (*infoRec->ClosePixmapCache) (infoRec->pScrn->pScreen);
+
+ free(infoRec->PreAllocMem);
+
+ free(infoRec->PixmapCachePrivate);
+
+ free(infoRec);
+}
+
+Bool
+XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ XAAScreenPtr pScreenPriv;
+ int i;
+ PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
+
+ /* Return successfully if no acceleration wanted */
+ if (!infoRec)
+ return TRUE;
+
+ if (!dixRegisterPrivateKey(&XAAGCKeyRec, PRIVATE_GC, sizeof(XAAGCRec)))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey
+ (&XAAPixmapKeyRec, PRIVATE_PIXMAP, sizeof(XAAPixmapRec)))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&XAAScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ if (!(pScreenPriv = malloc(sizeof(XAAScreenRec))))
+ return FALSE;
+
+ dixSetPrivate(&pScreen->devPrivates, XAAScreenKey, pScreenPriv);
+
+ if (!xf86FBManagerRunning(pScreen))
+ infoRec->Flags &= ~(PIXMAP_CACHE | OFFSCREEN_PIXMAPS);
+ if (!(infoRec->Flags & LINEAR_FRAMEBUFFER))
+ infoRec->Flags &= ~OFFSCREEN_PIXMAPS;
+
+ if (!infoRec->FullPlanemask) { /* for backwards compatibility */
+ infoRec->FullPlanemask = (1 << pScrn->depth) - 1;
+ infoRec->FullPlanemasks[pScrn->depth - 1] = infoRec->FullPlanemask;
+ }
+
+ for (i = 0; i < 32; i++) {
+ if (!infoRec->FullPlanemasks[i]) /* keep any set by caller */
+ infoRec->FullPlanemasks[i] = (1 << (i + 1)) - 1;
+ }
+
+ if (!XAAInitAccel(pScreen, infoRec))
+ return FALSE;
+ pScreenPriv->AccelInfoRec = infoRec;
+ infoRec->ScratchGC.pScreen = pScreen;
+
+ if (!infoRec->GetImage)
+ infoRec->GetImage = XAAGetImage;
+ if (!infoRec->GetSpans)
+ infoRec->GetSpans = XAAGetSpans;
+ if (!infoRec->CopyWindow)
+ infoRec->CopyWindow = XAACopyWindow;
+
+ pScreenPriv->CreateGC = pScreen->CreateGC;
+ pScreen->CreateGC = XAACreateGC;
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = XAACloseScreen;
+ pScreenPriv->GetImage = pScreen->GetImage;
+ pScreen->GetImage = infoRec->GetImage;
+ pScreenPriv->GetSpans = pScreen->GetSpans;
+ pScreen->GetSpans = infoRec->GetSpans;
+ pScreenPriv->CopyWindow = pScreen->CopyWindow;
+ pScreen->CopyWindow = infoRec->CopyWindow;
+ pScreenPriv->CreatePixmap = pScreen->CreatePixmap;
+ pScreen->CreatePixmap = XAACreatePixmap;
+ pScreenPriv->DestroyPixmap = pScreen->DestroyPixmap;
+ pScreen->DestroyPixmap = XAADestroyPixmap;
+ pScreenPriv->ChangeWindowAttributes = pScreen->ChangeWindowAttributes;
+ pScreen->ChangeWindowAttributes = XAAChangeWindowAttributes;
+
+ pScreenPriv->EnterVT = pScrn->EnterVT;
+ pScrn->EnterVT = XAAEnterVT;
+ pScreenPriv->LeaveVT = pScrn->LeaveVT;
+ pScrn->LeaveVT = XAALeaveVT;
+ pScreenPriv->SetDGAMode = pScrn->SetDGAMode;
+ pScrn->SetDGAMode = XAASetDGAMode;
+ pScreenPriv->EnableDisableFBAccess = pScrn->EnableDisableFBAccess;
+ pScrn->EnableDisableFBAccess = XAAEnableDisableFBAccess;
+
+ pScreenPriv->WindowExposures = pScreen->WindowExposures;
+ if (ps) {
+ pScreenPriv->Composite = ps->Composite;
+ ps->Composite = XAAComposite;
+ pScreenPriv->Glyphs = ps->Glyphs;
+ ps->Glyphs = XAAGlyphs;
+ }
+ if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR)
+ XAASetupOverlay8_32Planar(pScreen);
+
+ infoRec->PreAllocMem = malloc(MAX_PREALLOC_MEM);
+ if (infoRec->PreAllocMem)
+ infoRec->PreAllocSize = MAX_PREALLOC_MEM;
+
+ if (infoRec->Flags & PIXMAP_CACHE)
+ xf86RegisterFreeBoxCallback(pScreen, infoRec->InitPixmapCache,
+ (pointer) infoRec);
+
+ if (infoRec->Flags & MICROSOFT_ZERO_LINE_BIAS)
+ miSetZeroLineBias(pScreen, OCTANT1 | OCTANT2 | OCTANT3 | OCTANT4);
+
+#ifdef COMPOSITE
+ /* Initialize the composite wrapper. This needs to happen after the
+ * wrapping above (so it comes before us), but before all other extensions,
+ * so it doesn't confuse them. (particularly damage).
+ */
+ miInitializeCompositeWrapper(pScreen);
+#endif
+
+ return TRUE;
+}
+
+static Bool
+XAACloseScreen(int i, ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ XAAScreenPtr pScreenPriv =
+ (XAAScreenPtr) dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
+
+ pScrn->EnterVT = pScreenPriv->EnterVT;
+ pScrn->LeaveVT = pScreenPriv->LeaveVT;
+ pScrn->EnableDisableFBAccess = pScreenPriv->EnableDisableFBAccess;
+
+ pScreen->CreateGC = pScreenPriv->CreateGC;
+ pScreen->CloseScreen = pScreenPriv->CloseScreen;
+ pScreen->GetImage = pScreenPriv->GetImage;
+ pScreen->GetSpans = pScreenPriv->GetSpans;
+ pScreen->CopyWindow = pScreenPriv->CopyWindow;
+ pScreen->WindowExposures = pScreenPriv->WindowExposures;
+ pScreen->CreatePixmap = pScreenPriv->CreatePixmap;
+ pScreen->DestroyPixmap = pScreenPriv->DestroyPixmap;
+ pScreen->ChangeWindowAttributes = pScreenPriv->ChangeWindowAttributes;
+
+ /* We leave it up to the client to free the XAAInfoRec */
+
+ free((pointer) pScreenPriv);
+
+ return (*pScreen->CloseScreen) (i, pScreen);
+}
+
+static void
+XAAGetImage(DrawablePtr pDraw,
+ int sx, int sy, int w, int h,
+ unsigned int format, unsigned long planemask, char *pdstLine)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+ ScrnInfoPtr pScrn = infoRec->pScrn;
+
+ if (pScrn->vtSema &&
+ ((pDraw->type == DRAWABLE_WINDOW) || IS_OFFSCREEN_PIXMAP(pDraw))) {
+ if (infoRec->ReadPixmap && (format == ZPixmap) &&
+ ((planemask & infoRec->FullPlanemasks[pDraw->depth - 1]) ==
+ infoRec->FullPlanemasks[pDraw->depth - 1]) &&
+ (pDraw->bitsPerPixel == BitsPerPixel(pDraw->depth))) {
+ (*infoRec->ReadPixmap) (pScrn,
+ sx + pDraw->x, sy + pDraw->y, w, h,
+ (unsigned char *) pdstLine,
+ PixmapBytePad(w, pDraw->depth),
+ pDraw->bitsPerPixel, pDraw->depth);
+ return;
+ }
+ SYNC_CHECK(pDraw);
+ }
+
+ XAA_SCREEN_PROLOGUE(pScreen, GetImage);
+ (*pScreen->GetImage) (pDraw, sx, sy, w, h, format, planemask, pdstLine);
+ XAA_SCREEN_EPILOGUE(pScreen, GetImage, XAAGetImage);
+}
+
+static void
+XAAGetSpans(DrawablePtr pDraw,
+ int wMax, DDXPointPtr ppt, int *pwidth, int nspans, char *pdstStart)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+
+ XAA_SCREEN_PROLOGUE(pScreen, GetSpans);
+ if (xf86Screens[pScreen->myNum]->vtSema &&
+ ((pDraw->type == DRAWABLE_WINDOW) || IS_OFFSCREEN_PIXMAP(pDraw))) {
+ SYNC_CHECK(pDraw);
+ }
+ (*pScreen->GetSpans) (pDraw, wMax, ppt, pwidth, nspans, pdstStart);
+ XAA_SCREEN_EPILOGUE(pScreen, GetSpans, XAAGetSpans);
+}
+
+static int
+XAAPixmapBPP(ScreenPtr pScreen, int depth)
+{
+ PixmapPtr pPix;
+ int bpp;
+ DestroyPixmapProcPtr destroyPixmap;
+
+ XAA_SCREEN_PROLOGUE(pScreen, CreatePixmap);
+ pPix = (*pScreen->CreatePixmap) (pScreen, 1, 1, depth,
+ CREATE_PIXMAP_USAGE_SCRATCH);
+ XAA_SCREEN_EPILOGUE(pScreen, CreatePixmap, XAACreatePixmap);
+ if (!pPix)
+ return 0;
+ bpp = pPix->drawable.bitsPerPixel;
+ destroyPixmap = pScreen->DestroyPixmap;
+ XAA_SCREEN_PROLOGUE(pScreen, DestroyPixmap);
+ (*pScreen->DestroyPixmap) (pPix);
+ XAA_SCREEN_EPILOGUE(pScreen, DestroyPixmap, destroyPixmap);
+ return bpp;
+}
+
+static void
+XAAInitializeOffscreenDepths(ScreenPtr pScreen)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ int d, dep;
+
+ infoRec->offscreenDepthsInitialized = TRUE;
+ infoRec->offscreenDepths = 0;
+ if (infoRec->Flags & OFFSCREEN_PIXMAPS) {
+ for (d = 0; d < pScreen->numDepths; d++) {
+ dep = pScreen->allowedDepths[d].depth;
+ if (XAAPixmapBPP(pScreen, dep) == pScrn->bitsPerPixel)
+ infoRec->offscreenDepths |= (1 << (dep - 1));
+ }
+ }
+}
+
+static PixmapPtr
+XAACreatePixmap(ScreenPtr pScreen, int w, int h, int depth, unsigned usage_hint)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ XAAPixmapPtr pPriv;
+ PixmapPtr pPix = NULL;
+ int size = w * h;
+
+ if (w > 32767 || h > 32767)
+ return NullPixmap;
+
+ if (!infoRec->offscreenDepthsInitialized)
+ XAAInitializeOffscreenDepths(pScreen);
+
+ if (pScrn->vtSema &&
+ (usage_hint != CREATE_PIXMAP_USAGE_GLYPH_PICTURE) &&
+ (infoRec->offscreenDepths & (1 << (depth - 1))) &&
+ (size >= MIN_OFFPIX_SIZE) && !SwitchedOut &&
+ (!infoRec->maxOffPixWidth || (w <= infoRec->maxOffPixWidth)) &&
+ (!infoRec->maxOffPixHeight || (h <= infoRec->maxOffPixHeight))) {
+ PixmapLinkPtr pLink;
+ PixmapPtr pScreenPix;
+ FBAreaPtr area;
+ int gran = 0;
+
+ switch (pScrn->bitsPerPixel) {
+ case 24:
+ case 8:
+ gran = 4;
+ break;
+ case 16:
+ gran = 2;
+ break;
+ case 32:
+ gran = 1;
+ break;
+ default:
+ break;
+ }
+
+ if (BITMAP_SCANLINE_PAD == 64)
+ gran *= 2;
+
+ if (!(area = xf86AllocateOffscreenArea(pScreen, w, h, gran, 0,
+ XAARemoveAreaCallback, NULL))) {
+ goto BAILOUT;
+ }
+
+ if (!(pLink = malloc(sizeof(PixmapLink)))) {
+ xf86FreeOffscreenArea(area);
+ goto BAILOUT;
+ }
+
+ XAA_SCREEN_PROLOGUE(pScreen, CreatePixmap);
+ pPix = (*pScreen->CreatePixmap) (pScreen, 0, 0, depth, usage_hint);
+ XAA_SCREEN_EPILOGUE(pScreen, CreatePixmap, XAACreatePixmap);
+
+ if (!pPix) {
+ free(pLink);
+ xf86FreeOffscreenArea(area);
+ goto BAILOUT;
+ }
+
+ pScreenPix = (*pScreen->GetScreenPixmap) (pScreen);
+
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
+ pPix->drawable.x = area->box.x1;
+ pPix->drawable.y = area->box.y1;
+ pPix->drawable.width = w;
+ pPix->drawable.height = h;
+ pPix->drawable.bitsPerPixel = pScrn->bitsPerPixel;
+ pPix->devKind = pScreenPix->devKind;
+ pPix->devPrivate.ptr = pScreenPix->devPrivate.ptr;
+ area->devPrivate.ptr = pPix;
+
+ pPriv->flags = OFFSCREEN;
+ pPriv->offscreenArea = area;
+ pPriv->freeData = FALSE;
+
+ pLink->next = infoRec->OffscreenPixmaps;
+ pLink->pPix = pPix;
+ infoRec->OffscreenPixmaps = pLink;
+ return pPix;
+ }
+ BAILOUT:
+ XAA_SCREEN_PROLOGUE(pScreen, CreatePixmap);
+ pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth, usage_hint);
+ XAA_SCREEN_EPILOGUE(pScreen, CreatePixmap, XAACreatePixmap);
+
+ if (pPix) {
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
+ pPriv->flags = 0;
+ pPriv->offscreenArea = NULL;
+ pPriv->freeData = FALSE;
+ if (!w || !h) /* either scratch or shared memory */
+ pPriv->flags |= SHARED_PIXMAP;
+ }
+
+ return pPix;
+}
+
+static Bool
+XAADestroyPixmap(PixmapPtr pPix)
+{
+ ScreenPtr pScreen = pPix->drawable.pScreen;
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
+ Bool ret;
+
+ if (pPix->refcnt == 1) {
+ if (pPriv->flags & OFFSCREEN) {
+ if (pPriv->flags & DGA_PIXMAP)
+ free(pPriv->offscreenArea);
+ else {
+ FBAreaPtr area = pPriv->offscreenArea;
+ PixmapLinkPtr pLink = infoRec->OffscreenPixmaps;
+ PixmapLinkPtr prev = NULL;
+
+ while (pLink->pPix != pPix) {
+ prev = pLink;
+ pLink = pLink->next;
+ }
+
+ if (prev)
+ prev->next = pLink->next;
+ else
+ infoRec->OffscreenPixmaps = pLink->next;
+
+ if (!area)
+ area = pLink->area;
+
+ xf86FreeOffscreenArea(area);
+ pPriv->offscreenArea = NULL;
+ free(pLink);
+ }
+ }
+
+ if (pPriv->freeData) { /* pixmaps that were once in video ram */
+ free(pPix->devPrivate.ptr);
+ pPix->devPrivate.ptr = NULL;
+ }
+ }
+
+ XAA_SCREEN_PROLOGUE(pScreen, DestroyPixmap);
+ ret = (*pScreen->DestroyPixmap) (pPix);
+ XAA_SCREEN_EPILOGUE(pScreen, DestroyPixmap, XAADestroyPixmap);
+
+ return ret;
+}
+
+static Bool
+XAAChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ Bool ret;
+
+ XAA_SCREEN_PROLOGUE(pScreen, ChangeWindowAttributes);
+ ret = (*pScreen->ChangeWindowAttributes) (pWin, mask);
+ XAA_SCREEN_EPILOGUE(pScreen, ChangeWindowAttributes,
+ XAAChangeWindowAttributes);
+
+ /* we have to assume that shared memory pixmaps are dirty
+ because we can't wrap operations on them */
+
+ if ((mask & CWBackPixmap) && (pWin->backgroundState == BackgroundPixmap) &&
+ PIXMAP_IS_SHARED(pWin->background.pixmap)) {
+ XAAPixmapPtr pPixPriv = XAA_GET_PIXMAP_PRIVATE(pWin->background.pixmap);
+
+ pPixPriv->flags |= DIRTY;
+ }
+ if ((mask & CWBorderPixmap) && !(pWin->borderIsPixel) &&
+ PIXMAP_IS_SHARED(pWin->border.pixmap)) {
+ XAAPixmapPtr pPixPriv = XAA_GET_PIXMAP_PRIVATE(pWin->border.pixmap);
+
+ pPixPriv->flags |= DIRTY;
+ }
+
+ return ret;
+}
+
+/* These two aren't really needed for anything */
+
+static Bool
+XAAEnterVT(int index, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ Bool ret;
+ ScreenPtr pScreen = screenInfo.screens[index];
+ XAAScreenPtr pScreenPriv =
+ (XAAScreenPtr) dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
+
+ pScrn->EnterVT = pScreenPriv->EnterVT;
+ ret = ((*pScreenPriv->EnterVT) (index, flags));
+ pScreenPriv->EnterVT = pScrn->EnterVT;
+ pScrn->EnterVT = XAAEnterVT;
+ return ret;
+}
+
+static void
+XAALeaveVT(int index, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ ScreenPtr pScreen = screenInfo.screens[index];
+ XAAScreenPtr pScreenPriv =
+ (XAAScreenPtr) dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
+ XAAInfoRecPtr infoRec = pScreenPriv->AccelInfoRec;
+
+ if (infoRec->NeedToSync) {
+ (*infoRec->Sync) (infoRec->pScrn);
+ infoRec->NeedToSync = FALSE;
+ }
+
+ pScrn->LeaveVT = pScreenPriv->LeaveVT;
+ (*pScreenPriv->LeaveVT) (index, flags);
+ pScreenPriv->LeaveVT = pScrn->LeaveVT;
+ pScrn->LeaveVT = XAALeaveVT;
+}
+
+typedef struct {
+ Bool UsingPixmapCache;
+ Bool CanDoColor8x8;
+ Bool CanDoMono8x8;
+} SavedCacheState, *SavedCacheStatePtr;
+
+static int
+XAASetDGAMode(int index, int num, DGADevicePtr devRet)
+{
+ ScreenPtr pScreen = screenInfo.screens[index];
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+ XAAScreenPtr pScreenPriv =
+ (XAAScreenPtr) dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
+ int ret;
+
+ if (!num && infoRec->dgaSaves) { /* restore old pixmap cache state */
+ SavedCacheStatePtr state = (SavedCacheStatePtr) infoRec->dgaSaves;
+
+ infoRec->UsingPixmapCache = state->UsingPixmapCache;
+ infoRec->CanDoColor8x8 = state->CanDoColor8x8;
+ infoRec->CanDoMono8x8 = state->CanDoMono8x8;
+ free(infoRec->dgaSaves);
+ infoRec->dgaSaves = NULL;
+ }
+
+ ret = (*pScreenPriv->SetDGAMode) (index, num, devRet);
+ if (ret != Success)
+ return ret;
+
+ if (num && devRet->pPix) { /* accelerate this pixmap */
+ XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE(devRet->pPix);
+ FBAreaPtr area;
+
+ if ((area = malloc(sizeof(FBArea)))) {
+ area->pScreen = pScreen;
+ area->box.x1 = 0;
+ area->box.x2 = 0;
+ area->box.y1 = devRet->mode->pixmapWidth;
+ area->box.y2 = devRet->mode->pixmapHeight;
+ area->granularity = 0;
+ area->MoveAreaCallback = 0;
+ area->RemoveAreaCallback = 0;
+ area->devPrivate.ptr = 0;
+
+ pixPriv->flags |= OFFSCREEN | DGA_PIXMAP;
+ pixPriv->offscreenArea = area;
+
+ if (!infoRec->dgaSaves) { /* save pixmap cache state */
+ SavedCacheStatePtr state = malloc(sizeof(SavedCacheState));
+
+ state->UsingPixmapCache = infoRec->UsingPixmapCache;
+ state->CanDoColor8x8 = infoRec->CanDoColor8x8;
+ state->CanDoMono8x8 = infoRec->CanDoMono8x8;
+ infoRec->dgaSaves = (char *) state;
+
+ infoRec->UsingPixmapCache = FALSE;
+ if (infoRec->PixmapCacheFlags & CACHE_MONO_8x8)
+ infoRec->CanDoMono8x8 = FALSE;
+ if (infoRec->PixmapCacheFlags & CACHE_COLOR_8x8)
+ infoRec->CanDoColor8x8 = FALSE;
+ }
+ }
+ }
+
+ return ret;
+}
+
+static void
+XAAEnableDisableFBAccess(int index, Bool enable)
+{
+ ScreenPtr pScreen = screenInfo.screens[index];
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+ XAAScreenPtr pScreenPriv =
+ (XAAScreenPtr) dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
+
+ if (!enable) {
+ if ((infoRec->Flags & OFFSCREEN_PIXMAPS) && (infoRec->OffscreenPixmaps))
+ XAAMoveOutOffscreenPixmaps(pScreen);
+ if (infoRec->Flags & PIXMAP_CACHE)
+ XAAInvalidatePixmapCache(pScreen);
+ SwitchedOut = TRUE;
+ }
+
+ (*pScreenPriv->EnableDisableFBAccess) (index, enable);
+
+ if (enable) {
+ if ((infoRec->Flags & OFFSCREEN_PIXMAPS) && (infoRec->OffscreenPixmaps))
+ XAAMoveInOffscreenPixmaps(pScreen);
+ SwitchedOut = FALSE;
+ }
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaInitAccel.c b/xorg-server/hw/xfree86/xaa/xaaInitAccel.c
index d24599d48..2a85a1996 100644
--- a/xorg-server/hw/xfree86/xaa/xaaInitAccel.c
+++ b/xorg-server/hw/xfree86/xaa/xaaInitAccel.c
@@ -1,1498 +1,1571 @@
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <string.h>
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-#include "xf86fbman.h"
-#include "servermd.h"
-
-/*
- * XAA Config options
- */
-
-typedef enum {
- XAAOPT_SCREEN_TO_SCREEN_COPY,
- XAAOPT_SOLID_FILL_RECT,
- XAAOPT_SOLID_FILL_TRAP,
- XAAOPT_SOLID_TWO_POINT_LINE,
- XAAOPT_SOLID_BRESENHAM_LINE,
- XAAOPT_SOLID_HORVERT_LINE,
- XAAOPT_DASHED_TWO_POINT_LINE,
- XAAOPT_DASHED_BRESENHAM_LINE,
- XAAOPT_MONO_8x8_PATTERN_FILL_RECT,
- XAAOPT_MONO_8x8_PATTERN_FILL_TRAP,
- XAAOPT_COL_8x8_PATTERN_FILL_RECT,
- XAAOPT_COL_8x8_PATTERN_FILL_TRAP,
- XAAOPT_CPU_TO_SCREEN_COL_EXP_FILL,
- XAAOPT_SCANLINE_CPU_TO_SCREEN_COL_EXP_FILL,
- XAAOPT_SCREEN_TO_SCREEN_COL_EXP_FILL,
- XAAOPT_IMAGE_WRITE_RECT,
- XAAOPT_SCANLINE_IMAGE_WRITE_RECT,
- XAAOPT_WRITE_BITMAP,
- XAAOPT_WRITE_PIXMAP,
- XAAOPT_PIXMAP_CACHE,
- XAAOPT_OFFSCREEN_PIXMAPS,
- XAAOPT_HAS_DUMB_INVERTED_OPTION_SENSE
-} XAAOpts;
-
-static const OptionInfoRec XAAOptions[] = {
- {XAAOPT_SCREEN_TO_SCREEN_COPY, "XaaNoScreenToScreenCopy",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_SOLID_FILL_RECT, "XaaNoSolidFillRect",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_SOLID_FILL_TRAP, "XaaNoSolidFillTrap",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_SOLID_TWO_POINT_LINE, "XaaNoSolidTwoPointLine",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_SOLID_BRESENHAM_LINE, "XaaNoSolidBresenhamLine",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_SOLID_HORVERT_LINE, "XaaNoSolidHorVertLine",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_DASHED_TWO_POINT_LINE, "XaaNoDashedTwoPointLine",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_DASHED_BRESENHAM_LINE, "XaaNoDashedBresenhamLine",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_MONO_8x8_PATTERN_FILL_RECT, "XaaNoMono8x8PatternFillRect",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_MONO_8x8_PATTERN_FILL_TRAP, "XaaNoMono8x8PatternFillTrap",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_COL_8x8_PATTERN_FILL_RECT, "XaaNoColor8x8PatternFillRect",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_COL_8x8_PATTERN_FILL_TRAP, "XaaNoColor8x8PatternFillTrap",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_CPU_TO_SCREEN_COL_EXP_FILL, "XaaNoCPUToScreenColorExpandFill",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_SCANLINE_CPU_TO_SCREEN_COL_EXP_FILL,"XaaNoScanlineCPUToScreenColorExpandFill",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_SCREEN_TO_SCREEN_COL_EXP_FILL, "XaaNoScreenToScreenColorExpandFill",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_IMAGE_WRITE_RECT, "XaaNoImageWriteRect",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_SCANLINE_IMAGE_WRITE_RECT, "XaaNoScanlineImageWriteRect",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_WRITE_BITMAP, "XaaNoWriteBitmap",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_WRITE_PIXMAP, "XaaNoWritePixmap",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_PIXMAP_CACHE, "XaaNoPixmapCache",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_OFFSCREEN_PIXMAPS, "XaaNoOffscreenPixmaps",
- OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_HAS_DUMB_INVERTED_OPTION_SENSE, "XaaOffscreenPixmaps",
- OPTV_BOOLEAN, {0}, FALSE },
- { -1, NULL,
- OPTV_NONE, {0}, FALSE }
-};
-
-static XF86ModuleVersionInfo xaaVersRec =
-{
- "xaa",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- XAA_VERSION_MAJOR,
- XAA_VERSION_MINOR,
- XAA_VERSION_RELEASE,
- ABI_CLASS_VIDEODRV, /* requires the video driver ABI */
- ABI_VIDEODRV_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0}
-};
-
-_X_EXPORT XF86ModuleData xaaModuleData = { &xaaVersRec, NULL, NULL };
-
-Bool
-XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
-{
- int index = pScreen->myNum;
- ScrnInfoPtr pScrn = xf86Screens[index];
- Bool HaveScreenToScreenCopy = FALSE;
- Bool HaveColorExpansion = FALSE;
- Bool HaveScanlineColorExpansion = FALSE;
- Bool HaveSolidFillRect = FALSE;
- Bool HaveMono8x8PatternFillRect = FALSE;
- Bool HaveColor8x8PatternFillRect = FALSE;
- Bool HaveSolidFillTrap = FALSE;
- Bool HaveMono8x8PatternFillTrap = FALSE;
- Bool HaveColor8x8PatternFillTrap = FALSE;
- Bool HaveSolidTwoPointLine = FALSE;
- Bool HaveSolidBresenhamLine = FALSE;
- Bool HaveSolidHorVertLine = FALSE;
- Bool HaveDashedTwoPointLine = FALSE;
- Bool HaveDashedBresenhamLine = FALSE;
- Bool HaveImageWriteRect = FALSE;
- Bool HaveScanlineImageWriteRect = FALSE;
- Bool HaveScreenToScreenColorExpandFill = FALSE;
- OptionInfoPtr options;
- int is_shared = 0;
- int i;
-
- options = xnfalloc(sizeof(XAAOptions));
- (void)memcpy(options, XAAOptions, sizeof(XAAOptions));
- xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
-
- infoRec->pScrn = pScrn;
- infoRec->NeedToSync = FALSE;
-
- /* must have a Sync function */
- if(!infoRec->Sync) return FALSE;
- for(i = 0; i < pScrn->numEntities; i++) {
- if(xf86IsEntityShared(pScrn->entityList[i])) is_shared = 1;
- }
-
- /* If this PCI entity has IS_SHARED_ACCEL set in entityProp
- * then a RestoreAccelState function is required
- */
- if(!infoRec->RestoreAccelState && is_shared) return FALSE;
-
- if(infoRec->RestoreAccelState) {
- if(!XAAInitStateWrap(pScreen, infoRec)) return FALSE;
- }
-
- if (serverGeneration == 1)
- xf86DrvMsg(index, X_INFO,
- "Using XFree86 Acceleration Architecture (XAA)\n");
-
-
- /************** Low Level *************/
-
- if(!infoRec->SetClippingRectangle || !infoRec->DisableClipping) {
- infoRec->ClippingFlags = 0;
- infoRec->SetClippingRectangle = NULL;
- infoRec->DisableClipping = NULL;
- }
-
- /**** CopyArea ****/
-
- if(infoRec->SetupForScreenToScreenCopy &&
- infoRec->SubsequentScreenToScreenCopy &&
- !xf86ReturnOptValBool(options, XAAOPT_SCREEN_TO_SCREEN_COPY, FALSE)) {
- HaveScreenToScreenCopy = TRUE;
- } else {
- infoRec->ScreenToScreenCopyFlags = 0;
- infoRec->SetupForScreenToScreenCopy = NULL;
- infoRec->SubsequentScreenToScreenCopy = NULL;
- }
-
- /**** Solid Filled Rects ****/
-
- if(infoRec->SetupForSolidFill && infoRec->SubsequentSolidFillRect &&
- !xf86ReturnOptValBool(options, XAAOPT_SOLID_FILL_RECT, FALSE)) {
- HaveSolidFillRect = TRUE;
- if(infoRec->SubsequentSolidFillTrap &&
- !xf86ReturnOptValBool(options, XAAOPT_SOLID_FILL_TRAP, FALSE))
- HaveSolidFillTrap = TRUE;
- else
- infoRec->SubsequentSolidFillTrap = NULL;
- } else {
- infoRec->SolidFillFlags = 0;
- infoRec->SetupForSolidFill = NULL;
- infoRec->SubsequentSolidFillRect = NULL;
- infoRec->SubsequentSolidFillTrap = NULL;
- }
-
- /**** Solid lines ****/
-
- if(infoRec->SetupForSolidLine) {
- if(infoRec->SubsequentSolidTwoPointLine &&
- !xf86ReturnOptValBool(options,
- XAAOPT_SOLID_TWO_POINT_LINE, FALSE))
- HaveSolidTwoPointLine = TRUE;
- if(infoRec->SubsequentSolidBresenhamLine &&
- !xf86ReturnOptValBool(options, XAAOPT_SOLID_BRESENHAM_LINE, FALSE)) {
- HaveSolidBresenhamLine = TRUE;
-
- if(infoRec->SolidBresenhamLineErrorTermBits)
- infoRec->SolidBresenhamLineErrorTermBits =
- ~((1 << infoRec->SolidBresenhamLineErrorTermBits) - 1);
- }
-
- if(infoRec->SubsequentSolidHorVertLine &&
- !xf86ReturnOptValBool(options,
- XAAOPT_SOLID_HORVERT_LINE, FALSE))
- HaveSolidHorVertLine = TRUE;
- else if(HaveSolidTwoPointLine) {
- infoRec->SubsequentSolidHorVertLine =
- XAASolidHorVertLineAsTwoPoint;
- HaveSolidHorVertLine = TRUE;
- } else if(HaveSolidBresenhamLine) {
- infoRec->SubsequentSolidHorVertLine =
- XAASolidHorVertLineAsBresenham;
- HaveSolidHorVertLine = TRUE;
- }
- }
-
- /* XXX Should this also check for XAAOPT_SOLID_HORVERT_LINE? */
- if (!HaveSolidTwoPointLine &&
- !HaveSolidBresenhamLine &&
- !HaveSolidHorVertLine &&
- HaveSolidFillRect) {
- infoRec->SetupForSolidLine = infoRec->SetupForSolidFill;
- infoRec->SubsequentSolidHorVertLine = XAASolidHorVertLineAsRects;
- infoRec->SolidLineFlags = infoRec->SolidFillFlags;
- HaveSolidHorVertLine = TRUE;
- }
-
- if (!HaveSolidTwoPointLine)
- infoRec->SubsequentSolidTwoPointLine = NULL;
- if (!HaveSolidBresenhamLine)
- infoRec->SubsequentSolidBresenhamLine = NULL;
- if (!HaveSolidHorVertLine)
- infoRec->SubsequentSolidHorVertLine = NULL;
-
- /* Disable all if nothing left over */
- if (!HaveSolidTwoPointLine &&
- !HaveSolidBresenhamLine &&
- !HaveSolidHorVertLine) {
- infoRec->SolidLineFlags = 0;
- infoRec->SetupForSolidLine = NULL;
- }
-
- /**** 8x8 Mono Pattern Filled Rects ****/
-
- if(infoRec->SetupForMono8x8PatternFill &&
- infoRec->SubsequentMono8x8PatternFillRect &&
- !xf86ReturnOptValBool(options,
- XAAOPT_MONO_8x8_PATTERN_FILL_RECT,
- FALSE)) {
- HaveMono8x8PatternFillRect = TRUE;
- if(infoRec->SubsequentMono8x8PatternFillTrap &&
- !xf86ReturnOptValBool(options,
- XAAOPT_MONO_8x8_PATTERN_FILL_TRAP,
- FALSE))
- HaveMono8x8PatternFillTrap = TRUE;
-
- if(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_BITS) {
- infoRec->CanDoMono8x8 = TRUE;
- } else { /* others require caching */
- int min_pitch;
- infoRec->PixmapCacheFlags |= CACHE_MONO_8x8;
-
- switch(pScrn->bitsPerPixel) {
- case 32: min_pitch = 2; break;
- case 24: min_pitch = 3; break;
- case 16: min_pitch = 4; break;
- default: min_pitch = 8; break;
- }
-
- if(min_pitch > infoRec->MonoPatternPitch)
- infoRec->MonoPatternPitch = min_pitch;
-
- if(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN) {
- if(!infoRec->CacheWidthMono8x8Pattern ||
- !infoRec->CacheHeightMono8x8Pattern) {
- infoRec->CacheWidthMono8x8Pattern =
- infoRec->MonoPatternPitch;
- infoRec->CacheHeightMono8x8Pattern = 1;
- }
- } else {
- int numPerLine = 128/infoRec->MonoPatternPitch;
-
- if(!infoRec->CacheWidthMono8x8Pattern ||
- !infoRec->CacheHeightMono8x8Pattern) {
- infoRec->CacheWidthMono8x8Pattern =
- numPerLine * infoRec->MonoPatternPitch;
- infoRec->CacheHeightMono8x8Pattern =
- (64 + numPerLine - 1)/numPerLine;
- }
- }
- }
- } else {
- infoRec->Mono8x8PatternFillFlags = 0;
- infoRec->SetupForMono8x8PatternFill = NULL;
- infoRec->SubsequentMono8x8PatternFillRect = NULL;
- }
-
- /**** Dashed lines ****/
-
- if(infoRec->SetupForDashedLine && infoRec->DashPatternMaxLength) {
- if(infoRec->SubsequentDashedTwoPointLine &&
- !xf86ReturnOptValBool(options, XAAOPT_DASHED_TWO_POINT_LINE,
- FALSE))
- HaveDashedTwoPointLine = TRUE;
- if(infoRec->SubsequentDashedBresenhamLine &&
- !xf86ReturnOptValBool(options, XAAOPT_DASHED_BRESENHAM_LINE,
- FALSE)) {
- HaveDashedBresenhamLine = TRUE;
-
- if(infoRec->DashedBresenhamLineErrorTermBits)
- infoRec->DashedBresenhamLineErrorTermBits =
- ~((1 << infoRec->DashedBresenhamLineErrorTermBits) - 1);
- }
- }
-
- if (!HaveDashedTwoPointLine)
- infoRec->SubsequentDashedTwoPointLine = NULL;
- if (!HaveDashedBresenhamLine)
- infoRec->SubsequentDashedBresenhamLine = NULL;
-
- /* Disable all if nothing left over */
- if (!HaveDashedTwoPointLine && !HaveDashedBresenhamLine) {
- infoRec->DashedLineFlags = 0;
- infoRec->SetupForDashedLine = NULL;
- }
-
- /**** 8x8 Color Pattern Filled Rects ****/
-
- if(infoRec->SetupForColor8x8PatternFill &&
- infoRec->SubsequentColor8x8PatternFillRect &&
- !xf86ReturnOptValBool(options, XAAOPT_COL_8x8_PATTERN_FILL_RECT, FALSE)) {
- HaveColor8x8PatternFillRect = TRUE;
- if(infoRec->SubsequentColor8x8PatternFillTrap &&
- !xf86ReturnOptValBool(options, XAAOPT_COL_8x8_PATTERN_FILL_TRAP,
- FALSE))
- HaveColor8x8PatternFillTrap = TRUE;
- else
- infoRec->SubsequentColor8x8PatternFillTrap = NULL;
-
- infoRec->PixmapCacheFlags |= CACHE_COLOR_8x8;
-
- if(infoRec->Color8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN) {
- if(!infoRec->CacheWidthColor8x8Pattern ||
- !infoRec->CacheHeightColor8x8Pattern) {
- infoRec->CacheWidthColor8x8Pattern = 64;
- infoRec->CacheHeightColor8x8Pattern = 1;
- }
- } else {
- if(!infoRec->CacheWidthColor8x8Pattern ||
- !infoRec->CacheHeightColor8x8Pattern) {
- infoRec->CacheWidthColor8x8Pattern = 128;
- infoRec->CacheHeightColor8x8Pattern = 8;
- }
- }
- } else {
- infoRec->Color8x8PatternFillFlags = 0;
- infoRec->SetupForColor8x8PatternFill = NULL;
- infoRec->SubsequentColor8x8PatternFillRect = NULL;
- infoRec->SubsequentColor8x8PatternFillTrap = NULL;
- }
-
- /**** Color Expansion ****/
-
- if(infoRec->SetupForCPUToScreenColorExpandFill &&
- infoRec->ColorExpandBase &&
- infoRec->SubsequentCPUToScreenColorExpandFill &&
- !xf86ReturnOptValBool(options, XAAOPT_CPU_TO_SCREEN_COL_EXP_FILL,
- FALSE)) {
- int dwordsNeeded = pScrn->virtualX;
-
- infoRec->ColorExpandRange >>= 2; /* convert to DWORDS */
- HaveColorExpansion = TRUE;
-
- if(infoRec->CPUToScreenColorExpandFillFlags &
- LEFT_EDGE_CLIPPING_NEGATIVE_X)
- dwordsNeeded += 31;
- dwordsNeeded = (dwordsNeeded + 31) >> 5;
- if(dwordsNeeded > infoRec->ColorExpandRange)
- infoRec->CPUToScreenColorExpandFillFlags |= CPU_TRANSFER_BASE_FIXED;
- } else {
- infoRec->CPUToScreenColorExpandFillFlags = 0;
- infoRec->SetupForCPUToScreenColorExpandFill = NULL;
- infoRec->SubsequentCPUToScreenColorExpandFill = NULL;
- }
-
- /**** Scanline Color Expansion ****/
-
- if(infoRec->SetupForScanlineCPUToScreenColorExpandFill &&
- infoRec->SubsequentScanlineCPUToScreenColorExpandFill &&
- infoRec->SubsequentColorExpandScanline &&
- infoRec->ScanlineColorExpandBuffers &&
- (infoRec->NumScanlineColorExpandBuffers > 0) &&
- !xf86ReturnOptValBool(options,
- XAAOPT_SCANLINE_CPU_TO_SCREEN_COL_EXP_FILL,
- FALSE)) {
- HaveScanlineColorExpansion = TRUE;
- } else {
- infoRec->ScanlineCPUToScreenColorExpandFillFlags = 0;
- infoRec->SetupForScanlineCPUToScreenColorExpandFill = NULL;
- infoRec->SubsequentScanlineCPUToScreenColorExpandFill = NULL;
- infoRec->SubsequentColorExpandScanline = NULL;
- }
-
- /**** Screen to Screen Color Expansion ****/
-
- if(infoRec->SetupForScreenToScreenColorExpandFill &&
- infoRec->SubsequentScreenToScreenColorExpandFill &&
- !xf86ReturnOptValBool(options, XAAOPT_SCREEN_TO_SCREEN_COL_EXP_FILL,
- FALSE)) {
- HaveScreenToScreenColorExpandFill = TRUE;
- if (!infoRec->CacheColorExpandDensity)
- infoRec->CacheColorExpandDensity = 1;
- } else {
- infoRec->ScreenToScreenColorExpandFillFlags = 0;
- infoRec->SetupForScreenToScreenColorExpandFill = NULL;
- infoRec->SubsequentScreenToScreenColorExpandFill = NULL;
- }
-
- /**** Image Writes ****/
-
- if(infoRec->SetupForImageWrite && infoRec->ImageWriteBase &&
- infoRec->SubsequentImageWriteRect &&
- !xf86ReturnOptValBool(options, XAAOPT_IMAGE_WRITE_RECT, FALSE)) {
-
- infoRec->ImageWriteRange >>= 2; /* convert to DWORDS */
- if(infoRec->ImageWriteFlags & CPU_TRANSFER_BASE_FIXED)
- infoRec->ImageWriteRange = 0;
- HaveImageWriteRect = TRUE;
- } else {
- infoRec->ImageWriteFlags = 0;
- infoRec->SetupForImageWrite = NULL;
- infoRec->SubsequentImageWriteRect = NULL;
- }
-
- /**** Scanline Image Writes ****/
-
- if(infoRec->SetupForScanlineImageWrite &&
- infoRec->SubsequentScanlineImageWriteRect &&
- infoRec->SubsequentImageWriteScanline &&
- infoRec->ScanlineImageWriteBuffers &&
- (infoRec->NumScanlineImageWriteBuffers > 0) &&
- !xf86ReturnOptValBool(options, XAAOPT_SCANLINE_IMAGE_WRITE_RECT,
- FALSE)) {
- HaveScanlineImageWriteRect = TRUE;
- } else {
- infoRec->ScanlineImageWriteFlags = 0;
- infoRec->SetupForScanlineImageWrite = NULL;
- infoRec->SubsequentScanlineImageWriteRect = NULL;
- infoRec->SubsequentImageWriteScanline = NULL;
- }
-
-#ifndef __i386__
- /* XAA makes some unaligned accesses when clipping is not available */
-# define CLIP_FLAGS (LEFT_EDGE_CLIPPING | LEFT_EDGE_CLIPPING_NEGATIVE_X)
- if(HaveImageWriteRect &&
- ((infoRec->ImageWriteFlags & CLIP_FLAGS) != CLIP_FLAGS))
- {
- HaveImageWriteRect = FALSE;
- }
- if(HaveScanlineImageWriteRect &&
- ((infoRec->ScanlineImageWriteFlags & CLIP_FLAGS) != CLIP_FLAGS))
- {
- HaveScanlineImageWriteRect = FALSE;
- }
-#endif
-
- if (serverGeneration == 1) {
- if(HaveScreenToScreenCopy)
- xf86ErrorF("\tScreen to screen bit blits\n");
- if(HaveSolidFillRect)
- xf86ErrorF("\tSolid filled rectangles\n");
- if(HaveSolidFillTrap)
- xf86ErrorF("\tSolid filled trapezoids\n");
- if(HaveMono8x8PatternFillRect)
- xf86ErrorF("\t8x8 mono pattern filled rectangles\n");
- if(HaveMono8x8PatternFillTrap)
- xf86ErrorF("\t8x8 mono pattern filled trapezoids\n");
- if(HaveColor8x8PatternFillRect)
- xf86ErrorF("\t8x8 color pattern filled rectangles\n");
- if(HaveColor8x8PatternFillTrap)
- xf86ErrorF("\t8x8 color pattern filled trapezoids\n");
-
- if(HaveColorExpansion)
- xf86ErrorF("\tCPU to Screen color expansion\n");
- else if(HaveScanlineColorExpansion)
- xf86ErrorF("\tIndirect CPU to Screen color expansion\n");
-
- if(HaveScreenToScreenColorExpandFill)
- xf86ErrorF("\tScreen to Screen color expansion\n");
-
- if(HaveSolidTwoPointLine || HaveSolidBresenhamLine)
- xf86ErrorF("\tSolid Lines\n");
- else if(HaveSolidHorVertLine)
- xf86ErrorF("\tSolid Horizontal and Vertical Lines\n");
-
- if(HaveDashedTwoPointLine || HaveDashedBresenhamLine)
- xf86ErrorF("\tDashed Lines\n");
-
- if(HaveImageWriteRect)
- xf86ErrorF("\tImage Writes\n");
- else if(HaveScanlineImageWriteRect)
- xf86ErrorF("\tScanline Image Writes\n");
-
- }
-
-#define XAAMSG(s) do { if (serverGeneration == 1) xf86ErrorF(s); } while (0)
-
- if((infoRec->Flags & OFFSCREEN_PIXMAPS) && HaveScreenToScreenCopy &&
- xf86ReturnOptValBool(options,
- XAAOPT_HAS_DUMB_INVERTED_OPTION_SENSE,
- FALSE))
- {
- XAAMSG("\tOffscreen Pixmaps\n");
- } else {
- infoRec->Flags &= ~OFFSCREEN_PIXMAPS;
- }
-
-
- /************** Mid Level *************/
-
- /**** ScreenToScreenBitBlt ****/
-
- if(infoRec->ScreenToScreenBitBlt) {
- XAAMSG("\tDriver provided ScreenToScreenBitBlt replacement\n");
- } else if(HaveScreenToScreenCopy) {
- infoRec->ScreenToScreenBitBlt = XAAScreenToScreenBitBlt;
- infoRec->ScreenToScreenBitBltFlags = infoRec->ScreenToScreenCopyFlags;
- }
-
- /**** FillSolidRects ****/
-
- if(infoRec->FillSolidRects) {
- XAAMSG("\tDriver provided FillSolidRects replacement\n");
- } else if(HaveSolidFillRect) {
- infoRec->FillSolidRects = XAAFillSolidRects;
- infoRec->FillSolidRectsFlags = infoRec->SolidFillFlags;
- }
-
- /**** FillSolidSpans ****/
-
- if(infoRec->FillSolidSpans) {
- XAAMSG("\tDriver provided FillSolidSpans replacement\n");
- } else if(HaveSolidFillRect) {
- infoRec->FillSolidSpans = XAAFillSolidSpans;
- infoRec->FillSolidSpansFlags = infoRec->SolidFillFlags;
- }
-
- /**** FillMono8x8PatternRects ****/
-
- if(infoRec->FillMono8x8PatternRects) {
- XAAMSG("\tDriver provided FillMono8x8PatternRects replacement\n");
- } else if(HaveMono8x8PatternFillRect) {
- infoRec->FillMono8x8PatternRects =
- (infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) ?
- XAAFillMono8x8PatternRectsScreenOrigin :
- XAAFillMono8x8PatternRects;
-
- infoRec->FillMono8x8PatternRectsFlags =
- infoRec->Mono8x8PatternFillFlags;
- }
-
- /**** FillMono8x8PatternSpans ****/
-
- if(infoRec->FillMono8x8PatternSpans) {
- XAAMSG("\tDriver provided FillMono8x8PatternSpans replacement\n");
- } else if(HaveMono8x8PatternFillRect) {
- infoRec->FillMono8x8PatternSpans =
- (infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) ?
- XAAFillMono8x8PatternSpansScreenOrigin:
- XAAFillMono8x8PatternSpans;
-
- infoRec->FillMono8x8PatternSpansFlags =
- infoRec->Mono8x8PatternFillFlags;
- }
-
- /**** FillColor8x8Rects ****/
-
- if(infoRec->FillColor8x8PatternRects) {
- XAAMSG("\tDriver provided FillColor8x8PatternRects replacement\n");
- } else if(HaveColor8x8PatternFillRect) {
- infoRec->FillColor8x8PatternRects =
- (infoRec->Color8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) ?
- XAAFillColor8x8PatternRectsScreenOrigin :
- XAAFillColor8x8PatternRects;
-
- infoRec->FillColor8x8PatternRectsFlags =
- infoRec->Color8x8PatternFillFlags;
- }
-
- /**** FillColor8x8Spans ****/
-
- if(infoRec->FillColor8x8PatternSpans) {
- XAAMSG("\tDriver provided FillColor8x8PatternSpans replacement\n");
- } else if(HaveColor8x8PatternFillRect) {
- infoRec->FillColor8x8PatternSpans =
- (infoRec->Color8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) ?
- XAAFillColor8x8PatternSpansScreenOrigin:
- XAAFillColor8x8PatternSpans;
-
- infoRec->FillColor8x8PatternSpansFlags =
- infoRec->Color8x8PatternFillFlags;
- }
-
- /**** FillCacheBltRects ****/
-
- if(infoRec->FillCacheBltRects) {
- XAAMSG("\tDriver provided FillCacheBltRects replacement\n");
- } else if(HaveScreenToScreenCopy) {
- infoRec->FillCacheBltRects = XAAFillCacheBltRects;
- infoRec->FillCacheBltRectsFlags = infoRec->ScreenToScreenCopyFlags;
- }
-
- /**** FillCacheBltSpans ****/
-
- if(infoRec->FillCacheBltSpans) {
- XAAMSG("\tDriver provided FillCacheBltSpans replacement\n");
- } else if(HaveScreenToScreenCopy) {
- infoRec->FillCacheBltSpans = XAAFillCacheBltSpans;
- infoRec->FillCacheBltSpansFlags = infoRec->ScreenToScreenCopyFlags;
- }
-
- /**** FillCacheExpandRects ****/
-
- if(infoRec->FillCacheExpandRects) {
- XAAMSG("\tDriver provided FillCacheExpandRects replacement\n");
- } else if(HaveScreenToScreenColorExpandFill) {
- infoRec->FillCacheExpandRects = XAAFillCacheExpandRects;
- infoRec->FillCacheExpandRectsFlags =
- infoRec->ScreenToScreenColorExpandFillFlags;
- }
-
- /**** FillCacheExpandSpans ****/
-
- if(infoRec->FillCacheExpandSpans) {
- XAAMSG("\tDriver provided FillCacheExpandSpans replacement\n");
- } else if(HaveScreenToScreenColorExpandFill) {
- infoRec->FillCacheExpandSpans = XAAFillCacheExpandSpans;
- infoRec->FillCacheExpandSpansFlags =
- infoRec->ScreenToScreenColorExpandFillFlags;
- }
-
- /**** FillColorExpandRects ****/
-
- if(infoRec->FillColorExpandRects) {
- XAAMSG("\tDriver provided FillColorExpandRects replacement\n");
- } else if(HaveColorExpansion) {
- if (infoRec->CPUToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP) {
- if(infoRec->CPUToScreenColorExpandFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST) {
- if(infoRec->CPUToScreenColorExpandFillFlags &
- CPU_TRANSFER_BASE_FIXED)
- infoRec->FillColorExpandRects =
- XAAFillColorExpandRects3MSBFirstFixedBase;
- else
- infoRec->FillColorExpandRects =
- XAAFillColorExpandRects3MSBFirst;
- } else {
- if(infoRec->CPUToScreenColorExpandFillFlags &
- CPU_TRANSFER_BASE_FIXED)
- infoRec->FillColorExpandRects =
- XAAFillColorExpandRects3LSBFirstFixedBase;
- else
- infoRec->FillColorExpandRects =
- XAAFillColorExpandRects3LSBFirst;
- }
- } else {
- if(infoRec->CPUToScreenColorExpandFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST) {
- if(infoRec->CPUToScreenColorExpandFillFlags &
- CPU_TRANSFER_BASE_FIXED)
- infoRec->FillColorExpandRects =
- XAAFillColorExpandRectsMSBFirstFixedBase;
- else
- infoRec->FillColorExpandRects =
- XAAFillColorExpandRectsMSBFirst;
- } else {
- if(infoRec->CPUToScreenColorExpandFillFlags &
- CPU_TRANSFER_BASE_FIXED)
- infoRec->FillColorExpandRects =
- XAAFillColorExpandRectsLSBFirstFixedBase;
- else
- infoRec->FillColorExpandRects =
- XAAFillColorExpandRectsLSBFirst;
- }
- }
- infoRec->FillColorExpandRectsFlags =
- infoRec->CPUToScreenColorExpandFillFlags;
- } else if(HaveScanlineColorExpansion) {
- if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
- TRIPLE_BITS_24BPP) {
- if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST)
- infoRec->FillColorExpandRects =
- XAAFillScanlineColorExpandRects3MSBFirst;
- else
- infoRec->FillColorExpandRects =
- XAAFillScanlineColorExpandRects3LSBFirst;
- } else {
- if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST)
- infoRec->FillColorExpandRects =
- XAAFillScanlineColorExpandRectsMSBFirst;
- else
- infoRec->FillColorExpandRects =
- XAAFillScanlineColorExpandRectsLSBFirst;
- }
- infoRec->FillColorExpandRectsFlags =
- infoRec->ScanlineCPUToScreenColorExpandFillFlags;
- }
-
- /**** FillColorExpandSpans ****/
-
- if(infoRec->FillColorExpandSpans) {
- XAAMSG("\tDriver provided FillColorExpandSpans replacement\n");
- } else if(HaveColorExpansion) {
- if (infoRec->CPUToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP) {
- if(infoRec->CPUToScreenColorExpandFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST) {
- if(infoRec->CPUToScreenColorExpandFillFlags &
- CPU_TRANSFER_BASE_FIXED)
- infoRec->FillColorExpandSpans =
- XAAFillColorExpandSpans3MSBFirstFixedBase;
- else
- infoRec->FillColorExpandSpans =
- XAAFillColorExpandSpans3MSBFirst;
- } else {
- if(infoRec->CPUToScreenColorExpandFillFlags &
- CPU_TRANSFER_BASE_FIXED)
- infoRec->FillColorExpandSpans =
- XAAFillColorExpandSpans3LSBFirstFixedBase;
- else
- infoRec->FillColorExpandSpans =
- XAAFillColorExpandSpans3LSBFirst;
- }
- } else {
- if(infoRec->CPUToScreenColorExpandFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST) {
- if(infoRec->CPUToScreenColorExpandFillFlags &
- CPU_TRANSFER_BASE_FIXED)
- infoRec->FillColorExpandSpans =
- XAAFillColorExpandSpansMSBFirstFixedBase;
- else
- infoRec->FillColorExpandSpans =
- XAAFillColorExpandSpansMSBFirst;
- } else {
- if(infoRec->CPUToScreenColorExpandFillFlags &
- CPU_TRANSFER_BASE_FIXED)
- infoRec->FillColorExpandSpans =
- XAAFillColorExpandSpansLSBFirstFixedBase;
- else
- infoRec->FillColorExpandSpans =
- XAAFillColorExpandSpansLSBFirst;
- }
- }
- infoRec->FillColorExpandSpansFlags =
- infoRec->CPUToScreenColorExpandFillFlags;
- } else if(HaveScanlineColorExpansion) {
- if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
- TRIPLE_BITS_24BPP) {
- if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST)
- infoRec->FillColorExpandSpans =
- XAAFillScanlineColorExpandSpans3MSBFirst;
- else
- infoRec->FillColorExpandSpans =
- XAAFillScanlineColorExpandSpans3LSBFirst;
- } else {
- if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST)
- infoRec->FillColorExpandSpans =
- XAAFillScanlineColorExpandSpansMSBFirst;
- else
- infoRec->FillColorExpandSpans =
- XAAFillScanlineColorExpandSpansLSBFirst;
- }
- infoRec->FillColorExpandSpansFlags =
- infoRec->ScanlineCPUToScreenColorExpandFillFlags;
- }
-
- /**** FillImageWriteRects ****/
-
- if(infoRec->FillImageWriteRects) {
- XAAMSG("\tDriver provided FillImageWriteRects replacement\n");
- } else if(HaveImageWriteRect &&
- (infoRec->ImageWriteFlags & LEFT_EDGE_CLIPPING_NEGATIVE_X) &&
- (infoRec->ImageWriteFlags & LEFT_EDGE_CLIPPING)) {
- infoRec->FillImageWriteRects = XAAFillImageWriteRects;
- infoRec->FillImageWriteRectsFlags = infoRec->ImageWriteFlags;
- }
-
- /**** WriteBitmap ****/
-
- if(infoRec->WriteBitmap &&
- !xf86ReturnOptValBool(options, XAAOPT_WRITE_BITMAP, FALSE)) {
- XAAMSG("\tDriver provided WriteBitmap replacement\n");
- } else if(HaveColorExpansion) {
- if (infoRec->CPUToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP) {
- if(infoRec->CPUToScreenColorExpandFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST) {
- if(infoRec->CPUToScreenColorExpandFillFlags &
- CPU_TRANSFER_BASE_FIXED)
- infoRec->WriteBitmap =
- XAAWriteBitmapColorExpand3MSBFirstFixedBase;
- else
- infoRec->WriteBitmap = XAAWriteBitmapColorExpand3MSBFirst;
- } else {
- if(infoRec->CPUToScreenColorExpandFillFlags &
- CPU_TRANSFER_BASE_FIXED)
- infoRec->WriteBitmap =
- XAAWriteBitmapColorExpand3LSBFirstFixedBase;
- else
- infoRec->WriteBitmap = XAAWriteBitmapColorExpand3LSBFirst;
- }
- } else {
- if(infoRec->CPUToScreenColorExpandFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST) {
- if(infoRec->CPUToScreenColorExpandFillFlags &
- CPU_TRANSFER_BASE_FIXED)
- infoRec->WriteBitmap =
- XAAWriteBitmapColorExpandMSBFirstFixedBase;
- else
- infoRec->WriteBitmap = XAAWriteBitmapColorExpandMSBFirst;
- } else {
- if(infoRec->CPUToScreenColorExpandFillFlags &
- CPU_TRANSFER_BASE_FIXED)
- infoRec->WriteBitmap =
- XAAWriteBitmapColorExpandLSBFirstFixedBase;
- else
- infoRec->WriteBitmap = XAAWriteBitmapColorExpandLSBFirst;
- }
- }
- infoRec->WriteBitmapFlags = infoRec->CPUToScreenColorExpandFillFlags;
- } else if(HaveScanlineColorExpansion) {
- if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
- TRIPLE_BITS_24BPP) {
- if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST)
- infoRec->WriteBitmap =
- XAAWriteBitmapScanlineColorExpand3MSBFirst;
- else
- infoRec->WriteBitmap =
- XAAWriteBitmapScanlineColorExpand3LSBFirst;
- } else {
- if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST)
- infoRec->WriteBitmap =
- XAAWriteBitmapScanlineColorExpandMSBFirst;
- else
- infoRec->WriteBitmap =
- XAAWriteBitmapScanlineColorExpandLSBFirst;
- }
- infoRec->WriteBitmapFlags =
- infoRec->ScanlineCPUToScreenColorExpandFillFlags;
- } else
- infoRec->WriteBitmap = NULL;
-
- /**** TE Glyphs ****/
-
- if (infoRec->TEGlyphRenderer) {
- XAAMSG("\tDriver provided TEGlyphRenderer replacement\n");
- } else if (HaveColorExpansion) {
- infoRec->TEGlyphRendererFlags =
- infoRec->CPUToScreenColorExpandFillFlags;
-
- if (infoRec->TEGlyphRendererFlags & TRIPLE_BITS_24BPP) {
- if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST) {
- if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED)
- infoRec->TEGlyphRenderer =
- XAATEGlyphRenderer3MSBFirstFixedBase;
- else
- infoRec->TEGlyphRenderer = XAATEGlyphRenderer3MSBFirst;
- } else {
- if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED)
- infoRec->TEGlyphRenderer =
- XAATEGlyphRenderer3LSBFirstFixedBase;
- else
- infoRec->TEGlyphRenderer = XAATEGlyphRenderer3LSBFirst;
- }
-
- if (!HaveSolidFillRect &&
- (infoRec->TEGlyphRendererFlags & RGB_EQUAL)) {
- infoRec->TEGlyphRendererFlags &= ~RGB_EQUAL;
- XAAMSG("WARNING: TEGlyphRenderer cannot support RGB_EQUAL"
- " without solid fills\n");
- }
- } else {
- if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST) {
- if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED)
- infoRec->TEGlyphRenderer =
- XAATEGlyphRendererMSBFirstFixedBase;
- else
- infoRec->TEGlyphRenderer = XAATEGlyphRendererMSBFirst;
- } else {
- if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED)
- infoRec->TEGlyphRenderer =
- XAATEGlyphRendererLSBFirstFixedBase;
- else
- infoRec->TEGlyphRenderer = XAATEGlyphRendererLSBFirst;
- }
- }
-
- if (!HaveSolidFillRect &&
- (infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) {
- infoRec->TEGlyphRendererFlags &= ~TRANSPARENCY_ONLY;
- XAAMSG("WARNING: TEGlyphRenderer cannot support TRANPARENCY_ONLY"
- " without solid fills\n");
- }
-
- } else if (HaveScanlineColorExpansion) {
- infoRec->TEGlyphRendererFlags =
- infoRec->ScanlineCPUToScreenColorExpandFillFlags;
-
- if (infoRec->TEGlyphRendererFlags & TRIPLE_BITS_24BPP) {
- if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST)
- infoRec->TEGlyphRenderer = XAATEGlyphRendererScanline3MSBFirst;
- else
- infoRec->TEGlyphRenderer = XAATEGlyphRendererScanline3LSBFirst;
-
- if (!HaveSolidFillRect &&
- (infoRec->TEGlyphRendererFlags & RGB_EQUAL)) {
- infoRec->TEGlyphRendererFlags &= ~RGB_EQUAL;
- XAAMSG("WARNING: TEGlyphRenderer cannot support RGB_EQUAL"
- " without solid fills\n");
- }
- } else {
- if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST)
- infoRec->TEGlyphRenderer = XAATEGlyphRendererScanlineMSBFirst;
- else
- infoRec->TEGlyphRenderer = XAATEGlyphRendererScanlineLSBFirst;
- }
-
- if (!HaveSolidFillRect &&
- (infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) {
- infoRec->TEGlyphRendererFlags &= ~TRANSPARENCY_ONLY;
- XAAMSG("WARNING: TEGlyphRenderer cannot support TRANPARENCY_ONLY"
- " without solid fills\n");
- }
- }
-
- /**** NonTE Glyphs ****/
-
- if(infoRec->NonTEGlyphRenderer) {
- XAAMSG("\tDriver provided NonTEGlyphRenderer replacement\n");
- } else if(infoRec->WriteBitmap &&
- !(infoRec->WriteBitmapFlags & NO_TRANSPARENCY)) {
- infoRec->NonTEGlyphRenderer = XAANonTEGlyphRenderer;
- infoRec->NonTEGlyphRendererFlags = infoRec->WriteBitmapFlags;
- }
-
- /**** WritePixmap ****/
-
- if(infoRec->WritePixmap &&
- !xf86ReturnOptValBool(options, XAAOPT_WRITE_PIXMAP, FALSE)) {
- XAAMSG("\tDriver provided WritePixmap replacement\n");
- } else if(HaveImageWriteRect) {
- infoRec->WritePixmap = XAAWritePixmap;
- infoRec->WritePixmapFlags =
- infoRec->ImageWriteFlags | CONVERT_32BPP_TO_24BPP;
- } else if(HaveScanlineImageWriteRect) {
- infoRec->WritePixmap = XAAWritePixmapScanline;
- infoRec->WritePixmapFlags = infoRec->ScanlineImageWriteFlags;
- } else
- infoRec->WritePixmap = NULL;
-
- /**** ReadPixmap ****/
-
- if(infoRec->ReadPixmap) {
- XAAMSG("\tDriver provided ReadPixmap replacement\n");
- }
-
-
- /************** GC Level *************/
-
- /**** CopyArea ****/
-
- if(infoRec->CopyArea) {
- XAAMSG("\tDriver provided GC level CopyArea replacement\n");
- } else if(infoRec->ScreenToScreenBitBlt) {
- infoRec->CopyArea = XAACopyArea;
- infoRec->CopyAreaFlags = infoRec->ScreenToScreenBitBltFlags;
-
- /* most GC level primitives use one mid-level primitive so
- the GC level primitive gets the mid-level primitive flag
- and we use that at GC validation time. But CopyArea uses
- more than one mid-level primitive so we have to essentially
- do a GC validation every time that primitive is used.
- The CopyAreaFlags would only be used for filtering out the
- common denominators. Here we assume that if you don't do
- ScreenToScreenBitBlt you aren't going to do the others.
- We also assume that ScreenToScreenBitBlt has the least
- restrictions. */
- }
-
- if(infoRec->CopyPlane) {
- XAAMSG("\tDriver provided GC level CopyPlane replacement\n");
- } else if(infoRec->WriteBitmap &&
- !(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY)) {
- infoRec->CopyPlane = XAACopyPlaneColorExpansion;
- infoRec->CopyPlaneFlags = infoRec->WriteBitmapFlags;
- }
-
- if(infoRec->PushPixelsSolid) {
- XAAMSG("\tDriver provided GC level PushPixelsSolid replacement\n");
- } else if(infoRec->WriteBitmap &&
- !(infoRec->WriteBitmapFlags & NO_TRANSPARENCY)) {
- infoRec->PushPixelsSolid = XAAPushPixelsSolidColorExpansion;
- infoRec->PushPixelsFlags = infoRec->WriteBitmapFlags;
- }
-
- if(infoRec->FillSolidRects) {
- if(!infoRec->PolyFillRectSolid) {
- infoRec->PolyFillRectSolid = XAAPolyFillRect;
- infoRec->PolyFillRectSolidFlags = infoRec->FillSolidRectsFlags;
- }
- }
- if(infoRec->FillSolidSpans) {
- if(!infoRec->FillSpansSolid) {
- infoRec->FillSpansSolid = XAAFillSpans;
- infoRec->FillSpansSolidFlags = infoRec->FillSolidSpansFlags;
- }
- }
-
- if(infoRec->FillMono8x8PatternRects || infoRec->FillColor8x8PatternRects ||
- infoRec->FillCacheBltRects || infoRec->FillColorExpandRects ||
- infoRec->FillCacheExpandRects) {
- if(!infoRec->PolyFillRectStippled) {
-
- infoRec->PolyFillRectStippled = XAAPolyFillRect;
- infoRec->PolyFillRectStippledFlags = 0;
- }
- }
-
- if(infoRec->FillMono8x8PatternSpans || infoRec->FillColor8x8PatternSpans ||
- infoRec->FillCacheBltSpans || infoRec->FillColorExpandSpans ||
- infoRec->FillCacheExpandSpans) {
- if(!infoRec->FillSpansStippled) {
-
- infoRec->FillSpansStippled = XAAFillSpans;
- infoRec->FillSpansStippledFlags = 0;
- }
- }
-
- if(infoRec->FillMono8x8PatternRects || infoRec->FillColor8x8PatternRects ||
- infoRec->FillCacheBltRects || infoRec->FillColorExpandRects ||
- infoRec->FillCacheExpandRects) {
- if(!infoRec->PolyFillRectOpaqueStippled) {
-
- infoRec->PolyFillRectOpaqueStippled = XAAPolyFillRect;
- infoRec->PolyFillRectOpaqueStippledFlags = 0;
- }
- }
-
- if(infoRec->FillMono8x8PatternSpans || infoRec->FillColor8x8PatternSpans ||
- infoRec->FillCacheBltSpans || infoRec->FillColorExpandSpans ||
- infoRec->FillCacheExpandSpans) {
- if(!infoRec->FillSpansOpaqueStippled) {
-
- infoRec->FillSpansOpaqueStippled = XAAFillSpans;
- infoRec->FillSpansOpaqueStippledFlags = 0;
- }
- }
-
- if(infoRec->FillMono8x8PatternRects || infoRec->FillColor8x8PatternRects ||
- infoRec->FillCacheBltRects || infoRec->FillImageWriteRects) {
- if(!infoRec->PolyFillRectTiled) {
-
- infoRec->PolyFillRectTiled = XAAPolyFillRect;
- infoRec->PolyFillRectTiledFlags = 0;
- }
- }
-
- if(infoRec->FillMono8x8PatternSpans || infoRec->FillColor8x8PatternSpans ||
- infoRec->FillCacheBltSpans) {
- if(!infoRec->FillSpansTiled) {
-
- infoRec->FillSpansTiled = XAAFillSpans;
- infoRec->FillSpansTiledFlags = 0;
- }
- }
-
- if(infoRec->TEGlyphRenderer &&
- !(infoRec->TEGlyphRendererFlags & NO_TRANSPARENCY)) {
-
- if(!infoRec->PolyText8TE) {
- infoRec->PolyText8TE = XAAPolyText8TEColorExpansion;
- infoRec->PolyText8TEFlags = infoRec->TEGlyphRendererFlags;
- }
-
- if(!infoRec->PolyText16TE) {
- infoRec->PolyText16TE = XAAPolyText16TEColorExpansion;
- infoRec->PolyText16TEFlags = infoRec->TEGlyphRendererFlags;
- }
-
- if(!infoRec->PolyGlyphBltTE) {
- infoRec->PolyGlyphBltTE = XAAPolyGlyphBltTEColorExpansion;
- infoRec->PolyGlyphBltTEFlags = infoRec->TEGlyphRendererFlags;
- }
- }
-
- if(infoRec->TEGlyphRenderer &&
- !(infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) {
-
- if(!infoRec->ImageText8TE) {
- infoRec->ImageText8TE = XAAImageText8TEColorExpansion;
- infoRec->ImageText8TEFlags = infoRec->TEGlyphRendererFlags;
- }
-
- if(!infoRec->ImageText16TE) {
- infoRec->ImageText16TE = XAAImageText16TEColorExpansion;
- infoRec->ImageText16TEFlags = infoRec->TEGlyphRendererFlags;
- }
-
- if(!infoRec->ImageGlyphBltTE) {
- infoRec->ImageGlyphBltTE = XAAImageGlyphBltTEColorExpansion;
- infoRec->ImageGlyphBltTEFlags = infoRec->TEGlyphRendererFlags;
- }
- }
-
- if(infoRec->NonTEGlyphRenderer) {
- if(!infoRec->PolyText8NonTE) {
- infoRec->PolyText8NonTE = XAAPolyText8NonTEColorExpansion;
- infoRec->PolyText8NonTEFlags = infoRec->NonTEGlyphRendererFlags;
- }
-
- if(!infoRec->PolyText16NonTE) {
- infoRec->PolyText16NonTE = XAAPolyText16NonTEColorExpansion;
- infoRec->PolyText16NonTEFlags = infoRec->NonTEGlyphRendererFlags;
- }
- if(!infoRec->PolyGlyphBltNonTE) {
- infoRec->PolyGlyphBltNonTE = XAAPolyGlyphBltNonTEColorExpansion;
- infoRec->PolyGlyphBltNonTEFlags = infoRec->NonTEGlyphRendererFlags;
- }
- }
-
- if(infoRec->NonTEGlyphRenderer && HaveSolidFillRect) {
- if(!infoRec->ImageText8NonTE) {
- infoRec->ImageText8NonTE = XAAImageText8NonTEColorExpansion;
- infoRec->ImageText8NonTEFlags = infoRec->NonTEGlyphRendererFlags;
- }
-
- if(!infoRec->ImageText16NonTE) {
- infoRec->ImageText16NonTE = XAAImageText16NonTEColorExpansion;
- infoRec->ImageText16NonTEFlags = infoRec->NonTEGlyphRendererFlags;
- }
-
- if(!infoRec->ImageGlyphBltNonTE) {
- infoRec->ImageGlyphBltNonTE = XAAImageGlyphBltNonTEColorExpansion;
- infoRec->ImageGlyphBltNonTEFlags = infoRec->NonTEGlyphRendererFlags;
- }
- }
-
- if(!infoRec->PolyRectangleThinSolid && HaveSolidHorVertLine) {
- infoRec->PolyRectangleThinSolid = XAAPolyRectangleThinSolid;
- infoRec->PolyRectangleThinSolidFlags = infoRec->SolidLineFlags;
- }
-
- if(!infoRec->FillPolygonSolid && HaveSolidFillRect) {
- infoRec->FillPolygonSolid = XAAFillPolygonSolid;
- infoRec->FillPolygonSolidFlags = infoRec->SolidFillFlags;
- }
-
- if(!infoRec->FillPolygonStippled && (HaveMono8x8PatternFillRect ||
- HaveScreenToScreenColorExpandFill || HaveScreenToScreenCopy)) {
- infoRec->FillPolygonStippled = XAAFillPolygonStippled;
- infoRec->FillPolygonStippledFlags = infoRec->SolidFillFlags;
- }
-
- if(!infoRec->FillPolygonOpaqueStippled && (HaveMono8x8PatternFillRect ||
- HaveScreenToScreenColorExpandFill || HaveScreenToScreenCopy)) {
- infoRec->FillPolygonOpaqueStippled = XAAFillPolygonStippled;
- infoRec->FillPolygonOpaqueStippledFlags = infoRec->SolidFillFlags;
- }
-
- if(!infoRec->FillPolygonTiled && (HaveMono8x8PatternFillRect ||
- HaveScreenToScreenColorExpandFill || HaveScreenToScreenCopy)) {
- infoRec->FillPolygonTiled = XAAFillPolygonTiled;
- infoRec->FillPolygonTiledFlags = infoRec->SolidFillFlags;
- }
-
-
- if(!infoRec->PolyFillArcSolid && HaveSolidFillRect) {
- infoRec->PolyFillArcSolid = XAAPolyFillArcSolid;
- infoRec->PolyFillArcSolidFlags = infoRec->SolidFillFlags;
- }
-
- if(!infoRec->PolylinesWideSolid && HaveSolidFillRect) {
- infoRec->PolylinesWideSolid = XAAPolylinesWideSolid;
- infoRec->PolylinesWideSolidFlags =
- infoRec->SolidFillFlags | GXCOPY_ONLY;
- }
-
- if(!infoRec->PutImage && (infoRec->WritePixmap ||
- (infoRec->WriteBitmap &&
- !(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY)))) {
- infoRec->PutImage = XAAPutImage;
-
- /* See comment for CopyArea above. But here we make fewer
- assumptions. The driver can provide the PutImageFlags if
- it wants too */
- }
-
- if(HaveSolidHorVertLine &&
- (HaveSolidBresenhamLine || (HaveSolidTwoPointLine &&
- (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_LINE)))){
- if(!infoRec->PolylinesThinSolid) {
- infoRec->PolylinesThinSolid = XAAPolyLines;
- infoRec->PolylinesThinSolidFlags = infoRec->SolidLineFlags;
- }
- if(!infoRec->PolySegmentThinSolid) {
- infoRec->PolySegmentThinSolid = XAAPolySegment;
- infoRec->PolySegmentThinSolidFlags = infoRec->SolidLineFlags;
- }
- }
-
- if(HaveDashedBresenhamLine || (HaveDashedTwoPointLine &&
- (infoRec->ClippingFlags & HARDWARE_CLIP_DASHED_LINE))){
- if(!infoRec->PolylinesThinDashed) {
- infoRec->PolylinesThinDashed = XAAPolyLinesDashed;
- infoRec->PolylinesThinDashedFlags = infoRec->DashedLineFlags;
- }
- if(!infoRec->PolySegmentThinDashed) {
- infoRec->PolySegmentThinDashed = XAAPolySegmentDashed;
- infoRec->PolySegmentThinDashedFlags = infoRec->DashedLineFlags;
- }
- }
-
- if(infoRec->PolylinesThinDashed || infoRec->PolySegmentThinDashed) {
- if(!infoRec->ComputeDash)
- infoRec->ComputeDash = XAAComputeDash;
- }
-
- {
- Bool haveTexture = infoRec->CPUToScreenTextureFormats &&
- infoRec->CPUToScreenTextureDstFormats &&
- infoRec->SetupForCPUToScreenTexture2 &&
- infoRec->SubsequentCPUToScreenTexture;
- Bool haveAlphaTexture = infoRec->CPUToScreenAlphaTextureFormats &&
- infoRec->CPUToScreenAlphaTextureDstFormats &&
- infoRec->SetupForCPUToScreenAlphaTexture2 &&
- infoRec->SubsequentCPUToScreenAlphaTexture;
-
- if(!infoRec->Composite && (haveTexture || haveAlphaTexture))
- infoRec->Composite = XAADoComposite;
-
- if(!infoRec->Glyphs && infoRec->WriteBitmap &&
- !(infoRec->WriteBitmapFlags & NO_TRANSPARENCY))
- {
- infoRec->Glyphs = XAADoGlyphs;
- }
- }
-
- /************ Validation Functions **************/
-
- if(!infoRec->ValidateCopyArea && infoRec->CopyArea) {
- infoRec->CopyAreaMask = GCWhenForced;
- if((infoRec->CopyAreaFlags & GXCOPY_ONLY) ||
- (infoRec->CopyAreaFlags & ROP_NEEDS_SOURCE))
- infoRec->CopyAreaMask |= GCFunction;
- if(infoRec->CopyAreaFlags & NO_PLANEMASK)
- infoRec->CopyAreaMask |= GCPlaneMask;
- infoRec->ValidateCopyArea = XAAValidateCopyArea;
- }
-
- if(!infoRec->ValidateCopyPlane && infoRec->CopyPlane) {
- infoRec->CopyPlaneMask = GCWhenForced;
- if((infoRec->CopyPlaneFlags & GXCOPY_ONLY) ||
- (infoRec->CopyPlaneFlags & ROP_NEEDS_SOURCE))
- infoRec->CopyPlaneMask |= GCFunction;
- if(infoRec->CopyPlaneFlags & NO_PLANEMASK)
- infoRec->CopyPlaneMask |= GCPlaneMask;
- if(infoRec->CopyPlaneFlags & RGB_EQUAL)
- infoRec->CopyPlaneMask |= GCForeground | GCBackground;
- infoRec->ValidateCopyPlane = XAAValidateCopyPlane;
- }
-
- if(!infoRec->ValidatePutImage && infoRec->PutImage) {
- infoRec->PutImageMask = GCWhenForced;
- if((infoRec->PutImageFlags & GXCOPY_ONLY) ||
- (infoRec->PutImageFlags & ROP_NEEDS_SOURCE))
- infoRec->PutImageMask |= GCFunction;
- if(infoRec->PutImageFlags & NO_PLANEMASK)
- infoRec->PutImageMask |= GCPlaneMask;
- if(infoRec->PutImageFlags & RGB_EQUAL)
- infoRec->PutImageMask |= GCForeground | GCBackground;
- infoRec->ValidatePutImage = XAAValidatePutImage;
- }
-
-
- if(!infoRec->ValidatePushPixels && infoRec->PushPixelsSolid) {
- infoRec->PushPixelsMask = GCFillStyle;
- if((infoRec->PushPixelsFlags & GXCOPY_ONLY) ||
- (infoRec->PushPixelsFlags & ROP_NEEDS_SOURCE) ||
- (infoRec->PushPixelsFlags & TRANSPARENCY_GXCOPY_ONLY))
- infoRec->PushPixelsMask |= GCFunction;
- if(infoRec->PushPixelsFlags & NO_PLANEMASK)
- infoRec->PushPixelsMask |= GCPlaneMask;
- if(infoRec->PushPixelsFlags & RGB_EQUAL)
- infoRec->PushPixelsMask |= GCForeground;
- infoRec->ValidatePushPixels = XAAValidatePushPixels;
- }
-
- /* By default XAA assumes the FillSpans, PolyFillRects, FillPolygon
- and PolyFillArcs have the same restrictions. If you supply GC
- level replacements for any of these and alter this relationship
- you may need to supply replacement validation routines */
-
- if(!infoRec->ValidateFillSpans &&
- (infoRec->FillSpansSolid || infoRec->FillSpansStippled ||
- infoRec->FillSpansOpaqueStippled || infoRec->FillSpansTiled)) {
-
- int compositeFlags = infoRec->FillSpansSolidFlags |
- infoRec->FillSpansStippledFlags |
- infoRec->FillSpansOpaqueStippledFlags |
- infoRec->FillSpansTiledFlags;
-
- infoRec->FillSpansMask = GCFillStyle | GCTile | GCStipple;
-
- if((compositeFlags & GXCOPY_ONLY) ||
- (compositeFlags & ROP_NEEDS_SOURCE))
- infoRec->FillSpansMask |= GCFunction;
- if(compositeFlags & NO_PLANEMASK)
- infoRec->FillSpansMask |= GCPlaneMask;
- if(compositeFlags & RGB_EQUAL)
- infoRec->FillSpansMask |= GCForeground;
- infoRec->ValidateFillSpans = XAAValidateFillSpans;
- }
-
- /* By default XAA only provides Validations for the GlyphBlt
- functions and not the text higher up. This is because the
- Text8/16 and GlyphBlt are linked. If you break this linkage,
- you may need to have the driver supply its own Validation
- routines */
-
- if(!infoRec->ValidatePolyGlyphBlt &&
- (infoRec->PolyGlyphBltTE || infoRec->PolyGlyphBltNonTE)) {
- int compositeFlags = infoRec->PolyGlyphBltTEFlags |
- infoRec->PolyGlyphBltNonTEFlags;
-
- infoRec->PolyGlyphBltMask = GCFillStyle | GCFont;
- if((compositeFlags & GXCOPY_ONLY) ||
- (compositeFlags & ROP_NEEDS_SOURCE) ||
- (infoRec->PolyGlyphBltNonTEFlags & TRANSPARENCY_GXCOPY_ONLY))
- infoRec->PolyGlyphBltMask |= GCFunction;
- if(compositeFlags & NO_PLANEMASK)
- infoRec->PolyGlyphBltMask |= GCPlaneMask;
- if(compositeFlags & RGB_EQUAL)
- infoRec->PolyGlyphBltMask |= GCForeground;
- infoRec->ValidatePolyGlyphBlt = XAAValidatePolyGlyphBlt;
- }
-
- if(!infoRec->ValidateImageGlyphBlt &&
- (infoRec->ImageGlyphBltTE || infoRec->ImageGlyphBltNonTE)) {
- int compositeFlags = infoRec->ImageGlyphBltTEFlags |
- infoRec->ImageGlyphBltNonTEFlags;
-
- if(infoRec->ImageGlyphBltNonTE)
- compositeFlags |= infoRec->SolidFillFlags;
-
- infoRec->ImageGlyphBltMask = GCFont;
- if(compositeFlags & NO_PLANEMASK)
- infoRec->ImageGlyphBltMask |= GCPlaneMask;
- if(compositeFlags & RGB_EQUAL)
- infoRec->ImageGlyphBltMask |= GCForeground | GCBackground;
- infoRec->ValidateImageGlyphBlt = XAAValidateImageGlyphBlt;
- }
-
- /* By default XAA only provides a Validation function for the
- Polylines and does segments and polylines at the same time */
-
- if(!infoRec->ValidatePolylines && infoRec->ValidateFillSpans) {
- int compositeFlags = infoRec->PolyRectangleThinSolidFlags |
- infoRec->PolylinesWideSolidFlags |
- infoRec->PolylinesThinSolidFlags |
- infoRec->PolySegmentThinSolidFlags |
- infoRec->PolySegmentThinDashedFlags |
- infoRec->PolylinesThinDashedFlags;
-
- infoRec->ValidatePolylines = XAAValidatePolylines;
- infoRec->PolylinesMask =
- infoRec->FillSpansMask | GCLineStyle | GCLineWidth;
-
- if(infoRec->PolySegmentThinDashed || infoRec->PolylinesThinDashed)
- infoRec->PolylinesMask |= GCDashList;
- if(compositeFlags & NO_PLANEMASK)
- infoRec->PolylinesMask |= GCPlaneMask;
- if((compositeFlags & GXCOPY_ONLY) ||
- (compositeFlags & ROP_NEEDS_SOURCE))
- infoRec->PolylinesMask |= GCFunction;
- if(compositeFlags & RGB_EQUAL)
- infoRec->PolylinesMask |= GCForeground;
- }
-
-
- /**** Fill choosers ****/
-
- if(!infoRec->StippledFillChooser)
- infoRec->StippledFillChooser = XAAStippledFillChooser;
-
- if(!infoRec->OpaqueStippledFillChooser)
- infoRec->OpaqueStippledFillChooser = XAAOpaqueStippledFillChooser;
-
- if(!infoRec->TiledFillChooser)
- infoRec->TiledFillChooser = XAATiledFillChooser;
-
-
- /**** Setup the pixmap cache ****/
-
- if(infoRec->WriteBitmapToCache) {}
- else if(infoRec->WriteBitmap &&
- !(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY))
- infoRec->WriteBitmapToCache = XAAWriteBitmapToCache;
- else if(infoRec->Flags & LINEAR_FRAMEBUFFER)
- infoRec->WriteBitmapToCache = XAAWriteBitmapToCacheLinear;
- else
- infoRec->PixmapCacheFlags |= DO_NOT_BLIT_STIPPLES;
-
- if(infoRec->WritePixmapToCache) {}
- else if(infoRec->WritePixmap && !(infoRec->WritePixmapFlags & NO_GXCOPY))
- infoRec->WritePixmapToCache = XAAWritePixmapToCache;
- else if(infoRec->Flags & LINEAR_FRAMEBUFFER)
- infoRec->WritePixmapToCache = XAAWritePixmapToCacheLinear;
- else
- infoRec->Flags &= ~PIXMAP_CACHE;
-
- if (xf86ReturnOptValBool(options, XAAOPT_PIXMAP_CACHE, FALSE))
- infoRec->Flags &= ~PIXMAP_CACHE;
-
- if(infoRec->WriteMono8x8PatternToCache) {}
- else if(infoRec->PixmapCacheFlags & CACHE_MONO_8x8) {
- if(infoRec->WritePixmapToCache)
- infoRec->WriteMono8x8PatternToCache = XAAWriteMono8x8PatternToCache;
- else
- infoRec->PixmapCacheFlags &= ~CACHE_MONO_8x8;
- }
-
- if(infoRec->WriteColor8x8PatternToCache) {}
- else if(infoRec->PixmapCacheFlags & CACHE_COLOR_8x8) {
- if(infoRec->WritePixmapToCache && infoRec->WriteBitmapToCache)
- infoRec->WriteColor8x8PatternToCache = XAAWriteColor8x8PatternToCache;
- else
- infoRec->PixmapCacheFlags &= ~CACHE_COLOR_8x8;
- }
-
- if(infoRec->CachePixelGranularity < 0) {
- switch(pScrn->bitsPerPixel) {
- case 24:
- case 8: infoRec->CachePixelGranularity = 4; break;
- case 16: infoRec->CachePixelGranularity = 2; break;
- case 32: infoRec->CachePixelGranularity = 1; break;
- default: break;
- }
-
- if(BITMAP_SCANLINE_PAD == 64)
- infoRec->CachePixelGranularity *= 2;
- }
-
- free(options);
-
- if(!infoRec->CacheTile && infoRec->WritePixmapToCache)
- infoRec->CacheTile = XAACacheTile;
- if(!infoRec->CacheMonoStipple && infoRec->WritePixmapToCache)
- infoRec->CacheMonoStipple = XAACacheMonoStipple;
- if(!infoRec->CacheStipple && infoRec->WriteBitmapToCache)
- infoRec->CacheStipple = XAACacheStipple;
- if(!infoRec->CacheMono8x8Pattern && infoRec->WriteMono8x8PatternToCache)
- infoRec->CacheMono8x8Pattern = XAACacheMono8x8Pattern;
- if(!infoRec->CacheColor8x8Pattern && infoRec->WriteColor8x8PatternToCache)
- infoRec->CacheColor8x8Pattern = XAACacheColor8x8Pattern;
-
- if((infoRec->Flags & PIXMAP_CACHE) && !infoRec->InitPixmapCache) {
- infoRec->InitPixmapCache = XAAInitPixmapCache;
- infoRec->ClosePixmapCache = XAAClosePixmapCache;
- }
-
- return TRUE;
-}
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <string.h>
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "xf86fbman.h"
+#include "servermd.h"
+
+/*
+ * XAA Config options
+ */
+
+typedef enum {
+ XAAOPT_SCREEN_TO_SCREEN_COPY,
+ XAAOPT_SOLID_FILL_RECT,
+ XAAOPT_SOLID_FILL_TRAP,
+ XAAOPT_SOLID_TWO_POINT_LINE,
+ XAAOPT_SOLID_BRESENHAM_LINE,
+ XAAOPT_SOLID_HORVERT_LINE,
+ XAAOPT_DASHED_TWO_POINT_LINE,
+ XAAOPT_DASHED_BRESENHAM_LINE,
+ XAAOPT_MONO_8x8_PATTERN_FILL_RECT,
+ XAAOPT_MONO_8x8_PATTERN_FILL_TRAP,
+ XAAOPT_COL_8x8_PATTERN_FILL_RECT,
+ XAAOPT_COL_8x8_PATTERN_FILL_TRAP,
+ XAAOPT_CPU_TO_SCREEN_COL_EXP_FILL,
+ XAAOPT_SCANLINE_CPU_TO_SCREEN_COL_EXP_FILL,
+ XAAOPT_SCREEN_TO_SCREEN_COL_EXP_FILL,
+ XAAOPT_IMAGE_WRITE_RECT,
+ XAAOPT_SCANLINE_IMAGE_WRITE_RECT,
+ XAAOPT_WRITE_BITMAP,
+ XAAOPT_WRITE_PIXMAP,
+ XAAOPT_PIXMAP_CACHE,
+ XAAOPT_OFFSCREEN_PIXMAPS,
+ XAAOPT_HAS_DUMB_INVERTED_OPTION_SENSE
+} XAAOpts;
+
+static const OptionInfoRec XAAOptions[] = {
+ {XAAOPT_SCREEN_TO_SCREEN_COPY, "XaaNoScreenToScreenCopy",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_SOLID_FILL_RECT, "XaaNoSolidFillRect",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_SOLID_FILL_TRAP, "XaaNoSolidFillTrap",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_SOLID_TWO_POINT_LINE, "XaaNoSolidTwoPointLine",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_SOLID_BRESENHAM_LINE, "XaaNoSolidBresenhamLine",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_SOLID_HORVERT_LINE, "XaaNoSolidHorVertLine",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_DASHED_TWO_POINT_LINE, "XaaNoDashedTwoPointLine",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_DASHED_BRESENHAM_LINE, "XaaNoDashedBresenhamLine",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_MONO_8x8_PATTERN_FILL_RECT, "XaaNoMono8x8PatternFillRect",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_MONO_8x8_PATTERN_FILL_TRAP, "XaaNoMono8x8PatternFillTrap",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_COL_8x8_PATTERN_FILL_RECT, "XaaNoColor8x8PatternFillRect",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_COL_8x8_PATTERN_FILL_TRAP, "XaaNoColor8x8PatternFillTrap",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_CPU_TO_SCREEN_COL_EXP_FILL, "XaaNoCPUToScreenColorExpandFill",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_SCANLINE_CPU_TO_SCREEN_COL_EXP_FILL,
+ "XaaNoScanlineCPUToScreenColorExpandFill",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_SCREEN_TO_SCREEN_COL_EXP_FILL, "XaaNoScreenToScreenColorExpandFill",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_IMAGE_WRITE_RECT, "XaaNoImageWriteRect",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_SCANLINE_IMAGE_WRITE_RECT, "XaaNoScanlineImageWriteRect",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_WRITE_BITMAP, "XaaNoWriteBitmap",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_WRITE_PIXMAP, "XaaNoWritePixmap",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_PIXMAP_CACHE, "XaaNoPixmapCache",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_OFFSCREEN_PIXMAPS, "XaaNoOffscreenPixmaps",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {XAAOPT_HAS_DUMB_INVERTED_OPTION_SENSE, "XaaOffscreenPixmaps",
+ OPTV_BOOLEAN, {0}, FALSE},
+ {-1, NULL,
+ OPTV_NONE, {0}, FALSE}
+};
+
+static XF86ModuleVersionInfo xaaVersRec = {
+ "xaa",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ XAA_VERSION_MAJOR,
+ XAA_VERSION_MINOR,
+ XAA_VERSION_RELEASE,
+ ABI_CLASS_VIDEODRV, /* requires the video driver ABI */
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_NONE,
+ {0, 0, 0, 0}
+};
+
+_X_EXPORT XF86ModuleData xaaModuleData = { &xaaVersRec, NULL, NULL };
+
+Bool
+XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
+{
+ int index = pScreen->myNum;
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ Bool HaveScreenToScreenCopy = FALSE;
+ Bool HaveColorExpansion = FALSE;
+ Bool HaveScanlineColorExpansion = FALSE;
+ Bool HaveSolidFillRect = FALSE;
+ Bool HaveMono8x8PatternFillRect = FALSE;
+ Bool HaveColor8x8PatternFillRect = FALSE;
+ Bool HaveSolidFillTrap = FALSE;
+ Bool HaveMono8x8PatternFillTrap = FALSE;
+ Bool HaveColor8x8PatternFillTrap = FALSE;
+ Bool HaveSolidTwoPointLine = FALSE;
+ Bool HaveSolidBresenhamLine = FALSE;
+ Bool HaveSolidHorVertLine = FALSE;
+ Bool HaveDashedTwoPointLine = FALSE;
+ Bool HaveDashedBresenhamLine = FALSE;
+ Bool HaveImageWriteRect = FALSE;
+ Bool HaveScanlineImageWriteRect = FALSE;
+ Bool HaveScreenToScreenColorExpandFill = FALSE;
+ OptionInfoPtr options;
+ int is_shared = 0;
+ int i;
+
+ options = xnfalloc(sizeof(XAAOptions));
+ (void) memcpy(options, XAAOptions, sizeof(XAAOptions));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
+
+ infoRec->pScrn = pScrn;
+ infoRec->NeedToSync = FALSE;
+
+ /* must have a Sync function */
+ if (!infoRec->Sync)
+ return FALSE;
+ for (i = 0; i < pScrn->numEntities; i++) {
+ if (xf86IsEntityShared(pScrn->entityList[i]))
+ is_shared = 1;
+ }
+
+ /* If this PCI entity has IS_SHARED_ACCEL set in entityProp
+ * then a RestoreAccelState function is required
+ */
+ if (!infoRec->RestoreAccelState && is_shared)
+ return FALSE;
+
+ if (infoRec->RestoreAccelState) {
+ if (!XAAInitStateWrap(pScreen, infoRec))
+ return FALSE;
+ }
+
+ if (serverGeneration == 1)
+ xf86DrvMsg(index, X_INFO,
+ "Using XFree86 Acceleration Architecture (XAA)\n");
+
+ /************** Low Level *************/
+
+ if (!infoRec->SetClippingRectangle || !infoRec->DisableClipping) {
+ infoRec->ClippingFlags = 0;
+ infoRec->SetClippingRectangle = NULL;
+ infoRec->DisableClipping = NULL;
+ }
+
+ /**** CopyArea ****/
+
+ if (infoRec->SetupForScreenToScreenCopy &&
+ infoRec->SubsequentScreenToScreenCopy &&
+ !xf86ReturnOptValBool(options, XAAOPT_SCREEN_TO_SCREEN_COPY, FALSE)) {
+ HaveScreenToScreenCopy = TRUE;
+ }
+ else {
+ infoRec->ScreenToScreenCopyFlags = 0;
+ infoRec->SetupForScreenToScreenCopy = NULL;
+ infoRec->SubsequentScreenToScreenCopy = NULL;
+ }
+
+ /**** Solid Filled Rects ****/
+
+ if (infoRec->SetupForSolidFill && infoRec->SubsequentSolidFillRect &&
+ !xf86ReturnOptValBool(options, XAAOPT_SOLID_FILL_RECT, FALSE)) {
+ HaveSolidFillRect = TRUE;
+ if (infoRec->SubsequentSolidFillTrap &&
+ !xf86ReturnOptValBool(options, XAAOPT_SOLID_FILL_TRAP, FALSE))
+ HaveSolidFillTrap = TRUE;
+ else
+ infoRec->SubsequentSolidFillTrap = NULL;
+ }
+ else {
+ infoRec->SolidFillFlags = 0;
+ infoRec->SetupForSolidFill = NULL;
+ infoRec->SubsequentSolidFillRect = NULL;
+ infoRec->SubsequentSolidFillTrap = NULL;
+ }
+
+ /**** Solid lines ****/
+
+ if (infoRec->SetupForSolidLine) {
+ if (infoRec->SubsequentSolidTwoPointLine &&
+ !xf86ReturnOptValBool(options, XAAOPT_SOLID_TWO_POINT_LINE, FALSE))
+ HaveSolidTwoPointLine = TRUE;
+ if (infoRec->SubsequentSolidBresenhamLine &&
+ !xf86ReturnOptValBool(options, XAAOPT_SOLID_BRESENHAM_LINE,
+ FALSE)) {
+ HaveSolidBresenhamLine = TRUE;
+
+ if (infoRec->SolidBresenhamLineErrorTermBits)
+ infoRec->SolidBresenhamLineErrorTermBits =
+ ~((1 << infoRec->SolidBresenhamLineErrorTermBits) - 1);
+ }
+
+ if (infoRec->SubsequentSolidHorVertLine &&
+ !xf86ReturnOptValBool(options, XAAOPT_SOLID_HORVERT_LINE, FALSE))
+ HaveSolidHorVertLine = TRUE;
+ else if (HaveSolidTwoPointLine) {
+ infoRec->SubsequentSolidHorVertLine = XAASolidHorVertLineAsTwoPoint;
+ HaveSolidHorVertLine = TRUE;
+ }
+ else if (HaveSolidBresenhamLine) {
+ infoRec->SubsequentSolidHorVertLine =
+ XAASolidHorVertLineAsBresenham;
+ HaveSolidHorVertLine = TRUE;
+ }
+ }
+
+ /* XXX Should this also check for XAAOPT_SOLID_HORVERT_LINE? */
+ if (!HaveSolidTwoPointLine &&
+ !HaveSolidBresenhamLine && !HaveSolidHorVertLine && HaveSolidFillRect) {
+ infoRec->SetupForSolidLine = infoRec->SetupForSolidFill;
+ infoRec->SubsequentSolidHorVertLine = XAASolidHorVertLineAsRects;
+ infoRec->SolidLineFlags = infoRec->SolidFillFlags;
+ HaveSolidHorVertLine = TRUE;
+ }
+
+ if (!HaveSolidTwoPointLine)
+ infoRec->SubsequentSolidTwoPointLine = NULL;
+ if (!HaveSolidBresenhamLine)
+ infoRec->SubsequentSolidBresenhamLine = NULL;
+ if (!HaveSolidHorVertLine)
+ infoRec->SubsequentSolidHorVertLine = NULL;
+
+ /* Disable all if nothing left over */
+ if (!HaveSolidTwoPointLine &&
+ !HaveSolidBresenhamLine && !HaveSolidHorVertLine) {
+ infoRec->SolidLineFlags = 0;
+ infoRec->SetupForSolidLine = NULL;
+ }
+
+ /**** 8x8 Mono Pattern Filled Rects ****/
+
+ if (infoRec->SetupForMono8x8PatternFill &&
+ infoRec->SubsequentMono8x8PatternFillRect &&
+ !xf86ReturnOptValBool(options,
+ XAAOPT_MONO_8x8_PATTERN_FILL_RECT, FALSE)) {
+ HaveMono8x8PatternFillRect = TRUE;
+ if (infoRec->SubsequentMono8x8PatternFillTrap &&
+ !xf86ReturnOptValBool(options,
+ XAAOPT_MONO_8x8_PATTERN_FILL_TRAP, FALSE))
+ HaveMono8x8PatternFillTrap = TRUE;
+
+ if (infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ infoRec->CanDoMono8x8 = TRUE;
+ }
+ else { /* others require caching */
+ int min_pitch;
+
+ infoRec->PixmapCacheFlags |= CACHE_MONO_8x8;
+
+ switch (pScrn->bitsPerPixel) {
+ case 32:
+ min_pitch = 2;
+ break;
+ case 24:
+ min_pitch = 3;
+ break;
+ case 16:
+ min_pitch = 4;
+ break;
+ default:
+ min_pitch = 8;
+ break;
+ }
+
+ if (min_pitch > infoRec->MonoPatternPitch)
+ infoRec->MonoPatternPitch = min_pitch;
+
+ if (infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN) {
+ if (!infoRec->CacheWidthMono8x8Pattern ||
+ !infoRec->CacheHeightMono8x8Pattern) {
+ infoRec->CacheWidthMono8x8Pattern =
+ infoRec->MonoPatternPitch;
+ infoRec->CacheHeightMono8x8Pattern = 1;
+ }
+ }
+ else {
+ int numPerLine = 128 / infoRec->MonoPatternPitch;
+
+ if (!infoRec->CacheWidthMono8x8Pattern ||
+ !infoRec->CacheHeightMono8x8Pattern) {
+ infoRec->CacheWidthMono8x8Pattern =
+ numPerLine * infoRec->MonoPatternPitch;
+ infoRec->CacheHeightMono8x8Pattern =
+ (64 + numPerLine - 1) / numPerLine;
+ }
+ }
+ }
+ }
+ else {
+ infoRec->Mono8x8PatternFillFlags = 0;
+ infoRec->SetupForMono8x8PatternFill = NULL;
+ infoRec->SubsequentMono8x8PatternFillRect = NULL;
+ }
+
+ /**** Dashed lines ****/
+
+ if (infoRec->SetupForDashedLine && infoRec->DashPatternMaxLength) {
+ if (infoRec->SubsequentDashedTwoPointLine &&
+ !xf86ReturnOptValBool(options, XAAOPT_DASHED_TWO_POINT_LINE, FALSE))
+ HaveDashedTwoPointLine = TRUE;
+ if (infoRec->SubsequentDashedBresenhamLine &&
+ !xf86ReturnOptValBool(options, XAAOPT_DASHED_BRESENHAM_LINE,
+ FALSE)) {
+ HaveDashedBresenhamLine = TRUE;
+
+ if (infoRec->DashedBresenhamLineErrorTermBits)
+ infoRec->DashedBresenhamLineErrorTermBits =
+ ~((1 << infoRec->DashedBresenhamLineErrorTermBits) - 1);
+ }
+ }
+
+ if (!HaveDashedTwoPointLine)
+ infoRec->SubsequentDashedTwoPointLine = NULL;
+ if (!HaveDashedBresenhamLine)
+ infoRec->SubsequentDashedBresenhamLine = NULL;
+
+ /* Disable all if nothing left over */
+ if (!HaveDashedTwoPointLine && !HaveDashedBresenhamLine) {
+ infoRec->DashedLineFlags = 0;
+ infoRec->SetupForDashedLine = NULL;
+ }
+
+ /**** 8x8 Color Pattern Filled Rects ****/
+
+ if (infoRec->SetupForColor8x8PatternFill &&
+ infoRec->SubsequentColor8x8PatternFillRect &&
+ !xf86ReturnOptValBool(options, XAAOPT_COL_8x8_PATTERN_FILL_RECT,
+ FALSE)) {
+ HaveColor8x8PatternFillRect = TRUE;
+ if (infoRec->SubsequentColor8x8PatternFillTrap &&
+ !xf86ReturnOptValBool(options, XAAOPT_COL_8x8_PATTERN_FILL_TRAP,
+ FALSE))
+ HaveColor8x8PatternFillTrap = TRUE;
+ else
+ infoRec->SubsequentColor8x8PatternFillTrap = NULL;
+
+ infoRec->PixmapCacheFlags |= CACHE_COLOR_8x8;
+
+ if (infoRec->Color8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN) {
+ if (!infoRec->CacheWidthColor8x8Pattern ||
+ !infoRec->CacheHeightColor8x8Pattern) {
+ infoRec->CacheWidthColor8x8Pattern = 64;
+ infoRec->CacheHeightColor8x8Pattern = 1;
+ }
+ }
+ else {
+ if (!infoRec->CacheWidthColor8x8Pattern ||
+ !infoRec->CacheHeightColor8x8Pattern) {
+ infoRec->CacheWidthColor8x8Pattern = 128;
+ infoRec->CacheHeightColor8x8Pattern = 8;
+ }
+ }
+ }
+ else {
+ infoRec->Color8x8PatternFillFlags = 0;
+ infoRec->SetupForColor8x8PatternFill = NULL;
+ infoRec->SubsequentColor8x8PatternFillRect = NULL;
+ infoRec->SubsequentColor8x8PatternFillTrap = NULL;
+ }
+
+ /**** Color Expansion ****/
+
+ if (infoRec->SetupForCPUToScreenColorExpandFill &&
+ infoRec->ColorExpandBase &&
+ infoRec->SubsequentCPUToScreenColorExpandFill &&
+ !xf86ReturnOptValBool(options, XAAOPT_CPU_TO_SCREEN_COL_EXP_FILL,
+ FALSE)) {
+ int dwordsNeeded = pScrn->virtualX;
+
+ infoRec->ColorExpandRange >>= 2; /* convert to DWORDS */
+ HaveColorExpansion = TRUE;
+
+ if (infoRec->CPUToScreenColorExpandFillFlags &
+ LEFT_EDGE_CLIPPING_NEGATIVE_X)
+ dwordsNeeded += 31;
+ dwordsNeeded = (dwordsNeeded + 31) >> 5;
+ if (dwordsNeeded > infoRec->ColorExpandRange)
+ infoRec->CPUToScreenColorExpandFillFlags |= CPU_TRANSFER_BASE_FIXED;
+ }
+ else {
+ infoRec->CPUToScreenColorExpandFillFlags = 0;
+ infoRec->SetupForCPUToScreenColorExpandFill = NULL;
+ infoRec->SubsequentCPUToScreenColorExpandFill = NULL;
+ }
+
+ /**** Scanline Color Expansion ****/
+
+ if (infoRec->SetupForScanlineCPUToScreenColorExpandFill &&
+ infoRec->SubsequentScanlineCPUToScreenColorExpandFill &&
+ infoRec->SubsequentColorExpandScanline &&
+ infoRec->ScanlineColorExpandBuffers &&
+ (infoRec->NumScanlineColorExpandBuffers > 0) &&
+ !xf86ReturnOptValBool(options,
+ XAAOPT_SCANLINE_CPU_TO_SCREEN_COL_EXP_FILL,
+ FALSE)) {
+ HaveScanlineColorExpansion = TRUE;
+ }
+ else {
+ infoRec->ScanlineCPUToScreenColorExpandFillFlags = 0;
+ infoRec->SetupForScanlineCPUToScreenColorExpandFill = NULL;
+ infoRec->SubsequentScanlineCPUToScreenColorExpandFill = NULL;
+ infoRec->SubsequentColorExpandScanline = NULL;
+ }
+
+ /**** Screen to Screen Color Expansion ****/
+
+ if (infoRec->SetupForScreenToScreenColorExpandFill &&
+ infoRec->SubsequentScreenToScreenColorExpandFill &&
+ !xf86ReturnOptValBool(options, XAAOPT_SCREEN_TO_SCREEN_COL_EXP_FILL,
+ FALSE)) {
+ HaveScreenToScreenColorExpandFill = TRUE;
+ if (!infoRec->CacheColorExpandDensity)
+ infoRec->CacheColorExpandDensity = 1;
+ }
+ else {
+ infoRec->ScreenToScreenColorExpandFillFlags = 0;
+ infoRec->SetupForScreenToScreenColorExpandFill = NULL;
+ infoRec->SubsequentScreenToScreenColorExpandFill = NULL;
+ }
+
+ /**** Image Writes ****/
+
+ if (infoRec->SetupForImageWrite && infoRec->ImageWriteBase &&
+ infoRec->SubsequentImageWriteRect &&
+ !xf86ReturnOptValBool(options, XAAOPT_IMAGE_WRITE_RECT, FALSE)) {
+
+ infoRec->ImageWriteRange >>= 2; /* convert to DWORDS */
+ if (infoRec->ImageWriteFlags & CPU_TRANSFER_BASE_FIXED)
+ infoRec->ImageWriteRange = 0;
+ HaveImageWriteRect = TRUE;
+ }
+ else {
+ infoRec->ImageWriteFlags = 0;
+ infoRec->SetupForImageWrite = NULL;
+ infoRec->SubsequentImageWriteRect = NULL;
+ }
+
+ /**** Scanline Image Writes ****/
+
+ if (infoRec->SetupForScanlineImageWrite &&
+ infoRec->SubsequentScanlineImageWriteRect &&
+ infoRec->SubsequentImageWriteScanline &&
+ infoRec->ScanlineImageWriteBuffers &&
+ (infoRec->NumScanlineImageWriteBuffers > 0) &&
+ !xf86ReturnOptValBool(options, XAAOPT_SCANLINE_IMAGE_WRITE_RECT,
+ FALSE)) {
+ HaveScanlineImageWriteRect = TRUE;
+ }
+ else {
+ infoRec->ScanlineImageWriteFlags = 0;
+ infoRec->SetupForScanlineImageWrite = NULL;
+ infoRec->SubsequentScanlineImageWriteRect = NULL;
+ infoRec->SubsequentImageWriteScanline = NULL;
+ }
+
+#ifndef __i386__
+ /* XAA makes some unaligned accesses when clipping is not available */
+#define CLIP_FLAGS (LEFT_EDGE_CLIPPING | LEFT_EDGE_CLIPPING_NEGATIVE_X)
+ if (HaveImageWriteRect &&
+ ((infoRec->ImageWriteFlags & CLIP_FLAGS) != CLIP_FLAGS)) {
+ HaveImageWriteRect = FALSE;
+ }
+ if (HaveScanlineImageWriteRect &&
+ ((infoRec->ScanlineImageWriteFlags & CLIP_FLAGS) != CLIP_FLAGS)) {
+ HaveScanlineImageWriteRect = FALSE;
+ }
+#endif
+
+ if (serverGeneration == 1) {
+ if (HaveScreenToScreenCopy)
+ xf86ErrorF("\tScreen to screen bit blits\n");
+ if (HaveSolidFillRect)
+ xf86ErrorF("\tSolid filled rectangles\n");
+ if (HaveSolidFillTrap)
+ xf86ErrorF("\tSolid filled trapezoids\n");
+ if (HaveMono8x8PatternFillRect)
+ xf86ErrorF("\t8x8 mono pattern filled rectangles\n");
+ if (HaveMono8x8PatternFillTrap)
+ xf86ErrorF("\t8x8 mono pattern filled trapezoids\n");
+ if (HaveColor8x8PatternFillRect)
+ xf86ErrorF("\t8x8 color pattern filled rectangles\n");
+ if (HaveColor8x8PatternFillTrap)
+ xf86ErrorF("\t8x8 color pattern filled trapezoids\n");
+
+ if (HaveColorExpansion)
+ xf86ErrorF("\tCPU to Screen color expansion\n");
+ else if (HaveScanlineColorExpansion)
+ xf86ErrorF("\tIndirect CPU to Screen color expansion\n");
+
+ if (HaveScreenToScreenColorExpandFill)
+ xf86ErrorF("\tScreen to Screen color expansion\n");
+
+ if (HaveSolidTwoPointLine || HaveSolidBresenhamLine)
+ xf86ErrorF("\tSolid Lines\n");
+ else if (HaveSolidHorVertLine)
+ xf86ErrorF("\tSolid Horizontal and Vertical Lines\n");
+
+ if (HaveDashedTwoPointLine || HaveDashedBresenhamLine)
+ xf86ErrorF("\tDashed Lines\n");
+
+ if (HaveImageWriteRect)
+ xf86ErrorF("\tImage Writes\n");
+ else if (HaveScanlineImageWriteRect)
+ xf86ErrorF("\tScanline Image Writes\n");
+
+ }
+
+#define XAAMSG(s) do { if (serverGeneration == 1) xf86ErrorF(s); } while (0)
+
+ if ((infoRec->Flags & OFFSCREEN_PIXMAPS) && HaveScreenToScreenCopy &&
+ xf86ReturnOptValBool(options,
+ XAAOPT_HAS_DUMB_INVERTED_OPTION_SENSE, FALSE)) {
+ XAAMSG("\tOffscreen Pixmaps\n");
+ }
+ else {
+ infoRec->Flags &= ~OFFSCREEN_PIXMAPS;
+ }
+
+ /************** Mid Level *************/
+
+ /**** ScreenToScreenBitBlt ****/
+
+ if (infoRec->ScreenToScreenBitBlt) {
+ XAAMSG("\tDriver provided ScreenToScreenBitBlt replacement\n");
+ }
+ else if (HaveScreenToScreenCopy) {
+ infoRec->ScreenToScreenBitBlt = XAAScreenToScreenBitBlt;
+ infoRec->ScreenToScreenBitBltFlags = infoRec->ScreenToScreenCopyFlags;
+ }
+
+ /**** FillSolidRects ****/
+
+ if (infoRec->FillSolidRects) {
+ XAAMSG("\tDriver provided FillSolidRects replacement\n");
+ }
+ else if (HaveSolidFillRect) {
+ infoRec->FillSolidRects = XAAFillSolidRects;
+ infoRec->FillSolidRectsFlags = infoRec->SolidFillFlags;
+ }
+
+ /**** FillSolidSpans ****/
+
+ if (infoRec->FillSolidSpans) {
+ XAAMSG("\tDriver provided FillSolidSpans replacement\n");
+ }
+ else if (HaveSolidFillRect) {
+ infoRec->FillSolidSpans = XAAFillSolidSpans;
+ infoRec->FillSolidSpansFlags = infoRec->SolidFillFlags;
+ }
+
+ /**** FillMono8x8PatternRects ****/
+
+ if (infoRec->FillMono8x8PatternRects) {
+ XAAMSG("\tDriver provided FillMono8x8PatternRects replacement\n");
+ }
+ else if (HaveMono8x8PatternFillRect) {
+ infoRec->FillMono8x8PatternRects =
+ (infoRec->
+ Mono8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) ?
+ XAAFillMono8x8PatternRectsScreenOrigin : XAAFillMono8x8PatternRects;
+
+ infoRec->FillMono8x8PatternRectsFlags =
+ infoRec->Mono8x8PatternFillFlags;
+ }
+
+ /**** FillMono8x8PatternSpans ****/
+
+ if (infoRec->FillMono8x8PatternSpans) {
+ XAAMSG("\tDriver provided FillMono8x8PatternSpans replacement\n");
+ }
+ else if (HaveMono8x8PatternFillRect) {
+ infoRec->FillMono8x8PatternSpans =
+ (infoRec->
+ Mono8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) ?
+ XAAFillMono8x8PatternSpansScreenOrigin : XAAFillMono8x8PatternSpans;
+
+ infoRec->FillMono8x8PatternSpansFlags =
+ infoRec->Mono8x8PatternFillFlags;
+ }
+
+ /**** FillColor8x8Rects ****/
+
+ if (infoRec->FillColor8x8PatternRects) {
+ XAAMSG("\tDriver provided FillColor8x8PatternRects replacement\n");
+ }
+ else if (HaveColor8x8PatternFillRect) {
+ infoRec->FillColor8x8PatternRects =
+ (infoRec->
+ Color8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) ?
+ XAAFillColor8x8PatternRectsScreenOrigin :
+ XAAFillColor8x8PatternRects;
+
+ infoRec->FillColor8x8PatternRectsFlags =
+ infoRec->Color8x8PatternFillFlags;
+ }
+
+ /**** FillColor8x8Spans ****/
+
+ if (infoRec->FillColor8x8PatternSpans) {
+ XAAMSG("\tDriver provided FillColor8x8PatternSpans replacement\n");
+ }
+ else if (HaveColor8x8PatternFillRect) {
+ infoRec->FillColor8x8PatternSpans =
+ (infoRec->
+ Color8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) ?
+ XAAFillColor8x8PatternSpansScreenOrigin :
+ XAAFillColor8x8PatternSpans;
+
+ infoRec->FillColor8x8PatternSpansFlags =
+ infoRec->Color8x8PatternFillFlags;
+ }
+
+ /**** FillCacheBltRects ****/
+
+ if (infoRec->FillCacheBltRects) {
+ XAAMSG("\tDriver provided FillCacheBltRects replacement\n");
+ }
+ else if (HaveScreenToScreenCopy) {
+ infoRec->FillCacheBltRects = XAAFillCacheBltRects;
+ infoRec->FillCacheBltRectsFlags = infoRec->ScreenToScreenCopyFlags;
+ }
+
+ /**** FillCacheBltSpans ****/
+
+ if (infoRec->FillCacheBltSpans) {
+ XAAMSG("\tDriver provided FillCacheBltSpans replacement\n");
+ }
+ else if (HaveScreenToScreenCopy) {
+ infoRec->FillCacheBltSpans = XAAFillCacheBltSpans;
+ infoRec->FillCacheBltSpansFlags = infoRec->ScreenToScreenCopyFlags;
+ }
+
+ /**** FillCacheExpandRects ****/
+
+ if (infoRec->FillCacheExpandRects) {
+ XAAMSG("\tDriver provided FillCacheExpandRects replacement\n");
+ }
+ else if (HaveScreenToScreenColorExpandFill) {
+ infoRec->FillCacheExpandRects = XAAFillCacheExpandRects;
+ infoRec->FillCacheExpandRectsFlags =
+ infoRec->ScreenToScreenColorExpandFillFlags;
+ }
+
+ /**** FillCacheExpandSpans ****/
+
+ if (infoRec->FillCacheExpandSpans) {
+ XAAMSG("\tDriver provided FillCacheExpandSpans replacement\n");
+ }
+ else if (HaveScreenToScreenColorExpandFill) {
+ infoRec->FillCacheExpandSpans = XAAFillCacheExpandSpans;
+ infoRec->FillCacheExpandSpansFlags =
+ infoRec->ScreenToScreenColorExpandFillFlags;
+ }
+
+ /**** FillColorExpandRects ****/
+
+ if (infoRec->FillColorExpandRects) {
+ XAAMSG("\tDriver provided FillColorExpandRects replacement\n");
+ }
+ else if (HaveColorExpansion) {
+ if (infoRec->CPUToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP) {
+ if (infoRec->CPUToScreenColorExpandFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST) {
+ if (infoRec->CPUToScreenColorExpandFillFlags &
+ CPU_TRANSFER_BASE_FIXED)
+ infoRec->FillColorExpandRects =
+ XAAFillColorExpandRects3MSBFirstFixedBase;
+ else
+ infoRec->FillColorExpandRects =
+ XAAFillColorExpandRects3MSBFirst;
+ }
+ else {
+ if (infoRec->CPUToScreenColorExpandFillFlags &
+ CPU_TRANSFER_BASE_FIXED)
+ infoRec->FillColorExpandRects =
+ XAAFillColorExpandRects3LSBFirstFixedBase;
+ else
+ infoRec->FillColorExpandRects =
+ XAAFillColorExpandRects3LSBFirst;
+ }
+ }
+ else {
+ if (infoRec->CPUToScreenColorExpandFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST) {
+ if (infoRec->CPUToScreenColorExpandFillFlags &
+ CPU_TRANSFER_BASE_FIXED)
+ infoRec->FillColorExpandRects =
+ XAAFillColorExpandRectsMSBFirstFixedBase;
+ else
+ infoRec->FillColorExpandRects =
+ XAAFillColorExpandRectsMSBFirst;
+ }
+ else {
+ if (infoRec->CPUToScreenColorExpandFillFlags &
+ CPU_TRANSFER_BASE_FIXED)
+ infoRec->FillColorExpandRects =
+ XAAFillColorExpandRectsLSBFirstFixedBase;
+ else
+ infoRec->FillColorExpandRects =
+ XAAFillColorExpandRectsLSBFirst;
+ }
+ }
+ infoRec->FillColorExpandRectsFlags =
+ infoRec->CPUToScreenColorExpandFillFlags;
+ }
+ else if (HaveScanlineColorExpansion) {
+ if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
+ TRIPLE_BITS_24BPP) {
+ if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST)
+ infoRec->FillColorExpandRects =
+ XAAFillScanlineColorExpandRects3MSBFirst;
+ else
+ infoRec->FillColorExpandRects =
+ XAAFillScanlineColorExpandRects3LSBFirst;
+ }
+ else {
+ if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST)
+ infoRec->FillColorExpandRects =
+ XAAFillScanlineColorExpandRectsMSBFirst;
+ else
+ infoRec->FillColorExpandRects =
+ XAAFillScanlineColorExpandRectsLSBFirst;
+ }
+ infoRec->FillColorExpandRectsFlags =
+ infoRec->ScanlineCPUToScreenColorExpandFillFlags;
+ }
+
+ /**** FillColorExpandSpans ****/
+
+ if (infoRec->FillColorExpandSpans) {
+ XAAMSG("\tDriver provided FillColorExpandSpans replacement\n");
+ }
+ else if (HaveColorExpansion) {
+ if (infoRec->CPUToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP) {
+ if (infoRec->CPUToScreenColorExpandFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST) {
+ if (infoRec->CPUToScreenColorExpandFillFlags &
+ CPU_TRANSFER_BASE_FIXED)
+ infoRec->FillColorExpandSpans =
+ XAAFillColorExpandSpans3MSBFirstFixedBase;
+ else
+ infoRec->FillColorExpandSpans =
+ XAAFillColorExpandSpans3MSBFirst;
+ }
+ else {
+ if (infoRec->CPUToScreenColorExpandFillFlags &
+ CPU_TRANSFER_BASE_FIXED)
+ infoRec->FillColorExpandSpans =
+ XAAFillColorExpandSpans3LSBFirstFixedBase;
+ else
+ infoRec->FillColorExpandSpans =
+ XAAFillColorExpandSpans3LSBFirst;
+ }
+ }
+ else {
+ if (infoRec->CPUToScreenColorExpandFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST) {
+ if (infoRec->CPUToScreenColorExpandFillFlags &
+ CPU_TRANSFER_BASE_FIXED)
+ infoRec->FillColorExpandSpans =
+ XAAFillColorExpandSpansMSBFirstFixedBase;
+ else
+ infoRec->FillColorExpandSpans =
+ XAAFillColorExpandSpansMSBFirst;
+ }
+ else {
+ if (infoRec->CPUToScreenColorExpandFillFlags &
+ CPU_TRANSFER_BASE_FIXED)
+ infoRec->FillColorExpandSpans =
+ XAAFillColorExpandSpansLSBFirstFixedBase;
+ else
+ infoRec->FillColorExpandSpans =
+ XAAFillColorExpandSpansLSBFirst;
+ }
+ }
+ infoRec->FillColorExpandSpansFlags =
+ infoRec->CPUToScreenColorExpandFillFlags;
+ }
+ else if (HaveScanlineColorExpansion) {
+ if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
+ TRIPLE_BITS_24BPP) {
+ if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST)
+ infoRec->FillColorExpandSpans =
+ XAAFillScanlineColorExpandSpans3MSBFirst;
+ else
+ infoRec->FillColorExpandSpans =
+ XAAFillScanlineColorExpandSpans3LSBFirst;
+ }
+ else {
+ if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST)
+ infoRec->FillColorExpandSpans =
+ XAAFillScanlineColorExpandSpansMSBFirst;
+ else
+ infoRec->FillColorExpandSpans =
+ XAAFillScanlineColorExpandSpansLSBFirst;
+ }
+ infoRec->FillColorExpandSpansFlags =
+ infoRec->ScanlineCPUToScreenColorExpandFillFlags;
+ }
+
+ /**** FillImageWriteRects ****/
+
+ if (infoRec->FillImageWriteRects) {
+ XAAMSG("\tDriver provided FillImageWriteRects replacement\n");
+ }
+ else if (HaveImageWriteRect &&
+ (infoRec->ImageWriteFlags & LEFT_EDGE_CLIPPING_NEGATIVE_X) &&
+ (infoRec->ImageWriteFlags & LEFT_EDGE_CLIPPING)) {
+ infoRec->FillImageWriteRects = XAAFillImageWriteRects;
+ infoRec->FillImageWriteRectsFlags = infoRec->ImageWriteFlags;
+ }
+
+ /**** WriteBitmap ****/
+
+ if (infoRec->WriteBitmap &&
+ !xf86ReturnOptValBool(options, XAAOPT_WRITE_BITMAP, FALSE)) {
+ XAAMSG("\tDriver provided WriteBitmap replacement\n");
+ }
+ else if (HaveColorExpansion) {
+ if (infoRec->CPUToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP) {
+ if (infoRec->CPUToScreenColorExpandFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST) {
+ if (infoRec->CPUToScreenColorExpandFillFlags &
+ CPU_TRANSFER_BASE_FIXED)
+ infoRec->WriteBitmap =
+ XAAWriteBitmapColorExpand3MSBFirstFixedBase;
+ else
+ infoRec->WriteBitmap = XAAWriteBitmapColorExpand3MSBFirst;
+ }
+ else {
+ if (infoRec->CPUToScreenColorExpandFillFlags &
+ CPU_TRANSFER_BASE_FIXED)
+ infoRec->WriteBitmap =
+ XAAWriteBitmapColorExpand3LSBFirstFixedBase;
+ else
+ infoRec->WriteBitmap = XAAWriteBitmapColorExpand3LSBFirst;
+ }
+ }
+ else {
+ if (infoRec->CPUToScreenColorExpandFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST) {
+ if (infoRec->CPUToScreenColorExpandFillFlags &
+ CPU_TRANSFER_BASE_FIXED)
+ infoRec->WriteBitmap =
+ XAAWriteBitmapColorExpandMSBFirstFixedBase;
+ else
+ infoRec->WriteBitmap = XAAWriteBitmapColorExpandMSBFirst;
+ }
+ else {
+ if (infoRec->CPUToScreenColorExpandFillFlags &
+ CPU_TRANSFER_BASE_FIXED)
+ infoRec->WriteBitmap =
+ XAAWriteBitmapColorExpandLSBFirstFixedBase;
+ else
+ infoRec->WriteBitmap = XAAWriteBitmapColorExpandLSBFirst;
+ }
+ }
+ infoRec->WriteBitmapFlags = infoRec->CPUToScreenColorExpandFillFlags;
+ }
+ else if (HaveScanlineColorExpansion) {
+ if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
+ TRIPLE_BITS_24BPP) {
+ if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST)
+ infoRec->WriteBitmap =
+ XAAWriteBitmapScanlineColorExpand3MSBFirst;
+ else
+ infoRec->WriteBitmap =
+ XAAWriteBitmapScanlineColorExpand3LSBFirst;
+ }
+ else {
+ if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST)
+ infoRec->WriteBitmap =
+ XAAWriteBitmapScanlineColorExpandMSBFirst;
+ else
+ infoRec->WriteBitmap =
+ XAAWriteBitmapScanlineColorExpandLSBFirst;
+ }
+ infoRec->WriteBitmapFlags =
+ infoRec->ScanlineCPUToScreenColorExpandFillFlags;
+ }
+ else
+ infoRec->WriteBitmap = NULL;
+
+ /**** TE Glyphs ****/
+
+ if (infoRec->TEGlyphRenderer) {
+ XAAMSG("\tDriver provided TEGlyphRenderer replacement\n");
+ }
+ else if (HaveColorExpansion) {
+ infoRec->TEGlyphRendererFlags =
+ infoRec->CPUToScreenColorExpandFillFlags;
+
+ if (infoRec->TEGlyphRendererFlags & TRIPLE_BITS_24BPP) {
+ if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST) {
+ if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED)
+ infoRec->TEGlyphRenderer =
+ XAATEGlyphRenderer3MSBFirstFixedBase;
+ else
+ infoRec->TEGlyphRenderer = XAATEGlyphRenderer3MSBFirst;
+ }
+ else {
+ if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED)
+ infoRec->TEGlyphRenderer =
+ XAATEGlyphRenderer3LSBFirstFixedBase;
+ else
+ infoRec->TEGlyphRenderer = XAATEGlyphRenderer3LSBFirst;
+ }
+
+ if (!HaveSolidFillRect &&
+ (infoRec->TEGlyphRendererFlags & RGB_EQUAL)) {
+ infoRec->TEGlyphRendererFlags &= ~RGB_EQUAL;
+ XAAMSG("WARNING: TEGlyphRenderer cannot support RGB_EQUAL"
+ " without solid fills\n");
+ }
+ }
+ else {
+ if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST) {
+ if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED)
+ infoRec->TEGlyphRenderer =
+ XAATEGlyphRendererMSBFirstFixedBase;
+ else
+ infoRec->TEGlyphRenderer = XAATEGlyphRendererMSBFirst;
+ }
+ else {
+ if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED)
+ infoRec->TEGlyphRenderer =
+ XAATEGlyphRendererLSBFirstFixedBase;
+ else
+ infoRec->TEGlyphRenderer = XAATEGlyphRendererLSBFirst;
+ }
+ }
+
+ if (!HaveSolidFillRect &&
+ (infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) {
+ infoRec->TEGlyphRendererFlags &= ~TRANSPARENCY_ONLY;
+ XAAMSG("WARNING: TEGlyphRenderer cannot support TRANPARENCY_ONLY"
+ " without solid fills\n");
+ }
+
+ }
+ else if (HaveScanlineColorExpansion) {
+ infoRec->TEGlyphRendererFlags =
+ infoRec->ScanlineCPUToScreenColorExpandFillFlags;
+
+ if (infoRec->TEGlyphRendererFlags & TRIPLE_BITS_24BPP) {
+ if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST)
+ infoRec->TEGlyphRenderer = XAATEGlyphRendererScanline3MSBFirst;
+ else
+ infoRec->TEGlyphRenderer = XAATEGlyphRendererScanline3LSBFirst;
+
+ if (!HaveSolidFillRect &&
+ (infoRec->TEGlyphRendererFlags & RGB_EQUAL)) {
+ infoRec->TEGlyphRendererFlags &= ~RGB_EQUAL;
+ XAAMSG("WARNING: TEGlyphRenderer cannot support RGB_EQUAL"
+ " without solid fills\n");
+ }
+ }
+ else {
+ if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST)
+ infoRec->TEGlyphRenderer = XAATEGlyphRendererScanlineMSBFirst;
+ else
+ infoRec->TEGlyphRenderer = XAATEGlyphRendererScanlineLSBFirst;
+ }
+
+ if (!HaveSolidFillRect &&
+ (infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) {
+ infoRec->TEGlyphRendererFlags &= ~TRANSPARENCY_ONLY;
+ XAAMSG("WARNING: TEGlyphRenderer cannot support TRANPARENCY_ONLY"
+ " without solid fills\n");
+ }
+ }
+
+ /**** NonTE Glyphs ****/
+
+ if (infoRec->NonTEGlyphRenderer) {
+ XAAMSG("\tDriver provided NonTEGlyphRenderer replacement\n");
+ }
+ else if (infoRec->WriteBitmap &&
+ !(infoRec->WriteBitmapFlags & NO_TRANSPARENCY)) {
+ infoRec->NonTEGlyphRenderer = XAANonTEGlyphRenderer;
+ infoRec->NonTEGlyphRendererFlags = infoRec->WriteBitmapFlags;
+ }
+
+ /**** WritePixmap ****/
+
+ if (infoRec->WritePixmap &&
+ !xf86ReturnOptValBool(options, XAAOPT_WRITE_PIXMAP, FALSE)) {
+ XAAMSG("\tDriver provided WritePixmap replacement\n");
+ }
+ else if (HaveImageWriteRect) {
+ infoRec->WritePixmap = XAAWritePixmap;
+ infoRec->WritePixmapFlags =
+ infoRec->ImageWriteFlags | CONVERT_32BPP_TO_24BPP;
+ }
+ else if (HaveScanlineImageWriteRect) {
+ infoRec->WritePixmap = XAAWritePixmapScanline;
+ infoRec->WritePixmapFlags = infoRec->ScanlineImageWriteFlags;
+ }
+ else
+ infoRec->WritePixmap = NULL;
+
+ /**** ReadPixmap ****/
+
+ if (infoRec->ReadPixmap) {
+ XAAMSG("\tDriver provided ReadPixmap replacement\n");
+ }
+
+ /************** GC Level *************/
+
+ /**** CopyArea ****/
+
+ if (infoRec->CopyArea) {
+ XAAMSG("\tDriver provided GC level CopyArea replacement\n");
+ }
+ else if (infoRec->ScreenToScreenBitBlt) {
+ infoRec->CopyArea = XAACopyArea;
+ infoRec->CopyAreaFlags = infoRec->ScreenToScreenBitBltFlags;
+
+ /* most GC level primitives use one mid-level primitive so
+ the GC level primitive gets the mid-level primitive flag
+ and we use that at GC validation time. But CopyArea uses
+ more than one mid-level primitive so we have to essentially
+ do a GC validation every time that primitive is used.
+ The CopyAreaFlags would only be used for filtering out the
+ common denominators. Here we assume that if you don't do
+ ScreenToScreenBitBlt you aren't going to do the others.
+ We also assume that ScreenToScreenBitBlt has the least
+ restrictions. */
+ }
+
+ if (infoRec->CopyPlane) {
+ XAAMSG("\tDriver provided GC level CopyPlane replacement\n");
+ }
+ else if (infoRec->WriteBitmap &&
+ !(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY)) {
+ infoRec->CopyPlane = XAACopyPlaneColorExpansion;
+ infoRec->CopyPlaneFlags = infoRec->WriteBitmapFlags;
+ }
+
+ if (infoRec->PushPixelsSolid) {
+ XAAMSG("\tDriver provided GC level PushPixelsSolid replacement\n");
+ }
+ else if (infoRec->WriteBitmap &&
+ !(infoRec->WriteBitmapFlags & NO_TRANSPARENCY)) {
+ infoRec->PushPixelsSolid = XAAPushPixelsSolidColorExpansion;
+ infoRec->PushPixelsFlags = infoRec->WriteBitmapFlags;
+ }
+
+ if (infoRec->FillSolidRects) {
+ if (!infoRec->PolyFillRectSolid) {
+ infoRec->PolyFillRectSolid = XAAPolyFillRect;
+ infoRec->PolyFillRectSolidFlags = infoRec->FillSolidRectsFlags;
+ }
+ }
+ if (infoRec->FillSolidSpans) {
+ if (!infoRec->FillSpansSolid) {
+ infoRec->FillSpansSolid = XAAFillSpans;
+ infoRec->FillSpansSolidFlags = infoRec->FillSolidSpansFlags;
+ }
+ }
+
+ if (infoRec->FillMono8x8PatternRects || infoRec->FillColor8x8PatternRects ||
+ infoRec->FillCacheBltRects || infoRec->FillColorExpandRects ||
+ infoRec->FillCacheExpandRects) {
+ if (!infoRec->PolyFillRectStippled) {
+
+ infoRec->PolyFillRectStippled = XAAPolyFillRect;
+ infoRec->PolyFillRectStippledFlags = 0;
+ }
+ }
+
+ if (infoRec->FillMono8x8PatternSpans || infoRec->FillColor8x8PatternSpans ||
+ infoRec->FillCacheBltSpans || infoRec->FillColorExpandSpans ||
+ infoRec->FillCacheExpandSpans) {
+ if (!infoRec->FillSpansStippled) {
+
+ infoRec->FillSpansStippled = XAAFillSpans;
+ infoRec->FillSpansStippledFlags = 0;
+ }
+ }
+
+ if (infoRec->FillMono8x8PatternRects || infoRec->FillColor8x8PatternRects ||
+ infoRec->FillCacheBltRects || infoRec->FillColorExpandRects ||
+ infoRec->FillCacheExpandRects) {
+ if (!infoRec->PolyFillRectOpaqueStippled) {
+
+ infoRec->PolyFillRectOpaqueStippled = XAAPolyFillRect;
+ infoRec->PolyFillRectOpaqueStippledFlags = 0;
+ }
+ }
+
+ if (infoRec->FillMono8x8PatternSpans || infoRec->FillColor8x8PatternSpans ||
+ infoRec->FillCacheBltSpans || infoRec->FillColorExpandSpans ||
+ infoRec->FillCacheExpandSpans) {
+ if (!infoRec->FillSpansOpaqueStippled) {
+
+ infoRec->FillSpansOpaqueStippled = XAAFillSpans;
+ infoRec->FillSpansOpaqueStippledFlags = 0;
+ }
+ }
+
+ if (infoRec->FillMono8x8PatternRects || infoRec->FillColor8x8PatternRects ||
+ infoRec->FillCacheBltRects || infoRec->FillImageWriteRects) {
+ if (!infoRec->PolyFillRectTiled) {
+
+ infoRec->PolyFillRectTiled = XAAPolyFillRect;
+ infoRec->PolyFillRectTiledFlags = 0;
+ }
+ }
+
+ if (infoRec->FillMono8x8PatternSpans || infoRec->FillColor8x8PatternSpans ||
+ infoRec->FillCacheBltSpans) {
+ if (!infoRec->FillSpansTiled) {
+
+ infoRec->FillSpansTiled = XAAFillSpans;
+ infoRec->FillSpansTiledFlags = 0;
+ }
+ }
+
+ if (infoRec->TEGlyphRenderer &&
+ !(infoRec->TEGlyphRendererFlags & NO_TRANSPARENCY)) {
+
+ if (!infoRec->PolyText8TE) {
+ infoRec->PolyText8TE = XAAPolyText8TEColorExpansion;
+ infoRec->PolyText8TEFlags = infoRec->TEGlyphRendererFlags;
+ }
+
+ if (!infoRec->PolyText16TE) {
+ infoRec->PolyText16TE = XAAPolyText16TEColorExpansion;
+ infoRec->PolyText16TEFlags = infoRec->TEGlyphRendererFlags;
+ }
+
+ if (!infoRec->PolyGlyphBltTE) {
+ infoRec->PolyGlyphBltTE = XAAPolyGlyphBltTEColorExpansion;
+ infoRec->PolyGlyphBltTEFlags = infoRec->TEGlyphRendererFlags;
+ }
+ }
+
+ if (infoRec->TEGlyphRenderer &&
+ !(infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) {
+
+ if (!infoRec->ImageText8TE) {
+ infoRec->ImageText8TE = XAAImageText8TEColorExpansion;
+ infoRec->ImageText8TEFlags = infoRec->TEGlyphRendererFlags;
+ }
+
+ if (!infoRec->ImageText16TE) {
+ infoRec->ImageText16TE = XAAImageText16TEColorExpansion;
+ infoRec->ImageText16TEFlags = infoRec->TEGlyphRendererFlags;
+ }
+
+ if (!infoRec->ImageGlyphBltTE) {
+ infoRec->ImageGlyphBltTE = XAAImageGlyphBltTEColorExpansion;
+ infoRec->ImageGlyphBltTEFlags = infoRec->TEGlyphRendererFlags;
+ }
+ }
+
+ if (infoRec->NonTEGlyphRenderer) {
+ if (!infoRec->PolyText8NonTE) {
+ infoRec->PolyText8NonTE = XAAPolyText8NonTEColorExpansion;
+ infoRec->PolyText8NonTEFlags = infoRec->NonTEGlyphRendererFlags;
+ }
+
+ if (!infoRec->PolyText16NonTE) {
+ infoRec->PolyText16NonTE = XAAPolyText16NonTEColorExpansion;
+ infoRec->PolyText16NonTEFlags = infoRec->NonTEGlyphRendererFlags;
+ }
+ if (!infoRec->PolyGlyphBltNonTE) {
+ infoRec->PolyGlyphBltNonTE = XAAPolyGlyphBltNonTEColorExpansion;
+ infoRec->PolyGlyphBltNonTEFlags = infoRec->NonTEGlyphRendererFlags;
+ }
+ }
+
+ if (infoRec->NonTEGlyphRenderer && HaveSolidFillRect) {
+ if (!infoRec->ImageText8NonTE) {
+ infoRec->ImageText8NonTE = XAAImageText8NonTEColorExpansion;
+ infoRec->ImageText8NonTEFlags = infoRec->NonTEGlyphRendererFlags;
+ }
+
+ if (!infoRec->ImageText16NonTE) {
+ infoRec->ImageText16NonTE = XAAImageText16NonTEColorExpansion;
+ infoRec->ImageText16NonTEFlags = infoRec->NonTEGlyphRendererFlags;
+ }
+
+ if (!infoRec->ImageGlyphBltNonTE) {
+ infoRec->ImageGlyphBltNonTE = XAAImageGlyphBltNonTEColorExpansion;
+ infoRec->ImageGlyphBltNonTEFlags = infoRec->NonTEGlyphRendererFlags;
+ }
+ }
+
+ if (!infoRec->PolyRectangleThinSolid && HaveSolidHorVertLine) {
+ infoRec->PolyRectangleThinSolid = XAAPolyRectangleThinSolid;
+ infoRec->PolyRectangleThinSolidFlags = infoRec->SolidLineFlags;
+ }
+
+ if (!infoRec->FillPolygonSolid && HaveSolidFillRect) {
+ infoRec->FillPolygonSolid = XAAFillPolygonSolid;
+ infoRec->FillPolygonSolidFlags = infoRec->SolidFillFlags;
+ }
+
+ if (!infoRec->FillPolygonStippled && (HaveMono8x8PatternFillRect ||
+ HaveScreenToScreenColorExpandFill ||
+ HaveScreenToScreenCopy)) {
+ infoRec->FillPolygonStippled = XAAFillPolygonStippled;
+ infoRec->FillPolygonStippledFlags = infoRec->SolidFillFlags;
+ }
+
+ if (!infoRec->FillPolygonOpaqueStippled && (HaveMono8x8PatternFillRect ||
+ HaveScreenToScreenColorExpandFill
+ || HaveScreenToScreenCopy)) {
+ infoRec->FillPolygonOpaqueStippled = XAAFillPolygonStippled;
+ infoRec->FillPolygonOpaqueStippledFlags = infoRec->SolidFillFlags;
+ }
+
+ if (!infoRec->FillPolygonTiled && (HaveMono8x8PatternFillRect ||
+ HaveScreenToScreenColorExpandFill ||
+ HaveScreenToScreenCopy)) {
+ infoRec->FillPolygonTiled = XAAFillPolygonTiled;
+ infoRec->FillPolygonTiledFlags = infoRec->SolidFillFlags;
+ }
+
+ if (!infoRec->PolyFillArcSolid && HaveSolidFillRect) {
+ infoRec->PolyFillArcSolid = XAAPolyFillArcSolid;
+ infoRec->PolyFillArcSolidFlags = infoRec->SolidFillFlags;
+ }
+
+ if (!infoRec->PolylinesWideSolid && HaveSolidFillRect) {
+ infoRec->PolylinesWideSolid = XAAPolylinesWideSolid;
+ infoRec->PolylinesWideSolidFlags =
+ infoRec->SolidFillFlags | GXCOPY_ONLY;
+ }
+
+ if (!infoRec->PutImage && (infoRec->WritePixmap ||
+ (infoRec->WriteBitmap &&
+ !(infoRec->
+ WriteBitmapFlags & TRANSPARENCY_ONLY)))) {
+ infoRec->PutImage = XAAPutImage;
+
+ /* See comment for CopyArea above. But here we make fewer
+ assumptions. The driver can provide the PutImageFlags if
+ it wants too */
+ }
+
+ if (HaveSolidHorVertLine &&
+ (HaveSolidBresenhamLine || (HaveSolidTwoPointLine &&
+ (infoRec->
+ ClippingFlags &
+ HARDWARE_CLIP_SOLID_LINE)))) {
+ if (!infoRec->PolylinesThinSolid) {
+ infoRec->PolylinesThinSolid = XAAPolyLines;
+ infoRec->PolylinesThinSolidFlags = infoRec->SolidLineFlags;
+ }
+ if (!infoRec->PolySegmentThinSolid) {
+ infoRec->PolySegmentThinSolid = XAAPolySegment;
+ infoRec->PolySegmentThinSolidFlags = infoRec->SolidLineFlags;
+ }
+ }
+
+ if (HaveDashedBresenhamLine || (HaveDashedTwoPointLine &&
+ (infoRec->
+ ClippingFlags &
+ HARDWARE_CLIP_DASHED_LINE))) {
+ if (!infoRec->PolylinesThinDashed) {
+ infoRec->PolylinesThinDashed = XAAPolyLinesDashed;
+ infoRec->PolylinesThinDashedFlags = infoRec->DashedLineFlags;
+ }
+ if (!infoRec->PolySegmentThinDashed) {
+ infoRec->PolySegmentThinDashed = XAAPolySegmentDashed;
+ infoRec->PolySegmentThinDashedFlags = infoRec->DashedLineFlags;
+ }
+ }
+
+ if (infoRec->PolylinesThinDashed || infoRec->PolySegmentThinDashed) {
+ if (!infoRec->ComputeDash)
+ infoRec->ComputeDash = XAAComputeDash;
+ }
+
+ {
+ Bool haveTexture = infoRec->CPUToScreenTextureFormats &&
+ infoRec->CPUToScreenTextureDstFormats &&
+ infoRec->SetupForCPUToScreenTexture2 &&
+ infoRec->SubsequentCPUToScreenTexture;
+ Bool haveAlphaTexture = infoRec->CPUToScreenAlphaTextureFormats &&
+ infoRec->CPUToScreenAlphaTextureDstFormats &&
+ infoRec->SetupForCPUToScreenAlphaTexture2 &&
+ infoRec->SubsequentCPUToScreenAlphaTexture;
+
+ if (!infoRec->Composite && (haveTexture || haveAlphaTexture))
+ infoRec->Composite = XAADoComposite;
+
+ if (!infoRec->Glyphs && infoRec->WriteBitmap &&
+ !(infoRec->WriteBitmapFlags & NO_TRANSPARENCY)) {
+ infoRec->Glyphs = XAADoGlyphs;
+ }
+ }
+
+ /************ Validation Functions **************/
+
+ if (!infoRec->ValidateCopyArea && infoRec->CopyArea) {
+ infoRec->CopyAreaMask = GCWhenForced;
+ if ((infoRec->CopyAreaFlags & GXCOPY_ONLY) ||
+ (infoRec->CopyAreaFlags & ROP_NEEDS_SOURCE))
+ infoRec->CopyAreaMask |= GCFunction;
+ if (infoRec->CopyAreaFlags & NO_PLANEMASK)
+ infoRec->CopyAreaMask |= GCPlaneMask;
+ infoRec->ValidateCopyArea = XAAValidateCopyArea;
+ }
+
+ if (!infoRec->ValidateCopyPlane && infoRec->CopyPlane) {
+ infoRec->CopyPlaneMask = GCWhenForced;
+ if ((infoRec->CopyPlaneFlags & GXCOPY_ONLY) ||
+ (infoRec->CopyPlaneFlags & ROP_NEEDS_SOURCE))
+ infoRec->CopyPlaneMask |= GCFunction;
+ if (infoRec->CopyPlaneFlags & NO_PLANEMASK)
+ infoRec->CopyPlaneMask |= GCPlaneMask;
+ if (infoRec->CopyPlaneFlags & RGB_EQUAL)
+ infoRec->CopyPlaneMask |= GCForeground | GCBackground;
+ infoRec->ValidateCopyPlane = XAAValidateCopyPlane;
+ }
+
+ if (!infoRec->ValidatePutImage && infoRec->PutImage) {
+ infoRec->PutImageMask = GCWhenForced;
+ if ((infoRec->PutImageFlags & GXCOPY_ONLY) ||
+ (infoRec->PutImageFlags & ROP_NEEDS_SOURCE))
+ infoRec->PutImageMask |= GCFunction;
+ if (infoRec->PutImageFlags & NO_PLANEMASK)
+ infoRec->PutImageMask |= GCPlaneMask;
+ if (infoRec->PutImageFlags & RGB_EQUAL)
+ infoRec->PutImageMask |= GCForeground | GCBackground;
+ infoRec->ValidatePutImage = XAAValidatePutImage;
+ }
+
+ if (!infoRec->ValidatePushPixels && infoRec->PushPixelsSolid) {
+ infoRec->PushPixelsMask = GCFillStyle;
+ if ((infoRec->PushPixelsFlags & GXCOPY_ONLY) ||
+ (infoRec->PushPixelsFlags & ROP_NEEDS_SOURCE) ||
+ (infoRec->PushPixelsFlags & TRANSPARENCY_GXCOPY_ONLY))
+ infoRec->PushPixelsMask |= GCFunction;
+ if (infoRec->PushPixelsFlags & NO_PLANEMASK)
+ infoRec->PushPixelsMask |= GCPlaneMask;
+ if (infoRec->PushPixelsFlags & RGB_EQUAL)
+ infoRec->PushPixelsMask |= GCForeground;
+ infoRec->ValidatePushPixels = XAAValidatePushPixels;
+ }
+
+ /* By default XAA assumes the FillSpans, PolyFillRects, FillPolygon
+ and PolyFillArcs have the same restrictions. If you supply GC
+ level replacements for any of these and alter this relationship
+ you may need to supply replacement validation routines */
+
+ if (!infoRec->ValidateFillSpans &&
+ (infoRec->FillSpansSolid || infoRec->FillSpansStippled ||
+ infoRec->FillSpansOpaqueStippled || infoRec->FillSpansTiled)) {
+
+ int compositeFlags = infoRec->FillSpansSolidFlags |
+ infoRec->FillSpansStippledFlags |
+ infoRec->FillSpansOpaqueStippledFlags |
+ infoRec->FillSpansTiledFlags;
+
+ infoRec->FillSpansMask = GCFillStyle | GCTile | GCStipple;
+
+ if ((compositeFlags & GXCOPY_ONLY) ||
+ (compositeFlags & ROP_NEEDS_SOURCE))
+ infoRec->FillSpansMask |= GCFunction;
+ if (compositeFlags & NO_PLANEMASK)
+ infoRec->FillSpansMask |= GCPlaneMask;
+ if (compositeFlags & RGB_EQUAL)
+ infoRec->FillSpansMask |= GCForeground;
+ infoRec->ValidateFillSpans = XAAValidateFillSpans;
+ }
+
+ /* By default XAA only provides Validations for the GlyphBlt
+ functions and not the text higher up. This is because the
+ Text8/16 and GlyphBlt are linked. If you break this linkage,
+ you may need to have the driver supply its own Validation
+ routines */
+
+ if (!infoRec->ValidatePolyGlyphBlt &&
+ (infoRec->PolyGlyphBltTE || infoRec->PolyGlyphBltNonTE)) {
+ int compositeFlags = infoRec->PolyGlyphBltTEFlags |
+ infoRec->PolyGlyphBltNonTEFlags;
+
+ infoRec->PolyGlyphBltMask = GCFillStyle | GCFont;
+ if ((compositeFlags & GXCOPY_ONLY) ||
+ (compositeFlags & ROP_NEEDS_SOURCE) ||
+ (infoRec->PolyGlyphBltNonTEFlags & TRANSPARENCY_GXCOPY_ONLY))
+ infoRec->PolyGlyphBltMask |= GCFunction;
+ if (compositeFlags & NO_PLANEMASK)
+ infoRec->PolyGlyphBltMask |= GCPlaneMask;
+ if (compositeFlags & RGB_EQUAL)
+ infoRec->PolyGlyphBltMask |= GCForeground;
+ infoRec->ValidatePolyGlyphBlt = XAAValidatePolyGlyphBlt;
+ }
+
+ if (!infoRec->ValidateImageGlyphBlt &&
+ (infoRec->ImageGlyphBltTE || infoRec->ImageGlyphBltNonTE)) {
+ int compositeFlags = infoRec->ImageGlyphBltTEFlags |
+ infoRec->ImageGlyphBltNonTEFlags;
+
+ if (infoRec->ImageGlyphBltNonTE)
+ compositeFlags |= infoRec->SolidFillFlags;
+
+ infoRec->ImageGlyphBltMask = GCFont;
+ if (compositeFlags & NO_PLANEMASK)
+ infoRec->ImageGlyphBltMask |= GCPlaneMask;
+ if (compositeFlags & RGB_EQUAL)
+ infoRec->ImageGlyphBltMask |= GCForeground | GCBackground;
+ infoRec->ValidateImageGlyphBlt = XAAValidateImageGlyphBlt;
+ }
+
+ /* By default XAA only provides a Validation function for the
+ Polylines and does segments and polylines at the same time */
+
+ if (!infoRec->ValidatePolylines && infoRec->ValidateFillSpans) {
+ int compositeFlags = infoRec->PolyRectangleThinSolidFlags |
+ infoRec->PolylinesWideSolidFlags |
+ infoRec->PolylinesThinSolidFlags |
+ infoRec->PolySegmentThinSolidFlags |
+ infoRec->PolySegmentThinDashedFlags |
+ infoRec->PolylinesThinDashedFlags;
+
+ infoRec->ValidatePolylines = XAAValidatePolylines;
+ infoRec->PolylinesMask =
+ infoRec->FillSpansMask | GCLineStyle | GCLineWidth;
+
+ if (infoRec->PolySegmentThinDashed || infoRec->PolylinesThinDashed)
+ infoRec->PolylinesMask |= GCDashList;
+ if (compositeFlags & NO_PLANEMASK)
+ infoRec->PolylinesMask |= GCPlaneMask;
+ if ((compositeFlags & GXCOPY_ONLY) ||
+ (compositeFlags & ROP_NEEDS_SOURCE))
+ infoRec->PolylinesMask |= GCFunction;
+ if (compositeFlags & RGB_EQUAL)
+ infoRec->PolylinesMask |= GCForeground;
+ }
+
+ /**** Fill choosers ****/
+
+ if (!infoRec->StippledFillChooser)
+ infoRec->StippledFillChooser = XAAStippledFillChooser;
+
+ if (!infoRec->OpaqueStippledFillChooser)
+ infoRec->OpaqueStippledFillChooser = XAAOpaqueStippledFillChooser;
+
+ if (!infoRec->TiledFillChooser)
+ infoRec->TiledFillChooser = XAATiledFillChooser;
+
+ /**** Setup the pixmap cache ****/
+
+ if (infoRec->WriteBitmapToCache) {
+ }
+ else if (infoRec->WriteBitmap &&
+ !(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY))
+ infoRec->WriteBitmapToCache = XAAWriteBitmapToCache;
+ else if (infoRec->Flags & LINEAR_FRAMEBUFFER)
+ infoRec->WriteBitmapToCache = XAAWriteBitmapToCacheLinear;
+ else
+ infoRec->PixmapCacheFlags |= DO_NOT_BLIT_STIPPLES;
+
+ if (infoRec->WritePixmapToCache) {
+ }
+ else if (infoRec->WritePixmap && !(infoRec->WritePixmapFlags & NO_GXCOPY))
+ infoRec->WritePixmapToCache = XAAWritePixmapToCache;
+ else if (infoRec->Flags & LINEAR_FRAMEBUFFER)
+ infoRec->WritePixmapToCache = XAAWritePixmapToCacheLinear;
+ else
+ infoRec->Flags &= ~PIXMAP_CACHE;
+
+ if (xf86ReturnOptValBool(options, XAAOPT_PIXMAP_CACHE, FALSE))
+ infoRec->Flags &= ~PIXMAP_CACHE;
+
+ if (infoRec->WriteMono8x8PatternToCache) {
+ }
+ else if (infoRec->PixmapCacheFlags & CACHE_MONO_8x8) {
+ if (infoRec->WritePixmapToCache)
+ infoRec->WriteMono8x8PatternToCache = XAAWriteMono8x8PatternToCache;
+ else
+ infoRec->PixmapCacheFlags &= ~CACHE_MONO_8x8;
+ }
+
+ if (infoRec->WriteColor8x8PatternToCache) {
+ }
+ else if (infoRec->PixmapCacheFlags & CACHE_COLOR_8x8) {
+ if (infoRec->WritePixmapToCache && infoRec->WriteBitmapToCache)
+ infoRec->WriteColor8x8PatternToCache =
+ XAAWriteColor8x8PatternToCache;
+ else
+ infoRec->PixmapCacheFlags &= ~CACHE_COLOR_8x8;
+ }
+
+ if (infoRec->CachePixelGranularity < 0) {
+ switch (pScrn->bitsPerPixel) {
+ case 24:
+ case 8:
+ infoRec->CachePixelGranularity = 4;
+ break;
+ case 16:
+ infoRec->CachePixelGranularity = 2;
+ break;
+ case 32:
+ infoRec->CachePixelGranularity = 1;
+ break;
+ default:
+ break;
+ }
+
+ if (BITMAP_SCANLINE_PAD == 64)
+ infoRec->CachePixelGranularity *= 2;
+ }
+
+ free(options);
+
+ if (!infoRec->CacheTile && infoRec->WritePixmapToCache)
+ infoRec->CacheTile = XAACacheTile;
+ if (!infoRec->CacheMonoStipple && infoRec->WritePixmapToCache)
+ infoRec->CacheMonoStipple = XAACacheMonoStipple;
+ if (!infoRec->CacheStipple && infoRec->WriteBitmapToCache)
+ infoRec->CacheStipple = XAACacheStipple;
+ if (!infoRec->CacheMono8x8Pattern && infoRec->WriteMono8x8PatternToCache)
+ infoRec->CacheMono8x8Pattern = XAACacheMono8x8Pattern;
+ if (!infoRec->CacheColor8x8Pattern && infoRec->WriteColor8x8PatternToCache)
+ infoRec->CacheColor8x8Pattern = XAACacheColor8x8Pattern;
+
+ if ((infoRec->Flags & PIXMAP_CACHE) && !infoRec->InitPixmapCache) {
+ infoRec->InitPixmapCache = XAAInitPixmapCache;
+ infoRec->ClosePixmapCache = XAAClosePixmapCache;
+ }
+
+ return TRUE;
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaLine.c b/xorg-server/hw/xfree86/xaa/xaaLine.c
index d94f1f4e0..d7c60975e 100644
--- a/xorg-server/hw/xfree86/xaa/xaaLine.c
+++ b/xorg-server/hw/xfree86/xaa/xaaLine.c
@@ -1,394 +1,422 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <stdlib.h>
-
-#include <X11/X.h>
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "miline.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-
-
-void
-#ifdef POLYSEGMENT
-XAAPolySegment(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int nseg,
- xSegment *pSeg
-#else
-XAAPolyLines(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int mode, /* Origin or Previous */
- int npt, /* number of points */
- DDXPointPtr pptInit
-#endif
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- BoxPtr pboxInit = RegionRects(pGC->pCompositeClip);
- int nboxInit = RegionNumRects(pGC->pCompositeClip);
- unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
- int xorg = pDrawable->x;
- int yorg = pDrawable->y;
- int nbox;
- BoxPtr pbox;
-#ifndef POLYSEGMENT
- DDXPointPtr ppt;
-#endif
- int x1, x2, y1, y2, tmp, len;
-
- if(!nboxInit)
- return;
-
- if (infoRec->SolidLineFlags & LINE_LIMIT_COORDS) {
- int minValX = infoRec->SolidLineLimits.x1;
- int maxValX = infoRec->SolidLineLimits.x2;
- int minValY = infoRec->SolidLineLimits.y1;
- int maxValY = infoRec->SolidLineLimits.y2;
-#ifdef POLYSEGMENT
- int n = nseg;
- xSegment *s = pSeg;
-
- while (n--)
-#else
- int n = npt;
- int xorgtmp = xorg;
- int yorgtmp = yorg;
-
- ppt = pptInit;
- x2 = ppt->x + xorgtmp;
- y2 = ppt->y + yorgtmp;
- while (--n)
-#endif
- {
-#ifdef POLYSEGMENT
- x1 = s->x1 + xorg;
- y1 = s->y1 + yorg;
- x2 = s->x2 + xorg;
- y2 = s->y2 + yorg;
- s++;
-#else
- x1 = x2;
- y1 = y2;
- ++ppt;
- if (mode == CoordModePrevious) {
- xorgtmp = x1;
- yorgtmp = y1;
- }
- x2 = ppt->x + xorgtmp;
- y2 = ppt->y + yorgtmp;
-#endif
- if (x1 > maxValX || x1 < minValX ||
- x2 > maxValX || x2 < minValX ||
- y1 > maxValY || y1 < minValY ||
- y2 > maxValY || y2 < minValY) {
-#ifdef POLYSEGMENT
- XAAFallbackOps.PolySegment(pDrawable, pGC, nseg, pSeg);
-#else
- XAAFallbackOps.Polylines(pDrawable, pGC, mode, npt, pptInit);
-#endif
- return;
- }
- }
- }
-
- (*infoRec->SetupForSolidLine)(infoRec->pScrn, pGC->fgPixel,
- pGC->alu, pGC->planemask);
-
-#ifdef POLYSEGMENT
- while (nseg--)
-#else
- ppt = pptInit;
- x2 = ppt->x + xorg;
- y2 = ppt->y + yorg;
- while(--npt)
-#endif
- {
- nbox = nboxInit;
- pbox = pboxInit;
-
-#ifdef POLYSEGMENT
- x1 = pSeg->x1 + xorg;
- y1 = pSeg->y1 + yorg;
- x2 = pSeg->x2 + xorg;
- y2 = pSeg->y2 + yorg;
- pSeg++;
-#else
- x1 = x2;
- y1 = y2;
- ++ppt;
- if (mode == CoordModePrevious) {
- xorg = x1;
- yorg = y1;
- }
- x2 = ppt->x + xorg;
- y2 = ppt->y + yorg;
-#endif
-
- if (x1 == x2) { /* vertical line */
- /* make the line go top to bottom of screen, keeping
- endpoint semantics
- */
- if (y1 > y2) {
- tmp = y2;
- y2 = y1 + 1;
- y1 = tmp + 1;
-#ifdef POLYSEGMENT
- if (pGC->capStyle != CapNotLast) y1--;
-#endif
- }
-#ifdef POLYSEGMENT
- else if (pGC->capStyle != CapNotLast) y2++;
-#endif
- /* get to first band that might contain part of line */
- while(nbox && (pbox->y2 <= y1)) {
- pbox++;
- nbox--;
- }
-
- /* stop when lower edge of box is beyond end of line */
- while(nbox && (y2 >= pbox->y1)) {
- if ((x1 >= pbox->x1) && (x1 < pbox->x2)) {
- tmp = max(y1, pbox->y1);
- len = min(y2, pbox->y2) - tmp;
- if (len) (*infoRec->SubsequentSolidHorVertLine)(
- infoRec->pScrn, x1, tmp, len, DEGREES_270);
- }
- nbox--;
- pbox++;
- }
-#ifndef POLYSEGMENT
- y2 = ppt->y + yorg;
-#endif
- } else if (y1 == y2) { /* horizontal line */
- /* force line from left to right, keeping endpoint semantics */
- if (x1 > x2) {
- tmp = x2;
- x2 = x1 + 1;
- x1 = tmp + 1;
-#ifdef POLYSEGMENT
- if (pGC->capStyle != CapNotLast) x1--;
-#endif
- }
-#ifdef POLYSEGMENT
- else if (pGC->capStyle != CapNotLast) x2++;
-#endif
-
- /* find the correct band */
- while(nbox && (pbox->y2 <= y1)) {
- pbox++;
- nbox--;
- }
-
- /* try to draw the line, if we haven't gone beyond it */
- if (nbox && (pbox->y1 <= y1)) {
- int orig_y = pbox->y1;
- /* when we leave this band, we're done */
- while(nbox && (orig_y == pbox->y1)) {
- if (pbox->x2 <= x1) {
- /* skip boxes until one might contain start point */
- nbox--;
- pbox++;
- continue;
- }
-
- /* stop if left of box is beyond right of line */
- if (pbox->x1 >= x2) {
- nbox = 0;
- break;
- }
-
- tmp = max(x1, pbox->x1);
- len = min(x2, pbox->x2) - tmp;
- if (len) (*infoRec->SubsequentSolidHorVertLine)(
- infoRec->pScrn, tmp, y1, len, DEGREES_0);
- nbox--;
- pbox++;
- }
- }
-#ifndef POLYSEGMENT
- x2 = ppt->x + xorg;
-#endif
- } else{ /* sloped line */
- unsigned int oc1, oc2;
- int dmin, dmaj, e, octant;
-
- if (infoRec->SubsequentSolidBresenhamLine) {
- if((dmaj = x2 - x1) < 0) {
- dmaj = -dmaj;
- octant = XDECREASING;
- } else octant = 0;
-
- if((dmin = y2 - y1) < 0) {
- dmin = -dmin;
- octant |= YDECREASING;
- }
-
- if(dmin >= dmaj){
- tmp = dmin; dmin = dmaj; dmaj = tmp;
- octant |= YMAJOR;
- }
-
- e = -dmaj - ((bias >> octant) & 1);
- len = dmaj;
- dmin <<= 1;
- dmaj <<= 1;
- } else { /* Muffle compiler */
- dmin = dmaj = e = octant = len = 0;
- }
-
- while(nbox--) {
- oc1 = oc2 = 0;
- OUTCODES(oc1, x1, y1, pbox);
- OUTCODES(oc2, x2, y2, pbox);
- if (!(oc1 | oc2)) { /* unclipped */
- if(infoRec->SubsequentSolidTwoPointLine) {
- (*infoRec->SubsequentSolidTwoPointLine)(
- infoRec->pScrn, x1, y1, x2, y2,
-#ifdef POLYSEGMENT
- (pGC->capStyle != CapNotLast) ? 0 :
-#endif
- OMIT_LAST
- );
- } else {
- (*infoRec->SubsequentSolidBresenhamLine)(
- infoRec->pScrn, x1, y1, dmaj, dmin, e,
-#ifdef POLYSEGMENT
- (pGC->capStyle != CapNotLast) ? (len+1) :
-#endif
- len, octant);
- }
- break;
- } else if (oc1 & oc2) { /* completely clipped */
- pbox++;
- } else if (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_LINE) {
- (*infoRec->SetClippingRectangle)(infoRec->pScrn,
- pbox->x1, pbox->y1, pbox->x2 - 1, pbox->y2 - 1);
-
- if(infoRec->SubsequentSolidBresenhamLine) {
- (*infoRec->SubsequentSolidBresenhamLine)(
- infoRec->pScrn, x1, y1, dmaj, dmin, e,
-#ifdef POLYSEGMENT
- (pGC->capStyle != CapNotLast) ? (len+1) :
-#endif
- len, octant);
- } else {
- (*infoRec->SubsequentSolidTwoPointLine)(
- infoRec->pScrn, x1, y1, x2, y2,
-#ifdef POLYSEGMENT
- (pGC->capStyle != CapNotLast) ? 0 :
-#endif
- OMIT_LAST
- );
- }
- (*infoRec->DisableClipping)(infoRec->pScrn);
- pbox++;
- } else {
- int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
- int clip1 = 0, clip2 = 0;
- int err, adx, ady;
-
- if(octant & YMAJOR) {
- ady = dmaj >> 1;
- adx = dmin >> 1;
- } else {
- ady = dmin >> 1;
- adx = dmaj >> 1;
- }
-
- if (miZeroClipLine(pbox->x1, pbox->y1,
- pbox->x2 - 1, pbox->y2 - 1,
- &new_x1, &new_y1, &new_x2, &new_y2,
- adx, ady, &clip1, &clip2,
- octant, bias, oc1, oc2) == -1)
- {
- pbox++;
- continue;
- }
-
- if (octant & YMAJOR)
- len = abs(new_y2 - new_y1);
- else
- len = abs(new_x2 - new_x1);
-#ifdef POLYSEGMENT
- if (clip2 != 0 || pGC->capStyle != CapNotLast)
- len++;
-#else
- len += (clip2 != 0);
-#endif
- if (len) {
- int abserr, clipdx, clipdy;
- /* unwind bresenham error term to first point */
- if (clip1) {
- clipdx = abs(new_x1 - x1);
- clipdy = abs(new_y1 - y1);
-
- if (octant & YMAJOR)
- err = e + clipdy*dmin - clipdx*dmaj;
- else
- err = e + clipdx*dmin - clipdy*dmaj;
- } else
- err = e;
-
-#define range infoRec->SolidBresenhamLineErrorTermBits
- abserr = abs(err);
- while((abserr & range) ||
- (dmaj & range) ||
- (dmin & range)) {
- dmin >>= 1;
- dmaj >>= 1;
- abserr >>= 1;
- err /= 2;
- }
-
- (*infoRec->SubsequentSolidBresenhamLine)(
- infoRec->pScrn, new_x1, new_y1,
- dmaj, dmin, err, len, octant);
- }
- pbox++;
- }
- } /* while (nbox--) */
- } /* sloped line */
- } /* while (nline--) */
-
-#ifndef POLYSEGMENT
- /* paint the last point if the end style isn't CapNotLast.
- (Assume that a projecting, butt, or round cap that is one
- pixel wide is the same as the single pixel of the endpoint.)
- */
-
- if ((pGC->capStyle != CapNotLast) &&
- ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
- (ppt->y + yorg != pptInit->y + pDrawable->y) ||
- (ppt == pptInit + 1)))
- {
- nbox = nboxInit;
- pbox = pboxInit;
- while (nbox--)
- {
- if ((x2 >= pbox->x1) && (y2 >= pbox->y1) &&
- (x2 < pbox->x2) && (y2 < pbox->y2))
- {
- (*infoRec->SubsequentSolidHorVertLine)(
- infoRec->pScrn, x2, y2, 1, DEGREES_0);
- break;
- }
- else
- pbox++;
- }
- }
-#endif
-
- SET_SYNC_FLAG(infoRec);
-}
-
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include <X11/X.h>
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "miline.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+
+void
+#ifdef POLYSEGMENT
+ XAAPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pSeg
+#else
+XAAPolyLines(DrawablePtr pDrawable, GCPtr pGC, int mode, /* Origin or Previous */
+ int npt, /* number of points */
+ DDXPointPtr pptInit
+#endif
+ )
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ BoxPtr pboxInit = RegionRects(pGC->pCompositeClip);
+ int nboxInit = RegionNumRects(pGC->pCompositeClip);
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+ int xorg = pDrawable->x;
+ int yorg = pDrawable->y;
+ int nbox;
+ BoxPtr pbox;
+
+#ifndef POLYSEGMENT
+ DDXPointPtr ppt;
+#endif
+ int x1, x2, y1, y2, tmp, len;
+
+ if (!nboxInit)
+ return;
+
+ if (infoRec->SolidLineFlags & LINE_LIMIT_COORDS) {
+ int minValX = infoRec->SolidLineLimits.x1;
+ int maxValX = infoRec->SolidLineLimits.x2;
+ int minValY = infoRec->SolidLineLimits.y1;
+ int maxValY = infoRec->SolidLineLimits.y2;
+
+#ifdef POLYSEGMENT
+ int n = nseg;
+ xSegment *s = pSeg;
+
+ while (n--)
+#else
+ int n = npt;
+ int xorgtmp = xorg;
+ int yorgtmp = yorg;
+
+ ppt = pptInit;
+ x2 = ppt->x + xorgtmp;
+ y2 = ppt->y + yorgtmp;
+ while (--n)
+#endif
+ {
+#ifdef POLYSEGMENT
+ x1 = s->x1 + xorg;
+ y1 = s->y1 + yorg;
+ x2 = s->x2 + xorg;
+ y2 = s->y2 + yorg;
+ s++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious) {
+ xorgtmp = x1;
+ yorgtmp = y1;
+ }
+ x2 = ppt->x + xorgtmp;
+ y2 = ppt->y + yorgtmp;
+#endif
+ if (x1 > maxValX || x1 < minValX ||
+ x2 > maxValX || x2 < minValX ||
+ y1 > maxValY || y1 < minValY || y2 > maxValY || y2 < minValY) {
+#ifdef POLYSEGMENT
+ XAAFallbackOps.PolySegment(pDrawable, pGC, nseg, pSeg);
+#else
+ XAAFallbackOps.Polylines(pDrawable, pGC, mode, npt, pptInit);
+#endif
+ return;
+ }
+ }
+ }
+
+ (*infoRec->SetupForSolidLine) (infoRec->pScrn, pGC->fgPixel,
+ pGC->alu, pGC->planemask);
+
+#ifdef POLYSEGMENT
+ while (nseg--)
+#else
+ ppt = pptInit;
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+ while (--npt)
+#endif
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+
+#ifdef POLYSEGMENT
+ x1 = pSeg->x1 + xorg;
+ y1 = pSeg->y1 + yorg;
+ x2 = pSeg->x2 + xorg;
+ y2 = pSeg->y2 + yorg;
+ pSeg++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious) {
+ xorg = x1;
+ yorg = y1;
+ }
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+#endif
+
+ if (x1 == x2) { /* vertical line */
+ /* make the line go top to bottom of screen, keeping
+ endpoint semantics
+ */
+ if (y1 > y2) {
+ tmp = y2;
+ y2 = y1 + 1;
+ y1 = tmp + 1;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ y1--;
+#endif
+ }
+#ifdef POLYSEGMENT
+ else if (pGC->capStyle != CapNotLast)
+ y2++;
+#endif
+ /* get to first band that might contain part of line */
+ while (nbox && (pbox->y2 <= y1)) {
+ pbox++;
+ nbox--;
+ }
+
+ /* stop when lower edge of box is beyond end of line */
+ while (nbox && (y2 >= pbox->y1)) {
+ if ((x1 >= pbox->x1) && (x1 < pbox->x2)) {
+ tmp = max(y1, pbox->y1);
+ len = min(y2, pbox->y2) - tmp;
+ if (len)
+ (*infoRec->SubsequentSolidHorVertLine) (infoRec->pScrn,
+ x1, tmp, len,
+ DEGREES_270);
+ }
+ nbox--;
+ pbox++;
+ }
+#ifndef POLYSEGMENT
+ y2 = ppt->y + yorg;
+#endif
+ }
+ else if (y1 == y2) { /* horizontal line */
+ /* force line from left to right, keeping endpoint semantics */
+ if (x1 > x2) {
+ tmp = x2;
+ x2 = x1 + 1;
+ x1 = tmp + 1;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ x1--;
+#endif
+ }
+#ifdef POLYSEGMENT
+ else if (pGC->capStyle != CapNotLast)
+ x2++;
+#endif
+
+ /* find the correct band */
+ while (nbox && (pbox->y2 <= y1)) {
+ pbox++;
+ nbox--;
+ }
+
+ /* try to draw the line, if we haven't gone beyond it */
+ if (nbox && (pbox->y1 <= y1)) {
+ int orig_y = pbox->y1;
+
+ /* when we leave this band, we're done */
+ while (nbox && (orig_y == pbox->y1)) {
+ if (pbox->x2 <= x1) {
+ /* skip boxes until one might contain start point */
+ nbox--;
+ pbox++;
+ continue;
+ }
+
+ /* stop if left of box is beyond right of line */
+ if (pbox->x1 >= x2) {
+ nbox = 0;
+ break;
+ }
+
+ tmp = max(x1, pbox->x1);
+ len = min(x2, pbox->x2) - tmp;
+ if (len)
+ (*infoRec->SubsequentSolidHorVertLine) (infoRec->pScrn,
+ tmp, y1, len,
+ DEGREES_0);
+ nbox--;
+ pbox++;
+ }
+ }
+#ifndef POLYSEGMENT
+ x2 = ppt->x + xorg;
+#endif
+ }
+ else { /* sloped line */
+ unsigned int oc1, oc2;
+ int dmin, dmaj, e, octant;
+
+ if (infoRec->SubsequentSolidBresenhamLine) {
+ if ((dmaj = x2 - x1) < 0) {
+ dmaj = -dmaj;
+ octant = XDECREASING;
+ }
+ else
+ octant = 0;
+
+ if ((dmin = y2 - y1) < 0) {
+ dmin = -dmin;
+ octant |= YDECREASING;
+ }
+
+ if (dmin >= dmaj) {
+ tmp = dmin;
+ dmin = dmaj;
+ dmaj = tmp;
+ octant |= YMAJOR;
+ }
+
+ e = -dmaj - ((bias >> octant) & 1);
+ len = dmaj;
+ dmin <<= 1;
+ dmaj <<= 1;
+ }
+ else { /* Muffle compiler */
+ dmin = dmaj = e = octant = len = 0;
+ }
+
+ while (nbox--) {
+ oc1 = oc2 = 0;
+ OUTCODES(oc1, x1, y1, pbox);
+ OUTCODES(oc2, x2, y2, pbox);
+ if (!(oc1 | oc2)) { /* unclipped */
+ if (infoRec->SubsequentSolidTwoPointLine) {
+ (*infoRec->SubsequentSolidTwoPointLine) (infoRec->pScrn,
+ x1, y1, x2, y2,
+#ifdef POLYSEGMENT
+ (pGC->
+ capStyle !=
+ CapNotLast) ?
+ 0 :
+#endif
+ OMIT_LAST);
+ }
+ else {
+ (*infoRec->SubsequentSolidBresenhamLine) (infoRec->
+ pScrn, x1, y1,
+ dmaj, dmin, e,
+#ifdef POLYSEGMENT
+ (pGC->
+ capStyle !=
+ CapNotLast)
+ ? (len + 1) :
+#endif
+ len, octant);
+ }
+ break;
+ }
+ else if (oc1 & oc2) { /* completely clipped */
+ pbox++;
+ }
+ else if (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_LINE) {
+ (*infoRec->SetClippingRectangle) (infoRec->pScrn,
+ pbox->x1, pbox->y1,
+ pbox->x2 - 1,
+ pbox->y2 - 1);
+
+ if (infoRec->SubsequentSolidBresenhamLine) {
+ (*infoRec->SubsequentSolidBresenhamLine) (infoRec->
+ pScrn, x1, y1,
+ dmaj, dmin, e,
+#ifdef POLYSEGMENT
+ (pGC->
+ capStyle !=
+ CapNotLast)
+ ? (len + 1) :
+#endif
+ len, octant);
+ }
+ else {
+ (*infoRec->SubsequentSolidTwoPointLine) (infoRec->pScrn,
+ x1, y1, x2, y2,
+#ifdef POLYSEGMENT
+ (pGC->
+ capStyle !=
+ CapNotLast) ?
+ 0 :
+#endif
+ OMIT_LAST);
+ }
+ (*infoRec->DisableClipping) (infoRec->pScrn);
+ pbox++;
+ }
+ else {
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+ int clip1 = 0, clip2 = 0;
+ int err, adx, ady;
+
+ if (octant & YMAJOR) {
+ ady = dmaj >> 1;
+ adx = dmin >> 1;
+ }
+ else {
+ ady = dmin >> 1;
+ adx = dmaj >> 1;
+ }
+
+ if (miZeroClipLine(pbox->x1, pbox->y1,
+ pbox->x2 - 1, pbox->y2 - 1,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady, &clip1, &clip2,
+ octant, bias, oc1, oc2) == -1) {
+ pbox++;
+ continue;
+ }
+
+ if (octant & YMAJOR)
+ len = abs(new_y2 - new_y1);
+ else
+ len = abs(new_x2 - new_x1);
+#ifdef POLYSEGMENT
+ if (clip2 != 0 || pGC->capStyle != CapNotLast)
+ len++;
+#else
+ len += (clip2 != 0);
+#endif
+ if (len) {
+ int abserr, clipdx, clipdy;
+
+ /* unwind bresenham error term to first point */
+ if (clip1) {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+
+ if (octant & YMAJOR)
+ err = e + clipdy * dmin - clipdx * dmaj;
+ else
+ err = e + clipdx * dmin - clipdy * dmaj;
+ }
+ else
+ err = e;
+
+#define range infoRec->SolidBresenhamLineErrorTermBits
+ abserr = abs(err);
+ while ((abserr & range) ||
+ (dmaj & range) || (dmin & range)) {
+ dmin >>= 1;
+ dmaj >>= 1;
+ abserr >>= 1;
+ err /= 2;
+ }
+
+ (*infoRec->SubsequentSolidBresenhamLine) (infoRec->
+ pScrn, new_x1,
+ new_y1, dmaj,
+ dmin, err,
+ len, octant);
+ }
+ pbox++;
+ }
+ } /* while (nbox--) */
+ } /* sloped line */
+ } /* while (nline--) */
+
+#ifndef POLYSEGMENT
+ /* paint the last point if the end style isn't CapNotLast.
+ (Assume that a projecting, butt, or round cap that is one
+ pixel wide is the same as the single pixel of the endpoint.)
+ */
+
+ if ((pGC->capStyle != CapNotLast) &&
+ ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
+ (ppt->y + yorg != pptInit->y + pDrawable->y) ||
+ (ppt == pptInit + 1))) {
+ nbox = nboxInit;
+ pbox = pboxInit;
+ while (nbox--) {
+ if ((x2 >= pbox->x1) && (y2 >= pbox->y1) &&
+ (x2 < pbox->x2) && (y2 < pbox->y2)) {
+ (*infoRec->SubsequentSolidHorVertLine) (infoRec->pScrn, x2, y2,
+ 1, DEGREES_0);
+ break;
+ }
+ else
+ pbox++;
+ }
+ }
+#endif
+
+ SET_SYNC_FLAG(infoRec);
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaLineMisc.c b/xorg-server/hw/xfree86/xaa/xaaLineMisc.c
index 44048674e..4379778f6 100644
--- a/xorg-server/hw/xfree86/xaa/xaaLineMisc.c
+++ b/xorg-server/hw/xfree86/xaa/xaaLineMisc.c
@@ -1,150 +1,149 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "miline.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-
-
-void
-XAASolidHorVertLineAsRects(
- ScrnInfoPtr pScrn,
- int x, int y, int len, int dir
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
-
- if(dir == DEGREES_0)
- (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, len, 1);
- else
- (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, len);
-}
-
-
-void
-XAASolidHorVertLineAsTwoPoint(
- ScrnInfoPtr pScrn,
- int x, int y, int len, int dir
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
-
- len--;
-
- if(dir == DEGREES_0)
- (*infoRec->SubsequentSolidTwoPointLine)(pScrn, x, y, x + len, y, 0);
- else
- (*infoRec->SubsequentSolidTwoPointLine)(pScrn, x, y, x, y + len, 0);
-}
-
-void
-XAASolidHorVertLineAsBresenham(
- ScrnInfoPtr pScrn,
- int x, int y, int len, int dir
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
-
- if(dir == DEGREES_0)
- (*infoRec->SubsequentSolidBresenhamLine)(
- pScrn, x, y, len << 1, 0, -len, len, 0);
- else
- (*infoRec->SubsequentSolidBresenhamLine)(
- pScrn, x, y, len << 1, 0, -len, len, YMAJOR);
-}
-
-
-void
-XAAComputeDash(GCPtr pGC)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates,
- XAAGetGCKey());
- Bool EvenDash = (pGC->numInDashList & 0x01) ? FALSE : TRUE;
- int PatternLength = 0;
- unsigned char* DashPtr = (unsigned char*)pGC->dash;
- CARD32 *ptr;
- int count = pGC->numInDashList;
- int shift, value, direction;
- Bool set;
-
- free(pGCPriv->DashPattern);
-
- pGCPriv->DashPattern = NULL;
- pGCPriv->DashLength = 0;
-
- while(count--)
- PatternLength += *(DashPtr++);
-
- if(!EvenDash)
- PatternLength <<= 1;
-
- if(PatternLength > infoRec->DashPatternMaxLength)
- return;
-
- if((infoRec->DashedLineFlags & LINE_PATTERN_POWER_OF_2_ONLY) &&
- (PatternLength & (PatternLength - 1)))
- return;
-
- pGCPriv->DashPattern = calloc((PatternLength + 31) >> 5, 4);
- if(!pGCPriv->DashPattern) return;
- pGCPriv->DashLength = PatternLength;
-
- if(infoRec->DashedLineFlags & (LINE_PATTERN_LSBFIRST_MSBJUSTIFIED |
- LINE_PATTERN_LSBFIRST_LSBJUSTIFIED)) {
- direction = 1;
- set = TRUE;
- DashPtr = (unsigned char*)pGC->dash;
- } else {
- direction = -1;
- set = FALSE;
- DashPtr = (unsigned char*)pGC->dash + pGC->numInDashList - 1;
- }
-
- if(infoRec->DashedLineFlags & (LINE_PATTERN_LSBFIRST_MSBJUSTIFIED |
- LINE_PATTERN_MSBFIRST_MSBJUSTIFIED))
- shift = 32 - (PatternLength & 31);
- else
- shift = 0;
-
- ptr = (CARD32*)(pGCPriv->DashPattern);
-
-CONCATENATE:
-
- count = pGC->numInDashList;
-
- while(count--) {
- value = *DashPtr;
- DashPtr += direction;
- while(value) {
- if(value < (32 - shift)) {
- if(set) *ptr |= XAAShiftMasks[value] << shift;
- shift += value;
- break;
- } else {
- if(set) *ptr |= ~0L << shift;
- value -= (32 - shift);
- shift = 0;
- ptr++;
- }
- }
- if(set) set = FALSE;
- else set = TRUE;
- }
-
- if(!EvenDash) {
- EvenDash = TRUE;
- if(infoRec->DashedLineFlags & (LINE_PATTERN_LSBFIRST_MSBJUSTIFIED |
- LINE_PATTERN_LSBFIRST_LSBJUSTIFIED))
- DashPtr = (unsigned char*)pGC->dash;
- else
- DashPtr = (unsigned char*)pGC->dash + pGC->numInDashList;
- goto CONCATENATE;
- }
-}
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "miline.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+
+void
+XAASolidHorVertLineAsRects(ScrnInfoPtr pScrn, int x, int y, int len, int dir)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ if (dir == DEGREES_0)
+ (*infoRec->SubsequentSolidFillRect) (pScrn, x, y, len, 1);
+ else
+ (*infoRec->SubsequentSolidFillRect) (pScrn, x, y, 1, len);
+}
+
+void
+XAASolidHorVertLineAsTwoPoint(ScrnInfoPtr pScrn, int x, int y, int len, int dir)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ len--;
+
+ if (dir == DEGREES_0)
+ (*infoRec->SubsequentSolidTwoPointLine) (pScrn, x, y, x + len, y, 0);
+ else
+ (*infoRec->SubsequentSolidTwoPointLine) (pScrn, x, y, x, y + len, 0);
+}
+
+void
+XAASolidHorVertLineAsBresenham(ScrnInfoPtr pScrn,
+ int x, int y, int len, int dir)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ if (dir == DEGREES_0)
+ (*infoRec->SubsequentSolidBresenhamLine) (pScrn, x, y, len << 1, 0,
+ -len, len, 0);
+ else
+ (*infoRec->SubsequentSolidBresenhamLine) (pScrn, x, y, len << 1, 0,
+ -len, len, YMAJOR);
+}
+
+void
+XAAComputeDash(GCPtr pGC)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAAGCPtr pGCPriv = (XAAGCPtr) dixLookupPrivate(&pGC->devPrivates,
+ XAAGetGCKey());
+ Bool EvenDash = (pGC->numInDashList & 0x01) ? FALSE : TRUE;
+ int PatternLength = 0;
+ unsigned char *DashPtr = (unsigned char *) pGC->dash;
+ CARD32 *ptr;
+ int count = pGC->numInDashList;
+ int shift, value, direction;
+ Bool set;
+
+ free(pGCPriv->DashPattern);
+
+ pGCPriv->DashPattern = NULL;
+ pGCPriv->DashLength = 0;
+
+ while (count--)
+ PatternLength += *(DashPtr++);
+
+ if (!EvenDash)
+ PatternLength <<= 1;
+
+ if (PatternLength > infoRec->DashPatternMaxLength)
+ return;
+
+ if ((infoRec->DashedLineFlags & LINE_PATTERN_POWER_OF_2_ONLY) &&
+ (PatternLength & (PatternLength - 1)))
+ return;
+
+ pGCPriv->DashPattern = calloc((PatternLength + 31) >> 5, 4);
+ if (!pGCPriv->DashPattern)
+ return;
+ pGCPriv->DashLength = PatternLength;
+
+ if (infoRec->DashedLineFlags & (LINE_PATTERN_LSBFIRST_MSBJUSTIFIED |
+ LINE_PATTERN_LSBFIRST_LSBJUSTIFIED)) {
+ direction = 1;
+ set = TRUE;
+ DashPtr = (unsigned char *) pGC->dash;
+ }
+ else {
+ direction = -1;
+ set = FALSE;
+ DashPtr = (unsigned char *) pGC->dash + pGC->numInDashList - 1;
+ }
+
+ if (infoRec->DashedLineFlags & (LINE_PATTERN_LSBFIRST_MSBJUSTIFIED |
+ LINE_PATTERN_MSBFIRST_MSBJUSTIFIED))
+ shift = 32 - (PatternLength & 31);
+ else
+ shift = 0;
+
+ ptr = (CARD32 *) (pGCPriv->DashPattern);
+
+ CONCATENATE:
+
+ count = pGC->numInDashList;
+
+ while (count--) {
+ value = *DashPtr;
+ DashPtr += direction;
+ while (value) {
+ if (value < (32 - shift)) {
+ if (set)
+ *ptr |= XAAShiftMasks[value] << shift;
+ shift += value;
+ break;
+ }
+ else {
+ if (set)
+ *ptr |= ~0L << shift;
+ value -= (32 - shift);
+ shift = 0;
+ ptr++;
+ }
+ }
+ if (set)
+ set = FALSE;
+ else
+ set = TRUE;
+ }
+
+ if (!EvenDash) {
+ EvenDash = TRUE;
+ if (infoRec->DashedLineFlags & (LINE_PATTERN_LSBFIRST_MSBJUSTIFIED |
+ LINE_PATTERN_LSBFIRST_LSBJUSTIFIED))
+ DashPtr = (unsigned char *) pGC->dash;
+ else
+ DashPtr = (unsigned char *) pGC->dash + pGC->numInDashList;
+ goto CONCATENATE;
+ }
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaNonTEGlyph.c b/xorg-server/hw/xfree86/xaa/xaaNonTEGlyph.c
index 7431ba2a0..bfe7f9a09 100644
--- a/xorg-server/hw/xfree86/xaa/xaaNonTEGlyph.c
+++ b/xorg-server/hw/xfree86/xaa/xaaNonTEGlyph.c
@@ -1,5 +1,4 @@
-
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
@@ -39,52 +38,52 @@
void
#ifdef TRIPLE_BITS
-EXPNAME(XAANonTEGlyphRenderer3)(
+ EXPNAME(XAANonTEGlyphRenderer3) (
#else
-EXPNAME(XAANonTEGlyphRenderer)(
+ EXPNAME(XAANonTEGlyphRenderer) (
#endif
- ScrnInfoPtr pScrn,
- int xText, int wText,
- int y, int h, int skipleft, int startline,
- NonTEGlyphInfo *glyphp,
- int fg, int rop,
- unsigned int planemask )
-{
+ ScrnInfoPtr pScrn,
+ int xText, int wText,
+ int y, int h, int skipleft, int startline,
+ NonTEGlyphInfo * glyphp,
+ int fg, int rop, unsigned int planemask) {
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- CARD32* base = (CARD32*)infoRec->ColorExpandBase;
+ CARD32 *base = (CARD32 *) infoRec->ColorExpandBase;
+
#ifdef TRIPLE_BITS
int dwords = ((3 * wText + 31) >> 5) * h;
#else
int dwords = ((wText + 31) >> 5) * h;
#endif
- (*infoRec->SetupForCPUToScreenColorExpandFill)(
- pScrn, fg, -1, rop, planemask);
- (*infoRec->SubsequentCPUToScreenColorExpandFill)(
- pScrn, xText, y, wText, h, 0);
+ (*infoRec->SetupForCPUToScreenColorExpandFill) (pScrn, fg, -1, rop,
+ planemask);
+ (*infoRec->SubsequentCPUToScreenColorExpandFill) (pScrn, xText, y, wText, h,
+ 0);
#ifndef FIXEDBASE
#ifdef TRIPLE_BITS
- if((((3 * wText + 31) >> 5) * h) <= infoRec->ColorExpandRange)
+ if ((((3 * wText + 31) >> 5) * h) <= infoRec->ColorExpandRange)
#else
- if((((wText + 31) >> 5) * h) <= infoRec->ColorExpandRange)
+ if ((((wText + 31) >> 5) * h) <= infoRec->ColorExpandRange)
#endif
- while(h--)
- base = NonTEGlyphFunc(base, glyphp, startline++, wText, skipleft);
+ while (h--)
+ base = NonTEGlyphFunc(base, glyphp, startline++, wText, skipleft);
else
#endif
- while(h--)
- NonTEGlyphFunc(base, glyphp, startline++, wText, skipleft);
+ while (h--)
+ NonTEGlyphFunc(base, glyphp, startline++, wText, skipleft);
- if((infoRec->CPUToScreenColorExpandFillFlags & CPU_TRANSFER_PAD_QWORD) &&
- (dwords & 1)) {
- base = (CARD32*)infoRec->ColorExpandBase;
- base[0] = 0x00000000;
+ if ((infoRec->CPUToScreenColorExpandFillFlags & CPU_TRANSFER_PAD_QWORD) &&
+ (dwords & 1)) {
+ base = (CARD32 *) infoRec->ColorExpandBase;
+ base[0] = 0x00000000;
}
- if(infoRec->CPUToScreenColorExpandFillFlags & SYNC_AFTER_COLOR_EXPAND)
- (*infoRec->Sync)(pScrn);
- else SET_SYNC_FLAG(infoRec);
+ if (infoRec->CPUToScreenColorExpandFillFlags & SYNC_AFTER_COLOR_EXPAND)
+ (*infoRec->Sync) (pScrn);
+ else
+ SET_SYNC_FLAG(infoRec);
}
#ifndef FIXEDBASE
@@ -92,32 +91,31 @@ EXPNAME(XAANonTEGlyphRenderer)(
void
#ifdef TRIPLE_BITS
-EXPNAME(XAANonTEGlyphRendererScanline3)(
+ EXPNAME(XAANonTEGlyphRendererScanline3) (
#else
-EXPNAME(XAANonTEGlyphRendererScanline)(
+ EXPNAME(XAANonTEGlyphRendererScanline) (
#endif
- ScrnInfoPtr pScrn,
- int xText, int wText,
- int y, int h, int skipleft, int startline,
- NonTEGlyphInfo *glyphp,
- int fg, int rop,
- unsigned int planemask )
-{
+ ScrnInfoPtr pScrn,
+ int xText, int wText,
+ int y, int h, int skipleft,
+ int startline,
+ NonTEGlyphInfo * glyphp, int fg,
+ int rop, unsigned int planemask) {
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
int bufferNo = 0;
- CARD32* base;
-
- (*infoRec->SetupForScanlineCPUToScreenColorExpandFill)(
- pScrn, fg, -1, rop, planemask);
- (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)(
- pScrn, xText, y, wText, h, 0);
-
- while(h--) {
- base = (CARD32*)infoRec->ScanlineColorExpandBuffers[bufferNo];
- NonTEGlyphFunc(base, glyphp, startline++, wText, skipleft);
- (*infoRec->SubsequentColorExpandScanline)(pScrn, bufferNo++);
- if(bufferNo >= infoRec->NumScanlineColorExpandBuffers)
- bufferNo = 0;
+ CARD32 *base;
+
+ (*infoRec->SetupForScanlineCPUToScreenColorExpandFill) (pScrn, fg, -1, rop,
+ planemask);
+ (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill) (pScrn, xText, y,
+ wText, h, 0);
+
+ while (h--) {
+ base = (CARD32 *) infoRec->ScanlineColorExpandBuffers[bufferNo];
+ NonTEGlyphFunc(base, glyphp, startline++, wText, skipleft);
+ (*infoRec->SubsequentColorExpandScanline) (pScrn, bufferNo++);
+ if (bufferNo >= infoRec->NumScanlineColorExpandBuffers)
+ bufferNo = 0;
}
SET_SYNC_FLAG(infoRec);
@@ -131,70 +129,64 @@ EXPNAME(XAANonTEGlyphRendererScanline)(
********************************************************************/
-
-CARD32*
-NonTEGlyphFunc(
- CARD32 *base,
- NonTEGlyphInfo *glyphp,
- int line, int TotalWidth, int skipleft )
+CARD32 *
+NonTEGlyphFunc(CARD32 *base,
+ NonTEGlyphInfo * glyphp, int line, int TotalWidth, int skipleft)
{
CARD32 bits = 0;
- int shift = glyphp->width;
+ int shift = glyphp->width;
- if(skipleft) {
- if((line >= glyphp->firstline) && (line <= glyphp->lastline))
+ if (skipleft) {
+ if ((line >= glyphp->firstline) && (line <= glyphp->lastline))
bits = SHIFT_R(glyphp->bitsp[line], skipleft);
- shift -= skipleft;
- } else if((line >= glyphp->firstline) && (line <= glyphp->lastline))
- bits = glyphp->bitsp[line];
-
-
- while(TotalWidth > 32) {
- while(shift < 32) {
- glyphp++;
- if((line >= glyphp->firstline) && (line <= glyphp->lastline))
- bits |= SHIFT_L(glyphp->bitsp[line],shift);
- shift += glyphp->width;
- }
+ shift -= skipleft;
+ }
+ else if ((line >= glyphp->firstline) && (line <= glyphp->lastline))
+ bits = glyphp->bitsp[line];
+
+ while (TotalWidth > 32) {
+ while (shift < 32) {
+ glyphp++;
+ if ((line >= glyphp->firstline) && (line <= glyphp->lastline))
+ bits |= SHIFT_L(glyphp->bitsp[line], shift);
+ shift += glyphp->width;
+ }
#ifdef TRIPLE_BITS
- WRITE_BITS3(bits);
+ WRITE_BITS3(bits);
#else
- WRITE_BITS(bits);
+ WRITE_BITS(bits);
#endif
- shift &= 31;
- if(shift &&
- (line >= glyphp->firstline) && (line <= glyphp->lastline))
- bits = SHIFT_R(glyphp->bitsp[line], glyphp->width - shift);
- else bits = 0;
- TotalWidth -= 32;
+ shift &= 31;
+ if (shift && (line >= glyphp->firstline) && (line <= glyphp->lastline))
+ bits = SHIFT_R(glyphp->bitsp[line], glyphp->width - shift);
+ else
+ bits = 0;
+ TotalWidth -= 32;
}
- if(TotalWidth) {
- TotalWidth -= shift;
- while(TotalWidth > 0) {
- glyphp++;
- if((line >= glyphp->firstline) && (line <= glyphp->lastline))
- bits |= SHIFT_L(glyphp->bitsp[line], shift);
- shift += glyphp->width;
- TotalWidth -= glyphp->width;
- }
+ if (TotalWidth) {
+ TotalWidth -= shift;
+ while (TotalWidth > 0) {
+ glyphp++;
+ if ((line >= glyphp->firstline) && (line <= glyphp->lastline))
+ bits |= SHIFT_L(glyphp->bitsp[line], shift);
+ shift += glyphp->width;
+ TotalWidth -= glyphp->width;
+ }
#ifdef TRIPLE_BITS
- if (shift >= 22) {
- WRITE_BITS3(bits);
- } else if (shift >= 11) {
- WRITE_BITS2(bits);
- } else {
- WRITE_BITS1(bits);
- }
+ if (shift >= 22) {
+ WRITE_BITS3(bits);
+ }
+ else if (shift >= 11) {
+ WRITE_BITS2(bits);
+ }
+ else {
+ WRITE_BITS1(bits);
+ }
#else
- WRITE_BITS(bits);
+ WRITE_BITS(bits);
#endif
}
-
return base;
}
-
-
-
-
diff --git a/xorg-server/hw/xfree86/xaa/xaaNonTEText.c b/xorg-server/hw/xfree86/xaa/xaaNonTEText.c
index 519bda0e7..35b43912b 100644
--- a/xorg-server/hw/xfree86/xaa/xaaNonTEText.c
+++ b/xorg-server/hw/xfree86/xaa/xaaNonTEText.c
@@ -1,591 +1,591 @@
-
-/********************************************************************
-
- In this file we have GC level replacements for PolyText8/16,
- ImageText8/16, ImageGlyphBlt and PolyGlyphBlt for NonTE (proportional)
- fonts. The idea is that everything in this file is device independent.
- The mentioned GCOps are merely wrappers for the
- PolyGlyphBltNonTEColorExpansion and ImageGlyphBltNonTEColorExpansion
- functions which calculate the boxes containing arbitrarily clipped
- text and passes them to the NonTEGlyphRenderer which will usually
- be a lower level XAA function which renders these clipped glyphs using
- the basic color expansion functions exported by the chipset driver.
- The NonTEGlyphRenderer itself may optionally be driver supplied to
- facilitate work-arounds/optimizations at a higher level than usual.
-
- Written by Mark Vojkovich (mvojkovi@ucsd.edu)
-
-********************************************************************/
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <string.h>
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include <X11/fonts/font.h>
-#include "scrnintstr.h"
-#include "dixfontstr.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaacexp.h"
-#include "xaalocal.h"
-#include "gcstruct.h"
-#include "pixmapstr.h"
-
-
-static void ImageGlyphBltNonTEColorExpansion(ScrnInfoPtr pScrn,
- int xInit, int yInit, FontPtr font,
- int fg, int bg, unsigned planemask,
- RegionPtr cclip, int nglyph,
- unsigned char* gBase, CharInfoPtr *ppci);
-static int PolyGlyphBltNonTEColorExpansion(ScrnInfoPtr pScrn,
- int xInit, int yInit, FontPtr font,
- int fg, int rop, unsigned planemask,
- RegionPtr cclip, int nglyph,
- unsigned char* gBase, CharInfoPtr *ppci);
-
-/********************************************************************
-
- GC level replacements for PolyText8/16 and ImageText8/16
- for NonTE fonts when using color expansion.
-
-********************************************************************/
-
-
-int
-XAAPolyText8NonTEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- char *chars )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- unsigned long n;
- int width = 0;
-
- (*pGC->font->get_glyphs)(pGC->font, (unsigned long)count,
- (unsigned char *)chars, Linear8Bit, &n, infoRec->CharInfo);
-
- if(n) {
- width = PolyGlyphBltNonTEColorExpansion( infoRec->pScrn,
- x + pDraw->x, y + pDraw->y, pGC->font,
- pGC->fgPixel, pGC->alu, pGC->planemask,
- pGC->pCompositeClip, n, FONTGLYPHS(pGC->font),
- infoRec->CharInfo);
- }
-
- return x + width;
-}
-
-
-int
-XAAPolyText16NonTEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- unsigned short *chars )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- unsigned long n;
- int width = 0;
-
- (*pGC->font->get_glyphs)(
- pGC->font, (unsigned long)count, (unsigned char *)chars,
- (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
- &n, infoRec->CharInfo);
-
- if(n) {
- width = PolyGlyphBltNonTEColorExpansion( infoRec->pScrn,
- x + pDraw->x, y + pDraw->y, pGC->font,
- pGC->fgPixel, pGC->alu, pGC->planemask,
- pGC->pCompositeClip, n, FONTGLYPHS(pGC->font),
- infoRec->CharInfo);
- }
-
- return x + width;
-}
-
-
-void
-XAAImageText8NonTEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- char *chars
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- unsigned long n;
-
- if(!RegionNumRects(pGC->pCompositeClip))
- return;
-
- (*pGC->font->get_glyphs)(pGC->font, (unsigned long)count,
- (unsigned char *)chars, Linear8Bit, &n, infoRec->CharInfo);
-
- if(n) ImageGlyphBltNonTEColorExpansion(
- infoRec->pScrn, x + pDraw->x, y + pDraw->y,
- pGC->font, pGC->fgPixel, pGC->bgPixel, pGC->planemask,
- pGC->pCompositeClip, n, FONTGLYPHS(pGC->font), infoRec->CharInfo);
-}
-
-
-void
-XAAImageText16NonTEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- unsigned short *chars
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- unsigned long n;
-
- if(!RegionNumRects(pGC->pCompositeClip))
- return;
-
- (*pGC->font->get_glyphs)(
- pGC->font, (unsigned long)count, (unsigned char *)chars,
- (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
- &n, infoRec->CharInfo);
-
- if(n) ImageGlyphBltNonTEColorExpansion(
- infoRec->pScrn, x + pDraw->x, y + pDraw->y,
- pGC->font, pGC->fgPixel, pGC->bgPixel, pGC->planemask,
- pGC->pCompositeClip, n, FONTGLYPHS(pGC->font), infoRec->CharInfo);
-}
-
-
-
-/********************************************************************
-
- GC level replacements for ImageGlyphBlt and PolyGlyphBlt for
- NonTE fonts when using color expansion.
-
-********************************************************************/
-
-
-void
-XAAImageGlyphBltNonTEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci, /* array of character info */
- pointer pglyphBase /* start of array of glyphs */
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-
- if(!RegionNumRects(pGC->pCompositeClip))
- return;
-
- ImageGlyphBltNonTEColorExpansion(
- infoRec->pScrn, xInit + pDraw->x, yInit + pDraw->y,
- pGC->font, pGC->fgPixel, pGC->bgPixel, pGC->planemask,
- pGC->pCompositeClip, nglyph, (unsigned char*)pglyphBase, ppci);
-}
-
-void
-XAAPolyGlyphBltNonTEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci, /* array of character info */
- pointer pglyphBase /* start of array of glyphs */
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-
- if(!RegionNumRects(pGC->pCompositeClip))
- return;
-
- PolyGlyphBltNonTEColorExpansion(
- infoRec->pScrn, xInit + pDraw->x, yInit + pDraw->y,
- pGC->font, pGC->fgPixel, pGC->alu, pGC->planemask,
- pGC->pCompositeClip, nglyph, (unsigned char*)pglyphBase, ppci);
-}
-
-
-
-
-/********************************************************************
-
- ImageGlyphBltNonTEColorExpansion -
- PolyGlyphBltNonTEColorExpansion -
-
- These guys compute the clipped pieces of text and send it to
- the lower-level function which will handle acceleration of
- arbitrarily clipped text.
-
-********************************************************************/
-
-
-
-static int
-CollectCharacterInfo(
- NonTEGlyphPtr glyphs,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- FontPtr pfont
-){
- int i, w = 0;
-
- for(i = 0; i < nglyph; i++, ppci++, glyphs++) {
- glyphs->bits = (unsigned char*)((*ppci)->bits);
- glyphs->start = w + (*ppci)->metrics.leftSideBearing;
- glyphs->end = w + (*ppci)->metrics.rightSideBearing;
- glyphs->yoff = (*ppci)->metrics.ascent;
- glyphs->height = glyphs->yoff + (*ppci)->metrics.descent;
- glyphs->srcwidth = PADGLYPHWIDTHBYTES(glyphs->end - glyphs->start);
- w += (*ppci)->metrics.characterWidth;
- }
- return w;
-}
-
-
-static void
-PolyGlyphBltAsSingleBitmap (
- ScrnInfoPtr pScrn,
- int nglyph,
- FontPtr font,
- int xInit,
- int yInit,
- int nbox,
- BoxPtr pbox,
- int fg,
- int rop,
- unsigned planemask
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- CARD32 *block, *pntr, *bits;
- int pitch, topLine, botLine, top, bot, height;
- int Left, Right, Top, Bottom;
- int LeftEdge, RightEdge;
- int bitPitch, shift, size, i, skippix;
- NonTEGlyphPtr glyphs = infoRec->GlyphInfo;
- Bool extra;
-
- Left = xInit + infoRec->GlyphInfo[0].start;
- Right = xInit + infoRec->GlyphInfo[nglyph - 1].end;
- Top = yInit - FONTMAXBOUNDS(font,ascent);
- Bottom = yInit + FONTMAXBOUNDS(font,descent);
-
- /* get into the first band that may contain part of our string */
- while(nbox && (Top >= pbox->y2)) {
- pbox++; nbox--;
- }
-
- if(!nbox) return;
-
- pitch = (Right - Left + 31) >> 5;
- size = (pitch << 2) * (Bottom - Top);
- block = calloc(1, size);
-
- topLine = 10000; botLine = -10000;
-
- while(nglyph--) {
- top = -glyphs->yoff;
- bot = top + glyphs->height;
- if(top < topLine) topLine = top;
- if(bot > botLine) botLine = bot;
- skippix = glyphs->start - infoRec->GlyphInfo[0].start;
- bits = (CARD32*)glyphs->bits;
- bitPitch = glyphs->srcwidth >> 2;
- pntr = block + ((FONTMAXBOUNDS(font,ascent) + top) * pitch) +
- (skippix >> 5);
- shift = skippix & 31;
- extra = ((shift + glyphs->end - glyphs->start) > 32);
-
- for(i = top; i < bot; i++) {
- *pntr |= SHIFT_L(*bits, shift);
- if(extra)
- *(pntr + 1) |= SHIFT_R(*bits,32 - shift);
- pntr += pitch;
- bits += bitPitch;
- }
-
- glyphs++;
- }
-
- pntr = block + ((FONTMAXBOUNDS(font,ascent) + topLine) * pitch);
-
- Top = yInit + topLine;
- Bottom = yInit + botLine;
-
- while(nbox && (Top >= pbox->y2)) {
- pbox++; nbox--;
- }
-
- while(nbox && (Bottom > pbox->y1)) {
- LeftEdge = max(Left, pbox->x1);
- RightEdge = min(Right, pbox->x2);
-
- if(RightEdge > LeftEdge) {
- skippix = LeftEdge - Left;
- topLine = max(Top, pbox->y1);
- botLine = min(Bottom, pbox->y2);
- height = botLine - topLine;
-
- if(height > 0)
- (*infoRec->WriteBitmap)(pScrn, LeftEdge, topLine,
- RightEdge - LeftEdge, height,
- (unsigned char*)(pntr + ((topLine - Top) * pitch) +
- (skippix >> 5)),
- pitch << 2, skippix & 31, fg, -1, rop, planemask);
- }
-
- nbox--; pbox++;
- }
-
- free(block);
-}
-
-static void
-ImageGlyphBltNonTEColorExpansion(
- ScrnInfoPtr pScrn,
- int xInit, int yInit,
- FontPtr font,
- int fg, int bg,
- unsigned planemask,
- RegionPtr cclip,
- int nglyph,
- unsigned char* gBase,
- CharInfoPtr *ppci
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int skippix, skipglyph, width, n, i;
- int Left, Right, Top, Bottom;
- int LeftEdge, RightEdge, ytop, ybot;
- int nbox = RegionNumRects(cclip);
- BoxPtr pbox = RegionRects(cclip);
- Bool AlreadySetup = FALSE;
-
- width = CollectCharacterInfo(infoRec->GlyphInfo, nglyph, ppci, font);
-
- /* find our backing rectangle dimensions */
- Left = xInit;
- Right = Left + width;
- Top = yInit - FONTASCENT(font);
- Bottom = yInit + FONTDESCENT(font);
-
- /* get into the first band that may contain part of our box */
- while(nbox && (Top >= pbox->y2)) {
- pbox++; nbox--;
- }
-
- while(nbox && (Bottom >= pbox->y1)) {
- /* handle backing rect first */
- LeftEdge = max(Left, pbox->x1);
- RightEdge = min(Right, pbox->x2);
- if(RightEdge > LeftEdge) {
- ytop = max(Top, pbox->y1);
- ybot = min(Bottom, pbox->y2);
-
- if(ybot > ytop) {
- if(!AlreadySetup) {
- (*infoRec->SetupForSolidFill)(pScrn, bg, GXcopy, planemask);
- AlreadySetup = TRUE;
- }
- (*infoRec->SubsequentSolidFillRect)(pScrn,
- LeftEdge, ytop, RightEdge - LeftEdge, ybot - ytop);
- }
- }
- nbox--; pbox++;
- }
-
- nbox = RegionNumRects(cclip);
- pbox = RegionRects(cclip);
-
- if(infoRec->WriteBitmap && (nglyph > 1) &&
- ((FONTMAXBOUNDS(font, rightSideBearing) -
- FONTMINBOUNDS(font, leftSideBearing)) <= 32))
- {
- PolyGlyphBltAsSingleBitmap(pScrn, nglyph, font,
- xInit, yInit, nbox, pbox,
- fg, GXcopy, planemask);
-
- return;
- }
-
- /* compute an approximate but covering bounding box */
- Left = xInit + infoRec->GlyphInfo[0].start;
- Right = xInit + infoRec->GlyphInfo[nglyph - 1].end;
- Top = yInit - FONTMAXBOUNDS(font,ascent);
- Bottom = yInit + FONTMAXBOUNDS(font,descent);
-
- /* get into the first band that may contain part of our box */
- while(nbox && (Top >= pbox->y2)) {
- pbox++; nbox--;
- }
-
- /* stop when the lower edge of the box is beyond our string */
- while(nbox && (Bottom >= pbox->y1)) {
- LeftEdge = max(Left, pbox->x1);
- RightEdge = min(Right, pbox->x2);
-
- if(RightEdge > LeftEdge) { /* we're possibly drawing something */
- ytop = max(Top, pbox->y1);
- ybot = min(Bottom, pbox->y2);
- if(ybot > ytop) {
- skippix = LeftEdge - xInit;
- skipglyph = 0;
- while(skippix >= infoRec->GlyphInfo[skipglyph].end)
- skipglyph++;
-
- skippix = RightEdge - xInit;
- n = 0; i = skipglyph;
- while((i < nglyph) && (skippix > infoRec->GlyphInfo[i].start)) {
- i++; n++;
- }
-
- if(n) (*infoRec->NonTEGlyphRenderer)(pScrn,
- xInit, yInit, n, infoRec->GlyphInfo + skipglyph,
- pbox, fg, GXcopy, planemask);
- }
- }
-
- nbox--; pbox++;
- }
-}
-
-
-static int
-PolyGlyphBltNonTEColorExpansion(
- ScrnInfoPtr pScrn,
- int xInit, int yInit,
- FontPtr font,
- int fg, int rop,
- unsigned planemask,
- RegionPtr cclip,
- int nglyph,
- unsigned char* gBase,
- CharInfoPtr *ppci
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int skippix, skipglyph, width, n, i;
- int Left, Right, Top, Bottom;
- int LeftEdge, RightEdge;
- int nbox = RegionNumRects(cclip);
- BoxPtr pbox = RegionRects(cclip);
-
- width = CollectCharacterInfo(infoRec->GlyphInfo, nglyph, ppci, font);
-
- if(!nbox)
- return width;
-
- if((infoRec->WriteBitmap) && (rop == GXcopy) && (nglyph > 1) &&
- ((FONTMAXBOUNDS(font, rightSideBearing) -
- FONTMINBOUNDS(font, leftSideBearing)) <= 32)) {
-
- PolyGlyphBltAsSingleBitmap(pScrn, nglyph, font,
- xInit, yInit, nbox, pbox,
- fg, rop, planemask);
-
- return width;
- }
-
- /* compute an approximate but covering bounding box */
- Left = xInit + infoRec->GlyphInfo[0].start;
- Right = xInit + infoRec->GlyphInfo[nglyph - 1].end;
- Top = yInit - FONTMAXBOUNDS(font,ascent);
- Bottom = yInit + FONTMAXBOUNDS(font,descent);
-
- /* get into the first band that may contain part of our string */
- while(nbox && (Top >= pbox->y2)) {
- pbox++; nbox--;
- }
-
- /* stop when the lower edge of the box is beyond our string */
- while(nbox && (Bottom >= pbox->y1)) {
- LeftEdge = max(Left, pbox->x1);
- RightEdge = min(Right, pbox->x2);
-
- if(RightEdge > LeftEdge) { /* we're possibly drawing something */
-
- skippix = LeftEdge - xInit;
- skipglyph = 0;
- while(skippix >= infoRec->GlyphInfo[skipglyph].end)
- skipglyph++;
-
- skippix = RightEdge - xInit;
- n = 0; i = skipglyph;
- while((i < nglyph) && (skippix > infoRec->GlyphInfo[i].start)) {
- i++; n++;
- }
-
- if(n) (*infoRec->NonTEGlyphRenderer)(pScrn,
- xInit, yInit, n, infoRec->GlyphInfo + skipglyph,
- pbox, fg, rop, planemask);
- }
-
- nbox--; pbox++;
- }
- return width;
-}
-
-
-/* It is possible that the none of the glyphs passed to the
- NonTEGlyphRenderer will be drawn. This function being called
- indicates that part of the text string's bounding box is visible
- but not necessarily that any of the characters are visible */
-
-void XAANonTEGlyphRenderer(
- ScrnInfoPtr pScrn,
- int x, int y, int n,
- NonTEGlyphPtr glyphs,
- BoxPtr pbox,
- int fg, int rop,
- unsigned int planemask
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int x1, x2, y1, y2, i, w, h, skipleft, skiptop;
- unsigned char *src;
-
- for(i = 0; i < n; i++, glyphs++) {
- x1 = x + glyphs->start;
- x2 = x + glyphs->end;
- y1 = y - glyphs->yoff;
- y2 = y1 + glyphs->height;
-
- if(y1 < pbox->y1) {
- skiptop = pbox->y1 - y1;
- y1 = pbox->y1;
- } else skiptop = 0;
- if(y2 > pbox->y2) y2 = pbox->y2;
- h = y2 - y1;
- if(h <= 0) continue;
-
- if(x1 < pbox->x1) {
- skipleft = pbox->x1 - x1;
- x1 = pbox->x1;
- } else skipleft = 0;
- if(x2 > pbox->x2) x2 = pbox->x2;
-
- w = x2 - x1;
-
- if(w > 0) {
- src = glyphs->bits + (skiptop * glyphs->srcwidth);
-
- if(skipleft) {
- src += (skipleft >> 5) << 2;
- skipleft &= 31;
- }
-
- (*infoRec->WriteBitmap)(pScrn, x1, y1, w, h, src,
- glyphs->srcwidth, skipleft, fg, -1, rop, planemask);
- }
- }
-
-}
+
+/********************************************************************
+
+ In this file we have GC level replacements for PolyText8/16,
+ ImageText8/16, ImageGlyphBlt and PolyGlyphBlt for NonTE (proportional)
+ fonts. The idea is that everything in this file is device independent.
+ The mentioned GCOps are merely wrappers for the
+ PolyGlyphBltNonTEColorExpansion and ImageGlyphBltNonTEColorExpansion
+ functions which calculate the boxes containing arbitrarily clipped
+ text and passes them to the NonTEGlyphRenderer which will usually
+ be a lower level XAA function which renders these clipped glyphs using
+ the basic color expansion functions exported by the chipset driver.
+ The NonTEGlyphRenderer itself may optionally be driver supplied to
+ facilitate work-arounds/optimizations at a higher level than usual.
+
+ Written by Mark Vojkovich (mvojkovi@ucsd.edu)
+
+********************************************************************/
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <string.h>
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include <X11/fonts/font.h>
+#include "scrnintstr.h"
+#include "dixfontstr.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaacexp.h"
+#include "xaalocal.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+
+static void ImageGlyphBltNonTEColorExpansion(ScrnInfoPtr pScrn,
+ int xInit, int yInit, FontPtr font,
+ int fg, int bg, unsigned planemask,
+ RegionPtr cclip, int nglyph,
+ unsigned char *gBase,
+ CharInfoPtr * ppci);
+static int PolyGlyphBltNonTEColorExpansion(ScrnInfoPtr pScrn, int xInit,
+ int yInit, FontPtr font, int fg,
+ int rop, unsigned planemask,
+ RegionPtr cclip, int nglyph,
+ unsigned char *gBase,
+ CharInfoPtr * ppci);
+
+/********************************************************************
+
+ GC level replacements for PolyText8/16 and ImageText8/16
+ for NonTE fonts when using color expansion.
+
+********************************************************************/
+
+int
+XAAPolyText8NonTEColorExpansion(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ unsigned long n;
+ int width = 0;
+
+ (*pGC->font->get_glyphs) (pGC->font, (unsigned long) count,
+ (unsigned char *) chars, Linear8Bit, &n,
+ infoRec->CharInfo);
+
+ if (n) {
+ width = PolyGlyphBltNonTEColorExpansion(infoRec->pScrn,
+ x + pDraw->x, y + pDraw->y,
+ pGC->font, pGC->fgPixel,
+ pGC->alu, pGC->planemask,
+ pGC->pCompositeClip, n,
+ FONTGLYPHS(pGC->font),
+ infoRec->CharInfo);
+ }
+
+ return x + width;
+}
+
+int
+XAAPolyText16NonTEColorExpansion(DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y, int count, unsigned short *chars)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ unsigned long n;
+ int width = 0;
+
+ (*pGC->font->get_glyphs) (pGC->font, (unsigned long) count,
+ (unsigned char *) chars,
+ (FONTLASTROW(pGC->font) ==
+ 0) ? Linear16Bit : TwoD16Bit, &n,
+ infoRec->CharInfo);
+
+ if (n) {
+ width = PolyGlyphBltNonTEColorExpansion(infoRec->pScrn,
+ x + pDraw->x, y + pDraw->y,
+ pGC->font, pGC->fgPixel,
+ pGC->alu, pGC->planemask,
+ pGC->pCompositeClip, n,
+ FONTGLYPHS(pGC->font),
+ infoRec->CharInfo);
+ }
+
+ return x + width;
+}
+
+void
+XAAImageText8NonTEColorExpansion(DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y, int count, char *chars)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ unsigned long n;
+
+ if (!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ (*pGC->font->get_glyphs) (pGC->font, (unsigned long) count,
+ (unsigned char *) chars, Linear8Bit, &n,
+ infoRec->CharInfo);
+
+ if (n)
+ ImageGlyphBltNonTEColorExpansion(infoRec->pScrn, x + pDraw->x,
+ y + pDraw->y, pGC->font, pGC->fgPixel,
+ pGC->bgPixel, pGC->planemask,
+ pGC->pCompositeClip, n,
+ FONTGLYPHS(pGC->font),
+ infoRec->CharInfo);
+}
+
+void
+XAAImageText16NonTEColorExpansion(DrawablePtr pDraw,
+ GCPtr pGC,
+ int x,
+ int y, int count, unsigned short *chars)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ unsigned long n;
+
+ if (!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ (*pGC->font->get_glyphs) (pGC->font, (unsigned long) count,
+ (unsigned char *) chars,
+ (FONTLASTROW(pGC->font) ==
+ 0) ? Linear16Bit : TwoD16Bit, &n,
+ infoRec->CharInfo);
+
+ if (n)
+ ImageGlyphBltNonTEColorExpansion(infoRec->pScrn, x + pDraw->x,
+ y + pDraw->y, pGC->font, pGC->fgPixel,
+ pGC->bgPixel, pGC->planemask,
+ pGC->pCompositeClip, n,
+ FONTGLYPHS(pGC->font),
+ infoRec->CharInfo);
+}
+
+/********************************************************************
+
+ GC level replacements for ImageGlyphBlt and PolyGlyphBlt for
+ NonTE fonts when using color expansion.
+
+********************************************************************/
+
+void
+XAAImageGlyphBltNonTEColorExpansion(DrawablePtr pDraw, GCPtr pGC, int xInit, int yInit, unsigned int nglyph, CharInfoPtr * ppci, /* array of character info */
+ pointer pglyphBase /* start of array of glyphs */
+ )
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
+ if (!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ ImageGlyphBltNonTEColorExpansion(infoRec->pScrn, xInit + pDraw->x,
+ yInit + pDraw->y, pGC->font, pGC->fgPixel,
+ pGC->bgPixel, pGC->planemask,
+ pGC->pCompositeClip, nglyph,
+ (unsigned char *) pglyphBase, ppci);
+}
+
+void
+XAAPolyGlyphBltNonTEColorExpansion(DrawablePtr pDraw, GCPtr pGC, int xInit, int yInit, unsigned int nglyph, CharInfoPtr * ppci, /* array of character info */
+ pointer pglyphBase /* start of array of glyphs */
+ )
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
+ if (!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ PolyGlyphBltNonTEColorExpansion(infoRec->pScrn, xInit + pDraw->x,
+ yInit + pDraw->y, pGC->font, pGC->fgPixel,
+ pGC->alu, pGC->planemask,
+ pGC->pCompositeClip, nglyph,
+ (unsigned char *) pglyphBase, ppci);
+}
+
+/********************************************************************
+
+ ImageGlyphBltNonTEColorExpansion -
+ PolyGlyphBltNonTEColorExpansion -
+
+ These guys compute the clipped pieces of text and send it to
+ the lower-level function which will handle acceleration of
+ arbitrarily clipped text.
+
+********************************************************************/
+
+static int
+CollectCharacterInfo(NonTEGlyphPtr glyphs,
+ unsigned int nglyph, CharInfoPtr * ppci, FontPtr pfont)
+{
+ int i, w = 0;
+
+ for (i = 0; i < nglyph; i++, ppci++, glyphs++) {
+ glyphs->bits = (unsigned char *) ((*ppci)->bits);
+ glyphs->start = w + (*ppci)->metrics.leftSideBearing;
+ glyphs->end = w + (*ppci)->metrics.rightSideBearing;
+ glyphs->yoff = (*ppci)->metrics.ascent;
+ glyphs->height = glyphs->yoff + (*ppci)->metrics.descent;
+ glyphs->srcwidth = PADGLYPHWIDTHBYTES(glyphs->end - glyphs->start);
+ w += (*ppci)->metrics.characterWidth;
+ }
+ return w;
+}
+
+static void
+PolyGlyphBltAsSingleBitmap(ScrnInfoPtr pScrn,
+ int nglyph,
+ FontPtr font,
+ int xInit,
+ int yInit,
+ int nbox,
+ BoxPtr pbox, int fg, int rop, unsigned planemask)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ CARD32 *block, *pntr, *bits;
+ int pitch, topLine, botLine, top, bot, height;
+ int Left, Right, Top, Bottom;
+ int LeftEdge, RightEdge;
+ int bitPitch, shift, size, i, skippix;
+ NonTEGlyphPtr glyphs = infoRec->GlyphInfo;
+ Bool extra;
+
+ Left = xInit + infoRec->GlyphInfo[0].start;
+ Right = xInit + infoRec->GlyphInfo[nglyph - 1].end;
+ Top = yInit - FONTMAXBOUNDS(font, ascent);
+ Bottom = yInit + FONTMAXBOUNDS(font, descent);
+
+ /* get into the first band that may contain part of our string */
+ while (nbox && (Top >= pbox->y2)) {
+ pbox++;
+ nbox--;
+ }
+
+ if (!nbox)
+ return;
+
+ pitch = (Right - Left + 31) >> 5;
+ size = (pitch << 2) * (Bottom - Top);
+ block = calloc(1, size);
+
+ topLine = 10000;
+ botLine = -10000;
+
+ while (nglyph--) {
+ top = -glyphs->yoff;
+ bot = top + glyphs->height;
+ if (top < topLine)
+ topLine = top;
+ if (bot > botLine)
+ botLine = bot;
+ skippix = glyphs->start - infoRec->GlyphInfo[0].start;
+ bits = (CARD32 *) glyphs->bits;
+ bitPitch = glyphs->srcwidth >> 2;
+ pntr = block + ((FONTMAXBOUNDS(font, ascent) + top) * pitch) +
+ (skippix >> 5);
+ shift = skippix & 31;
+ extra = ((shift + glyphs->end - glyphs->start) > 32);
+
+ for (i = top; i < bot; i++) {
+ *pntr |= SHIFT_L(*bits, shift);
+ if (extra)
+ *(pntr + 1) |= SHIFT_R(*bits, 32 - shift);
+ pntr += pitch;
+ bits += bitPitch;
+ }
+
+ glyphs++;
+ }
+
+ pntr = block + ((FONTMAXBOUNDS(font, ascent) + topLine) * pitch);
+
+ Top = yInit + topLine;
+ Bottom = yInit + botLine;
+
+ while (nbox && (Top >= pbox->y2)) {
+ pbox++;
+ nbox--;
+ }
+
+ while (nbox && (Bottom > pbox->y1)) {
+ LeftEdge = max(Left, pbox->x1);
+ RightEdge = min(Right, pbox->x2);
+
+ if (RightEdge > LeftEdge) {
+ skippix = LeftEdge - Left;
+ topLine = max(Top, pbox->y1);
+ botLine = min(Bottom, pbox->y2);
+ height = botLine - topLine;
+
+ if (height > 0)
+ (*infoRec->WriteBitmap) (pScrn, LeftEdge, topLine,
+ RightEdge - LeftEdge, height,
+ (unsigned char *) (pntr +
+ ((topLine -
+ Top) * pitch) +
+ (skippix >> 5)),
+ pitch << 2, skippix & 31, fg, -1, rop,
+ planemask);
+ }
+
+ nbox--;
+ pbox++;
+ }
+
+ free(block);
+}
+
+static void
+ImageGlyphBltNonTEColorExpansion(ScrnInfoPtr pScrn,
+ int xInit, int yInit,
+ FontPtr font,
+ int fg, int bg,
+ unsigned planemask,
+ RegionPtr cclip,
+ int nglyph,
+ unsigned char *gBase, CharInfoPtr * ppci)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int skippix, skipglyph, width, n, i;
+ int Left, Right, Top, Bottom;
+ int LeftEdge, RightEdge, ytop, ybot;
+ int nbox = RegionNumRects(cclip);
+ BoxPtr pbox = RegionRects(cclip);
+ Bool AlreadySetup = FALSE;
+
+ width = CollectCharacterInfo(infoRec->GlyphInfo, nglyph, ppci, font);
+
+ /* find our backing rectangle dimensions */
+ Left = xInit;
+ Right = Left + width;
+ Top = yInit - FONTASCENT(font);
+ Bottom = yInit + FONTDESCENT(font);
+
+ /* get into the first band that may contain part of our box */
+ while (nbox && (Top >= pbox->y2)) {
+ pbox++;
+ nbox--;
+ }
+
+ while (nbox && (Bottom >= pbox->y1)) {
+ /* handle backing rect first */
+ LeftEdge = max(Left, pbox->x1);
+ RightEdge = min(Right, pbox->x2);
+ if (RightEdge > LeftEdge) {
+ ytop = max(Top, pbox->y1);
+ ybot = min(Bottom, pbox->y2);
+
+ if (ybot > ytop) {
+ if (!AlreadySetup) {
+ (*infoRec->SetupForSolidFill) (pScrn, bg, GXcopy,
+ planemask);
+ AlreadySetup = TRUE;
+ }
+ (*infoRec->SubsequentSolidFillRect) (pScrn,
+ LeftEdge, ytop,
+ RightEdge - LeftEdge,
+ ybot - ytop);
+ }
+ }
+ nbox--;
+ pbox++;
+ }
+
+ nbox = RegionNumRects(cclip);
+ pbox = RegionRects(cclip);
+
+ if (infoRec->WriteBitmap && (nglyph > 1) &&
+ ((FONTMAXBOUNDS(font, rightSideBearing) -
+ FONTMINBOUNDS(font, leftSideBearing)) <= 32)) {
+ PolyGlyphBltAsSingleBitmap(pScrn, nglyph, font,
+ xInit, yInit, nbox, pbox,
+ fg, GXcopy, planemask);
+
+ return;
+ }
+
+ /* compute an approximate but covering bounding box */
+ Left = xInit + infoRec->GlyphInfo[0].start;
+ Right = xInit + infoRec->GlyphInfo[nglyph - 1].end;
+ Top = yInit - FONTMAXBOUNDS(font, ascent);
+ Bottom = yInit + FONTMAXBOUNDS(font, descent);
+
+ /* get into the first band that may contain part of our box */
+ while (nbox && (Top >= pbox->y2)) {
+ pbox++;
+ nbox--;
+ }
+
+ /* stop when the lower edge of the box is beyond our string */
+ while (nbox && (Bottom >= pbox->y1)) {
+ LeftEdge = max(Left, pbox->x1);
+ RightEdge = min(Right, pbox->x2);
+
+ if (RightEdge > LeftEdge) { /* we're possibly drawing something */
+ ytop = max(Top, pbox->y1);
+ ybot = min(Bottom, pbox->y2);
+ if (ybot > ytop) {
+ skippix = LeftEdge - xInit;
+ skipglyph = 0;
+ while (skippix >= infoRec->GlyphInfo[skipglyph].end)
+ skipglyph++;
+
+ skippix = RightEdge - xInit;
+ n = 0;
+ i = skipglyph;
+ while ((i < nglyph) && (skippix > infoRec->GlyphInfo[i].start)) {
+ i++;
+ n++;
+ }
+
+ if (n)
+ (*infoRec->NonTEGlyphRenderer) (pScrn,
+ xInit, yInit, n,
+ infoRec->GlyphInfo +
+ skipglyph, pbox, fg, GXcopy,
+ planemask);
+ }
+ }
+
+ nbox--;
+ pbox++;
+ }
+}
+
+static int
+PolyGlyphBltNonTEColorExpansion(ScrnInfoPtr pScrn,
+ int xInit, int yInit,
+ FontPtr font,
+ int fg, int rop,
+ unsigned planemask,
+ RegionPtr cclip,
+ int nglyph,
+ unsigned char *gBase, CharInfoPtr * ppci)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int skippix, skipglyph, width, n, i;
+ int Left, Right, Top, Bottom;
+ int LeftEdge, RightEdge;
+ int nbox = RegionNumRects(cclip);
+ BoxPtr pbox = RegionRects(cclip);
+
+ width = CollectCharacterInfo(infoRec->GlyphInfo, nglyph, ppci, font);
+
+ if (!nbox)
+ return width;
+
+ if ((infoRec->WriteBitmap) && (rop == GXcopy) && (nglyph > 1) &&
+ ((FONTMAXBOUNDS(font, rightSideBearing) -
+ FONTMINBOUNDS(font, leftSideBearing)) <= 32)) {
+
+ PolyGlyphBltAsSingleBitmap(pScrn, nglyph, font,
+ xInit, yInit, nbox, pbox,
+ fg, rop, planemask);
+
+ return width;
+ }
+
+ /* compute an approximate but covering bounding box */
+ Left = xInit + infoRec->GlyphInfo[0].start;
+ Right = xInit + infoRec->GlyphInfo[nglyph - 1].end;
+ Top = yInit - FONTMAXBOUNDS(font, ascent);
+ Bottom = yInit + FONTMAXBOUNDS(font, descent);
+
+ /* get into the first band that may contain part of our string */
+ while (nbox && (Top >= pbox->y2)) {
+ pbox++;
+ nbox--;
+ }
+
+ /* stop when the lower edge of the box is beyond our string */
+ while (nbox && (Bottom >= pbox->y1)) {
+ LeftEdge = max(Left, pbox->x1);
+ RightEdge = min(Right, pbox->x2);
+
+ if (RightEdge > LeftEdge) { /* we're possibly drawing something */
+
+ skippix = LeftEdge - xInit;
+ skipglyph = 0;
+ while (skippix >= infoRec->GlyphInfo[skipglyph].end)
+ skipglyph++;
+
+ skippix = RightEdge - xInit;
+ n = 0;
+ i = skipglyph;
+ while ((i < nglyph) && (skippix > infoRec->GlyphInfo[i].start)) {
+ i++;
+ n++;
+ }
+
+ if (n)
+ (*infoRec->NonTEGlyphRenderer) (pScrn,
+ xInit, yInit, n,
+ infoRec->GlyphInfo + skipglyph,
+ pbox, fg, rop, planemask);
+ }
+
+ nbox--;
+ pbox++;
+ }
+ return width;
+}
+
+/* It is possible that the none of the glyphs passed to the
+ NonTEGlyphRenderer will be drawn. This function being called
+ indicates that part of the text string's bounding box is visible
+ but not necessarily that any of the characters are visible */
+
+void
+XAANonTEGlyphRenderer(ScrnInfoPtr pScrn,
+ int x, int y, int n,
+ NonTEGlyphPtr glyphs,
+ BoxPtr pbox, int fg, int rop, unsigned int planemask)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x1, x2, y1, y2, i, w, h, skipleft, skiptop;
+ unsigned char *src;
+
+ for (i = 0; i < n; i++, glyphs++) {
+ x1 = x + glyphs->start;
+ x2 = x + glyphs->end;
+ y1 = y - glyphs->yoff;
+ y2 = y1 + glyphs->height;
+
+ if (y1 < pbox->y1) {
+ skiptop = pbox->y1 - y1;
+ y1 = pbox->y1;
+ }
+ else
+ skiptop = 0;
+ if (y2 > pbox->y2)
+ y2 = pbox->y2;
+ h = y2 - y1;
+ if (h <= 0)
+ continue;
+
+ if (x1 < pbox->x1) {
+ skipleft = pbox->x1 - x1;
+ x1 = pbox->x1;
+ }
+ else
+ skipleft = 0;
+ if (x2 > pbox->x2)
+ x2 = pbox->x2;
+
+ w = x2 - x1;
+
+ if (w > 0) {
+ src = glyphs->bits + (skiptop * glyphs->srcwidth);
+
+ if (skipleft) {
+ src += (skipleft >> 5) << 2;
+ skipleft &= 31;
+ }
+
+ (*infoRec->WriteBitmap) (pScrn, x1, y1, w, h, src,
+ glyphs->srcwidth, skipleft, fg, -1, rop,
+ planemask);
+ }
+ }
+
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaOffscreen.c b/xorg-server/hw/xfree86/xaa/xaaOffscreen.c
index 41be2b491..7d89fc17a 100644
--- a/xorg-server/hw/xfree86/xaa/xaaOffscreen.c
+++ b/xorg-server/hw/xfree86/xaa/xaaOffscreen.c
@@ -1,162 +1,163 @@
-
-/*
- Copyright (c) 1999 - The XFree86 Project Inc.
-
- Written by Mark Vojkovich
-
-*/
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "windowstr.h"
-#include "xf86str.h"
-#include "mi.h"
-#include "miline.h"
-#include "xaa.h"
-#include "xaalocal.h"
-#include "xaawrap.h"
-#include "xf86fbman.h"
-#include "servermd.h"
-
-void
-XAAMoveOutOffscreenPixmaps(ScreenPtr pScreen)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
- PixmapLinkPtr pLink = infoRec->OffscreenPixmaps;
- XAAPixmapPtr pPriv;
-
- while(pLink) {
- pPriv = XAA_GET_PIXMAP_PRIVATE(pLink->pPix);
- pLink->area = pPriv->offscreenArea;
- XAAMoveOutOffscreenPixmap(pLink->pPix);
- pLink = pLink->next;
- }
-}
-
-
-
-void
-XAAMoveInOffscreenPixmaps(ScreenPtr pScreen)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
- PixmapLinkPtr pLink = infoRec->OffscreenPixmaps;
- PixmapPtr pPix, pScreenPix, tmpPix;
- pointer data;
- XAAPixmapPtr pPriv;
- GCPtr pGC;
- FBAreaPtr area;
-
- pScreenPix = (*pScreen->GetScreenPixmap)(pScreen);
-
- while(pLink) {
- pPix = pLink->pPix;
- pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
- area = pLink->area;
-
- data = pPix->devPrivate.ptr;
- tmpPix = GetScratchPixmapHeader(pScreen,
- pPix->drawable.width, pPix->drawable.height,
- pPix->drawable.depth, pPix->drawable.bitsPerPixel,
- pPix->devKind, data);
-
- pPriv->freeData = FALSE;
-
- pPix->drawable.x = area->box.x1;
- pPix->drawable.y = area->box.y1;
- pPix->devKind = pScreenPix->devKind;
- pPix->devPrivate.ptr = pScreenPix->devPrivate.ptr;
- pPix->drawable.bitsPerPixel = infoRec->pScrn->bitsPerPixel;
- pPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-
- if(!tmpPix) {
- pPriv->offscreenArea = area;
- free(data);
- pLink = pLink->next;
- continue;
- }
-
- pGC = GetScratchGC(pPix->drawable.depth, pScreen);
- ValidateGC((DrawablePtr)pPix, pGC);
-
- (*pGC->ops->CopyArea)((DrawablePtr)tmpPix, (DrawablePtr)pPix, pGC,
- 0, 0, pPix->drawable.width, pPix->drawable.height, 0, 0);
-
- free(data);
- tmpPix->devPrivate.ptr = NULL;
-
- FreeScratchGC(pGC);
- FreeScratchPixmapHeader(tmpPix);
-
- pPriv->offscreenArea = area;
- pLink->area = NULL;
- pLink = pLink->next;
- }
-}
-
-
-void
-XAARemoveAreaCallback(FBAreaPtr area)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(area->pScreen);
- PixmapPtr pPix = (PixmapPtr)area->devPrivate.ptr;
- XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
-
- XAAMoveOutOffscreenPixmap(pPix);
-
- pPriv->flags &= ~OFFSCREEN;
-
- DELIST_OFFSCREEN_PIXMAP(pPix);
-}
-
-void
-XAAMoveOutOffscreenPixmap(PixmapPtr pPix)
-{
- ScreenPtr pScreen = pPix->drawable.pScreen;
- XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
- int width, height, devKind, bitsPerPixel;
- PixmapPtr tmpPix;
- unsigned char *data;
- GCPtr pGC;
-
- width = pPix->drawable.width;
- height = pPix->drawable.height;
- bitsPerPixel = pPix->drawable.bitsPerPixel;
-
- devKind = BitmapBytePad(width * bitsPerPixel);
- if(!(data = malloc(devKind * height)))
- FatalError("Out of memory\n");
-
- tmpPix = GetScratchPixmapHeader(pScreen, width, height,
- pPix->drawable.depth, bitsPerPixel, devKind, data);
- if(!tmpPix) {
- free(data);
- FatalError("Out of memory\n");
- }
-
- pGC = GetScratchGC(pPix->drawable.depth, pScreen);
- ValidateGC((DrawablePtr)tmpPix, pGC);
-
- (*pGC->ops->CopyArea)((DrawablePtr)pPix, (DrawablePtr)tmpPix,
- pGC, 0, 0, width, height, 0, 0);
-
- FreeScratchGC(pGC);
- FreeScratchPixmapHeader(tmpPix);
-
- pPix->drawable.x = 0;
- pPix->drawable.y = 0;
- pPix->devKind = devKind;
- pPix->devPrivate.ptr = data;
- pPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-
- pPriv->offscreenArea = NULL;
- pPriv->freeData = TRUE;
-}
+
+/*
+ Copyright (c) 1999 - The XFree86 Project Inc.
+
+ Written by Mark Vojkovich
+
+*/
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "xf86str.h"
+#include "mi.h"
+#include "miline.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "xaawrap.h"
+#include "xf86fbman.h"
+#include "servermd.h"
+
+void
+XAAMoveOutOffscreenPixmaps(ScreenPtr pScreen)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+ PixmapLinkPtr pLink = infoRec->OffscreenPixmaps;
+ XAAPixmapPtr pPriv;
+
+ while (pLink) {
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pLink->pPix);
+ pLink->area = pPriv->offscreenArea;
+ XAAMoveOutOffscreenPixmap(pLink->pPix);
+ pLink = pLink->next;
+ }
+}
+
+void
+XAAMoveInOffscreenPixmaps(ScreenPtr pScreen)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+ PixmapLinkPtr pLink = infoRec->OffscreenPixmaps;
+ PixmapPtr pPix, pScreenPix, tmpPix;
+ pointer data;
+ XAAPixmapPtr pPriv;
+ GCPtr pGC;
+ FBAreaPtr area;
+
+ pScreenPix = (*pScreen->GetScreenPixmap) (pScreen);
+
+ while (pLink) {
+ pPix = pLink->pPix;
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
+ area = pLink->area;
+
+ data = pPix->devPrivate.ptr;
+ tmpPix = GetScratchPixmapHeader(pScreen,
+ pPix->drawable.width,
+ pPix->drawable.height,
+ pPix->drawable.depth,
+ pPix->drawable.bitsPerPixel,
+ pPix->devKind, data);
+
+ pPriv->freeData = FALSE;
+
+ pPix->drawable.x = area->box.x1;
+ pPix->drawable.y = area->box.y1;
+ pPix->devKind = pScreenPix->devKind;
+ pPix->devPrivate.ptr = pScreenPix->devPrivate.ptr;
+ pPix->drawable.bitsPerPixel = infoRec->pScrn->bitsPerPixel;
+ pPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+
+ if (!tmpPix) {
+ pPriv->offscreenArea = area;
+ free(data);
+ pLink = pLink->next;
+ continue;
+ }
+
+ pGC = GetScratchGC(pPix->drawable.depth, pScreen);
+ ValidateGC((DrawablePtr) pPix, pGC);
+
+ (*pGC->ops->CopyArea) ((DrawablePtr) tmpPix, (DrawablePtr) pPix, pGC,
+ 0, 0, pPix->drawable.width,
+ pPix->drawable.height, 0, 0);
+
+ free(data);
+ tmpPix->devPrivate.ptr = NULL;
+
+ FreeScratchGC(pGC);
+ FreeScratchPixmapHeader(tmpPix);
+
+ pPriv->offscreenArea = area;
+ pLink->area = NULL;
+ pLink = pLink->next;
+ }
+}
+
+void
+XAARemoveAreaCallback(FBAreaPtr area)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(area->pScreen);
+ PixmapPtr pPix = (PixmapPtr) area->devPrivate.ptr;
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
+
+ XAAMoveOutOffscreenPixmap(pPix);
+
+ pPriv->flags &= ~OFFSCREEN;
+
+ DELIST_OFFSCREEN_PIXMAP(pPix);
+}
+
+void
+XAAMoveOutOffscreenPixmap(PixmapPtr pPix)
+{
+ ScreenPtr pScreen = pPix->drawable.pScreen;
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
+ int width, height, devKind, bitsPerPixel;
+ PixmapPtr tmpPix;
+ unsigned char *data;
+ GCPtr pGC;
+
+ width = pPix->drawable.width;
+ height = pPix->drawable.height;
+ bitsPerPixel = pPix->drawable.bitsPerPixel;
+
+ devKind = BitmapBytePad(width * bitsPerPixel);
+ if (!(data = malloc(devKind * height)))
+ FatalError("Out of memory\n");
+
+ tmpPix = GetScratchPixmapHeader(pScreen, width, height,
+ pPix->drawable.depth, bitsPerPixel, devKind,
+ data);
+ if (!tmpPix) {
+ free(data);
+ FatalError("Out of memory\n");
+ }
+
+ pGC = GetScratchGC(pPix->drawable.depth, pScreen);
+ ValidateGC((DrawablePtr) tmpPix, pGC);
+
+ (*pGC->ops->CopyArea) ((DrawablePtr) pPix, (DrawablePtr) tmpPix,
+ pGC, 0, 0, width, height, 0, 0);
+
+ FreeScratchGC(pGC);
+ FreeScratchPixmapHeader(tmpPix);
+
+ pPix->drawable.x = 0;
+ pPix->drawable.y = 0;
+ pPix->devKind = devKind;
+ pPix->devPrivate.ptr = data;
+ pPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+
+ pPriv->offscreenArea = NULL;
+ pPriv->freeData = TRUE;
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaOverlay.c b/xorg-server/hw/xfree86/xaa/xaaOverlay.c
index 176a2d891..25d18da96 100644
--- a/xorg-server/hw/xfree86/xaa/xaaOverlay.c
+++ b/xorg-server/hw/xfree86/xaa/xaaOverlay.c
@@ -1,129 +1,122 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-#include "xaawrap.h"
-#include "gcstruct.h"
-#include "pixmapstr.h"
-#include "mioverlay.h"
-
-#ifdef PANORAMIX
-#include "panoramiX.h"
-#include "panoramiXsrv.h"
-#endif
-
-static void
-XAACopyWindow8_32(
- WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgnSrc
-){
- DDXPointPtr pptSrc, ppt;
- RegionRec rgnDst;
- BoxPtr pbox;
- int dx, dy, nbox;
- WindowPtr pwinRoot;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- XAAInfoRecPtr infoRec =
- GET_XAAINFORECPTR_FROM_DRAWABLE((&pWin->drawable));
- Bool doUnderlay = miOverlayCopyUnderlay(pScreen);
- RegionPtr borderClip = &pWin->borderClip;
- Bool freeReg = FALSE;
-
- if (!infoRec->pScrn->vtSema || !infoRec->ScreenToScreenBitBlt ||
- (infoRec->ScreenToScreenBitBltFlags & NO_PLANEMASK))
- {
- XAA_SCREEN_PROLOGUE (pScreen, CopyWindow);
- if(infoRec->pScrn->vtSema && infoRec->NeedToSync) {
- (*infoRec->Sync)(infoRec->pScrn);
- infoRec->NeedToSync = FALSE;
- }
- (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
- XAA_SCREEN_EPILOGUE (pScreen, CopyWindow, XAACopyWindow8_32);
- return;
- }
-
- pwinRoot = pScreen->root;
-
- if(doUnderlay)
- freeReg = miOverlayCollectUnderlayRegions(pWin, &borderClip);
-
- RegionNull(&rgnDst);
-
- dx = ptOldOrg.x - pWin->drawable.x;
- dy = ptOldOrg.y - pWin->drawable.y;
- RegionTranslate(prgnSrc, -dx, -dy);
- RegionIntersect(&rgnDst, borderClip, prgnSrc);
-
- pbox = RegionRects(&rgnDst);
- nbox = RegionNumRects(&rgnDst);
- if(!nbox ||
- !(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))) {
- RegionUninit(&rgnDst);
- return;
- }
- ppt = pptSrc;
-
- while(nbox--) {
- ppt->x = pbox->x1 + dx;
- ppt->y = pbox->y1 + dy;
- ppt++; pbox++;
- }
-
- infoRec->ScratchGC.planemask = doUnderlay ? 0x00ffffff : 0xff000000;
- infoRec->ScratchGC.alu = GXcopy;
-
- XAADoBitBlt((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
- &(infoRec->ScratchGC), &rgnDst, pptSrc);
-
- free(pptSrc);
- RegionUninit(&rgnDst);
- if(freeReg)
- RegionDestroy(borderClip);
-}
-
-static void
-XAASetColorKey8_32(
- ScreenPtr pScreen,
- int nbox,
- BoxPtr pbox
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
- ScrnInfoPtr pScrn = infoRec->pScrn;
-
- /* I'm counting on writes being clipped away while switched away.
- If this isn't going to be true then I need to be wrapping instead. */
- if(!infoRec->pScrn->vtSema) return;
-
- (*infoRec->FillSolidRects)(pScrn, pScrn->colorKey << 24, GXcopy,
- 0xff000000, nbox, pbox);
-
- SET_SYNC_FLAG(infoRec);
-}
-
-void
-XAASetupOverlay8_32Planar(ScreenPtr pScreen)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
- int i;
-
- pScreen->CopyWindow = XAACopyWindow8_32;
-
- if(!(infoRec->FillSolidRectsFlags & NO_PLANEMASK))
- miOverlaySetTransFunction(pScreen, XAASetColorKey8_32);
-
- infoRec->FullPlanemask = ~0;
- for(i = 0; i < 32; i++) /* haven't thought about this much */
- infoRec->FullPlanemasks[i] = ~0;
-}
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "xaawrap.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "mioverlay.h"
+
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+
+static void
+XAACopyWindow8_32(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ DDXPointPtr pptSrc, ppt;
+ RegionRec rgnDst;
+ BoxPtr pbox;
+ int dx, dy, nbox;
+ WindowPtr pwinRoot;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_DRAWABLE((&pWin->drawable));
+ Bool doUnderlay = miOverlayCopyUnderlay(pScreen);
+ RegionPtr borderClip = &pWin->borderClip;
+ Bool freeReg = FALSE;
+
+ if (!infoRec->pScrn->vtSema || !infoRec->ScreenToScreenBitBlt ||
+ (infoRec->ScreenToScreenBitBltFlags & NO_PLANEMASK)) {
+ XAA_SCREEN_PROLOGUE(pScreen, CopyWindow);
+ if (infoRec->pScrn->vtSema && infoRec->NeedToSync) {
+ (*infoRec->Sync) (infoRec->pScrn);
+ infoRec->NeedToSync = FALSE;
+ }
+ (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
+ XAA_SCREEN_EPILOGUE(pScreen, CopyWindow, XAACopyWindow8_32);
+ return;
+ }
+
+ pwinRoot = pScreen->root;
+
+ if (doUnderlay)
+ freeReg = miOverlayCollectUnderlayRegions(pWin, &borderClip);
+
+ RegionNull(&rgnDst);
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ RegionTranslate(prgnSrc, -dx, -dy);
+ RegionIntersect(&rgnDst, borderClip, prgnSrc);
+
+ pbox = RegionRects(&rgnDst);
+ nbox = RegionNumRects(&rgnDst);
+ if (!nbox || !(pptSrc = (DDXPointPtr) malloc(nbox * sizeof(DDXPointRec)))) {
+ RegionUninit(&rgnDst);
+ return;
+ }
+ ppt = pptSrc;
+
+ while (nbox--) {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ ppt++;
+ pbox++;
+ }
+
+ infoRec->ScratchGC.planemask = doUnderlay ? 0x00ffffff : 0xff000000;
+ infoRec->ScratchGC.alu = GXcopy;
+
+ XAADoBitBlt((DrawablePtr) pwinRoot, (DrawablePtr) pwinRoot,
+ &(infoRec->ScratchGC), &rgnDst, pptSrc);
+
+ free(pptSrc);
+ RegionUninit(&rgnDst);
+ if (freeReg)
+ RegionDestroy(borderClip);
+}
+
+static void
+XAASetColorKey8_32(ScreenPtr pScreen, int nbox, BoxPtr pbox)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+ ScrnInfoPtr pScrn = infoRec->pScrn;
+
+ /* I'm counting on writes being clipped away while switched away.
+ If this isn't going to be true then I need to be wrapping instead. */
+ if (!infoRec->pScrn->vtSema)
+ return;
+
+ (*infoRec->FillSolidRects) (pScrn, pScrn->colorKey << 24, GXcopy,
+ 0xff000000, nbox, pbox);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+void
+XAASetupOverlay8_32Planar(ScreenPtr pScreen)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+ int i;
+
+ pScreen->CopyWindow = XAACopyWindow8_32;
+
+ if (!(infoRec->FillSolidRectsFlags & NO_PLANEMASK))
+ miOverlaySetTransFunction(pScreen, XAASetColorKey8_32);
+
+ infoRec->FullPlanemask = ~0;
+ for (i = 0; i < 32; i++) /* haven't thought about this much */
+ infoRec->FullPlanemasks[i] = ~0;
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaOverlayDF.c b/xorg-server/hw/xfree86/xaa/xaaOverlayDF.c
index 309ec9fa4..5918f65a3 100644
--- a/xorg-server/hw/xfree86/xaa/xaaOverlayDF.c
+++ b/xorg-server/hw/xfree86/xaa/xaaOverlayDF.c
@@ -1,1053 +1,906 @@
-/*
- Copyright (c) 1999 - The XFree86 Project Inc.
-
- Written by Mark Vojkovich
-*/
-
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "windowstr.h"
-#include "xf86str.h"
-#include "mi.h"
-#include "miline.h"
-#include "xaa.h"
-#include "xaalocal.h"
-#include "xaawrap.h"
-#include "servermd.h"
-
-/* Screen funcs */
-
-static void XAAOverCopyWindow(WindowPtr, DDXPointRec, RegionPtr);
-static void XAAOverWindowExposures(WindowPtr, RegionPtr, RegionPtr);
-
-static int XAAOverStippledFillChooser(GCPtr);
-static int XAAOverOpaqueStippledFillChooser(GCPtr);
-static int XAAOverTiledFillChooser(GCPtr);
-
-/* GC funcs */
-
-static RegionPtr XAAOverCopyArea(DrawablePtr, DrawablePtr, GC *,
- int, int, int, int, int, int);
-static RegionPtr XAAOverCopyPlane(DrawablePtr, DrawablePtr, GCPtr,
- int, int, int, int, int, int, unsigned long);
-static void XAAOverPushPixelsSolid(GCPtr, PixmapPtr, DrawablePtr, int,
- int, int, int);
-static void XAAOverPolyFillRectSolid(DrawablePtr, GCPtr, int, xRectangle*);
-static void XAAOverPolyFillRectStippled(DrawablePtr, GCPtr, int, xRectangle*);
-static void XAAOverPolyFillRectOpaqueStippled(DrawablePtr, GCPtr,
- int, xRectangle*);
-static void XAAOverPolyFillRectTiled(DrawablePtr, GCPtr, int, xRectangle*);
-static void XAAOverFillSpansSolid(DrawablePtr, GCPtr, int, DDXPointPtr,
- int*, int);
-static void XAAOverFillSpansStippled(DrawablePtr, GCPtr, int, DDXPointPtr,
- int*, int);
-static void XAAOverFillSpansOpaqueStippled(DrawablePtr, GCPtr, int,
- DDXPointPtr, int*, int);
-static void XAAOverFillSpansTiled(DrawablePtr, GCPtr, int, DDXPointPtr,
- int*, int);
-static int XAAOverPolyText8TE(DrawablePtr, GCPtr, int, int, int, char *);
-static int XAAOverPolyText16TE(DrawablePtr, GCPtr, int, int, int,
- unsigned short*);
-static void XAAOverImageText8TE(DrawablePtr, GCPtr, int, int, int, char*);
-static void XAAOverImageText16TE(DrawablePtr, GCPtr, int, int, int,
- unsigned short*);
-static void XAAOverImageGlyphBltTE(DrawablePtr, GCPtr, int, int,
- unsigned int, CharInfoPtr*, pointer);
-static void XAAOverPolyGlyphBltTE(DrawablePtr, GCPtr, int, int,
- unsigned int, CharInfoPtr*, pointer);
-static int XAAOverPolyText8NonTE(DrawablePtr, GCPtr, int, int, int, char*);
-static int XAAOverPolyText16NonTE(DrawablePtr, GCPtr, int, int, int,
- unsigned short*);
-static void XAAOverImageText8NonTE(DrawablePtr, GCPtr, int, int, int, char*);
-static void XAAOverImageText16NonTE(DrawablePtr, GCPtr, int, int, int,
- unsigned short*);
-static void XAAOverImageGlyphBltNonTE(DrawablePtr, GCPtr, int, int,
- unsigned int, CharInfoPtr *, pointer);
-static void XAAOverPolyGlyphBltNonTE(DrawablePtr, GCPtr, int, int,
- unsigned int, CharInfoPtr *, pointer);
-static void XAAOverPolyRectangleThinSolid(DrawablePtr, GCPtr, int, xRectangle*);
-static void XAAOverPolylinesWideSolid(DrawablePtr, GCPtr, int, int,
- DDXPointPtr);
-static void XAAOverPolylinesThinSolid(DrawablePtr, GCPtr, int, int,
- DDXPointPtr);
-static void XAAOverPolySegmentThinSolid(DrawablePtr, GCPtr, int, xSegment*);
-static void XAAOverPolylinesThinDashed(DrawablePtr, GCPtr, int, int,
- DDXPointPtr);
-static void XAAOverPolySegmentThinDashed(DrawablePtr, GCPtr, int, xSegment*);
-static void XAAOverFillPolygonSolid(DrawablePtr, GCPtr, int, int, int,
- DDXPointPtr);
-static void XAAOverFillPolygonStippled(DrawablePtr, GCPtr, int, int, int,
- DDXPointPtr);
-static void XAAOverFillPolygonOpaqueStippled(DrawablePtr, GCPtr, int, int, int,
- DDXPointPtr);
-static void XAAOverFillPolygonTiled(DrawablePtr, GCPtr, int, int, int,
- DDXPointPtr);
-static void XAAOverPolyFillArcSolid(DrawablePtr, GCPtr, int, xArc*);
-static void XAAOverPutImage(DrawablePtr, GCPtr, int, int, int, int, int,
- int, int, char*);
-
-
-typedef struct {
- ScrnInfoPtr pScrn;
- DepthChangeFuncPtr callback;
- int currentDepth;
-/* GC funcs */
- RegionPtr (*CopyArea)(DrawablePtr, DrawablePtr, GC *,
- int, int, int, int, int, int);
- RegionPtr (*CopyPlane)(DrawablePtr, DrawablePtr, GCPtr,
- int, int, int, int, int, int, unsigned long);
- void (*PushPixelsSolid)(GCPtr, PixmapPtr, DrawablePtr, int, int, int, int);
- void (*PolyFillRectSolid)(DrawablePtr, GCPtr, int, xRectangle*);
- void (*PolyFillRectStippled)(DrawablePtr, GCPtr, int, xRectangle*);
- void (*PolyFillRectOpaqueStippled)(DrawablePtr, GCPtr, int, xRectangle*);
- void (*PolyFillRectTiled)(DrawablePtr, GCPtr, int, xRectangle*);
- void (*FillSpansSolid)(DrawablePtr, GCPtr, int, DDXPointPtr, int*, int);
- void (*FillSpansStippled)(DrawablePtr, GCPtr, int, DDXPointPtr, int*, int);
- void (*FillSpansOpaqueStippled)(DrawablePtr,GCPtr,int,DDXPointPtr,int*,int);
- void (*FillSpansTiled)(DrawablePtr, GCPtr, int, DDXPointPtr, int*, int);
- int (*PolyText8TE)(DrawablePtr, GCPtr, int, int, int, char *);
- int (*PolyText16TE)(DrawablePtr, GCPtr, int, int, int, unsigned short*);
- void (*ImageText8TE)(DrawablePtr, GCPtr, int, int, int, char*);
- void (*ImageText16TE)(DrawablePtr, GCPtr, int, int, int, unsigned short*);
- void (*ImageGlyphBltTE)(DrawablePtr, GCPtr, int, int, unsigned int,
- CharInfoPtr*, pointer);
- void (*PolyGlyphBltTE)(DrawablePtr, GCPtr, int, int, unsigned int,
- CharInfoPtr*, pointer);
- int (*PolyText8NonTE)(DrawablePtr, GCPtr, int, int, int, char*);
- int (*PolyText16NonTE)(DrawablePtr, GCPtr, int, int, int, unsigned short*);
- void (*ImageText8NonTE)(DrawablePtr, GCPtr, int, int, int, char*);
- void (*ImageText16NonTE)(DrawablePtr, GCPtr, int, int, int, unsigned short*);
- void (*ImageGlyphBltNonTE)(DrawablePtr, GCPtr, int, int, unsigned int,
- CharInfoPtr *, pointer);
- void (*PolyGlyphBltNonTE)(DrawablePtr, GCPtr, int, int, unsigned int,
- CharInfoPtr *, pointer);
- void (*PolyRectangleThinSolid)(DrawablePtr, GCPtr, int, xRectangle*);
- void (*PolylinesWideSolid)(DrawablePtr, GCPtr, int, int, DDXPointPtr);
-
- void (*PolylinesThinSolid)(DrawablePtr, GCPtr, int, int, DDXPointPtr);
- void (*PolySegmentThinSolid)(DrawablePtr, GCPtr, int, xSegment*);
- void (*PolylinesThinDashed)(DrawablePtr, GCPtr, int, int, DDXPointPtr);
- void (*PolySegmentThinDashed)(DrawablePtr, GCPtr, int, xSegment*);
- void (*FillPolygonSolid)(DrawablePtr, GCPtr, int, int, int, DDXPointPtr);
- void (*FillPolygonStippled)(DrawablePtr, GCPtr, int, int, int, DDXPointPtr);
- void (*FillPolygonOpaqueStippled)(DrawablePtr, GCPtr, int, int, int,
- DDXPointPtr);
- void (*FillPolygonTiled)(DrawablePtr, GCPtr, int, int, int, DDXPointPtr);
- void (*PolyFillArcSolid)(DrawablePtr, GCPtr, int, xArc*);
- void (*PutImage)(DrawablePtr, GCPtr, int, int, int, int, int, int,
- int, char*);
- int (*StippledFillChooser)(GCPtr);
- int (*OpaqueStippledFillChooser)(GCPtr);
- int (*TiledFillChooser)(GCPtr);
-} XAAOverlayRec, *XAAOverlayPtr;
-
-static DevPrivateKeyRec XAAOverlayKeyRec;
-#define XAAOverlayKey (&XAAOverlayKeyRec)
-
-#define GET_OVERLAY_PRIV(pScreen) \
- (XAAOverlayPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAOverlayKey)
-
-#define SWITCH_DEPTH(d) \
- if(pOverPriv->currentDepth != d) { \
- (*pOverPriv->callback)(pOverPriv->pScrn, d); \
- pOverPriv->currentDepth = d; \
- }
-
-
-Bool
-XAAInitDualFramebufferOverlay(
- ScreenPtr pScreen,
- DepthChangeFuncPtr callback
-){
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
- XAAOverlayPtr pOverPriv;
-
- if (!dixRegisterPrivateKey(&XAAOverlayKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
-
- if(!(pOverPriv = malloc(sizeof(XAAOverlayRec))))
- return FALSE;
-
- dixSetPrivate(&pScreen->devPrivates, XAAOverlayKey, pOverPriv);
-
- pOverPriv->pScrn = pScrn;
- pOverPriv->callback = callback;
- pOverPriv->currentDepth = -1;
-
- /* Overwrite key screen functions. The XAA core will clean up */
-
- pScreen->CopyWindow = XAAOverCopyWindow;
- pScreen->WindowExposures = XAAOverWindowExposures;
-
- pOverPriv->StippledFillChooser = infoRec->StippledFillChooser;
- pOverPriv->OpaqueStippledFillChooser = infoRec->OpaqueStippledFillChooser;
- pOverPriv->TiledFillChooser = infoRec->TiledFillChooser;
-
- infoRec->StippledFillChooser = XAAOverStippledFillChooser;
- infoRec->OpaqueStippledFillChooser = XAAOverOpaqueStippledFillChooser;
- infoRec->TiledFillChooser = XAAOverTiledFillChooser;
-
- /* wrap all XAA GC rendering */
-
- pOverPriv->CopyArea = infoRec->CopyArea;
- pOverPriv->CopyPlane = infoRec->CopyPlane;
- pOverPriv->PushPixelsSolid = infoRec->PushPixelsSolid;
- pOverPriv->PolyFillRectSolid = infoRec->PolyFillRectSolid;
- pOverPriv->PolyFillRectStippled = infoRec->PolyFillRectStippled;
- pOverPriv->PolyFillRectOpaqueStippled = infoRec->PolyFillRectOpaqueStippled;
- pOverPriv->PolyFillRectTiled = infoRec->PolyFillRectTiled;
- pOverPriv->FillSpansSolid = infoRec->FillSpansSolid;
- pOverPriv->FillSpansStippled = infoRec->FillSpansStippled;
- pOverPriv->FillSpansOpaqueStippled = infoRec->FillSpansOpaqueStippled;
- pOverPriv->FillSpansTiled = infoRec->FillSpansTiled;
- pOverPriv->PolyText8TE = infoRec->PolyText8TE;
- pOverPriv->PolyText16TE = infoRec->PolyText16TE;
- pOverPriv->ImageText8TE = infoRec->ImageText8TE;
- pOverPriv->ImageText16TE = infoRec->ImageText16TE;
- pOverPriv->ImageGlyphBltTE = infoRec->ImageGlyphBltTE;
- pOverPriv->PolyGlyphBltTE = infoRec->PolyGlyphBltTE;
- pOverPriv->PolyText8NonTE = infoRec->PolyText8NonTE;
- pOverPriv->PolyText16NonTE = infoRec->PolyText16NonTE;
- pOverPriv->ImageText8NonTE = infoRec->ImageText8NonTE;
- pOverPriv->ImageText16NonTE = infoRec->ImageText16NonTE;
- pOverPriv->ImageGlyphBltNonTE = infoRec->ImageGlyphBltNonTE;
- pOverPriv->PolyGlyphBltNonTE = infoRec->PolyGlyphBltNonTE;
- pOverPriv->PolyRectangleThinSolid = infoRec->PolyRectangleThinSolid;
- pOverPriv->PolylinesWideSolid = infoRec->PolylinesWideSolid;
- pOverPriv->PolylinesThinSolid = infoRec->PolylinesThinSolid;
- pOverPriv->PolySegmentThinSolid = infoRec->PolySegmentThinSolid;
- pOverPriv->PolylinesThinDashed = infoRec->PolylinesThinDashed;
- pOverPriv->PolySegmentThinDashed = infoRec->PolySegmentThinDashed;
- pOverPriv->FillPolygonSolid = infoRec->FillPolygonSolid;
- pOverPriv->FillPolygonStippled = infoRec->FillPolygonStippled;
- pOverPriv->FillPolygonOpaqueStippled = infoRec->FillPolygonOpaqueStippled;
- pOverPriv->FillPolygonTiled = infoRec->FillPolygonTiled;
- pOverPriv->PolyFillArcSolid = infoRec->PolyFillArcSolid;
- pOverPriv->PutImage = infoRec->PutImage;
-
-
- if(infoRec->CopyArea)
- infoRec->CopyArea = XAAOverCopyArea;
- if(infoRec->CopyPlane)
- infoRec->CopyPlane = XAAOverCopyPlane;
- if(infoRec->PushPixelsSolid)
- infoRec->PushPixelsSolid = XAAOverPushPixelsSolid;
- if(infoRec->PolyFillRectSolid)
- infoRec->PolyFillRectSolid = XAAOverPolyFillRectSolid;
- if(infoRec->PolyFillRectStippled)
- infoRec->PolyFillRectStippled = XAAOverPolyFillRectStippled;
- if(infoRec->PolyFillRectOpaqueStippled)
- infoRec->PolyFillRectOpaqueStippled = XAAOverPolyFillRectOpaqueStippled;
- if(infoRec->PolyFillRectTiled)
- infoRec->PolyFillRectTiled = XAAOverPolyFillRectTiled;
- if(infoRec->FillSpansSolid)
- infoRec->FillSpansSolid = XAAOverFillSpansSolid;
- if(infoRec->FillSpansStippled)
- infoRec->FillSpansStippled = XAAOverFillSpansStippled;
- if(infoRec->FillSpansOpaqueStippled)
- infoRec->FillSpansOpaqueStippled = XAAOverFillSpansOpaqueStippled;
- if(infoRec->FillSpansTiled)
- infoRec->FillSpansTiled = XAAOverFillSpansTiled;
- if(infoRec->PolyText8TE)
- infoRec->PolyText8TE = XAAOverPolyText8TE;
- if(infoRec->PolyText16TE)
- infoRec->PolyText16TE = XAAOverPolyText16TE;
- if(infoRec->ImageText8TE)
- infoRec->ImageText8TE = XAAOverImageText8TE;
- if(infoRec->ImageText16TE)
- infoRec->ImageText16TE = XAAOverImageText16TE;
- if(infoRec->ImageGlyphBltTE)
- infoRec->ImageGlyphBltTE = XAAOverImageGlyphBltTE;
- if(infoRec->PolyGlyphBltTE)
- infoRec->PolyGlyphBltTE = XAAOverPolyGlyphBltTE;
- if(infoRec->PolyText8NonTE)
- infoRec->PolyText8NonTE = XAAOverPolyText8NonTE;
- if(infoRec->PolyText16NonTE)
- infoRec->PolyText16NonTE = XAAOverPolyText16NonTE;
- if(infoRec->ImageText8NonTE)
- infoRec->ImageText8NonTE = XAAOverImageText8NonTE;
- if(infoRec->ImageText16NonTE)
- infoRec->ImageText16NonTE = XAAOverImageText16NonTE;
- if(infoRec->ImageGlyphBltNonTE)
- infoRec->ImageGlyphBltNonTE = XAAOverImageGlyphBltNonTE;
- if(infoRec->PolyGlyphBltNonTE)
- infoRec->PolyGlyphBltNonTE = XAAOverPolyGlyphBltNonTE;
- if(infoRec->PolyRectangleThinSolid)
- infoRec->PolyRectangleThinSolid = XAAOverPolyRectangleThinSolid;
- if(infoRec->PolylinesWideSolid)
- infoRec->PolylinesWideSolid = XAAOverPolylinesWideSolid;
- if(infoRec->PolylinesThinSolid)
- infoRec->PolylinesThinSolid = XAAOverPolylinesThinSolid;
- if(infoRec->PolySegmentThinSolid)
- infoRec->PolySegmentThinSolid = XAAOverPolySegmentThinSolid;
- if(infoRec->PolylinesThinDashed)
- infoRec->PolylinesThinDashed = XAAOverPolylinesThinDashed;
- if(infoRec->PolySegmentThinDashed)
- infoRec->PolySegmentThinDashed = XAAOverPolySegmentThinDashed;
- if(infoRec->FillPolygonSolid)
- infoRec->FillPolygonSolid = XAAOverFillPolygonSolid;
- if(infoRec->FillPolygonStippled)
- infoRec->FillPolygonStippled = XAAOverFillPolygonStippled;
- if(infoRec->FillPolygonOpaqueStippled)
- infoRec->FillPolygonOpaqueStippled = XAAOverFillPolygonOpaqueStippled;
- if(infoRec->FillPolygonTiled)
- infoRec->FillPolygonTiled = XAAOverFillPolygonTiled;
- if(infoRec->PolyFillArcSolid)
- infoRec->PolyFillArcSolid = XAAOverPolyFillArcSolid;
- if(infoRec->PutImage)
- infoRec->PutImage = XAAOverPutImage;
-
- return TRUE;
-}
-
-/*********************** Screen functions ************************/
-
-void
-XAAOverCopyWindow(
- WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgnSrc
-){
- ScreenPtr pScreen = pWin->drawable.pScreen;
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pScreen);
- ScrnInfoPtr pScrn = infoRec->pScrn;
- DDXPointPtr ppt, pptSrc;
- RegionRec rgnDst;
- BoxPtr pbox;
- int i, nbox, dx, dy;
- WindowPtr pRoot = pScreen->root;
-
-
- if (!pScrn->vtSema || !infoRec->ScreenToScreenBitBlt) {
- XAA_SCREEN_PROLOGUE (pScreen, CopyWindow);
- if(pScrn->vtSema && infoRec->NeedToSync) {
- (*infoRec->Sync)(pScrn);
- infoRec->NeedToSync = FALSE;
- }
- (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
- XAA_SCREEN_EPILOGUE (pScreen, CopyWindow, XAAOverCopyWindow);
- return;
- }
-
- infoRec->ScratchGC.alu = GXcopy;
- infoRec->ScratchGC.planemask = ~0;
-
- RegionNull(&rgnDst);
-
- dx = ptOldOrg.x - pWin->drawable.x;
- dy = ptOldOrg.y - pWin->drawable.y;
- RegionTranslate(prgnSrc, -dx, -dy);
- RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
-
- nbox = RegionNumRects(&rgnDst);
- if(nbox &&
- (pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))) {
-
- pbox = RegionRects(&rgnDst);
- for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
- ppt->x = pbox->x1 + dx;
- ppt->y = pbox->y1 + dy;
- }
-
- SWITCH_DEPTH(8);
- XAADoBitBlt((DrawablePtr)pRoot, (DrawablePtr)pRoot,
- &(infoRec->ScratchGC), &rgnDst, pptSrc);
-
- if(pWin->drawable.bitsPerPixel != 8) {
- SWITCH_DEPTH(pScrn->depth);
- XAADoBitBlt((DrawablePtr)pRoot, (DrawablePtr)pRoot,
- &(infoRec->ScratchGC), &rgnDst, pptSrc);
- }
-
- free(pptSrc);
- }
-
- RegionUninit(&rgnDst);
-
- if(pWin->drawable.depth == 8) {
- RegionNull(&rgnDst);
- miSegregateChildren(pWin, &rgnDst, pScrn->depth);
- if(RegionNotEmpty(&rgnDst)) {
- RegionIntersect(&rgnDst, &rgnDst, prgnSrc);
- nbox = RegionNumRects(&rgnDst);
- if(nbox &&
- (pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))){
-
- pbox = RegionRects(&rgnDst);
- for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
- ppt->x = pbox->x1 + dx;
- ppt->y = pbox->y1 + dy;
- }
-
- SWITCH_DEPTH(pScrn->depth);
- XAADoBitBlt((DrawablePtr)pRoot, (DrawablePtr)pRoot,
- &(infoRec->ScratchGC), &rgnDst, pptSrc);
- free(pptSrc);
- }
- }
- RegionUninit(&rgnDst);
- }
-}
-
-
-void
-XAAOverWindowExposures(
- WindowPtr pWin,
- RegionPtr pReg,
- RegionPtr pOtherReg
-){
- ScreenPtr pScreen = pWin->drawable.pScreen;
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
-
- if((pWin->drawable.bitsPerPixel != 8) && infoRec->pScrn->vtSema) {
- if(RegionNumRects(pReg) && infoRec->FillSolidRects) {
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pScreen);
-
- SWITCH_DEPTH(8);
- (*infoRec->FillSolidRects)(infoRec->pScrn,
- infoRec->pScrn->colorKey, GXcopy, ~0,
- RegionNumRects(pReg), RegionRects(pReg));
- miWindowExposures(pWin, pReg, pOtherReg);
- return;
- } else if(infoRec->NeedToSync) {
- (*infoRec->Sync)(infoRec->pScrn);
- infoRec->NeedToSync = FALSE;
- }
- }
-
- XAA_SCREEN_PROLOGUE (pScreen, WindowExposures);
- (*pScreen->WindowExposures) (pWin, pReg, pOtherReg);
- XAA_SCREEN_EPILOGUE(pScreen, WindowExposures, XAAOverWindowExposures);
-}
-
-/********************* Choosers *************************/
-
-static int
-XAAOverStippledFillChooser(GCPtr pGC)
-{
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
- int ret;
-
- ret = (*pOverPriv->StippledFillChooser)(pGC);
-
- if((pGC->depth == 8) &&
- ((ret == DO_COLOR_8x8) || (ret == DO_CACHE_BLT))) {
- ret = 0;
- }
-
- return ret;
-}
-
-static int
-XAAOverOpaqueStippledFillChooser(GCPtr pGC)
-{
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
- int ret;
-
- ret = (*pOverPriv->OpaqueStippledFillChooser)(pGC);
-
- if((pGC->depth == 8) &&
- ((ret == DO_COLOR_8x8) || (ret == DO_CACHE_BLT))) {
- ret = 0;
- }
-
- return ret;
-}
-
-static int
-XAAOverTiledFillChooser(GCPtr pGC)
-{
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
- int ret;
-
- ret = (*pOverPriv->TiledFillChooser)(pGC);
-
- if((pGC->depth == 8) &&
- ((ret == DO_COLOR_8x8) || (ret == DO_CACHE_BLT))) {
- ret = 0;
- }
-
- return ret;
-}
-
-
-/**************************** GC Functions **************************/
-
-static RegionPtr
-XAAOverCopyArea(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GC *pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- return (*pOverPriv->CopyArea)(pSrc, pDst,
- pGC, srcx, srcy, width, height, dstx, dsty);
-}
-
-static RegionPtr
-XAAOverCopyPlane(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GCPtr pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty,
- unsigned long bitPlane
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- return (*pOverPriv->CopyPlane)(pSrc, pDst,
- pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
-
-}
-
-static void
-XAAOverPushPixelsSolid(
- GCPtr pGC,
- PixmapPtr pBitMap,
- DrawablePtr pDraw,
- int dx, int dy,
- int xOrg, int yOrg
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->PushPixelsSolid)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
-}
-
-
-
-static void
-XAAOverPolyFillRectSolid(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nrectFill,
- xRectangle *prectInit
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->PolyFillRectSolid)(pDraw, pGC, nrectFill, prectInit);
-}
-
-static void
-XAAOverPolyFillRectStippled(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nrectFill,
- xRectangle *prectInit
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->PolyFillRectStippled)(pDraw, pGC, nrectFill, prectInit);
-}
-
-
-static void
-XAAOverPolyFillRectOpaqueStippled(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nrectFill,
- xRectangle *prectInit
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->PolyFillRectOpaqueStippled)(pDraw, pGC, nrectFill, prectInit);
-}
-
-static void
-XAAOverPolyFillRectTiled(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nrectFill,
- xRectangle *prectInit
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->PolyFillRectTiled)(pDraw, pGC, nrectFill, prectInit);
-}
-
-
-static void
-XAAOverFillSpansSolid(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nInit,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->FillSpansSolid)(
- pDraw, pGC, nInit, ppt, pwidth, fSorted);
-}
-
-
-static void
-XAAOverFillSpansStippled(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nInit,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->FillSpansStippled)(pDraw, pGC, nInit, ppt, pwidth, fSorted);
-}
-
-static void
-XAAOverFillSpansOpaqueStippled(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nInit,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->FillSpansOpaqueStippled)(
- pDraw, pGC, nInit, ppt, pwidth, fSorted);
-}
-
-
-static void
-XAAOverFillSpansTiled(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nInit,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->FillSpansTiled)(pDraw, pGC, nInit, ppt, pwidth, fSorted);
-}
-
-static int
-XAAOverPolyText8TE(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- char *chars
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- return (*pOverPriv->PolyText8TE)(pDraw, pGC, x, y, count, chars);
-}
-
-
-static int
-XAAOverPolyText16TE(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- unsigned short *chars
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- return (*pOverPriv->PolyText16TE)(pDraw, pGC, x, y, count, chars);
-}
-
-
-static void
-XAAOverImageText8TE(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- char *chars
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->ImageText8TE)(pDraw, pGC, x, y, count, chars);
-}
-
-
-static void
-XAAOverImageText16TE(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- unsigned short *chars
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->ImageText16TE)(pDraw, pGC, x, y, count, chars);
-}
-
-static void
-XAAOverImageGlyphBltTE(
- DrawablePtr pDraw,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->ImageGlyphBltTE)(
- pDraw, pGC, xInit, yInit, nglyph, ppci, pglyphBase);
-}
-
-static void
-XAAOverPolyGlyphBltTE(
- DrawablePtr pDraw,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->PolyGlyphBltTE)(
- pDraw, pGC, xInit, yInit, nglyph, ppci, pglyphBase);
-}
-
-static int
-XAAOverPolyText8NonTE(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- char *chars
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- return (*pOverPriv->PolyText8NonTE)(pDraw, pGC, x, y, count, chars);
-}
-
-
-static int
-XAAOverPolyText16NonTE(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- unsigned short *chars
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- return (*pOverPriv->PolyText16NonTE)(pDraw, pGC, x, y, count, chars);
-}
-
-static void
-XAAOverImageText8NonTE(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- char *chars
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->ImageText8NonTE)(pDraw, pGC, x, y, count, chars);
-}
-
-static void
-XAAOverImageText16NonTE(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- unsigned short *chars
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->ImageText16NonTE)(pDraw, pGC, x, y, count, chars);
-}
-
-
-static void
-XAAOverImageGlyphBltNonTE(
- DrawablePtr pDraw,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->ImageGlyphBltNonTE)(
- pDraw, pGC, xInit, yInit, nglyph, ppci, pglyphBase);
-}
-
-static void
-XAAOverPolyGlyphBltNonTE(
- DrawablePtr pDraw,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->PolyGlyphBltNonTE)(
- pDraw, pGC, xInit, yInit, nglyph, ppci, pglyphBase);
-}
-
-static void
-XAAOverPolyRectangleThinSolid(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nRectsInit,
- xRectangle *pRectsInit
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->PolyRectangleThinSolid)(pDraw, pGC, nRectsInit, pRectsInit);
-}
-
-
-
-static void
-XAAOverPolylinesWideSolid(
- DrawablePtr pDraw,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr pPts
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->PolylinesWideSolid)(pDraw, pGC, mode, npt, pPts);
-}
-
-
-static void
-XAAOverPolylinesThinSolid(
- DrawablePtr pDraw,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr pPts
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->PolylinesThinSolid)(pDraw, pGC, mode, npt, pPts);
-}
-
-static void
-XAAOverPolySegmentThinSolid(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nseg,
- xSegment *pSeg
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->PolySegmentThinSolid)(pDraw, pGC, nseg, pSeg);
-}
-
-static void
-XAAOverPolylinesThinDashed(
- DrawablePtr pDraw,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr pPts
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->PolylinesThinDashed)(pDraw, pGC, mode, npt, pPts);
-}
-
-static void
-XAAOverPolySegmentThinDashed(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nseg,
- xSegment *pSeg
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->PolySegmentThinDashed)(pDraw, pGC, nseg, pSeg);
-}
-
-
-static void
-XAAOverFillPolygonSolid(
- DrawablePtr pDraw,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->FillPolygonSolid)(pDraw, pGC, shape, mode, count, ptsIn);
-}
-
-static void
-XAAOverFillPolygonStippled(
- DrawablePtr pDraw,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->FillPolygonStippled)(pDraw, pGC, shape, mode, count, ptsIn);
-}
-
-
-static void
-XAAOverFillPolygonOpaqueStippled(
- DrawablePtr pDraw,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->FillPolygonOpaqueStippled)(
- pDraw, pGC, shape, mode, count, ptsIn);
-}
-
-static void
-XAAOverFillPolygonTiled(
- DrawablePtr pDraw,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->FillPolygonTiled)(pDraw, pGC, shape, mode, count, ptsIn);
-}
-
-
-static void
-XAAOverPolyFillArcSolid(
- DrawablePtr pDraw,
- GCPtr pGC,
- int narcs,
- xArc *parcs
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->PolyFillArcSolid)(pDraw, pGC, narcs, parcs);
-}
-
-
-static void
-XAAOverPutImage(
- DrawablePtr pDraw,
- GCPtr pGC,
- int depth,
- int x,
- int y,
- int w,
- int h,
- int leftPad,
- int format,
- char *pImage
-){
- XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
-
- SWITCH_DEPTH(pGC->depth);
-
- (*pOverPriv->PutImage)(pDraw, pGC, depth, x, y, w, h,
- leftPad, format, pImage);
-}
-
+/*
+ Copyright (c) 1999 - The XFree86 Project Inc.
+
+ Written by Mark Vojkovich
+*/
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "xf86str.h"
+#include "mi.h"
+#include "miline.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "xaawrap.h"
+#include "servermd.h"
+
+/* Screen funcs */
+
+static void XAAOverCopyWindow(WindowPtr, DDXPointRec, RegionPtr);
+static void XAAOverWindowExposures(WindowPtr, RegionPtr, RegionPtr);
+
+static int XAAOverStippledFillChooser(GCPtr);
+static int XAAOverOpaqueStippledFillChooser(GCPtr);
+static int XAAOverTiledFillChooser(GCPtr);
+
+/* GC funcs */
+
+static RegionPtr XAAOverCopyArea(DrawablePtr, DrawablePtr, GC *,
+ int, int, int, int, int, int);
+static RegionPtr XAAOverCopyPlane(DrawablePtr, DrawablePtr, GCPtr,
+ int, int, int, int, int, int, unsigned long);
+static void XAAOverPushPixelsSolid(GCPtr, PixmapPtr, DrawablePtr, int,
+ int, int, int);
+static void XAAOverPolyFillRectSolid(DrawablePtr, GCPtr, int, xRectangle *);
+static void XAAOverPolyFillRectStippled(DrawablePtr, GCPtr, int, xRectangle *);
+static void XAAOverPolyFillRectOpaqueStippled(DrawablePtr, GCPtr,
+ int, xRectangle *);
+static void XAAOverPolyFillRectTiled(DrawablePtr, GCPtr, int, xRectangle *);
+static void XAAOverFillSpansSolid(DrawablePtr, GCPtr, int, DDXPointPtr,
+ int *, int);
+static void XAAOverFillSpansStippled(DrawablePtr, GCPtr, int, DDXPointPtr,
+ int *, int);
+static void XAAOverFillSpansOpaqueStippled(DrawablePtr, GCPtr, int,
+ DDXPointPtr, int *, int);
+static void XAAOverFillSpansTiled(DrawablePtr, GCPtr, int, DDXPointPtr,
+ int *, int);
+static int XAAOverPolyText8TE(DrawablePtr, GCPtr, int, int, int, char *);
+static int XAAOverPolyText16TE(DrawablePtr, GCPtr, int, int, int,
+ unsigned short *);
+static void XAAOverImageText8TE(DrawablePtr, GCPtr, int, int, int, char *);
+static void XAAOverImageText16TE(DrawablePtr, GCPtr, int, int, int,
+ unsigned short *);
+static void XAAOverImageGlyphBltTE(DrawablePtr, GCPtr, int, int,
+ unsigned int, CharInfoPtr *, pointer);
+static void XAAOverPolyGlyphBltTE(DrawablePtr, GCPtr, int, int,
+ unsigned int, CharInfoPtr *, pointer);
+static int XAAOverPolyText8NonTE(DrawablePtr, GCPtr, int, int, int, char *);
+static int XAAOverPolyText16NonTE(DrawablePtr, GCPtr, int, int, int,
+ unsigned short *);
+static void XAAOverImageText8NonTE(DrawablePtr, GCPtr, int, int, int, char *);
+static void XAAOverImageText16NonTE(DrawablePtr, GCPtr, int, int, int,
+ unsigned short *);
+static void XAAOverImageGlyphBltNonTE(DrawablePtr, GCPtr, int, int,
+ unsigned int, CharInfoPtr *, pointer);
+static void XAAOverPolyGlyphBltNonTE(DrawablePtr, GCPtr, int, int,
+ unsigned int, CharInfoPtr *, pointer);
+static void XAAOverPolyRectangleThinSolid(DrawablePtr, GCPtr, int,
+ xRectangle *);
+static void XAAOverPolylinesWideSolid(DrawablePtr, GCPtr, int, int,
+ DDXPointPtr);
+static void XAAOverPolylinesThinSolid(DrawablePtr, GCPtr, int, int,
+ DDXPointPtr);
+static void XAAOverPolySegmentThinSolid(DrawablePtr, GCPtr, int, xSegment *);
+static void XAAOverPolylinesThinDashed(DrawablePtr, GCPtr, int, int,
+ DDXPointPtr);
+static void XAAOverPolySegmentThinDashed(DrawablePtr, GCPtr, int, xSegment *);
+static void XAAOverFillPolygonSolid(DrawablePtr, GCPtr, int, int, int,
+ DDXPointPtr);
+static void XAAOverFillPolygonStippled(DrawablePtr, GCPtr, int, int, int,
+ DDXPointPtr);
+static void XAAOverFillPolygonOpaqueStippled(DrawablePtr, GCPtr, int, int, int,
+ DDXPointPtr);
+static void XAAOverFillPolygonTiled(DrawablePtr, GCPtr, int, int, int,
+ DDXPointPtr);
+static void XAAOverPolyFillArcSolid(DrawablePtr, GCPtr, int, xArc *);
+static void XAAOverPutImage(DrawablePtr, GCPtr, int, int, int, int, int,
+ int, int, char *);
+
+typedef struct {
+ ScrnInfoPtr pScrn;
+ DepthChangeFuncPtr callback;
+ int currentDepth;
+/* GC funcs */
+ RegionPtr (*CopyArea) (DrawablePtr, DrawablePtr, GC *,
+ int, int, int, int, int, int);
+ RegionPtr (*CopyPlane) (DrawablePtr, DrawablePtr, GCPtr,
+ int, int, int, int, int, int, unsigned long);
+ void (*PushPixelsSolid) (GCPtr, PixmapPtr, DrawablePtr, int, int, int, int);
+ void (*PolyFillRectSolid) (DrawablePtr, GCPtr, int, xRectangle *);
+ void (*PolyFillRectStippled) (DrawablePtr, GCPtr, int, xRectangle *);
+ void (*PolyFillRectOpaqueStippled) (DrawablePtr, GCPtr, int, xRectangle *);
+ void (*PolyFillRectTiled) (DrawablePtr, GCPtr, int, xRectangle *);
+ void (*FillSpansSolid) (DrawablePtr, GCPtr, int, DDXPointPtr, int *, int);
+ void (*FillSpansStippled) (DrawablePtr, GCPtr, int, DDXPointPtr, int *,
+ int);
+ void (*FillSpansOpaqueStippled) (DrawablePtr, GCPtr, int, DDXPointPtr,
+ int *, int);
+ void (*FillSpansTiled) (DrawablePtr, GCPtr, int, DDXPointPtr, int *, int);
+ int (*PolyText8TE) (DrawablePtr, GCPtr, int, int, int, char *);
+ int (*PolyText16TE) (DrawablePtr, GCPtr, int, int, int, unsigned short *);
+ void (*ImageText8TE) (DrawablePtr, GCPtr, int, int, int, char *);
+ void (*ImageText16TE) (DrawablePtr, GCPtr, int, int, int, unsigned short *);
+ void (*ImageGlyphBltTE) (DrawablePtr, GCPtr, int, int, unsigned int,
+ CharInfoPtr *, pointer);
+ void (*PolyGlyphBltTE) (DrawablePtr, GCPtr, int, int, unsigned int,
+ CharInfoPtr *, pointer);
+ int (*PolyText8NonTE) (DrawablePtr, GCPtr, int, int, int, char *);
+ int (*PolyText16NonTE) (DrawablePtr, GCPtr, int, int, int,
+ unsigned short *);
+ void (*ImageText8NonTE) (DrawablePtr, GCPtr, int, int, int, char *);
+ void (*ImageText16NonTE) (DrawablePtr, GCPtr, int, int, int,
+ unsigned short *);
+ void (*ImageGlyphBltNonTE) (DrawablePtr, GCPtr, int, int, unsigned int,
+ CharInfoPtr *, pointer);
+ void (*PolyGlyphBltNonTE) (DrawablePtr, GCPtr, int, int, unsigned int,
+ CharInfoPtr *, pointer);
+ void (*PolyRectangleThinSolid) (DrawablePtr, GCPtr, int, xRectangle *);
+ void (*PolylinesWideSolid) (DrawablePtr, GCPtr, int, int, DDXPointPtr);
+
+ void (*PolylinesThinSolid) (DrawablePtr, GCPtr, int, int, DDXPointPtr);
+ void (*PolySegmentThinSolid) (DrawablePtr, GCPtr, int, xSegment *);
+ void (*PolylinesThinDashed) (DrawablePtr, GCPtr, int, int, DDXPointPtr);
+ void (*PolySegmentThinDashed) (DrawablePtr, GCPtr, int, xSegment *);
+ void (*FillPolygonSolid) (DrawablePtr, GCPtr, int, int, int, DDXPointPtr);
+ void (*FillPolygonStippled) (DrawablePtr, GCPtr, int, int, int,
+ DDXPointPtr);
+ void (*FillPolygonOpaqueStippled) (DrawablePtr, GCPtr, int, int, int,
+ DDXPointPtr);
+ void (*FillPolygonTiled) (DrawablePtr, GCPtr, int, int, int, DDXPointPtr);
+ void (*PolyFillArcSolid) (DrawablePtr, GCPtr, int, xArc *);
+ void (*PutImage) (DrawablePtr, GCPtr, int, int, int, int, int, int,
+ int, char *);
+ int (*StippledFillChooser) (GCPtr);
+ int (*OpaqueStippledFillChooser) (GCPtr);
+ int (*TiledFillChooser) (GCPtr);
+} XAAOverlayRec, *XAAOverlayPtr;
+
+static DevPrivateKeyRec XAAOverlayKeyRec;
+
+#define XAAOverlayKey (&XAAOverlayKeyRec)
+
+#define GET_OVERLAY_PRIV(pScreen) \
+ (XAAOverlayPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAOverlayKey)
+
+#define SWITCH_DEPTH(d) \
+ if(pOverPriv->currentDepth != d) { \
+ (*pOverPriv->callback)(pOverPriv->pScrn, d); \
+ pOverPriv->currentDepth = d; \
+ }
+
+Bool
+XAAInitDualFramebufferOverlay(ScreenPtr pScreen, DepthChangeFuncPtr callback)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+ XAAOverlayPtr pOverPriv;
+
+ if (!dixRegisterPrivateKey(&XAAOverlayKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ if (!(pOverPriv = malloc(sizeof(XAAOverlayRec))))
+ return FALSE;
+
+ dixSetPrivate(&pScreen->devPrivates, XAAOverlayKey, pOverPriv);
+
+ pOverPriv->pScrn = pScrn;
+ pOverPriv->callback = callback;
+ pOverPriv->currentDepth = -1;
+
+ /* Overwrite key screen functions. The XAA core will clean up */
+
+ pScreen->CopyWindow = XAAOverCopyWindow;
+ pScreen->WindowExposures = XAAOverWindowExposures;
+
+ pOverPriv->StippledFillChooser = infoRec->StippledFillChooser;
+ pOverPriv->OpaqueStippledFillChooser = infoRec->OpaqueStippledFillChooser;
+ pOverPriv->TiledFillChooser = infoRec->TiledFillChooser;
+
+ infoRec->StippledFillChooser = XAAOverStippledFillChooser;
+ infoRec->OpaqueStippledFillChooser = XAAOverOpaqueStippledFillChooser;
+ infoRec->TiledFillChooser = XAAOverTiledFillChooser;
+
+ /* wrap all XAA GC rendering */
+
+ pOverPriv->CopyArea = infoRec->CopyArea;
+ pOverPriv->CopyPlane = infoRec->CopyPlane;
+ pOverPriv->PushPixelsSolid = infoRec->PushPixelsSolid;
+ pOverPriv->PolyFillRectSolid = infoRec->PolyFillRectSolid;
+ pOverPriv->PolyFillRectStippled = infoRec->PolyFillRectStippled;
+ pOverPriv->PolyFillRectOpaqueStippled = infoRec->PolyFillRectOpaqueStippled;
+ pOverPriv->PolyFillRectTiled = infoRec->PolyFillRectTiled;
+ pOverPriv->FillSpansSolid = infoRec->FillSpansSolid;
+ pOverPriv->FillSpansStippled = infoRec->FillSpansStippled;
+ pOverPriv->FillSpansOpaqueStippled = infoRec->FillSpansOpaqueStippled;
+ pOverPriv->FillSpansTiled = infoRec->FillSpansTiled;
+ pOverPriv->PolyText8TE = infoRec->PolyText8TE;
+ pOverPriv->PolyText16TE = infoRec->PolyText16TE;
+ pOverPriv->ImageText8TE = infoRec->ImageText8TE;
+ pOverPriv->ImageText16TE = infoRec->ImageText16TE;
+ pOverPriv->ImageGlyphBltTE = infoRec->ImageGlyphBltTE;
+ pOverPriv->PolyGlyphBltTE = infoRec->PolyGlyphBltTE;
+ pOverPriv->PolyText8NonTE = infoRec->PolyText8NonTE;
+ pOverPriv->PolyText16NonTE = infoRec->PolyText16NonTE;
+ pOverPriv->ImageText8NonTE = infoRec->ImageText8NonTE;
+ pOverPriv->ImageText16NonTE = infoRec->ImageText16NonTE;
+ pOverPriv->ImageGlyphBltNonTE = infoRec->ImageGlyphBltNonTE;
+ pOverPriv->PolyGlyphBltNonTE = infoRec->PolyGlyphBltNonTE;
+ pOverPriv->PolyRectangleThinSolid = infoRec->PolyRectangleThinSolid;
+ pOverPriv->PolylinesWideSolid = infoRec->PolylinesWideSolid;
+ pOverPriv->PolylinesThinSolid = infoRec->PolylinesThinSolid;
+ pOverPriv->PolySegmentThinSolid = infoRec->PolySegmentThinSolid;
+ pOverPriv->PolylinesThinDashed = infoRec->PolylinesThinDashed;
+ pOverPriv->PolySegmentThinDashed = infoRec->PolySegmentThinDashed;
+ pOverPriv->FillPolygonSolid = infoRec->FillPolygonSolid;
+ pOverPriv->FillPolygonStippled = infoRec->FillPolygonStippled;
+ pOverPriv->FillPolygonOpaqueStippled = infoRec->FillPolygonOpaqueStippled;
+ pOverPriv->FillPolygonTiled = infoRec->FillPolygonTiled;
+ pOverPriv->PolyFillArcSolid = infoRec->PolyFillArcSolid;
+ pOverPriv->PutImage = infoRec->PutImage;
+
+ if (infoRec->CopyArea)
+ infoRec->CopyArea = XAAOverCopyArea;
+ if (infoRec->CopyPlane)
+ infoRec->CopyPlane = XAAOverCopyPlane;
+ if (infoRec->PushPixelsSolid)
+ infoRec->PushPixelsSolid = XAAOverPushPixelsSolid;
+ if (infoRec->PolyFillRectSolid)
+ infoRec->PolyFillRectSolid = XAAOverPolyFillRectSolid;
+ if (infoRec->PolyFillRectStippled)
+ infoRec->PolyFillRectStippled = XAAOverPolyFillRectStippled;
+ if (infoRec->PolyFillRectOpaqueStippled)
+ infoRec->PolyFillRectOpaqueStippled = XAAOverPolyFillRectOpaqueStippled;
+ if (infoRec->PolyFillRectTiled)
+ infoRec->PolyFillRectTiled = XAAOverPolyFillRectTiled;
+ if (infoRec->FillSpansSolid)
+ infoRec->FillSpansSolid = XAAOverFillSpansSolid;
+ if (infoRec->FillSpansStippled)
+ infoRec->FillSpansStippled = XAAOverFillSpansStippled;
+ if (infoRec->FillSpansOpaqueStippled)
+ infoRec->FillSpansOpaqueStippled = XAAOverFillSpansOpaqueStippled;
+ if (infoRec->FillSpansTiled)
+ infoRec->FillSpansTiled = XAAOverFillSpansTiled;
+ if (infoRec->PolyText8TE)
+ infoRec->PolyText8TE = XAAOverPolyText8TE;
+ if (infoRec->PolyText16TE)
+ infoRec->PolyText16TE = XAAOverPolyText16TE;
+ if (infoRec->ImageText8TE)
+ infoRec->ImageText8TE = XAAOverImageText8TE;
+ if (infoRec->ImageText16TE)
+ infoRec->ImageText16TE = XAAOverImageText16TE;
+ if (infoRec->ImageGlyphBltTE)
+ infoRec->ImageGlyphBltTE = XAAOverImageGlyphBltTE;
+ if (infoRec->PolyGlyphBltTE)
+ infoRec->PolyGlyphBltTE = XAAOverPolyGlyphBltTE;
+ if (infoRec->PolyText8NonTE)
+ infoRec->PolyText8NonTE = XAAOverPolyText8NonTE;
+ if (infoRec->PolyText16NonTE)
+ infoRec->PolyText16NonTE = XAAOverPolyText16NonTE;
+ if (infoRec->ImageText8NonTE)
+ infoRec->ImageText8NonTE = XAAOverImageText8NonTE;
+ if (infoRec->ImageText16NonTE)
+ infoRec->ImageText16NonTE = XAAOverImageText16NonTE;
+ if (infoRec->ImageGlyphBltNonTE)
+ infoRec->ImageGlyphBltNonTE = XAAOverImageGlyphBltNonTE;
+ if (infoRec->PolyGlyphBltNonTE)
+ infoRec->PolyGlyphBltNonTE = XAAOverPolyGlyphBltNonTE;
+ if (infoRec->PolyRectangleThinSolid)
+ infoRec->PolyRectangleThinSolid = XAAOverPolyRectangleThinSolid;
+ if (infoRec->PolylinesWideSolid)
+ infoRec->PolylinesWideSolid = XAAOverPolylinesWideSolid;
+ if (infoRec->PolylinesThinSolid)
+ infoRec->PolylinesThinSolid = XAAOverPolylinesThinSolid;
+ if (infoRec->PolySegmentThinSolid)
+ infoRec->PolySegmentThinSolid = XAAOverPolySegmentThinSolid;
+ if (infoRec->PolylinesThinDashed)
+ infoRec->PolylinesThinDashed = XAAOverPolylinesThinDashed;
+ if (infoRec->PolySegmentThinDashed)
+ infoRec->PolySegmentThinDashed = XAAOverPolySegmentThinDashed;
+ if (infoRec->FillPolygonSolid)
+ infoRec->FillPolygonSolid = XAAOverFillPolygonSolid;
+ if (infoRec->FillPolygonStippled)
+ infoRec->FillPolygonStippled = XAAOverFillPolygonStippled;
+ if (infoRec->FillPolygonOpaqueStippled)
+ infoRec->FillPolygonOpaqueStippled = XAAOverFillPolygonOpaqueStippled;
+ if (infoRec->FillPolygonTiled)
+ infoRec->FillPolygonTiled = XAAOverFillPolygonTiled;
+ if (infoRec->PolyFillArcSolid)
+ infoRec->PolyFillArcSolid = XAAOverPolyFillArcSolid;
+ if (infoRec->PutImage)
+ infoRec->PutImage = XAAOverPutImage;
+
+ return TRUE;
+}
+
+/*********************** Screen functions ************************/
+
+void
+XAAOverCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pScreen);
+ ScrnInfoPtr pScrn = infoRec->pScrn;
+ DDXPointPtr ppt, pptSrc;
+ RegionRec rgnDst;
+ BoxPtr pbox;
+ int i, nbox, dx, dy;
+ WindowPtr pRoot = pScreen->root;
+
+ if (!pScrn->vtSema || !infoRec->ScreenToScreenBitBlt) {
+ XAA_SCREEN_PROLOGUE(pScreen, CopyWindow);
+ if (pScrn->vtSema && infoRec->NeedToSync) {
+ (*infoRec->Sync) (pScrn);
+ infoRec->NeedToSync = FALSE;
+ }
+ (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
+ XAA_SCREEN_EPILOGUE(pScreen, CopyWindow, XAAOverCopyWindow);
+ return;
+ }
+
+ infoRec->ScratchGC.alu = GXcopy;
+ infoRec->ScratchGC.planemask = ~0;
+
+ RegionNull(&rgnDst);
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ RegionTranslate(prgnSrc, -dx, -dy);
+ RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
+
+ nbox = RegionNumRects(&rgnDst);
+ if (nbox && (pptSrc = (DDXPointPtr) malloc(nbox * sizeof(DDXPointRec)))) {
+
+ pbox = RegionRects(&rgnDst);
+ for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ }
+
+ SWITCH_DEPTH(8);
+ XAADoBitBlt((DrawablePtr) pRoot, (DrawablePtr) pRoot,
+ &(infoRec->ScratchGC), &rgnDst, pptSrc);
+
+ if (pWin->drawable.bitsPerPixel != 8) {
+ SWITCH_DEPTH(pScrn->depth);
+ XAADoBitBlt((DrawablePtr) pRoot, (DrawablePtr) pRoot,
+ &(infoRec->ScratchGC), &rgnDst, pptSrc);
+ }
+
+ free(pptSrc);
+ }
+
+ RegionUninit(&rgnDst);
+
+ if (pWin->drawable.depth == 8) {
+ RegionNull(&rgnDst);
+ miSegregateChildren(pWin, &rgnDst, pScrn->depth);
+ if (RegionNotEmpty(&rgnDst)) {
+ RegionIntersect(&rgnDst, &rgnDst, prgnSrc);
+ nbox = RegionNumRects(&rgnDst);
+ if (nbox &&
+ (pptSrc = (DDXPointPtr) malloc(nbox * sizeof(DDXPointRec)))) {
+
+ pbox = RegionRects(&rgnDst);
+ for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ }
+
+ SWITCH_DEPTH(pScrn->depth);
+ XAADoBitBlt((DrawablePtr) pRoot, (DrawablePtr) pRoot,
+ &(infoRec->ScratchGC), &rgnDst, pptSrc);
+ free(pptSrc);
+ }
+ }
+ RegionUninit(&rgnDst);
+ }
+}
+
+void
+XAAOverWindowExposures(WindowPtr pWin, RegionPtr pReg, RegionPtr pOtherReg)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+
+ if ((pWin->drawable.bitsPerPixel != 8) && infoRec->pScrn->vtSema) {
+ if (RegionNumRects(pReg) && infoRec->FillSolidRects) {
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pScreen);
+
+ SWITCH_DEPTH(8);
+ (*infoRec->FillSolidRects) (infoRec->pScrn,
+ infoRec->pScrn->colorKey, GXcopy, ~0,
+ RegionNumRects(pReg),
+ RegionRects(pReg));
+ miWindowExposures(pWin, pReg, pOtherReg);
+ return;
+ }
+ else if (infoRec->NeedToSync) {
+ (*infoRec->Sync) (infoRec->pScrn);
+ infoRec->NeedToSync = FALSE;
+ }
+ }
+
+ XAA_SCREEN_PROLOGUE(pScreen, WindowExposures);
+ (*pScreen->WindowExposures) (pWin, pReg, pOtherReg);
+ XAA_SCREEN_EPILOGUE(pScreen, WindowExposures, XAAOverWindowExposures);
+}
+
+/********************* Choosers *************************/
+
+static int
+XAAOverStippledFillChooser(GCPtr pGC)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+ int ret;
+
+ ret = (*pOverPriv->StippledFillChooser) (pGC);
+
+ if ((pGC->depth == 8) && ((ret == DO_COLOR_8x8) || (ret == DO_CACHE_BLT))) {
+ ret = 0;
+ }
+
+ return ret;
+}
+
+static int
+XAAOverOpaqueStippledFillChooser(GCPtr pGC)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+ int ret;
+
+ ret = (*pOverPriv->OpaqueStippledFillChooser) (pGC);
+
+ if ((pGC->depth == 8) && ((ret == DO_COLOR_8x8) || (ret == DO_CACHE_BLT))) {
+ ret = 0;
+ }
+
+ return ret;
+}
+
+static int
+XAAOverTiledFillChooser(GCPtr pGC)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+ int ret;
+
+ ret = (*pOverPriv->TiledFillChooser) (pGC);
+
+ if ((pGC->depth == 8) && ((ret == DO_COLOR_8x8) || (ret == DO_CACHE_BLT))) {
+ ret = 0;
+ }
+
+ return ret;
+}
+
+/**************************** GC Functions **************************/
+
+static RegionPtr
+XAAOverCopyArea(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GC * pGC,
+ int srcx, int srcy, int width, int height, int dstx, int dsty)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ return (*pOverPriv->CopyArea) (pSrc, pDst,
+ pGC, srcx, srcy, width, height, dstx, dsty);
+}
+
+static RegionPtr
+XAAOverCopyPlane(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx, int srcy,
+ int width, int height,
+ int dstx, int dsty, unsigned long bitPlane)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ return (*pOverPriv->CopyPlane) (pSrc, pDst,
+ pGC, srcx, srcy, width, height, dstx, dsty,
+ bitPlane);
+
+}
+
+static void
+XAAOverPushPixelsSolid(GCPtr pGC,
+ PixmapPtr pBitMap,
+ DrawablePtr pDraw, int dx, int dy, int xOrg, int yOrg)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->PushPixelsSolid) (pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
+}
+
+static void
+XAAOverPolyFillRectSolid(DrawablePtr pDraw,
+ GCPtr pGC, int nrectFill, xRectangle *prectInit)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->PolyFillRectSolid) (pDraw, pGC, nrectFill, prectInit);
+}
+
+static void
+XAAOverPolyFillRectStippled(DrawablePtr pDraw,
+ GCPtr pGC, int nrectFill, xRectangle *prectInit)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->PolyFillRectStippled) (pDraw, pGC, nrectFill, prectInit);
+}
+
+static void
+XAAOverPolyFillRectOpaqueStippled(DrawablePtr pDraw,
+ GCPtr pGC,
+ int nrectFill, xRectangle *prectInit)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->PolyFillRectOpaqueStippled) (pDraw, pGC, nrectFill, prectInit);
+}
+
+static void
+XAAOverPolyFillRectTiled(DrawablePtr pDraw,
+ GCPtr pGC, int nrectFill, xRectangle *prectInit)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->PolyFillRectTiled) (pDraw, pGC, nrectFill, prectInit);
+}
+
+static void
+XAAOverFillSpansSolid(DrawablePtr pDraw,
+ GCPtr pGC,
+ int nInit, DDXPointPtr ppt, int *pwidth, int fSorted)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->FillSpansSolid) (pDraw, pGC, nInit, ppt, pwidth, fSorted);
+}
+
+static void
+XAAOverFillSpansStippled(DrawablePtr pDraw,
+ GCPtr pGC,
+ int nInit, DDXPointPtr ppt, int *pwidth, int fSorted)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->FillSpansStippled) (pDraw, pGC, nInit, ppt, pwidth, fSorted);
+}
+
+static void
+XAAOverFillSpansOpaqueStippled(DrawablePtr pDraw,
+ GCPtr pGC,
+ int nInit,
+ DDXPointPtr ppt, int *pwidth, int fSorted)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->FillSpansOpaqueStippled) (pDraw, pGC, nInit, ppt, pwidth,
+ fSorted);
+}
+
+static void
+XAAOverFillSpansTiled(DrawablePtr pDraw,
+ GCPtr pGC,
+ int nInit, DDXPointPtr ppt, int *pwidth, int fSorted)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->FillSpansTiled) (pDraw, pGC, nInit, ppt, pwidth, fSorted);
+}
+
+static int
+XAAOverPolyText8TE(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ return (*pOverPriv->PolyText8TE) (pDraw, pGC, x, y, count, chars);
+}
+
+static int
+XAAOverPolyText16TE(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, unsigned short *chars)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ return (*pOverPriv->PolyText16TE) (pDraw, pGC, x, y, count, chars);
+}
+
+static void
+XAAOverImageText8TE(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->ImageText8TE) (pDraw, pGC, x, y, count, chars);
+}
+
+static void
+XAAOverImageText16TE(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, unsigned short *chars)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->ImageText16TE) (pDraw, pGC, x, y, count, chars);
+}
+
+static void
+XAAOverImageGlyphBltTE(DrawablePtr pDraw,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->ImageGlyphBltTE) (pDraw, pGC, xInit, yInit, nglyph, ppci,
+ pglyphBase);
+}
+
+static void
+XAAOverPolyGlyphBltTE(DrawablePtr pDraw,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->PolyGlyphBltTE) (pDraw, pGC, xInit, yInit, nglyph, ppci,
+ pglyphBase);
+}
+
+static int
+XAAOverPolyText8NonTE(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ return (*pOverPriv->PolyText8NonTE) (pDraw, pGC, x, y, count, chars);
+}
+
+static int
+XAAOverPolyText16NonTE(DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y, int count, unsigned short *chars)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ return (*pOverPriv->PolyText16NonTE) (pDraw, pGC, x, y, count, chars);
+}
+
+static void
+XAAOverImageText8NonTE(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->ImageText8NonTE) (pDraw, pGC, x, y, count, chars);
+}
+
+static void
+XAAOverImageText16NonTE(DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y, int count, unsigned short *chars)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->ImageText16NonTE) (pDraw, pGC, x, y, count, chars);
+}
+
+static void
+XAAOverImageGlyphBltNonTE(DrawablePtr pDraw,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->ImageGlyphBltNonTE) (pDraw, pGC, xInit, yInit, nglyph, ppci,
+ pglyphBase);
+}
+
+static void
+XAAOverPolyGlyphBltNonTE(DrawablePtr pDraw,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->PolyGlyphBltNonTE) (pDraw, pGC, xInit, yInit, nglyph, ppci,
+ pglyphBase);
+}
+
+static void
+XAAOverPolyRectangleThinSolid(DrawablePtr pDraw,
+ GCPtr pGC, int nRectsInit, xRectangle *pRectsInit)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->PolyRectangleThinSolid) (pDraw, pGC, nRectsInit, pRectsInit);
+}
+
+static void
+XAAOverPolylinesWideSolid(DrawablePtr pDraw,
+ GCPtr pGC, int mode, int npt, DDXPointPtr pPts)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->PolylinesWideSolid) (pDraw, pGC, mode, npt, pPts);
+}
+
+static void
+XAAOverPolylinesThinSolid(DrawablePtr pDraw,
+ GCPtr pGC, int mode, int npt, DDXPointPtr pPts)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->PolylinesThinSolid) (pDraw, pGC, mode, npt, pPts);
+}
+
+static void
+XAAOverPolySegmentThinSolid(DrawablePtr pDraw,
+ GCPtr pGC, int nseg, xSegment * pSeg)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->PolySegmentThinSolid) (pDraw, pGC, nseg, pSeg);
+}
+
+static void
+XAAOverPolylinesThinDashed(DrawablePtr pDraw,
+ GCPtr pGC, int mode, int npt, DDXPointPtr pPts)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->PolylinesThinDashed) (pDraw, pGC, mode, npt, pPts);
+}
+
+static void
+XAAOverPolySegmentThinDashed(DrawablePtr pDraw,
+ GCPtr pGC, int nseg, xSegment * pSeg)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->PolySegmentThinDashed) (pDraw, pGC, nseg, pSeg);
+}
+
+static void
+XAAOverFillPolygonSolid(DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape, int mode, int count, DDXPointPtr ptsIn)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->FillPolygonSolid) (pDraw, pGC, shape, mode, count, ptsIn);
+}
+
+static void
+XAAOverFillPolygonStippled(DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape, int mode, int count, DDXPointPtr ptsIn)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->FillPolygonStippled) (pDraw, pGC, shape, mode, count, ptsIn);
+}
+
+static void
+XAAOverFillPolygonOpaqueStippled(DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape,
+ int mode, int count, DDXPointPtr ptsIn)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->FillPolygonOpaqueStippled) (pDraw, pGC, shape, mode, count,
+ ptsIn);
+}
+
+static void
+XAAOverFillPolygonTiled(DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape, int mode, int count, DDXPointPtr ptsIn)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->FillPolygonTiled) (pDraw, pGC, shape, mode, count, ptsIn);
+}
+
+static void
+XAAOverPolyFillArcSolid(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->PolyFillArcSolid) (pDraw, pGC, narcs, parcs);
+}
+
+static void
+XAAOverPutImage(DrawablePtr pDraw,
+ GCPtr pGC,
+ int depth,
+ int x,
+ int y, int w, int h, int leftPad, int format, char *pImage)
+{
+ XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
+
+ SWITCH_DEPTH(pGC->depth);
+
+ (*pOverPriv->PutImage) (pDraw, pGC, depth, x, y, w, h,
+ leftPad, format, pImage);
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaPCache.c b/xorg-server/hw/xfree86/xaa/xaaPCache.c
index ff3f9ef56..02c0cd498 100644
--- a/xorg-server/hw/xfree86/xaa/xaaPCache.c
+++ b/xorg-server/hw/xfree86/xaa/xaaPCache.c
@@ -1,2374 +1,2527 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <string.h>
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "gc.h"
-#include "mi.h"
-#include "pixmapstr.h"
-#include "windowstr.h"
-#include "regionstr.h"
-#include "servermd.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaacexp.h"
-#include "xaalocal.h"
-#include "xaawrap.h"
-
-#define MAX_COLOR 32
-#define MAX_MONO 32
-#define MAX_8 32
-#define MAX_128 32
-#define MAX_256 32
-#define MAX_512 16
-
-static int CacheInitIndex = -1;
-#define CACHEINIT(p) ((p)->privates[CacheInitIndex].val)
-
-
-typedef struct _CacheLink {
- int x;
- int y;
- int w;
- int h;
- struct _CacheLink *next;
-} CacheLink, *CacheLinkPtr;
-
-
-static void
-TransferList(CacheLinkPtr list, XAACacheInfoPtr array, int num)
-{
- while(num--) {
- array->x = list->x;
- array->y = list->y;
- array->w = list->w;
- array->h = list->h;
- array->serialNumber = 0;
- array->fg = array->bg = -1;
- list = list->next;
- array++;
- }
-}
-
-
-
-static CacheLinkPtr
-Enlist(CacheLinkPtr link, int x, int y, int w, int h)
-{
- CacheLinkPtr newLink;
-
- newLink = malloc(sizeof(CacheLink));
- newLink->next = link;
- newLink->x = x; newLink->y = y;
- newLink->w = w; newLink->h = h;
- return newLink;
-}
-
-
-
-static CacheLinkPtr
-Delist(CacheLinkPtr link) {
- CacheLinkPtr ret = NULL;
-
- if(link) {
- ret = link->next;
- free(link);
- }
- return ret;
-}
-
-
-
-static void
-FreeList(CacheLinkPtr link) {
- CacheLinkPtr tmp;
-
- while(link) {
- tmp = link;
- link = link->next;
- free(tmp);
- }
-}
-
-
-
-static CacheLinkPtr
-QuadLinks(CacheLinkPtr big, CacheLinkPtr little)
-{
- /* CAUTION: This doesn't free big */
- int w1, w2, h1, h2;
-
- while(big) {
- w1 = big->w >> 1;
- w2 = big->w - w1;
- h1 = big->h >> 1;
- h2 = big->h - h1;
-
- little = Enlist(little, big->x, big->y, w1, h1);
- little = Enlist(little, big->x + w1, big->y, w2, h1);
- little = Enlist(little, big->x, big->y + h1, w1, h2);
- little = Enlist(little, big->x + w1, big->y + h1, w2, h2);
-
- big = big->next;
- }
- return little;
-}
-
-
-static void
-SubdivideList(CacheLinkPtr *large, CacheLinkPtr *small)
-{
- CacheLinkPtr big = *large;
- CacheLinkPtr little = *small;
- int size = big->w >> 1;
-
- little = Enlist(little, big->x, big->y, size, size);
- little = Enlist(little, big->x + size, big->y, size, size);
- little = Enlist(little, big->x, big->y + size, size, size);
- little = Enlist(little, big->x + size, big->y + size, size, size);
- *small = little;
- big = Delist(big);
- *large = big;
-}
-
-static void
-FreePixmapCachePrivate(XAAPixmapCachePrivatePtr pPriv)
-{
- if(!pPriv) return;
-
- free(pPriv->Info512);
- free(pPriv->Info256);
- free(pPriv->Info128);
- free(pPriv->InfoColor);
- free(pPriv->InfoMono);
- free(pPriv->InfoPartial);
-
- free(pPriv);
-}
-
-void
-XAAClosePixmapCache(ScreenPtr pScreen)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
-
- if(infoRec->PixmapCachePrivate)
- FreePixmapCachePrivate(
- (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate);
-
- infoRec->PixmapCachePrivate = NULL;
-}
-
-
-
-static CacheLinkPtr
-ThinOutPartials(
- CacheLinkPtr ListPartial,
- int *num, int *maxw, int *maxh
-) {
-/* This guy's job is to get at least 4 big slots out of a list of fragments */
-
- CacheLinkPtr List64, List32, List16, List8, pCur, next, ListKeepers;
- int Num64, Num32, Num16, Num8, NumKeepers;
- int w, h;
-
- List64 = List32 = List16 = List8 = ListKeepers = NULL;
- Num64 = Num32 = Num16 = Num8 = NumKeepers = 0;
- w = h = 0;
-
- /* We sort partials by how large a square tile they can cache.
- If a partial can't store a 64x64, 32x32, 16x16 or 8x8 tile,
- we free it. */
-
- pCur = ListPartial;
- while(pCur) {
- next = pCur->next;
- if((pCur->w >= 64) && (pCur->h >= 64)) {
- pCur->next = List64; List64 = pCur;
- Num64++;
- } else
- if((pCur->w >= 32) && (pCur->h >= 32)) {
- pCur->next = List32; List32 = pCur;
- Num32++;
- } else
- if((pCur->w >= 16) && (pCur->h >= 16)) {
- pCur->next = List16; List16 = pCur;
- Num16++;
- } else
- if((pCur->w >= 8) && (pCur->h >= 8)) {
- pCur->next = List8; List8 = pCur;
- Num8++;
- } else {
- free(pCur);
- }
-
- pCur = next;
- }
-
- /* We save all the tiles from the largest bin that we can get
- at least 4 of. If there are too few of a bigger slot, we
- cut it in fourths to make smaller slots. */
-
- if(Num64 >= 4) {
- ListKeepers = List64; List64 = NULL;
- NumKeepers = Num64;
- goto GOT_EM;
- } else if(Num64) {
- List32 = QuadLinks(List64, List32);
- Num32 += Num64 * 4;
- Num64 = 0;
- }
-
- if(Num32 >= 4) {
- ListKeepers = List32; List32 = NULL;
- NumKeepers = Num32;
- goto GOT_EM;
- } else if(Num32) {
- List16 = QuadLinks(List32, List16);
- Num16 += Num32 * 4;
- Num32 = 0;
- }
-
- if(Num16 >= 4) {
- ListKeepers = List16; List16 = NULL;
- NumKeepers = Num16;
- goto GOT_EM;
- } else if(Num16) {
- List8 = QuadLinks(List16, List8);
- Num8 += Num16 * 4;
- Num16 = 0;
- }
-
- if(Num8 >= 4) {
- ListKeepers = List8; List8 = NULL;
- NumKeepers = Num8;
- goto GOT_EM;
- }
-
-GOT_EM:
-
- /* Free the ones we aren't using */
-
- if(List64) FreeList(List64);
- if(List32) FreeList(List32);
- if(List16) FreeList(List16);
- if(List8) FreeList(List8);
-
-
- /* Enlarge the slots if we can */
-
- if(ListKeepers) {
- CacheLinkPtr pLink = ListKeepers;
- w = h = 128;
-
- while(pLink) {
- if(pLink->w < w) w = pLink->w;
- if(pLink->h < h) h = pLink->h;
- pLink = pLink->next;
- }
- }
-
- *maxw = w;
- *maxh = h;
- *num = NumKeepers;
- return ListKeepers;
-}
-
-static void
-ConvertColorToMono(
- CacheLinkPtr *ColorList,
- int ColorW, int ColorH,
- CacheLinkPtr *MonoList,
- int MonoW, int MonoH
-){
- int x, y, w;
-
- x = (*ColorList)->x; y = (*ColorList)->y;
- *ColorList = Delist(*ColorList);
-
- while(ColorH) {
- ColorH -= MonoH;
- for(w = 0; w <= (ColorW - MonoW); w += MonoW)
- *MonoList = Enlist(*MonoList, x + w, y + ColorH, MonoW, MonoH);
- }
-}
-
-static void
-ConvertAllPartialsTo8x8(
- int *NumMono, int *NumColor,
- CacheLinkPtr ListPartial,
- CacheLinkPtr *ListMono,
- CacheLinkPtr *ListColor,
- XAAInfoRecPtr infoRec
-){
-/* This guy extracts as many 8x8 slots as it can out of fragments */
-
- int ColorH = infoRec->CacheHeightColor8x8Pattern;
- int ColorW = infoRec->CacheWidthColor8x8Pattern;
- int MonoH = infoRec->CacheHeightMono8x8Pattern;
- int MonoW = infoRec->CacheWidthMono8x8Pattern;
- int x, y, w, Height, Width;
- Bool DoColor = (infoRec->PixmapCacheFlags & CACHE_COLOR_8x8);
- Bool DoMono = (infoRec->PixmapCacheFlags & CACHE_MONO_8x8);
- CacheLinkPtr pLink = ListPartial;
- CacheLinkPtr MonoList = *ListMono, ColorList = *ListColor;
-
- if(DoColor && DoMono) {
- /* we assume color patterns take more space than color ones */
- if(MonoH > ColorH) ColorH = MonoH;
- if(MonoW > ColorW) ColorW = MonoW;
- }
-
- /* Break up the area into as many Color and Mono slots as we can */
-
- while(pLink) {
- Height = pLink->h;
- Width = pLink->w;
- x = pLink->x;
- y = pLink->y;
-
- if(DoColor) {
- while(Height >= ColorH) {
- Height -= ColorH;
- for(w = 0; w <= (Width - ColorW); w += ColorW) {
- ColorList = Enlist(
- ColorList, x + w, y + Height, ColorW, ColorH);
- (*NumColor)++;
- }
- }
- }
-
- if(DoMono && (Height >= MonoH)) {
- while(Height >= MonoH) {
- Height -= MonoH;
- for(w = 0; w <= (Width - MonoW); w += MonoW) {
- MonoList = Enlist(
- MonoList, x + w, y + Height, MonoW, MonoH);
- (*NumMono)++;
- }
- }
- }
-
- pLink = pLink->next;
- }
-
-
- *ListMono = MonoList;
- *ListColor = ColorList;
- FreeList(ListPartial);
-}
-
-
-static CacheLinkPtr
-ExtractOneThatFits(CacheLinkPtr *initList, int w, int h)
-{
- CacheLinkPtr list = *initList;
- CacheLinkPtr prev = NULL;
-
- while(list) {
- if((list->w >= w) && (list->h >= h))
- break;
- prev = list;
- list = list->next;
- }
-
- if(list) {
- if(prev)
- prev->next = list->next;
- else
- *initList = list->next;
-
- list->next = NULL;
- }
-
- return list;
-}
-
-
-static CacheLinkPtr
-ConvertSomePartialsTo8x8(
- int *NumMono, int *NumColor, int *NumPartial,
- CacheLinkPtr ListPartial,
- CacheLinkPtr *ListMono,
- CacheLinkPtr *ListColor,
- int *maxw, int *maxh,
- XAAInfoRecPtr infoRec
-){
-/* This guy tries to get 4 of each type of 8x8 slot requested out of
- a list of fragments all while trying to retain some big fragments
- for the cache blits */
-
- int ColorH = infoRec->CacheHeightColor8x8Pattern;
- int ColorW = infoRec->CacheWidthColor8x8Pattern;
- int MonoH = infoRec->CacheHeightMono8x8Pattern;
- int MonoW = infoRec->CacheWidthMono8x8Pattern;
- Bool DoColor = (infoRec->PixmapCacheFlags & CACHE_COLOR_8x8);
- Bool DoMono = (infoRec->PixmapCacheFlags & CACHE_MONO_8x8);
- CacheLinkPtr List64, List32, List16, List8, pCur, next, ListKeepers;
- CacheLinkPtr MonoList = *ListMono, ColorList = *ListColor;
- int Num64, Num32, Num16, Num8, NumKeepers;
- int w, h, Width, Height;
- int MonosPerColor = 1;
-
- if(DoColor && DoMono) {
- /* we assume color patterns take more space than color ones */
- if(MonoH > ColorH) ColorH = MonoH;
- if(MonoW > ColorW) ColorW = MonoW;
- MonosPerColor = (ColorH/MonoH) * (ColorW/MonoW);
- }
-
- List64 = List32 = List16 = List8 = ListKeepers = MonoList = ColorList = NULL;
- Num64 = Num32 = Num16 = Num8 = NumKeepers = 0;
- Width = Height = 0;
-
- /* We sort partials by how large a square tile they can cache.
- We make 8x8 patterns from the leftovers if we can. */
-
- pCur = ListPartial;
- while(pCur) {
- next = pCur->next;
- if((pCur->w >= 64) && (pCur->h >= 64)) {
- pCur->next = List64; List64 = pCur;
- Num64++;
- } else
- if((pCur->w >= 32) && (pCur->h >= 32)) {
- pCur->next = List32; List32 = pCur;
- Num32++;
- } else
- if((pCur->w >= 16) && (pCur->h >= 16)) {
- pCur->next = List16; List16 = pCur;
- Num16++;
- } else
- if((pCur->w >= 8) && (pCur->h >= 8)) {
- pCur->next = List8; List8 = pCur;
- Num8++;
- } else {
- h = pCur->h;
- if(DoColor && (pCur->w >= ColorW) && (h >= ColorH)) {
- while(h >= ColorH) {
- h -= ColorH;
- for(w = 0; w <= (pCur->w - ColorW); w += ColorW) {
- ColorList = Enlist( ColorList,
- pCur->x + w, pCur->y + h, ColorW, ColorH);
- (*NumColor)++;
- }
- }
- }
- if(DoMono && (pCur->w >= MonoW) && (h >= MonoH)) {
- while(h >= MonoH) {
- h -= MonoH;
- for(w = 0; w <= (pCur->w - MonoW); w += MonoW) {
- MonoList = Enlist( MonoList,
- pCur->x + w, pCur->y + h, MonoW, MonoH);
- (*NumMono)++;
- }
- }
- }
- free(pCur);
- }
-
- pCur = next;
- }
-
- /* Try to extract at least 4 of each type of 8x8 slot that we need */
-
- if(DoColor) {
- CacheLinkPtr theOne;
- while(*NumColor < 4) {
- theOne = NULL;
- if(Num8) {
- if((theOne = ExtractOneThatFits(&List8, ColorW, ColorH)))
- Num8--;
- }
- if(Num16 && !theOne) {
- if((theOne = ExtractOneThatFits(&List16, ColorW, ColorH)))
- Num16--;
- }
- if(Num32 && !theOne) {
- if((theOne = ExtractOneThatFits(&List32, ColorW, ColorH)))
- Num32--;
- }
- if(Num64 && !theOne) {
- if((theOne = ExtractOneThatFits(&List64, ColorW, ColorH)))
- Num64--;
- }
-
- if(!theOne) break;
-
-
- ConvertAllPartialsTo8x8(NumMono, NumColor, theOne,
- &MonoList, &ColorList, infoRec);
-
- if(DoMono) {
- while(*NumColor && (*NumMono < 4)) {
- ConvertColorToMono(&ColorList, ColorW, ColorH,
- &MonoList, MonoW, MonoH);
- (*NumColor)--; *NumMono += MonosPerColor;
- }
- }
- }
- }
-
- if(DoMono) {
- CacheLinkPtr theOne;
- while(*NumMono < 4) {
- theOne = NULL;
- if(Num8) {
- if((theOne = ExtractOneThatFits(&List8, MonoW, MonoH)))
- Num8--;
- }
- if(Num16 && !theOne) {
- if((theOne = ExtractOneThatFits(&List16, MonoW, MonoH)))
- Num16--;
- }
- if(Num32 && !theOne) {
- if((theOne = ExtractOneThatFits(&List32, MonoW, MonoH)))
- Num32--;
- }
- if(Num64 && !theOne) {
- if((theOne = ExtractOneThatFits(&List64, MonoW, MonoH)))
- Num64--;
- }
-
- if(!theOne) break;
-
- ConvertAllPartialsTo8x8(NumMono, NumColor, theOne,
- &MonoList, &ColorList, infoRec);
- }
- }
-
- /* We save all the tiles from the largest bin that we can get
- at least 4 of. If there are too few of a bigger slot, we
- cut it in fourths to make smaller slots. */
-
- if(Num64 >= 4) {
- ListKeepers = List64; List64 = NULL;
- NumKeepers = Num64;
- goto GOT_EM;
- } else if(Num64) {
- List32 = QuadLinks(List64, List32);
- Num32 += Num64 * 4;
- Num64 = 0;
- }
-
- if(Num32 >= 4) {
- ListKeepers = List32; List32 = NULL;
- NumKeepers = Num32;
- goto GOT_EM;
- } else if(Num32) {
- List16 = QuadLinks(List32, List16);
- Num16 += Num32 * 4;
- Num32 = 0;
- }
-
- if(Num16 >= 4) {
- ListKeepers = List16; List16 = NULL;
- NumKeepers = Num16;
- goto GOT_EM;
- } else if(Num16) {
- List8 = QuadLinks(List16, List8);
- Num8 += Num16 * 4;
- Num16 = 0;
- }
-
- if(Num8 >= 4) {
- ListKeepers = List8; List8 = NULL;
- NumKeepers = Num8;
- goto GOT_EM;
- }
-
-GOT_EM:
-
- /* Free the ones we aren't using */
-
- if(List64)
- ConvertAllPartialsTo8x8(NumMono, NumColor, List64,
- &MonoList, &ColorList, infoRec);
- if(List32)
- ConvertAllPartialsTo8x8(NumMono, NumColor, List32,
- &MonoList, &ColorList, infoRec);
- if(List16)
- ConvertAllPartialsTo8x8(NumMono, NumColor, List16,
- &MonoList, &ColorList, infoRec);
- if(List8)
- ConvertAllPartialsTo8x8(NumMono, NumColor, List8,
- &MonoList, &ColorList, infoRec);
-
-
- /* Enlarge the slots if we can */
-
- if(ListKeepers) {
- CacheLinkPtr pLink = ListKeepers;
- Width = Height = 128;
-
- while(pLink) {
- if(pLink->w < Width) Width = pLink->w;
- if(pLink->h < Height) Height = pLink->h;
- pLink = pLink->next;
- }
- }
-
- *ListMono = MonoList;
- *ListColor = ColorList;
- *maxw = Width;
- *maxh = Height;
- *NumPartial = NumKeepers;
- return ListKeepers;
-}
-
-
-void
-XAAInitPixmapCache(
- ScreenPtr pScreen,
- RegionPtr areas,
- pointer data
-) {
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- XAAInfoRecPtr infoRec = (XAAInfoRecPtr)data;
- XAAPixmapCachePrivatePtr pCachePriv;
- BoxPtr pBox = RegionRects(areas);
- int nBox = RegionNumRects(areas);
- int Num512, Num256, Num128, NumPartial, NumColor, NumMono;
- int Target512, Target256;
- CacheLinkPtr List512, List256, List128, ListPartial, ListColor, ListMono;
- int x, y, w, h, ntotal, granularity, width, height, i;
- int MaxPartialWidth, MaxPartialHeight;
-
- infoRec->MaxCacheableTileWidth = 0;
- infoRec->MaxCacheableTileHeight = 0;
- infoRec->MaxCacheableStippleHeight = 0;
- infoRec->MaxCacheableStippleWidth = 0;
- infoRec->UsingPixmapCache = FALSE;
-
-
- if(!nBox || !pBox || !(infoRec->Flags & PIXMAP_CACHE))
- return;
-
- /* Allocate a persistent per-screen init flag to control messages */
- if (CacheInitIndex < 0)
- CacheInitIndex = xf86AllocateScrnInfoPrivateIndex();
-
- /* free the old private data if it exists */
- if(infoRec->PixmapCachePrivate) {
- FreePixmapCachePrivate(
- (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate);
- infoRec->PixmapCachePrivate = NULL;
- }
-
- Num512 = Num256 = Num128 = NumPartial = NumMono = NumColor = 0;
- List512 = List256 = List128 = ListPartial = ListMono = ListColor = NULL;
- granularity = infoRec->CachePixelGranularity;
- if(granularity <= 1) granularity = 0;
-
- /* go through the boxes and break it into as many pieces as we can fit */
-
- while(nBox--) {
- x = pBox->x1;
- if(granularity) {
- int tmp = x % granularity;
- if(tmp) x += (granularity - tmp);
- }
- width = pBox->x2 - x;
- if(width <= 0) {pBox++; continue;}
-
- y = pBox->y1;
- height = pBox->y2 - y;
-
- for(h = 0; h <= (height - 512); h += 512) {
- for(w = 0; w <= (width - 512); w += 512) {
- List512 = Enlist(List512, x + w, y + h, 512, 512);
- Num512++;
- }
- for(; w <= (width - 256); w += 256) {
- List256 = Enlist(List256, x + w, y + h, 256, 256);
- List256 = Enlist(List256, x + w, y + h + 256, 256, 256);
- Num256 += 2;
- }
- for(; w <= (width - 128); w += 128) {
- List128 = Enlist(List128, x + w, y + h, 128, 128);
- List128 = Enlist(List128, x + w, y + h + 128, 128, 128);
- List128 = Enlist(List128, x + w, y + h + 256, 128, 128);
- List128 = Enlist(List128, x + w, y + h + 384, 128, 128);
- Num128 += 4;
- }
- if(w < width) {
- int d = width - w;
- ListPartial = Enlist(ListPartial, x + w, y + h, d, 128);
- ListPartial = Enlist(ListPartial, x + w, y + h + 128, d, 128);
- ListPartial = Enlist(ListPartial, x + w, y + h + 256, d, 128);
- ListPartial = Enlist(ListPartial, x + w, y + h + 384, d, 128);
- NumPartial += 4;
- }
- }
- for(; h <= (height - 256); h += 256) {
- for(w = 0; w <= (width - 256); w += 256) {
- List256 = Enlist(List256, x + w, y + h, 256, 256);
- Num256++;
- }
- for(; w <= (width - 128); w += 128) {
- List128 = Enlist(List128, x + w, y + h, 128, 128);
- List128 = Enlist(List128, x + w, y + h + 128, 128, 128);
- Num128 += 2;
- }
- if(w < width) {
- int d = width - w;
- ListPartial = Enlist(ListPartial, x + w, y + h, d, 128);
- ListPartial = Enlist(ListPartial, x + w, y + h + 128, d, 128);
- NumPartial += 2;
- }
- }
- for(; h <= (height - 128); h += 128) {
- for(w = 0; w <= (width - 128); w += 128) {
- List128 = Enlist(List128, x + w, y + h, 128, 128);
- Num128++;
- }
- if(w < width) {
- ListPartial = Enlist(
- ListPartial, x + w, y + h, width - w, 128);
- NumPartial++;
- }
- }
- if(h < height) {
- int d = height - h;
- for(w = 0; w <= (width - 128); w += 128) {
- ListPartial = Enlist(ListPartial, x + w, y + h, 128, d);
- NumPartial++;
- }
- if(w < width) {
- ListPartial = Enlist(ListPartial, x + w, y + h, width - w, d);
- NumPartial++;
- }
- }
- pBox++;
- }
-
-
-/*
- by this point we've carved the space into as many 512x512, 256x256
- and 128x128 blocks as we could fit. We will then break larger
- blocks into smaller ones if we need to. The rules are as follows:
-
- 512x512 -
- 1) Don't take up more than half the memory.
- 2) Don't bother if you can't get at least four.
- 3) Don't make more than MAX_512.
- 4) Don't have any of there are no 256x256s.
-
- 256x256 -
- 1) Don't take up more than a quarter of the memory enless there
- aren't any 512x512s. Then we can take up to half.
- 2) Don't bother if you can't get at least four.
- 3) Don't make more than MAX_256.
-
- 128x128 -
- 1) Don't make more than MAX_128.
-
- We don't bother with the partial blocks unless we can use them
- for 8x8 pattern fills or we are short on larger blocks.
-
-*/
-
- ntotal = Num128 + (Num256<<2) + (Num512<<4);
-
- Target512 = ntotal >> 5;
- if(Target512 < 4) Target512 = 0;
- if(!Target512) Target256 = ntotal >> 3;
- else Target256 = ntotal >> 4;
- if(Target256 < 4) Target256 = 0;
-
- if(Num512 && Num256 < 4) {
- while(Num512 && Num256 < Target256) {
- SubdivideList(&List512, &List256);
- Num256 += 4; Num512--;
- }
- }
-
- if(!Num512) { /* no room */
- } else if((Num512 < 4) || (!Target512)) {
- while(Num512) {
- SubdivideList(&List512, &List256);
- Num256 += 4; Num512--;
- }
- } else if((Num512 > MAX_512) || (Num512 > Target512)){
- while(Num512 > MAX_512) {
- SubdivideList(&List512, &List256);
- Num256 += 4; Num512--;
- }
- while(Num512 > Target512) {
- if(Num256 < MAX_256) {
- SubdivideList(&List512, &List256);
- Num256 += 4; Num512--;
- } else break;
- }
- }
-
- if(!Num256) { /* no room */
- } else if((Num256 < 4) || (!Target256)) {
- while(Num256) {
- SubdivideList(&List256, &List128);
- Num128 += 4; Num256--;
- }
- } else if((Num256 > MAX_256) || (Num256 > Target256)) {
- while(Num256 > MAX_256) {
- SubdivideList(&List256, &List128);
- Num128 += 4; Num256--;
- }
- while(Num256 > Target256) {
- if(Num128 < MAX_128) {
- SubdivideList(&List256, &List128);
- Num128 += 4; Num256--;
- } else break;
- }
- }
-
- if(Num128 && ((Num128 < 4) || (Num128 > MAX_128))) {
- CacheLinkPtr next;
- int max = (Num128 > MAX_128) ? MAX_128 : 0;
-
- /*
- * Note: next is set in this way to work around a code generation
- * bug in gcc 2.7.2.3.
- */
- next = List128->next;
- while(Num128 > max) {
- List128->next = ListPartial;
- ListPartial = List128;
- if((List128 = next))
- next = List128->next;
- NumPartial++; Num128--;
- }
- }
-
- MaxPartialHeight = MaxPartialWidth = 0;
-
- /* at this point we have as many 512x512 and 256x256 slots as we
- want but may have an excess of 128x128 slots. We still need
- to find out if we need 8x8 slots. We take these from the
- partials if we have them. Otherwise, we break some 128x128's */
-
- if(!(infoRec->PixmapCacheFlags & (CACHE_MONO_8x8 | CACHE_COLOR_8x8))) {
- if(NumPartial) {
- if(Num128) { /* don't bother with partials */
- FreeList(ListPartial);
- NumPartial = 0; ListPartial = NULL;
- } else {
- /* We have no big slots. Weed out the unusable partials */
- ListPartial = ThinOutPartials(ListPartial, &NumPartial,
- &MaxPartialWidth, &MaxPartialHeight);
- }
- }
- } else {
- int MonosPerColor = 1;
- int ColorH = infoRec->CacheHeightColor8x8Pattern;
- int ColorW = infoRec->CacheWidthColor8x8Pattern;
- int MonoH = infoRec->CacheHeightMono8x8Pattern;
- int MonoW = infoRec->CacheWidthMono8x8Pattern;
- Bool DoColor = (infoRec->PixmapCacheFlags & CACHE_COLOR_8x8);
- Bool DoMono = (infoRec->PixmapCacheFlags & CACHE_MONO_8x8);
-
- if(DoColor) infoRec->CanDoColor8x8 = FALSE;
- if(DoMono) infoRec->CanDoMono8x8 = FALSE;
-
- if(DoColor && DoMono) {
- /* we assume color patterns take more space than color ones */
- if(MonoH > ColorH) ColorH = MonoH;
- if(MonoW > ColorW) ColorW = MonoW;
- MonosPerColor = (ColorH/MonoH) * (ColorW/MonoW);
- }
-
- if(Num128) {
- if(NumPartial) { /* use all for 8x8 slots */
- ConvertAllPartialsTo8x8(&NumMono, &NumColor,
- ListPartial, &ListMono, &ListColor, infoRec);
- NumPartial = 0; ListPartial = NULL;
- }
-
- /* Get some 8x8 slots from the 128 slots */
- while((Num128 > 4) &&
- ((NumMono < MAX_MONO) && (NumColor < MAX_COLOR))) {
- CacheLinkPtr tmp = NULL;
-
- tmp = Enlist(tmp, List128->x, List128->y,
- List128->w, List128->h);
- List128 = Delist(List128);
- Num128--;
-
- ConvertAllPartialsTo8x8(&NumMono, &NumColor,
- tmp, &ListMono, &ListColor, infoRec);
- }
- } else if(NumPartial) {
- /* We have share partials between 8x8 slots and tiles. */
- ListPartial = ConvertSomePartialsTo8x8(&NumMono, &NumColor,
- &NumPartial, ListPartial, &ListMono, &ListColor,
- &MaxPartialWidth, &MaxPartialHeight, infoRec);
- }
-
-
- if(DoMono && DoColor) {
- if(NumColor && ((NumColor > MAX_COLOR) || (NumColor < 4))) {
- int max = (NumColor > MAX_COLOR) ? MAX_COLOR : 0;
-
- while(NumColor > max) {
- ConvertColorToMono(&ListColor, ColorW, ColorH,
- &ListMono, MonoW, MonoH);
- NumColor--; NumMono += MonosPerColor;
- }
- }
-
- /* favor Mono slots over Color ones */
- while((NumColor > 4) && (NumMono < MAX_MONO)) {
- ConvertColorToMono(&ListColor, ColorW, ColorH,
- &ListMono, MonoW, MonoH);
- NumColor--; NumMono += MonosPerColor;
- }
- }
-
- if(NumMono && ((NumMono > MAX_MONO) || (NumMono < 4))) {
- int max = (NumMono > MAX_MONO) ? MAX_MONO : 0;
-
- while(NumMono > max) {
- ListMono = Delist(ListMono);
- NumMono--;
- }
- }
- if(NumColor && ((NumColor > MAX_COLOR) || (NumColor < 4))) {
- int max = (NumColor > MAX_COLOR) ? MAX_COLOR : 0;
-
- while(NumColor > max) {
- ListColor = Delist(ListColor);
- NumColor--;
- }
- }
- }
-
-
- pCachePriv = calloc(1,sizeof(XAAPixmapCachePrivate));
- if(!pCachePriv) {
- if(Num512) FreeList(List512);
- if(Num256) FreeList(List256);
- if(Num128) FreeList(List128);
- if(NumPartial) FreeList(ListPartial);
- if(NumColor) FreeList(ListColor);
- if(NumMono) FreeList(ListMono);
- return;
- }
-
- infoRec->PixmapCachePrivate = (char*)pCachePriv;
-
- if(Num512) {
- pCachePriv->Info512 = calloc(Num512,sizeof(XAACacheInfoRec));
- if(!pCachePriv->Info512) Num512 = 0;
- if(Num512) TransferList(List512, pCachePriv->Info512, Num512);
- FreeList(List512);
- pCachePriv->Num512x512 = Num512;
- }
- if(Num256) {
- pCachePriv->Info256 = calloc(Num256, sizeof(XAACacheInfoRec));
- if(!pCachePriv->Info256) Num256 = 0;
- if(Num256) TransferList(List256, pCachePriv->Info256, Num256);
- FreeList(List256);
- pCachePriv->Num256x256 = Num256;
- }
- if(Num128) {
- pCachePriv->Info128 = calloc(Num128, sizeof(XAACacheInfoRec));
- if(!pCachePriv->Info128) Num128 = 0;
- if(Num128) TransferList(List128, pCachePriv->Info128, Num128);
- FreeList(List128);
- pCachePriv->Num128x128 = Num128;
- }
-
- if(NumPartial) {
- pCachePriv->InfoPartial = calloc(NumPartial, sizeof(XAACacheInfoRec));
- if(!pCachePriv->InfoPartial) NumPartial = 0;
- if(NumPartial)
- TransferList(ListPartial, pCachePriv->InfoPartial, NumPartial);
- FreeList(ListPartial);
- pCachePriv->NumPartial = NumPartial;
- }
-
- if(NumColor) {
- pCachePriv->InfoColor = calloc(NumColor, sizeof(XAACacheInfoRec));
- if(!pCachePriv->InfoColor) NumColor = 0;
- if(NumColor) TransferList(ListColor, pCachePriv->InfoColor, NumColor);
- FreeList(ListColor);
- pCachePriv->NumColor = NumColor;
- }
-
- if(NumMono) {
- pCachePriv->InfoMono = calloc(NumMono, sizeof(XAACacheInfoRec));
- if(!pCachePriv->InfoMono) NumMono = 0;
- if(NumMono) TransferList(ListMono, pCachePriv->InfoMono, NumMono);
- FreeList(ListMono);
- pCachePriv->NumMono = NumMono;
- }
-
-
- if(NumPartial) {
- infoRec->MaxCacheableTileWidth = MaxPartialWidth;
- infoRec->MaxCacheableTileHeight = MaxPartialHeight;
- }
- if(Num128)
- infoRec->MaxCacheableTileWidth = infoRec->MaxCacheableTileHeight = 128;
- if(Num256)
- infoRec->MaxCacheableTileWidth = infoRec->MaxCacheableTileHeight = 256;
- if(Num512)
- infoRec->MaxCacheableTileWidth = infoRec->MaxCacheableTileHeight = 512;
-
-
- infoRec->MaxCacheableStippleHeight = infoRec->MaxCacheableTileHeight;
- infoRec->MaxCacheableStippleWidth =
- infoRec->MaxCacheableTileWidth * pScrn->bitsPerPixel;
- if(infoRec->ScreenToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP)
- infoRec->MaxCacheableStippleWidth /= 3;
-
- if(NumMono) {
- if(!(infoRec->Mono8x8PatternFillFlags &
- (HARDWARE_PATTERN_PROGRAMMED_ORIGIN |
- HARDWARE_PATTERN_PROGRAMMED_BITS))) {
- int numPerLine =
- infoRec->CacheWidthMono8x8Pattern/infoRec->MonoPatternPitch;
-
- for(i = 0; i < 64; i++) {
- pCachePriv->MonoOffsets[i].y = i/numPerLine;
- pCachePriv->MonoOffsets[i].x = (i % numPerLine) *
- infoRec->MonoPatternPitch;
- }
- }
- infoRec->CanDoMono8x8 = TRUE;
- }
- if(NumColor) {
- if(!(infoRec->Color8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
-
- for(i = 0; i < 64; i++) {
- pCachePriv->ColorOffsets[i].y = i & 0x07;
- pCachePriv->ColorOffsets[i].x = i & ~0x07;
- }
- }
- infoRec->CanDoColor8x8 = TRUE;
- }
-
- if(!CACHEINIT(pScrn)) {
- xf86ErrorF("\tSetting up tile and stipple cache:\n");
- if(NumPartial)
- xf86ErrorF("\t\t%i %ix%i slots\n",
- NumPartial, MaxPartialWidth, MaxPartialHeight);
- if(Num128) xf86ErrorF("\t\t%i 128x128 slots\n", Num128);
- if(Num256) xf86ErrorF("\t\t%i 256x256 slots\n", Num256);
- if(Num512) xf86ErrorF("\t\t%i 512x512 slots\n", Num512);
- if(NumColor) xf86ErrorF("\t\t%i 8x8 color pattern slots\n", NumColor);
- if(NumMono) xf86ErrorF("\t\t%i 8x8 color expansion slots\n", NumMono);
- }
-
- if(!(NumPartial | Num128 | Num256 | Num512 | NumColor | NumMono)) {
- if(!CACHEINIT(pScrn))
- xf86ErrorF("\t\tNot enough video memory for pixmap cache\n");
- } else infoRec->UsingPixmapCache = TRUE;
-
- CACHEINIT(pScrn) = 1;
-}
-
-#if X_BYTE_ORDER == X_BIG_ENDIAN
-static CARD32 StippleMasks[4] = {
- 0x80808080,
- 0xC0C0C0C0,
- 0x00000000,
- 0xF0F0F0F0
-};
-#else
-static CARD32 StippleMasks[4] = {
- 0x01010101,
- 0x03030303,
- 0x00000000,
- 0x0F0F0F0F
-};
-#endif
-
-Bool
-XAACheckStippleReducibility(PixmapPtr pPixmap)
-{
- XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPixmap);
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_DRAWABLE(&pPixmap->drawable);
- CARD32 *IntPtr = (CARD32*)pPixmap->devPrivate.ptr;
- int w = pPixmap->drawable.width;
- int h = pPixmap->drawable.height;
- int i;
- CARD32 bits[8];
- CARD32 mask = SHIFT_R(0xFFFFFFFF,24);
-
- pPriv->flags |= REDUCIBILITY_CHECKED | REDUCIBLE_TO_2_COLOR;
- pPriv->flags &= ~REDUCIBLE_TO_8x8;
-
- if((w > 32) || (h > 32) || (w & (w - 1)) || (h & (h - 1)))
- return FALSE;
-
- i = (h > 8) ? 8 : h;
-
- switch(w) {
- case 32:
- while(i--) {
- bits[i] = IntPtr[i] & mask;
- if( (bits[i] != SHIFT_R((IntPtr[i] & SHIFT_L(mask, 8)), 8)) ||
- (bits[i] != SHIFT_R((IntPtr[i] & SHIFT_L(mask,16)),16)) ||
- (bits[i] != SHIFT_R((IntPtr[i] & SHIFT_L(mask,24)),24)))
- return FALSE;
- }
- break;
- case 16:
- while(i--) {
- bits[i] = IntPtr[i] & mask;
- if(bits[i] != ((IntPtr[i] & SHIFT_R(SHIFT_L(mask,8),8))))
- return FALSE;
- }
- break;
- default:
- while(i--)
- bits[i] = IntPtr[i] & mask;
- break;
- }
-
- switch(h) {
- case 32:
- if( (IntPtr[8] != IntPtr[16]) || (IntPtr[9] != IntPtr[17]) ||
- (IntPtr[10] != IntPtr[18]) || (IntPtr[11] != IntPtr[19]) ||
- (IntPtr[12] != IntPtr[20]) || (IntPtr[13] != IntPtr[21]) ||
- (IntPtr[14] != IntPtr[22]) || (IntPtr[15] != IntPtr[23]) ||
- (IntPtr[16] != IntPtr[24]) || (IntPtr[17] != IntPtr[25]) ||
- (IntPtr[18] != IntPtr[26]) || (IntPtr[19] != IntPtr[27]) ||
- (IntPtr[20] != IntPtr[28]) || (IntPtr[21] != IntPtr[29]) ||
- (IntPtr[22] != IntPtr[30]) || (IntPtr[23] != IntPtr[31]))
- return FALSE;
- /* fall through */
- case 16:
- if( (IntPtr[0] != IntPtr[8]) || (IntPtr[1] != IntPtr[9]) ||
- (IntPtr[2] != IntPtr[10]) || (IntPtr[3] != IntPtr[11]) ||
- (IntPtr[4] != IntPtr[12]) || (IntPtr[5] != IntPtr[13]) ||
- (IntPtr[6] != IntPtr[14]) || (IntPtr[7] != IntPtr[15]))
- return FALSE;
- case 8: break;
- case 1: bits[1] = bits[0];
- case 2: bits[2] = bits[0]; bits[3] = bits[1];
- case 4: bits[4] = bits[0]; bits[5] = bits[1];
- bits[6] = bits[2]; bits[7] = bits[3];
- break;
- }
-
- pPriv->flags |= REDUCIBLE_TO_8x8;
-
- pPriv->pattern0 = bits[0] | SHIFT_L(bits[1],8) | SHIFT_L(bits[2],16) | SHIFT_L(bits[3],24);
- pPriv->pattern1 = bits[4] | SHIFT_L(bits[5],8) | SHIFT_L(bits[6],16) | SHIFT_L(bits[7],24);
-
- if(w < 8) {
- pPriv->pattern0 &= StippleMasks[w - 1];
- pPriv->pattern1 &= StippleMasks[w - 1];
-
- switch(w) {
- case 1: pPriv->pattern0 |= SHIFT_L(pPriv->pattern0,1);
- pPriv->pattern1 |= SHIFT_L(pPriv->pattern1,1);
- case 2: pPriv->pattern0 |= SHIFT_L(pPriv->pattern0,2);
- pPriv->pattern1 |= SHIFT_L(pPriv->pattern1,2);
- case 4: pPriv->pattern0 |= SHIFT_L(pPriv->pattern0,4);
- pPriv->pattern1 |= SHIFT_L(pPriv->pattern1,4);
- }
- }
-
- if(infoRec->Mono8x8PatternFillFlags & BIT_ORDER_IN_BYTE_MSBFIRST) {
- pPriv->pattern0 = SWAP_BITS_IN_BYTES(pPriv->pattern0);
- pPriv->pattern1 = SWAP_BITS_IN_BYTES(pPriv->pattern1);
- }
-
-
- return TRUE;
-}
-
-
-Bool
-XAACheckTileReducibility(PixmapPtr pPixmap, Bool checkMono)
-{
- XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPixmap);
- CARD32 *IntPtr;
- int w = pPixmap->drawable.width;
- int h = pPixmap->drawable.height;
- int pitch = pPixmap->devKind >> 2;
- int dwords, i, j;
-
- pPriv->flags |= REDUCIBILITY_CHECKED;
- pPriv->flags &= ~(REDUCIBILITY_CHECKED | REDUCIBLE_TO_2_COLOR);
-
- if((w > 32) || (h > 32) || (w & (w - 1)) || (h & (h - 1)))
- return FALSE;
-
- dwords = ((w * pPixmap->drawable.bitsPerPixel) + 31) >> 5;
- i = (h > 8) ? 8 : h;
-
-
- if(w > 8) {
- IntPtr = (CARD32*)pPixmap->devPrivate.ptr;
- switch(pPixmap->drawable.bitsPerPixel) {
- case 8:
- while(i--) {
- for(j = 2; j < dwords; j++)
- if(IntPtr[j] != IntPtr[j & 0x01])
- return FALSE;
- IntPtr += pitch;
- }
- break;
- case 16:
- while(i--) {
- for(j = 4; j < dwords; j++)
- if(IntPtr[j] != IntPtr[j & 0x03])
- return FALSE;
- IntPtr += pitch;
- }
- break;
- case 24:
- while(i--) {
- for(j = 6; j < dwords; j++)
- if(IntPtr[j] != IntPtr[j % 6])
- return FALSE;
- IntPtr += pitch;
- }
- break;
- case 32:
- while(i--) {
- for(j = 8; j < dwords; j++)
- if(IntPtr[j] != IntPtr[j & 0x07])
- return FALSE;
- IntPtr += pitch;
- }
- break;
- default: return FALSE;
- }
-
- }
-
-
- if(h == 32) {
- CARD32 *IntPtr2, *IntPtr3, *IntPtr4;
- i = 8;
- IntPtr = (CARD32*)pPixmap->devPrivate.ptr;
- IntPtr2 = IntPtr + (pitch << 3);
- IntPtr3 = IntPtr2 + (pitch << 3);
- IntPtr4 = IntPtr3 + (pitch << 3);
- while(i--) {
- for(j = 0; j < dwords; j++)
- if((IntPtr[j] != IntPtr2[j]) || (IntPtr[j] != IntPtr3[j]) ||
- (IntPtr[j] != IntPtr4[j]))
- return FALSE;
- IntPtr += pitch;
- IntPtr2 += pitch;
- IntPtr3 += pitch;
- IntPtr4 += pitch;
- }
- } else if (h == 16) {
- CARD32 *IntPtr2;
- i = 8;
- IntPtr = (CARD32*)pPixmap->devPrivate.ptr;
- IntPtr2 = IntPtr + (pitch << 3);
- while(i--) {
- for(j = 0; j < dwords; j++)
- if(IntPtr[j] != IntPtr2[j])
- return FALSE;
- IntPtr += pitch;
- IntPtr2 += pitch;
- }
- }
-
- pPriv->flags |= REDUCIBLE_TO_8x8;
-
- if(checkMono) {
- XAAInfoRecPtr infoRec =
- GET_XAAINFORECPTR_FROM_DRAWABLE(&pPixmap->drawable);
- unsigned char bits[8];
- int fg, bg = -1, x, y;
-
- i = (h > 8) ? 8 : h;
- j = (w > 8) ? 8 : w;
-
- if(pPixmap->drawable.bitsPerPixel == 8) {
- unsigned char *srcp = pPixmap->devPrivate.ptr;
- fg = srcp[0];
- pitch = pPixmap->devKind;
- for(y = 0; y < i; y++) {
- bits[y] = 0;
- for(x = 0; x < j; x++) {
- if(srcp[x] != fg) {
- if(bg == -1) bg = srcp[x];
- else if(bg != srcp[x]) return TRUE;
- } else bits[y] |= 1 << x;
- }
- srcp += pitch;
- }
- } else if(pPixmap->drawable.bitsPerPixel == 16) {
- unsigned short *srcp = (unsigned short*)pPixmap->devPrivate.ptr;
- fg = srcp[0];
- pitch = pPixmap->devKind >> 1;
- for(y = 0; y < i; y++) {
- bits[y] = 0;
- for(x = 0; x < j; x++) {
- if(srcp[x] != fg) {
- if(bg == -1) bg = srcp[x];
- else if(bg != srcp[x]) return TRUE;
- } else bits[y] |= 1 << x;
- }
- srcp += pitch;
- }
- } else if(pPixmap->drawable.bitsPerPixel == 24) {
- CARD32 val;
- unsigned char *srcp = pPixmap->devPrivate.ptr;
- fg = *((CARD32*)srcp) & 0x00FFFFFF;
- pitch = pPixmap->devKind;
- j *= 3;
- for(y = 0; y < i; y++) {
- bits[y] = 0;
- for(x = 0; x < j; x+=3) {
- val = *((CARD32*)(srcp+x)) & 0x00FFFFFF;
- if(val != fg) {
- if(bg == -1) bg = val;
- else if(bg != val)
- return TRUE;
- } else bits[y] |= 1 << (x/3);
- }
- srcp += pitch;
- }
- } else if(pPixmap->drawable.bitsPerPixel == 32) {
- IntPtr = (CARD32*)pPixmap->devPrivate.ptr;
- fg = IntPtr[0];
- for(y = 0; y < i; y++) {
- bits[y] = 0;
- for(x = 0; x < j; x++) {
- if(IntPtr[x] != fg) {
- if(bg == -1) bg = IntPtr[x];
- else if(bg != IntPtr[x]) return TRUE;
- } else bits[y] |= 1 << x;
- }
- IntPtr += pitch;
- }
- } else return TRUE;
-
- pPriv->fg = fg;
- if(bg == -1) pPriv->bg = fg;
- else pPriv->bg = bg;
-
- if(h < 8) {
- switch(h) {
- case 1: bits[1] = bits[0];
- case 2: bits[2] = bits[0]; bits[3] = bits[1];
- case 4: bits[4] = bits[0]; bits[5] = bits[1];
- bits[6] = bits[2]; bits[7] = bits[3];
- break;
- }
- }
-
- pPriv->pattern0 =
- bits[0] | (bits[1]<<8) | (bits[2]<<16) | (bits[3]<<24);
- pPriv->pattern1 =
- bits[4] | (bits[5]<<8) | (bits[6]<<16) | (bits[7]<<24);
-
- if(w < 8) {
- switch(w) {
- case 1: pPriv->pattern0 |= (pPriv->pattern0 << 1);
- pPriv->pattern1 |= (pPriv->pattern1 << 1);
- case 2: pPriv->pattern0 |= (pPriv->pattern0 << 2);
- pPriv->pattern1 |= (pPriv->pattern1 << 2);
- case 4: pPriv->pattern0 |= (pPriv->pattern0 << 4);
- pPriv->pattern1 |= (pPriv->pattern1 << 4);
- }
- }
- pPriv->flags |= REDUCIBLE_TO_2_COLOR;
-
- if(infoRec->Mono8x8PatternFillFlags & BIT_ORDER_IN_BYTE_MSBFIRST) {
- pPriv->pattern0 = SWAP_BITS_IN_BYTES(pPriv->pattern0);
- pPriv->pattern1 = SWAP_BITS_IN_BYTES(pPriv->pattern1);
- }
-
- }
-
- return TRUE;
-}
-
-
-void XAATileCache(
- ScrnInfoPtr pScrn,
- XAACacheInfoPtr pCache,
- int w, int h
-) {
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
-
- (*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, GXcopy, ~0, -1);
-
- while((w << 1) <= pCache->w) {
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn, pCache->x, pCache->y,
- pCache->x + w, pCache->y, w, h);
- w <<= 1;
- }
- if(w != pCache->w) {
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn, pCache->x, pCache->y,
- pCache->x + w, pCache->y, pCache->w - w, h);
- w = pCache->w;
- }
-
- while((h << 1) <= pCache->h) {
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn, pCache->x, pCache->y,
- pCache->x, pCache->y + h, w, h);
- h <<= 1;
- }
- if(h != pCache->h) {
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn, pCache->x, pCache->y,
- pCache->x, pCache->y + h, w, pCache->h - h);
- }
- SET_SYNC_FLAG(infoRec);
-}
-
-XAACacheInfoPtr
-XAACacheTile(ScrnInfoPtr pScrn, PixmapPtr pPix)
-{
- int w = pPix->drawable.width;
- int h = pPix->drawable.height;
- int size = max(w, h);
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- XAAPixmapCachePrivatePtr pCachePriv =
- (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate;
- XAACacheInfoPtr pCache, cacheRoot = NULL;
- int i, max = 0;
- int *current;
-
- if(size <= 128) {
- if(pCachePriv->Info128) {
- cacheRoot = pCachePriv->Info128;
- max = pCachePriv->Num128x128;
- current = &pCachePriv->Current128;
- } else {
- cacheRoot = pCachePriv->InfoPartial;
- max = pCachePriv->NumPartial;
- current = &pCachePriv->CurrentPartial;
- }
- } else if(size <= 256) {
- cacheRoot = pCachePriv->Info256;
- max = pCachePriv->Num256x256;
- current = &pCachePriv->Current256;
- } else if(size <= 512) {
- cacheRoot = pCachePriv->Info512;
- max = pCachePriv->Num512x512;
- current = &pCachePriv->Current512;
- } else { /* something's wrong */
- ErrorF("Something's wrong in XAACacheTile()\n");
- return pCachePriv->Info128;
- }
-
- pCache = cacheRoot;
-
- /* lets look for it */
- for(i = 0; i < max; i++, pCache++) {
- if(pCache->serialNumber == pPix->drawable.serialNumber) {
- pCache->trans_color = -1;
- return pCache;
- }
- }
-
- pCache = &cacheRoot[(*current)++];
- if(*current >= max) *current = 0;
-
- pCache->serialNumber = pPix->drawable.serialNumber;
- pCache->trans_color = pCache->bg = pCache->fg = -1;
- pCache->orig_w = w; pCache->orig_h = h;
- (*infoRec->WritePixmapToCache)(
- pScrn, pCache->x, pCache->y, w, h, pPix->devPrivate.ptr,
- pPix->devKind, pPix->drawable.bitsPerPixel, pPix->drawable.depth);
- if(!(infoRec->PixmapCacheFlags & DO_NOT_TILE_COLOR_DATA) &&
- ((w != pCache->w) || (h != pCache->h)))
- XAATileCache(pScrn, pCache, w, h);
-
- return pCache;
-}
-
-XAACacheInfoPtr
-XAACacheMonoStipple(ScrnInfoPtr pScrn, PixmapPtr pPix)
-{
- int w = pPix->drawable.width;
- int h = pPix->drawable.height;
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- XAAPixmapCachePrivatePtr pCachePriv =
- (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate;
- XAACacheInfoPtr pCache, cacheRoot = NULL;
- int i, max = 0, funcNo, pad, dwords, bpp = pScrn->bitsPerPixel;
- int *current;
- StippleScanlineProcPtr StippleFunc;
- unsigned char *data, *srcPtr, *dstPtr;
-
- if((h <= 128) && (w <= 128 * bpp)) {
- if(pCachePriv->Info128) {
- cacheRoot = pCachePriv->Info128;
- max = pCachePriv->Num128x128;
- current = &pCachePriv->Current128;
- } else {
- cacheRoot = pCachePriv->InfoPartial;
- max = pCachePriv->NumPartial;
- current = &pCachePriv->CurrentPartial;
- }
- } else if((h <= 256) && (w <= 256 * bpp)){
- cacheRoot = pCachePriv->Info256;
- max = pCachePriv->Num256x256;
- current = &pCachePriv->Current256;
- } else if((h <= 512) && (w <= 526 * bpp)){
- cacheRoot = pCachePriv->Info512;
- max = pCachePriv->Num512x512;
- current = &pCachePriv->Current512;
- } else { /* something's wrong */
- ErrorF("Something's wrong in XAACacheMonoStipple()\n");
- return pCachePriv->Info128;
- }
-
- pCache = cacheRoot;
-
- /* lets look for it */
- for(i = 0; i < max; i++, pCache++) {
- if((pCache->serialNumber == pPix->drawable.serialNumber) &&
- (pCache->fg == -1) && (pCache->bg == -1)) {
- pCache->trans_color = -1;
- return pCache;
- }
- }
-
- pCache = &cacheRoot[(*current)++];
- if(*current >= max) *current = 0;
-
- pCache->serialNumber = pPix->drawable.serialNumber;
- pCache->trans_color = pCache->bg = pCache->fg = -1;
- pCache->orig_w = w; pCache->orig_h = h;
-
- if(w <= 32) {
- if(w & (w - 1)) funcNo = 1;
- else funcNo = 0;
- } else funcNo = 2;
-
- pad = BitmapBytePad(pCache->w * bpp);
- dwords = bytes_to_int32(pad);
- dstPtr = data = (unsigned char*)malloc(pad * pCache->h);
- srcPtr = (unsigned char*)pPix->devPrivate.ptr;
-
- if(infoRec->ScreenToScreenColorExpandFillFlags & BIT_ORDER_IN_BYTE_MSBFIRST)
- StippleFunc = XAAStippleScanlineFuncMSBFirst[funcNo];
- else
- StippleFunc = XAAStippleScanlineFuncLSBFirst[funcNo];
-
- /* don't bother generating more than we'll ever use */
- max = ((pScrn->displayWidth + w - 1) + 31) >> 5;
- if(dwords > max)
- dwords = max;
-
- for(i = 0; i < h; i++) {
- (*StippleFunc)((CARD32*)dstPtr, (CARD32*)srcPtr, 0, w, dwords);
- srcPtr += pPix->devKind;
- dstPtr += pad;
- }
-
- while((h<<1) <= pCache->h) {
- memcpy(data + (pad * h), data, pad * h);
- h <<= 1;
- }
-
- if(h < pCache->h)
- memcpy(data + (pad * h), data, pad * (pCache->h - h));
-
- (*infoRec->WritePixmapToCache)(
- pScrn, pCache->x, pCache->y, pCache->w, pCache->h, data,
- pad, bpp, pScrn->depth);
-
- free(data);
-
- return pCache;
-}
-
-XAACacheInfoPtr
-XAACachePlanarMonoStipple(ScrnInfoPtr pScrn, PixmapPtr pPix)
-{
- int w = pPix->drawable.width;
- int h = pPix->drawable.height;
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- XAAPixmapCachePrivatePtr pCachePriv =
- (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate;
- XAACacheInfoPtr pCache, cacheRoot = NULL;
- int i, max = 0;
- int *current;
-
- if((h <= 128) && (w <= 128)) {
- if(pCachePriv->Info128) {
- cacheRoot = pCachePriv->Info128;
- max = pCachePriv->Num128x128;
- current = &pCachePriv->Current128;
- } else {
- cacheRoot = pCachePriv->InfoPartial;
- max = pCachePriv->NumPartial;
- current = &pCachePriv->CurrentPartial;
- }
- } else if((h <= 256) && (w <= 256)){
- cacheRoot = pCachePriv->Info256;
- max = pCachePriv->Num256x256;
- current = &pCachePriv->Current256;
- } else if((h <= 512) && (w <= 526)){
- cacheRoot = pCachePriv->Info512;
- max = pCachePriv->Num512x512;
- current = &pCachePriv->Current512;
- } else { /* something's wrong */
- ErrorF("Something's wrong in XAACachePlanarMonoStipple()\n");
- return pCachePriv->Info128;
- }
-
- pCache = cacheRoot;
-
- /* lets look for it */
- for(i = 0; i < max; i++, pCache++) {
- if((pCache->serialNumber == pPix->drawable.serialNumber) &&
- (pCache->fg == -1) && (pCache->bg == -1)) {
- pCache->trans_color = -1;
- return pCache;
- }
- }
-
- pCache = &cacheRoot[(*current)++];
- if(*current >= max) *current = 0;
-
- pCache->serialNumber = pPix->drawable.serialNumber;
- pCache->trans_color = pCache->bg = pCache->fg = -1;
- pCache->orig_w = w; pCache->orig_h = h;
-
- /* Plane 0 holds the stipple. Plane 1 holds the inverted stipple */
- (*infoRec->WriteBitmapToCache)(pScrn, pCache->x, pCache->y,
- pPix->drawable.width, pPix->drawable.height, pPix->devPrivate.ptr,
- pPix->devKind, 1, 2);
- if(!(infoRec->PixmapCacheFlags & DO_NOT_TILE_MONO_DATA) &&
- ((w != pCache->w) || (h != pCache->h)))
- XAATileCache(pScrn, pCache, w, h);
-
- return pCache;
-}
-
-XAACachePlanarMonoStippleProc
-XAAGetCachePlanarMonoStipple(void)
-{
- return XAACachePlanarMonoStipple;
-}
-
-XAACacheInfoPtr
-XAACacheStipple(ScrnInfoPtr pScrn, PixmapPtr pPix, int fg, int bg)
-{
- int w = pPix->drawable.width;
- int h = pPix->drawable.height;
- int size = max(w, h);
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- XAAPixmapCachePrivatePtr pCachePriv =
- (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate;
- XAACacheInfoPtr pCache, cacheRoot = NULL;
- int i, max = 0;
- int *current;
-
- if(size <= 128) {
- if(pCachePriv->Info128) {
- cacheRoot = pCachePriv->Info128;
- max = pCachePriv->Num128x128;
- current = &pCachePriv->Current128;
- } else {
- cacheRoot = pCachePriv->InfoPartial;
- max = pCachePriv->NumPartial;
- current = &pCachePriv->CurrentPartial;
- }
- } else if(size <= 256) {
- cacheRoot = pCachePriv->Info256;
- max = pCachePriv->Num256x256;
- current = &pCachePriv->Current256;
- } else if(size <= 512) {
- cacheRoot = pCachePriv->Info512;
- max = pCachePriv->Num512x512;
- current = &pCachePriv->Current512;
- } else { /* something's wrong */
- ErrorF("Something's wrong in XAACacheStipple()\n");
- return pCachePriv->Info128;
- }
-
- pCache = cacheRoot;
- /* lets look for it */
- if(bg == -1)
- for(i = 0; i < max; i++, pCache++) {
- if((pCache->serialNumber == pPix->drawable.serialNumber) &&
- (fg == pCache->fg) && (pCache->fg != pCache->bg)) {
- pCache->trans_color = pCache->bg;
- return pCache;
- }
- }
- else
- for(i = 0; i < max; i++, pCache++) {
- if((pCache->serialNumber == pPix->drawable.serialNumber) &&
- (fg == pCache->fg) && (bg == pCache->bg)) {
- pCache->trans_color = -1;
- return pCache;
- }
- }
-
- pCache = &cacheRoot[(*current)++];
- if(*current >= max) *current = 0;
-
- pCache->serialNumber = pPix->drawable.serialNumber;
- pCache->fg = fg;
- if(bg == -1)
- pCache->trans_color = bg = fg ^ 1;
- else
- pCache->trans_color = -1;
- pCache->bg = bg;
-
- pCache->orig_w = w; pCache->orig_h = h;
- (*infoRec->WriteBitmapToCache)(pScrn, pCache->x, pCache->y,
- pPix->drawable.width, pPix->drawable.height, pPix->devPrivate.ptr,
- pPix->devKind, fg, bg);
- if(!(infoRec->PixmapCacheFlags & DO_NOT_TILE_COLOR_DATA) &&
- ((w != pCache->w) || (h != pCache->h)))
- XAATileCache(pScrn, pCache, w, h);
-
- return pCache;
-}
-
-
-
-XAACacheInfoPtr
-XAACacheMono8x8Pattern(ScrnInfoPtr pScrn, int pat0, int pat1)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- XAAPixmapCachePrivatePtr pCachePriv =
- (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate;
- XAACacheInfoPtr pCache = pCachePriv->InfoMono;
- int i;
-
- for(i = 0; i < pCachePriv->NumMono; i++, pCache++) {
- if(pCache->serialNumber &&
- (pCache->pat0 == pat0) && (pCache->pat1 == pat1))
- return pCache;
- }
-
- /* OK, let's cache it */
- pCache = &pCachePriv->InfoMono[pCachePriv->CurrentMono++];
- if(pCachePriv->CurrentMono >= pCachePriv->NumMono)
- pCachePriv->CurrentMono = 0;
-
- pCache->serialNumber = 1; /* we don't care since we do lookups by pattern */
- pCache->pat0 = pat0;
- pCache->pat1 = pat1;
-
- (*infoRec->WriteMono8x8PatternToCache)(pScrn, pCache);
-
- return pCache;
-}
-
-
-
-XAACacheInfoPtr
-XAACacheColor8x8Pattern(ScrnInfoPtr pScrn, PixmapPtr pPix, int fg, int bg)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- XAAPixmapCachePrivatePtr pCachePriv =
- (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate;
- XAACacheInfoPtr pCache = pCachePriv->InfoColor;
- XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
- int i;
-
- if(!(pixPriv->flags & REDUCIBLE_TO_2_COLOR)) {
- for(i = 0; i < pCachePriv->NumColor; i++, pCache++) {
- if(pCache->serialNumber == pPix->drawable.serialNumber) {
- pCache->trans_color = -1;
- return pCache;
- }
- }
- pCache = &pCachePriv->InfoColor[pCachePriv->CurrentColor++];
- if(pCachePriv->CurrentColor >= pCachePriv->NumColor)
- pCachePriv->CurrentColor = 0;
-
- pCache->serialNumber = pPix->drawable.serialNumber;
- pCache->trans_color = pCache->fg = pCache->bg = -1;
- } else {
- int pat0 = pixPriv->pattern0;
- int pat1 = pixPriv->pattern1;
-
- if(fg == -1) { /* it's a tile */
- fg = pixPriv->fg; bg = pixPriv->bg;
- }
-
- if(bg == -1) { /* stipple */
- for(i = 0; i < pCachePriv->NumColor; i++, pCache++) {
- if(pCache->serialNumber &&
- (pCache->pat0 == pat0) && (pCache->pat1 == pat1) &&
- (pCache->fg == fg) && (pCache->bg != fg)) {
- pCache->trans_color = pCache->bg;
- return pCache;
- }
- }
- } else { /* opaque stipple */
- for(i = 0; i < pCachePriv->NumColor; i++, pCache++) {
- if(pCache->serialNumber &&
- (pCache->pat0 == pat0) && (pCache->pat1 == pat1) &&
- (pCache->fg == fg) && (pCache->bg == bg)) {
- pCache->trans_color = -1;
- return pCache;
- }
- }
- }
- pCache = &pCachePriv->InfoColor[pCachePriv->CurrentColor++];
- if(pCachePriv->CurrentColor >= pCachePriv->NumColor)
- pCachePriv->CurrentColor = 0;
-
- if(bg == -1)
- pCache->trans_color = bg = fg ^ 1;
- else
- pCache->trans_color = -1;
-
- pCache->pat0 = pat0; pCache->pat1 = pat1;
- pCache->fg = fg; pCache->bg = bg;
- pCache->serialNumber = 1;
- }
-
- (*infoRec->WriteColor8x8PatternToCache)(pScrn, pPix, pCache);
-
- return pCache;
-}
-
-
-void
-XAAWriteBitmapToCache(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int fg, int bg
-) {
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
-
- (*infoRec->WriteBitmap)(pScrn, x, y, w, h, src, srcwidth,
- 0, fg, bg, GXcopy, ~0);
-}
-
-void
-XAAWriteBitmapToCacheLinear(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int fg, int bg
-){
- ScreenPtr pScreen = pScrn->pScreen;
- PixmapPtr pScreenPix, pDstPix;
- ChangeGCVal gcvals[2];
- GCPtr pGC;
-
- pScreenPix = (*pScreen->GetScreenPixmap)(pScreen);
-
- pDstPix = GetScratchPixmapHeader(pScreen, pScreenPix->drawable.width,
- y + h, pScreenPix->drawable.depth,
- pScreenPix->drawable.bitsPerPixel,
- pScreenPix->devKind,
- pScreenPix->devPrivate.ptr);
-
- pGC = GetScratchGC(pScreenPix->drawable.depth, pScreen);
- gcvals[0].val = fg;
- gcvals[1].val = bg;
- ChangeGC(NullClient, pGC, GCForeground | GCBackground, gcvals);
- ValidateGC((DrawablePtr)pDstPix, pGC);
-
- /* We've unwrapped already so these ops miss a sync */
- SYNC_CHECK(pScrn);
-
- (*pGC->ops->PutImage)((DrawablePtr)pDstPix, pGC, 1, x, y, w, h, 0,
- XYBitmap, (pointer)src);
-
- FreeScratchGC(pGC);
- FreeScratchPixmapHeader(pDstPix);
-}
-
-
-void
-XAAWritePixmapToCache(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int bpp, int depth
-) {
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
-
- (*infoRec->WritePixmap)(pScrn, x, y, w, h, src, srcwidth,
- GXcopy, ~0, -1, bpp, depth);
-}
-
-
-
-void
-XAAWritePixmapToCacheLinear(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int bpp, int depth
-){
- ScreenPtr pScreen = pScrn->pScreen;
- PixmapPtr pScreenPix, pDstPix;
- GCPtr pGC;
-
- pScreenPix = (*pScreen->GetScreenPixmap)(pScreen);
-
- pDstPix = GetScratchPixmapHeader(pScreen, x + w, y + h,
- depth, bpp, pScreenPix->devKind,
- pScreenPix->devPrivate.ptr);
-
- pGC = GetScratchGC(depth, pScreen);
- ValidateGC((DrawablePtr)pDstPix, pGC);
-
- /* We've unwrapped already so these ops miss a sync */
- SYNC_CHECK(pScrn);
-
- if(bpp == BitsPerPixel(depth))
- (*pGC->ops->PutImage)((DrawablePtr)pDstPix, pGC, depth, x, y, w,
- h, 0, ZPixmap, (pointer)src);
- else {
- PixmapPtr pSrcPix;
-
- pSrcPix = GetScratchPixmapHeader(pScreen, w, h, depth, bpp,
- srcwidth, (pointer)src);
-
- (*pGC->ops->CopyArea)((DrawablePtr)pSrcPix, (DrawablePtr)pDstPix,
- pGC, 0, 0, w, h, x, y);
-
- FreeScratchPixmapHeader(pSrcPix);
- }
-
- FreeScratchGC(pGC);
- FreeScratchPixmapHeader(pDstPix);
-}
-
-
-void
-XAAWriteMono8x8PatternToCache(
- ScrnInfoPtr pScrn,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- XAAPixmapCachePrivatePtr pCachePriv =
- (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate;
- unsigned char *data;
- int pad, Bpp = (pScrn->bitsPerPixel >> 3);
-
- pCache->offsets = pCachePriv->MonoOffsets;
-
- pad = BitmapBytePad(pCache->w * pScrn->bitsPerPixel);
-
- data = (unsigned char*)malloc(pad * pCache->h);
- if(!data) return;
-
- if(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_ORIGIN) {
- CARD32* ptr = (CARD32*)data;
- ptr[0] = pCache->pat0; ptr[1] = pCache->pat1;
- } else {
- CARD32 *ptr;
- DDXPointPtr pPoint = pCache->offsets;
- int patx, paty, i;
-
- for(i = 0; i < 64; i++, pPoint++) {
- patx = pCache->pat0; paty = pCache->pat1;
- XAARotateMonoPattern(&patx, &paty, i & 0x07, i >> 3,
- (infoRec->Mono8x8PatternFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST));
- ptr = (CARD32*)(data + (pad * pPoint->y) + (Bpp * pPoint->x));
- ptr[0] = patx; ptr[1] = paty;
- }
- }
-
- (*infoRec->WritePixmapToCache)(pScrn, pCache->x, pCache->y,
- pCache->w, pCache->h, data, pad, pScrn->bitsPerPixel, pScrn->depth);
-
- free(data);
-}
-
-void
-XAAWriteColor8x8PatternToCache(
- ScrnInfoPtr pScrn,
- PixmapPtr pPix,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
- XAAPixmapCachePrivatePtr pCachePriv =
- (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate;
- int pad, i, w, h, nw, nh, Bpp;
- unsigned char *data, *srcPtr, *dstPtr;
-
- pCache->offsets = pCachePriv->ColorOffsets;
-
- if(pixPriv->flags & REDUCIBLE_TO_2_COLOR) {
- CARD32* ptr;
- pad = BitmapBytePad(pCache->w);
- data = (unsigned char*)malloc(pad * pCache->h);
- if(!data) return;
-
- if(infoRec->Color8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN) {
- ptr = (CARD32*)data;
- ptr[0] = pCache->pat0; ptr[1] = pCache->pat1;
- } else {
- int patx, paty;
-
- ptr = (CARD32*)data;
- ptr[0] = ptr[2] = pCache->pat0; ptr[1] = ptr[3] = pCache->pat1;
- for(i = 1; i < 8; i++) {
- patx = pCache->pat0; paty = pCache->pat1;
- XAARotateMonoPattern(&patx, &paty, i, 0,
- (infoRec->Mono8x8PatternFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST));
- ptr = (CARD32*)(data + (pad * i));
- ptr[0] = ptr[2] = patx; ptr[1] = ptr[3] = paty;
- }
- }
-
- (*infoRec->WriteBitmapToCache)(pScrn, pCache->x, pCache->y,
- pCache->w, pCache->h, data, pad, pCache->fg, pCache->bg);
-
- free(data);
- return;
- }
-
- Bpp = pScrn->bitsPerPixel >> 3;
- h = min(8,pPix->drawable.height);
- w = min(8,pPix->drawable.width);
- pad = BitmapBytePad(pCache->w * pScrn->bitsPerPixel);
-
- data = (unsigned char*)malloc(pad * pCache->h);
- if(!data) return;
-
- /* Write and expand horizontally. */
- for (i = h, dstPtr = data, srcPtr = pPix->devPrivate.ptr; i--;
- srcPtr += pPix->devKind, dstPtr += pScrn->bitsPerPixel) {
- nw = w;
- memcpy(dstPtr, srcPtr, w * Bpp);
- while (nw != 8) {
- memcpy(dstPtr + (nw * Bpp), dstPtr, nw * Bpp);
- nw <<= 1;
- }
- }
- nh = h;
- /* Expand vertically. */
- while (nh != 8) {
- memcpy(data + (nh*pScrn->bitsPerPixel), data, nh*pScrn->bitsPerPixel);
- nh <<= 1;
- }
-
- if(!(infoRec->Color8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- int j;
- unsigned char *ptr = data + (128 * Bpp);
-
- memcpy(data + (64 * Bpp), data, 64 * Bpp);
- for(i = 1; i < 8; i++, ptr += (128 * Bpp)) {
- for(j = 0; j < 8; j++) {
- memcpy(ptr + (j * 8) * Bpp, data + (j * 8 + i) * Bpp,
- (8 - i) * Bpp);
- memcpy(ptr + (j * 8 + 8 - i) * Bpp, data + j * 8 * Bpp, i*Bpp);
- }
- memcpy(ptr + (64 * Bpp), ptr, 64 * Bpp);
- }
- }
-
- (*infoRec->WritePixmapToCache)(pScrn, pCache->x, pCache->y,
- pCache->w, pCache->h, data, pad, pScrn->bitsPerPixel, pScrn->depth);
-
- free(data);
-}
-
-
-
-int
-XAAStippledFillChooser(GCPtr pGC)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- PixmapPtr pPixmap = pGC->stipple;
- XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPixmap);
-
- if(!(pPriv->flags & REDUCIBILITY_CHECKED) &&
- (infoRec->CanDoMono8x8 || infoRec->CanDoColor8x8)) {
- XAACheckStippleReducibility(pPixmap);
- }
-
-
- if(pPriv->flags & REDUCIBLE_TO_8x8) {
- if(infoRec->CanDoMono8x8 &&
- !(infoRec->FillMono8x8PatternSpansFlags & NO_TRANSPARENCY) &&
- ((pGC->alu == GXcopy) || !(infoRec->FillMono8x8PatternSpansFlags &
- TRANSPARENCY_GXCOPY_ONLY)) &&
- CHECK_ROP(pGC,infoRec->FillMono8x8PatternSpansFlags) &&
- CHECK_ROPSRC(pGC,infoRec->FillMono8x8PatternSpansFlags) &&
- CHECK_FG(pGC,infoRec->FillMono8x8PatternSpansFlags) &&
- CHECK_PLANEMASK(pGC,infoRec->FillMono8x8PatternSpansFlags)) {
-
- return DO_MONO_8x8;
- }
-
- if(infoRec->CanDoColor8x8 &&
- !(infoRec->FillColor8x8PatternSpansFlags & NO_TRANSPARENCY) &&
- ((pGC->alu == GXcopy) || !(infoRec->FillColor8x8PatternSpansFlags &
- TRANSPARENCY_GXCOPY_ONLY)) &&
- CHECK_ROP(pGC,infoRec->FillColor8x8PatternSpansFlags) &&
- CHECK_ROPSRC(pGC,infoRec->FillColor8x8PatternSpansFlags) &&
- CHECK_PLANEMASK(pGC,infoRec->FillColor8x8PatternSpansFlags)) {
-
- return DO_COLOR_8x8;
- }
- }
-
- if(infoRec->UsingPixmapCache && infoRec->FillCacheExpandSpans &&
- (pPixmap->drawable.height <= infoRec->MaxCacheableStippleHeight) &&
- (pPixmap->drawable.width <= infoRec->MaxCacheableStippleWidth /
- infoRec->CacheColorExpandDensity) &&
- !(infoRec->FillCacheExpandSpansFlags & NO_TRANSPARENCY) &&
- ((pGC->alu == GXcopy) || !(infoRec->FillCacheExpandSpansFlags &
- TRANSPARENCY_GXCOPY_ONLY)) &&
- CHECK_ROP(pGC,infoRec->FillCacheExpandSpansFlags) &&
- CHECK_ROPSRC(pGC,infoRec->FillCacheExpandSpansFlags) &&
- CHECK_FG(pGC,infoRec->FillCacheExpandSpansFlags) &&
- CHECK_PLANEMASK(pGC,infoRec->FillCacheExpandSpansFlags)) {
-
- return DO_CACHE_EXPAND;
- }
-
-
- if(infoRec->UsingPixmapCache &&
- !(infoRec->PixmapCacheFlags & DO_NOT_BLIT_STIPPLES) &&
- infoRec->FillCacheBltSpans &&
- (pPixmap->drawable.height <= infoRec->MaxCacheableTileHeight) &&
- (pPixmap->drawable.width <= infoRec->MaxCacheableTileWidth) &&
- !(infoRec->FillCacheBltSpansFlags & NO_TRANSPARENCY) &&
- ((pGC->alu == GXcopy) || !(infoRec->FillCacheBltSpansFlags &
- TRANSPARENCY_GXCOPY_ONLY)) &&
- CHECK_ROP(pGC,infoRec->FillCacheBltSpansFlags) &&
- CHECK_ROPSRC(pGC,infoRec->FillCacheBltSpansFlags) &&
- CHECK_PLANEMASK(pGC,infoRec->FillCacheBltSpansFlags)) {
-
- return DO_CACHE_BLT;
- }
-
- if(infoRec->FillColorExpandSpans &&
- !(infoRec->FillColorExpandSpansFlags & NO_TRANSPARENCY) &&
- ((pGC->alu == GXcopy) || !(infoRec->FillColorExpandSpansFlags &
- TRANSPARENCY_GXCOPY_ONLY)) &&
- CHECK_ROP(pGC,infoRec->FillColorExpandSpansFlags) &&
- CHECK_ROPSRC(pGC,infoRec->FillColorExpandSpansFlags) &&
- CHECK_FG(pGC,infoRec->FillColorExpandSpansFlags) &&
- CHECK_PLANEMASK(pGC,infoRec->FillColorExpandSpansFlags)) {
-
- return DO_COLOR_EXPAND;
- }
-
- return 0;
-}
-
-
-int
-XAAOpaqueStippledFillChooser(GCPtr pGC)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- PixmapPtr pPixmap = pGC->stipple;
- XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPixmap);
-
- if(XAA_DEPTH_BUG(pGC))
- return 0;
-
- if(!(pPriv->flags & REDUCIBILITY_CHECKED) &&
- (infoRec->CanDoMono8x8 || infoRec->CanDoColor8x8)) {
- XAACheckStippleReducibility(pPixmap);
- }
-
- if(pPriv->flags & REDUCIBLE_TO_8x8) {
- if(infoRec->CanDoMono8x8 &&
- !(infoRec->FillMono8x8PatternSpansFlags & TRANSPARENCY_ONLY) &&
- CHECK_ROP(pGC,infoRec->FillMono8x8PatternSpansFlags) &&
- CHECK_ROPSRC(pGC,infoRec->FillMono8x8PatternSpansFlags) &&
- CHECK_COLORS(pGC,infoRec->FillMono8x8PatternSpansFlags) &&
- CHECK_PLANEMASK(pGC,infoRec->FillMono8x8PatternSpansFlags)) {
-
- return DO_MONO_8x8;
- }
-
- if(infoRec->CanDoColor8x8 &&
- CHECK_ROP(pGC,infoRec->FillColor8x8PatternSpansFlags) &&
- CHECK_ROPSRC(pGC,infoRec->FillColor8x8PatternSpansFlags) &&
- CHECK_PLANEMASK(pGC,infoRec->FillColor8x8PatternSpansFlags)) {
-
- return DO_COLOR_8x8;
- }
- }
-
- if(infoRec->UsingPixmapCache && infoRec->FillCacheExpandSpans &&
- (pPixmap->drawable.height <= infoRec->MaxCacheableStippleHeight) &&
- (pPixmap->drawable.width <= infoRec->MaxCacheableStippleWidth /
- infoRec->CacheColorExpandDensity) &&
- !(infoRec->FillCacheExpandSpansFlags & TRANSPARENCY_ONLY) &&
- CHECK_ROP(pGC,infoRec->FillCacheExpandSpansFlags) &&
- CHECK_ROPSRC(pGC,infoRec->FillCacheExpandSpansFlags) &&
- CHECK_COLORS(pGC,infoRec->FillCacheExpandSpansFlags) &&
- CHECK_PLANEMASK(pGC,infoRec->FillCacheExpandSpansFlags)) {
-
- return DO_CACHE_EXPAND;
- }
-
- if(infoRec->UsingPixmapCache &&
- !(infoRec->PixmapCacheFlags & DO_NOT_BLIT_STIPPLES) &&
- infoRec->FillCacheBltSpans &&
- (pPixmap->drawable.height <= infoRec->MaxCacheableTileHeight) &&
- (pPixmap->drawable.width <= infoRec->MaxCacheableTileWidth) &&
- CHECK_ROP(pGC,infoRec->FillCacheBltSpansFlags) &&
- CHECK_ROPSRC(pGC,infoRec->FillCacheBltSpansFlags) &&
- CHECK_PLANEMASK(pGC,infoRec->FillCacheBltSpansFlags)) {
-
- return DO_CACHE_BLT;
- }
-
- if(infoRec->FillColorExpandSpans &&
- !(infoRec->FillColorExpandSpansFlags & TRANSPARENCY_ONLY) &&
- CHECK_ROP(pGC,infoRec->FillColorExpandSpansFlags) &&
- CHECK_ROPSRC(pGC,infoRec->FillColorExpandSpansFlags) &&
- CHECK_COLORS(pGC,infoRec->FillColorExpandSpansFlags) &&
- CHECK_PLANEMASK(pGC,infoRec->FillColorExpandSpansFlags)) {
-
- return DO_COLOR_EXPAND;
- }
-
- return 0;
-}
-
-
-
-int
-XAATiledFillChooser(GCPtr pGC)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- PixmapPtr pPixmap = pGC->tile.pixmap;
- XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPixmap);
-
- if(IS_OFFSCREEN_PIXMAP(pPixmap) && infoRec->FillCacheBltSpans &&
- CHECK_ROP(pGC,infoRec->FillCacheBltSpansFlags) &&
- CHECK_ROPSRC(pGC,infoRec->FillCacheBltSpansFlags) &&
- CHECK_PLANEMASK(pGC,infoRec->FillCacheBltSpansFlags)) {
-
- return DO_PIXMAP_COPY;
- }
-
- if(!(pPriv->flags & REDUCIBILITY_CHECKED) &&
- (infoRec->CanDoMono8x8 || infoRec->CanDoColor8x8)) {
- XAACheckTileReducibility(pPixmap,infoRec->CanDoMono8x8);
- }
-
- if(pPriv->flags & REDUCIBLE_TO_8x8) {
- if((pPriv->flags & REDUCIBLE_TO_2_COLOR) && infoRec->CanDoMono8x8 &&
- !(infoRec->FillMono8x8PatternSpansFlags & TRANSPARENCY_ONLY) &&
- CHECK_ROP(pGC,infoRec->FillMono8x8PatternSpansFlags) &&
- CHECK_ROPSRC(pGC,infoRec->FillMono8x8PatternSpansFlags) &&
- (!(infoRec->FillMono8x8PatternSpansFlags & RGB_EQUAL) ||
- (CHECK_RGB_EQUAL(pPriv->fg) && CHECK_RGB_EQUAL(pPriv->bg))) &&
- CHECK_PLANEMASK(pGC,infoRec->FillMono8x8PatternSpansFlags)) {
-
- return DO_MONO_8x8;
- }
-
- if(infoRec->CanDoColor8x8 &&
- CHECK_ROP(pGC,infoRec->FillColor8x8PatternSpansFlags) &&
- CHECK_ROPSRC(pGC,infoRec->FillColor8x8PatternSpansFlags) &&
- CHECK_PLANEMASK(pGC,infoRec->FillColor8x8PatternSpansFlags)) {
-
- return DO_COLOR_8x8;
- }
- }
-
- if(infoRec->UsingPixmapCache && infoRec->FillCacheBltSpans &&
- (pPixmap->drawable.height <= infoRec->MaxCacheableTileHeight) &&
- (pPixmap->drawable.width <= infoRec->MaxCacheableTileWidth) &&
- CHECK_ROP(pGC,infoRec->FillCacheBltSpansFlags) &&
- CHECK_ROPSRC(pGC,infoRec->FillCacheBltSpansFlags) &&
- CHECK_PLANEMASK(pGC,infoRec->FillCacheBltSpansFlags)) {
-
- return DO_CACHE_BLT;
- }
-
- if(infoRec->FillImageWriteRects &&
- CHECK_NO_GXCOPY(pGC,infoRec->FillImageWriteRectsFlags) &&
- CHECK_ROP(pGC,infoRec->FillImageWriteRectsFlags) &&
- CHECK_ROPSRC(pGC,infoRec->FillImageWriteRectsFlags) &&
- CHECK_PLANEMASK(pGC,infoRec->FillImageWriteRectsFlags)) {
-
- return DO_IMAGE_WRITE;
- }
-
- return 0;
-}
-
-
-static int RotateMasksX[8] = {
- 0xFFFFFFFF, 0x7F7F7F7F, 0x3F3F3F3F, 0x1F1F1F1F,
- 0x0F0F0F0F, 0x07070707, 0x03030303, 0x01010101
-};
-
-static int RotateMasksY[4] = {
- 0xFFFFFFFF, 0x00FFFFFF, 0x0000FFFF, 0x000000FF
-};
-
-void
-XAARotateMonoPattern(
- int *pat0, int *pat1,
- int xorg, int yorg,
- Bool msbfirst
-){
- int tmp, mask;
-
- if(xorg) {
- if(msbfirst) xorg = 8 - xorg;
- mask = RotateMasksX[xorg];
- *pat0 = ((*pat0 >> xorg) & mask) | ((*pat0 << (8 - xorg)) & ~mask);
- *pat1 = ((*pat1 >> xorg) & mask) | ((*pat1 << (8 - xorg)) & ~mask);
- }
- if(yorg >= 4) {
- tmp = *pat0; *pat0 = *pat1; *pat1 = tmp;
- yorg -= 4;
- }
- if(yorg) {
- mask = RotateMasksY[yorg];
- yorg <<= 3;
- tmp = *pat0;
- *pat0 = ((*pat0 >> yorg) & mask) | ((*pat1 << (32 - yorg)) & ~mask);
- *pat1 = ((*pat1 >> yorg) & mask) | ((tmp << (32 - yorg)) & ~mask);
- }
-}
-
-
-
-void
-XAAInvalidatePixmapCache(ScreenPtr pScreen)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
- XAAPixmapCachePrivatePtr pCachePriv =
- (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate;
- int i;
-
- if(!pCachePriv) return;
-
- for(i = 0; i < pCachePriv->Num512x512; i++)
- (pCachePriv->Info512)[i].serialNumber = 0;
- for(i = 0; i < pCachePriv->Num256x256; i++)
- (pCachePriv->Info256)[i].serialNumber = 0;
- for(i = 0; i < pCachePriv->Num128x128; i++)
- (pCachePriv->Info128)[i].serialNumber = 0;
- for(i = 0; i < pCachePriv->NumPartial; i++)
- (pCachePriv->InfoPartial)[i].serialNumber = 0;
- for(i = 0; i < pCachePriv->NumMono; i++)
- (pCachePriv->InfoMono)[i].serialNumber = 0;
- for(i = 0; i < pCachePriv->NumColor; i++)
- (pCachePriv->InfoColor)[i].serialNumber = 0;
-}
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <string.h>
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "gc.h"
+#include "mi.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "regionstr.h"
+#include "servermd.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaacexp.h"
+#include "xaalocal.h"
+#include "xaawrap.h"
+
+#define MAX_COLOR 32
+#define MAX_MONO 32
+#define MAX_8 32
+#define MAX_128 32
+#define MAX_256 32
+#define MAX_512 16
+
+static int CacheInitIndex = -1;
+
+#define CACHEINIT(p) ((p)->privates[CacheInitIndex].val)
+
+typedef struct _CacheLink {
+ int x;
+ int y;
+ int w;
+ int h;
+ struct _CacheLink *next;
+} CacheLink, *CacheLinkPtr;
+
+static void
+TransferList(CacheLinkPtr list, XAACacheInfoPtr array, int num)
+{
+ while (num--) {
+ array->x = list->x;
+ array->y = list->y;
+ array->w = list->w;
+ array->h = list->h;
+ array->serialNumber = 0;
+ array->fg = array->bg = -1;
+ list = list->next;
+ array++;
+ }
+}
+
+static CacheLinkPtr
+Enlist(CacheLinkPtr link, int x, int y, int w, int h)
+{
+ CacheLinkPtr newLink;
+
+ newLink = malloc(sizeof(CacheLink));
+ newLink->next = link;
+ newLink->x = x;
+ newLink->y = y;
+ newLink->w = w;
+ newLink->h = h;
+ return newLink;
+}
+
+static CacheLinkPtr
+Delist(CacheLinkPtr link)
+{
+ CacheLinkPtr ret = NULL;
+
+ if (link) {
+ ret = link->next;
+ free(link);
+ }
+ return ret;
+}
+
+static void
+FreeList(CacheLinkPtr link)
+{
+ CacheLinkPtr tmp;
+
+ while (link) {
+ tmp = link;
+ link = link->next;
+ free(tmp);
+ }
+}
+
+static CacheLinkPtr
+QuadLinks(CacheLinkPtr big, CacheLinkPtr little)
+{
+ /* CAUTION: This doesn't free big */
+ int w1, w2, h1, h2;
+
+ while (big) {
+ w1 = big->w >> 1;
+ w2 = big->w - w1;
+ h1 = big->h >> 1;
+ h2 = big->h - h1;
+
+ little = Enlist(little, big->x, big->y, w1, h1);
+ little = Enlist(little, big->x + w1, big->y, w2, h1);
+ little = Enlist(little, big->x, big->y + h1, w1, h2);
+ little = Enlist(little, big->x + w1, big->y + h1, w2, h2);
+
+ big = big->next;
+ }
+ return little;
+}
+
+static void
+SubdivideList(CacheLinkPtr * large, CacheLinkPtr * small)
+{
+ CacheLinkPtr big = *large;
+ CacheLinkPtr little = *small;
+ int size = big->w >> 1;
+
+ little = Enlist(little, big->x, big->y, size, size);
+ little = Enlist(little, big->x + size, big->y, size, size);
+ little = Enlist(little, big->x, big->y + size, size, size);
+ little = Enlist(little, big->x + size, big->y + size, size, size);
+ *small = little;
+ big = Delist(big);
+ *large = big;
+}
+
+static void
+FreePixmapCachePrivate(XAAPixmapCachePrivatePtr pPriv)
+{
+ if (!pPriv)
+ return;
+
+ free(pPriv->Info512);
+ free(pPriv->Info256);
+ free(pPriv->Info128);
+ free(pPriv->InfoColor);
+ free(pPriv->InfoMono);
+ free(pPriv->InfoPartial);
+
+ free(pPriv);
+}
+
+void
+XAAClosePixmapCache(ScreenPtr pScreen)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+
+ if (infoRec->PixmapCachePrivate)
+ FreePixmapCachePrivate((XAAPixmapCachePrivatePtr) infoRec->
+ PixmapCachePrivate);
+
+ infoRec->PixmapCachePrivate = NULL;
+}
+
+static CacheLinkPtr
+ThinOutPartials(CacheLinkPtr ListPartial, int *num, int *maxw, int *maxh)
+{
+/* This guy's job is to get at least 4 big slots out of a list of fragments */
+
+ CacheLinkPtr List64, List32, List16, List8, pCur, next, ListKeepers;
+ int Num64, Num32, Num16, Num8, NumKeepers;
+ int w, h;
+
+ List64 = List32 = List16 = List8 = ListKeepers = NULL;
+ Num64 = Num32 = Num16 = Num8 = NumKeepers = 0;
+ w = h = 0;
+
+ /* We sort partials by how large a square tile they can cache.
+ If a partial can't store a 64x64, 32x32, 16x16 or 8x8 tile,
+ we free it. */
+
+ pCur = ListPartial;
+ while (pCur) {
+ next = pCur->next;
+ if ((pCur->w >= 64) && (pCur->h >= 64)) {
+ pCur->next = List64;
+ List64 = pCur;
+ Num64++;
+ }
+ else if ((pCur->w >= 32) && (pCur->h >= 32)) {
+ pCur->next = List32;
+ List32 = pCur;
+ Num32++;
+ }
+ else if ((pCur->w >= 16) && (pCur->h >= 16)) {
+ pCur->next = List16;
+ List16 = pCur;
+ Num16++;
+ }
+ else if ((pCur->w >= 8) && (pCur->h >= 8)) {
+ pCur->next = List8;
+ List8 = pCur;
+ Num8++;
+ }
+ else {
+ free(pCur);
+ }
+
+ pCur = next;
+ }
+
+ /* We save all the tiles from the largest bin that we can get
+ at least 4 of. If there are too few of a bigger slot, we
+ cut it in fourths to make smaller slots. */
+
+ if (Num64 >= 4) {
+ ListKeepers = List64;
+ List64 = NULL;
+ NumKeepers = Num64;
+ goto GOT_EM;
+ }
+ else if (Num64) {
+ List32 = QuadLinks(List64, List32);
+ Num32 += Num64 * 4;
+ Num64 = 0;
+ }
+
+ if (Num32 >= 4) {
+ ListKeepers = List32;
+ List32 = NULL;
+ NumKeepers = Num32;
+ goto GOT_EM;
+ }
+ else if (Num32) {
+ List16 = QuadLinks(List32, List16);
+ Num16 += Num32 * 4;
+ Num32 = 0;
+ }
+
+ if (Num16 >= 4) {
+ ListKeepers = List16;
+ List16 = NULL;
+ NumKeepers = Num16;
+ goto GOT_EM;
+ }
+ else if (Num16) {
+ List8 = QuadLinks(List16, List8);
+ Num8 += Num16 * 4;
+ Num16 = 0;
+ }
+
+ if (Num8 >= 4) {
+ ListKeepers = List8;
+ List8 = NULL;
+ NumKeepers = Num8;
+ goto GOT_EM;
+ }
+
+ GOT_EM:
+
+ /* Free the ones we aren't using */
+
+ if (List64)
+ FreeList(List64);
+ if (List32)
+ FreeList(List32);
+ if (List16)
+ FreeList(List16);
+ if (List8)
+ FreeList(List8);
+
+ /* Enlarge the slots if we can */
+
+ if (ListKeepers) {
+ CacheLinkPtr pLink = ListKeepers;
+
+ w = h = 128;
+
+ while (pLink) {
+ if (pLink->w < w)
+ w = pLink->w;
+ if (pLink->h < h)
+ h = pLink->h;
+ pLink = pLink->next;
+ }
+ }
+
+ *maxw = w;
+ *maxh = h;
+ *num = NumKeepers;
+ return ListKeepers;
+}
+
+static void
+ConvertColorToMono(CacheLinkPtr * ColorList,
+ int ColorW, int ColorH,
+ CacheLinkPtr * MonoList, int MonoW, int MonoH)
+{
+ int x, y, w;
+
+ x = (*ColorList)->x;
+ y = (*ColorList)->y;
+ *ColorList = Delist(*ColorList);
+
+ while (ColorH) {
+ ColorH -= MonoH;
+ for (w = 0; w <= (ColorW - MonoW); w += MonoW)
+ *MonoList = Enlist(*MonoList, x + w, y + ColorH, MonoW, MonoH);
+ }
+}
+
+static void
+ConvertAllPartialsTo8x8(int *NumMono, int *NumColor,
+ CacheLinkPtr ListPartial,
+ CacheLinkPtr * ListMono,
+ CacheLinkPtr * ListColor, XAAInfoRecPtr infoRec)
+{
+/* This guy extracts as many 8x8 slots as it can out of fragments */
+
+ int ColorH = infoRec->CacheHeightColor8x8Pattern;
+ int ColorW = infoRec->CacheWidthColor8x8Pattern;
+ int MonoH = infoRec->CacheHeightMono8x8Pattern;
+ int MonoW = infoRec->CacheWidthMono8x8Pattern;
+ int x, y, w, Height, Width;
+ Bool DoColor = (infoRec->PixmapCacheFlags & CACHE_COLOR_8x8);
+ Bool DoMono = (infoRec->PixmapCacheFlags & CACHE_MONO_8x8);
+ CacheLinkPtr pLink = ListPartial;
+ CacheLinkPtr MonoList = *ListMono, ColorList = *ListColor;
+
+ if (DoColor && DoMono) {
+ /* we assume color patterns take more space than color ones */
+ if (MonoH > ColorH)
+ ColorH = MonoH;
+ if (MonoW > ColorW)
+ ColorW = MonoW;
+ }
+
+ /* Break up the area into as many Color and Mono slots as we can */
+
+ while (pLink) {
+ Height = pLink->h;
+ Width = pLink->w;
+ x = pLink->x;
+ y = pLink->y;
+
+ if (DoColor) {
+ while (Height >= ColorH) {
+ Height -= ColorH;
+ for (w = 0; w <= (Width - ColorW); w += ColorW) {
+ ColorList =
+ Enlist(ColorList, x + w, y + Height, ColorW, ColorH);
+ (*NumColor)++;
+ }
+ }
+ }
+
+ if (DoMono && (Height >= MonoH)) {
+ while (Height >= MonoH) {
+ Height -= MonoH;
+ for (w = 0; w <= (Width - MonoW); w += MonoW) {
+ MonoList =
+ Enlist(MonoList, x + w, y + Height, MonoW, MonoH);
+ (*NumMono)++;
+ }
+ }
+ }
+
+ pLink = pLink->next;
+ }
+
+ *ListMono = MonoList;
+ *ListColor = ColorList;
+ FreeList(ListPartial);
+}
+
+static CacheLinkPtr
+ExtractOneThatFits(CacheLinkPtr * initList, int w, int h)
+{
+ CacheLinkPtr list = *initList;
+ CacheLinkPtr prev = NULL;
+
+ while (list) {
+ if ((list->w >= w) && (list->h >= h))
+ break;
+ prev = list;
+ list = list->next;
+ }
+
+ if (list) {
+ if (prev)
+ prev->next = list->next;
+ else
+ *initList = list->next;
+
+ list->next = NULL;
+ }
+
+ return list;
+}
+
+static CacheLinkPtr
+ConvertSomePartialsTo8x8(int *NumMono, int *NumColor, int *NumPartial,
+ CacheLinkPtr ListPartial,
+ CacheLinkPtr * ListMono,
+ CacheLinkPtr * ListColor,
+ int *maxw, int *maxh, XAAInfoRecPtr infoRec)
+{
+/* This guy tries to get 4 of each type of 8x8 slot requested out of
+ a list of fragments all while trying to retain some big fragments
+ for the cache blits */
+
+ int ColorH = infoRec->CacheHeightColor8x8Pattern;
+ int ColorW = infoRec->CacheWidthColor8x8Pattern;
+ int MonoH = infoRec->CacheHeightMono8x8Pattern;
+ int MonoW = infoRec->CacheWidthMono8x8Pattern;
+ Bool DoColor = (infoRec->PixmapCacheFlags & CACHE_COLOR_8x8);
+ Bool DoMono = (infoRec->PixmapCacheFlags & CACHE_MONO_8x8);
+ CacheLinkPtr List64, List32, List16, List8, pCur, next, ListKeepers;
+ CacheLinkPtr MonoList = *ListMono, ColorList = *ListColor;
+ int Num64, Num32, Num16, Num8, NumKeepers;
+ int w, h, Width, Height;
+ int MonosPerColor = 1;
+
+ if (DoColor && DoMono) {
+ /* we assume color patterns take more space than color ones */
+ if (MonoH > ColorH)
+ ColorH = MonoH;
+ if (MonoW > ColorW)
+ ColorW = MonoW;
+ MonosPerColor = (ColorH / MonoH) * (ColorW / MonoW);
+ }
+
+ List64 = List32 = List16 = List8 = ListKeepers = MonoList = ColorList =
+ NULL;
+ Num64 = Num32 = Num16 = Num8 = NumKeepers = 0;
+ Width = Height = 0;
+
+ /* We sort partials by how large a square tile they can cache.
+ We make 8x8 patterns from the leftovers if we can. */
+
+ pCur = ListPartial;
+ while (pCur) {
+ next = pCur->next;
+ if ((pCur->w >= 64) && (pCur->h >= 64)) {
+ pCur->next = List64;
+ List64 = pCur;
+ Num64++;
+ }
+ else if ((pCur->w >= 32) && (pCur->h >= 32)) {
+ pCur->next = List32;
+ List32 = pCur;
+ Num32++;
+ }
+ else if ((pCur->w >= 16) && (pCur->h >= 16)) {
+ pCur->next = List16;
+ List16 = pCur;
+ Num16++;
+ }
+ else if ((pCur->w >= 8) && (pCur->h >= 8)) {
+ pCur->next = List8;
+ List8 = pCur;
+ Num8++;
+ }
+ else {
+ h = pCur->h;
+ if (DoColor && (pCur->w >= ColorW) && (h >= ColorH)) {
+ while (h >= ColorH) {
+ h -= ColorH;
+ for (w = 0; w <= (pCur->w - ColorW); w += ColorW) {
+ ColorList = Enlist(ColorList,
+ pCur->x + w, pCur->y + h, ColorW,
+ ColorH);
+ (*NumColor)++;
+ }
+ }
+ }
+ if (DoMono && (pCur->w >= MonoW) && (h >= MonoH)) {
+ while (h >= MonoH) {
+ h -= MonoH;
+ for (w = 0; w <= (pCur->w - MonoW); w += MonoW) {
+ MonoList = Enlist(MonoList,
+ pCur->x + w, pCur->y + h, MonoW,
+ MonoH);
+ (*NumMono)++;
+ }
+ }
+ }
+ free(pCur);
+ }
+
+ pCur = next;
+ }
+
+ /* Try to extract at least 4 of each type of 8x8 slot that we need */
+
+ if (DoColor) {
+ CacheLinkPtr theOne;
+
+ while (*NumColor < 4) {
+ theOne = NULL;
+ if (Num8) {
+ if ((theOne = ExtractOneThatFits(&List8, ColorW, ColorH)))
+ Num8--;
+ }
+ if (Num16 && !theOne) {
+ if ((theOne = ExtractOneThatFits(&List16, ColorW, ColorH)))
+ Num16--;
+ }
+ if (Num32 && !theOne) {
+ if ((theOne = ExtractOneThatFits(&List32, ColorW, ColorH)))
+ Num32--;
+ }
+ if (Num64 && !theOne) {
+ if ((theOne = ExtractOneThatFits(&List64, ColorW, ColorH)))
+ Num64--;
+ }
+
+ if (!theOne)
+ break;
+
+ ConvertAllPartialsTo8x8(NumMono, NumColor, theOne,
+ &MonoList, &ColorList, infoRec);
+
+ if (DoMono) {
+ while (*NumColor && (*NumMono < 4)) {
+ ConvertColorToMono(&ColorList, ColorW, ColorH,
+ &MonoList, MonoW, MonoH);
+ (*NumColor)--;
+ *NumMono += MonosPerColor;
+ }
+ }
+ }
+ }
+
+ if (DoMono) {
+ CacheLinkPtr theOne;
+
+ while (*NumMono < 4) {
+ theOne = NULL;
+ if (Num8) {
+ if ((theOne = ExtractOneThatFits(&List8, MonoW, MonoH)))
+ Num8--;
+ }
+ if (Num16 && !theOne) {
+ if ((theOne = ExtractOneThatFits(&List16, MonoW, MonoH)))
+ Num16--;
+ }
+ if (Num32 && !theOne) {
+ if ((theOne = ExtractOneThatFits(&List32, MonoW, MonoH)))
+ Num32--;
+ }
+ if (Num64 && !theOne) {
+ if ((theOne = ExtractOneThatFits(&List64, MonoW, MonoH)))
+ Num64--;
+ }
+
+ if (!theOne)
+ break;
+
+ ConvertAllPartialsTo8x8(NumMono, NumColor, theOne,
+ &MonoList, &ColorList, infoRec);
+ }
+ }
+
+ /* We save all the tiles from the largest bin that we can get
+ at least 4 of. If there are too few of a bigger slot, we
+ cut it in fourths to make smaller slots. */
+
+ if (Num64 >= 4) {
+ ListKeepers = List64;
+ List64 = NULL;
+ NumKeepers = Num64;
+ goto GOT_EM;
+ }
+ else if (Num64) {
+ List32 = QuadLinks(List64, List32);
+ Num32 += Num64 * 4;
+ Num64 = 0;
+ }
+
+ if (Num32 >= 4) {
+ ListKeepers = List32;
+ List32 = NULL;
+ NumKeepers = Num32;
+ goto GOT_EM;
+ }
+ else if (Num32) {
+ List16 = QuadLinks(List32, List16);
+ Num16 += Num32 * 4;
+ Num32 = 0;
+ }
+
+ if (Num16 >= 4) {
+ ListKeepers = List16;
+ List16 = NULL;
+ NumKeepers = Num16;
+ goto GOT_EM;
+ }
+ else if (Num16) {
+ List8 = QuadLinks(List16, List8);
+ Num8 += Num16 * 4;
+ Num16 = 0;
+ }
+
+ if (Num8 >= 4) {
+ ListKeepers = List8;
+ List8 = NULL;
+ NumKeepers = Num8;
+ goto GOT_EM;
+ }
+
+ GOT_EM:
+
+ /* Free the ones we aren't using */
+
+ if (List64)
+ ConvertAllPartialsTo8x8(NumMono, NumColor, List64,
+ &MonoList, &ColorList, infoRec);
+ if (List32)
+ ConvertAllPartialsTo8x8(NumMono, NumColor, List32,
+ &MonoList, &ColorList, infoRec);
+ if (List16)
+ ConvertAllPartialsTo8x8(NumMono, NumColor, List16,
+ &MonoList, &ColorList, infoRec);
+ if (List8)
+ ConvertAllPartialsTo8x8(NumMono, NumColor, List8,
+ &MonoList, &ColorList, infoRec);
+
+ /* Enlarge the slots if we can */
+
+ if (ListKeepers) {
+ CacheLinkPtr pLink = ListKeepers;
+
+ Width = Height = 128;
+
+ while (pLink) {
+ if (pLink->w < Width)
+ Width = pLink->w;
+ if (pLink->h < Height)
+ Height = pLink->h;
+ pLink = pLink->next;
+ }
+ }
+
+ *ListMono = MonoList;
+ *ListColor = ColorList;
+ *maxw = Width;
+ *maxh = Height;
+ *NumPartial = NumKeepers;
+ return ListKeepers;
+}
+
+void
+XAAInitPixmapCache(ScreenPtr pScreen, RegionPtr areas, pointer data)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ XAAInfoRecPtr infoRec = (XAAInfoRecPtr) data;
+ XAAPixmapCachePrivatePtr pCachePriv;
+ BoxPtr pBox = RegionRects(areas);
+ int nBox = RegionNumRects(areas);
+ int Num512, Num256, Num128, NumPartial, NumColor, NumMono;
+ int Target512, Target256;
+ CacheLinkPtr List512, List256, List128, ListPartial, ListColor, ListMono;
+ int x, y, w, h, ntotal, granularity, width, height, i;
+ int MaxPartialWidth, MaxPartialHeight;
+
+ infoRec->MaxCacheableTileWidth = 0;
+ infoRec->MaxCacheableTileHeight = 0;
+ infoRec->MaxCacheableStippleHeight = 0;
+ infoRec->MaxCacheableStippleWidth = 0;
+ infoRec->UsingPixmapCache = FALSE;
+
+ if (!nBox || !pBox || !(infoRec->Flags & PIXMAP_CACHE))
+ return;
+
+ /* Allocate a persistent per-screen init flag to control messages */
+ if (CacheInitIndex < 0)
+ CacheInitIndex = xf86AllocateScrnInfoPrivateIndex();
+
+ /* free the old private data if it exists */
+ if (infoRec->PixmapCachePrivate) {
+ FreePixmapCachePrivate((XAAPixmapCachePrivatePtr) infoRec->
+ PixmapCachePrivate);
+ infoRec->PixmapCachePrivate = NULL;
+ }
+
+ Num512 = Num256 = Num128 = NumPartial = NumMono = NumColor = 0;
+ List512 = List256 = List128 = ListPartial = ListMono = ListColor = NULL;
+ granularity = infoRec->CachePixelGranularity;
+ if (granularity <= 1)
+ granularity = 0;
+
+ /* go through the boxes and break it into as many pieces as we can fit */
+
+ while (nBox--) {
+ x = pBox->x1;
+ if (granularity) {
+ int tmp = x % granularity;
+
+ if (tmp)
+ x += (granularity - tmp);
+ }
+ width = pBox->x2 - x;
+ if (width <= 0) {
+ pBox++;
+ continue;
+ }
+
+ y = pBox->y1;
+ height = pBox->y2 - y;
+
+ for (h = 0; h <= (height - 512); h += 512) {
+ for (w = 0; w <= (width - 512); w += 512) {
+ List512 = Enlist(List512, x + w, y + h, 512, 512);
+ Num512++;
+ }
+ for (; w <= (width - 256); w += 256) {
+ List256 = Enlist(List256, x + w, y + h, 256, 256);
+ List256 = Enlist(List256, x + w, y + h + 256, 256, 256);
+ Num256 += 2;
+ }
+ for (; w <= (width - 128); w += 128) {
+ List128 = Enlist(List128, x + w, y + h, 128, 128);
+ List128 = Enlist(List128, x + w, y + h + 128, 128, 128);
+ List128 = Enlist(List128, x + w, y + h + 256, 128, 128);
+ List128 = Enlist(List128, x + w, y + h + 384, 128, 128);
+ Num128 += 4;
+ }
+ if (w < width) {
+ int d = width - w;
+
+ ListPartial = Enlist(ListPartial, x + w, y + h, d, 128);
+ ListPartial = Enlist(ListPartial, x + w, y + h + 128, d, 128);
+ ListPartial = Enlist(ListPartial, x + w, y + h + 256, d, 128);
+ ListPartial = Enlist(ListPartial, x + w, y + h + 384, d, 128);
+ NumPartial += 4;
+ }
+ }
+ for (; h <= (height - 256); h += 256) {
+ for (w = 0; w <= (width - 256); w += 256) {
+ List256 = Enlist(List256, x + w, y + h, 256, 256);
+ Num256++;
+ }
+ for (; w <= (width - 128); w += 128) {
+ List128 = Enlist(List128, x + w, y + h, 128, 128);
+ List128 = Enlist(List128, x + w, y + h + 128, 128, 128);
+ Num128 += 2;
+ }
+ if (w < width) {
+ int d = width - w;
+
+ ListPartial = Enlist(ListPartial, x + w, y + h, d, 128);
+ ListPartial = Enlist(ListPartial, x + w, y + h + 128, d, 128);
+ NumPartial += 2;
+ }
+ }
+ for (; h <= (height - 128); h += 128) {
+ for (w = 0; w <= (width - 128); w += 128) {
+ List128 = Enlist(List128, x + w, y + h, 128, 128);
+ Num128++;
+ }
+ if (w < width) {
+ ListPartial = Enlist(ListPartial, x + w, y + h, width - w, 128);
+ NumPartial++;
+ }
+ }
+ if (h < height) {
+ int d = height - h;
+
+ for (w = 0; w <= (width - 128); w += 128) {
+ ListPartial = Enlist(ListPartial, x + w, y + h, 128, d);
+ NumPartial++;
+ }
+ if (w < width) {
+ ListPartial = Enlist(ListPartial, x + w, y + h, width - w, d);
+ NumPartial++;
+ }
+ }
+ pBox++;
+ }
+
+/*
+ by this point we've carved the space into as many 512x512, 256x256
+ and 128x128 blocks as we could fit. We will then break larger
+ blocks into smaller ones if we need to. The rules are as follows:
+
+ 512x512 -
+ 1) Don't take up more than half the memory.
+ 2) Don't bother if you can't get at least four.
+ 3) Don't make more than MAX_512.
+ 4) Don't have any of there are no 256x256s.
+
+ 256x256 -
+ 1) Don't take up more than a quarter of the memory enless there
+ aren't any 512x512s. Then we can take up to half.
+ 2) Don't bother if you can't get at least four.
+ 3) Don't make more than MAX_256.
+
+ 128x128 -
+ 1) Don't make more than MAX_128.
+
+ We don't bother with the partial blocks unless we can use them
+ for 8x8 pattern fills or we are short on larger blocks.
+
+*/
+
+ ntotal = Num128 + (Num256 << 2) + (Num512 << 4);
+
+ Target512 = ntotal >> 5;
+ if (Target512 < 4)
+ Target512 = 0;
+ if (!Target512)
+ Target256 = ntotal >> 3;
+ else
+ Target256 = ntotal >> 4;
+ if (Target256 < 4)
+ Target256 = 0;
+
+ if (Num512 && Num256 < 4) {
+ while (Num512 && Num256 < Target256) {
+ SubdivideList(&List512, &List256);
+ Num256 += 4;
+ Num512--;
+ }
+ }
+
+ if (!Num512) { /* no room */
+ }
+ else if ((Num512 < 4) || (!Target512)) {
+ while (Num512) {
+ SubdivideList(&List512, &List256);
+ Num256 += 4;
+ Num512--;
+ }
+ }
+ else if ((Num512 > MAX_512) || (Num512 > Target512)) {
+ while (Num512 > MAX_512) {
+ SubdivideList(&List512, &List256);
+ Num256 += 4;
+ Num512--;
+ }
+ while (Num512 > Target512) {
+ if (Num256 < MAX_256) {
+ SubdivideList(&List512, &List256);
+ Num256 += 4;
+ Num512--;
+ }
+ else
+ break;
+ }
+ }
+
+ if (!Num256) { /* no room */
+ }
+ else if ((Num256 < 4) || (!Target256)) {
+ while (Num256) {
+ SubdivideList(&List256, &List128);
+ Num128 += 4;
+ Num256--;
+ }
+ }
+ else if ((Num256 > MAX_256) || (Num256 > Target256)) {
+ while (Num256 > MAX_256) {
+ SubdivideList(&List256, &List128);
+ Num128 += 4;
+ Num256--;
+ }
+ while (Num256 > Target256) {
+ if (Num128 < MAX_128) {
+ SubdivideList(&List256, &List128);
+ Num128 += 4;
+ Num256--;
+ }
+ else
+ break;
+ }
+ }
+
+ if (Num128 && ((Num128 < 4) || (Num128 > MAX_128))) {
+ CacheLinkPtr next;
+ int max = (Num128 > MAX_128) ? MAX_128 : 0;
+
+ /*
+ * Note: next is set in this way to work around a code generation
+ * bug in gcc 2.7.2.3.
+ */
+ next = List128->next;
+ while (Num128 > max) {
+ List128->next = ListPartial;
+ ListPartial = List128;
+ if ((List128 = next))
+ next = List128->next;
+ NumPartial++;
+ Num128--;
+ }
+ }
+
+ MaxPartialHeight = MaxPartialWidth = 0;
+
+ /* at this point we have as many 512x512 and 256x256 slots as we
+ want but may have an excess of 128x128 slots. We still need
+ to find out if we need 8x8 slots. We take these from the
+ partials if we have them. Otherwise, we break some 128x128's */
+
+ if (!(infoRec->PixmapCacheFlags & (CACHE_MONO_8x8 | CACHE_COLOR_8x8))) {
+ if (NumPartial) {
+ if (Num128) { /* don't bother with partials */
+ FreeList(ListPartial);
+ NumPartial = 0;
+ ListPartial = NULL;
+ }
+ else {
+ /* We have no big slots. Weed out the unusable partials */
+ ListPartial = ThinOutPartials(ListPartial, &NumPartial,
+ &MaxPartialWidth,
+ &MaxPartialHeight);
+ }
+ }
+ }
+ else {
+ int MonosPerColor = 1;
+ int ColorH = infoRec->CacheHeightColor8x8Pattern;
+ int ColorW = infoRec->CacheWidthColor8x8Pattern;
+ int MonoH = infoRec->CacheHeightMono8x8Pattern;
+ int MonoW = infoRec->CacheWidthMono8x8Pattern;
+ Bool DoColor = (infoRec->PixmapCacheFlags & CACHE_COLOR_8x8);
+ Bool DoMono = (infoRec->PixmapCacheFlags & CACHE_MONO_8x8);
+
+ if (DoColor)
+ infoRec->CanDoColor8x8 = FALSE;
+ if (DoMono)
+ infoRec->CanDoMono8x8 = FALSE;
+
+ if (DoColor && DoMono) {
+ /* we assume color patterns take more space than color ones */
+ if (MonoH > ColorH)
+ ColorH = MonoH;
+ if (MonoW > ColorW)
+ ColorW = MonoW;
+ MonosPerColor = (ColorH / MonoH) * (ColorW / MonoW);
+ }
+
+ if (Num128) {
+ if (NumPartial) { /* use all for 8x8 slots */
+ ConvertAllPartialsTo8x8(&NumMono, &NumColor,
+ ListPartial, &ListMono, &ListColor,
+ infoRec);
+ NumPartial = 0;
+ ListPartial = NULL;
+ }
+
+ /* Get some 8x8 slots from the 128 slots */
+ while ((Num128 > 4) &&
+ ((NumMono < MAX_MONO) && (NumColor < MAX_COLOR))) {
+ CacheLinkPtr tmp = NULL;
+
+ tmp = Enlist(tmp, List128->x, List128->y,
+ List128->w, List128->h);
+ List128 = Delist(List128);
+ Num128--;
+
+ ConvertAllPartialsTo8x8(&NumMono, &NumColor,
+ tmp, &ListMono, &ListColor, infoRec);
+ }
+ }
+ else if (NumPartial) {
+ /* We have share partials between 8x8 slots and tiles. */
+ ListPartial = ConvertSomePartialsTo8x8(&NumMono, &NumColor,
+ &NumPartial, ListPartial,
+ &ListMono, &ListColor,
+ &MaxPartialWidth,
+ &MaxPartialHeight, infoRec);
+ }
+
+ if (DoMono && DoColor) {
+ if (NumColor && ((NumColor > MAX_COLOR) || (NumColor < 4))) {
+ int max = (NumColor > MAX_COLOR) ? MAX_COLOR : 0;
+
+ while (NumColor > max) {
+ ConvertColorToMono(&ListColor, ColorW, ColorH,
+ &ListMono, MonoW, MonoH);
+ NumColor--;
+ NumMono += MonosPerColor;
+ }
+ }
+
+ /* favor Mono slots over Color ones */
+ while ((NumColor > 4) && (NumMono < MAX_MONO)) {
+ ConvertColorToMono(&ListColor, ColorW, ColorH,
+ &ListMono, MonoW, MonoH);
+ NumColor--;
+ NumMono += MonosPerColor;
+ }
+ }
+
+ if (NumMono && ((NumMono > MAX_MONO) || (NumMono < 4))) {
+ int max = (NumMono > MAX_MONO) ? MAX_MONO : 0;
+
+ while (NumMono > max) {
+ ListMono = Delist(ListMono);
+ NumMono--;
+ }
+ }
+ if (NumColor && ((NumColor > MAX_COLOR) || (NumColor < 4))) {
+ int max = (NumColor > MAX_COLOR) ? MAX_COLOR : 0;
+
+ while (NumColor > max) {
+ ListColor = Delist(ListColor);
+ NumColor--;
+ }
+ }
+ }
+
+ pCachePriv = calloc(1, sizeof(XAAPixmapCachePrivate));
+ if (!pCachePriv) {
+ if (Num512)
+ FreeList(List512);
+ if (Num256)
+ FreeList(List256);
+ if (Num128)
+ FreeList(List128);
+ if (NumPartial)
+ FreeList(ListPartial);
+ if (NumColor)
+ FreeList(ListColor);
+ if (NumMono)
+ FreeList(ListMono);
+ return;
+ }
+
+ infoRec->PixmapCachePrivate = (char *) pCachePriv;
+
+ if (Num512) {
+ pCachePriv->Info512 = calloc(Num512, sizeof(XAACacheInfoRec));
+ if (!pCachePriv->Info512)
+ Num512 = 0;
+ if (Num512)
+ TransferList(List512, pCachePriv->Info512, Num512);
+ FreeList(List512);
+ pCachePriv->Num512x512 = Num512;
+ }
+ if (Num256) {
+ pCachePriv->Info256 = calloc(Num256, sizeof(XAACacheInfoRec));
+ if (!pCachePriv->Info256)
+ Num256 = 0;
+ if (Num256)
+ TransferList(List256, pCachePriv->Info256, Num256);
+ FreeList(List256);
+ pCachePriv->Num256x256 = Num256;
+ }
+ if (Num128) {
+ pCachePriv->Info128 = calloc(Num128, sizeof(XAACacheInfoRec));
+ if (!pCachePriv->Info128)
+ Num128 = 0;
+ if (Num128)
+ TransferList(List128, pCachePriv->Info128, Num128);
+ FreeList(List128);
+ pCachePriv->Num128x128 = Num128;
+ }
+
+ if (NumPartial) {
+ pCachePriv->InfoPartial = calloc(NumPartial, sizeof(XAACacheInfoRec));
+ if (!pCachePriv->InfoPartial)
+ NumPartial = 0;
+ if (NumPartial)
+ TransferList(ListPartial, pCachePriv->InfoPartial, NumPartial);
+ FreeList(ListPartial);
+ pCachePriv->NumPartial = NumPartial;
+ }
+
+ if (NumColor) {
+ pCachePriv->InfoColor = calloc(NumColor, sizeof(XAACacheInfoRec));
+ if (!pCachePriv->InfoColor)
+ NumColor = 0;
+ if (NumColor)
+ TransferList(ListColor, pCachePriv->InfoColor, NumColor);
+ FreeList(ListColor);
+ pCachePriv->NumColor = NumColor;
+ }
+
+ if (NumMono) {
+ pCachePriv->InfoMono = calloc(NumMono, sizeof(XAACacheInfoRec));
+ if (!pCachePriv->InfoMono)
+ NumMono = 0;
+ if (NumMono)
+ TransferList(ListMono, pCachePriv->InfoMono, NumMono);
+ FreeList(ListMono);
+ pCachePriv->NumMono = NumMono;
+ }
+
+ if (NumPartial) {
+ infoRec->MaxCacheableTileWidth = MaxPartialWidth;
+ infoRec->MaxCacheableTileHeight = MaxPartialHeight;
+ }
+ if (Num128)
+ infoRec->MaxCacheableTileWidth = infoRec->MaxCacheableTileHeight = 128;
+ if (Num256)
+ infoRec->MaxCacheableTileWidth = infoRec->MaxCacheableTileHeight = 256;
+ if (Num512)
+ infoRec->MaxCacheableTileWidth = infoRec->MaxCacheableTileHeight = 512;
+
+ infoRec->MaxCacheableStippleHeight = infoRec->MaxCacheableTileHeight;
+ infoRec->MaxCacheableStippleWidth =
+ infoRec->MaxCacheableTileWidth * pScrn->bitsPerPixel;
+ if (infoRec->ScreenToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP)
+ infoRec->MaxCacheableStippleWidth /= 3;
+
+ if (NumMono) {
+ if (!(infoRec->Mono8x8PatternFillFlags &
+ (HARDWARE_PATTERN_PROGRAMMED_ORIGIN |
+ HARDWARE_PATTERN_PROGRAMMED_BITS))) {
+ int numPerLine =
+ infoRec->CacheWidthMono8x8Pattern / infoRec->MonoPatternPitch;
+
+ for (i = 0; i < 64; i++) {
+ pCachePriv->MonoOffsets[i].y = i / numPerLine;
+ pCachePriv->MonoOffsets[i].x = (i % numPerLine) *
+ infoRec->MonoPatternPitch;
+ }
+ }
+ infoRec->CanDoMono8x8 = TRUE;
+ }
+ if (NumColor) {
+ if (!(infoRec->Color8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+
+ for (i = 0; i < 64; i++) {
+ pCachePriv->ColorOffsets[i].y = i & 0x07;
+ pCachePriv->ColorOffsets[i].x = i & ~0x07;
+ }
+ }
+ infoRec->CanDoColor8x8 = TRUE;
+ }
+
+ if (!CACHEINIT(pScrn)) {
+ xf86ErrorF("\tSetting up tile and stipple cache:\n");
+ if (NumPartial)
+ xf86ErrorF("\t\t%i %ix%i slots\n",
+ NumPartial, MaxPartialWidth, MaxPartialHeight);
+ if (Num128)
+ xf86ErrorF("\t\t%i 128x128 slots\n", Num128);
+ if (Num256)
+ xf86ErrorF("\t\t%i 256x256 slots\n", Num256);
+ if (Num512)
+ xf86ErrorF("\t\t%i 512x512 slots\n", Num512);
+ if (NumColor)
+ xf86ErrorF("\t\t%i 8x8 color pattern slots\n", NumColor);
+ if (NumMono)
+ xf86ErrorF("\t\t%i 8x8 color expansion slots\n", NumMono);
+ }
+
+ if (!(NumPartial | Num128 | Num256 | Num512 | NumColor | NumMono)) {
+ if (!CACHEINIT(pScrn))
+ xf86ErrorF("\t\tNot enough video memory for pixmap cache\n");
+ }
+ else
+ infoRec->UsingPixmapCache = TRUE;
+
+ CACHEINIT(pScrn) = 1;
+}
+
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+static CARD32 StippleMasks[4] = {
+ 0x80808080,
+ 0xC0C0C0C0,
+ 0x00000000,
+ 0xF0F0F0F0
+};
+#else
+static CARD32 StippleMasks[4] = {
+ 0x01010101,
+ 0x03030303,
+ 0x00000000,
+ 0x0F0F0F0F
+};
+#endif
+
+Bool
+XAACheckStippleReducibility(PixmapPtr pPixmap)
+{
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPixmap);
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_DRAWABLE(&pPixmap->drawable);
+ CARD32 *IntPtr = (CARD32 *) pPixmap->devPrivate.ptr;
+ int w = pPixmap->drawable.width;
+ int h = pPixmap->drawable.height;
+ int i;
+ CARD32 bits[8];
+ CARD32 mask = SHIFT_R(0xFFFFFFFF, 24);
+
+ pPriv->flags |= REDUCIBILITY_CHECKED | REDUCIBLE_TO_2_COLOR;
+ pPriv->flags &= ~REDUCIBLE_TO_8x8;
+
+ if ((w > 32) || (h > 32) || (w & (w - 1)) || (h & (h - 1)))
+ return FALSE;
+
+ i = (h > 8) ? 8 : h;
+
+ switch (w) {
+ case 32:
+ while (i--) {
+ bits[i] = IntPtr[i] & mask;
+ if ((bits[i] != SHIFT_R((IntPtr[i] & SHIFT_L(mask, 8)), 8)) ||
+ (bits[i] != SHIFT_R((IntPtr[i] & SHIFT_L(mask, 16)), 16)) ||
+ (bits[i] != SHIFT_R((IntPtr[i] & SHIFT_L(mask, 24)), 24)))
+ return FALSE;
+ }
+ break;
+ case 16:
+ while (i--) {
+ bits[i] = IntPtr[i] & mask;
+ if (bits[i] != ((IntPtr[i] & SHIFT_R(SHIFT_L(mask, 8), 8))))
+ return FALSE;
+ }
+ break;
+ default:
+ while (i--)
+ bits[i] = IntPtr[i] & mask;
+ break;
+ }
+
+ switch (h) {
+ case 32:
+ if ((IntPtr[8] != IntPtr[16]) || (IntPtr[9] != IntPtr[17]) ||
+ (IntPtr[10] != IntPtr[18]) || (IntPtr[11] != IntPtr[19]) ||
+ (IntPtr[12] != IntPtr[20]) || (IntPtr[13] != IntPtr[21]) ||
+ (IntPtr[14] != IntPtr[22]) || (IntPtr[15] != IntPtr[23]) ||
+ (IntPtr[16] != IntPtr[24]) || (IntPtr[17] != IntPtr[25]) ||
+ (IntPtr[18] != IntPtr[26]) || (IntPtr[19] != IntPtr[27]) ||
+ (IntPtr[20] != IntPtr[28]) || (IntPtr[21] != IntPtr[29]) ||
+ (IntPtr[22] != IntPtr[30]) || (IntPtr[23] != IntPtr[31]))
+ return FALSE;
+ /* fall through */
+ case 16:
+ if ((IntPtr[0] != IntPtr[8]) || (IntPtr[1] != IntPtr[9]) ||
+ (IntPtr[2] != IntPtr[10]) || (IntPtr[3] != IntPtr[11]) ||
+ (IntPtr[4] != IntPtr[12]) || (IntPtr[5] != IntPtr[13]) ||
+ (IntPtr[6] != IntPtr[14]) || (IntPtr[7] != IntPtr[15]))
+ return FALSE;
+ case 8:
+ break;
+ case 1:
+ bits[1] = bits[0];
+ case 2:
+ bits[2] = bits[0];
+ bits[3] = bits[1];
+ case 4:
+ bits[4] = bits[0];
+ bits[5] = bits[1];
+ bits[6] = bits[2];
+ bits[7] = bits[3];
+ break;
+ }
+
+ pPriv->flags |= REDUCIBLE_TO_8x8;
+
+ pPriv->pattern0 =
+ bits[0] | SHIFT_L(bits[1], 8) | SHIFT_L(bits[2], 16) | SHIFT_L(bits[3],
+ 24);
+ pPriv->pattern1 =
+ bits[4] | SHIFT_L(bits[5], 8) | SHIFT_L(bits[6], 16) | SHIFT_L(bits[7],
+ 24);
+
+ if (w < 8) {
+ pPriv->pattern0 &= StippleMasks[w - 1];
+ pPriv->pattern1 &= StippleMasks[w - 1];
+
+ switch (w) {
+ case 1:
+ pPriv->pattern0 |= SHIFT_L(pPriv->pattern0, 1);
+ pPriv->pattern1 |= SHIFT_L(pPriv->pattern1, 1);
+ case 2:
+ pPriv->pattern0 |= SHIFT_L(pPriv->pattern0, 2);
+ pPriv->pattern1 |= SHIFT_L(pPriv->pattern1, 2);
+ case 4:
+ pPriv->pattern0 |= SHIFT_L(pPriv->pattern0, 4);
+ pPriv->pattern1 |= SHIFT_L(pPriv->pattern1, 4);
+ }
+ }
+
+ if (infoRec->Mono8x8PatternFillFlags & BIT_ORDER_IN_BYTE_MSBFIRST) {
+ pPriv->pattern0 = SWAP_BITS_IN_BYTES(pPriv->pattern0);
+ pPriv->pattern1 = SWAP_BITS_IN_BYTES(pPriv->pattern1);
+ }
+
+ return TRUE;
+}
+
+Bool
+XAACheckTileReducibility(PixmapPtr pPixmap, Bool checkMono)
+{
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPixmap);
+ CARD32 *IntPtr;
+ int w = pPixmap->drawable.width;
+ int h = pPixmap->drawable.height;
+ int pitch = pPixmap->devKind >> 2;
+ int dwords, i, j;
+
+ pPriv->flags |= REDUCIBILITY_CHECKED;
+ pPriv->flags &= ~(REDUCIBILITY_CHECKED | REDUCIBLE_TO_2_COLOR);
+
+ if ((w > 32) || (h > 32) || (w & (w - 1)) || (h & (h - 1)))
+ return FALSE;
+
+ dwords = ((w * pPixmap->drawable.bitsPerPixel) + 31) >> 5;
+ i = (h > 8) ? 8 : h;
+
+ if (w > 8) {
+ IntPtr = (CARD32 *) pPixmap->devPrivate.ptr;
+ switch (pPixmap->drawable.bitsPerPixel) {
+ case 8:
+ while (i--) {
+ for (j = 2; j < dwords; j++)
+ if (IntPtr[j] != IntPtr[j & 0x01])
+ return FALSE;
+ IntPtr += pitch;
+ }
+ break;
+ case 16:
+ while (i--) {
+ for (j = 4; j < dwords; j++)
+ if (IntPtr[j] != IntPtr[j & 0x03])
+ return FALSE;
+ IntPtr += pitch;
+ }
+ break;
+ case 24:
+ while (i--) {
+ for (j = 6; j < dwords; j++)
+ if (IntPtr[j] != IntPtr[j % 6])
+ return FALSE;
+ IntPtr += pitch;
+ }
+ break;
+ case 32:
+ while (i--) {
+ for (j = 8; j < dwords; j++)
+ if (IntPtr[j] != IntPtr[j & 0x07])
+ return FALSE;
+ IntPtr += pitch;
+ }
+ break;
+ default:
+ return FALSE;
+ }
+
+ }
+
+ if (h == 32) {
+ CARD32 *IntPtr2, *IntPtr3, *IntPtr4;
+
+ i = 8;
+ IntPtr = (CARD32 *) pPixmap->devPrivate.ptr;
+ IntPtr2 = IntPtr + (pitch << 3);
+ IntPtr3 = IntPtr2 + (pitch << 3);
+ IntPtr4 = IntPtr3 + (pitch << 3);
+ while (i--) {
+ for (j = 0; j < dwords; j++)
+ if ((IntPtr[j] != IntPtr2[j]) || (IntPtr[j] != IntPtr3[j]) ||
+ (IntPtr[j] != IntPtr4[j]))
+ return FALSE;
+ IntPtr += pitch;
+ IntPtr2 += pitch;
+ IntPtr3 += pitch;
+ IntPtr4 += pitch;
+ }
+ }
+ else if (h == 16) {
+ CARD32 *IntPtr2;
+
+ i = 8;
+ IntPtr = (CARD32 *) pPixmap->devPrivate.ptr;
+ IntPtr2 = IntPtr + (pitch << 3);
+ while (i--) {
+ for (j = 0; j < dwords; j++)
+ if (IntPtr[j] != IntPtr2[j])
+ return FALSE;
+ IntPtr += pitch;
+ IntPtr2 += pitch;
+ }
+ }
+
+ pPriv->flags |= REDUCIBLE_TO_8x8;
+
+ if (checkMono) {
+ XAAInfoRecPtr infoRec =
+ GET_XAAINFORECPTR_FROM_DRAWABLE(&pPixmap->drawable);
+ unsigned char bits[8];
+ int fg, bg = -1, x, y;
+
+ i = (h > 8) ? 8 : h;
+ j = (w > 8) ? 8 : w;
+
+ if (pPixmap->drawable.bitsPerPixel == 8) {
+ unsigned char *srcp = pPixmap->devPrivate.ptr;
+
+ fg = srcp[0];
+ pitch = pPixmap->devKind;
+ for (y = 0; y < i; y++) {
+ bits[y] = 0;
+ for (x = 0; x < j; x++) {
+ if (srcp[x] != fg) {
+ if (bg == -1)
+ bg = srcp[x];
+ else if (bg != srcp[x])
+ return TRUE;
+ }
+ else
+ bits[y] |= 1 << x;
+ }
+ srcp += pitch;
+ }
+ }
+ else if (pPixmap->drawable.bitsPerPixel == 16) {
+ unsigned short *srcp = (unsigned short *) pPixmap->devPrivate.ptr;
+
+ fg = srcp[0];
+ pitch = pPixmap->devKind >> 1;
+ for (y = 0; y < i; y++) {
+ bits[y] = 0;
+ for (x = 0; x < j; x++) {
+ if (srcp[x] != fg) {
+ if (bg == -1)
+ bg = srcp[x];
+ else if (bg != srcp[x])
+ return TRUE;
+ }
+ else
+ bits[y] |= 1 << x;
+ }
+ srcp += pitch;
+ }
+ }
+ else if (pPixmap->drawable.bitsPerPixel == 24) {
+ CARD32 val;
+ unsigned char *srcp = pPixmap->devPrivate.ptr;
+
+ fg = *((CARD32 *) srcp) & 0x00FFFFFF;
+ pitch = pPixmap->devKind;
+ j *= 3;
+ for (y = 0; y < i; y++) {
+ bits[y] = 0;
+ for (x = 0; x < j; x += 3) {
+ val = *((CARD32 *) (srcp + x)) & 0x00FFFFFF;
+ if (val != fg) {
+ if (bg == -1)
+ bg = val;
+ else if (bg != val)
+ return TRUE;
+ }
+ else
+ bits[y] |= 1 << (x / 3);
+ }
+ srcp += pitch;
+ }
+ }
+ else if (pPixmap->drawable.bitsPerPixel == 32) {
+ IntPtr = (CARD32 *) pPixmap->devPrivate.ptr;
+ fg = IntPtr[0];
+ for (y = 0; y < i; y++) {
+ bits[y] = 0;
+ for (x = 0; x < j; x++) {
+ if (IntPtr[x] != fg) {
+ if (bg == -1)
+ bg = IntPtr[x];
+ else if (bg != IntPtr[x])
+ return TRUE;
+ }
+ else
+ bits[y] |= 1 << x;
+ }
+ IntPtr += pitch;
+ }
+ }
+ else
+ return TRUE;
+
+ pPriv->fg = fg;
+ if (bg == -1)
+ pPriv->bg = fg;
+ else
+ pPriv->bg = bg;
+
+ if (h < 8) {
+ switch (h) {
+ case 1:
+ bits[1] = bits[0];
+ case 2:
+ bits[2] = bits[0];
+ bits[3] = bits[1];
+ case 4:
+ bits[4] = bits[0];
+ bits[5] = bits[1];
+ bits[6] = bits[2];
+ bits[7] = bits[3];
+ break;
+ }
+ }
+
+ pPriv->pattern0 =
+ bits[0] | (bits[1] << 8) | (bits[2] << 16) | (bits[3] << 24);
+ pPriv->pattern1 =
+ bits[4] | (bits[5] << 8) | (bits[6] << 16) | (bits[7] << 24);
+
+ if (w < 8) {
+ switch (w) {
+ case 1:
+ pPriv->pattern0 |= (pPriv->pattern0 << 1);
+ pPriv->pattern1 |= (pPriv->pattern1 << 1);
+ case 2:
+ pPriv->pattern0 |= (pPriv->pattern0 << 2);
+ pPriv->pattern1 |= (pPriv->pattern1 << 2);
+ case 4:
+ pPriv->pattern0 |= (pPriv->pattern0 << 4);
+ pPriv->pattern1 |= (pPriv->pattern1 << 4);
+ }
+ }
+ pPriv->flags |= REDUCIBLE_TO_2_COLOR;
+
+ if (infoRec->Mono8x8PatternFillFlags & BIT_ORDER_IN_BYTE_MSBFIRST) {
+ pPriv->pattern0 = SWAP_BITS_IN_BYTES(pPriv->pattern0);
+ pPriv->pattern1 = SWAP_BITS_IN_BYTES(pPriv->pattern1);
+ }
+
+ }
+
+ return TRUE;
+}
+
+void
+XAATileCache(ScrnInfoPtr pScrn, XAACacheInfoPtr pCache, int w, int h)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->SetupForScreenToScreenCopy) (pScrn, 1, 1, GXcopy, ~0, -1);
+
+ while ((w << 1) <= pCache->w) {
+ (*infoRec->SubsequentScreenToScreenCopy) (pScrn, pCache->x, pCache->y,
+ pCache->x + w, pCache->y, w,
+ h);
+ w <<= 1;
+ }
+ if (w != pCache->w) {
+ (*infoRec->SubsequentScreenToScreenCopy) (pScrn, pCache->x, pCache->y,
+ pCache->x + w, pCache->y,
+ pCache->w - w, h);
+ w = pCache->w;
+ }
+
+ while ((h << 1) <= pCache->h) {
+ (*infoRec->SubsequentScreenToScreenCopy) (pScrn, pCache->x, pCache->y,
+ pCache->x, pCache->y + h, w,
+ h);
+ h <<= 1;
+ }
+ if (h != pCache->h) {
+ (*infoRec->SubsequentScreenToScreenCopy) (pScrn, pCache->x, pCache->y,
+ pCache->x, pCache->y + h, w,
+ pCache->h - h);
+ }
+ SET_SYNC_FLAG(infoRec);
+}
+
+XAACacheInfoPtr
+XAACacheTile(ScrnInfoPtr pScrn, PixmapPtr pPix)
+{
+ int w = pPix->drawable.width;
+ int h = pPix->drawable.height;
+ int size = max(w, h);
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ XAAPixmapCachePrivatePtr pCachePriv =
+ (XAAPixmapCachePrivatePtr) infoRec->PixmapCachePrivate;
+ XAACacheInfoPtr pCache, cacheRoot = NULL;
+ int i, max = 0;
+ int *current;
+
+ if (size <= 128) {
+ if (pCachePriv->Info128) {
+ cacheRoot = pCachePriv->Info128;
+ max = pCachePriv->Num128x128;
+ current = &pCachePriv->Current128;
+ }
+ else {
+ cacheRoot = pCachePriv->InfoPartial;
+ max = pCachePriv->NumPartial;
+ current = &pCachePriv->CurrentPartial;
+ }
+ }
+ else if (size <= 256) {
+ cacheRoot = pCachePriv->Info256;
+ max = pCachePriv->Num256x256;
+ current = &pCachePriv->Current256;
+ }
+ else if (size <= 512) {
+ cacheRoot = pCachePriv->Info512;
+ max = pCachePriv->Num512x512;
+ current = &pCachePriv->Current512;
+ }
+ else { /* something's wrong */
+ ErrorF("Something's wrong in XAACacheTile()\n");
+ return pCachePriv->Info128;
+ }
+
+ pCache = cacheRoot;
+
+ /* lets look for it */
+ for (i = 0; i < max; i++, pCache++) {
+ if (pCache->serialNumber == pPix->drawable.serialNumber) {
+ pCache->trans_color = -1;
+ return pCache;
+ }
+ }
+
+ pCache = &cacheRoot[(*current)++];
+ if (*current >= max)
+ *current = 0;
+
+ pCache->serialNumber = pPix->drawable.serialNumber;
+ pCache->trans_color = pCache->bg = pCache->fg = -1;
+ pCache->orig_w = w;
+ pCache->orig_h = h;
+ (*infoRec->WritePixmapToCache) (pScrn, pCache->x, pCache->y, w, h,
+ pPix->devPrivate.ptr, pPix->devKind,
+ pPix->drawable.bitsPerPixel,
+ pPix->drawable.depth);
+ if (!(infoRec->PixmapCacheFlags & DO_NOT_TILE_COLOR_DATA) &&
+ ((w != pCache->w) || (h != pCache->h)))
+ XAATileCache(pScrn, pCache, w, h);
+
+ return pCache;
+}
+
+XAACacheInfoPtr
+XAACacheMonoStipple(ScrnInfoPtr pScrn, PixmapPtr pPix)
+{
+ int w = pPix->drawable.width;
+ int h = pPix->drawable.height;
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ XAAPixmapCachePrivatePtr pCachePriv =
+ (XAAPixmapCachePrivatePtr) infoRec->PixmapCachePrivate;
+ XAACacheInfoPtr pCache, cacheRoot = NULL;
+ int i, max = 0, funcNo, pad, dwords, bpp = pScrn->bitsPerPixel;
+ int *current;
+ StippleScanlineProcPtr StippleFunc;
+ unsigned char *data, *srcPtr, *dstPtr;
+
+ if ((h <= 128) && (w <= 128 * bpp)) {
+ if (pCachePriv->Info128) {
+ cacheRoot = pCachePriv->Info128;
+ max = pCachePriv->Num128x128;
+ current = &pCachePriv->Current128;
+ }
+ else {
+ cacheRoot = pCachePriv->InfoPartial;
+ max = pCachePriv->NumPartial;
+ current = &pCachePriv->CurrentPartial;
+ }
+ }
+ else if ((h <= 256) && (w <= 256 * bpp)) {
+ cacheRoot = pCachePriv->Info256;
+ max = pCachePriv->Num256x256;
+ current = &pCachePriv->Current256;
+ }
+ else if ((h <= 512) && (w <= 526 * bpp)) {
+ cacheRoot = pCachePriv->Info512;
+ max = pCachePriv->Num512x512;
+ current = &pCachePriv->Current512;
+ }
+ else { /* something's wrong */
+ ErrorF("Something's wrong in XAACacheMonoStipple()\n");
+ return pCachePriv->Info128;
+ }
+
+ pCache = cacheRoot;
+
+ /* lets look for it */
+ for (i = 0; i < max; i++, pCache++) {
+ if ((pCache->serialNumber == pPix->drawable.serialNumber) &&
+ (pCache->fg == -1) && (pCache->bg == -1)) {
+ pCache->trans_color = -1;
+ return pCache;
+ }
+ }
+
+ pCache = &cacheRoot[(*current)++];
+ if (*current >= max)
+ *current = 0;
+
+ pCache->serialNumber = pPix->drawable.serialNumber;
+ pCache->trans_color = pCache->bg = pCache->fg = -1;
+ pCache->orig_w = w;
+ pCache->orig_h = h;
+
+ if (w <= 32) {
+ if (w & (w - 1))
+ funcNo = 1;
+ else
+ funcNo = 0;
+ }
+ else
+ funcNo = 2;
+
+ pad = BitmapBytePad(pCache->w * bpp);
+ dwords = bytes_to_int32(pad);
+ dstPtr = data = (unsigned char *) malloc(pad * pCache->h);
+ srcPtr = (unsigned char *) pPix->devPrivate.ptr;
+
+ if (infoRec->
+ ScreenToScreenColorExpandFillFlags & BIT_ORDER_IN_BYTE_MSBFIRST)
+ StippleFunc = XAAStippleScanlineFuncMSBFirst[funcNo];
+ else
+ StippleFunc = XAAStippleScanlineFuncLSBFirst[funcNo];
+
+ /* don't bother generating more than we'll ever use */
+ max = ((pScrn->displayWidth + w - 1) + 31) >> 5;
+ if (dwords > max)
+ dwords = max;
+
+ for (i = 0; i < h; i++) {
+ (*StippleFunc) ((CARD32 *) dstPtr, (CARD32 *) srcPtr, 0, w, dwords);
+ srcPtr += pPix->devKind;
+ dstPtr += pad;
+ }
+
+ while ((h << 1) <= pCache->h) {
+ memcpy(data + (pad * h), data, pad * h);
+ h <<= 1;
+ }
+
+ if (h < pCache->h)
+ memcpy(data + (pad * h), data, pad * (pCache->h - h));
+
+ (*infoRec->WritePixmapToCache) (pScrn, pCache->x, pCache->y, pCache->w,
+ pCache->h, data, pad, bpp, pScrn->depth);
+
+ free(data);
+
+ return pCache;
+}
+
+XAACacheInfoPtr
+XAACachePlanarMonoStipple(ScrnInfoPtr pScrn, PixmapPtr pPix)
+{
+ int w = pPix->drawable.width;
+ int h = pPix->drawable.height;
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ XAAPixmapCachePrivatePtr pCachePriv =
+ (XAAPixmapCachePrivatePtr) infoRec->PixmapCachePrivate;
+ XAACacheInfoPtr pCache, cacheRoot = NULL;
+ int i, max = 0;
+ int *current;
+
+ if ((h <= 128) && (w <= 128)) {
+ if (pCachePriv->Info128) {
+ cacheRoot = pCachePriv->Info128;
+ max = pCachePriv->Num128x128;
+ current = &pCachePriv->Current128;
+ }
+ else {
+ cacheRoot = pCachePriv->InfoPartial;
+ max = pCachePriv->NumPartial;
+ current = &pCachePriv->CurrentPartial;
+ }
+ }
+ else if ((h <= 256) && (w <= 256)) {
+ cacheRoot = pCachePriv->Info256;
+ max = pCachePriv->Num256x256;
+ current = &pCachePriv->Current256;
+ }
+ else if ((h <= 512) && (w <= 526)) {
+ cacheRoot = pCachePriv->Info512;
+ max = pCachePriv->Num512x512;
+ current = &pCachePriv->Current512;
+ }
+ else { /* something's wrong */
+ ErrorF("Something's wrong in XAACachePlanarMonoStipple()\n");
+ return pCachePriv->Info128;
+ }
+
+ pCache = cacheRoot;
+
+ /* lets look for it */
+ for (i = 0; i < max; i++, pCache++) {
+ if ((pCache->serialNumber == pPix->drawable.serialNumber) &&
+ (pCache->fg == -1) && (pCache->bg == -1)) {
+ pCache->trans_color = -1;
+ return pCache;
+ }
+ }
+
+ pCache = &cacheRoot[(*current)++];
+ if (*current >= max)
+ *current = 0;
+
+ pCache->serialNumber = pPix->drawable.serialNumber;
+ pCache->trans_color = pCache->bg = pCache->fg = -1;
+ pCache->orig_w = w;
+ pCache->orig_h = h;
+
+ /* Plane 0 holds the stipple. Plane 1 holds the inverted stipple */
+ (*infoRec->WriteBitmapToCache) (pScrn, pCache->x, pCache->y,
+ pPix->drawable.width, pPix->drawable.height,
+ pPix->devPrivate.ptr, pPix->devKind, 1, 2);
+ if (!(infoRec->PixmapCacheFlags & DO_NOT_TILE_MONO_DATA) &&
+ ((w != pCache->w) || (h != pCache->h)))
+ XAATileCache(pScrn, pCache, w, h);
+
+ return pCache;
+}
+
+XAACachePlanarMonoStippleProc
+XAAGetCachePlanarMonoStipple(void)
+{
+ return XAACachePlanarMonoStipple;
+}
+
+XAACacheInfoPtr
+XAACacheStipple(ScrnInfoPtr pScrn, PixmapPtr pPix, int fg, int bg)
+{
+ int w = pPix->drawable.width;
+ int h = pPix->drawable.height;
+ int size = max(w, h);
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ XAAPixmapCachePrivatePtr pCachePriv =
+ (XAAPixmapCachePrivatePtr) infoRec->PixmapCachePrivate;
+ XAACacheInfoPtr pCache, cacheRoot = NULL;
+ int i, max = 0;
+ int *current;
+
+ if (size <= 128) {
+ if (pCachePriv->Info128) {
+ cacheRoot = pCachePriv->Info128;
+ max = pCachePriv->Num128x128;
+ current = &pCachePriv->Current128;
+ }
+ else {
+ cacheRoot = pCachePriv->InfoPartial;
+ max = pCachePriv->NumPartial;
+ current = &pCachePriv->CurrentPartial;
+ }
+ }
+ else if (size <= 256) {
+ cacheRoot = pCachePriv->Info256;
+ max = pCachePriv->Num256x256;
+ current = &pCachePriv->Current256;
+ }
+ else if (size <= 512) {
+ cacheRoot = pCachePriv->Info512;
+ max = pCachePriv->Num512x512;
+ current = &pCachePriv->Current512;
+ }
+ else { /* something's wrong */
+ ErrorF("Something's wrong in XAACacheStipple()\n");
+ return pCachePriv->Info128;
+ }
+
+ pCache = cacheRoot;
+ /* lets look for it */
+ if (bg == -1)
+ for (i = 0; i < max; i++, pCache++) {
+ if ((pCache->serialNumber == pPix->drawable.serialNumber) &&
+ (fg == pCache->fg) && (pCache->fg != pCache->bg)) {
+ pCache->trans_color = pCache->bg;
+ return pCache;
+ }
+ }
+ else
+ for (i = 0; i < max; i++, pCache++) {
+ if ((pCache->serialNumber == pPix->drawable.serialNumber) &&
+ (fg == pCache->fg) && (bg == pCache->bg)) {
+ pCache->trans_color = -1;
+ return pCache;
+ }
+ }
+
+ pCache = &cacheRoot[(*current)++];
+ if (*current >= max)
+ *current = 0;
+
+ pCache->serialNumber = pPix->drawable.serialNumber;
+ pCache->fg = fg;
+ if (bg == -1)
+ pCache->trans_color = bg = fg ^ 1;
+ else
+ pCache->trans_color = -1;
+ pCache->bg = bg;
+
+ pCache->orig_w = w;
+ pCache->orig_h = h;
+ (*infoRec->WriteBitmapToCache) (pScrn, pCache->x, pCache->y,
+ pPix->drawable.width, pPix->drawable.height,
+ pPix->devPrivate.ptr, pPix->devKind, fg,
+ bg);
+ if (!(infoRec->PixmapCacheFlags & DO_NOT_TILE_COLOR_DATA) &&
+ ((w != pCache->w) || (h != pCache->h)))
+ XAATileCache(pScrn, pCache, w, h);
+
+ return pCache;
+}
+
+XAACacheInfoPtr
+XAACacheMono8x8Pattern(ScrnInfoPtr pScrn, int pat0, int pat1)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ XAAPixmapCachePrivatePtr pCachePriv =
+ (XAAPixmapCachePrivatePtr) infoRec->PixmapCachePrivate;
+ XAACacheInfoPtr pCache = pCachePriv->InfoMono;
+ int i;
+
+ for (i = 0; i < pCachePriv->NumMono; i++, pCache++) {
+ if (pCache->serialNumber &&
+ (pCache->pat0 == pat0) && (pCache->pat1 == pat1))
+ return pCache;
+ }
+
+ /* OK, let's cache it */
+ pCache = &pCachePriv->InfoMono[pCachePriv->CurrentMono++];
+ if (pCachePriv->CurrentMono >= pCachePriv->NumMono)
+ pCachePriv->CurrentMono = 0;
+
+ pCache->serialNumber = 1; /* we don't care since we do lookups by pattern */
+ pCache->pat0 = pat0;
+ pCache->pat1 = pat1;
+
+ (*infoRec->WriteMono8x8PatternToCache) (pScrn, pCache);
+
+ return pCache;
+}
+
+XAACacheInfoPtr
+XAACacheColor8x8Pattern(ScrnInfoPtr pScrn, PixmapPtr pPix, int fg, int bg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ XAAPixmapCachePrivatePtr pCachePriv =
+ (XAAPixmapCachePrivatePtr) infoRec->PixmapCachePrivate;
+ XAACacheInfoPtr pCache = pCachePriv->InfoColor;
+ XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
+ int i;
+
+ if (!(pixPriv->flags & REDUCIBLE_TO_2_COLOR)) {
+ for (i = 0; i < pCachePriv->NumColor; i++, pCache++) {
+ if (pCache->serialNumber == pPix->drawable.serialNumber) {
+ pCache->trans_color = -1;
+ return pCache;
+ }
+ }
+ pCache = &pCachePriv->InfoColor[pCachePriv->CurrentColor++];
+ if (pCachePriv->CurrentColor >= pCachePriv->NumColor)
+ pCachePriv->CurrentColor = 0;
+
+ pCache->serialNumber = pPix->drawable.serialNumber;
+ pCache->trans_color = pCache->fg = pCache->bg = -1;
+ }
+ else {
+ int pat0 = pixPriv->pattern0;
+ int pat1 = pixPriv->pattern1;
+
+ if (fg == -1) { /* it's a tile */
+ fg = pixPriv->fg;
+ bg = pixPriv->bg;
+ }
+
+ if (bg == -1) { /* stipple */
+ for (i = 0; i < pCachePriv->NumColor; i++, pCache++) {
+ if (pCache->serialNumber &&
+ (pCache->pat0 == pat0) && (pCache->pat1 == pat1) &&
+ (pCache->fg == fg) && (pCache->bg != fg)) {
+ pCache->trans_color = pCache->bg;
+ return pCache;
+ }
+ }
+ }
+ else { /* opaque stipple */
+ for (i = 0; i < pCachePriv->NumColor; i++, pCache++) {
+ if (pCache->serialNumber &&
+ (pCache->pat0 == pat0) && (pCache->pat1 == pat1) &&
+ (pCache->fg == fg) && (pCache->bg == bg)) {
+ pCache->trans_color = -1;
+ return pCache;
+ }
+ }
+ }
+ pCache = &pCachePriv->InfoColor[pCachePriv->CurrentColor++];
+ if (pCachePriv->CurrentColor >= pCachePriv->NumColor)
+ pCachePriv->CurrentColor = 0;
+
+ if (bg == -1)
+ pCache->trans_color = bg = fg ^ 1;
+ else
+ pCache->trans_color = -1;
+
+ pCache->pat0 = pat0;
+ pCache->pat1 = pat1;
+ pCache->fg = fg;
+ pCache->bg = bg;
+ pCache->serialNumber = 1;
+ }
+
+ (*infoRec->WriteColor8x8PatternToCache) (pScrn, pPix, pCache);
+
+ return pCache;
+}
+
+void
+XAAWriteBitmapToCache(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src, int srcwidth, int fg, int bg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->WriteBitmap) (pScrn, x, y, w, h, src, srcwidth,
+ 0, fg, bg, GXcopy, ~0);
+}
+
+void
+XAAWriteBitmapToCacheLinear(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src, int srcwidth, int fg, int bg)
+{
+ ScreenPtr pScreen = pScrn->pScreen;
+ PixmapPtr pScreenPix, pDstPix;
+ ChangeGCVal gcvals[2];
+ GCPtr pGC;
+
+ pScreenPix = (*pScreen->GetScreenPixmap) (pScreen);
+
+ pDstPix = GetScratchPixmapHeader(pScreen, pScreenPix->drawable.width,
+ y + h, pScreenPix->drawable.depth,
+ pScreenPix->drawable.bitsPerPixel,
+ pScreenPix->devKind,
+ pScreenPix->devPrivate.ptr);
+
+ pGC = GetScratchGC(pScreenPix->drawable.depth, pScreen);
+ gcvals[0].val = fg;
+ gcvals[1].val = bg;
+ ChangeGC(NullClient, pGC, GCForeground | GCBackground, gcvals);
+ ValidateGC((DrawablePtr) pDstPix, pGC);
+
+ /* We've unwrapped already so these ops miss a sync */
+ SYNC_CHECK(pScrn);
+
+ (*pGC->ops->PutImage) ((DrawablePtr) pDstPix, pGC, 1, x, y, w, h, 0,
+ XYBitmap, (pointer) src);
+
+ FreeScratchGC(pGC);
+ FreeScratchPixmapHeader(pDstPix);
+}
+
+void
+XAAWritePixmapToCache(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src, int srcwidth, int bpp, int depth)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->WritePixmap) (pScrn, x, y, w, h, src, srcwidth,
+ GXcopy, ~0, -1, bpp, depth);
+}
+
+void
+XAAWritePixmapToCacheLinear(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth, int bpp, int depth)
+{
+ ScreenPtr pScreen = pScrn->pScreen;
+ PixmapPtr pScreenPix, pDstPix;
+ GCPtr pGC;
+
+ pScreenPix = (*pScreen->GetScreenPixmap) (pScreen);
+
+ pDstPix = GetScratchPixmapHeader(pScreen, x + w, y + h,
+ depth, bpp, pScreenPix->devKind,
+ pScreenPix->devPrivate.ptr);
+
+ pGC = GetScratchGC(depth, pScreen);
+ ValidateGC((DrawablePtr) pDstPix, pGC);
+
+ /* We've unwrapped already so these ops miss a sync */
+ SYNC_CHECK(pScrn);
+
+ if (bpp == BitsPerPixel(depth))
+ (*pGC->ops->PutImage) ((DrawablePtr) pDstPix, pGC, depth, x, y, w,
+ h, 0, ZPixmap, (pointer) src);
+ else {
+ PixmapPtr pSrcPix;
+
+ pSrcPix = GetScratchPixmapHeader(pScreen, w, h, depth, bpp,
+ srcwidth, (pointer) src);
+
+ (*pGC->ops->CopyArea) ((DrawablePtr) pSrcPix, (DrawablePtr) pDstPix,
+ pGC, 0, 0, w, h, x, y);
+
+ FreeScratchPixmapHeader(pSrcPix);
+ }
+
+ FreeScratchGC(pGC);
+ FreeScratchPixmapHeader(pDstPix);
+}
+
+void
+XAAWriteMono8x8PatternToCache(ScrnInfoPtr pScrn, XAACacheInfoPtr pCache)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ XAAPixmapCachePrivatePtr pCachePriv =
+ (XAAPixmapCachePrivatePtr) infoRec->PixmapCachePrivate;
+ unsigned char *data;
+ int pad, Bpp = (pScrn->bitsPerPixel >> 3);
+
+ pCache->offsets = pCachePriv->MonoOffsets;
+
+ pad = BitmapBytePad(pCache->w * pScrn->bitsPerPixel);
+
+ data = (unsigned char *) malloc(pad * pCache->h);
+ if (!data)
+ return;
+
+ if (infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_ORIGIN) {
+ CARD32 *ptr = (CARD32 *) data;
+
+ ptr[0] = pCache->pat0;
+ ptr[1] = pCache->pat1;
+ }
+ else {
+ CARD32 *ptr;
+ DDXPointPtr pPoint = pCache->offsets;
+ int patx, paty, i;
+
+ for (i = 0; i < 64; i++, pPoint++) {
+ patx = pCache->pat0;
+ paty = pCache->pat1;
+ XAARotateMonoPattern(&patx, &paty, i & 0x07, i >> 3,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ ptr = (CARD32 *) (data + (pad * pPoint->y) + (Bpp * pPoint->x));
+ ptr[0] = patx;
+ ptr[1] = paty;
+ }
+ }
+
+ (*infoRec->WritePixmapToCache) (pScrn, pCache->x, pCache->y,
+ pCache->w, pCache->h, data, pad,
+ pScrn->bitsPerPixel, pScrn->depth);
+
+ free(data);
+}
+
+void
+XAAWriteColor8x8PatternToCache(ScrnInfoPtr pScrn,
+ PixmapPtr pPix, XAACacheInfoPtr pCache)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
+ XAAPixmapCachePrivatePtr pCachePriv =
+ (XAAPixmapCachePrivatePtr) infoRec->PixmapCachePrivate;
+ int pad, i, w, h, nw, nh, Bpp;
+ unsigned char *data, *srcPtr, *dstPtr;
+
+ pCache->offsets = pCachePriv->ColorOffsets;
+
+ if (pixPriv->flags & REDUCIBLE_TO_2_COLOR) {
+ CARD32 *ptr;
+
+ pad = BitmapBytePad(pCache->w);
+ data = (unsigned char *) malloc(pad * pCache->h);
+ if (!data)
+ return;
+
+ if (infoRec->Color8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN) {
+ ptr = (CARD32 *) data;
+ ptr[0] = pCache->pat0;
+ ptr[1] = pCache->pat1;
+ }
+ else {
+ int patx, paty;
+
+ ptr = (CARD32 *) data;
+ ptr[0] = ptr[2] = pCache->pat0;
+ ptr[1] = ptr[3] = pCache->pat1;
+ for (i = 1; i < 8; i++) {
+ patx = pCache->pat0;
+ paty = pCache->pat1;
+ XAARotateMonoPattern(&patx, &paty, i, 0,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ ptr = (CARD32 *) (data + (pad * i));
+ ptr[0] = ptr[2] = patx;
+ ptr[1] = ptr[3] = paty;
+ }
+ }
+
+ (*infoRec->WriteBitmapToCache) (pScrn, pCache->x, pCache->y,
+ pCache->w, pCache->h, data, pad,
+ pCache->fg, pCache->bg);
+
+ free(data);
+ return;
+ }
+
+ Bpp = pScrn->bitsPerPixel >> 3;
+ h = min(8, pPix->drawable.height);
+ w = min(8, pPix->drawable.width);
+ pad = BitmapBytePad(pCache->w * pScrn->bitsPerPixel);
+
+ data = (unsigned char *) malloc(pad * pCache->h);
+ if (!data)
+ return;
+
+ /* Write and expand horizontally. */
+ for (i = h, dstPtr = data, srcPtr = pPix->devPrivate.ptr; i--;
+ srcPtr += pPix->devKind, dstPtr += pScrn->bitsPerPixel) {
+ nw = w;
+ memcpy(dstPtr, srcPtr, w * Bpp);
+ while (nw != 8) {
+ memcpy(dstPtr + (nw * Bpp), dstPtr, nw * Bpp);
+ nw <<= 1;
+ }
+ }
+ nh = h;
+ /* Expand vertically. */
+ while (nh != 8) {
+ memcpy(data + (nh * pScrn->bitsPerPixel), data,
+ nh * pScrn->bitsPerPixel);
+ nh <<= 1;
+ }
+
+ if (!(infoRec->Color8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+ int j;
+ unsigned char *ptr = data + (128 * Bpp);
+
+ memcpy(data + (64 * Bpp), data, 64 * Bpp);
+ for (i = 1; i < 8; i++, ptr += (128 * Bpp)) {
+ for (j = 0; j < 8; j++) {
+ memcpy(ptr + (j * 8) * Bpp, data + (j * 8 + i) * Bpp,
+ (8 - i) * Bpp);
+ memcpy(ptr + (j * 8 + 8 - i) * Bpp, data + j * 8 * Bpp,
+ i * Bpp);
+ }
+ memcpy(ptr + (64 * Bpp), ptr, 64 * Bpp);
+ }
+ }
+
+ (*infoRec->WritePixmapToCache) (pScrn, pCache->x, pCache->y,
+ pCache->w, pCache->h, data, pad,
+ pScrn->bitsPerPixel, pScrn->depth);
+
+ free(data);
+}
+
+int
+XAAStippledFillChooser(GCPtr pGC)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ PixmapPtr pPixmap = pGC->stipple;
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPixmap);
+
+ if (!(pPriv->flags & REDUCIBILITY_CHECKED) &&
+ (infoRec->CanDoMono8x8 || infoRec->CanDoColor8x8)) {
+ XAACheckStippleReducibility(pPixmap);
+ }
+
+ if (pPriv->flags & REDUCIBLE_TO_8x8) {
+ if (infoRec->CanDoMono8x8 &&
+ !(infoRec->FillMono8x8PatternSpansFlags & NO_TRANSPARENCY) &&
+ ((pGC->alu == GXcopy) || !(infoRec->FillMono8x8PatternSpansFlags &
+ TRANSPARENCY_GXCOPY_ONLY)) &&
+ CHECK_ROP(pGC, infoRec->FillMono8x8PatternSpansFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->FillMono8x8PatternSpansFlags) &&
+ CHECK_FG(pGC, infoRec->FillMono8x8PatternSpansFlags) &&
+ CHECK_PLANEMASK(pGC, infoRec->FillMono8x8PatternSpansFlags)) {
+
+ return DO_MONO_8x8;
+ }
+
+ if (infoRec->CanDoColor8x8 &&
+ !(infoRec->FillColor8x8PatternSpansFlags & NO_TRANSPARENCY) &&
+ ((pGC->alu == GXcopy) || !(infoRec->FillColor8x8PatternSpansFlags &
+ TRANSPARENCY_GXCOPY_ONLY)) &&
+ CHECK_ROP(pGC, infoRec->FillColor8x8PatternSpansFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->FillColor8x8PatternSpansFlags) &&
+ CHECK_PLANEMASK(pGC, infoRec->FillColor8x8PatternSpansFlags)) {
+
+ return DO_COLOR_8x8;
+ }
+ }
+
+ if (infoRec->UsingPixmapCache && infoRec->FillCacheExpandSpans &&
+ (pPixmap->drawable.height <= infoRec->MaxCacheableStippleHeight) &&
+ (pPixmap->drawable.width <= infoRec->MaxCacheableStippleWidth /
+ infoRec->CacheColorExpandDensity) &&
+ !(infoRec->FillCacheExpandSpansFlags & NO_TRANSPARENCY) &&
+ ((pGC->alu == GXcopy) || !(infoRec->FillCacheExpandSpansFlags &
+ TRANSPARENCY_GXCOPY_ONLY)) &&
+ CHECK_ROP(pGC, infoRec->FillCacheExpandSpansFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->FillCacheExpandSpansFlags) &&
+ CHECK_FG(pGC, infoRec->FillCacheExpandSpansFlags) &&
+ CHECK_PLANEMASK(pGC, infoRec->FillCacheExpandSpansFlags)) {
+
+ return DO_CACHE_EXPAND;
+ }
+
+ if (infoRec->UsingPixmapCache &&
+ !(infoRec->PixmapCacheFlags & DO_NOT_BLIT_STIPPLES) &&
+ infoRec->FillCacheBltSpans &&
+ (pPixmap->drawable.height <= infoRec->MaxCacheableTileHeight) &&
+ (pPixmap->drawable.width <= infoRec->MaxCacheableTileWidth) &&
+ !(infoRec->FillCacheBltSpansFlags & NO_TRANSPARENCY) &&
+ ((pGC->alu == GXcopy) || !(infoRec->FillCacheBltSpansFlags &
+ TRANSPARENCY_GXCOPY_ONLY)) &&
+ CHECK_ROP(pGC, infoRec->FillCacheBltSpansFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->FillCacheBltSpansFlags) &&
+ CHECK_PLANEMASK(pGC, infoRec->FillCacheBltSpansFlags)) {
+
+ return DO_CACHE_BLT;
+ }
+
+ if (infoRec->FillColorExpandSpans &&
+ !(infoRec->FillColorExpandSpansFlags & NO_TRANSPARENCY) &&
+ ((pGC->alu == GXcopy) || !(infoRec->FillColorExpandSpansFlags &
+ TRANSPARENCY_GXCOPY_ONLY)) &&
+ CHECK_ROP(pGC, infoRec->FillColorExpandSpansFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->FillColorExpandSpansFlags) &&
+ CHECK_FG(pGC, infoRec->FillColorExpandSpansFlags) &&
+ CHECK_PLANEMASK(pGC, infoRec->FillColorExpandSpansFlags)) {
+
+ return DO_COLOR_EXPAND;
+ }
+
+ return 0;
+}
+
+int
+XAAOpaqueStippledFillChooser(GCPtr pGC)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ PixmapPtr pPixmap = pGC->stipple;
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPixmap);
+
+ if (XAA_DEPTH_BUG(pGC))
+ return 0;
+
+ if (!(pPriv->flags & REDUCIBILITY_CHECKED) &&
+ (infoRec->CanDoMono8x8 || infoRec->CanDoColor8x8)) {
+ XAACheckStippleReducibility(pPixmap);
+ }
+
+ if (pPriv->flags & REDUCIBLE_TO_8x8) {
+ if (infoRec->CanDoMono8x8 &&
+ !(infoRec->FillMono8x8PatternSpansFlags & TRANSPARENCY_ONLY) &&
+ CHECK_ROP(pGC, infoRec->FillMono8x8PatternSpansFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->FillMono8x8PatternSpansFlags) &&
+ CHECK_COLORS(pGC, infoRec->FillMono8x8PatternSpansFlags) &&
+ CHECK_PLANEMASK(pGC, infoRec->FillMono8x8PatternSpansFlags)) {
+
+ return DO_MONO_8x8;
+ }
+
+ if (infoRec->CanDoColor8x8 &&
+ CHECK_ROP(pGC, infoRec->FillColor8x8PatternSpansFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->FillColor8x8PatternSpansFlags) &&
+ CHECK_PLANEMASK(pGC, infoRec->FillColor8x8PatternSpansFlags)) {
+
+ return DO_COLOR_8x8;
+ }
+ }
+
+ if (infoRec->UsingPixmapCache && infoRec->FillCacheExpandSpans &&
+ (pPixmap->drawable.height <= infoRec->MaxCacheableStippleHeight) &&
+ (pPixmap->drawable.width <= infoRec->MaxCacheableStippleWidth /
+ infoRec->CacheColorExpandDensity) &&
+ !(infoRec->FillCacheExpandSpansFlags & TRANSPARENCY_ONLY) &&
+ CHECK_ROP(pGC, infoRec->FillCacheExpandSpansFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->FillCacheExpandSpansFlags) &&
+ CHECK_COLORS(pGC, infoRec->FillCacheExpandSpansFlags) &&
+ CHECK_PLANEMASK(pGC, infoRec->FillCacheExpandSpansFlags)) {
+
+ return DO_CACHE_EXPAND;
+ }
+
+ if (infoRec->UsingPixmapCache &&
+ !(infoRec->PixmapCacheFlags & DO_NOT_BLIT_STIPPLES) &&
+ infoRec->FillCacheBltSpans &&
+ (pPixmap->drawable.height <= infoRec->MaxCacheableTileHeight) &&
+ (pPixmap->drawable.width <= infoRec->MaxCacheableTileWidth) &&
+ CHECK_ROP(pGC, infoRec->FillCacheBltSpansFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->FillCacheBltSpansFlags) &&
+ CHECK_PLANEMASK(pGC, infoRec->FillCacheBltSpansFlags)) {
+
+ return DO_CACHE_BLT;
+ }
+
+ if (infoRec->FillColorExpandSpans &&
+ !(infoRec->FillColorExpandSpansFlags & TRANSPARENCY_ONLY) &&
+ CHECK_ROP(pGC, infoRec->FillColorExpandSpansFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->FillColorExpandSpansFlags) &&
+ CHECK_COLORS(pGC, infoRec->FillColorExpandSpansFlags) &&
+ CHECK_PLANEMASK(pGC, infoRec->FillColorExpandSpansFlags)) {
+
+ return DO_COLOR_EXPAND;
+ }
+
+ return 0;
+}
+
+int
+XAATiledFillChooser(GCPtr pGC)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ PixmapPtr pPixmap = pGC->tile.pixmap;
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPixmap);
+
+ if (IS_OFFSCREEN_PIXMAP(pPixmap) && infoRec->FillCacheBltSpans &&
+ CHECK_ROP(pGC, infoRec->FillCacheBltSpansFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->FillCacheBltSpansFlags) &&
+ CHECK_PLANEMASK(pGC, infoRec->FillCacheBltSpansFlags)) {
+
+ return DO_PIXMAP_COPY;
+ }
+
+ if (!(pPriv->flags & REDUCIBILITY_CHECKED) &&
+ (infoRec->CanDoMono8x8 || infoRec->CanDoColor8x8)) {
+ XAACheckTileReducibility(pPixmap, infoRec->CanDoMono8x8);
+ }
+
+ if (pPriv->flags & REDUCIBLE_TO_8x8) {
+ if ((pPriv->flags & REDUCIBLE_TO_2_COLOR) && infoRec->CanDoMono8x8 &&
+ !(infoRec->FillMono8x8PatternSpansFlags & TRANSPARENCY_ONLY) &&
+ CHECK_ROP(pGC, infoRec->FillMono8x8PatternSpansFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->FillMono8x8PatternSpansFlags) &&
+ (!(infoRec->FillMono8x8PatternSpansFlags & RGB_EQUAL) ||
+ (CHECK_RGB_EQUAL(pPriv->fg) && CHECK_RGB_EQUAL(pPriv->bg))) &&
+ CHECK_PLANEMASK(pGC, infoRec->FillMono8x8PatternSpansFlags)) {
+
+ return DO_MONO_8x8;
+ }
+
+ if (infoRec->CanDoColor8x8 &&
+ CHECK_ROP(pGC, infoRec->FillColor8x8PatternSpansFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->FillColor8x8PatternSpansFlags) &&
+ CHECK_PLANEMASK(pGC, infoRec->FillColor8x8PatternSpansFlags)) {
+
+ return DO_COLOR_8x8;
+ }
+ }
+
+ if (infoRec->UsingPixmapCache && infoRec->FillCacheBltSpans &&
+ (pPixmap->drawable.height <= infoRec->MaxCacheableTileHeight) &&
+ (pPixmap->drawable.width <= infoRec->MaxCacheableTileWidth) &&
+ CHECK_ROP(pGC, infoRec->FillCacheBltSpansFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->FillCacheBltSpansFlags) &&
+ CHECK_PLANEMASK(pGC, infoRec->FillCacheBltSpansFlags)) {
+
+ return DO_CACHE_BLT;
+ }
+
+ if (infoRec->FillImageWriteRects &&
+ CHECK_NO_GXCOPY(pGC, infoRec->FillImageWriteRectsFlags) &&
+ CHECK_ROP(pGC, infoRec->FillImageWriteRectsFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->FillImageWriteRectsFlags) &&
+ CHECK_PLANEMASK(pGC, infoRec->FillImageWriteRectsFlags)) {
+
+ return DO_IMAGE_WRITE;
+ }
+
+ return 0;
+}
+
+static int RotateMasksX[8] = {
+ 0xFFFFFFFF, 0x7F7F7F7F, 0x3F3F3F3F, 0x1F1F1F1F,
+ 0x0F0F0F0F, 0x07070707, 0x03030303, 0x01010101
+};
+
+static int RotateMasksY[4] = {
+ 0xFFFFFFFF, 0x00FFFFFF, 0x0000FFFF, 0x000000FF
+};
+
+void
+XAARotateMonoPattern(int *pat0, int *pat1, int xorg, int yorg, Bool msbfirst)
+{
+ int tmp, mask;
+
+ if (xorg) {
+ if (msbfirst)
+ xorg = 8 - xorg;
+ mask = RotateMasksX[xorg];
+ *pat0 = ((*pat0 >> xorg) & mask) | ((*pat0 << (8 - xorg)) & ~mask);
+ *pat1 = ((*pat1 >> xorg) & mask) | ((*pat1 << (8 - xorg)) & ~mask);
+ }
+ if (yorg >= 4) {
+ tmp = *pat0;
+ *pat0 = *pat1;
+ *pat1 = tmp;
+ yorg -= 4;
+ }
+ if (yorg) {
+ mask = RotateMasksY[yorg];
+ yorg <<= 3;
+ tmp = *pat0;
+ *pat0 = ((*pat0 >> yorg) & mask) | ((*pat1 << (32 - yorg)) & ~mask);
+ *pat1 = ((*pat1 >> yorg) & mask) | ((tmp << (32 - yorg)) & ~mask);
+ }
+}
+
+void
+XAAInvalidatePixmapCache(ScreenPtr pScreen)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+ XAAPixmapCachePrivatePtr pCachePriv =
+ (XAAPixmapCachePrivatePtr) infoRec->PixmapCachePrivate;
+ int i;
+
+ if (!pCachePriv)
+ return;
+
+ for (i = 0; i < pCachePriv->Num512x512; i++)
+ (pCachePriv->Info512)[i].serialNumber = 0;
+ for (i = 0; i < pCachePriv->Num256x256; i++)
+ (pCachePriv->Info256)[i].serialNumber = 0;
+ for (i = 0; i < pCachePriv->Num128x128; i++)
+ (pCachePriv->Info128)[i].serialNumber = 0;
+ for (i = 0; i < pCachePriv->NumPartial; i++)
+ (pCachePriv->InfoPartial)[i].serialNumber = 0;
+ for (i = 0; i < pCachePriv->NumMono; i++)
+ (pCachePriv->InfoMono)[i].serialNumber = 0;
+ for (i = 0; i < pCachePriv->NumColor; i++)
+ (pCachePriv->InfoColor)[i].serialNumber = 0;
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaPict.c b/xorg-server/hw/xfree86/xaa/xaaPict.c
index 1ad75835b..0721768ed 100644
--- a/xorg-server/hw/xfree86/xaa/xaaPict.c
+++ b/xorg-server/hw/xfree86/xaa/xaaPict.c
@@ -1,655 +1,654 @@
-/*
- *
- * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <string.h>
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "windowstr.h"
-#include "xf86str.h"
-#include "mi.h"
-#include "picturestr.h"
-#include "glyphstr.h"
-#include "picture.h"
-#include "mipict.h"
-#include "xaa.h"
-#include "xaalocal.h"
-#include "xaawrap.h"
-#include "xaacexp.h"
-#include "xf86fbman.h"
-#include "servermd.h"
-
-Bool
-XAAGetPixelFromRGBA (
- CARD32 *pixel,
- CARD16 red,
- CARD16 green,
- CARD16 blue,
- CARD16 alpha,
- CARD32 format
-){
- int rbits, bbits, gbits, abits;
- int rshift, bshift, gshift, ashift;
-
- *pixel = 0;
-
- if(!PICT_FORMAT_COLOR(format))
- return FALSE;
-
- rbits = PICT_FORMAT_R(format);
- gbits = PICT_FORMAT_G(format);
- bbits = PICT_FORMAT_B(format);
- abits = PICT_FORMAT_A(format);
-
- if(PICT_FORMAT_TYPE(format) == PICT_TYPE_ARGB) {
- bshift = 0;
- gshift = bbits;
- rshift = gshift + gbits;
- ashift = rshift + rbits;
- } else if(PICT_FORMAT_TYPE(format) == PICT_TYPE_ABGR) {
- rshift = 0;
- gshift = rbits;
- bshift = gshift + gbits;
- ashift = bshift + bbits;
- } else if(PICT_FORMAT_TYPE(format) == PICT_TYPE_BGRA) {
- bshift = PICT_FORMAT_BPP(format) - bbits;
- gshift = bshift - gbits;
- rshift = gshift - rbits;
- ashift = 0;
- } else
- return FALSE;
-
- *pixel |= ( blue >> (16 - bbits)) << bshift;
- *pixel |= ( red >> (16 - rbits)) << rshift;
- *pixel |= (green >> (16 - gbits)) << gshift;
- *pixel |= (alpha >> (16 - abits)) << ashift;
-
- return TRUE;
-}
-
-
-Bool
-XAAGetRGBAFromPixel(
- CARD32 pixel,
- CARD16 *red,
- CARD16 *green,
- CARD16 *blue,
- CARD16 *alpha,
- CARD32 format
-){
- int rbits, bbits, gbits, abits;
- int rshift, bshift, gshift, ashift;
-
- if(!PICT_FORMAT_COLOR(format))
- return FALSE;
-
- rbits = PICT_FORMAT_R(format);
- gbits = PICT_FORMAT_G(format);
- bbits = PICT_FORMAT_B(format);
- abits = PICT_FORMAT_A(format);
-
- if(PICT_FORMAT_TYPE(format) == PICT_TYPE_ARGB) {
- bshift = 0;
- gshift = bbits;
- rshift = gshift + gbits;
- ashift = rshift + rbits;
- } else if(PICT_FORMAT_TYPE(format) == PICT_TYPE_ABGR) {
- rshift = 0;
- gshift = rbits;
- bshift = gshift + gbits;
- ashift = bshift + bbits;
- } else if(PICT_FORMAT_TYPE(format) == PICT_TYPE_BGRA) {
- bshift = PICT_FORMAT_BPP(format) - bbits;
- gshift = bshift - gbits;
- rshift = gshift - rbits;
- ashift = 0;
- } else
- return FALSE;
-
- *red = ((pixel >> rshift ) & ((1 << rbits) - 1)) << (16 - rbits);
- while(rbits < 16) {
- *red |= *red >> rbits;
- rbits <<= 1;
- }
-
- *green = ((pixel >> gshift ) & ((1 << gbits) - 1)) << (16 - gbits);
- while(gbits < 16) {
- *green |= *green >> gbits;
- gbits <<= 1;
- }
-
- *blue = ((pixel >> bshift ) & ((1 << bbits) - 1)) << (16 - bbits);
- while(bbits < 16) {
- *blue |= *blue >> bbits;
- bbits <<= 1;
- }
-
- if(abits) {
- *alpha = ((pixel >> ashift ) & ((1 << abits) - 1)) << (16 - abits);
- while(abits < 16) {
- *alpha |= *alpha >> abits;
- abits <<= 1;
- }
- } else *alpha = 0xffff;
-
- return TRUE;
-}
-
-/* 8:8:8 + PICT_a8 -> 8:8:8:8 texture */
-
-void
-XAA_888_plus_PICT_a8_to_8888 (
- CARD32 color,
- CARD8 *alphaPtr, /* in bytes */
- int alphaPitch,
- CARD32 *dstPtr,
- int dstPitch, /* in dwords */
- int width,
- int height
-){
- int x;
-
- color &= 0x00ffffff;
-
- while(height--) {
- for(x = 0; x < width; x++)
- dstPtr[x] = color | (alphaPtr[x] << 24);
- dstPtr += dstPitch;
- alphaPtr += alphaPitch;
- }
-}
-
-#define DRAWABLE_IS_ON_CARD(pDraw) \
- (pDraw->type == DRAWABLE_WINDOW || \
- (pDraw->type == DRAWABLE_PIXMAP && IS_OFFSCREEN_PIXMAP(pDraw)))
-
-Bool
-XAADoComposite (
- CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst,
- CARD16 width,
- CARD16 height
-){
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
- RegionRec region;
- CARD32 *formats, *dstformats;
- int flags = 0;
- BoxPtr pbox;
- int nbox, w, h;
-
- if(!RegionNumRects(pDst->pCompositeClip))
- return TRUE;
-
- if(!infoRec->pScrn->vtSema || !DRAWABLE_IS_ON_CARD(pDst->pDrawable))
- return FALSE;
-
- if(DRAWABLE_IS_ON_CARD(pSrc->pDrawable))
- return FALSE;
-
- if (pSrc->transform || (pMask && pMask->transform))
- return FALSE;
-
- if (pDst->alphaMap || pSrc->alphaMap || (pMask && pMask->alphaMap))
- return FALSE;
-
- if ((pSrc->repeat && pSrc->repeatType != RepeatNormal) ||
- (pMask && pMask->repeat && pMask->repeatType != RepeatNormal))
- {
- return FALSE;
- }
-
- xDst += pDst->pDrawable->x;
- yDst += pDst->pDrawable->y;
- xSrc += pSrc->pDrawable->x;
- ySrc += pSrc->pDrawable->y;
-
- if(pMask) {
- if(pMask->componentAlpha)
- return FALSE;
-
- /* for now we only do it if there is a 1x1 (solid) source */
-
- if((pSrc->pDrawable->width == 1) && (pSrc->pDrawable->height == 1)) {
- CARD16 red, green, blue, alpha;
- CARD32 pixel =
- *((CARD32*)(((PixmapPtr)(pSrc->pDrawable))->devPrivate.ptr));
-
- if(!XAAGetRGBAFromPixel(pixel,&red,&green,&blue,&alpha,pSrc->format))
- return FALSE;
-
- xMask += pMask->pDrawable->x;
- yMask += pMask->pDrawable->y;
-
- /* pull out color expandable operations here */
- if((pMask->format == PICT_a1) && (alpha == 0xffff) &&
- (op == PictOpOver) && infoRec->WriteBitmap && !pMask->repeat &&
- !(infoRec->WriteBitmapFlags & NO_TRANSPARENCY) &&
- (!(infoRec->WriteBitmapFlags & RGB_EQUAL) ||
- ((red == green) && (green == blue))))
- {
- PixmapPtr pPix = (PixmapPtr)(pMask->pDrawable);
- int skipleft;
-
- if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst,
- xSrc, ySrc, xMask, yMask, xDst, yDst,
- width, height))
- return TRUE;
-
- nbox = RegionNumRects(&region);
- pbox = RegionRects(&region);
-
- if(!nbox)
- return TRUE;
-
- XAAGetPixelFromRGBA(&pixel, red, green, blue, 0, pDst->format);
-
- xMask -= xDst;
- yMask -= yDst;
-
- while(nbox--) {
- skipleft = pbox->x1 + xMask;
-
- (*infoRec->WriteBitmap)(infoRec->pScrn,
- pbox->x1, pbox->y1,
- pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
- (unsigned char*)(pPix->devPrivate.ptr) +
- (pPix->devKind * (pbox->y1 + yMask)) +
- ((skipleft >> 3) & ~3), pPix->devKind,
- skipleft & 31, pixel, -1, GXcopy, ~0);
- pbox++;
- }
-
- /* WriteBitmap sets the Sync flag */
- RegionUninit(&region);
- return TRUE;
- }
-
- formats = infoRec->CPUToScreenAlphaTextureFormats;
- dstformats = infoRec->CPUToScreenAlphaTextureDstFormats;
- if(!formats || !dstformats)
- return FALSE;
-
- w = pMask->pDrawable->width;
- h = pMask->pDrawable->height;
-
- if(pMask->repeat) {
- if((infoRec->CPUToScreenAlphaTextureFlags & XAA_RENDER_NO_TILE) ||
- ((infoRec->CPUToScreenAlphaTextureFlags &
- XAA_RENDER_POWER_OF_2_TILE_ONLY) &&
- ((h & (h - 1)) || (w & (w - 1)))))
- {
- return FALSE;
- }
- flags |= XAA_RENDER_REPEAT;
- }
-
- if((alpha != 0xffff) &&
- (infoRec->CPUToScreenAlphaTextureFlags & XAA_RENDER_NO_SRC_ALPHA))
- return FALSE;
-
- while(*formats != pMask->format) {
- if(!(*formats)) return FALSE;
- formats++;
- }
- while(*dstformats != pDst->format) {
- if(!(*dstformats))
- return FALSE;
- dstformats++;
- }
-
- if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst,
- xSrc, ySrc, xMask, yMask, xDst, yDst,
- width, height))
- return TRUE;
-
- nbox = RegionNumRects(&region);
- pbox = RegionRects(&region);
-
- if(!nbox) {
- RegionUninit(&region);
- return TRUE;
- }
-
- if(!(infoRec->SetupForCPUToScreenAlphaTexture2)(infoRec->pScrn,
- op, red, green, blue, alpha, pMask->format,
- pDst->format,
- ((PixmapPtr)(pMask->pDrawable))->devPrivate.ptr,
- ((PixmapPtr)(pMask->pDrawable))->devKind,
- w, h, flags))
- {
- RegionUninit(&region);
- return FALSE;
- }
-
- xMask -= xDst;
- yMask -= yDst;
-
- while(nbox--) {
- (*infoRec->SubsequentCPUToScreenAlphaTexture)(infoRec->pScrn,
- pbox->x1, pbox->y1,
- pbox->x1 + xMask, pbox->y1 + yMask,
- pbox->x2 - pbox->x1, pbox->y2 - pbox->y1);
- pbox++;
- }
-
- SET_SYNC_FLAG(infoRec);
- RegionUninit(&region);
- return TRUE;
- }
- } else {
- formats = infoRec->CPUToScreenTextureFormats;
- dstformats = infoRec->CPUToScreenTextureDstFormats;
- if(!formats || !dstformats)
- return FALSE;
-
- w = pSrc->pDrawable->width;
- h = pSrc->pDrawable->height;
-
- if(pSrc->repeat) {
- if((infoRec->CPUToScreenTextureFlags & XAA_RENDER_NO_TILE) ||
- ((infoRec->CPUToScreenTextureFlags &
- XAA_RENDER_POWER_OF_2_TILE_ONLY) &&
- ((h & (h - 1)) || (w & (w - 1)))))
- {
- return FALSE;
- }
- flags |= XAA_RENDER_REPEAT;
- }
-
- while(*formats != pSrc->format) {
- if(!(*formats)) return FALSE;
- formats++;
- }
- while(*dstformats != pDst->format) {
- if(!(*dstformats))
- return FALSE;
- dstformats++;
- }
-
- if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst,
- xSrc, ySrc, xMask, yMask, xDst, yDst,
- width, height))
- return TRUE;
-
- nbox = RegionNumRects(&region);
- pbox = RegionRects(&region);
-
- if(!nbox) {
- RegionUninit(&region);
- return TRUE;
- }
-
- if(!(infoRec->SetupForCPUToScreenTexture2)(infoRec->pScrn,
- op, pSrc->format, pDst->format,
- ((PixmapPtr)(pSrc->pDrawable))->devPrivate.ptr,
- ((PixmapPtr)(pSrc->pDrawable))->devKind,
- w, h, flags))
- {
- RegionUninit(&region);
- return FALSE;
- }
-
-
- xSrc -= xDst;
- ySrc -= yDst;
-
- while(nbox--) {
- (*infoRec->SubsequentCPUToScreenTexture)(infoRec->pScrn,
- pbox->x1, pbox->y1,
- pbox->x1 + xSrc, pbox->y1 + ySrc,
- pbox->x2 - pbox->x1, pbox->y2 - pbox->y1);
- pbox++;
- }
-
- SET_SYNC_FLAG(infoRec);
- RegionUninit(&region);
- return TRUE;
- }
-
-
- return FALSE;
-}
-
-static void
-XAACompositeSrcCopy (PicturePtr pSrc,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xDst,
- INT16 yDst,
- CARD16 width,
- CARD16 height)
-{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
- int i, nbox;
- int xoff, yoff;
- BoxPtr pbox;
- DDXPointPtr pptSrc;
- RegionRec region;
-
- xDst += pDst->pDrawable->x;
- yDst += pDst->pDrawable->y;
- xSrc += pSrc->pDrawable->x;
- ySrc += pSrc->pDrawable->y;
-
- if (!miComputeCompositeRegion (&region, pSrc, NULL, pDst,
- xSrc, ySrc, 0, 0, xDst, yDst,
- width, height))
- return;
-
- nbox = RegionNumRects(&region);
- pbox = RegionRects(&region);
-
- if(!nbox) {
- RegionUninit(&region);
- return;
- }
- pptSrc = malloc(sizeof(DDXPointRec) * nbox);
- if (!pptSrc) {
- RegionUninit(&region);
- return;
- }
- xoff = xSrc - xDst;
- yoff = ySrc - yDst;
- for (i = 0; i < nbox; i++) {
- pptSrc[i].x = pbox[i].x1 + xoff;
- pptSrc[i].y = pbox[i].y1 + yoff;
- }
-
- infoRec->ScratchGC.planemask = ~0L;
- infoRec->ScratchGC.alu = GXcopy;
-
- XAADoBitBlt(pSrc->pDrawable, pDst->pDrawable, &infoRec->ScratchGC, &region,
- pptSrc);
-
- free(pptSrc);
- RegionUninit(&region);
- return;
-}
-
-void
-XAAComposite (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst,
- CARD16 width,
- CARD16 height)
-{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
- XAA_RENDER_PROLOGUE(pScreen, Composite);
-
- if(!pMask && infoRec->pScrn->vtSema &&
- infoRec->ScreenToScreenBitBlt &&
- pSrc->pDrawable &&
- DRAWABLE_IS_ON_CARD(pSrc->pDrawable) &&
- DRAWABLE_IS_ON_CARD(pDst->pDrawable) &&
- !pSrc->transform &&
- (!pSrc->repeat || (xSrc >= 0 && ySrc >= 0 &&
- xSrc+width<=pSrc->pDrawable->width &&
- ySrc+height<=pSrc->pDrawable->height)) &&
- ((op == PictOpSrc &&
- ((pSrc->format==pDst->format) ||
- (pSrc->format==PICT_a8r8g8b8 && pDst->format==PICT_x8r8g8b8) ||
- (pSrc->format==PICT_a8b8g8r8 && pDst->format==PICT_x8b8g8r8))) ||
- (op == PictOpOver && !pSrc->alphaMap && !pDst->alphaMap &&
- pSrc->format==pDst->format &&
- (pSrc->format==PICT_x8r8g8b8 || pSrc->format==PICT_x8b8g8r8))))
- {
- XAACompositeSrcCopy(pSrc, pDst, xSrc, ySrc, xDst, yDst, width, height);
- } else if(!pSrc->pDrawable || (pMask && !pMask->pDrawable) ||
- !infoRec->Composite ||
- !(*infoRec->Composite)(op, pSrc, pMask, pDst,
- xSrc, ySrc, xMask, yMask, xDst, yDst,
- width, height))
- {
- if(infoRec->pScrn->vtSema &&
- ((pSrc->pDrawable &&
- (pSrc->pDrawable->type == DRAWABLE_WINDOW || IS_OFFSCREEN_PIXMAP(pSrc->pDrawable))) ||
- pDst->pDrawable->type == DRAWABLE_WINDOW || IS_OFFSCREEN_PIXMAP(pDst->pDrawable))) {
- SYNC_CHECK(pDst->pDrawable);
- }
- (*GetPictureScreen(pScreen)->Composite) (op,
- pSrc,
- pMask,
- pDst,
- xSrc,
- ySrc,
- xMask,
- yMask,
- xDst,
- yDst,
- width,
- height);
- }
-
- if(pDst->pDrawable->type == DRAWABLE_PIXMAP)
- (XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pDst->pDrawable)))->flags |= DIRTY;
-
- XAA_RENDER_EPILOGUE(pScreen, Composite, XAAComposite);
-}
-
-Bool
-XAADoGlyphs (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pDst,
- PictFormatPtr maskFormat,
- INT16 xSrc,
- INT16 ySrc,
- int nlist,
- GlyphListPtr list,
- GlyphPtr *glyphs)
-{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
-
- if(!RegionNumRects(pDst->pCompositeClip))
- return TRUE;
-
- if(!infoRec->pScrn->vtSema ||
- ((pDst->pDrawable->type != DRAWABLE_WINDOW) &&
- !IS_OFFSCREEN_PIXMAP(pDst->pDrawable)))
- return FALSE;
-
- if((pSrc->pDrawable->type != DRAWABLE_PIXMAP) ||
- IS_OFFSCREEN_PIXMAP(pSrc->pDrawable))
- return FALSE;
-
- /*
- * If it looks like we have a chance of being able to draw these
- * glyphs with an accelerated Composite, do that now to avoid
- * unneeded and costly syncs.
- */
- if(maskFormat) {
- if(!infoRec->CPUToScreenAlphaTextureFormats)
- return FALSE;
- } else {
- if(!infoRec->CPUToScreenTextureFormats)
- return FALSE;
- }
-
- miGlyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
-
- return TRUE;
-}
-
-
-void
-XAAGlyphs (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pDst,
- PictFormatPtr maskFormat,
- INT16 xSrc,
- INT16 ySrc,
- int nlist,
- GlyphListPtr list,
- GlyphPtr *glyphs)
-{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
- XAA_RENDER_PROLOGUE(pScreen, Glyphs);
-
- if(!pSrc->pDrawable || !infoRec->Glyphs ||
- !(*infoRec->Glyphs)(op, pSrc, pDst, maskFormat,
- xSrc, ySrc, nlist, list, glyphs))
- {
- if(infoRec->pScrn->vtSema &&
- ((pSrc->pDrawable &&
- (pSrc->pDrawable->type == DRAWABLE_WINDOW || IS_OFFSCREEN_PIXMAP(pSrc->pDrawable))) ||
- pDst->pDrawable->type == DRAWABLE_WINDOW || IS_OFFSCREEN_PIXMAP(pDst->pDrawable))) {
- SYNC_CHECK(pDst->pDrawable);
- }
- (*GetPictureScreen(pScreen)->Glyphs) (op, pSrc, pDst, maskFormat,
- xSrc, ySrc, nlist, list, glyphs);
- }
-
- if(pDst->pDrawable->type == DRAWABLE_PIXMAP)
- (XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pDst->pDrawable)))->flags |= DIRTY;
-
- XAA_RENDER_EPILOGUE(pScreen, Glyphs, XAAGlyphs);
-}
+/*
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <string.h>
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "xf86str.h"
+#include "mi.h"
+#include "picturestr.h"
+#include "glyphstr.h"
+#include "picture.h"
+#include "mipict.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "xaawrap.h"
+#include "xaacexp.h"
+#include "xf86fbman.h"
+#include "servermd.h"
+
+Bool
+XAAGetPixelFromRGBA(CARD32 *pixel,
+ CARD16 red,
+ CARD16 green, CARD16 blue, CARD16 alpha, CARD32 format)
+{
+ int rbits, bbits, gbits, abits;
+ int rshift, bshift, gshift, ashift;
+
+ *pixel = 0;
+
+ if (!PICT_FORMAT_COLOR(format))
+ return FALSE;
+
+ rbits = PICT_FORMAT_R(format);
+ gbits = PICT_FORMAT_G(format);
+ bbits = PICT_FORMAT_B(format);
+ abits = PICT_FORMAT_A(format);
+
+ if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ARGB) {
+ bshift = 0;
+ gshift = bbits;
+ rshift = gshift + gbits;
+ ashift = rshift + rbits;
+ }
+ else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ABGR) {
+ rshift = 0;
+ gshift = rbits;
+ bshift = gshift + gbits;
+ ashift = bshift + bbits;
+ }
+ else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_BGRA) {
+ bshift = PICT_FORMAT_BPP(format) - bbits;
+ gshift = bshift - gbits;
+ rshift = gshift - rbits;
+ ashift = 0;
+ }
+ else
+ return FALSE;
+
+ *pixel |= (blue >> (16 - bbits)) << bshift;
+ *pixel |= (red >> (16 - rbits)) << rshift;
+ *pixel |= (green >> (16 - gbits)) << gshift;
+ *pixel |= (alpha >> (16 - abits)) << ashift;
+
+ return TRUE;
+}
+
+Bool
+XAAGetRGBAFromPixel(CARD32 pixel,
+ CARD16 *red,
+ CARD16 *green, CARD16 *blue, CARD16 *alpha, CARD32 format)
+{
+ int rbits, bbits, gbits, abits;
+ int rshift, bshift, gshift, ashift;
+
+ if (!PICT_FORMAT_COLOR(format))
+ return FALSE;
+
+ rbits = PICT_FORMAT_R(format);
+ gbits = PICT_FORMAT_G(format);
+ bbits = PICT_FORMAT_B(format);
+ abits = PICT_FORMAT_A(format);
+
+ if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ARGB) {
+ bshift = 0;
+ gshift = bbits;
+ rshift = gshift + gbits;
+ ashift = rshift + rbits;
+ }
+ else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ABGR) {
+ rshift = 0;
+ gshift = rbits;
+ bshift = gshift + gbits;
+ ashift = bshift + bbits;
+ }
+ else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_BGRA) {
+ bshift = PICT_FORMAT_BPP(format) - bbits;
+ gshift = bshift - gbits;
+ rshift = gshift - rbits;
+ ashift = 0;
+ }
+ else
+ return FALSE;
+
+ *red = ((pixel >> rshift) & ((1 << rbits) - 1)) << (16 - rbits);
+ while (rbits < 16) {
+ *red |= *red >> rbits;
+ rbits <<= 1;
+ }
+
+ *green = ((pixel >> gshift) & ((1 << gbits) - 1)) << (16 - gbits);
+ while (gbits < 16) {
+ *green |= *green >> gbits;
+ gbits <<= 1;
+ }
+
+ *blue = ((pixel >> bshift) & ((1 << bbits) - 1)) << (16 - bbits);
+ while (bbits < 16) {
+ *blue |= *blue >> bbits;
+ bbits <<= 1;
+ }
+
+ if (abits) {
+ *alpha = ((pixel >> ashift) & ((1 << abits) - 1)) << (16 - abits);
+ while (abits < 16) {
+ *alpha |= *alpha >> abits;
+ abits <<= 1;
+ }
+ }
+ else
+ *alpha = 0xffff;
+
+ return TRUE;
+}
+
+/* 8:8:8 + PICT_a8 -> 8:8:8:8 texture */
+
+void
+XAA_888_plus_PICT_a8_to_8888(CARD32 color, CARD8 *alphaPtr, /* in bytes */
+ int alphaPitch, CARD32 *dstPtr, int dstPitch, /* in dwords */
+ int width, int height)
+{
+ int x;
+
+ color &= 0x00ffffff;
+
+ while (height--) {
+ for (x = 0; x < width; x++)
+ dstPtr[x] = color | (alphaPtr[x] << 24);
+ dstPtr += dstPitch;
+ alphaPtr += alphaPitch;
+ }
+}
+
+#define DRAWABLE_IS_ON_CARD(pDraw) \
+ (pDraw->type == DRAWABLE_WINDOW || \
+ (pDraw->type == DRAWABLE_PIXMAP && IS_OFFSCREEN_PIXMAP(pDraw)))
+
+Bool
+XAADoComposite(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+ RegionRec region;
+ CARD32 *formats, *dstformats;
+ int flags = 0;
+ BoxPtr pbox;
+ int nbox, w, h;
+
+ if (!RegionNumRects(pDst->pCompositeClip))
+ return TRUE;
+
+ if (!infoRec->pScrn->vtSema || !DRAWABLE_IS_ON_CARD(pDst->pDrawable))
+ return FALSE;
+
+ if (DRAWABLE_IS_ON_CARD(pSrc->pDrawable))
+ return FALSE;
+
+ if (pSrc->transform || (pMask && pMask->transform))
+ return FALSE;
+
+ if (pDst->alphaMap || pSrc->alphaMap || (pMask && pMask->alphaMap))
+ return FALSE;
+
+ if ((pSrc->repeat && pSrc->repeatType != RepeatNormal) ||
+ (pMask && pMask->repeat && pMask->repeatType != RepeatNormal)) {
+ return FALSE;
+ }
+
+ xDst += pDst->pDrawable->x;
+ yDst += pDst->pDrawable->y;
+ xSrc += pSrc->pDrawable->x;
+ ySrc += pSrc->pDrawable->y;
+
+ if (pMask) {
+ if (pMask->componentAlpha)
+ return FALSE;
+
+ /* for now we only do it if there is a 1x1 (solid) source */
+
+ if ((pSrc->pDrawable->width == 1) && (pSrc->pDrawable->height == 1)) {
+ CARD16 red, green, blue, alpha;
+ CARD32 pixel =
+ *((CARD32 *) (((PixmapPtr) (pSrc->pDrawable))->devPrivate.ptr));
+
+ if (!XAAGetRGBAFromPixel
+ (pixel, &red, &green, &blue, &alpha, pSrc->format))
+ return FALSE;
+
+ xMask += pMask->pDrawable->x;
+ yMask += pMask->pDrawable->y;
+
+ /* pull out color expandable operations here */
+ if ((pMask->format == PICT_a1) && (alpha == 0xffff) &&
+ (op == PictOpOver) && infoRec->WriteBitmap && !pMask->repeat &&
+ !(infoRec->WriteBitmapFlags & NO_TRANSPARENCY) &&
+ (!(infoRec->WriteBitmapFlags & RGB_EQUAL) ||
+ ((red == green) && (green == blue)))) {
+ PixmapPtr pPix = (PixmapPtr) (pMask->pDrawable);
+ int skipleft;
+
+ if (!miComputeCompositeRegion(&region, pSrc, pMask, pDst,
+ xSrc, ySrc, xMask, yMask, xDst,
+ yDst, width, height))
+ return TRUE;
+
+ nbox = RegionNumRects(&region);
+ pbox = RegionRects(&region);
+
+ if (!nbox)
+ return TRUE;
+
+ XAAGetPixelFromRGBA(&pixel, red, green, blue, 0, pDst->format);
+
+ xMask -= xDst;
+ yMask -= yDst;
+
+ while (nbox--) {
+ skipleft = pbox->x1 + xMask;
+
+ (*infoRec->WriteBitmap) (infoRec->pScrn,
+ pbox->x1, pbox->y1,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1,
+ (unsigned char *) (pPix->
+ devPrivate.
+ ptr) +
+ (pPix->devKind *
+ (pbox->y1 + yMask)) +
+ ((skipleft >> 3) & ~3),
+ pPix->devKind, skipleft & 31,
+ pixel, -1, GXcopy, ~0);
+ pbox++;
+ }
+
+ /* WriteBitmap sets the Sync flag */
+ RegionUninit(&region);
+ return TRUE;
+ }
+
+ formats = infoRec->CPUToScreenAlphaTextureFormats;
+ dstformats = infoRec->CPUToScreenAlphaTextureDstFormats;
+ if (!formats || !dstformats)
+ return FALSE;
+
+ w = pMask->pDrawable->width;
+ h = pMask->pDrawable->height;
+
+ if (pMask->repeat) {
+ if ((infoRec->CPUToScreenAlphaTextureFlags & XAA_RENDER_NO_TILE)
+ ||
+ ((infoRec->
+ CPUToScreenAlphaTextureFlags &
+ XAA_RENDER_POWER_OF_2_TILE_ONLY) && ((h & (h - 1)) ||
+ (w & (w - 1))))) {
+ return FALSE;
+ }
+ flags |= XAA_RENDER_REPEAT;
+ }
+
+ if ((alpha != 0xffff) &&
+ (infoRec->
+ CPUToScreenAlphaTextureFlags & XAA_RENDER_NO_SRC_ALPHA))
+ return FALSE;
+
+ while (*formats != pMask->format) {
+ if (!(*formats))
+ return FALSE;
+ formats++;
+ }
+ while (*dstformats != pDst->format) {
+ if (!(*dstformats))
+ return FALSE;
+ dstformats++;
+ }
+
+ if (!miComputeCompositeRegion(&region, pSrc, pMask, pDst,
+ xSrc, ySrc, xMask, yMask, xDst, yDst,
+ width, height))
+ return TRUE;
+
+ nbox = RegionNumRects(&region);
+ pbox = RegionRects(&region);
+
+ if (!nbox) {
+ RegionUninit(&region);
+ return TRUE;
+ }
+
+ if (!(infoRec->SetupForCPUToScreenAlphaTexture2) (infoRec->pScrn,
+ op, red, green,
+ blue, alpha,
+ pMask->format,
+ pDst->format,
+ ((PixmapPtr)
+ (pMask->
+ pDrawable))->
+ devPrivate.ptr,
+ ((PixmapPtr)
+ (pMask->
+ pDrawable))->
+ devKind, w, h,
+ flags)) {
+ RegionUninit(&region);
+ return FALSE;
+ }
+
+ xMask -= xDst;
+ yMask -= yDst;
+
+ while (nbox--) {
+ (*infoRec->SubsequentCPUToScreenAlphaTexture) (infoRec->pScrn,
+ pbox->x1,
+ pbox->y1,
+ pbox->x1 + xMask,
+ pbox->y1 + yMask,
+ pbox->x2 -
+ pbox->x1,
+ pbox->y2 -
+ pbox->y1);
+ pbox++;
+ }
+
+ SET_SYNC_FLAG(infoRec);
+ RegionUninit(&region);
+ return TRUE;
+ }
+ }
+ else {
+ formats = infoRec->CPUToScreenTextureFormats;
+ dstformats = infoRec->CPUToScreenTextureDstFormats;
+ if (!formats || !dstformats)
+ return FALSE;
+
+ w = pSrc->pDrawable->width;
+ h = pSrc->pDrawable->height;
+
+ if (pSrc->repeat) {
+ if ((infoRec->CPUToScreenTextureFlags & XAA_RENDER_NO_TILE) ||
+ ((infoRec->CPUToScreenTextureFlags &
+ XAA_RENDER_POWER_OF_2_TILE_ONLY) &&
+ ((h & (h - 1)) || (w & (w - 1))))) {
+ return FALSE;
+ }
+ flags |= XAA_RENDER_REPEAT;
+ }
+
+ while (*formats != pSrc->format) {
+ if (!(*formats))
+ return FALSE;
+ formats++;
+ }
+ while (*dstformats != pDst->format) {
+ if (!(*dstformats))
+ return FALSE;
+ dstformats++;
+ }
+
+ if (!miComputeCompositeRegion(&region, pSrc, pMask, pDst,
+ xSrc, ySrc, xMask, yMask, xDst, yDst,
+ width, height))
+ return TRUE;
+
+ nbox = RegionNumRects(&region);
+ pbox = RegionRects(&region);
+
+ if (!nbox) {
+ RegionUninit(&region);
+ return TRUE;
+ }
+
+ if (!(infoRec->SetupForCPUToScreenTexture2) (infoRec->pScrn,
+ op, pSrc->format,
+ pDst->format,
+ ((PixmapPtr)
+ (pSrc->pDrawable))->
+ devPrivate.ptr,
+ ((PixmapPtr)
+ (pSrc->pDrawable))->
+ devKind, w, h, flags)) {
+ RegionUninit(&region);
+ return FALSE;
+ }
+
+ xSrc -= xDst;
+ ySrc -= yDst;
+
+ while (nbox--) {
+ (*infoRec->SubsequentCPUToScreenTexture) (infoRec->pScrn,
+ pbox->x1, pbox->y1,
+ pbox->x1 + xSrc,
+ pbox->y1 + ySrc,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+ pbox++;
+ }
+
+ SET_SYNC_FLAG(infoRec);
+ RegionUninit(&region);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+XAACompositeSrcCopy(PicturePtr pSrc,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+ int i, nbox;
+ int xoff, yoff;
+ BoxPtr pbox;
+ DDXPointPtr pptSrc;
+ RegionRec region;
+
+ xDst += pDst->pDrawable->x;
+ yDst += pDst->pDrawable->y;
+ xSrc += pSrc->pDrawable->x;
+ ySrc += pSrc->pDrawable->y;
+
+ if (!miComputeCompositeRegion(&region, pSrc, NULL, pDst,
+ xSrc, ySrc, 0, 0, xDst, yDst, width, height))
+ return;
+
+ nbox = RegionNumRects(&region);
+ pbox = RegionRects(&region);
+
+ if (!nbox) {
+ RegionUninit(&region);
+ return;
+ }
+ pptSrc = malloc(sizeof(DDXPointRec) * nbox);
+ if (!pptSrc) {
+ RegionUninit(&region);
+ return;
+ }
+ xoff = xSrc - xDst;
+ yoff = ySrc - yDst;
+ for (i = 0; i < nbox; i++) {
+ pptSrc[i].x = pbox[i].x1 + xoff;
+ pptSrc[i].y = pbox[i].y1 + yoff;
+ }
+
+ infoRec->ScratchGC.planemask = ~0L;
+ infoRec->ScratchGC.alu = GXcopy;
+
+ XAADoBitBlt(pSrc->pDrawable, pDst->pDrawable, &infoRec->ScratchGC, &region,
+ pptSrc);
+
+ free(pptSrc);
+ RegionUninit(&region);
+ return;
+}
+
+void
+XAAComposite(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+
+ XAA_RENDER_PROLOGUE(pScreen, Composite);
+
+ if (!pMask && infoRec->pScrn->vtSema &&
+ infoRec->ScreenToScreenBitBlt &&
+ pSrc->pDrawable &&
+ DRAWABLE_IS_ON_CARD(pSrc->pDrawable) &&
+ DRAWABLE_IS_ON_CARD(pDst->pDrawable) &&
+ !pSrc->transform &&
+ (!pSrc->repeat || (xSrc >= 0 && ySrc >= 0 &&
+ xSrc + width <= pSrc->pDrawable->width &&
+ ySrc + height <= pSrc->pDrawable->height)) &&
+ ((op == PictOpSrc &&
+ ((pSrc->format == pDst->format) ||
+ (pSrc->format == PICT_a8r8g8b8 && pDst->format == PICT_x8r8g8b8) ||
+ (pSrc->format == PICT_a8b8g8r8 && pDst->format == PICT_x8b8g8r8))) ||
+ (op == PictOpOver && !pSrc->alphaMap && !pDst->alphaMap &&
+ pSrc->format == pDst->format &&
+ (pSrc->format == PICT_x8r8g8b8 || pSrc->format == PICT_x8b8g8r8)))) {
+ XAACompositeSrcCopy(pSrc, pDst, xSrc, ySrc, xDst, yDst, width, height);
+ }
+ else if (!pSrc->pDrawable || (pMask && !pMask->pDrawable) ||
+ !infoRec->Composite ||
+ !(*infoRec->Composite) (op, pSrc, pMask, pDst,
+ xSrc, ySrc, xMask, yMask, xDst, yDst,
+ width, height)) {
+ if (infoRec->pScrn->vtSema &&
+ ((pSrc->pDrawable &&
+ (pSrc->pDrawable->type == DRAWABLE_WINDOW ||
+ IS_OFFSCREEN_PIXMAP(pSrc->pDrawable))) ||
+ pDst->pDrawable->type == DRAWABLE_WINDOW ||
+ IS_OFFSCREEN_PIXMAP(pDst->pDrawable))) {
+ SYNC_CHECK(pDst->pDrawable);
+ }
+ (*GetPictureScreen(pScreen)->Composite) (op,
+ pSrc,
+ pMask,
+ pDst,
+ xSrc,
+ ySrc,
+ xMask,
+ yMask,
+ xDst, yDst, width, height);
+ }
+
+ if (pDst->pDrawable->type == DRAWABLE_PIXMAP)
+ (XAA_GET_PIXMAP_PRIVATE((PixmapPtr) (pDst->pDrawable)))->flags |= DIRTY;
+
+ XAA_RENDER_EPILOGUE(pScreen, Composite, XAAComposite);
+}
+
+Bool
+XAADoGlyphs(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc, int nlist, GlyphListPtr list, GlyphPtr * glyphs)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+
+ if (!RegionNumRects(pDst->pCompositeClip))
+ return TRUE;
+
+ if (!infoRec->pScrn->vtSema ||
+ ((pDst->pDrawable->type != DRAWABLE_WINDOW) &&
+ !IS_OFFSCREEN_PIXMAP(pDst->pDrawable)))
+ return FALSE;
+
+ if ((pSrc->pDrawable->type != DRAWABLE_PIXMAP) ||
+ IS_OFFSCREEN_PIXMAP(pSrc->pDrawable))
+ return FALSE;
+
+ /*
+ * If it looks like we have a chance of being able to draw these
+ * glyphs with an accelerated Composite, do that now to avoid
+ * unneeded and costly syncs.
+ */
+ if (maskFormat) {
+ if (!infoRec->CPUToScreenAlphaTextureFormats)
+ return FALSE;
+ }
+ else {
+ if (!infoRec->CPUToScreenTextureFormats)
+ return FALSE;
+ }
+
+ miGlyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
+
+ return TRUE;
+}
+
+void
+XAAGlyphs(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc, int nlist, GlyphListPtr list, GlyphPtr * glyphs)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+
+ XAA_RENDER_PROLOGUE(pScreen, Glyphs);
+
+ if (!pSrc->pDrawable || !infoRec->Glyphs ||
+ !(*infoRec->Glyphs) (op, pSrc, pDst, maskFormat,
+ xSrc, ySrc, nlist, list, glyphs)) {
+ if (infoRec->pScrn->vtSema &&
+ ((pSrc->pDrawable &&
+ (pSrc->pDrawable->type == DRAWABLE_WINDOW ||
+ IS_OFFSCREEN_PIXMAP(pSrc->pDrawable))) ||
+ pDst->pDrawable->type == DRAWABLE_WINDOW ||
+ IS_OFFSCREEN_PIXMAP(pDst->pDrawable))) {
+ SYNC_CHECK(pDst->pDrawable);
+ }
+ (*GetPictureScreen(pScreen)->Glyphs) (op, pSrc, pDst, maskFormat,
+ xSrc, ySrc, nlist, list, glyphs);
+ }
+
+ if (pDst->pDrawable->type == DRAWABLE_PIXMAP)
+ (XAA_GET_PIXMAP_PRIVATE((PixmapPtr) (pDst->pDrawable)))->flags |= DIRTY;
+
+ XAA_RENDER_EPILOGUE(pScreen, Glyphs, XAAGlyphs);
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaROP.c b/xorg-server/hw/xfree86/xaa/xaaROP.c
index 155daa4ee..3b6ec9385 100644
--- a/xorg-server/hw/xfree86/xaa/xaaROP.c
+++ b/xorg-server/hw/xfree86/xaa/xaaROP.c
@@ -13,104 +13,102 @@
#include "xaa.h"
#include "xaalocal.h"
-
-int XAACopyROP[16] =
-{
- ROP_0, /* GXclear */
- ROP_DSa, /* GXand */
- ROP_SDna, /* GXandReverse */
- ROP_S, /* GXcopy */
- ROP_DSna, /* GXandInverted */
- ROP_D, /* GXnoop */
- ROP_DSx, /* GXxor */
- ROP_DSo, /* GXor */
- ROP_DSon, /* GXnor */
- ROP_DSxn, /* GXequiv */
- ROP_Dn, /* GXinvert*/
- ROP_SDno, /* GXorReverse */
- ROP_Sn, /* GXcopyInverted */
- ROP_DSno, /* GXorInverted */
- ROP_DSan, /* GXnand */
- ROP_1 /* GXset */
+int XAACopyROP[16] = {
+ ROP_0, /* GXclear */
+ ROP_DSa, /* GXand */
+ ROP_SDna, /* GXandReverse */
+ ROP_S, /* GXcopy */
+ ROP_DSna, /* GXandInverted */
+ ROP_D, /* GXnoop */
+ ROP_DSx, /* GXxor */
+ ROP_DSo, /* GXor */
+ ROP_DSon, /* GXnor */
+ ROP_DSxn, /* GXequiv */
+ ROP_Dn, /* GXinvert */
+ ROP_SDno, /* GXorReverse */
+ ROP_Sn, /* GXcopyInverted */
+ ROP_DSno, /* GXorInverted */
+ ROP_DSan, /* GXnand */
+ ROP_1 /* GXset */
};
-int XAACopyROP_PM[16] =
-{
- ROP_0, /* not used */
- ROP_DSPnoa,
- ROP_DPSnaon,
- ROP_DPSDxax,
- ROP_DPSana,
- ROP_D, /* not used */
- ROP_DPSax,
- ROP_DPSao,
- ROP_DPSaon,
- ROP_DPSaxn,
- ROP_Dn, /* not used */
- ROP_DPSanan,
- ROP_PSDPxox, /* is that correct ? */
- ROP_DPSnao,
- ROP_DSPnoan,
- ROP_1 /* not used */
+int XAACopyROP_PM[16] = {
+ ROP_0, /* not used */
+ ROP_DSPnoa,
+ ROP_DPSnaon,
+ ROP_DPSDxax,
+ ROP_DPSana,
+ ROP_D, /* not used */
+ ROP_DPSax,
+ ROP_DPSao,
+ ROP_DPSaon,
+ ROP_DPSaxn,
+ ROP_Dn, /* not used */
+ ROP_DPSanan,
+ ROP_PSDPxox, /* is that correct ? */
+ ROP_DPSnao,
+ ROP_DSPnoan,
+ ROP_1 /* not used */
};
-
-int XAAPatternROP[16]=
-{
- ROP_0,
- ROP_DPa,
- ROP_PDna,
- ROP_P,
- ROP_DPna,
- ROP_D,
- ROP_DPx,
- ROP_DPo,
- ROP_DPon,
- ROP_PDxn,
- ROP_Dn,
- ROP_PDno,
- ROP_Pn,
- ROP_DPno,
- ROP_DPan,
- ROP_1
+int XAAPatternROP[16] = {
+ ROP_0,
+ ROP_DPa,
+ ROP_PDna,
+ ROP_P,
+ ROP_DPna,
+ ROP_D,
+ ROP_DPx,
+ ROP_DPo,
+ ROP_DPon,
+ ROP_PDxn,
+ ROP_Dn,
+ ROP_PDno,
+ ROP_Pn,
+ ROP_DPno,
+ ROP_DPan,
+ ROP_1
};
-int XAAPatternROP_PM[16] =
-{
- ROP_DPna,
- ROP_DPSnoa,
- ROP_DSPnaon,
- ROP_DSPDxax,
- ROP_DPSana,
- ROP_D,
- ROP_DPSax,
- ROP_DPSao,
- ROP_DPSaon,
- ROP_DPSaxn,
- ROP_DPx,
- ROP_DPSanan,
- ROP_SPDSxox, /* is that correct ? */
- ROP_DSPnao,
- ROP_DPSnoan,
- ROP_DPo
+int XAAPatternROP_PM[16] = {
+ ROP_DPna,
+ ROP_DPSnoa,
+ ROP_DSPnaon,
+ ROP_DSPDxax,
+ ROP_DPSana,
+ ROP_D,
+ ROP_DPSax,
+ ROP_DPSao,
+ ROP_DPSaon,
+ ROP_DPSaxn,
+ ROP_DPx,
+ ROP_DPSanan,
+ ROP_SPDSxox, /* is that correct ? */
+ ROP_DSPnao,
+ ROP_DPSnoan,
+ ROP_DPo
};
-int XAAGetCopyROP(int i)
+int
+XAAGetCopyROP(int i)
{
return XAACopyROP[i];
}
-int XAAGetCopyROP_PM(int i)
+int
+XAAGetCopyROP_PM(int i)
{
return XAACopyROP_PM[i];
}
-int XAAGetPatternROP(int i)
+int
+XAAGetPatternROP(int i)
{
return XAAPatternROP[i];
}
-int XAAGetPatternROP_PM(int i)
+int
+XAAGetPatternROP_PM(int i)
{
return XAAPatternROP_PM[i];
}
@@ -120,65 +118,65 @@ XAAHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg, int pm, int *rop)
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
int ret = 0;
-
+
pm &= infoRec->FullPlanemasks[pScrn->depth - 1];
- if(pm == infoRec->FullPlanemasks[pScrn->depth - 1]) {
- if(!NO_SRC_ROP(*rop))
- ret |= ROP_PAT;
- *rop = XAAPatternROP[*rop];
- } else {
- switch(*rop) {
- case GXnoop:
- break;
- case GXset:
- case GXclear:
- case GXinvert:
- ret |= ROP_PAT;
- *fg = pm;
- if(*bg != -1)
- *bg = pm;
- break;
- default:
- ret |= ROP_PAT | ROP_SRC;
- break;
- }
- *rop = XAAPatternROP_PM[*rop];
+ if (pm == infoRec->FullPlanemasks[pScrn->depth - 1]) {
+ if (!NO_SRC_ROP(*rop))
+ ret |= ROP_PAT;
+ *rop = XAAPatternROP[*rop];
+ }
+ else {
+ switch (*rop) {
+ case GXnoop:
+ break;
+ case GXset:
+ case GXclear:
+ case GXinvert:
+ ret |= ROP_PAT;
+ *fg = pm;
+ if (*bg != -1)
+ *bg = pm;
+ break;
+ default:
+ ret |= ROP_PAT | ROP_SRC;
+ break;
+ }
+ *rop = XAAPatternROP_PM[*rop];
}
return ret;
}
-
int
XAAHelpSolidROP(ScrnInfoPtr pScrn, int *fg, int pm, int *rop)
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
int ret = 0;
-
+
pm &= infoRec->FullPlanemasks[pScrn->depth - 1];
- if(pm == infoRec->FullPlanemasks[pScrn->depth - 1]) {
- if(!NO_SRC_ROP(*rop))
- ret |= ROP_PAT;
- *rop = XAAPatternROP[*rop];
- } else {
- switch(*rop) {
- case GXnoop:
- break;
- case GXset:
- case GXclear:
- case GXinvert:
- ret |= ROP_PAT;
- *fg = pm;
- break;
- default:
- ret |= ROP_PAT | ROP_SRC;
- break;
- }
- *rop = XAAPatternROP_PM[*rop];
+ if (pm == infoRec->FullPlanemasks[pScrn->depth - 1]) {
+ if (!NO_SRC_ROP(*rop))
+ ret |= ROP_PAT;
+ *rop = XAAPatternROP[*rop];
+ }
+ else {
+ switch (*rop) {
+ case GXnoop:
+ break;
+ case GXset:
+ case GXclear:
+ case GXinvert:
+ ret |= ROP_PAT;
+ *fg = pm;
+ break;
+ default:
+ ret |= ROP_PAT | ROP_SRC;
+ break;
+ }
+ *rop = XAAPatternROP_PM[*rop];
}
return ret;
}
-
diff --git a/xorg-server/hw/xfree86/xaa/xaaRect.c b/xorg-server/hw/xfree86/xaa/xaaRect.c
index 988dbf608..002090085 100644
--- a/xorg-server/hw/xfree86/xaa/xaaRect.c
+++ b/xorg-server/hw/xfree86/xaa/xaaRect.c
@@ -1,136 +1,121 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-
-/*
- Much of this file based on code by
- Harm Hanemaayer (H.Hanemaayer@inter.nl.net).
-*/
-
-
-void
-XAAPolyRectangleThinSolid(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int nRectsInit,
- xRectangle *pRectsInit )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int nClipRects; /* number of clip rectangles */
- BoxPtr pClipRects; /* points to the list of clip rects */
- int xOrigin; /* Drawables x origin */
- int yOrigin; /* Drawables x origin */
- xRectangle *pRect; /* list of rects */
- int nRects; /* running count of number of rects */
- int origX1, origY1; /* original rectangle's U/L corner */
- int origX2, origY2; /* original rectangle's L/R corner */
- int clippedX1; /* clipped rectangle's left x */
- int clippedY1; /* clipped rectangle's top y */
- int clippedX2; /* clipped rectangle's right x */
- int clippedY2; /* clipped rectangle's bottom y */
- int clipXMin; /* upper left corner of clip rect */
- int clipYMin; /* upper left corner of clip rect */
- int clipXMax; /* lower right corner of clip rect */
- int clipYMax; /* lower right corner of clip rect */
- int width, height; /* width and height of rect */
-
- nClipRects = RegionNumRects(pGC->pCompositeClip);
- pClipRects = RegionRects(pGC->pCompositeClip);
-
- if(!nClipRects) return;
-
- xOrigin = pDrawable->x;
- yOrigin = pDrawable->y;
-
-
- (*infoRec->SetupForSolidLine)(infoRec->pScrn,
- pGC->fgPixel, pGC->alu, pGC->planemask);
-
-
- for ( ; nClipRects > 0;
- nClipRects--, pClipRects++ )
- {
- clipYMin = pClipRects->y1;
- clipYMax = pClipRects->y2 - 1;
- clipXMin = pClipRects->x1;
- clipXMax = pClipRects->x2 - 1;
-
- for (pRect = pRectsInit, nRects = nRectsInit;
- nRects > 0;
- nRects--, pRect++ )
- {
- /* translate rectangle data over to the drawable */
- origX1 = pRect->x + xOrigin;
- origY1 = pRect->y + yOrigin;
- origX2 = origX1 + pRect->width;
- origY2 = origY1 + pRect->height;
-
- /* reject entire rectangle if completely outside clip rect */
- if ((origX1 > clipXMax) || (origX2 < clipXMin) ||
- (origY1 > clipYMax) || (origY2 < clipYMin))
- continue;
-
- /* clip the rectangle */
- clippedX1 = max (origX1, clipXMin);
- clippedX2 = min (origX2, clipXMax);
- clippedY1 = max (origY1, clipYMin);
- clippedY2 = min (origY2, clipYMax);
-
- width = clippedX2 - clippedX1 + 1;
-
- if (origY1 >= clipYMin) {
- (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn,
- clippedX1, clippedY1, width, DEGREES_0);
-
- /* don't overwrite corner */
- clippedY1++;
- }
-
- if ((origY2 <= clipYMax) && (origY1 != origY2)) {
- (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn,
- clippedX1, clippedY2, width, DEGREES_0);
-
- /* don't overwrite corner */
- clippedY2--;
- }
-
- if (clippedY2 < clippedY1) continue;
-
- height = clippedY2 - clippedY1 + 1;
-
- /* draw vertical edges using lines if not clipped out */
- if (origX1 >= clipXMin)
- (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn,
- clippedX1, clippedY1, height, DEGREES_270);
-
- if ((origX2 <= clipXMax) && (origX2 != origX1))
- (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn,
- clippedX2, clippedY1, height, DEGREES_270);
- }
- }
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
-
-
-
-
-
-
-
-
-
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+
+/*
+ Much of this file based on code by
+ Harm Hanemaayer (H.Hanemaayer@inter.nl.net).
+*/
+
+void
+XAAPolyRectangleThinSolid(DrawablePtr pDrawable,
+ GCPtr pGC, int nRectsInit, xRectangle *pRectsInit)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int nClipRects; /* number of clip rectangles */
+ BoxPtr pClipRects; /* points to the list of clip rects */
+ int xOrigin; /* Drawables x origin */
+ int yOrigin; /* Drawables x origin */
+ xRectangle *pRect; /* list of rects */
+ int nRects; /* running count of number of rects */
+ int origX1, origY1; /* original rectangle's U/L corner */
+ int origX2, origY2; /* original rectangle's L/R corner */
+ int clippedX1; /* clipped rectangle's left x */
+ int clippedY1; /* clipped rectangle's top y */
+ int clippedX2; /* clipped rectangle's right x */
+ int clippedY2; /* clipped rectangle's bottom y */
+ int clipXMin; /* upper left corner of clip rect */
+ int clipYMin; /* upper left corner of clip rect */
+ int clipXMax; /* lower right corner of clip rect */
+ int clipYMax; /* lower right corner of clip rect */
+ int width, height; /* width and height of rect */
+
+ nClipRects = RegionNumRects(pGC->pCompositeClip);
+ pClipRects = RegionRects(pGC->pCompositeClip);
+
+ if (!nClipRects)
+ return;
+
+ xOrigin = pDrawable->x;
+ yOrigin = pDrawable->y;
+
+ (*infoRec->SetupForSolidLine) (infoRec->pScrn,
+ pGC->fgPixel, pGC->alu, pGC->planemask);
+
+ for (; nClipRects > 0; nClipRects--, pClipRects++) {
+ clipYMin = pClipRects->y1;
+ clipYMax = pClipRects->y2 - 1;
+ clipXMin = pClipRects->x1;
+ clipXMax = pClipRects->x2 - 1;
+
+ for (pRect = pRectsInit, nRects = nRectsInit;
+ nRects > 0; nRects--, pRect++) {
+ /* translate rectangle data over to the drawable */
+ origX1 = pRect->x + xOrigin;
+ origY1 = pRect->y + yOrigin;
+ origX2 = origX1 + pRect->width;
+ origY2 = origY1 + pRect->height;
+
+ /* reject entire rectangle if completely outside clip rect */
+ if ((origX1 > clipXMax) || (origX2 < clipXMin) ||
+ (origY1 > clipYMax) || (origY2 < clipYMin))
+ continue;
+
+ /* clip the rectangle */
+ clippedX1 = max(origX1, clipXMin);
+ clippedX2 = min(origX2, clipXMax);
+ clippedY1 = max(origY1, clipYMin);
+ clippedY2 = min(origY2, clipYMax);
+
+ width = clippedX2 - clippedX1 + 1;
+
+ if (origY1 >= clipYMin) {
+ (*infoRec->SubsequentSolidHorVertLine) (infoRec->pScrn,
+ clippedX1, clippedY1,
+ width, DEGREES_0);
+
+ /* don't overwrite corner */
+ clippedY1++;
+ }
+
+ if ((origY2 <= clipYMax) && (origY1 != origY2)) {
+ (*infoRec->SubsequentSolidHorVertLine) (infoRec->pScrn,
+ clippedX1, clippedY2,
+ width, DEGREES_0);
+
+ /* don't overwrite corner */
+ clippedY2--;
+ }
+
+ if (clippedY2 < clippedY1)
+ continue;
+
+ height = clippedY2 - clippedY1 + 1;
+
+ /* draw vertical edges using lines if not clipped out */
+ if (origX1 >= clipXMin)
+ (*infoRec->SubsequentSolidHorVertLine) (infoRec->pScrn,
+ clippedX1, clippedY1,
+ height, DEGREES_270);
+
+ if ((origX2 <= clipXMax) && (origX2 != origX1))
+ (*infoRec->SubsequentSolidHorVertLine) (infoRec->pScrn,
+ clippedX2, clippedY1,
+ height, DEGREES_270);
+ }
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaSpans.c b/xorg-server/hw/xfree86/xaa/xaaSpans.c
index 1e6ef3a18..f03452a46 100644
--- a/xorg-server/hw/xfree86/xaa/xaaSpans.c
+++ b/xorg-server/hw/xfree86/xaa/xaaSpans.c
@@ -1,882 +1,876 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "xf86str.h"
-#include "mi.h"
-#include "mispans.h"
-#include "xaa.h"
-#include "xaalocal.h"
-
-
-static void XAARenderSolidSpans(
- GCPtr, int, DDXPointPtr, int*, int, int, int);
-static void XAARenderColor8x8Spans(
- GCPtr, int, DDXPointPtr, int*, int, int, int);
-static void XAARenderMono8x8Spans(
- GCPtr, int, DDXPointPtr, int*, int, int, int);
-static void XAARenderCacheBltSpans(
- GCPtr, int, DDXPointPtr, int*, int, int, int);
-static void XAARenderColorExpandSpans(
- GCPtr, int, DDXPointPtr, int*, int, int, int);
-static void XAARenderCacheExpandSpans(
- GCPtr, int, DDXPointPtr, int*, int, int, int);
-static void XAARenderPixmapCopySpans(
- GCPtr, int, DDXPointPtr, int*, int, int, int);
-
-void
-XAAFillSpans(
- DrawablePtr pDraw,
- GC *pGC,
- int nInit, /* number of spans to fill */
- DDXPointPtr pptInit, /* pointer to list of start points */
- int *pwidthInit, /* pointer to list of n widths */
- int fSorted
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int type = 0;
- ClipAndRenderSpansFunc function;
- Bool fastClip = FALSE;
-
- if((nInit <= 0) || !pGC->planemask)
- return;
-
- if(!RegionNumRects(pGC->pCompositeClip))
- return;
-
- switch(pGC->fillStyle) {
- case FillSolid:
- type = DO_SOLID;
- break;
- case FillStippled:
- type = (*infoRec->StippledFillChooser)(pGC);
- break;
- case FillOpaqueStippled:
- if((pGC->fgPixel == pGC->bgPixel) && infoRec->FillSpansSolid &&
- CHECK_PLANEMASK(pGC,infoRec->FillSpansSolidFlags) &&
- CHECK_ROP(pGC,infoRec->FillSpansSolidFlags) &&
- CHECK_ROPSRC(pGC,infoRec->FillSpansSolidFlags) &&
- CHECK_FG(pGC,infoRec->FillSpansSolidFlags))
- type = DO_SOLID;
- else
- type = (*infoRec->OpaqueStippledFillChooser)(pGC);
- break;
- case FillTiled:
- type = (*infoRec->TiledFillChooser)(pGC);
- break;
- }
-
- switch(type) {
- case DO_SOLID:
- function = XAARenderSolidSpans;
- if(infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL)
- fastClip = TRUE;
- break;
- case DO_COLOR_8x8:
- function = XAARenderColor8x8Spans;
- if(infoRec->ClippingFlags & HARDWARE_CLIP_COLOR_8x8_FILL)
- fastClip = TRUE;
- break;
- case DO_MONO_8x8:
- function = XAARenderMono8x8Spans;
- if(infoRec->ClippingFlags & HARDWARE_CLIP_MONO_8x8_FILL)
- fastClip = TRUE;
- break;
- case DO_CACHE_BLT:
- function = XAARenderCacheBltSpans;
- if(infoRec->ClippingFlags & HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY)
- fastClip = TRUE;
- break;
- case DO_COLOR_EXPAND:
- function = XAARenderColorExpandSpans;
- break;
- case DO_CACHE_EXPAND:
- function = XAARenderCacheExpandSpans;
- if(infoRec->ClippingFlags &
- HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND)
- fastClip = TRUE;
- break;
- case DO_PIXMAP_COPY:
- function = XAARenderPixmapCopySpans;
- if(infoRec->ClippingFlags & HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY)
- fastClip = TRUE;
- break;
- case DO_IMAGE_WRITE:
- default:
- (*XAAFallbackOps.FillSpans)(pDraw, pGC, nInit, pptInit,
- pwidthInit, fSorted);
- return;
- }
-
-
- if((nInit < 10) || (RegionNumRects(pGC->pCompositeClip) != 1))
- fastClip = FALSE;
-
- if(fastClip) {
- infoRec->ClipBox = &pGC->pCompositeClip->extents;
- (*function)(pGC, nInit, pptInit, pwidthInit, fSorted,
- pDraw->x, pDraw->y);
- infoRec->ClipBox = NULL;
- } else
- XAAClipAndRenderSpans(pGC, pptInit, pwidthInit, nInit, fSorted,
- function, pDraw->x, pDraw->y);
-}
-
-
- /*********************\
- | Solid Spans |
- \*********************/
-
-
-static void
-XAARenderSolidSpans(
- GCPtr pGC,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-
- (*infoRec->FillSolidSpans) (infoRec->pScrn, pGC->fgPixel,
- pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted);
-}
-
-
- /************************\
- | Mono 8x8 Spans |
- \************************/
-
-
-static void
-XAARenderMono8x8Spans(
- GCPtr pGC,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAAPixmapPtr pPriv;
- int fg, bg;
-
- switch(pGC->fillStyle) {
- case FillStippled:
- pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
- fg = pGC->fgPixel; bg = -1;
- break;
- case FillOpaqueStippled:
- pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
- fg = pGC->fgPixel; bg = pGC->bgPixel;
- break;
- case FillTiled:
- pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
- fg = pPriv->fg; bg = pPriv->bg;
- break;
- default: /* Muffle compiler */
- pPriv = NULL; /* Kaboom */
- fg = -1; bg = -1;
- break;
- }
-
- (*infoRec->FillMono8x8PatternSpans) (infoRec->pScrn,
- fg, bg, pGC->alu, pGC->planemask,
- n, ppt, pwidth, fSorted, pPriv->pattern0, pPriv->pattern1,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y));
-}
-
-
- /*************************\
- | Color 8x8 Spans |
- \*************************/
-
-
-static void
-XAARenderColor8x8Spans(
- GCPtr pGC,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAACacheInfoPtr pCache;
- PixmapPtr pPix;
- int fg, bg;
-
- switch(pGC->fillStyle) {
- case FillStippled:
- pPix = pGC->stipple;
- fg = pGC->fgPixel; bg = -1;
- break;
- case FillOpaqueStippled:
- pPix = pGC->stipple;
- fg = pGC->fgPixel; bg = pGC->bgPixel;
- break;
- case FillTiled:
- pPix = pGC->tile.pixmap;
- fg = -1; bg = -1;
- break;
- default: /* Muffle compiler */
- pPix = NULL;
- fg = -1; bg = -1;
- break;
- }
-
- pCache = (*infoRec->CacheColor8x8Pattern)(infoRec->pScrn, pPix, fg, bg);
-
- (*infoRec->FillColor8x8PatternSpans) (infoRec->pScrn,
- pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache,
- (yorg + pGC->patOrg.x), (xorg + pGC->patOrg.y));
-}
-
-
- /****************************\
- | Color Expand Spans |
- \****************************/
-
-
-static void
-XAARenderColorExpandSpans(
- GCPtr pGC,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int fg, bg;
-
- switch(pGC->fillStyle) {
- case FillStippled:
- fg = pGC->fgPixel; bg = -1;
- break;
- case FillOpaqueStippled:
- fg = pGC->fgPixel; bg = pGC->bgPixel;
- break;
- default: /* Muffle compiler */
- fg = -1; bg = -1;
- break;
- }
-
- (*infoRec->FillColorExpandSpans) (infoRec->pScrn, fg, bg,
- pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
- pGC->stipple);
-
-}
-
-
- /*************************\
- | Cache Blt Spans |
- \*************************/
-
-
-static void
-XAARenderCacheBltSpans(
- GCPtr pGC,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAACacheInfoPtr pCache;
-
- switch(pGC->fillStyle) {
- case FillStippled:
- pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple,
- pGC->fgPixel, -1);
- break;
- case FillOpaqueStippled:
- pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple,
- pGC->fgPixel, pGC->bgPixel);
- break;
- case FillTiled:
- pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap);
- break;
- default: /* Muffle compiler */
- pCache = NULL;
- break;
- }
-
- (*infoRec->FillCacheBltSpans) (infoRec->pScrn,
- pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y));
-
-}
-
-
- /****************************\
- | Cache Expand Spans |
- \****************************/
-
-
-static void
-XAARenderCacheExpandSpans(
- GCPtr pGC,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int fg, bg;
-
- switch(pGC->fillStyle) {
- case FillStippled:
- fg = pGC->fgPixel; bg = -1;
- break;
- case FillOpaqueStippled:
- fg = pGC->fgPixel; bg = pGC->bgPixel;
- break;
- default: /* Muffle compiler */
- fg = -1; bg = -1;
- break;
- }
-
- (*infoRec->FillCacheExpandSpans) (infoRec->pScrn, fg, bg,
- pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
- pGC->stipple);
-}
-
-
- /***************************\
- | Pixmap Copy Spans |
- \***************************/
-
-
-static void
-XAARenderPixmapCopySpans(
- GCPtr pGC,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec);
- XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
-
- pCache->x = pPriv->offscreenArea->box.x1;
- pCache->y = pPriv->offscreenArea->box.y1;
- pCache->w = pCache->orig_w =
- pPriv->offscreenArea->box.x2 - pCache->x;
- pCache->h = pCache->orig_h =
- pPriv->offscreenArea->box.y2 - pCache->y;
- pCache->trans_color = -1;
-
- (*infoRec->FillCacheBltSpans) (infoRec->pScrn,
- pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y));
-}
-
-
-
-
-
- /****************\
- | Solid |
- \****************/
-
-
-void
-XAAFillSolidSpans(
- ScrnInfoPtr pScrn,
- int fg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth, int fSorted
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
-
- (*infoRec->SetupForSolidFill)(pScrn, fg, rop, planemask);
-
- if(infoRec->ClipBox)
- (*infoRec->SetClippingRectangle)(infoRec->pScrn,
- infoRec->ClipBox->x1, infoRec->ClipBox->y1,
- infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
-
- while(n--) {
- if (*pwidth > 0)
- (*infoRec->SubsequentSolidFillRect)(pScrn, ppt->x, ppt->y,
- *pwidth, 1);
- ppt++; pwidth++;
- }
-
- if(infoRec->ClipBox)
- (*infoRec->DisableClipping)(infoRec->pScrn);
-
- SET_SYNC_FLAG(infoRec);
-}
-
- /***************\
- | Mono 8x8 |
- \***************/
-
-
-void
-XAAFillMono8x8PatternSpansScreenOrigin(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth, int fSorted,
- int pattern0, int pattern1,
- int xorigin, int yorigin
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int patx = pattern0, paty = pattern1;
- int xorg = (-xorigin) & 0x07;
- int yorg = (-yorigin) & 0x07;
-
-
- if(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS) {
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- XAARotateMonoPattern(&patx, &paty, xorg, yorg,
- (infoRec->Mono8x8PatternFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST));
- xorg = patx; yorg = paty;
- }
- } else {
- XAACacheInfoPtr pCache =
- (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1);
- patx = pCache->x; paty = pCache->y;
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- int slot = (yorg << 3) + xorg;
- patx += pCache->offsets[slot].x;
- paty += pCache->offsets[slot].y;
- xorg = patx; yorg = paty;
- }
- }
-
- (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty,
- fg, bg, rop, planemask);
-
- if(infoRec->ClipBox)
- (*infoRec->SetClippingRectangle)(infoRec->pScrn,
- infoRec->ClipBox->x1, infoRec->ClipBox->y1,
- infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
-
- while(n--) {
- (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn,
- xorg, yorg, ppt->x, ppt->y, *pwidth, 1);
- ppt++; pwidth++;
- }
-
- if(infoRec->ClipBox)
- (*infoRec->DisableClipping)(infoRec->pScrn);
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
-void
-XAAFillMono8x8PatternSpans(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth, int fSorted,
- int pattern0, int pattern1,
- int xorigin, int yorigin
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int patx = pattern0, paty = pattern1;
- int xorg, yorg, slot;
- XAACacheInfoPtr pCache = NULL;
-
-
- if(!(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS)){
- pCache = (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1);
- patx = pCache->x; paty = pCache->y;
- }
-
- (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty,
- fg, bg, rop, planemask);
-
- if(infoRec->ClipBox)
- (*infoRec->SetClippingRectangle)(infoRec->pScrn,
- infoRec->ClipBox->x1, infoRec->ClipBox->y1,
- infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
-
- while(n--) {
- xorg = (ppt->x - xorigin) & 0x07;
- yorg = (ppt->y - yorigin) & 0x07;
-
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- if(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_BITS) {
- patx = pattern0; paty = pattern1;
- XAARotateMonoPattern(&patx, &paty, xorg, yorg,
- (infoRec->Mono8x8PatternFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST));
- xorg = patx; yorg = paty;
- } else {
- slot = (yorg << 3) + xorg;
- xorg = patx + pCache->offsets[slot].x;
- yorg = paty + pCache->offsets[slot].y;
- }
- }
-
- (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn,
- xorg, yorg, ppt->x, ppt->y, *pwidth, 1);
- ppt++; pwidth++;
- }
-
- if(infoRec->ClipBox)
- (*infoRec->DisableClipping)(infoRec->pScrn);
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
-
- /****************\
- | Color 8x8 |
- \****************/
-
-
-void
-XAAFillColor8x8PatternSpansScreenOrigin(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth, int fSorted,
- XAACacheInfoPtr pCache,
- int xorigin, int yorigin
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int patx = pCache->x, paty = pCache->y;
- int xorg = (-xorigin) & 0x07;
- int yorg = (-yorigin) & 0x07;
-
-
- if(!(infoRec->Color8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- int slot = (yorg << 3) + xorg;
- paty += pCache->offsets[slot].y;
- patx += pCache->offsets[slot].x;
- xorg = patx; yorg = paty;
- }
-
- (*infoRec->SetupForColor8x8PatternFill)(pScrn, patx, paty,
- rop, planemask, pCache->trans_color);
-
- if(infoRec->ClipBox)
- (*infoRec->SetClippingRectangle)(infoRec->pScrn,
- infoRec->ClipBox->x1, infoRec->ClipBox->y1,
- infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
-
- while(n--) {
- (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn,
- xorg, yorg, ppt->x, ppt->y, *pwidth, 1);
- ppt++; pwidth++;
- }
-
- if(infoRec->ClipBox)
- (*infoRec->DisableClipping)(infoRec->pScrn);
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
-void
-XAAFillColor8x8PatternSpans(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth, int fSorted,
- XAACacheInfoPtr pCache,
- int xorigin, int yorigin
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int xorg, yorg, slot;
-
- (*infoRec->SetupForColor8x8PatternFill)(pScrn, pCache->x, pCache->y,
- rop, planemask, pCache->trans_color);
-
- if(infoRec->ClipBox)
- (*infoRec->SetClippingRectangle)(infoRec->pScrn,
- infoRec->ClipBox->x1, infoRec->ClipBox->y1,
- infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
-
- while(n--) {
- xorg = (ppt->x - xorigin) & 0x07;
- yorg = (ppt->y - yorigin) & 0x07;
-
- if(!(infoRec->Color8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- slot = (yorg << 3) + xorg;
- yorg = pCache->y + pCache->offsets[slot].y;
- xorg = pCache->x + pCache->offsets[slot].x;
- }
-
- (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn,
- xorg, yorg, ppt->x, ppt->y, *pwidth, 1);
- ppt++; pwidth++;
- }
-
- if(infoRec->ClipBox)
- (*infoRec->DisableClipping)(infoRec->pScrn);
-
- SET_SYNC_FLAG(infoRec);
-}
-
- /*****************\
- | Cache Blit |
- \*****************/
-
-
-void
-XAAFillCacheBltSpans(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- XAACacheInfoPtr pCache,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int x, w, phaseX, phaseY, blit_w;
-
- (*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, rop, planemask,
- pCache->trans_color);
-
- if(infoRec->ClipBox)
- (*infoRec->SetClippingRectangle)(infoRec->pScrn,
- infoRec->ClipBox->x1, infoRec->ClipBox->y1,
- infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
-
- while(n--) {
- x = ppt->x;
- w = *pwidth;
- phaseX = (x - xorg) % pCache->orig_w;
- if(phaseX < 0) phaseX += pCache->orig_w;
- phaseY = (ppt->y - yorg) % pCache->orig_h;
- if(phaseY < 0) phaseY += pCache->orig_h;
-
- while(1) {
- blit_w = pCache->w - phaseX;
- if(blit_w > w) blit_w = w;
-
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
- pCache->x + phaseX, pCache->y + phaseY,
- x, ppt->y, blit_w, 1);
-
- w -= blit_w;
- if(!w) break;
- x += blit_w;
- phaseX = (phaseX + blit_w) % pCache->orig_w;
- }
- ppt++; pwidth++;
- }
-
- if(infoRec->ClipBox)
- (*infoRec->DisableClipping)(infoRec->pScrn);
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
- /****************\
- | Cache Expand |
- \****************/
-
-
-void
-XAAFillCacheExpandSpans(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int x, w, phaseX, phaseY, blit_w, cacheWidth;
- XAACacheInfoPtr pCache;
-
- pCache = (*infoRec->CacheMonoStipple)(pScrn, pPix);
-
- cacheWidth = (pCache->w * pScrn->bitsPerPixel) /
- infoRec->CacheColorExpandDensity;
-
- (*infoRec->SetupForScreenToScreenColorExpandFill)(pScrn, fg, bg, rop,
- planemask);
-
- if(infoRec->ClipBox)
- (*infoRec->SetClippingRectangle)(infoRec->pScrn,
- infoRec->ClipBox->x1, infoRec->ClipBox->y1,
- infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
-
- while(n--) {
- x = ppt->x;
- w = *pwidth;
- phaseX = (x - xorg) % pCache->orig_w;
- if(phaseX < 0) phaseX += pCache->orig_w;
- phaseY = (ppt->y - yorg) % pCache->orig_h;
- if(phaseY < 0) phaseY += pCache->orig_h;
-
- while(1) {
- blit_w = cacheWidth - phaseX;
- if(blit_w > w) blit_w = w;
-
- (*infoRec->SubsequentScreenToScreenColorExpandFill)(
- pScrn, x, ppt->y, blit_w, 1,
- pCache->x, pCache->y + phaseY, phaseX);
-
- w -= blit_w;
- if(!w) break;
- x += blit_w;
- phaseX = (phaseX + blit_w) % pCache->orig_w;
- }
- ppt++; pwidth++;
- }
-
- if(infoRec->ClipBox)
- (*infoRec->DisableClipping)(infoRec->pScrn);
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
-
-void
-XAAClipAndRenderSpans(
- GCPtr pGC,
- DDXPointPtr ppt,
- int *pwidth,
- int nspans,
- int fSorted,
- ClipAndRenderSpansFunc func,
- int xorg,
- int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- DDXPointPtr pptNew, pptBase;
- int *pwidthBase, *pwidthNew;
- int Right, numRects, MaxBoxes;
-
- MaxBoxes = infoRec->PreAllocSize/(sizeof(DDXPointRec) + sizeof(int));
- pptBase = (DDXPointRec*)infoRec->PreAllocMem;
- pwidthBase = (int*)(&pptBase[MaxBoxes]);
-
- pptNew = pptBase;
- pwidthNew = pwidthBase;
-
- numRects = RegionNumRects(pGC->pCompositeClip);
-
- if(numRects == 1) {
- BoxPtr pextent = RegionRects(pGC->pCompositeClip);
-
- while(nspans--) {
- if ((pextent->y1 <= ppt->y) && (ppt->y < pextent->y2)) {
- pptNew->x = max(pextent->x1, ppt->x);
- Right = ppt->x + *pwidth;
- *pwidthNew = min(pextent->x2, Right) - pptNew->x;
-
- if (*pwidthNew > 0) {
- pptNew->y = ppt->y;
- pptNew++;
- pwidthNew++;
-
- if(pptNew >= (pptBase + MaxBoxes)) {
- (*func)(pGC, MaxBoxes, pptBase, pwidthBase, fSorted,
- xorg, yorg);
- pptNew = pptBase;
- pwidthNew = pwidthBase;
- }
- }
- }
- ppt++;
- pwidth++;
- }
- } else if (numRects) {
- BoxPtr pbox;
- int nbox;
-
- while(nspans--) {
- nbox = numRects;
- pbox = RegionRects(pGC->pCompositeClip);
-
- /* find the first band */
- while(nbox && (pbox->y2 <= ppt->y)) {
- pbox++;
- nbox--;
- }
-
- if(nbox && (pbox->y1 <= ppt->y)) {
- int orig_y = pbox->y1;
- Right = ppt->x + *pwidth;
- while(nbox && (orig_y == pbox->y1)) {
- if(pbox->x2 <= ppt->x) {
- nbox--;
- pbox++;
- continue;
- }
-
- if(pbox->x1 >= Right) {
- nbox = 0;
- break;
- }
-
- pptNew->x = max(pbox->x1, ppt->x);
- *pwidthNew = min(pbox->x2, Right) - pptNew->x;
- if(*pwidthNew > 0) {
- pptNew->y = ppt->y;
- pptNew++;
- pwidthNew++;
-
- if(pptNew >= (pptBase + MaxBoxes)) {
- (*func)(pGC, MaxBoxes, pptBase, pwidthBase,
- fSorted, xorg, yorg);
- pptNew = pptBase;
- pwidthNew = pwidthBase;
- }
- }
- pbox++;
- nbox--;
- }
- }
- ppt++;
- pwidth++;
- }
- }
-
- if(pptNew != pptBase)
- (*func)(pGC, pptNew - pptBase, pptBase, pwidthBase, fSorted,
- xorg, yorg);
-}
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "xf86str.h"
+#include "mi.h"
+#include "mispans.h"
+#include "xaa.h"
+#include "xaalocal.h"
+
+static void XAARenderSolidSpans(GCPtr, int, DDXPointPtr, int *, int, int, int);
+static void XAARenderColor8x8Spans(GCPtr, int, DDXPointPtr, int *, int, int,
+ int);
+static void XAARenderMono8x8Spans(GCPtr, int, DDXPointPtr, int *, int, int,
+ int);
+static void XAARenderCacheBltSpans(GCPtr, int, DDXPointPtr, int *, int, int,
+ int);
+static void XAARenderColorExpandSpans(GCPtr, int, DDXPointPtr, int *, int, int,
+ int);
+static void XAARenderCacheExpandSpans(GCPtr, int, DDXPointPtr, int *, int, int,
+ int);
+static void XAARenderPixmapCopySpans(GCPtr, int, DDXPointPtr, int *, int, int,
+ int);
+
+void
+XAAFillSpans(DrawablePtr pDraw, GC * pGC, int nInit, /* number of spans to fill */
+ DDXPointPtr pptInit, /* pointer to list of start points */
+ int *pwidthInit, /* pointer to list of n widths */
+ int fSorted)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int type = 0;
+ ClipAndRenderSpansFunc function;
+ Bool fastClip = FALSE;
+
+ if ((nInit <= 0) || !pGC->planemask)
+ return;
+
+ if (!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ switch (pGC->fillStyle) {
+ case FillSolid:
+ type = DO_SOLID;
+ break;
+ case FillStippled:
+ type = (*infoRec->StippledFillChooser) (pGC);
+ break;
+ case FillOpaqueStippled:
+ if ((pGC->fgPixel == pGC->bgPixel) && infoRec->FillSpansSolid &&
+ CHECK_PLANEMASK(pGC, infoRec->FillSpansSolidFlags) &&
+ CHECK_ROP(pGC, infoRec->FillSpansSolidFlags) &&
+ CHECK_ROPSRC(pGC, infoRec->FillSpansSolidFlags) &&
+ CHECK_FG(pGC, infoRec->FillSpansSolidFlags))
+ type = DO_SOLID;
+ else
+ type = (*infoRec->OpaqueStippledFillChooser) (pGC);
+ break;
+ case FillTiled:
+ type = (*infoRec->TiledFillChooser) (pGC);
+ break;
+ }
+
+ switch (type) {
+ case DO_SOLID:
+ function = XAARenderSolidSpans;
+ if (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL)
+ fastClip = TRUE;
+ break;
+ case DO_COLOR_8x8:
+ function = XAARenderColor8x8Spans;
+ if (infoRec->ClippingFlags & HARDWARE_CLIP_COLOR_8x8_FILL)
+ fastClip = TRUE;
+ break;
+ case DO_MONO_8x8:
+ function = XAARenderMono8x8Spans;
+ if (infoRec->ClippingFlags & HARDWARE_CLIP_MONO_8x8_FILL)
+ fastClip = TRUE;
+ break;
+ case DO_CACHE_BLT:
+ function = XAARenderCacheBltSpans;
+ if (infoRec->ClippingFlags & HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY)
+ fastClip = TRUE;
+ break;
+ case DO_COLOR_EXPAND:
+ function = XAARenderColorExpandSpans;
+ break;
+ case DO_CACHE_EXPAND:
+ function = XAARenderCacheExpandSpans;
+ if (infoRec->ClippingFlags &
+ HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND)
+ fastClip = TRUE;
+ break;
+ case DO_PIXMAP_COPY:
+ function = XAARenderPixmapCopySpans;
+ if (infoRec->ClippingFlags & HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY)
+ fastClip = TRUE;
+ break;
+ case DO_IMAGE_WRITE:
+ default:
+ (*XAAFallbackOps.FillSpans) (pDraw, pGC, nInit, pptInit,
+ pwidthInit, fSorted);
+ return;
+ }
+
+ if ((nInit < 10) || (RegionNumRects(pGC->pCompositeClip) != 1))
+ fastClip = FALSE;
+
+ if (fastClip) {
+ infoRec->ClipBox = &pGC->pCompositeClip->extents;
+ (*function) (pGC, nInit, pptInit, pwidthInit, fSorted,
+ pDraw->x, pDraw->y);
+ infoRec->ClipBox = NULL;
+ }
+ else
+ XAAClipAndRenderSpans(pGC, pptInit, pwidthInit, nInit, fSorted,
+ function, pDraw->x, pDraw->y);
+}
+
+ /*********************\
+ | Solid Spans |
+ \*********************/
+
+static void
+XAARenderSolidSpans(GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
+ (*infoRec->FillSolidSpans) (infoRec->pScrn, pGC->fgPixel,
+ pGC->alu, pGC->planemask, n, ppt, pwidth,
+ fSorted);
+}
+
+ /************************\
+ | Mono 8x8 Spans |
+ \************************/
+
+static void
+XAARenderMono8x8Spans(GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAAPixmapPtr pPriv;
+ int fg, bg;
+
+ switch (pGC->fillStyle) {
+ case FillStippled:
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
+ fg = pGC->fgPixel;
+ bg = -1;
+ break;
+ case FillOpaqueStippled:
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
+ fg = pGC->fgPixel;
+ bg = pGC->bgPixel;
+ break;
+ case FillTiled:
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
+ fg = pPriv->fg;
+ bg = pPriv->bg;
+ break;
+ default: /* Muffle compiler */
+ pPriv = NULL; /* Kaboom */
+ fg = -1;
+ bg = -1;
+ break;
+ }
+
+ (*infoRec->FillMono8x8PatternSpans) (infoRec->pScrn,
+ fg, bg, pGC->alu, pGC->planemask,
+ n, ppt, pwidth, fSorted,
+ pPriv->pattern0, pPriv->pattern1,
+ (xorg + pGC->patOrg.x),
+ (yorg + pGC->patOrg.y));
+}
+
+ /*************************\
+ | Color 8x8 Spans |
+ \*************************/
+
+static void
+XAARenderColor8x8Spans(GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAACacheInfoPtr pCache;
+ PixmapPtr pPix;
+ int fg, bg;
+
+ switch (pGC->fillStyle) {
+ case FillStippled:
+ pPix = pGC->stipple;
+ fg = pGC->fgPixel;
+ bg = -1;
+ break;
+ case FillOpaqueStippled:
+ pPix = pGC->stipple;
+ fg = pGC->fgPixel;
+ bg = pGC->bgPixel;
+ break;
+ case FillTiled:
+ pPix = pGC->tile.pixmap;
+ fg = -1;
+ bg = -1;
+ break;
+ default: /* Muffle compiler */
+ pPix = NULL;
+ fg = -1;
+ bg = -1;
+ break;
+ }
+
+ pCache = (*infoRec->CacheColor8x8Pattern) (infoRec->pScrn, pPix, fg, bg);
+
+ (*infoRec->FillColor8x8PatternSpans) (infoRec->pScrn,
+ pGC->alu, pGC->planemask, n, ppt,
+ pwidth, fSorted, pCache,
+ (yorg + pGC->patOrg.x),
+ (xorg + pGC->patOrg.y));
+}
+
+ /****************************\
+ | Color Expand Spans |
+ \****************************/
+
+static void
+XAARenderColorExpandSpans(GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int fg, bg;
+
+ switch (pGC->fillStyle) {
+ case FillStippled:
+ fg = pGC->fgPixel;
+ bg = -1;
+ break;
+ case FillOpaqueStippled:
+ fg = pGC->fgPixel;
+ bg = pGC->bgPixel;
+ break;
+ default: /* Muffle compiler */
+ fg = -1;
+ bg = -1;
+ break;
+ }
+
+ (*infoRec->FillColorExpandSpans) (infoRec->pScrn, fg, bg,
+ pGC->alu, pGC->planemask, n, ppt, pwidth,
+ fSorted, (xorg + pGC->patOrg.x),
+ (yorg + pGC->patOrg.y), pGC->stipple);
+
+}
+
+ /*************************\
+ | Cache Blt Spans |
+ \*************************/
+
+static void
+XAARenderCacheBltSpans(GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAACacheInfoPtr pCache;
+
+ switch (pGC->fillStyle) {
+ case FillStippled:
+ pCache = (*infoRec->CacheStipple) (infoRec->pScrn, pGC->stipple,
+ pGC->fgPixel, -1);
+ break;
+ case FillOpaqueStippled:
+ pCache = (*infoRec->CacheStipple) (infoRec->pScrn, pGC->stipple,
+ pGC->fgPixel, pGC->bgPixel);
+ break;
+ case FillTiled:
+ pCache = (*infoRec->CacheTile) (infoRec->pScrn, pGC->tile.pixmap);
+ break;
+ default: /* Muffle compiler */
+ pCache = NULL;
+ break;
+ }
+
+ (*infoRec->FillCacheBltSpans) (infoRec->pScrn,
+ pGC->alu, pGC->planemask, n, ppt, pwidth,
+ fSorted, pCache, (xorg + pGC->patOrg.x),
+ (yorg + pGC->patOrg.y));
+
+}
+
+ /****************************\
+ | Cache Expand Spans |
+ \****************************/
+
+static void
+XAARenderCacheExpandSpans(GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int fg, bg;
+
+ switch (pGC->fillStyle) {
+ case FillStippled:
+ fg = pGC->fgPixel;
+ bg = -1;
+ break;
+ case FillOpaqueStippled:
+ fg = pGC->fgPixel;
+ bg = pGC->bgPixel;
+ break;
+ default: /* Muffle compiler */
+ fg = -1;
+ bg = -1;
+ break;
+ }
+
+ (*infoRec->FillCacheExpandSpans) (infoRec->pScrn, fg, bg,
+ pGC->alu, pGC->planemask, n, ppt, pwidth,
+ fSorted, (xorg + pGC->patOrg.x),
+ (yorg + pGC->patOrg.y), pGC->stipple);
+}
+
+ /***************************\
+ | Pixmap Copy Spans |
+ \***************************/
+
+static void
+XAARenderPixmapCopySpans(GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec);
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
+
+ pCache->x = pPriv->offscreenArea->box.x1;
+ pCache->y = pPriv->offscreenArea->box.y1;
+ pCache->w = pCache->orig_w = pPriv->offscreenArea->box.x2 - pCache->x;
+ pCache->h = pCache->orig_h = pPriv->offscreenArea->box.y2 - pCache->y;
+ pCache->trans_color = -1;
+
+ (*infoRec->FillCacheBltSpans) (infoRec->pScrn,
+ pGC->alu, pGC->planemask, n, ppt, pwidth,
+ fSorted, pCache, (xorg + pGC->patOrg.x),
+ (yorg + pGC->patOrg.y));
+}
+
+ /****************\
+ | Solid |
+ \****************/
+
+void
+XAAFillSolidSpans(ScrnInfoPtr pScrn,
+ int fg, int rop,
+ unsigned int planemask,
+ int n, DDXPointPtr ppt, int *pwidth, int fSorted)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->SetupForSolidFill) (pScrn, fg, rop, planemask);
+
+ if (infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle) (infoRec->pScrn,
+ infoRec->ClipBox->x1,
+ infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1,
+ infoRec->ClipBox->y2 - 1);
+
+ while (n--) {
+ if (*pwidth > 0)
+ (*infoRec->SubsequentSolidFillRect) (pScrn, ppt->x, ppt->y,
+ *pwidth, 1);
+ ppt++;
+ pwidth++;
+ }
+
+ if (infoRec->ClipBox)
+ (*infoRec->DisableClipping) (infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+ /***************\
+ | Mono 8x8 |
+ \***************/
+
+void
+XAAFillMono8x8PatternSpansScreenOrigin(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted,
+ int pattern0, int pattern1,
+ int xorigin, int yorigin)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int patx = pattern0, paty = pattern1;
+ int xorg = (-xorigin) & 0x07;
+ int yorg = (-yorigin) & 0x07;
+
+ if (infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ if (!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx;
+ yorg = paty;
+ }
+ }
+ else {
+ XAACacheInfoPtr pCache =
+ (*infoRec->CacheMono8x8Pattern) (pScrn, pattern0, pattern1);
+ patx = pCache->x;
+ paty = pCache->y;
+ if (!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+ int slot = (yorg << 3) + xorg;
+
+ patx += pCache->offsets[slot].x;
+ paty += pCache->offsets[slot].y;
+ xorg = patx;
+ yorg = paty;
+ }
+ }
+
+ (*infoRec->SetupForMono8x8PatternFill) (pScrn, patx, paty,
+ fg, bg, rop, planemask);
+
+ if (infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle) (infoRec->pScrn,
+ infoRec->ClipBox->x1,
+ infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1,
+ infoRec->ClipBox->y2 - 1);
+
+ while (n--) {
+ (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn,
+ xorg, yorg, ppt->x,
+ ppt->y, *pwidth, 1);
+ ppt++;
+ pwidth++;
+ }
+
+ if (infoRec->ClipBox)
+ (*infoRec->DisableClipping) (infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+void
+XAAFillMono8x8PatternSpans(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted,
+ int pattern0, int pattern1, int xorigin, int yorigin)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int patx = pattern0, paty = pattern1;
+ int xorg, yorg, slot;
+ XAACacheInfoPtr pCache = NULL;
+
+ if (!(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS)) {
+ pCache = (*infoRec->CacheMono8x8Pattern) (pScrn, pattern0, pattern1);
+ patx = pCache->x;
+ paty = pCache->y;
+ }
+
+ (*infoRec->SetupForMono8x8PatternFill) (pScrn, patx, paty,
+ fg, bg, rop, planemask);
+
+ if (infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle) (infoRec->pScrn,
+ infoRec->ClipBox->x1,
+ infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1,
+ infoRec->ClipBox->y2 - 1);
+
+ while (n--) {
+ xorg = (ppt->x - xorigin) & 0x07;
+ yorg = (ppt->y - yorigin) & 0x07;
+
+ if (!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+ if (infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ patx = pattern0;
+ paty = pattern1;
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx;
+ yorg = paty;
+ }
+ else {
+ slot = (yorg << 3) + xorg;
+ xorg = patx + pCache->offsets[slot].x;
+ yorg = paty + pCache->offsets[slot].y;
+ }
+ }
+
+ (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn,
+ xorg, yorg, ppt->x,
+ ppt->y, *pwidth, 1);
+ ppt++;
+ pwidth++;
+ }
+
+ if (infoRec->ClipBox)
+ (*infoRec->DisableClipping) (infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+ /****************\
+ | Color 8x8 |
+ \****************/
+
+void
+XAAFillColor8x8PatternSpansScreenOrigin(ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted,
+ XAACacheInfoPtr pCache,
+ int xorigin, int yorigin)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int patx = pCache->x, paty = pCache->y;
+ int xorg = (-xorigin) & 0x07;
+ int yorg = (-yorigin) & 0x07;
+
+ if (!(infoRec->Color8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+ int slot = (yorg << 3) + xorg;
+
+ paty += pCache->offsets[slot].y;
+ patx += pCache->offsets[slot].x;
+ xorg = patx;
+ yorg = paty;
+ }
+
+ (*infoRec->SetupForColor8x8PatternFill) (pScrn, patx, paty,
+ rop, planemask,
+ pCache->trans_color);
+
+ if (infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle) (infoRec->pScrn,
+ infoRec->ClipBox->x1,
+ infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1,
+ infoRec->ClipBox->y2 - 1);
+
+ while (n--) {
+ (*infoRec->SubsequentColor8x8PatternFillRect) (pScrn,
+ xorg, yorg, ppt->x,
+ ppt->y, *pwidth, 1);
+ ppt++;
+ pwidth++;
+ }
+
+ if (infoRec->ClipBox)
+ (*infoRec->DisableClipping) (infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+void
+XAAFillColor8x8PatternSpans(ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted,
+ XAACacheInfoPtr pCache, int xorigin, int yorigin)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int xorg, yorg, slot;
+
+ (*infoRec->SetupForColor8x8PatternFill) (pScrn, pCache->x, pCache->y,
+ rop, planemask,
+ pCache->trans_color);
+
+ if (infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle) (infoRec->pScrn,
+ infoRec->ClipBox->x1,
+ infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1,
+ infoRec->ClipBox->y2 - 1);
+
+ while (n--) {
+ xorg = (ppt->x - xorigin) & 0x07;
+ yorg = (ppt->y - yorigin) & 0x07;
+
+ if (!(infoRec->Color8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+ slot = (yorg << 3) + xorg;
+ yorg = pCache->y + pCache->offsets[slot].y;
+ xorg = pCache->x + pCache->offsets[slot].x;
+ }
+
+ (*infoRec->SubsequentColor8x8PatternFillRect) (pScrn,
+ xorg, yorg, ppt->x,
+ ppt->y, *pwidth, 1);
+ ppt++;
+ pwidth++;
+ }
+
+ if (infoRec->ClipBox)
+ (*infoRec->DisableClipping) (infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+ /*****************\
+ | Cache Blit |
+ \*****************/
+
+void
+XAAFillCacheBltSpans(ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted, XAACacheInfoPtr pCache, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, w, phaseX, phaseY, blit_w;
+
+ (*infoRec->SetupForScreenToScreenCopy) (pScrn, 1, 1, rop, planemask,
+ pCache->trans_color);
+
+ if (infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle) (infoRec->pScrn,
+ infoRec->ClipBox->x1,
+ infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1,
+ infoRec->ClipBox->y2 - 1);
+
+ while (n--) {
+ x = ppt->x;
+ w = *pwidth;
+ phaseX = (x - xorg) % pCache->orig_w;
+ if (phaseX < 0)
+ phaseX += pCache->orig_w;
+ phaseY = (ppt->y - yorg) % pCache->orig_h;
+ if (phaseY < 0)
+ phaseY += pCache->orig_h;
+
+ while (1) {
+ blit_w = pCache->w - phaseX;
+ if (blit_w > w)
+ blit_w = w;
+
+ (*infoRec->SubsequentScreenToScreenCopy) (pScrn,
+ pCache->x + phaseX,
+ pCache->y + phaseY, x,
+ ppt->y, blit_w, 1);
+
+ w -= blit_w;
+ if (!w)
+ break;
+ x += blit_w;
+ phaseX = (phaseX + blit_w) % pCache->orig_w;
+ }
+ ppt++;
+ pwidth++;
+ }
+
+ if (infoRec->ClipBox)
+ (*infoRec->DisableClipping) (infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+ /****************\
+ | Cache Expand |
+ \****************/
+
+void
+XAAFillCacheExpandSpans(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted, int xorg, int yorg, PixmapPtr pPix)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, w, phaseX, phaseY, blit_w, cacheWidth;
+ XAACacheInfoPtr pCache;
+
+ pCache = (*infoRec->CacheMonoStipple) (pScrn, pPix);
+
+ cacheWidth = (pCache->w * pScrn->bitsPerPixel) /
+ infoRec->CacheColorExpandDensity;
+
+ (*infoRec->SetupForScreenToScreenColorExpandFill) (pScrn, fg, bg, rop,
+ planemask);
+
+ if (infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle) (infoRec->pScrn,
+ infoRec->ClipBox->x1,
+ infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1,
+ infoRec->ClipBox->y2 - 1);
+
+ while (n--) {
+ x = ppt->x;
+ w = *pwidth;
+ phaseX = (x - xorg) % pCache->orig_w;
+ if (phaseX < 0)
+ phaseX += pCache->orig_w;
+ phaseY = (ppt->y - yorg) % pCache->orig_h;
+ if (phaseY < 0)
+ phaseY += pCache->orig_h;
+
+ while (1) {
+ blit_w = cacheWidth - phaseX;
+ if (blit_w > w)
+ blit_w = w;
+
+ (*infoRec->SubsequentScreenToScreenColorExpandFill) (pScrn, x,
+ ppt->y, blit_w,
+ 1, pCache->x,
+ pCache->y +
+ phaseY,
+ phaseX);
+
+ w -= blit_w;
+ if (!w)
+ break;
+ x += blit_w;
+ phaseX = (phaseX + blit_w) % pCache->orig_w;
+ }
+ ppt++;
+ pwidth++;
+ }
+
+ if (infoRec->ClipBox)
+ (*infoRec->DisableClipping) (infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+void
+XAAClipAndRenderSpans(GCPtr pGC,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ int fSorted,
+ ClipAndRenderSpansFunc func, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ DDXPointPtr pptNew, pptBase;
+ int *pwidthBase, *pwidthNew;
+ int Right, numRects, MaxBoxes;
+
+ MaxBoxes = infoRec->PreAllocSize / (sizeof(DDXPointRec) + sizeof(int));
+ pptBase = (DDXPointRec *) infoRec->PreAllocMem;
+ pwidthBase = (int *) (&pptBase[MaxBoxes]);
+
+ pptNew = pptBase;
+ pwidthNew = pwidthBase;
+
+ numRects = RegionNumRects(pGC->pCompositeClip);
+
+ if (numRects == 1) {
+ BoxPtr pextent = RegionRects(pGC->pCompositeClip);
+
+ while (nspans--) {
+ if ((pextent->y1 <= ppt->y) && (ppt->y < pextent->y2)) {
+ pptNew->x = max(pextent->x1, ppt->x);
+ Right = ppt->x + *pwidth;
+ *pwidthNew = min(pextent->x2, Right) - pptNew->x;
+
+ if (*pwidthNew > 0) {
+ pptNew->y = ppt->y;
+ pptNew++;
+ pwidthNew++;
+
+ if (pptNew >= (pptBase + MaxBoxes)) {
+ (*func) (pGC, MaxBoxes, pptBase, pwidthBase, fSorted,
+ xorg, yorg);
+ pptNew = pptBase;
+ pwidthNew = pwidthBase;
+ }
+ }
+ }
+ ppt++;
+ pwidth++;
+ }
+ }
+ else if (numRects) {
+ BoxPtr pbox;
+ int nbox;
+
+ while (nspans--) {
+ nbox = numRects;
+ pbox = RegionRects(pGC->pCompositeClip);
+
+ /* find the first band */
+ while (nbox && (pbox->y2 <= ppt->y)) {
+ pbox++;
+ nbox--;
+ }
+
+ if (nbox && (pbox->y1 <= ppt->y)) {
+ int orig_y = pbox->y1;
+
+ Right = ppt->x + *pwidth;
+ while (nbox && (orig_y == pbox->y1)) {
+ if (pbox->x2 <= ppt->x) {
+ nbox--;
+ pbox++;
+ continue;
+ }
+
+ if (pbox->x1 >= Right) {
+ nbox = 0;
+ break;
+ }
+
+ pptNew->x = max(pbox->x1, ppt->x);
+ *pwidthNew = min(pbox->x2, Right) - pptNew->x;
+ if (*pwidthNew > 0) {
+ pptNew->y = ppt->y;
+ pptNew++;
+ pwidthNew++;
+
+ if (pptNew >= (pptBase + MaxBoxes)) {
+ (*func) (pGC, MaxBoxes, pptBase, pwidthBase,
+ fSorted, xorg, yorg);
+ pptNew = pptBase;
+ pwidthNew = pwidthBase;
+ }
+ }
+ pbox++;
+ nbox--;
+ }
+ }
+ ppt++;
+ pwidth++;
+ }
+ }
+
+ if (pptNew != pptBase)
+ (*func) (pGC, pptNew - pptBase, pptBase, pwidthBase, fSorted,
+ xorg, yorg);
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaStateChange.c b/xorg-server/hw/xfree86/xaa/xaaStateChange.c
index 4eb15125b..0218cb57c 100644
--- a/xorg-server/hw/xfree86/xaa/xaaStateChange.c
+++ b/xorg-server/hw/xfree86/xaa/xaaStateChange.c
@@ -1,1627 +1,1665 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "windowstr.h"
-#include "xf86str.h"
-#include "mi.h"
-#include "miline.h"
-#include "xaa.h"
-#include "xaalocal.h"
-#include "xaawrap.h"
-#include "servermd.h"
-
-#define XAA_STATE_WRAP(func) do {\
-if(infoRec->func) { \
- pStatePriv->func = infoRec->func;\
- infoRec->func = XAAStateWrap##func;\
-}} while(0)
-
-/* Wrap all XAA functions and allocate our private structure.
- */
-
-typedef struct _XAAStateWrapRec {
- ScrnInfoPtr pScrn;
- void (*RestoreAccelState)(ScrnInfoPtr pScrn);
- void (*Sync)(ScrnInfoPtr pScrn);
- void (*SetupForScreenToScreenCopy)(ScrnInfoPtr pScrn, int xdir, int ydir,
- int rop, unsigned int planemask,
- int trans_color);
- void (*SetupForSolidFill)(ScrnInfoPtr pScrn, int color, int rop,
- unsigned int planemask);
- void (*SetupForSolidLine)(ScrnInfoPtr pScrn,int color,int rop,
- unsigned int planemask);
- void (*SetupForDashedLine)(ScrnInfoPtr pScrn, int fg, int bg, int rop,
- unsigned int planemask, int length,
- unsigned char *pattern);
- void (*SetClippingRectangle) (ScrnInfoPtr pScrn, int left, int top,
- int right, int bottom);
- void (*DisableClipping)(ScrnInfoPtr pScrn);
- void (*SetupForMono8x8PatternFill)(ScrnInfoPtr pScrn, int patx, int paty,
- int fg, int bg, int rop,
- unsigned int planemask);
- void (*SetupForColor8x8PatternFill)(ScrnInfoPtr pScrn, int patx, int paty,
- int rop, unsigned int planemask,
- int transparency_color);
- void (*SetupForCPUToScreenColorExpandFill)(ScrnInfoPtr pScrn, int fg,
- int bg, int rop,
- unsigned int planemask);
- void (*SetupForScanlineCPUToScreenColorExpandFill)(ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask);
- void (*SetupForScreenToScreenColorExpandFill) (ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask);
- void (*SetupForImageWrite)(ScrnInfoPtr pScrn, int rop,
- unsigned int planemask, int transparency_color,
- int bpp, int depth);
- void (*SetupForScanlineImageWrite)(ScrnInfoPtr pScrn, int rop,
- unsigned int planemask,
- int transparency_color,
- int bpp, int depth);
- void (*SetupForImageRead) (ScrnInfoPtr pScrn, int bpp, int depth);
- void (*ScreenToScreenBitBlt)(ScrnInfoPtr pScrn, int nbox,
- DDXPointPtr pptSrc, BoxPtr pbox, int xdir,
- int ydir, int alu, unsigned int planmask);
- void (*WriteBitmap) (ScrnInfoPtr pScrn, int x, int y, int w, int h,
- unsigned char *src, int srcwidth, int skipleft,
- int fg, int bg, int rop, unsigned int planemask);
- void (*FillSolidRects)(ScrnInfoPtr pScrn, int fg, int rop,
- unsigned int planemask, int nBox, BoxPtr pBox);
- void (*FillMono8x8PatternRects)(ScrnInfoPtr pScrn, int fg, int bg, int rop,
- unsigned int planemask, int nBox,
- BoxPtr pBox, int pat0, int pat1,
- int xorg, int yorg);
- void (*FillColor8x8PatternRects)(ScrnInfoPtr pScrn, int rop,
- unsigned int planemask, int nBox,
- BoxPtr pBox, int xorg, int yorg,
- XAACacheInfoPtr pCache);
- void (*FillCacheBltRects)(ScrnInfoPtr pScrn, int rop,
- unsigned int planemask, int nBox, BoxPtr pBox,
- int xorg, int yorg, XAACacheInfoPtr pCache);
- void (*FillColorExpandRects)(ScrnInfoPtr pScrn, int fg, int bg, int rop,
- unsigned int planemask, int nBox,
- BoxPtr pBox, int xorg, int yorg,
- PixmapPtr pPix);
- void (*FillCacheExpandRects)(ScrnInfoPtr pScrn, int fg, int bg, int rop,
- unsigned int planemask, int nBox, BoxPtr pBox,
- int xorg, int yorg, PixmapPtr pPix);
- void (*FillImageWriteRects)(ScrnInfoPtr pScrn, int rop,
- unsigned int planemask, int nBox, BoxPtr pBox,
- int xorg, int yorg, PixmapPtr pPix);
- void (*FillSolidSpans)(ScrnInfoPtr pScrn, int fg, int rop,
- unsigned int planemask, int n, DDXPointPtr points,
- int *widths, int fSorted);
- void (*FillMono8x8PatternSpans)(ScrnInfoPtr pScrn, int fg, int bg, int rop,
- unsigned int planemask, int n,
- DDXPointPtr points, int *widths,
- int fSorted, int pat0, int pat1,
- int xorg, int yorg);
- void (*FillColor8x8PatternSpans)(ScrnInfoPtr pScrn, int rop,
- unsigned int planemask, int n,
- DDXPointPtr points, int *widths,
- int fSorted, XAACacheInfoPtr pCache,
- int xorg, int yorg);
- void (*FillCacheBltSpans)(ScrnInfoPtr pScrn, int rop,
- unsigned int planemask, int n, DDXPointPtr points,
- int *widths, int fSorted, XAACacheInfoPtr pCache,
- int xorg, int yorg);
- void (*FillColorExpandSpans)(ScrnInfoPtr pScrn, int fg, int bg, int rop,
- unsigned int planemask, int n,
- DDXPointPtr points, int *widths, int fSorted,
- int xorg, int yorg, PixmapPtr pPix);
- void (*FillCacheExpandSpans)(ScrnInfoPtr pScrn, int fg, int bg, int rop,
- unsigned int planemask, int n, DDXPointPtr ppt,
- int *pwidth, int fSorted, int xorg, int yorg,
- PixmapPtr pPix);
- void (*TEGlyphRenderer)(ScrnInfoPtr pScrn, int x, int y, int w, int h,
- int skipleft, int startline, unsigned int **glyphs,
- int glyphWidth, int fg, int bg, int rop,
- unsigned planemask);
- void (*NonTEGlyphRenderer)(ScrnInfoPtr pScrn, int x, int y, int n,
- NonTEGlyphPtr glyphs, BoxPtr pbox,
- int fg, int rop, unsigned int planemask);
- void (*WritePixmap) (ScrnInfoPtr pScrn, int x, int y, int w, int h,
- unsigned char *src, int srcwidth, int rop,
- unsigned int planemask, int transparency_color,
- int bpp, int depth);
- void (*ReadPixmap) (ScrnInfoPtr pScrn, int x, int y, int w, int h,
- unsigned char *dst, int dstwidth, int bpp, int depth);
- RegionPtr (*CopyArea)(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
- GC *pGC, int srcx, int srcy, int width, int height,
- int dstx, int dsty);
- RegionPtr (*CopyPlane)(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
- int srcx, int srcy, int width, int height, int dstx,
- int dsty, unsigned long bitPlane);
- void (*PushPixelsSolid) (GCPtr pGC, PixmapPtr pBitMap,
- DrawablePtr pDrawable, int dx, int dy, int xOrg,
- int yOrg);
- void (*PolyFillRectSolid)(DrawablePtr pDraw, GCPtr pGC, int nrectFill,
- xRectangle *prectInit);
- void (*PolyFillRectStippled)(DrawablePtr pDraw, GCPtr pGC, int nrectFill,
- xRectangle *prectInit);
- void (*PolyFillRectOpaqueStippled)(DrawablePtr pDraw, GCPtr pGC,
- int nrectFill, xRectangle *prectInit);
- void (*PolyFillRectTiled)(DrawablePtr pDraw, GCPtr pGC, int nrectFill,
- xRectangle *prectInit);
- void (*FillSpansSolid)(DrawablePtr pDraw, GCPtr pGC, int nInit,
- DDXPointPtr ppt, int *pwidth, int fSorted);
- void (*FillSpansStippled)(DrawablePtr pDraw, GCPtr pGC, int nInit,
- DDXPointPtr ppt, int *pwidth, int fSorted);
- void (*FillSpansOpaqueStippled)(DrawablePtr pDraw, GCPtr pGC, int nInit,
- DDXPointPtr ppt, int *pwidth, int fSorted);
- void (*FillSpansTiled)(DrawablePtr pDraw, GCPtr pGC, int nInit,
- DDXPointPtr ppt, int *pwidth, int fSorted);
- int (*PolyText8TE) (DrawablePtr pDraw, GCPtr pGC, int x, int y, int count,
- char *chars);
- int (*PolyText16TE) (DrawablePtr pDraw, GCPtr pGC, int x, int y, int count,
- unsigned short *chars);
- void (*ImageText8TE) (DrawablePtr pDraw, GCPtr pGC, int x, int y, int count,
- char *chars);
- void (*ImageText16TE) (DrawablePtr pDraw, GCPtr pGC, int x, int y,
- int count, unsigned short *chars);
- void (*ImageGlyphBltTE) (DrawablePtr pDrawable, GCPtr pGC, int xInit,
- int yInit, unsigned int nglyph, CharInfoPtr *ppci,
- pointer pglyphBase);
- void (*PolyGlyphBltTE) (DrawablePtr pDrawable, GCPtr pGC, int xInit,
- int yInit, unsigned int nglyph, CharInfoPtr *ppci,
- pointer pglyphBase);
- int (*PolyText8NonTE) (DrawablePtr pDraw, GCPtr pGC, int x, int y,
- int count, char *chars);
- int (*PolyText16NonTE) (DrawablePtr pDraw, GCPtr pGC, int x, int y,
- int count, unsigned short *chars);
- void (*ImageText8NonTE) (DrawablePtr pDraw, GCPtr pGC, int x, int y,
- int count, char *chars);
- void (*ImageText16NonTE) (DrawablePtr pDraw, GCPtr pGC, int x, int y,
- int count, unsigned short *chars);
- void (*ImageGlyphBltNonTE) (DrawablePtr pDrawable, GCPtr pGC, int xInit,
- int yInit, unsigned int nglyph,
- CharInfoPtr *ppci, pointer pglyphBase);
- void (*PolyGlyphBltNonTE) (DrawablePtr pDrawable, GCPtr pGC, int xInit,
- int yInit, unsigned int nglyph,
- CharInfoPtr *ppci, pointer pglyphBase);
- void (*PolyRectangleThinSolid)(DrawablePtr pDrawable,GCPtr pGC,
- int nRectsInit, xRectangle *pRectsInit);
- void (*PolylinesWideSolid)(DrawablePtr pDrawable, GCPtr pGC, int mode,
- int npt, DDXPointPtr pPts);
- void (*PolylinesThinSolid)(DrawablePtr pDrawable, GCPtr pGC, int mode,
- int npt, DDXPointPtr pPts);
- void (*PolySegmentThinSolid)(DrawablePtr pDrawable, GCPtr pGC, int nseg,
- xSegment *pSeg);
- void (*PolylinesThinDashed)(DrawablePtr pDrawable, GCPtr pGC, int mode,
- int npt, DDXPointPtr pPts);
- void (*PolySegmentThinDashed)(DrawablePtr pDrawable, GCPtr pGC, int nseg,
- xSegment *pSeg);
- void (*FillPolygonSolid)(DrawablePtr pDrawable, GCPtr pGC, int shape,
- int mode, int count, DDXPointPtr ptsIn);
- void (*FillPolygonStippled)(DrawablePtr pDrawable, GCPtr pGC, int shape,
- int mode, int count, DDXPointPtr ptsIn);
- void (*FillPolygonOpaqueStippled)(DrawablePtr pDrawable, GCPtr pGC,
- int shape, int mode, int count,
- DDXPointPtr ptsIn);
- void (*FillPolygonTiled)(DrawablePtr pDrawable, GCPtr pGC, int shape,
- int mode, int count, DDXPointPtr ptsIn);
- void (*PolyFillArcSolid)(DrawablePtr pDraw, GCPtr pGC, int narcs,
- xArc *parcs);
- void (*PutImage)(DrawablePtr pDraw, GCPtr pGC, int depth, int x, int y,
- int w, int h, int leftPad, int format, char *pImage);
- ValidateGCProcPtr ValidateFillSpans;
- ValidateGCProcPtr ValidateSetSpans;
- ValidateGCProcPtr ValidatePutImage;
- ValidateGCProcPtr ValidateCopyArea;
- ValidateGCProcPtr ValidateCopyPlane;
- ValidateGCProcPtr ValidatePolyPoint;
- ValidateGCProcPtr ValidatePolylines;
- ValidateGCProcPtr ValidatePolySegment;
- ValidateGCProcPtr ValidatePolyRectangle;
- ValidateGCProcPtr ValidatePolyArc;
- ValidateGCProcPtr ValidateFillPolygon;
- ValidateGCProcPtr ValidatePolyFillRect;
- ValidateGCProcPtr ValidatePolyFillArc;
- ValidateGCProcPtr ValidatePolyText8;
- ValidateGCProcPtr ValidatePolyText16;
- ValidateGCProcPtr ValidateImageText8;
- ValidateGCProcPtr ValidateImageText16;
- ValidateGCProcPtr ValidatePolyGlyphBlt;
- ValidateGCProcPtr ValidateImageGlyphBlt;
- ValidateGCProcPtr ValidatePushPixels;
- void (*ComputeDash)(GCPtr pGC);
- void (*InitPixmapCache)(ScreenPtr pScreen, RegionPtr areas, pointer data);
- void (*ClosePixmapCache)(ScreenPtr pScreen);
- int (*StippledFillChooser)(GCPtr pGC);
- int (*OpaqueStippledFillChooser)(GCPtr pGC);
- int (*TiledFillChooser)(GCPtr pGC);
- XAACacheInfoPtr (*CacheTile)(ScrnInfoPtr Scrn, PixmapPtr pPix);
- XAACacheInfoPtr (*CacheStipple)(ScrnInfoPtr Scrn, PixmapPtr pPix, int fg,
- int bg);
- XAACacheInfoPtr (*CacheMonoStipple)(ScrnInfoPtr Scrn, PixmapPtr pPix);
- XAACacheInfoPtr (*CacheMono8x8Pattern)(ScrnInfoPtr Scrn, int pat0,
- int pat1);
- XAACacheInfoPtr (*CacheColor8x8Pattern)(ScrnInfoPtr Scrn, PixmapPtr pPix,
- int fg, int bg);
- void (*WriteBitmapToCache) (ScrnInfoPtr pScrn, int x, int y, int w, int h,
- unsigned char *src, int srcwidth, int fg,
- int bg);
- void (*WritePixmapToCache) (ScrnInfoPtr pScrn, int x, int y, int w, int h,
- unsigned char *src, int srcwidth, int bpp,
- int depth);
- void (*WriteMono8x8PatternToCache)(ScrnInfoPtr pScrn,
- XAACacheInfoPtr pCache);
- void (*WriteColor8x8PatternToCache)(ScrnInfoPtr pScrn, PixmapPtr pPix,
- XAACacheInfoPtr pCache);
- GetImageProcPtr GetImage;
- GetSpansProcPtr GetSpans;
- CopyWindowProcPtr CopyWindow;
- Bool (*SetupForCPUToScreenAlphaTexture2)(ScrnInfoPtr pScrn, int op,
- CARD16 red, CARD16 green,
- CARD16 blue, CARD16 alpha,
- CARD32 maskFormat, CARD32 dstFormat,
- CARD8 *alphaPtr, int alphaPitch,
- int width, int height, int flags);
- Bool (*SetupForCPUToScreenTexture2)(ScrnInfoPtr pScrn, int op,
- CARD32 srcFormat, CARD32 dstFormat,
- CARD8 *texPtr, int texPitch,
- int width, int height, int flags);
-} XAAStateWrapRec, *XAAStateWrapPtr;
-
-static DevPrivateKeyRec XAAStateKeyRec;
-#define XAAStateKey (&XAAStateKeyRec)
-
-/* Wrap functions start here */
-#define GET_STATEPRIV_GC(pGC) XAAStateWrapPtr pStatePriv =\
-(XAAStateWrapPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAStateKey)
-
-#define GET_STATEPRIV_SCREEN(pScreen) XAAStateWrapPtr pStatePriv =\
-(XAAStateWrapPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAStateKey)
-
-#define GET_STATEPRIV_PSCRN(pScrn) XAAStateWrapPtr pStatePriv =\
-(XAAStateWrapPtr)dixLookupPrivate(&(pScrn)->pScreen->devPrivates, XAAStateKey)
-
-#define STATE_CHECK_SP(pStatePriv) {\
- ScrnInfoPtr pScrn = pStatePriv->pScrn;\
- int i = 0;\
- int need_change = 0;\
- while(i < pScrn->numEntities) {\
- if(xf86IsEntityShared(pScrn->entityList[i]) &&\
- xf86GetLastScrnFlag(pScrn->entityList[i]) != pScrn->scrnIndex) {\
- need_change = 1;\
- xf86SetLastScrnFlag(pScrn->entityList[i],\
- pScrn->scrnIndex);\
- }\
- i++;\
- }\
- if(need_change == 1) (*pStatePriv->RestoreAccelState)(pScrn);\
-}
-
-#define STATE_CHECK_PSCRN(pScrn) {\
- int i = 0;\
- int need_change = 0;\
- while(i < pScrn->numEntities) {\
- if(xf86IsEntityShared(pScrn->entityList[i]) &&\
- xf86GetLastScrnFlag(pScrn->entityList[i]) != pScrn->scrnIndex) {\
- need_change = 1;\
- xf86SetLastScrnFlag(pScrn->entityList[i],\
- pScrn->scrnIndex);\
- }\
- i++;\
- }\
- if(need_change == 1) (*pStatePriv->RestoreAccelState)(pScrn);\
-}
-
-static void XAAStateWrapSync(ScrnInfoPtr pScrn)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->Sync)(pScrn);
-}
-
-static void XAAStateWrapSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir,
- int rop, unsigned int planemask,
- int trans_color)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->SetupForScreenToScreenCopy)(pScrn, xdir, ydir, rop, planemask,
- trans_color);
-}
-
-static void XAAStateWrapSetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop,
- unsigned int planemask)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->SetupForSolidFill)(pScrn, color, rop, planemask);
-}
-
-static void XAAStateWrapSetupForSolidLine(ScrnInfoPtr pScrn,int color,int rop,
- unsigned int planemask)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->SetupForSolidLine)(pScrn, color, rop, planemask);
-}
-
-static void XAAStateWrapSetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop,
- unsigned int planemask, int length,
- unsigned char *pattern)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->SetupForDashedLine)(pScrn, fg, bg, rop, planemask, length, pattern);
-}
-
-static void XAAStateWrapSetClippingRectangle(ScrnInfoPtr pScrn, int left, int top,
- int right, int bottom)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->SetClippingRectangle)(pScrn, left, top, right, bottom);
-}
-
-static void XAAStateWrapDisableClipping(ScrnInfoPtr pScrn)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->DisableClipping)(pScrn);
-}
-
-static void XAAStateWrapSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty,
- int fg, int bg, int rop,
- unsigned int planemask)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->SetupForMono8x8PatternFill)(pScrn, patx, paty, fg, bg, rop, planemask);
-}
-
-static void XAAStateWrapSetupForColor8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty,
- int rop, unsigned int planemask,
- int transparency_color)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->SetupForColor8x8PatternFill)(pScrn, patx, paty, rop, planemask,
- transparency_color);
-}
-
-static void XAAStateWrapSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg,
- int bg, int rop,
- unsigned int planemask)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->SetupForCPUToScreenColorExpandFill)(pScrn, fg, bg, rop, planemask);
-}
-
-static void XAAStateWrapSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn,
- int fg, int bg,
- int rop,
- unsigned int planemask)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->SetupForScanlineCPUToScreenColorExpandFill)(pScrn, fg, bg, rop,
- planemask);
-}
-
-static void XAAStateWrapSetupForScreenToScreenColorExpandFill(ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->SetupForScreenToScreenColorExpandFill)(pScrn, fg, bg, rop, planemask);
-}
-
-static void XAAStateWrapSetupForImageWrite(ScrnInfoPtr pScrn, int rop,
- unsigned int planemask, int transparency_color,
- int bpp, int depth)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->SetupForImageWrite)(pScrn, rop, planemask, transparency_color, bpp,
- depth);
-}
-
-static void XAAStateWrapSetupForScanlineImageWrite(ScrnInfoPtr pScrn, int rop,
- unsigned int planemask,
- int transparency_color,
- int bpp, int depth)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->SetupForScanlineImageWrite)(pScrn, rop, planemask, transparency_color,
- bpp, depth);
-}
-
-static void XAAStateWrapSetupForImageRead(ScrnInfoPtr pScrn, int bpp, int depth)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->SetupForImageRead)(pScrn, bpp, depth);
-}
-
-static void XAAStateWrapScreenToScreenBitBlt(ScrnInfoPtr pScrn, int nbox,
- DDXPointPtr pptSrc, BoxPtr pbox, int xdir,
- int ydir, int alu, unsigned int planmask)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->ScreenToScreenBitBlt)(pScrn, nbox,
- pptSrc, pbox, xdir,
- ydir, alu, planmask);
-}
-
-static void XAAStateWrapWriteBitmap(ScrnInfoPtr pScrn, int x, int y, int w, int h,
- unsigned char *src, int srcwidth, int skipleft,
- int fg, int bg, int rop, unsigned int planemask)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->WriteBitmap)(pScrn, x, y, w, h,
- src, srcwidth, skipleft,
- fg, bg, rop, planemask);
-}
-
-static void XAAStateWrapFillSolidRects(ScrnInfoPtr pScrn, int fg, int rop,
- unsigned int planemask, int nBox, BoxPtr pBox)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->FillSolidRects)(pScrn, fg, rop,
- planemask, nBox, pBox);
-}
-
-static void XAAStateWrapFillMono8x8PatternRects(ScrnInfoPtr pScrn, int fg, int bg,
- int rop, unsigned int planemask, int nBox,
- BoxPtr pBox, int pat0, int pat1,
- int xorg, int yorg)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->FillMono8x8PatternRects)(pScrn, fg, bg,
- rop, planemask, nBox,
- pBox, pat0, pat1,
- xorg, yorg);
-}
-
-static void XAAStateWrapFillColor8x8PatternRects(ScrnInfoPtr pScrn, int rop,
- unsigned int planemask, int nBox,
- BoxPtr pBox, int xorg, int yorg,
- XAACacheInfoPtr pCache)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->FillColor8x8PatternRects)(pScrn, rop,
- planemask, nBox,
- pBox, xorg, yorg,
- pCache);
-}
-
-static void XAAStateWrapFillCacheBltRects(ScrnInfoPtr pScrn, int rop,
- unsigned int planemask, int nBox, BoxPtr pBox,
- int xorg, int yorg, XAACacheInfoPtr pCache)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->FillCacheBltRects)(pScrn, rop,
- planemask, nBox, pBox,
- xorg, yorg, pCache);
-}
-
-static void XAAStateWrapFillColorExpandRects(ScrnInfoPtr pScrn, int fg, int bg, int rop,
- unsigned int planemask, int nBox,
- BoxPtr pBox, int xorg, int yorg,
- PixmapPtr pPix)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->FillColorExpandRects)(pScrn, fg, bg, rop,
- planemask, nBox,
- pBox, xorg, yorg,
- pPix);
-}
-
-static void XAAStateWrapFillCacheExpandRects(ScrnInfoPtr pScrn, int fg, int bg, int rop,
- unsigned int planemask, int nBox,
- BoxPtr pBox, int xorg, int yorg,
- PixmapPtr pPix)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->FillCacheExpandRects)(pScrn, fg, bg, rop,
- planemask, nBox,
- pBox, xorg, yorg,
- pPix);
-}
-
-static void XAAStateWrapFillImageWriteRects(ScrnInfoPtr pScrn, int rop,
- unsigned int planemask, int nBox, BoxPtr pBox,
- int xorg, int yorg, PixmapPtr pPix)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->FillImageWriteRects)(pScrn, rop,
- planemask, nBox, pBox,
- xorg, yorg, pPix);
-}
-
-static void XAAStateWrapFillSolidSpans(ScrnInfoPtr pScrn, int fg, int rop,
- unsigned int planemask, int n, DDXPointPtr points,
- int *widths, int fSorted)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->FillSolidSpans)(pScrn, fg, rop,
- planemask, n, points,
- widths, fSorted);
-}
-
-static void XAAStateWrapFillMono8x8PatternSpans(ScrnInfoPtr pScrn, int fg, int bg,
- int rop, unsigned int planemask, int n,
- DDXPointPtr points, int *widths,
- int fSorted, int pat0, int pat1,
- int xorg, int yorg)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->FillMono8x8PatternSpans)(pScrn, fg, bg,
- rop, planemask, n,
- points, widths,
- fSorted, pat0, pat1,
- xorg, yorg);
-}
-
-static void XAAStateWrapFillColor8x8PatternSpans(ScrnInfoPtr pScrn, int rop,
- unsigned int planemask, int n,
- DDXPointPtr points, int *widths,
- int fSorted, XAACacheInfoPtr pCache,
- int xorg, int yorg)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->FillColor8x8PatternSpans)(pScrn, rop,
- planemask, n,
- points, widths,
- fSorted, pCache,
- xorg, yorg);
-}
-
-static void XAAStateWrapFillCacheBltSpans(ScrnInfoPtr pScrn, int rop,
- unsigned int planemask, int n,
- DDXPointPtr points, int *widths,
- int fSorted, XAACacheInfoPtr pCache,
- int xorg, int yorg)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->FillCacheBltSpans)(pScrn, rop,
- planemask, n,
- points, widths,
- fSorted, pCache,
- xorg, yorg);
-}
-
-static void XAAStateWrapFillColorExpandSpans(ScrnInfoPtr pScrn, int fg, int bg, int rop,
- unsigned int planemask, int n,
- DDXPointPtr points, int *widths, int fSorted,
- int xorg, int yorg, PixmapPtr pPix)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->FillColorExpandSpans)(pScrn, fg, bg, rop,
- planemask, n,
- points, widths, fSorted,
- xorg, yorg, pPix);
-}
-
-static void XAAStateWrapFillCacheExpandSpans(ScrnInfoPtr pScrn, int fg, int bg, int rop,
- unsigned int planemask, int n,
- DDXPointPtr ppt, int *pwidth, int fSorted,
- int xorg, int yorg, PixmapPtr pPix)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->FillCacheExpandSpans)(pScrn, fg, bg, rop,
- planemask, n,
- ppt, pwidth, fSorted,
- xorg, yorg, pPix);
-}
-
-static void XAAStateWrapTEGlyphRenderer(ScrnInfoPtr pScrn, int x, int y, int w, int h,
- int skipleft, int startline,
- unsigned int **glyphs,
- int glyphWidth, int fg, int bg, int rop,
- unsigned planemask)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->TEGlyphRenderer)(pScrn, x, y, w, h,
- skipleft, startline,
- glyphs,
- glyphWidth, fg, bg, rop,
- planemask);
-}
-
-static void XAAStateWrapNonTEGlyphRenderer(ScrnInfoPtr pScrn, int x, int y, int n,
- NonTEGlyphPtr glyphs, BoxPtr pbox,
- int fg, int rop, unsigned int planemask)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->NonTEGlyphRenderer)(pScrn, x, y, n,
- glyphs, pbox,
- fg, rop, planemask);
-}
-
-static void XAAStateWrapWritePixmap(ScrnInfoPtr pScrn, int x, int y, int w, int h,
- unsigned char *src, int srcwidth, int rop,
- unsigned int planemask, int transparency_color,
- int bpp, int depth)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->WritePixmap)(pScrn, x, y, w, h,
- src, srcwidth, rop,
- planemask, transparency_color,
- bpp, depth);
-}
-
-static void XAAStateWrapReadPixmap(ScrnInfoPtr pScrn, int x, int y, int w, int h,
- unsigned char *dst, int dstwidth, int bpp, int depth)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->ReadPixmap)(pScrn, x, y, w, h,
- dst, dstwidth, bpp, depth);
-}
-
-static RegionPtr XAAStateWrapCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
- GC *pGC, int srcx, int srcy, int width, int height,
- int dstx, int dsty)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- return (*pStatePriv->CopyArea)(pSrcDrawable, pDstDrawable,
- pGC, srcx, srcy, width, height,
- dstx, dsty);
-}
-
-static RegionPtr XAAStateWrapCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
- int srcx, int srcy, int width, int height,
- int dstx, int dsty, unsigned long bitPlane)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- return (*pStatePriv->CopyPlane)(pSrc, pDst, pGC,
- srcx, srcy, width, height,
- dstx, dsty, bitPlane);
-}
-
-static void XAAStateWrapPushPixelsSolid(GCPtr pGC, PixmapPtr pBitMap,
- DrawablePtr pDrawable, int dx, int dy, int xOrg,
- int yOrg)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->PushPixelsSolid)(pGC, pBitMap,
- pDrawable, dx, dy, xOrg,
- yOrg);
-}
-
-static void XAAStateWrapPolyFillRectSolid(DrawablePtr pDraw, GCPtr pGC, int nrectFill,
- xRectangle *prectInit)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->PolyFillRectSolid)(pDraw, pGC, nrectFill,
- prectInit);
-}
-
-static void XAAStateWrapPolyFillRectStippled(DrawablePtr pDraw, GCPtr pGC, int nrectFill,
- xRectangle *prectInit)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->PolyFillRectStippled)(pDraw, pGC, nrectFill,
- prectInit);
-}
-
-static void XAAStateWrapPolyFillRectOpaqueStippled(DrawablePtr pDraw, GCPtr pGC,
- int nrectFill, xRectangle *prectInit)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->PolyFillRectOpaqueStippled)(pDraw, pGC,
- nrectFill, prectInit);
-}
-
-static void XAAStateWrapPolyFillRectTiled(DrawablePtr pDraw, GCPtr pGC, int nrectFill,
- xRectangle *prectInit)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->PolyFillRectTiled)(pDraw, pGC, nrectFill,
- prectInit);
-}
-
-static void XAAStateWrapFillSpansSolid(DrawablePtr pDraw, GCPtr pGC, int nInit,
- DDXPointPtr ppt, int *pwidth, int fSorted)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->FillSpansSolid)(pDraw, pGC, nInit,
- ppt, pwidth, fSorted);
-}
-
-static void XAAStateWrapFillSpansStippled(DrawablePtr pDraw, GCPtr pGC, int nInit,
- DDXPointPtr ppt, int *pwidth, int fSorted)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->FillSpansStippled)(pDraw, pGC, nInit,
- ppt, pwidth, fSorted);
-}
-
-static void XAAStateWrapFillSpansOpaqueStippled(DrawablePtr pDraw, GCPtr pGC, int nInit,
- DDXPointPtr ppt, int *pwidth, int fSorted)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->FillSpansOpaqueStippled)(pDraw, pGC, nInit,
- ppt, pwidth, fSorted);
-}
-
-static void XAAStateWrapFillSpansTiled(DrawablePtr pDraw, GCPtr pGC, int nInit,
- DDXPointPtr ppt, int *pwidth, int fSorted)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->FillSpansTiled)(pDraw, pGC, nInit,
- ppt, pwidth, fSorted);
-}
-
-static int XAAStateWrapPolyText8TE(DrawablePtr pDraw, GCPtr pGC, int x, int y, int count,
- char *chars)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- return (*pStatePriv->PolyText8TE)(pDraw, pGC, x, y, count,
- chars);
-}
-
-static int XAAStateWrapPolyText16TE(DrawablePtr pDraw, GCPtr pGC, int x, int y, int count,
- unsigned short *chars)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- return (*pStatePriv->PolyText16TE)(pDraw, pGC, x, y, count,
- chars);
-}
-
-static void XAAStateWrapImageText8TE(DrawablePtr pDraw, GCPtr pGC, int x, int y,
- int count, char *chars)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ImageText8TE)(pDraw, pGC, x, y,
- count, chars);
-}
-
-static void XAAStateWrapImageText16TE(DrawablePtr pDraw, GCPtr pGC, int x, int y,
- int count, unsigned short *chars)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ImageText16TE)(pDraw, pGC, x, y,
- count, chars);
-}
-
-static void XAAStateWrapImageGlyphBltTE(DrawablePtr pDrawable, GCPtr pGC, int xInit,
- int yInit, unsigned int nglyph, CharInfoPtr *ppci,
- pointer pglyphBase)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ImageGlyphBltTE)(pDrawable, pGC, xInit,
- yInit, nglyph, ppci,
- pglyphBase);
-}
-
-static void XAAStateWrapPolyGlyphBltTE(DrawablePtr pDrawable, GCPtr pGC, int xInit,
- int yInit, unsigned int nglyph, CharInfoPtr *ppci,
- pointer pglyphBase)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->PolyGlyphBltTE)(pDrawable, pGC, xInit,
- yInit, nglyph, ppci,
- pglyphBase);
-}
-
-static int XAAStateWrapPolyText8NonTE(DrawablePtr pDraw, GCPtr pGC, int x, int y,
- int count, char *chars)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- return (*pStatePriv->PolyText8NonTE)(pDraw, pGC, x, y,
- count, chars);
-}
-
-static int XAAStateWrapPolyText16NonTE(DrawablePtr pDraw, GCPtr pGC, int x, int y,
- int count, unsigned short *chars)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- return (*pStatePriv->PolyText16NonTE)(pDraw, pGC, x, y,
- count, chars);
-}
-
-static void XAAStateWrapImageText8NonTE(DrawablePtr pDraw, GCPtr pGC, int x, int y,
- int count, char *chars)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ImageText8NonTE)(pDraw, pGC, x, y,
- count, chars);
-}
-
-static void XAAStateWrapImageText16NonTE(DrawablePtr pDraw, GCPtr pGC, int x, int y,
- int count, unsigned short *chars)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ImageText16NonTE)(pDraw, pGC, x, y,
- count, chars);
-}
-
-static void XAAStateWrapImageGlyphBltNonTE(DrawablePtr pDrawable, GCPtr pGC, int xInit,
- int yInit, unsigned int nglyph,
- CharInfoPtr *ppci, pointer pglyphBase)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ImageGlyphBltNonTE)(pDrawable, pGC, xInit,
- yInit, nglyph,
- ppci, pglyphBase);
-}
-
-static void XAAStateWrapPolyGlyphBltNonTE(DrawablePtr pDrawable, GCPtr pGC, int xInit,
- int yInit, unsigned int nglyph,
- CharInfoPtr *ppci, pointer pglyphBase)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->PolyGlyphBltNonTE)(pDrawable, pGC, xInit,
- yInit, nglyph,
- ppci, pglyphBase);
-}
-
-static void XAAStateWrapPolyRectangleThinSolid(DrawablePtr pDrawable,GCPtr pGC,
- int nRectsInit, xRectangle *pRectsInit)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->PolyRectangleThinSolid)(pDrawable, pGC,
- nRectsInit, pRectsInit);
-}
-
-static void XAAStateWrapPolylinesWideSolid(DrawablePtr pDrawable, GCPtr pGC, int mode,
- int npt, DDXPointPtr pPts)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->PolylinesWideSolid)(pDrawable, pGC, mode,
- npt, pPts);
-}
-
-static void XAAStateWrapPolylinesThinSolid(DrawablePtr pDrawable, GCPtr pGC, int mode,
- int npt, DDXPointPtr pPts)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->PolylinesThinSolid)(pDrawable, pGC, mode,
- npt, pPts);
-}
-
-static void XAAStateWrapPolySegmentThinSolid(DrawablePtr pDrawable, GCPtr pGC, int nseg,
- xSegment *pSeg)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->PolySegmentThinSolid)(pDrawable, pGC, nseg,
- pSeg);
-}
-
-static void XAAStateWrapPolylinesThinDashed(DrawablePtr pDrawable, GCPtr pGC, int mode,
- int npt, DDXPointPtr pPts)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->PolylinesThinDashed)(pDrawable, pGC, mode,
- npt, pPts);
-}
-
-static void XAAStateWrapPolySegmentThinDashed(DrawablePtr pDrawable, GCPtr pGC, int nseg,
- xSegment *pSeg)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->PolySegmentThinDashed)(pDrawable, pGC, nseg,
- pSeg);
-}
-
-static void XAAStateWrapFillPolygonSolid(DrawablePtr pDrawable, GCPtr pGC, int shape,
- int mode, int count, DDXPointPtr ptsIn)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->FillPolygonSolid)(pDrawable, pGC, shape,
- mode, count, ptsIn);
-}
-
-static void XAAStateWrapFillPolygonStippled(DrawablePtr pDrawable, GCPtr pGC, int shape,
- int mode, int count, DDXPointPtr ptsIn)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->FillPolygonStippled)(pDrawable, pGC, shape,
- mode, count, ptsIn);
-}
-
-static void XAAStateWrapFillPolygonOpaqueStippled(DrawablePtr pDrawable, GCPtr pGC,
- int shape, int mode, int count,
- DDXPointPtr ptsIn)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->FillPolygonOpaqueStippled)(pDrawable, pGC,
- shape, mode, count,
- ptsIn);
-}
-
-static void XAAStateWrapFillPolygonTiled(DrawablePtr pDrawable, GCPtr pGC, int shape,
- int mode, int count, DDXPointPtr ptsIn)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->FillPolygonTiled)(pDrawable, pGC, shape,
- mode, count, ptsIn);
-}
-
-static void XAAStateWrapPolyFillArcSolid(DrawablePtr pDraw, GCPtr pGC, int narcs,
- xArc *parcs)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->PolyFillArcSolid)(pDraw, pGC, narcs,
- parcs);
-}
-
-static void XAAStateWrapPutImage(DrawablePtr pDraw, GCPtr pGC, int depth, int x, int y,
- int w, int h, int leftPad, int format, char *pImage)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->PutImage)(pDraw, pGC, depth, x, y,
- w, h, leftPad, format, pImage);
-}
-
-static void XAAStateWrapValidateFillSpans(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ValidateFillSpans)(pGC, changes,
- pDraw);
-}
-
-static void XAAStateWrapValidateSetSpans(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ValidateSetSpans)(pGC, changes,
- pDraw);
-}
-
-static void XAAStateWrapValidatePutImage(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ValidatePutImage)(pGC, changes,
- pDraw);
-}
-
-static void XAAStateWrapValidateCopyArea(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ValidateCopyArea)(pGC, changes,
- pDraw);
-}
-
-static void XAAStateWrapValidateCopyPlane(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ValidateCopyPlane)(pGC, changes,
- pDraw);
-}
-
-static void XAAStateWrapValidatePolyPoint(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ValidatePolyPoint)(pGC, changes,
- pDraw);
-}
-
-static void XAAStateWrapValidatePolylines(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ValidatePolylines)(pGC, changes,
- pDraw);
-}
-
-static void XAAStateWrapValidatePolySegment(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ValidatePolySegment)(pGC, changes,
- pDraw);
-}
-
-static void XAAStateWrapValidatePolyRectangle(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ValidatePolyRectangle)(pGC, changes,
- pDraw);
-}
-
-static void XAAStateWrapValidatePolyArc(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ValidatePolyArc)(pGC, changes,
- pDraw);
-}
-
-static void XAAStateWrapValidateFillPolygon(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ValidateFillPolygon)(pGC, changes,
- pDraw);
-}
-
-static void XAAStateWrapValidatePolyFillRect(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ValidatePolyFillRect)(pGC, changes,
- pDraw);
-}
-
-static void XAAStateWrapValidatePolyFillArc(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ValidatePolyFillArc)(pGC, changes,
- pDraw);
-}
-
-static void XAAStateWrapValidatePolyText8(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ValidatePolyText8)(pGC, changes,
- pDraw);
-}
-
-static void XAAStateWrapValidatePolyText16(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ValidatePolyText16)(pGC, changes,
- pDraw);
-}
-
-static void XAAStateWrapValidateImageText8(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ValidateImageText8)(pGC, changes,
- pDraw);
-}
-
-static void XAAStateWrapValidateImageText16(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ValidateImageText16)(pGC, changes,
- pDraw);
-}
-
-static void XAAStateWrapValidatePolyGlyphBlt(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ValidatePolyGlyphBlt)(pGC, changes,
- pDraw);
-}
-
-static void XAAStateWrapValidateImageGlyphBlt(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
- (*pStatePriv->ValidateImageGlyphBlt)(pGC, changes,
- pDraw);
-}
-
-static void XAAStateWrapValidatePushPixels(GCPtr pGC, unsigned long changes,
- DrawablePtr pDraw)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ValidatePushPixels)(pGC, changes,
- pDraw);
-}
-
-static void XAAStateWrapComputeDash(GCPtr pGC)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ComputeDash)(pGC);
-}
-
-static void XAAStateWrapInitPixmapCache(ScreenPtr pScreen, RegionPtr areas,
- pointer data)
-{
- GET_STATEPRIV_SCREEN(pScreen);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->InitPixmapCache)(pScreen, areas,
- data);
-}
-
-static void XAAStateWrapClosePixmapCache(ScreenPtr pScreen)
-{
- GET_STATEPRIV_SCREEN(pScreen);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->ClosePixmapCache)(pScreen);
-}
-
-static int XAAStateWrapStippledFillChooser(GCPtr pGC)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- return (*pStatePriv->StippledFillChooser)(pGC);
-}
-
-static int XAAStateWrapOpaqueStippledFillChooser(GCPtr pGC)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- return (*pStatePriv->OpaqueStippledFillChooser)(pGC);
-}
-
-static int XAAStateWrapTiledFillChooser(GCPtr pGC)
-{
- GET_STATEPRIV_GC(pGC);
- STATE_CHECK_SP(pStatePriv);
-
- return (*pStatePriv->TiledFillChooser)(pGC);
-}
-
-static XAACacheInfoPtr XAAStateWrapCacheTile(ScrnInfoPtr pScrn, PixmapPtr pPix)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- return (*pStatePriv->CacheTile)(pScrn, pPix);
-}
-
-static XAACacheInfoPtr XAAStateWrapCacheStipple(ScrnInfoPtr pScrn, PixmapPtr pPix, int fg,
- int bg)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- return (*pStatePriv->CacheStipple)(pScrn, pPix, fg,
- bg);
-}
-
-static XAACacheInfoPtr XAAStateWrapCacheMonoStipple(ScrnInfoPtr pScrn, PixmapPtr pPix)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- return (*pStatePriv->CacheMonoStipple)(pScrn, pPix);
-}
-
-static XAACacheInfoPtr XAAStateWrapCacheMono8x8Pattern(ScrnInfoPtr pScrn, int pat0,
- int pat1)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- return (*pStatePriv->CacheMono8x8Pattern)(pScrn, pat0,
- pat1);
-}
-
-static XAACacheInfoPtr XAAStateWrapCacheColor8x8Pattern(ScrnInfoPtr pScrn, PixmapPtr pPix,
- int fg, int bg)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- return (*pStatePriv->CacheColor8x8Pattern)(pScrn, pPix,
- fg, bg);
-}
-
-static void XAAStateWrapWriteBitmapToCache(ScrnInfoPtr pScrn, int x, int y, int w, int h,
- unsigned char *src, int srcwidth, int fg,
- int bg)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->WriteBitmapToCache)(pScrn, x, y, w, h,
- src, srcwidth, fg,
- bg);
-}
-
-static void XAAStateWrapWritePixmapToCache(ScrnInfoPtr pScrn, int x, int y, int w, int h,
- unsigned char *src, int srcwidth, int bpp,
- int depth)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->WritePixmapToCache)(pScrn, x, y, w, h,
- src, srcwidth, bpp,
- depth);
-}
-
-static void XAAStateWrapWriteMono8x8PatternToCache(ScrnInfoPtr pScrn,
- XAACacheInfoPtr pCache)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->WriteMono8x8PatternToCache)(pScrn,
- pCache);
-}
-
-static void XAAStateWrapWriteColor8x8PatternToCache(ScrnInfoPtr pScrn, PixmapPtr pPix,
- XAACacheInfoPtr pCache)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- (*pStatePriv->WriteColor8x8PatternToCache)(pScrn, pPix,
- pCache);
-}
-
-static void XAAStateWrapGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h,
- unsigned int format,unsigned long planeMask,
- char *pdstLine)
-{
- GET_STATEPRIV_SCREEN(pDrawable->pScreen);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->GetImage)(pDrawable, sx, sy, w, h,
- format, planeMask,
- pdstLine);
-}
-
-static void XAAStateWrapGetSpans(DrawablePtr pDrawable, int wMax, DDXPointPtr ppt,
- int *pwidth, int nspans, char *pdstStart)
-{
- GET_STATEPRIV_SCREEN(pDrawable->pScreen);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->GetSpans)(pDrawable, wMax, ppt,
- pwidth, nspans, pdstStart);
-}
-
-static void XAAStateWrapCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg,
- RegionPtr prgnSrc)
-{
- GET_STATEPRIV_SCREEN(pWindow->drawable.pScreen);
- STATE_CHECK_SP(pStatePriv);
-
- (*pStatePriv->CopyWindow)(pWindow, ptOldOrg,
- prgnSrc);
-}
-
-static Bool XAAStateWrapSetupForCPUToScreenAlphaTexture2(ScrnInfoPtr pScrn,
- int op, CARD16 red,
- CARD16 green,
- CARD16 blue,
- CARD16 alpha,
- CARD32 srcFormat,
- CARD32 dstFormat,
- CARD8 *alphaPtr,
- int alphaPitch,
- int width, int height,
- int flags)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- return (*pStatePriv->SetupForCPUToScreenAlphaTexture2)(pScrn, op, red, green,
- blue, alpha, srcFormat,
- dstFormat, alphaPtr,
- alphaPitch, width,
- height, flags);
-}
-
-static Bool XAAStateWrapSetupForCPUToScreenTexture2(ScrnInfoPtr pScrn, int op,
- CARD32 srcFormat,
- CARD32 dstFormat,
- CARD8 *texPtr, int texPitch,
- int width, int height,
- int flags)
-{
- GET_STATEPRIV_PSCRN(pScrn);
- STATE_CHECK_PSCRN(pScrn);
-
- return (*pStatePriv->SetupForCPUToScreenTexture2)(pScrn, op, srcFormat,
- dstFormat, texPtr, texPitch,
- width, height, flags);
-}
-
-/* Setup Function */
-Bool
-XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- XAAStateWrapPtr pStatePriv;
- int i = 0;
-
- if (!dixRegisterPrivateKey(&XAAStateKeyRec, PRIVATE_SCREEN, 0)) return FALSE;
- if(!(pStatePriv = malloc(sizeof(XAAStateWrapRec)))) return FALSE;
- dixSetPrivate(&pScreen->devPrivates, XAAStateKey, pStatePriv);
- pStatePriv->RestoreAccelState = infoRec->RestoreAccelState;
- pStatePriv->pScrn = pScrn;
-
- /* Initialize the last screen to -1 so whenever an accel function
- * is called the proper state is setup
- */
- while(i < pScrn->numEntities) {
- xf86SetLastScrnFlag(pScrn->entityList[i], -1);
- i++;
- }
-/* Do the wrapping */
- XAA_STATE_WRAP(Sync);
- XAA_STATE_WRAP(SetupForScreenToScreenCopy);
- XAA_STATE_WRAP(SetupForSolidFill);
- XAA_STATE_WRAP(SetupForSolidLine);
- XAA_STATE_WRAP(SetupForDashedLine);
- XAA_STATE_WRAP(SetClippingRectangle);
- XAA_STATE_WRAP(DisableClipping);
- XAA_STATE_WRAP(SetupForMono8x8PatternFill);
- XAA_STATE_WRAP(SetupForColor8x8PatternFill);
- XAA_STATE_WRAP(SetupForCPUToScreenColorExpandFill);
- XAA_STATE_WRAP(SetupForScanlineCPUToScreenColorExpandFill);
- XAA_STATE_WRAP(SetupForScreenToScreenColorExpandFill);
- XAA_STATE_WRAP(SetupForImageWrite);
- XAA_STATE_WRAP(SetupForScanlineImageWrite);
- XAA_STATE_WRAP(SetupForImageRead);
- XAA_STATE_WRAP(ScreenToScreenBitBlt);
- XAA_STATE_WRAP(WriteBitmap);
- XAA_STATE_WRAP(FillSolidRects);
- XAA_STATE_WRAP(FillMono8x8PatternRects);
- XAA_STATE_WRAP(FillColor8x8PatternRects);
- XAA_STATE_WRAP(FillCacheBltRects);
- XAA_STATE_WRAP(FillColorExpandRects);
- XAA_STATE_WRAP(FillCacheExpandRects);
- XAA_STATE_WRAP(FillImageWriteRects);
- XAA_STATE_WRAP(FillSolidSpans);
- XAA_STATE_WRAP(FillMono8x8PatternSpans);
- XAA_STATE_WRAP(FillColor8x8PatternSpans);
- XAA_STATE_WRAP(FillCacheBltSpans);
- XAA_STATE_WRAP(FillColorExpandSpans);
- XAA_STATE_WRAP(FillCacheExpandSpans);
- XAA_STATE_WRAP(TEGlyphRenderer);
- XAA_STATE_WRAP(NonTEGlyphRenderer);
- XAA_STATE_WRAP(WritePixmap);
- XAA_STATE_WRAP(ReadPixmap);
- XAA_STATE_WRAP(CopyArea);
- XAA_STATE_WRAP(CopyPlane);
- XAA_STATE_WRAP(PushPixelsSolid);
- XAA_STATE_WRAP(PolyFillRectSolid);
- XAA_STATE_WRAP(PolyFillRectStippled);
- XAA_STATE_WRAP(PolyFillRectOpaqueStippled);
- XAA_STATE_WRAP(PolyFillRectTiled);
- XAA_STATE_WRAP(FillSpansSolid);
- XAA_STATE_WRAP(FillSpansStippled);
- XAA_STATE_WRAP(FillSpansOpaqueStippled);
- XAA_STATE_WRAP(FillSpansTiled);
- XAA_STATE_WRAP(PolyText8TE);
- XAA_STATE_WRAP(PolyText16TE);
- XAA_STATE_WRAP(ImageText8TE);
- XAA_STATE_WRAP(ImageText16TE);
- XAA_STATE_WRAP(ImageGlyphBltTE);
- XAA_STATE_WRAP(PolyGlyphBltTE);
- XAA_STATE_WRAP(PolyText8NonTE);
- XAA_STATE_WRAP(PolyText16NonTE);
- XAA_STATE_WRAP(ImageText8NonTE);
- XAA_STATE_WRAP(ImageText16NonTE);
- XAA_STATE_WRAP(ImageGlyphBltNonTE);
- XAA_STATE_WRAP(PolyGlyphBltNonTE);
- XAA_STATE_WRAP(PolyRectangleThinSolid);
- XAA_STATE_WRAP(PolylinesWideSolid);
- XAA_STATE_WRAP(PolylinesThinSolid);
- XAA_STATE_WRAP(PolySegmentThinSolid);
- XAA_STATE_WRAP(PolylinesThinDashed);
- XAA_STATE_WRAP(PolySegmentThinDashed);
- XAA_STATE_WRAP(FillPolygonSolid);
- XAA_STATE_WRAP(FillPolygonStippled);
- XAA_STATE_WRAP(FillPolygonOpaqueStippled);
- XAA_STATE_WRAP(FillPolygonTiled);
- XAA_STATE_WRAP(PolyFillArcSolid);
- XAA_STATE_WRAP(PutImage);
- XAA_STATE_WRAP(ValidateFillSpans);
- XAA_STATE_WRAP(ValidateSetSpans);
- XAA_STATE_WRAP(ValidatePutImage);
- XAA_STATE_WRAP(ValidateCopyArea);
- XAA_STATE_WRAP(ValidateCopyPlane);
- XAA_STATE_WRAP(ValidatePolyPoint);
- XAA_STATE_WRAP(ValidatePolylines);
- XAA_STATE_WRAP(ValidatePolySegment);
- XAA_STATE_WRAP(ValidatePolyRectangle);
- XAA_STATE_WRAP(ValidatePolyArc);
- XAA_STATE_WRAP(ValidateFillPolygon);
- XAA_STATE_WRAP(ValidatePolyFillRect);
- XAA_STATE_WRAP(ValidatePolyFillArc);
- XAA_STATE_WRAP(ValidatePolyText8);
- XAA_STATE_WRAP(ValidatePolyText16);
- XAA_STATE_WRAP(ValidateImageText8);
- XAA_STATE_WRAP(ValidateImageText16);
- XAA_STATE_WRAP(ValidatePolyGlyphBlt);
- XAA_STATE_WRAP(ValidateImageGlyphBlt);
- XAA_STATE_WRAP(ValidatePushPixels);
- XAA_STATE_WRAP(ComputeDash);
- XAA_STATE_WRAP(InitPixmapCache);
- XAA_STATE_WRAP(ClosePixmapCache);
- XAA_STATE_WRAP(StippledFillChooser);
- XAA_STATE_WRAP(OpaqueStippledFillChooser);
- XAA_STATE_WRAP(TiledFillChooser);
- XAA_STATE_WRAP(CacheTile);
- XAA_STATE_WRAP(CacheStipple);
- XAA_STATE_WRAP(CacheMonoStipple);
- XAA_STATE_WRAP(CacheMono8x8Pattern);
- XAA_STATE_WRAP(CacheColor8x8Pattern);
- XAA_STATE_WRAP(WriteBitmapToCache);
- XAA_STATE_WRAP(WritePixmapToCache);
- XAA_STATE_WRAP(WriteMono8x8PatternToCache);
- XAA_STATE_WRAP(WriteColor8x8PatternToCache);
- XAA_STATE_WRAP(GetImage);
- XAA_STATE_WRAP(GetSpans);
- XAA_STATE_WRAP(CopyWindow);
- XAA_STATE_WRAP(SetupForCPUToScreenAlphaTexture2);
- XAA_STATE_WRAP(SetupForCPUToScreenTexture2);
- return TRUE;
-}
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "xf86str.h"
+#include "mi.h"
+#include "miline.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "xaawrap.h"
+#include "servermd.h"
+
+#define XAA_STATE_WRAP(func) do {\
+if(infoRec->func) { \
+ pStatePriv->func = infoRec->func;\
+ infoRec->func = XAAStateWrap##func;\
+}} while(0)
+
+/* Wrap all XAA functions and allocate our private structure.
+ */
+
+typedef struct _XAAStateWrapRec {
+ ScrnInfoPtr pScrn;
+ void (*RestoreAccelState) (ScrnInfoPtr pScrn);
+ void (*Sync) (ScrnInfoPtr pScrn);
+ void (*SetupForScreenToScreenCopy) (ScrnInfoPtr pScrn, int xdir, int ydir,
+ int rop, unsigned int planemask,
+ int trans_color);
+ void (*SetupForSolidFill) (ScrnInfoPtr pScrn, int color, int rop,
+ unsigned int planemask);
+ void (*SetupForSolidLine) (ScrnInfoPtr pScrn, int color, int rop,
+ unsigned int planemask);
+ void (*SetupForDashedLine) (ScrnInfoPtr pScrn, int fg, int bg, int rop,
+ unsigned int planemask, int length,
+ unsigned char *pattern);
+ void (*SetClippingRectangle) (ScrnInfoPtr pScrn, int left, int top,
+ int right, int bottom);
+ void (*DisableClipping) (ScrnInfoPtr pScrn);
+ void (*SetupForMono8x8PatternFill) (ScrnInfoPtr pScrn, int patx, int paty,
+ int fg, int bg, int rop,
+ unsigned int planemask);
+ void (*SetupForColor8x8PatternFill) (ScrnInfoPtr pScrn, int patx, int paty,
+ int rop, unsigned int planemask,
+ int transparency_color);
+ void (*SetupForCPUToScreenColorExpandFill) (ScrnInfoPtr pScrn, int fg,
+ int bg, int rop,
+ unsigned int planemask);
+ void (*SetupForScanlineCPUToScreenColorExpandFill) (ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask);
+ void (*SetupForScreenToScreenColorExpandFill) (ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask);
+ void (*SetupForImageWrite) (ScrnInfoPtr pScrn, int rop,
+ unsigned int planemask, int transparency_color,
+ int bpp, int depth);
+ void (*SetupForScanlineImageWrite) (ScrnInfoPtr pScrn, int rop,
+ unsigned int planemask,
+ int transparency_color,
+ int bpp, int depth);
+ void (*SetupForImageRead) (ScrnInfoPtr pScrn, int bpp, int depth);
+ void (*ScreenToScreenBitBlt) (ScrnInfoPtr pScrn, int nbox,
+ DDXPointPtr pptSrc, BoxPtr pbox, int xdir,
+ int ydir, int alu, unsigned int planmask);
+ void (*WriteBitmap) (ScrnInfoPtr pScrn, int x, int y, int w, int h,
+ unsigned char *src, int srcwidth, int skipleft,
+ int fg, int bg, int rop, unsigned int planemask);
+ void (*FillSolidRects) (ScrnInfoPtr pScrn, int fg, int rop,
+ unsigned int planemask, int nBox, BoxPtr pBox);
+ void (*FillMono8x8PatternRects) (ScrnInfoPtr pScrn, int fg, int bg, int rop,
+ unsigned int planemask, int nBox,
+ BoxPtr pBox, int pat0, int pat1,
+ int xorg, int yorg);
+ void (*FillColor8x8PatternRects) (ScrnInfoPtr pScrn, int rop,
+ unsigned int planemask, int nBox,
+ BoxPtr pBox, int xorg, int yorg,
+ XAACacheInfoPtr pCache);
+ void (*FillCacheBltRects) (ScrnInfoPtr pScrn, int rop,
+ unsigned int planemask, int nBox, BoxPtr pBox,
+ int xorg, int yorg, XAACacheInfoPtr pCache);
+ void (*FillColorExpandRects) (ScrnInfoPtr pScrn, int fg, int bg, int rop,
+ unsigned int planemask, int nBox,
+ BoxPtr pBox, int xorg, int yorg,
+ PixmapPtr pPix);
+ void (*FillCacheExpandRects) (ScrnInfoPtr pScrn, int fg, int bg, int rop,
+ unsigned int planemask, int nBox, BoxPtr pBox,
+ int xorg, int yorg, PixmapPtr pPix);
+ void (*FillImageWriteRects) (ScrnInfoPtr pScrn, int rop,
+ unsigned int planemask, int nBox, BoxPtr pBox,
+ int xorg, int yorg, PixmapPtr pPix);
+ void (*FillSolidSpans) (ScrnInfoPtr pScrn, int fg, int rop,
+ unsigned int planemask, int n, DDXPointPtr points,
+ int *widths, int fSorted);
+ void (*FillMono8x8PatternSpans) (ScrnInfoPtr pScrn, int fg, int bg, int rop,
+ unsigned int planemask, int n,
+ DDXPointPtr points, int *widths,
+ int fSorted, int pat0, int pat1,
+ int xorg, int yorg);
+ void (*FillColor8x8PatternSpans) (ScrnInfoPtr pScrn, int rop,
+ unsigned int planemask, int n,
+ DDXPointPtr points, int *widths,
+ int fSorted, XAACacheInfoPtr pCache,
+ int xorg, int yorg);
+ void (*FillCacheBltSpans) (ScrnInfoPtr pScrn, int rop,
+ unsigned int planemask, int n,
+ DDXPointPtr points, int *widths, int fSorted,
+ XAACacheInfoPtr pCache, int xorg, int yorg);
+ void (*FillColorExpandSpans) (ScrnInfoPtr pScrn, int fg, int bg, int rop,
+ unsigned int planemask, int n,
+ DDXPointPtr points, int *widths, int fSorted,
+ int xorg, int yorg, PixmapPtr pPix);
+ void (*FillCacheExpandSpans) (ScrnInfoPtr pScrn, int fg, int bg, int rop,
+ unsigned int planemask, int n,
+ DDXPointPtr ppt, int *pwidth, int fSorted,
+ int xorg, int yorg, PixmapPtr pPix);
+ void (*TEGlyphRenderer) (ScrnInfoPtr pScrn, int x, int y, int w, int h,
+ int skipleft, int startline, unsigned int **glyphs,
+ int glyphWidth, int fg, int bg, int rop,
+ unsigned planemask);
+ void (*NonTEGlyphRenderer) (ScrnInfoPtr pScrn, int x, int y, int n,
+ NonTEGlyphPtr glyphs, BoxPtr pbox, int fg,
+ int rop, unsigned int planemask);
+ void (*WritePixmap) (ScrnInfoPtr pScrn, int x, int y, int w, int h,
+ unsigned char *src, int srcwidth, int rop,
+ unsigned int planemask, int transparency_color,
+ int bpp, int depth);
+ void (*ReadPixmap) (ScrnInfoPtr pScrn, int x, int y, int w, int h,
+ unsigned char *dst, int dstwidth, int bpp, int depth);
+ RegionPtr (*CopyArea) (DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
+ GC * pGC, int srcx, int srcy, int width, int height,
+ int dstx, int dsty);
+ RegionPtr (*CopyPlane) (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int width, int height, int dstx,
+ int dsty, unsigned long bitPlane);
+ void (*PushPixelsSolid) (GCPtr pGC, PixmapPtr pBitMap,
+ DrawablePtr pDrawable, int dx, int dy, int xOrg,
+ int yOrg);
+ void (*PolyFillRectSolid) (DrawablePtr pDraw, GCPtr pGC, int nrectFill,
+ xRectangle *prectInit);
+ void (*PolyFillRectStippled) (DrawablePtr pDraw, GCPtr pGC, int nrectFill,
+ xRectangle *prectInit);
+ void (*PolyFillRectOpaqueStippled) (DrawablePtr pDraw, GCPtr pGC,
+ int nrectFill, xRectangle *prectInit);
+ void (*PolyFillRectTiled) (DrawablePtr pDraw, GCPtr pGC, int nrectFill,
+ xRectangle *prectInit);
+ void (*FillSpansSolid) (DrawablePtr pDraw, GCPtr pGC, int nInit,
+ DDXPointPtr ppt, int *pwidth, int fSorted);
+ void (*FillSpansStippled) (DrawablePtr pDraw, GCPtr pGC, int nInit,
+ DDXPointPtr ppt, int *pwidth, int fSorted);
+ void (*FillSpansOpaqueStippled) (DrawablePtr pDraw, GCPtr pGC, int nInit,
+ DDXPointPtr ppt, int *pwidth, int fSorted);
+ void (*FillSpansTiled) (DrawablePtr pDraw, GCPtr pGC, int nInit,
+ DDXPointPtr ppt, int *pwidth, int fSorted);
+ int (*PolyText8TE) (DrawablePtr pDraw, GCPtr pGC, int x, int y, int count,
+ char *chars);
+ int (*PolyText16TE) (DrawablePtr pDraw, GCPtr pGC, int x, int y, int count,
+ unsigned short *chars);
+ void (*ImageText8TE) (DrawablePtr pDraw, GCPtr pGC, int x, int y, int count,
+ char *chars);
+ void (*ImageText16TE) (DrawablePtr pDraw, GCPtr pGC, int x, int y,
+ int count, unsigned short *chars);
+ void (*ImageGlyphBltTE) (DrawablePtr pDrawable, GCPtr pGC, int xInit,
+ int yInit, unsigned int nglyph, CharInfoPtr * ppci,
+ pointer pglyphBase);
+ void (*PolyGlyphBltTE) (DrawablePtr pDrawable, GCPtr pGC, int xInit,
+ int yInit, unsigned int nglyph, CharInfoPtr * ppci,
+ pointer pglyphBase);
+ int (*PolyText8NonTE) (DrawablePtr pDraw, GCPtr pGC, int x, int y,
+ int count, char *chars);
+ int (*PolyText16NonTE) (DrawablePtr pDraw, GCPtr pGC, int x, int y,
+ int count, unsigned short *chars);
+ void (*ImageText8NonTE) (DrawablePtr pDraw, GCPtr pGC, int x, int y,
+ int count, char *chars);
+ void (*ImageText16NonTE) (DrawablePtr pDraw, GCPtr pGC, int x, int y,
+ int count, unsigned short *chars);
+ void (*ImageGlyphBltNonTE) (DrawablePtr pDrawable, GCPtr pGC, int xInit,
+ int yInit, unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase);
+ void (*PolyGlyphBltNonTE) (DrawablePtr pDrawable, GCPtr pGC, int xInit,
+ int yInit, unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase);
+ void (*PolyRectangleThinSolid) (DrawablePtr pDrawable, GCPtr pGC,
+ int nRectsInit, xRectangle *pRectsInit);
+ void (*PolylinesWideSolid) (DrawablePtr pDrawable, GCPtr pGC, int mode,
+ int npt, DDXPointPtr pPts);
+ void (*PolylinesThinSolid) (DrawablePtr pDrawable, GCPtr pGC, int mode,
+ int npt, DDXPointPtr pPts);
+ void (*PolySegmentThinSolid) (DrawablePtr pDrawable, GCPtr pGC, int nseg,
+ xSegment * pSeg);
+ void (*PolylinesThinDashed) (DrawablePtr pDrawable, GCPtr pGC, int mode,
+ int npt, DDXPointPtr pPts);
+ void (*PolySegmentThinDashed) (DrawablePtr pDrawable, GCPtr pGC, int nseg,
+ xSegment * pSeg);
+ void (*FillPolygonSolid) (DrawablePtr pDrawable, GCPtr pGC, int shape,
+ int mode, int count, DDXPointPtr ptsIn);
+ void (*FillPolygonStippled) (DrawablePtr pDrawable, GCPtr pGC, int shape,
+ int mode, int count, DDXPointPtr ptsIn);
+ void (*FillPolygonOpaqueStippled) (DrawablePtr pDrawable, GCPtr pGC,
+ int shape, int mode, int count,
+ DDXPointPtr ptsIn);
+ void (*FillPolygonTiled) (DrawablePtr pDrawable, GCPtr pGC, int shape,
+ int mode, int count, DDXPointPtr ptsIn);
+ void (*PolyFillArcSolid) (DrawablePtr pDraw, GCPtr pGC, int narcs,
+ xArc * parcs);
+ void (*PutImage) (DrawablePtr pDraw, GCPtr pGC, int depth, int x, int y,
+ int w, int h, int leftPad, int format, char *pImage);
+ ValidateGCProcPtr ValidateFillSpans;
+ ValidateGCProcPtr ValidateSetSpans;
+ ValidateGCProcPtr ValidatePutImage;
+ ValidateGCProcPtr ValidateCopyArea;
+ ValidateGCProcPtr ValidateCopyPlane;
+ ValidateGCProcPtr ValidatePolyPoint;
+ ValidateGCProcPtr ValidatePolylines;
+ ValidateGCProcPtr ValidatePolySegment;
+ ValidateGCProcPtr ValidatePolyRectangle;
+ ValidateGCProcPtr ValidatePolyArc;
+ ValidateGCProcPtr ValidateFillPolygon;
+ ValidateGCProcPtr ValidatePolyFillRect;
+ ValidateGCProcPtr ValidatePolyFillArc;
+ ValidateGCProcPtr ValidatePolyText8;
+ ValidateGCProcPtr ValidatePolyText16;
+ ValidateGCProcPtr ValidateImageText8;
+ ValidateGCProcPtr ValidateImageText16;
+ ValidateGCProcPtr ValidatePolyGlyphBlt;
+ ValidateGCProcPtr ValidateImageGlyphBlt;
+ ValidateGCProcPtr ValidatePushPixels;
+ void (*ComputeDash) (GCPtr pGC);
+ void (*InitPixmapCache) (ScreenPtr pScreen, RegionPtr areas, pointer data);
+ void (*ClosePixmapCache) (ScreenPtr pScreen);
+ int (*StippledFillChooser) (GCPtr pGC);
+ int (*OpaqueStippledFillChooser) (GCPtr pGC);
+ int (*TiledFillChooser) (GCPtr pGC);
+ XAACacheInfoPtr(*CacheTile) (ScrnInfoPtr Scrn, PixmapPtr pPix);
+ XAACacheInfoPtr(*CacheStipple) (ScrnInfoPtr Scrn, PixmapPtr pPix, int fg,
+ int bg);
+ XAACacheInfoPtr(*CacheMonoStipple) (ScrnInfoPtr Scrn, PixmapPtr pPix);
+ XAACacheInfoPtr(*CacheMono8x8Pattern) (ScrnInfoPtr Scrn, int pat0,
+ int pat1);
+ XAACacheInfoPtr(*CacheColor8x8Pattern) (ScrnInfoPtr Scrn, PixmapPtr pPix,
+ int fg, int bg);
+ void (*WriteBitmapToCache) (ScrnInfoPtr pScrn, int x, int y, int w, int h,
+ unsigned char *src, int srcwidth, int fg,
+ int bg);
+ void (*WritePixmapToCache) (ScrnInfoPtr pScrn, int x, int y, int w, int h,
+ unsigned char *src, int srcwidth, int bpp,
+ int depth);
+ void (*WriteMono8x8PatternToCache) (ScrnInfoPtr pScrn,
+ XAACacheInfoPtr pCache);
+ void (*WriteColor8x8PatternToCache) (ScrnInfoPtr pScrn, PixmapPtr pPix,
+ XAACacheInfoPtr pCache);
+ GetImageProcPtr GetImage;
+ GetSpansProcPtr GetSpans;
+ CopyWindowProcPtr CopyWindow;
+ Bool (*SetupForCPUToScreenAlphaTexture2) (ScrnInfoPtr pScrn, int op,
+ CARD16 red, CARD16 green,
+ CARD16 blue, CARD16 alpha,
+ CARD32 maskFormat,
+ CARD32 dstFormat, CARD8 *alphaPtr,
+ int alphaPitch, int width,
+ int height, int flags);
+ Bool (*SetupForCPUToScreenTexture2) (ScrnInfoPtr pScrn, int op,
+ CARD32 srcFormat, CARD32 dstFormat,
+ CARD8 *texPtr, int texPitch, int width,
+ int height, int flags);
+} XAAStateWrapRec, *XAAStateWrapPtr;
+
+static DevPrivateKeyRec XAAStateKeyRec;
+
+#define XAAStateKey (&XAAStateKeyRec)
+
+/* Wrap functions start here */
+#define GET_STATEPRIV_GC(pGC) XAAStateWrapPtr pStatePriv =\
+(XAAStateWrapPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAStateKey)
+
+#define GET_STATEPRIV_SCREEN(pScreen) XAAStateWrapPtr pStatePriv =\
+(XAAStateWrapPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAStateKey)
+
+#define GET_STATEPRIV_PSCRN(pScrn) XAAStateWrapPtr pStatePriv =\
+(XAAStateWrapPtr)dixLookupPrivate(&(pScrn)->pScreen->devPrivates, XAAStateKey)
+
+#define STATE_CHECK_SP(pStatePriv) {\
+ ScrnInfoPtr pScrn = pStatePriv->pScrn;\
+ int i = 0;\
+ int need_change = 0;\
+ while(i < pScrn->numEntities) {\
+ if(xf86IsEntityShared(pScrn->entityList[i]) &&\
+ xf86GetLastScrnFlag(pScrn->entityList[i]) != pScrn->scrnIndex) {\
+ need_change = 1;\
+ xf86SetLastScrnFlag(pScrn->entityList[i],\
+ pScrn->scrnIndex);\
+ }\
+ i++;\
+ }\
+ if(need_change == 1) (*pStatePriv->RestoreAccelState)(pScrn);\
+}
+
+#define STATE_CHECK_PSCRN(pScrn) {\
+ int i = 0;\
+ int need_change = 0;\
+ while(i < pScrn->numEntities) {\
+ if(xf86IsEntityShared(pScrn->entityList[i]) &&\
+ xf86GetLastScrnFlag(pScrn->entityList[i]) != pScrn->scrnIndex) {\
+ need_change = 1;\
+ xf86SetLastScrnFlag(pScrn->entityList[i],\
+ pScrn->scrnIndex);\
+ }\
+ i++;\
+ }\
+ if(need_change == 1) (*pStatePriv->RestoreAccelState)(pScrn);\
+}
+
+static void
+XAAStateWrapSync(ScrnInfoPtr pScrn)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->Sync) (pScrn);
+}
+
+static void
+XAAStateWrapSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir,
+ int rop, unsigned int planemask,
+ int trans_color)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->SetupForScreenToScreenCopy) (pScrn, xdir, ydir, rop,
+ planemask, trans_color);
+}
+
+static void
+XAAStateWrapSetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop,
+ unsigned int planemask)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->SetupForSolidFill) (pScrn, color, rop, planemask);
+}
+
+static void
+XAAStateWrapSetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop,
+ unsigned int planemask)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->SetupForSolidLine) (pScrn, color, rop, planemask);
+}
+
+static void
+XAAStateWrapSetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop,
+ unsigned int planemask, int length,
+ unsigned char *pattern)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->SetupForDashedLine) (pScrn, fg, bg, rop, planemask, length,
+ pattern);
+}
+
+static void
+XAAStateWrapSetClippingRectangle(ScrnInfoPtr pScrn, int left, int top,
+ int right, int bottom)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->SetClippingRectangle) (pScrn, left, top, right, bottom);
+}
+
+static void
+XAAStateWrapDisableClipping(ScrnInfoPtr pScrn)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->DisableClipping) (pScrn);
+}
+
+static void
+XAAStateWrapSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty,
+ int fg, int bg, int rop,
+ unsigned int planemask)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->SetupForMono8x8PatternFill) (pScrn, patx, paty, fg, bg, rop,
+ planemask);
+}
+
+static void
+XAAStateWrapSetupForColor8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty,
+ int rop, unsigned int planemask,
+ int transparency_color)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->SetupForColor8x8PatternFill) (pScrn, patx, paty, rop,
+ planemask, transparency_color);
+}
+
+static void
+XAAStateWrapSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg,
+ int bg, int rop,
+ unsigned int planemask)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->SetupForCPUToScreenColorExpandFill) (pScrn, fg, bg, rop,
+ planemask);
+}
+
+static void
+XAAStateWrapSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->SetupForScanlineCPUToScreenColorExpandFill) (pScrn, fg, bg,
+ rop, planemask);
+}
+
+static void
+XAAStateWrapSetupForScreenToScreenColorExpandFill(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->SetupForScreenToScreenColorExpandFill) (pScrn, fg, bg, rop,
+ planemask);
+}
+
+static void
+XAAStateWrapSetupForImageWrite(ScrnInfoPtr pScrn, int rop,
+ unsigned int planemask, int transparency_color,
+ int bpp, int depth)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->SetupForImageWrite) (pScrn, rop, planemask,
+ transparency_color, bpp, depth);
+}
+
+static void
+XAAStateWrapSetupForScanlineImageWrite(ScrnInfoPtr pScrn, int rop,
+ unsigned int planemask,
+ int transparency_color,
+ int bpp, int depth)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->SetupForScanlineImageWrite) (pScrn, rop, planemask,
+ transparency_color, bpp, depth);
+}
+
+static void
+XAAStateWrapSetupForImageRead(ScrnInfoPtr pScrn, int bpp, int depth)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->SetupForImageRead) (pScrn, bpp, depth);
+}
+
+static void
+XAAStateWrapScreenToScreenBitBlt(ScrnInfoPtr pScrn, int nbox,
+ DDXPointPtr pptSrc, BoxPtr pbox, int xdir,
+ int ydir, int alu, unsigned int planmask)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->ScreenToScreenBitBlt) (pScrn, nbox,
+ pptSrc, pbox, xdir,
+ ydir, alu, planmask);
+}
+
+static void
+XAAStateWrapWriteBitmap(ScrnInfoPtr pScrn, int x, int y, int w, int h,
+ unsigned char *src, int srcwidth, int skipleft,
+ int fg, int bg, int rop, unsigned int planemask)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->WriteBitmap) (pScrn, x, y, w, h,
+ src, srcwidth, skipleft,
+ fg, bg, rop, planemask);
+}
+
+static void
+XAAStateWrapFillSolidRects(ScrnInfoPtr pScrn, int fg, int rop,
+ unsigned int planemask, int nBox, BoxPtr pBox)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->FillSolidRects) (pScrn, fg, rop, planemask, nBox, pBox);
+}
+
+static void
+XAAStateWrapFillMono8x8PatternRects(ScrnInfoPtr pScrn, int fg, int bg,
+ int rop, unsigned int planemask, int nBox,
+ BoxPtr pBox, int pat0, int pat1,
+ int xorg, int yorg)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->FillMono8x8PatternRects) (pScrn, fg, bg,
+ rop, planemask, nBox,
+ pBox, pat0, pat1, xorg, yorg);
+}
+
+static void
+XAAStateWrapFillColor8x8PatternRects(ScrnInfoPtr pScrn, int rop,
+ unsigned int planemask, int nBox,
+ BoxPtr pBox, int xorg, int yorg,
+ XAACacheInfoPtr pCache)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->FillColor8x8PatternRects) (pScrn, rop,
+ planemask, nBox,
+ pBox, xorg, yorg, pCache);
+}
+
+static void
+XAAStateWrapFillCacheBltRects(ScrnInfoPtr pScrn, int rop,
+ unsigned int planemask, int nBox, BoxPtr pBox,
+ int xorg, int yorg, XAACacheInfoPtr pCache)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->FillCacheBltRects) (pScrn, rop,
+ planemask, nBox, pBox,
+ xorg, yorg, pCache);
+}
+
+static void
+XAAStateWrapFillColorExpandRects(ScrnInfoPtr pScrn, int fg, int bg, int rop,
+ unsigned int planemask, int nBox,
+ BoxPtr pBox, int xorg, int yorg,
+ PixmapPtr pPix)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->FillColorExpandRects) (pScrn, fg, bg, rop,
+ planemask, nBox,
+ pBox, xorg, yorg, pPix);
+}
+
+static void
+XAAStateWrapFillCacheExpandRects(ScrnInfoPtr pScrn, int fg, int bg, int rop,
+ unsigned int planemask, int nBox,
+ BoxPtr pBox, int xorg, int yorg,
+ PixmapPtr pPix)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->FillCacheExpandRects) (pScrn, fg, bg, rop,
+ planemask, nBox,
+ pBox, xorg, yorg, pPix);
+}
+
+static void
+XAAStateWrapFillImageWriteRects(ScrnInfoPtr pScrn, int rop,
+ unsigned int planemask, int nBox, BoxPtr pBox,
+ int xorg, int yorg, PixmapPtr pPix)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->FillImageWriteRects) (pScrn, rop,
+ planemask, nBox, pBox,
+ xorg, yorg, pPix);
+}
+
+static void
+XAAStateWrapFillSolidSpans(ScrnInfoPtr pScrn, int fg, int rop,
+ unsigned int planemask, int n, DDXPointPtr points,
+ int *widths, int fSorted)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->FillSolidSpans) (pScrn, fg, rop,
+ planemask, n, points, widths, fSorted);
+}
+
+static void
+XAAStateWrapFillMono8x8PatternSpans(ScrnInfoPtr pScrn, int fg, int bg,
+ int rop, unsigned int planemask, int n,
+ DDXPointPtr points, int *widths,
+ int fSorted, int pat0, int pat1,
+ int xorg, int yorg)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->FillMono8x8PatternSpans) (pScrn, fg, bg,
+ rop, planemask, n,
+ points, widths,
+ fSorted, pat0, pat1, xorg, yorg);
+}
+
+static void
+XAAStateWrapFillColor8x8PatternSpans(ScrnInfoPtr pScrn, int rop,
+ unsigned int planemask, int n,
+ DDXPointPtr points, int *widths,
+ int fSorted, XAACacheInfoPtr pCache,
+ int xorg, int yorg)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->FillColor8x8PatternSpans) (pScrn, rop,
+ planemask, n,
+ points, widths,
+ fSorted, pCache, xorg, yorg);
+}
+
+static void
+XAAStateWrapFillCacheBltSpans(ScrnInfoPtr pScrn, int rop,
+ unsigned int planemask, int n,
+ DDXPointPtr points, int *widths,
+ int fSorted, XAACacheInfoPtr pCache,
+ int xorg, int yorg)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->FillCacheBltSpans) (pScrn, rop,
+ planemask, n,
+ points, widths,
+ fSorted, pCache, xorg, yorg);
+}
+
+static void
+XAAStateWrapFillColorExpandSpans(ScrnInfoPtr pScrn, int fg, int bg, int rop,
+ unsigned int planemask, int n,
+ DDXPointPtr points, int *widths, int fSorted,
+ int xorg, int yorg, PixmapPtr pPix)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->FillColorExpandSpans) (pScrn, fg, bg, rop,
+ planemask, n,
+ points, widths, fSorted,
+ xorg, yorg, pPix);
+}
+
+static void
+XAAStateWrapFillCacheExpandSpans(ScrnInfoPtr pScrn, int fg, int bg, int rop,
+ unsigned int planemask, int n,
+ DDXPointPtr ppt, int *pwidth, int fSorted,
+ int xorg, int yorg, PixmapPtr pPix)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->FillCacheExpandSpans) (pScrn, fg, bg, rop,
+ planemask, n,
+ ppt, pwidth, fSorted,
+ xorg, yorg, pPix);
+}
+
+static void
+XAAStateWrapTEGlyphRenderer(ScrnInfoPtr pScrn, int x, int y, int w, int h,
+ int skipleft, int startline,
+ unsigned int **glyphs,
+ int glyphWidth, int fg, int bg, int rop,
+ unsigned planemask)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->TEGlyphRenderer) (pScrn, x, y, w, h,
+ skipleft, startline,
+ glyphs, glyphWidth, fg, bg, rop, planemask);
+}
+
+static void
+XAAStateWrapNonTEGlyphRenderer(ScrnInfoPtr pScrn, int x, int y, int n,
+ NonTEGlyphPtr glyphs, BoxPtr pbox,
+ int fg, int rop, unsigned int planemask)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->NonTEGlyphRenderer) (pScrn, x, y, n,
+ glyphs, pbox, fg, rop, planemask);
+}
+
+static void
+XAAStateWrapWritePixmap(ScrnInfoPtr pScrn, int x, int y, int w, int h,
+ unsigned char *src, int srcwidth, int rop,
+ unsigned int planemask, int transparency_color,
+ int bpp, int depth)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->WritePixmap) (pScrn, x, y, w, h,
+ src, srcwidth, rop,
+ planemask, transparency_color, bpp, depth);
+}
+
+static void
+XAAStateWrapReadPixmap(ScrnInfoPtr pScrn, int x, int y, int w, int h,
+ unsigned char *dst, int dstwidth, int bpp, int depth)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->ReadPixmap) (pScrn, x, y, w, h, dst, dstwidth, bpp, depth);
+}
+
+static RegionPtr
+XAAStateWrapCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
+ GC * pGC, int srcx, int srcy, int width, int height,
+ int dstx, int dsty)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ return (*pStatePriv->CopyArea) (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty);
+}
+
+static RegionPtr
+XAAStateWrapCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int width, int height,
+ int dstx, int dsty, unsigned long bitPlane)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ return (*pStatePriv->CopyPlane) (pSrc, pDst, pGC,
+ srcx, srcy, width, height,
+ dstx, dsty, bitPlane);
+}
+
+static void
+XAAStateWrapPushPixelsSolid(GCPtr pGC, PixmapPtr pBitMap,
+ DrawablePtr pDrawable, int dx, int dy, int xOrg,
+ int yOrg)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->PushPixelsSolid) (pGC, pBitMap,
+ pDrawable, dx, dy, xOrg, yOrg);
+}
+
+static void
+XAAStateWrapPolyFillRectSolid(DrawablePtr pDraw, GCPtr pGC, int nrectFill,
+ xRectangle *prectInit)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->PolyFillRectSolid) (pDraw, pGC, nrectFill, prectInit);
+}
+
+static void
+XAAStateWrapPolyFillRectStippled(DrawablePtr pDraw, GCPtr pGC, int nrectFill,
+ xRectangle *prectInit)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->PolyFillRectStippled) (pDraw, pGC, nrectFill, prectInit);
+}
+
+static void
+XAAStateWrapPolyFillRectOpaqueStippled(DrawablePtr pDraw, GCPtr pGC,
+ int nrectFill, xRectangle *prectInit)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->PolyFillRectOpaqueStippled) (pDraw, pGC,
+ nrectFill, prectInit);
+}
+
+static void
+XAAStateWrapPolyFillRectTiled(DrawablePtr pDraw, GCPtr pGC, int nrectFill,
+ xRectangle *prectInit)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->PolyFillRectTiled) (pDraw, pGC, nrectFill, prectInit);
+}
+
+static void
+XAAStateWrapFillSpansSolid(DrawablePtr pDraw, GCPtr pGC, int nInit,
+ DDXPointPtr ppt, int *pwidth, int fSorted)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->FillSpansSolid) (pDraw, pGC, nInit, ppt, pwidth, fSorted);
+}
+
+static void
+XAAStateWrapFillSpansStippled(DrawablePtr pDraw, GCPtr pGC, int nInit,
+ DDXPointPtr ppt, int *pwidth, int fSorted)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->FillSpansStippled) (pDraw, pGC, nInit, ppt, pwidth, fSorted);
+}
+
+static void
+XAAStateWrapFillSpansOpaqueStippled(DrawablePtr pDraw, GCPtr pGC, int nInit,
+ DDXPointPtr ppt, int *pwidth, int fSorted)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->FillSpansOpaqueStippled) (pDraw, pGC, nInit,
+ ppt, pwidth, fSorted);
+}
+
+static void
+XAAStateWrapFillSpansTiled(DrawablePtr pDraw, GCPtr pGC, int nInit,
+ DDXPointPtr ppt, int *pwidth, int fSorted)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->FillSpansTiled) (pDraw, pGC, nInit, ppt, pwidth, fSorted);
+}
+
+static int
+XAAStateWrapPolyText8TE(DrawablePtr pDraw, GCPtr pGC, int x, int y, int count,
+ char *chars)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ return (*pStatePriv->PolyText8TE) (pDraw, pGC, x, y, count, chars);
+}
+
+static int
+XAAStateWrapPolyText16TE(DrawablePtr pDraw, GCPtr pGC, int x, int y, int count,
+ unsigned short *chars)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ return (*pStatePriv->PolyText16TE) (pDraw, pGC, x, y, count, chars);
+}
+
+static void
+XAAStateWrapImageText8TE(DrawablePtr pDraw, GCPtr pGC, int x, int y,
+ int count, char *chars)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ImageText8TE) (pDraw, pGC, x, y, count, chars);
+}
+
+static void
+XAAStateWrapImageText16TE(DrawablePtr pDraw, GCPtr pGC, int x, int y,
+ int count, unsigned short *chars)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ImageText16TE) (pDraw, pGC, x, y, count, chars);
+}
+
+static void
+XAAStateWrapImageGlyphBltTE(DrawablePtr pDrawable, GCPtr pGC, int xInit,
+ int yInit, unsigned int nglyph, CharInfoPtr * ppci,
+ pointer pglyphBase)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ImageGlyphBltTE) (pDrawable, pGC, xInit,
+ yInit, nglyph, ppci, pglyphBase);
+}
+
+static void
+XAAStateWrapPolyGlyphBltTE(DrawablePtr pDrawable, GCPtr pGC, int xInit,
+ int yInit, unsigned int nglyph, CharInfoPtr * ppci,
+ pointer pglyphBase)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->PolyGlyphBltTE) (pDrawable, pGC, xInit,
+ yInit, nglyph, ppci, pglyphBase);
+}
+
+static int
+XAAStateWrapPolyText8NonTE(DrawablePtr pDraw, GCPtr pGC, int x, int y,
+ int count, char *chars)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ return (*pStatePriv->PolyText8NonTE) (pDraw, pGC, x, y, count, chars);
+}
+
+static int
+XAAStateWrapPolyText16NonTE(DrawablePtr pDraw, GCPtr pGC, int x, int y,
+ int count, unsigned short *chars)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ return (*pStatePriv->PolyText16NonTE) (pDraw, pGC, x, y, count, chars);
+}
+
+static void
+XAAStateWrapImageText8NonTE(DrawablePtr pDraw, GCPtr pGC, int x, int y,
+ int count, char *chars)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ImageText8NonTE) (pDraw, pGC, x, y, count, chars);
+}
+
+static void
+XAAStateWrapImageText16NonTE(DrawablePtr pDraw, GCPtr pGC, int x, int y,
+ int count, unsigned short *chars)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ImageText16NonTE) (pDraw, pGC, x, y, count, chars);
+}
+
+static void
+XAAStateWrapImageGlyphBltNonTE(DrawablePtr pDrawable, GCPtr pGC, int xInit,
+ int yInit, unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ImageGlyphBltNonTE) (pDrawable, pGC, xInit,
+ yInit, nglyph, ppci, pglyphBase);
+}
+
+static void
+XAAStateWrapPolyGlyphBltNonTE(DrawablePtr pDrawable, GCPtr pGC, int xInit,
+ int yInit, unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->PolyGlyphBltNonTE) (pDrawable, pGC, xInit,
+ yInit, nglyph, ppci, pglyphBase);
+}
+
+static void
+XAAStateWrapPolyRectangleThinSolid(DrawablePtr pDrawable, GCPtr pGC,
+ int nRectsInit, xRectangle *pRectsInit)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->PolyRectangleThinSolid) (pDrawable, pGC,
+ nRectsInit, pRectsInit);
+}
+
+static void
+XAAStateWrapPolylinesWideSolid(DrawablePtr pDrawable, GCPtr pGC, int mode,
+ int npt, DDXPointPtr pPts)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->PolylinesWideSolid) (pDrawable, pGC, mode, npt, pPts);
+}
+
+static void
+XAAStateWrapPolylinesThinSolid(DrawablePtr pDrawable, GCPtr pGC, int mode,
+ int npt, DDXPointPtr pPts)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->PolylinesThinSolid) (pDrawable, pGC, mode, npt, pPts);
+}
+
+static void
+XAAStateWrapPolySegmentThinSolid(DrawablePtr pDrawable, GCPtr pGC, int nseg,
+ xSegment * pSeg)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->PolySegmentThinSolid) (pDrawable, pGC, nseg, pSeg);
+}
+
+static void
+XAAStateWrapPolylinesThinDashed(DrawablePtr pDrawable, GCPtr pGC, int mode,
+ int npt, DDXPointPtr pPts)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->PolylinesThinDashed) (pDrawable, pGC, mode, npt, pPts);
+}
+
+static void
+XAAStateWrapPolySegmentThinDashed(DrawablePtr pDrawable, GCPtr pGC, int nseg,
+ xSegment * pSeg)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->PolySegmentThinDashed) (pDrawable, pGC, nseg, pSeg);
+}
+
+static void
+XAAStateWrapFillPolygonSolid(DrawablePtr pDrawable, GCPtr pGC, int shape,
+ int mode, int count, DDXPointPtr ptsIn)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->FillPolygonSolid) (pDrawable, pGC, shape, mode, count, ptsIn);
+}
+
+static void
+XAAStateWrapFillPolygonStippled(DrawablePtr pDrawable, GCPtr pGC, int shape,
+ int mode, int count, DDXPointPtr ptsIn)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->FillPolygonStippled) (pDrawable, pGC, shape,
+ mode, count, ptsIn);
+}
+
+static void
+XAAStateWrapFillPolygonOpaqueStippled(DrawablePtr pDrawable, GCPtr pGC,
+ int shape, int mode, int count,
+ DDXPointPtr ptsIn)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->FillPolygonOpaqueStippled) (pDrawable, pGC,
+ shape, mode, count, ptsIn);
+}
+
+static void
+XAAStateWrapFillPolygonTiled(DrawablePtr pDrawable, GCPtr pGC, int shape,
+ int mode, int count, DDXPointPtr ptsIn)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->FillPolygonTiled) (pDrawable, pGC, shape, mode, count, ptsIn);
+}
+
+static void
+XAAStateWrapPolyFillArcSolid(DrawablePtr pDraw, GCPtr pGC, int narcs,
+ xArc * parcs)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->PolyFillArcSolid) (pDraw, pGC, narcs, parcs);
+}
+
+static void
+XAAStateWrapPutImage(DrawablePtr pDraw, GCPtr pGC, int depth, int x, int y,
+ int w, int h, int leftPad, int format, char *pImage)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->PutImage) (pDraw, pGC, depth, x, y,
+ w, h, leftPad, format, pImage);
+}
+
+static void
+XAAStateWrapValidateFillSpans(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDraw)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ValidateFillSpans) (pGC, changes, pDraw);
+}
+
+static void
+XAAStateWrapValidateSetSpans(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDraw)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ValidateSetSpans) (pGC, changes, pDraw);
+}
+
+static void
+XAAStateWrapValidatePutImage(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDraw)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ValidatePutImage) (pGC, changes, pDraw);
+}
+
+static void
+XAAStateWrapValidateCopyArea(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDraw)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ValidateCopyArea) (pGC, changes, pDraw);
+}
+
+static void
+XAAStateWrapValidateCopyPlane(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDraw)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ValidateCopyPlane) (pGC, changes, pDraw);
+}
+
+static void
+XAAStateWrapValidatePolyPoint(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDraw)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ValidatePolyPoint) (pGC, changes, pDraw);
+}
+
+static void
+XAAStateWrapValidatePolylines(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDraw)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ValidatePolylines) (pGC, changes, pDraw);
+}
+
+static void
+XAAStateWrapValidatePolySegment(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDraw)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ValidatePolySegment) (pGC, changes, pDraw);
+}
+
+static void
+XAAStateWrapValidatePolyRectangle(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDraw)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ValidatePolyRectangle) (pGC, changes, pDraw);
+}
+
+static void
+XAAStateWrapValidatePolyArc(GCPtr pGC, unsigned long changes, DrawablePtr pDraw)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ValidatePolyArc) (pGC, changes, pDraw);
+}
+
+static void
+XAAStateWrapValidateFillPolygon(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDraw)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ValidateFillPolygon) (pGC, changes, pDraw);
+}
+
+static void
+XAAStateWrapValidatePolyFillRect(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDraw)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ValidatePolyFillRect) (pGC, changes, pDraw);
+}
+
+static void
+XAAStateWrapValidatePolyFillArc(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDraw)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ValidatePolyFillArc) (pGC, changes, pDraw);
+}
+
+static void
+XAAStateWrapValidatePolyText8(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDraw)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ValidatePolyText8) (pGC, changes, pDraw);
+}
+
+static void
+XAAStateWrapValidatePolyText16(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDraw)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ValidatePolyText16) (pGC, changes, pDraw);
+}
+
+static void
+XAAStateWrapValidateImageText8(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDraw)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ValidateImageText8) (pGC, changes, pDraw);
+}
+
+static void
+XAAStateWrapValidateImageText16(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDraw)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ValidateImageText16) (pGC, changes, pDraw);
+}
+
+static void
+XAAStateWrapValidatePolyGlyphBlt(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDraw)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ValidatePolyGlyphBlt) (pGC, changes, pDraw);
+}
+
+static void
+XAAStateWrapValidateImageGlyphBlt(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDraw)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+ (*pStatePriv->ValidateImageGlyphBlt) (pGC, changes, pDraw);
+}
+
+static void
+XAAStateWrapValidatePushPixels(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDraw)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ValidatePushPixels) (pGC, changes, pDraw);
+}
+
+static void
+XAAStateWrapComputeDash(GCPtr pGC)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ComputeDash) (pGC);
+}
+
+static void
+XAAStateWrapInitPixmapCache(ScreenPtr pScreen, RegionPtr areas, pointer data)
+{
+ GET_STATEPRIV_SCREEN(pScreen);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->InitPixmapCache) (pScreen, areas, data);
+}
+
+static void
+XAAStateWrapClosePixmapCache(ScreenPtr pScreen)
+{
+ GET_STATEPRIV_SCREEN(pScreen);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->ClosePixmapCache) (pScreen);
+}
+
+static int
+XAAStateWrapStippledFillChooser(GCPtr pGC)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ return (*pStatePriv->StippledFillChooser) (pGC);
+}
+
+static int
+XAAStateWrapOpaqueStippledFillChooser(GCPtr pGC)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ return (*pStatePriv->OpaqueStippledFillChooser) (pGC);
+}
+
+static int
+XAAStateWrapTiledFillChooser(GCPtr pGC)
+{
+ GET_STATEPRIV_GC(pGC);
+ STATE_CHECK_SP(pStatePriv);
+
+ return (*pStatePriv->TiledFillChooser) (pGC);
+}
+
+static XAACacheInfoPtr
+XAAStateWrapCacheTile(ScrnInfoPtr pScrn, PixmapPtr pPix)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ return (*pStatePriv->CacheTile) (pScrn, pPix);
+}
+
+static XAACacheInfoPtr
+XAAStateWrapCacheStipple(ScrnInfoPtr pScrn, PixmapPtr pPix, int fg, int bg)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ return (*pStatePriv->CacheStipple) (pScrn, pPix, fg, bg);
+}
+
+static XAACacheInfoPtr
+XAAStateWrapCacheMonoStipple(ScrnInfoPtr pScrn, PixmapPtr pPix)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ return (*pStatePriv->CacheMonoStipple) (pScrn, pPix);
+}
+
+static XAACacheInfoPtr
+XAAStateWrapCacheMono8x8Pattern(ScrnInfoPtr pScrn, int pat0, int pat1)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ return (*pStatePriv->CacheMono8x8Pattern) (pScrn, pat0, pat1);
+}
+
+static XAACacheInfoPtr
+XAAStateWrapCacheColor8x8Pattern(ScrnInfoPtr pScrn, PixmapPtr pPix,
+ int fg, int bg)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ return (*pStatePriv->CacheColor8x8Pattern) (pScrn, pPix, fg, bg);
+}
+
+static void
+XAAStateWrapWriteBitmapToCache(ScrnInfoPtr pScrn, int x, int y, int w, int h,
+ unsigned char *src, int srcwidth, int fg, int bg)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->WriteBitmapToCache) (pScrn, x, y, w, h,
+ src, srcwidth, fg, bg);
+}
+
+static void
+XAAStateWrapWritePixmapToCache(ScrnInfoPtr pScrn, int x, int y, int w, int h,
+ unsigned char *src, int srcwidth, int bpp,
+ int depth)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->WritePixmapToCache) (pScrn, x, y, w, h,
+ src, srcwidth, bpp, depth);
+}
+
+static void
+XAAStateWrapWriteMono8x8PatternToCache(ScrnInfoPtr pScrn,
+ XAACacheInfoPtr pCache)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->WriteMono8x8PatternToCache) (pScrn, pCache);
+}
+
+static void
+XAAStateWrapWriteColor8x8PatternToCache(ScrnInfoPtr pScrn, PixmapPtr pPix,
+ XAACacheInfoPtr pCache)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ (*pStatePriv->WriteColor8x8PatternToCache) (pScrn, pPix, pCache);
+}
+
+static void
+XAAStateWrapGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h,
+ unsigned int format, unsigned long planeMask,
+ char *pdstLine)
+{
+ GET_STATEPRIV_SCREEN(pDrawable->pScreen);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->GetImage) (pDrawable, sx, sy, w, h,
+ format, planeMask, pdstLine);
+}
+
+static void
+XAAStateWrapGetSpans(DrawablePtr pDrawable, int wMax, DDXPointPtr ppt,
+ int *pwidth, int nspans, char *pdstStart)
+{
+ GET_STATEPRIV_SCREEN(pDrawable->pScreen);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+}
+
+static void
+XAAStateWrapCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc)
+{
+ GET_STATEPRIV_SCREEN(pWindow->drawable.pScreen);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->CopyWindow) (pWindow, ptOldOrg, prgnSrc);
+}
+
+static Bool
+XAAStateWrapSetupForCPUToScreenAlphaTexture2(ScrnInfoPtr pScrn,
+ int op, CARD16 red,
+ CARD16 green,
+ CARD16 blue,
+ CARD16 alpha,
+ CARD32 srcFormat,
+ CARD32 dstFormat,
+ CARD8 *alphaPtr,
+ int alphaPitch,
+ int width, int height, int flags)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ return (*pStatePriv->SetupForCPUToScreenAlphaTexture2) (pScrn, op, red,
+ green, blue, alpha,
+ srcFormat,
+ dstFormat, alphaPtr,
+ alphaPitch, width,
+ height, flags);
+}
+
+static Bool
+XAAStateWrapSetupForCPUToScreenTexture2(ScrnInfoPtr pScrn, int op,
+ CARD32 srcFormat,
+ CARD32 dstFormat,
+ CARD8 *texPtr, int texPitch,
+ int width, int height, int flags)
+{
+ GET_STATEPRIV_PSCRN(pScrn);
+ STATE_CHECK_PSCRN(pScrn);
+
+ return (*pStatePriv->SetupForCPUToScreenTexture2) (pScrn, op, srcFormat,
+ dstFormat, texPtr,
+ texPitch, width, height,
+ flags);
+}
+
+/* Setup Function */
+Bool
+XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ XAAStateWrapPtr pStatePriv;
+ int i = 0;
+
+ if (!dixRegisterPrivateKey(&XAAStateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+ if (!(pStatePriv = malloc(sizeof(XAAStateWrapRec))))
+ return FALSE;
+ dixSetPrivate(&pScreen->devPrivates, XAAStateKey, pStatePriv);
+ pStatePriv->RestoreAccelState = infoRec->RestoreAccelState;
+ pStatePriv->pScrn = pScrn;
+
+ /* Initialize the last screen to -1 so whenever an accel function
+ * is called the proper state is setup
+ */
+ while (i < pScrn->numEntities) {
+ xf86SetLastScrnFlag(pScrn->entityList[i], -1);
+ i++;
+ }
+/* Do the wrapping */
+ XAA_STATE_WRAP(Sync);
+ XAA_STATE_WRAP(SetupForScreenToScreenCopy);
+ XAA_STATE_WRAP(SetupForSolidFill);
+ XAA_STATE_WRAP(SetupForSolidLine);
+ XAA_STATE_WRAP(SetupForDashedLine);
+ XAA_STATE_WRAP(SetClippingRectangle);
+ XAA_STATE_WRAP(DisableClipping);
+ XAA_STATE_WRAP(SetupForMono8x8PatternFill);
+ XAA_STATE_WRAP(SetupForColor8x8PatternFill);
+ XAA_STATE_WRAP(SetupForCPUToScreenColorExpandFill);
+ XAA_STATE_WRAP(SetupForScanlineCPUToScreenColorExpandFill);
+ XAA_STATE_WRAP(SetupForScreenToScreenColorExpandFill);
+ XAA_STATE_WRAP(SetupForImageWrite);
+ XAA_STATE_WRAP(SetupForScanlineImageWrite);
+ XAA_STATE_WRAP(SetupForImageRead);
+ XAA_STATE_WRAP(ScreenToScreenBitBlt);
+ XAA_STATE_WRAP(WriteBitmap);
+ XAA_STATE_WRAP(FillSolidRects);
+ XAA_STATE_WRAP(FillMono8x8PatternRects);
+ XAA_STATE_WRAP(FillColor8x8PatternRects);
+ XAA_STATE_WRAP(FillCacheBltRects);
+ XAA_STATE_WRAP(FillColorExpandRects);
+ XAA_STATE_WRAP(FillCacheExpandRects);
+ XAA_STATE_WRAP(FillImageWriteRects);
+ XAA_STATE_WRAP(FillSolidSpans);
+ XAA_STATE_WRAP(FillMono8x8PatternSpans);
+ XAA_STATE_WRAP(FillColor8x8PatternSpans);
+ XAA_STATE_WRAP(FillCacheBltSpans);
+ XAA_STATE_WRAP(FillColorExpandSpans);
+ XAA_STATE_WRAP(FillCacheExpandSpans);
+ XAA_STATE_WRAP(TEGlyphRenderer);
+ XAA_STATE_WRAP(NonTEGlyphRenderer);
+ XAA_STATE_WRAP(WritePixmap);
+ XAA_STATE_WRAP(ReadPixmap);
+ XAA_STATE_WRAP(CopyArea);
+ XAA_STATE_WRAP(CopyPlane);
+ XAA_STATE_WRAP(PushPixelsSolid);
+ XAA_STATE_WRAP(PolyFillRectSolid);
+ XAA_STATE_WRAP(PolyFillRectStippled);
+ XAA_STATE_WRAP(PolyFillRectOpaqueStippled);
+ XAA_STATE_WRAP(PolyFillRectTiled);
+ XAA_STATE_WRAP(FillSpansSolid);
+ XAA_STATE_WRAP(FillSpansStippled);
+ XAA_STATE_WRAP(FillSpansOpaqueStippled);
+ XAA_STATE_WRAP(FillSpansTiled);
+ XAA_STATE_WRAP(PolyText8TE);
+ XAA_STATE_WRAP(PolyText16TE);
+ XAA_STATE_WRAP(ImageText8TE);
+ XAA_STATE_WRAP(ImageText16TE);
+ XAA_STATE_WRAP(ImageGlyphBltTE);
+ XAA_STATE_WRAP(PolyGlyphBltTE);
+ XAA_STATE_WRAP(PolyText8NonTE);
+ XAA_STATE_WRAP(PolyText16NonTE);
+ XAA_STATE_WRAP(ImageText8NonTE);
+ XAA_STATE_WRAP(ImageText16NonTE);
+ XAA_STATE_WRAP(ImageGlyphBltNonTE);
+ XAA_STATE_WRAP(PolyGlyphBltNonTE);
+ XAA_STATE_WRAP(PolyRectangleThinSolid);
+ XAA_STATE_WRAP(PolylinesWideSolid);
+ XAA_STATE_WRAP(PolylinesThinSolid);
+ XAA_STATE_WRAP(PolySegmentThinSolid);
+ XAA_STATE_WRAP(PolylinesThinDashed);
+ XAA_STATE_WRAP(PolySegmentThinDashed);
+ XAA_STATE_WRAP(FillPolygonSolid);
+ XAA_STATE_WRAP(FillPolygonStippled);
+ XAA_STATE_WRAP(FillPolygonOpaqueStippled);
+ XAA_STATE_WRAP(FillPolygonTiled);
+ XAA_STATE_WRAP(PolyFillArcSolid);
+ XAA_STATE_WRAP(PutImage);
+ XAA_STATE_WRAP(ValidateFillSpans);
+ XAA_STATE_WRAP(ValidateSetSpans);
+ XAA_STATE_WRAP(ValidatePutImage);
+ XAA_STATE_WRAP(ValidateCopyArea);
+ XAA_STATE_WRAP(ValidateCopyPlane);
+ XAA_STATE_WRAP(ValidatePolyPoint);
+ XAA_STATE_WRAP(ValidatePolylines);
+ XAA_STATE_WRAP(ValidatePolySegment);
+ XAA_STATE_WRAP(ValidatePolyRectangle);
+ XAA_STATE_WRAP(ValidatePolyArc);
+ XAA_STATE_WRAP(ValidateFillPolygon);
+ XAA_STATE_WRAP(ValidatePolyFillRect);
+ XAA_STATE_WRAP(ValidatePolyFillArc);
+ XAA_STATE_WRAP(ValidatePolyText8);
+ XAA_STATE_WRAP(ValidatePolyText16);
+ XAA_STATE_WRAP(ValidateImageText8);
+ XAA_STATE_WRAP(ValidateImageText16);
+ XAA_STATE_WRAP(ValidatePolyGlyphBlt);
+ XAA_STATE_WRAP(ValidateImageGlyphBlt);
+ XAA_STATE_WRAP(ValidatePushPixels);
+ XAA_STATE_WRAP(ComputeDash);
+ XAA_STATE_WRAP(InitPixmapCache);
+ XAA_STATE_WRAP(ClosePixmapCache);
+ XAA_STATE_WRAP(StippledFillChooser);
+ XAA_STATE_WRAP(OpaqueStippledFillChooser);
+ XAA_STATE_WRAP(TiledFillChooser);
+ XAA_STATE_WRAP(CacheTile);
+ XAA_STATE_WRAP(CacheStipple);
+ XAA_STATE_WRAP(CacheMonoStipple);
+ XAA_STATE_WRAP(CacheMono8x8Pattern);
+ XAA_STATE_WRAP(CacheColor8x8Pattern);
+ XAA_STATE_WRAP(WriteBitmapToCache);
+ XAA_STATE_WRAP(WritePixmapToCache);
+ XAA_STATE_WRAP(WriteMono8x8PatternToCache);
+ XAA_STATE_WRAP(WriteColor8x8PatternToCache);
+ XAA_STATE_WRAP(GetImage);
+ XAA_STATE_WRAP(GetSpans);
+ XAA_STATE_WRAP(CopyWindow);
+ XAA_STATE_WRAP(SetupForCPUToScreenAlphaTexture2);
+ XAA_STATE_WRAP(SetupForCPUToScreenTexture2);
+ return TRUE;
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaStipple.c b/xorg-server/hw/xfree86/xaa/xaaStipple.c
index c1d6f8ab4..fc74e3988 100644
--- a/xorg-server/hw/xfree86/xaa/xaaStipple.c
+++ b/xorg-server/hw/xfree86/xaa/xaaStipple.c
@@ -8,12 +8,12 @@
#include "xaacexp.h"
#include "xf86.h"
-static CARD32* StipplePowerOfTwo(CARD32*, CARD32*, int, int, int);
-static CARD32* StipplePowerOfTwo_Inverted(CARD32*, CARD32*, int, int, int);
-static CARD32* StippleUpTo32(CARD32*, CARD32*, int, int, int);
-static CARD32* StippleUpTo32_Inverted(CARD32*, CARD32*, int, int, int);
-static CARD32* StippleOver32(CARD32*, CARD32*, int, int, int);
-static CARD32* StippleOver32_Inverted(CARD32*, CARD32*, int, int, int);
+static CARD32 *StipplePowerOfTwo(CARD32 *, CARD32 *, int, int, int);
+static CARD32 *StipplePowerOfTwo_Inverted(CARD32 *, CARD32 *, int, int, int);
+static CARD32 *StippleUpTo32(CARD32 *, CARD32 *, int, int, int);
+static CARD32 *StippleUpTo32_Inverted(CARD32 *, CARD32 *, int, int, int);
+static CARD32 *StippleOver32(CARD32 *, CARD32 *, int, int, int);
+static CARD32 *StippleOver32_Inverted(CARD32 *, CARD32 *, int, int, int);
#ifdef TRIPLE_BITS
#define stipple_scanline_func EXPNAME(XAAStippleScanlineFunc3)
@@ -24,27 +24,28 @@ static CARD32* StippleOver32_Inverted(CARD32*, CARD32*, int, int, int);
#endif
StippleScanlineProcPtr stipple_scanline_func[6] = {
- StipplePowerOfTwo,
- StippleUpTo32,
- StippleOver32,
- StipplePowerOfTwo_Inverted,
- StippleUpTo32_Inverted,
- StippleOver32_Inverted
+ StipplePowerOfTwo,
+ StippleUpTo32,
+ StippleOver32,
+ StipplePowerOfTwo_Inverted,
+ StippleUpTo32_Inverted,
+ StippleOver32_Inverted
};
-StippleScanlineProcPtr *stipple_get_scanline_func(void) {
- return stipple_scanline_func;
+StippleScanlineProcPtr *
+stipple_get_scanline_func(void)
+{
+ return stipple_scanline_func;
}
#ifdef FIXEDBASE
-# define DEST(i) *dest
-# define RETURN(i) return(dest)
+#define DEST(i) *dest
+#define RETURN(i) return(dest)
#else
-# define DEST(i) dest[i]
-# define RETURN(i) return(dest + i)
+#define DEST(i) dest[i]
+#define RETURN(i) return(dest + i)
#endif
-
/* TRIPLE_BITS pattern expansion */
#ifdef TRIPLE_BITS
#define EXPAND_PAT \
@@ -80,45 +81,42 @@ StippleScanlineProcPtr *stipple_get_scanline_func(void) {
#endif
#endif
-
#if !defined(FIXEDBASE) && !defined(MSBFIRST) && !defined(TRIPLE_BITS)
unsigned int XAAShiftMasks[32] = {
- /* gcc is rather pedantic about SHIFT_R(0xFFFFFFFF,32) */
- 0x00000000 , SHIFT_R(0xFFFFFFFF,31),
- SHIFT_R(0xFFFFFFFF,30), SHIFT_R(0xFFFFFFFF,29),
- SHIFT_R(0xFFFFFFFF,28), SHIFT_R(0xFFFFFFFF,27),
- SHIFT_R(0xFFFFFFFF,26), SHIFT_R(0xFFFFFFFF,25),
- SHIFT_R(0xFFFFFFFF,24), SHIFT_R(0xFFFFFFFF,23),
- SHIFT_R(0xFFFFFFFF,22), SHIFT_R(0xFFFFFFFF,21),
- SHIFT_R(0xFFFFFFFF,20), SHIFT_R(0xFFFFFFFF,19),
- SHIFT_R(0xFFFFFFFF,18), SHIFT_R(0xFFFFFFFF,17),
- SHIFT_R(0xFFFFFFFF,16), SHIFT_R(0xFFFFFFFF,15),
- SHIFT_R(0xFFFFFFFF,14), SHIFT_R(0xFFFFFFFF,13),
- SHIFT_R(0xFFFFFFFF,12), SHIFT_R(0xFFFFFFFF,11),
- SHIFT_R(0xFFFFFFFF,10), SHIFT_R(0xFFFFFFFF,9),
- SHIFT_R(0xFFFFFFFF,8), SHIFT_R(0xFFFFFFFF,7),
- SHIFT_R(0xFFFFFFFF,6), SHIFT_R(0xFFFFFFFF,5),
- SHIFT_R(0xFFFFFFFF,4), SHIFT_R(0xFFFFFFFF,3),
- SHIFT_R(0xFFFFFFFF,2), SHIFT_R(0xFFFFFFFF,1)
+ /* gcc is rather pedantic about SHIFT_R(0xFFFFFFFF,32) */
+ 0x00000000, SHIFT_R(0xFFFFFFFF, 31),
+ SHIFT_R(0xFFFFFFFF, 30), SHIFT_R(0xFFFFFFFF, 29),
+ SHIFT_R(0xFFFFFFFF, 28), SHIFT_R(0xFFFFFFFF, 27),
+ SHIFT_R(0xFFFFFFFF, 26), SHIFT_R(0xFFFFFFFF, 25),
+ SHIFT_R(0xFFFFFFFF, 24), SHIFT_R(0xFFFFFFFF, 23),
+ SHIFT_R(0xFFFFFFFF, 22), SHIFT_R(0xFFFFFFFF, 21),
+ SHIFT_R(0xFFFFFFFF, 20), SHIFT_R(0xFFFFFFFF, 19),
+ SHIFT_R(0xFFFFFFFF, 18), SHIFT_R(0xFFFFFFFF, 17),
+ SHIFT_R(0xFFFFFFFF, 16), SHIFT_R(0xFFFFFFFF, 15),
+ SHIFT_R(0xFFFFFFFF, 14), SHIFT_R(0xFFFFFFFF, 13),
+ SHIFT_R(0xFFFFFFFF, 12), SHIFT_R(0xFFFFFFFF, 11),
+ SHIFT_R(0xFFFFFFFF, 10), SHIFT_R(0xFFFFFFFF, 9),
+ SHIFT_R(0xFFFFFFFF, 8), SHIFT_R(0xFFFFFFFF, 7),
+ SHIFT_R(0xFFFFFFFF, 6), SHIFT_R(0xFFFFFFFF, 5),
+ SHIFT_R(0xFFFFFFFF, 4), SHIFT_R(0xFFFFFFFF, 3),
+ SHIFT_R(0xFFFFFFFF, 2), SHIFT_R(0xFFFFFFFF, 1)
};
#endif
void
#ifdef TRIPLE_BITS
-EXPNAME(XAAFillColorExpandRects3)(
+ EXPNAME(XAAFillColorExpandRects3) (
#else
-EXPNAME(XAAFillColorExpandRects)(
+ EXPNAME(XAAFillColorExpandRects) (
#endif
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-){
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg, PixmapPtr pPix) {
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
CARD32 *base;
Bool TwoPass = FALSE, FirstPass = TRUE;
@@ -127,136 +125,145 @@ EXPNAME(XAAFillColorExpandRects)(
int stippleheight = pPix->drawable.height;
int srcwidth = pPix->devKind;
int dwords, srcy, srcx, funcNo = 2, h;
- unsigned char *src = (unsigned char*)pPix->devPrivate.ptr;
+ unsigned char *src = (unsigned char *) pPix->devPrivate.ptr;
unsigned char *srcp;
int flag;
- if(stipplewidth <= 32) {
- if(stipplewidth & (stipplewidth - 1))
- funcNo = 1;
- else
- funcNo = 0;
- }
+ if (stipplewidth <= 32) {
+ if (stipplewidth & (stipplewidth - 1))
+ funcNo = 1;
+ else
+ funcNo = 0;
+ }
StippleFunc = stipple_scanline_func[funcNo];
SecondFunc = stipple_scanline_func[funcNo];
FirstFunc = stipple_scanline_func[funcNo + 3];
#ifdef TRIPLE_BITS
- if((bg == -1) ||
- (!(infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) &&
- (!(infoRec->CPUToScreenColorExpandFillFlags & RGB_EQUAL) ||
- (CHECK_RGB_EQUAL(bg))))) {
+ if ((bg == -1) ||
+ (!(infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) &&
+ (!(infoRec->CPUToScreenColorExpandFillFlags & RGB_EQUAL) ||
+ (CHECK_RGB_EQUAL(bg))))) {
#else
- if((bg == -1) ||
- !(infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) {
+ if ((bg == -1) ||
+ !(infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) {
#endif
- /* one pass */
- } else if((rop == GXcopy) && infoRec->FillSolidRects) {
- /* one pass but we fill background rects first */
- (*infoRec->FillSolidRects)(pScrn, bg, rop, planemask, nBox, pBox);
- bg = -1;
- } else {
- /* gotta do two passes */
- TwoPass = TRUE;
+ /* one pass */
+ }
+ else if ((rop == GXcopy) && infoRec->FillSolidRects) {
+ /* one pass but we fill background rects first */
+ (*infoRec->FillSolidRects) (pScrn, bg, rop, planemask, nBox, pBox);
+ bg = -1;
+ }
+ else {
+ /* gotta do two passes */
+ TwoPass = TRUE;
}
- if(!TwoPass)
- (*infoRec->SetupForCPUToScreenColorExpandFill)(
- pScrn, fg, bg, rop, planemask);
+ if (!TwoPass)
+ (*infoRec->SetupForCPUToScreenColorExpandFill) (pScrn, fg, bg, rop,
+ planemask);
- while(nBox--) {
+ while (nBox--) {
#ifdef TRIPLE_BITS
- dwords = (3 * (pBox->x2 - pBox->x1) + 31) >> 5;
+ dwords = (3 * (pBox->x2 - pBox->x1) + 31) >> 5;
#else
- dwords = (pBox->x2 - pBox->x1 + 31) >> 5;
+ dwords = (pBox->x2 - pBox->x1 + 31) >> 5;
#endif
-SECOND_PASS:
- if(TwoPass) {
- (*infoRec->SetupForCPUToScreenColorExpandFill)(pScrn,
- (FirstPass) ? bg : fg, -1, rop, planemask);
- StippleFunc = (FirstPass) ? FirstFunc : SecondFunc;
- }
+ SECOND_PASS:
+ if (TwoPass) {
+ (*infoRec->SetupForCPUToScreenColorExpandFill) (pScrn,
+ (FirstPass) ? bg :
+ fg, -1, rop,
+ planemask);
+ StippleFunc = (FirstPass) ? FirstFunc : SecondFunc;
+ }
+
+ h = pBox->y2 - pBox->y1;
+ flag = (infoRec->CPUToScreenColorExpandFillFlags
+ & CPU_TRANSFER_PAD_QWORD) && ((dwords * h) & 0x01);
- h = pBox->y2 - pBox->y1;
- flag = (infoRec->CPUToScreenColorExpandFillFlags
- & CPU_TRANSFER_PAD_QWORD) && ((dwords * h) & 0x01);
+ (*infoRec->SubsequentCPUToScreenColorExpandFill) (pScrn, pBox->x1,
+ pBox->y1,
+ pBox->x2 - pBox->x1,
+ h, 0);
- (*infoRec->SubsequentCPUToScreenColorExpandFill)(
- pScrn, pBox->x1, pBox->y1,
- pBox->x2 - pBox->x1, h, 0);
+ base = (CARD32 *) infoRec->ColorExpandBase;
- base = (CARD32*)infoRec->ColorExpandBase;
+ srcy = (pBox->y1 - yorg) % stippleheight;
+ if (srcy < 0)
+ srcy += stippleheight;
+ srcx = (pBox->x1 - xorg) % stipplewidth;
+ if (srcx < 0)
+ srcx += stipplewidth;
- srcy = (pBox->y1 - yorg) % stippleheight;
- if(srcy < 0) srcy += stippleheight;
- srcx = (pBox->x1 - xorg) % stipplewidth;
- if(srcx < 0) srcx += stipplewidth;
+ srcp = (srcwidth * srcy) + src;
- srcp = (srcwidth * srcy) + src;
-
#ifndef FIXEDBASE
- if((dwords * h) <= infoRec->ColorExpandRange) {
- while(h--) {
- base = (*StippleFunc)(
- base, (CARD32*)srcp, srcx, stipplewidth, dwords);
- srcy++;
- srcp += srcwidth;
- if (srcy >= stippleheight) {
- srcy = 0;
- srcp = src;
- }
- }
- } else
+ if ((dwords * h) <= infoRec->ColorExpandRange) {
+ while (h--) {
+ base =
+ (*StippleFunc) (base, (CARD32 *) srcp, srcx, stipplewidth,
+ dwords);
+ srcy++;
+ srcp += srcwidth;
+ if (srcy >= stippleheight) {
+ srcy = 0;
+ srcp = src;
+ }
+ }
+ }
+ else
#endif
- while(h--) {
- (*StippleFunc)(base, (CARD32*)srcp, srcx, stipplewidth, dwords);
- srcy++;
- srcp += srcwidth;
- if (srcy >= stippleheight) {
- srcy = 0;
- srcp = src;
- }
- }
-
- if (flag) {
- base = (CARD32*)infoRec->ColorExpandBase;
- base[0] = 0x00000000;
- }
-
- if(TwoPass) {
- if(FirstPass) {
- FirstPass = FALSE;
- goto SECOND_PASS;
- } else FirstPass = TRUE;
- }
-
- pBox++;
- }
-
- if(infoRec->CPUToScreenColorExpandFillFlags & SYNC_AFTER_COLOR_EXPAND)
- (*infoRec->Sync)(pScrn);
- else SET_SYNC_FLAG(infoRec);
-}
+ while (h--) {
+ (*StippleFunc) (base, (CARD32 *) srcp, srcx, stipplewidth,
+ dwords);
+ srcy++;
+ srcp += srcwidth;
+ if (srcy >= stippleheight) {
+ srcy = 0;
+ srcp = src;
+ }
+ }
+
+ if (flag) {
+ base = (CARD32 *) infoRec->ColorExpandBase;
+ base[0] = 0x00000000;
+ }
+ if (TwoPass) {
+ if (FirstPass) {
+ FirstPass = FALSE;
+ goto SECOND_PASS;
+ }
+ else
+ FirstPass = TRUE;
+ }
+ pBox++;
+ }
+
+ if (infoRec->CPUToScreenColorExpandFillFlags & SYNC_AFTER_COLOR_EXPAND)
+ (*infoRec->Sync) (pScrn);
+ else
+ SET_SYNC_FLAG(infoRec);
+}
void
#ifdef TRIPLE_BITS
-EXPNAME(XAAFillColorExpandSpans3)(
+ EXPNAME(XAAFillColorExpandSpans3) (
#else
-EXPNAME(XAAFillColorExpandSpans)(
+ EXPNAME(XAAFillColorExpandSpans) (
#endif
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-){
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg, PixmapPtr pPix) {
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
CARD32 *base;
Bool TwoPass = FALSE, FirstPass = TRUE;
@@ -266,106 +273,114 @@ EXPNAME(XAAFillColorExpandSpans)(
int dwords, srcy, srcx, funcNo = 2;
unsigned char *srcp;
- if(stipplewidth <= 32) {
- if(stipplewidth & (stipplewidth - 1))
- funcNo = 1;
- else
- funcNo = 0;
- }
+ if (stipplewidth <= 32) {
+ if (stipplewidth & (stipplewidth - 1))
+ funcNo = 1;
+ else
+ funcNo = 0;
+ }
StippleFunc = stipple_scanline_func[funcNo];
SecondFunc = stipple_scanline_func[funcNo];
FirstFunc = stipple_scanline_func[funcNo + 3];
#ifdef TRIPLE_BITS
- if((bg == -1) ||
- (!(infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) &&
- (!(infoRec->CPUToScreenColorExpandFillFlags & RGB_EQUAL) ||
- (CHECK_RGB_EQUAL(bg))))) {
+ if ((bg == -1) ||
+ (!(infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) &&
+ (!(infoRec->CPUToScreenColorExpandFillFlags & RGB_EQUAL) ||
+ (CHECK_RGB_EQUAL(bg))))) {
#else
- if((bg == -1) ||
- !(infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) {
+ if ((bg == -1) ||
+ !(infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) {
#endif
- /* one pass */
- } else if((rop == GXcopy) && infoRec->FillSolidSpans) {
- /* one pass but we fill background rects first */
- (*infoRec->FillSolidSpans)(
- pScrn, bg, rop, planemask, n, ppt, pwidth, fSorted);
- bg = -1;
- } else {
- /* gotta do two passes */
- TwoPass = TRUE;
- }
-
- if(!TwoPass)
- (*infoRec->SetupForCPUToScreenColorExpandFill)(
- pScrn, fg, bg, rop, planemask);
-
- while(n--) {
+ /* one pass */
+ }
+ else if ((rop == GXcopy) && infoRec->FillSolidSpans) {
+ /* one pass but we fill background rects first */
+ (*infoRec->FillSolidSpans) (pScrn, bg, rop, planemask, n, ppt, pwidth,
+ fSorted);
+ bg = -1;
+ }
+ else {
+ /* gotta do two passes */
+ TwoPass = TRUE;
+ }
+
+ if (!TwoPass)
+ (*infoRec->SetupForCPUToScreenColorExpandFill) (pScrn, fg, bg, rop,
+ planemask);
+
+ while (n--) {
#ifdef TRIPLE_BITS
- dwords = (3 * *pwidth + 31) >> 5;
+ dwords = (3 * *pwidth + 31) >> 5;
#else
- dwords = (*pwidth + 31) >> 5;
+ dwords = (*pwidth + 31) >> 5;
#endif
- srcy = (ppt->y - yorg) % stippleheight;
- if(srcy < 0) srcy += stippleheight;
- srcx = (ppt->x - xorg) % stipplewidth;
- if(srcx < 0) srcx += stipplewidth;
-
- srcp = (pPix->devKind * srcy) + (unsigned char*)pPix->devPrivate.ptr;
-
-SECOND_PASS:
- if(TwoPass) {
- (*infoRec->SetupForCPUToScreenColorExpandFill)(pScrn,
- (FirstPass) ? bg : fg, -1, rop, planemask);
- StippleFunc = (FirstPass) ? FirstFunc : SecondFunc;
- }
-
- (*infoRec->SubsequentCPUToScreenColorExpandFill)(pScrn, ppt->x, ppt->y,
- *pwidth, 1, 0);
-
- base = (CARD32*)infoRec->ColorExpandBase;
-
- (*StippleFunc)(base, (CARD32*)srcp, srcx, stipplewidth, dwords);
-
- if((infoRec->CPUToScreenColorExpandFillFlags & CPU_TRANSFER_PAD_QWORD)
- && (dwords & 0x01)) {
- base = (CARD32*)infoRec->ColorExpandBase;
- base[0] = 0x00000000;
- }
-
- if(TwoPass) {
- if(FirstPass) {
- FirstPass = FALSE;
- goto SECOND_PASS;
- } else FirstPass = TRUE;
- }
-
- ppt++; pwidth++;
- }
-
- if(infoRec->CPUToScreenColorExpandFillFlags & SYNC_AFTER_COLOR_EXPAND)
- (*infoRec->Sync)(pScrn);
- else SET_SYNC_FLAG(infoRec);
-}
+ srcy = (ppt->y - yorg) % stippleheight;
+ if (srcy < 0)
+ srcy += stippleheight;
+ srcx = (ppt->x - xorg) % stipplewidth;
+ if (srcx < 0)
+ srcx += stipplewidth;
+
+ srcp = (pPix->devKind * srcy) + (unsigned char *) pPix->devPrivate.ptr;
+
+ SECOND_PASS:
+ if (TwoPass) {
+ (*infoRec->SetupForCPUToScreenColorExpandFill) (pScrn,
+ (FirstPass) ? bg :
+ fg, -1, rop,
+ planemask);
+ StippleFunc = (FirstPass) ? FirstFunc : SecondFunc;
+ }
+
+ (*infoRec->SubsequentCPUToScreenColorExpandFill) (pScrn, ppt->x, ppt->y,
+ *pwidth, 1, 0);
+
+ base = (CARD32 *) infoRec->ColorExpandBase;
+
+ (*StippleFunc) (base, (CARD32 *) srcp, srcx, stipplewidth, dwords);
+
+ if ((infoRec->CPUToScreenColorExpandFillFlags & CPU_TRANSFER_PAD_QWORD)
+ && (dwords & 0x01)) {
+ base = (CARD32 *) infoRec->ColorExpandBase;
+ base[0] = 0x00000000;
+ }
+
+ if (TwoPass) {
+ if (FirstPass) {
+ FirstPass = FALSE;
+ goto SECOND_PASS;
+ }
+ else
+ FirstPass = TRUE;
+ }
+ ppt++;
+ pwidth++;
+ }
+
+ if (infoRec->CPUToScreenColorExpandFillFlags & SYNC_AFTER_COLOR_EXPAND)
+ (*infoRec->Sync) (pScrn);
+ else
+ SET_SYNC_FLAG(infoRec);
+}
#ifndef FIXEDBASE
void
#ifdef TRIPLE_BITS
-EXPNAME(XAAFillScanlineColorExpandRects3)(
+ EXPNAME(XAAFillScanlineColorExpandRects3) (
#else
-EXPNAME(XAAFillScanlineColorExpandRects)(
+ EXPNAME(XAAFillScanlineColorExpandRects) (
#endif
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-){
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ PixmapPtr pPix) {
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
CARD32 *base;
Bool TwoPass = FALSE, FirstPass = TRUE;
@@ -377,110 +392,123 @@ EXPNAME(XAAFillScanlineColorExpandRects)(
unsigned char *src = pPix->devPrivate.ptr;
unsigned char *srcp;
- if(stipplewidth <= 32) {
- if(stipplewidth & (stipplewidth - 1))
- funcNo = 1;
- else
- funcNo = 0;
- }
+ if (stipplewidth <= 32) {
+ if (stipplewidth & (stipplewidth - 1))
+ funcNo = 1;
+ else
+ funcNo = 0;
+ }
StippleFunc = stipple_scanline_func[funcNo];
SecondFunc = stipple_scanline_func[funcNo];
FirstFunc = stipple_scanline_func[funcNo + 3];
#ifdef TRIPLE_BITS
- if((bg == -1) ||
- (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) &&
- (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags & RGB_EQUAL) ||
- (CHECK_RGB_EQUAL(bg))))) {
+ if ((bg == -1) ||
+ (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)
+ && (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags & RGB_EQUAL) ||
+ (CHECK_RGB_EQUAL(bg))))) {
#else
- if((bg == -1) ||
- !(infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) {
+ if ((bg == -1) ||
+ !(infoRec->
+ ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) {
#endif
- /* one pass */
- } else if((rop == GXcopy) && infoRec->FillSolidRects) {
- /* one pass but we fill background rects first */
- (*infoRec->FillSolidRects)(pScrn, bg, rop, planemask, nBox, pBox);
- bg = -1;
- } else {
- /* gotta do two passes */
- TwoPass = TRUE;
+ /* one pass */
+ }
+ else if ((rop == GXcopy) && infoRec->FillSolidRects) {
+ /* one pass but we fill background rects first */
+ (*infoRec->FillSolidRects) (pScrn, bg, rop, planemask, nBox, pBox);
+ bg = -1;
+ }
+ else {
+ /* gotta do two passes */
+ TwoPass = TRUE;
}
- if(!TwoPass)
- (*infoRec->SetupForScanlineCPUToScreenColorExpandFill)(
- pScrn, fg, bg, rop, planemask);
+ if (!TwoPass)
+ (*infoRec->SetupForScanlineCPUToScreenColorExpandFill) (pScrn, fg, bg,
+ rop, planemask);
- while(nBox--) {
+ while (nBox--) {
#ifdef TRIPLE_BITS
- dwords = (3 * (pBox->x2 - pBox->x1) + 31) >> 5;
+ dwords = (3 * (pBox->x2 - pBox->x1) + 31) >> 5;
#else
- dwords = (pBox->x2 - pBox->x1 + 31) >> 5;
+ dwords = (pBox->x2 - pBox->x1 + 31) >> 5;
#endif
-SECOND_PASS:
- if(TwoPass) {
- (*infoRec->SetupForScanlineCPUToScreenColorExpandFill)(pScrn,
- (FirstPass) ? bg : fg, -1, rop, planemask);
- StippleFunc = (FirstPass) ? FirstFunc : SecondFunc;
- }
-
- h = pBox->y2 - pBox->y1;
-
- (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)(
- pScrn, pBox->x1, pBox->y1, pBox->x2 - pBox->x1, h, 0);
-
- bufferNo = 0;
-
- srcy = (pBox->y1 - yorg) % stippleheight;
- if(srcy < 0) srcy += stippleheight;
- srcx = (pBox->x1 - xorg) % stipplewidth;
- if(srcx < 0) srcx += stipplewidth;
-
- srcp = (srcwidth * srcy) + src;
-
- while(h--) {
- base = (CARD32*)infoRec->ScanlineColorExpandBuffers[bufferNo];
- (*StippleFunc)(base, (CARD32*)srcp, srcx, stipplewidth, dwords);
- (*infoRec->SubsequentColorExpandScanline)(pScrn, bufferNo++);
- if(bufferNo >= infoRec->NumScanlineColorExpandBuffers)
- bufferNo = 0;
- srcy++;
- srcp += srcwidth;
- if (srcy >= stippleheight) {
- srcy = 0;
- srcp = src;
- }
- }
-
- if(TwoPass) {
- if(FirstPass) {
- FirstPass = FALSE;
- goto SECOND_PASS;
- } else FirstPass = TRUE;
- }
-
- pBox++;
- }
-
- SET_SYNC_FLAG(infoRec);
+ SECOND_PASS:
+ if (TwoPass) {
+ (*infoRec->SetupForScanlineCPUToScreenColorExpandFill) (pScrn,
+ (FirstPass)
+ ? bg : fg,
+ -1, rop,
+ planemask);
+ StippleFunc = (FirstPass) ? FirstFunc : SecondFunc;
+ }
+
+ h = pBox->y2 - pBox->y1;
+
+ (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill) (pScrn,
+ pBox->x1,
+ pBox->y1,
+ pBox->x2 -
+ pBox->x1, h,
+ 0);
+
+ bufferNo = 0;
+
+ srcy = (pBox->y1 - yorg) % stippleheight;
+ if (srcy < 0)
+ srcy += stippleheight;
+ srcx = (pBox->x1 - xorg) % stipplewidth;
+ if (srcx < 0)
+ srcx += stipplewidth;
+
+ srcp = (srcwidth * srcy) + src;
+
+ while (h--) {
+ base = (CARD32 *) infoRec->ScanlineColorExpandBuffers[bufferNo];
+ (*StippleFunc) (base, (CARD32 *) srcp, srcx, stipplewidth, dwords);
+ (*infoRec->SubsequentColorExpandScanline) (pScrn, bufferNo++);
+ if (bufferNo >= infoRec->NumScanlineColorExpandBuffers)
+ bufferNo = 0;
+ srcy++;
+ srcp += srcwidth;
+ if (srcy >= stippleheight) {
+ srcy = 0;
+ srcp = src;
+ }
+ }
+
+ if (TwoPass) {
+ if (FirstPass) {
+ FirstPass = FALSE;
+ goto SECOND_PASS;
+ }
+ else
+ FirstPass = TRUE;
+ }
+
+ pBox++;
+ }
+
+ SET_SYNC_FLAG(infoRec);
}
void
#ifdef TRIPLE_BITS
-EXPNAME(XAAFillScanlineColorExpandSpans3)(
+ EXPNAME(XAAFillScanlineColorExpandSpans3) (
#else
-EXPNAME(XAAFillScanlineColorExpandSpans)(
+ EXPNAME(XAAFillScanlineColorExpandSpans) (
#endif
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-){
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg,
+ PixmapPtr pPix) {
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
CARD32 *base;
Bool TwoPass = FALSE, FirstPass = TRUE;
@@ -490,377 +518,398 @@ EXPNAME(XAAFillScanlineColorExpandSpans)(
int dwords, srcy, srcx, funcNo = 2;
unsigned char *srcp;
- if(stipplewidth <= 32) {
- if(stipplewidth & (stipplewidth - 1))
- funcNo = 1;
- else
- funcNo = 0;
- }
+ if (stipplewidth <= 32) {
+ if (stipplewidth & (stipplewidth - 1))
+ funcNo = 1;
+ else
+ funcNo = 0;
+ }
StippleFunc = stipple_scanline_func[funcNo];
SecondFunc = stipple_scanline_func[funcNo];
FirstFunc = stipple_scanline_func[funcNo + 3];
#ifdef TRIPLE_BITS
- if((bg == -1) ||
- (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) &&
- (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags & RGB_EQUAL) ||
- (CHECK_RGB_EQUAL(bg))))) {
+ if ((bg == -1) ||
+ (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)
+ && (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags & RGB_EQUAL) ||
+ (CHECK_RGB_EQUAL(bg))))) {
#else
- if((bg == -1) ||
- !(infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) {
+ if ((bg == -1) ||
+ !(infoRec->
+ ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) {
#endif
- /* one pass */
- } else if((rop == GXcopy) && infoRec->FillSolidSpans) {
- /* one pass but we fill background rects first */
- (*infoRec->FillSolidSpans)(
- pScrn, bg, rop, planemask, n, ppt, pwidth, fSorted);
- bg = -1;
- } else {
- /* gotta do two passes */
- TwoPass = TRUE;
+ /* one pass */
+ }
+ else if ((rop == GXcopy) && infoRec->FillSolidSpans) {
+ /* one pass but we fill background rects first */
+ (*infoRec->FillSolidSpans) (pScrn, bg, rop, planemask, n, ppt, pwidth,
+ fSorted);
+ bg = -1;
+ }
+ else {
+ /* gotta do two passes */
+ TwoPass = TRUE;
}
- if(!TwoPass)
- (*infoRec->SetupForScanlineCPUToScreenColorExpandFill)(
- pScrn, fg, bg, rop, planemask);
-
+ if (!TwoPass)
+ (*infoRec->SetupForScanlineCPUToScreenColorExpandFill) (pScrn, fg, bg,
+ rop, planemask);
- while(n--) {
+ while (n--) {
#ifdef TRIPLE_BITS
- dwords = (3 * *pwidth + 31) >> 5;
+ dwords = (3 * *pwidth + 31) >> 5;
#else
- dwords = (*pwidth + 31) >> 5;
+ dwords = (*pwidth + 31) >> 5;
#endif
- srcy = (ppt->y - yorg) % stippleheight;
- if(srcy < 0) srcy += stippleheight;
- srcx = (ppt->x - xorg) % stipplewidth;
- if(srcx < 0) srcx += stipplewidth;
-
- srcp = (pPix->devKind * srcy) + (unsigned char*)pPix->devPrivate.ptr;
+ srcy = (ppt->y - yorg) % stippleheight;
+ if (srcy < 0)
+ srcy += stippleheight;
+ srcx = (ppt->x - xorg) % stipplewidth;
+ if (srcx < 0)
+ srcx += stipplewidth;
+
+ srcp = (pPix->devKind * srcy) + (unsigned char *) pPix->devPrivate.ptr;
+
+ SECOND_PASS:
+ if (TwoPass) {
+ (*infoRec->SetupForScanlineCPUToScreenColorExpandFill) (pScrn,
+ (FirstPass)
+ ? bg : fg,
+ -1, rop,
+ planemask);
+ StippleFunc = (FirstPass) ? FirstFunc : SecondFunc;
+ }
-SECOND_PASS:
- if(TwoPass) {
- (*infoRec->SetupForScanlineCPUToScreenColorExpandFill)(pScrn,
- (FirstPass) ? bg : fg, -1, rop, planemask);
- StippleFunc = (FirstPass) ? FirstFunc : SecondFunc;
- }
+ (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill) (pScrn, ppt->x,
+ ppt->y,
+ *pwidth, 1,
+ 0);
- (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)(
- pScrn, ppt->x, ppt->y, *pwidth, 1, 0);
+ base = (CARD32 *) infoRec->ScanlineColorExpandBuffers[0];
- base = (CARD32*)infoRec->ScanlineColorExpandBuffers[0];
+ (*StippleFunc) (base, (CARD32 *) srcp, srcx, stipplewidth, dwords);
+ (*infoRec->SubsequentColorExpandScanline) (pScrn, 0);
- (*StippleFunc)(base, (CARD32*)srcp, srcx, stipplewidth, dwords);
- (*infoRec->SubsequentColorExpandScanline)(pScrn, 0);
-
- if(TwoPass) {
- if(FirstPass) {
- FirstPass = FALSE;
- goto SECOND_PASS;
- } else FirstPass = TRUE;
- }
+ if (TwoPass) {
+ if (FirstPass) {
+ FirstPass = FALSE;
+ goto SECOND_PASS;
+ }
+ else
+ FirstPass = TRUE;
+ }
- ppt++; pwidth++;
- }
+ ppt++;
+ pwidth++;
+ }
- SET_SYNC_FLAG(infoRec);
+ SET_SYNC_FLAG(infoRec);
}
#endif
static CARD32 *
-StipplePowerOfTwo(
- CARD32* dest, CARD32* src,
- int shift, int width, int dwords
-){
+StipplePowerOfTwo(CARD32 *dest, CARD32 *src, int shift, int width, int dwords)
+{
CARD32 pat = *src;
- if(width < 32) {
- pat &= XAAShiftMasks[width];
- while(width < 32) {
- pat |= SHIFT_L(pat,width);
- width <<= 1;
- }
+
+ if (width < 32) {
+ pat &= XAAShiftMasks[width];
+ while (width < 32) {
+ pat |= SHIFT_L(pat, width);
+ width <<= 1;
+ }
}
-
- if(shift)
- pat = SHIFT_R(pat,shift) | SHIFT_L(pat,32 - shift);
+
+ if (shift)
+ pat = SHIFT_R(pat, shift) | SHIFT_L(pat, 32 - shift);
#ifdef MSBFIRST
- pat = SWAP_BITS_IN_BYTES(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;
- DEST(2) = pat;
- DEST(3) = pat;
- dwords -= 4;
+ EXPAND_PAT;
+
+ while (dwords >= 3) {
+ WRITE_PAT3;
+ dwords -= 3;
+ }
+ if (dwords == 2) {
+ WRITE_PAT2;
+ }
+ else if (dwords == 1) {
+ WRITE_PAT1;
+ }
+
+ return dest;
+ }
+#else /* TRIPLE_BITS */
+ while (dwords >= 4) {
+ DEST(0) = pat;
+ DEST(1) = pat;
+ DEST(2) = pat;
+ DEST(3) = pat;
+ dwords -= 4;
#ifndef FIXEDBASE
- dest += 4;
+ dest += 4;
#endif
- }
-
- if(!dwords) return dest;
- DEST(0) = pat;
- if(dwords == 1) RETURN(1);
- DEST(1) = pat;
- if(dwords == 2) RETURN(2);
- DEST(2) = pat;
- RETURN(3);
-#endif /* TRIPLE_BITS */
+ }
+
+ if (!dwords)
+ return dest;
+ DEST(0) = pat;
+ if (dwords == 1)
+ RETURN(1);
+ DEST(1) = pat;
+ if (dwords == 2)
+ RETURN(2);
+ DEST(2) = pat;
+ RETURN(3);
+#endif /* TRIPLE_BITS */
}
static CARD32 *
-StipplePowerOfTwo_Inverted(
- CARD32* dest, CARD32* src,
- int shift, int width, int dwords
-){
+StipplePowerOfTwo_Inverted(CARD32 *dest, CARD32 *src,
+ int shift, int width, int dwords)
+{
CARD32 pat = *src;
- if(width < 32) {
- pat &= XAAShiftMasks[width];
- while(width < 32) {
- pat |= SHIFT_L(pat,width);
- width <<= 1;
- }
+
+ if (width < 32) {
+ pat &= XAAShiftMasks[width];
+ while (width < 32) {
+ pat |= SHIFT_L(pat, width);
+ width <<= 1;
+ }
}
-
- if(shift)
- pat = SHIFT_R(pat,shift) | SHIFT_L(pat,32 - shift);
+
+ if (shift)
+ pat = SHIFT_R(pat, shift) | SHIFT_L(pat, 32 - shift);
#ifdef MSBFIRST
- pat = SWAP_BITS_IN_BYTES(pat);
+ pat = SWAP_BITS_IN_BYTES(pat);
#endif
- pat = ~pat;
+ pat = ~pat;
#ifdef TRIPLE_BITS
{
- EXPAND_PAT;
-
- while(dwords >= 3) {
- WRITE_PAT3;
- dwords -= 3;
- }
- if (dwords == 2) {
- WRITE_PAT2;
- } else if (dwords == 1) {
- WRITE_PAT1;
- }
-
- return dest;
- }
-#else /* TRIPLE_BITS */
- while(dwords >= 4) {
- DEST(0) = pat;
- DEST(1) = pat;
- DEST(2) = pat;
- DEST(3) = pat;
- dwords -= 4;
+ EXPAND_PAT;
+
+ while (dwords >= 3) {
+ WRITE_PAT3;
+ dwords -= 3;
+ }
+ if (dwords == 2) {
+ WRITE_PAT2;
+ }
+ else if (dwords == 1) {
+ WRITE_PAT1;
+ }
+
+ return dest;
+ }
+#else /* TRIPLE_BITS */
+ while (dwords >= 4) {
+ DEST(0) = pat;
+ DEST(1) = pat;
+ DEST(2) = pat;
+ DEST(3) = pat;
+ dwords -= 4;
#ifndef FIXEDBASE
- dest += 4;
+ dest += 4;
#endif
- }
-
- if(!dwords) return dest;
- DEST(0) = pat;
- if(dwords == 1) RETURN(1);
- DEST(1) = pat;
- if(dwords == 2) RETURN(2);
- DEST(2) = pat;
- RETURN(3);
-#endif /* TRIPLE_BITS */
-}
+ }
+ if (!dwords)
+ return dest;
+ DEST(0) = pat;
+ if (dwords == 1)
+ RETURN(1);
+ DEST(1) = pat;
+ if (dwords == 2)
+ RETURN(2);
+ DEST(2) = pat;
+ RETURN(3);
+#endif /* TRIPLE_BITS */
+}
static CARD32 *
-StippleUpTo32(
- CARD32* base, CARD32* src,
- int shift, int width, int dwords
-){
+StippleUpTo32(CARD32 *base, CARD32 *src, int shift, int width, int dwords)
+{
CARD32 pat = *src & XAAShiftMasks[width];
- while(width <= 15) {
- pat |= SHIFT_L(pat,width);
- width <<= 1;
+ while (width <= 15) {
+ pat |= SHIFT_L(pat, width);
+ width <<= 1;
}
- pat |= SHIFT_L(pat,width);
+ pat |= SHIFT_L(pat, width);
+
+ while (dwords--) {
+ CARD32 bits = SHIFT_R(pat, shift) | SHIFT_L(pat, width - shift);
- while(dwords--) {
- CARD32 bits = SHIFT_R(pat,shift) | SHIFT_L(pat,width-shift);
#ifdef TRIPLE_BITS
- if(dwords >= 2) {
- WRITE_BITS3(bits);
- dwords -= 2;
- } else if(dwords > 0) {
- WRITE_BITS2(bits);
- dwords--;
- } else {
- WRITE_BITS1(bits);
- }
+ if (dwords >= 2) {
+ WRITE_BITS3(bits);
+ dwords -= 2;
+ }
+ else if (dwords > 0) {
+ WRITE_BITS2(bits);
+ dwords--;
+ }
+ else {
+ WRITE_BITS1(bits);
+ }
#else
- WRITE_BITS(bits);
+ WRITE_BITS(bits);
#endif
- shift += 32;
- shift %= width;
+ shift += 32;
+ shift %= width;
}
return base;
}
-
static CARD32 *
-StippleUpTo32_Inverted(
- CARD32* base, CARD32* src,
- int shift, int width, int dwords
-){
+StippleUpTo32_Inverted(CARD32 *base, CARD32 *src,
+ int shift, int width, int dwords)
+{
CARD32 pat = *src & XAAShiftMasks[width];
- while(width <= 15) {
- pat |= SHIFT_L(pat,width);
- width <<= 1;
+ while (width <= 15) {
+ pat |= SHIFT_L(pat, width);
+ width <<= 1;
}
- pat |= SHIFT_L(pat,width);
+ pat |= SHIFT_L(pat, width);
+
+ while (dwords--) {
+ CARD32 bits = ~(SHIFT_R(pat, shift) | SHIFT_L(pat, width - shift));
- while(dwords--) {
- CARD32 bits = ~(SHIFT_R(pat,shift) | SHIFT_L(pat,width-shift));
#ifdef TRIPLE_BITS
- if(dwords >= 2) {
- WRITE_BITS3(bits);
- dwords -= 2;
- } else if(dwords > 0) {
- WRITE_BITS2(bits);
- dwords--;
- } else {
- WRITE_BITS1(bits);
- }
+ if (dwords >= 2) {
+ WRITE_BITS3(bits);
+ dwords -= 2;
+ }
+ else if (dwords > 0) {
+ WRITE_BITS2(bits);
+ dwords--;
+ }
+ else {
+ WRITE_BITS1(bits);
+ }
#else
- WRITE_BITS(bits);
+ WRITE_BITS(bits);
#endif
- shift += 32;
- shift %= width;
+ shift += 32;
+ shift %= width;
}
return base;
}
-
static CARD32 *
-StippleOver32(
- CARD32* base, CARD32* src,
- int offset, int width, int dwords
-){
- CARD32* srcp;
- CARD32 bits;
- int bitsleft, shift, usable;
-
- while(dwords--) {
+StippleOver32(CARD32 *base, CARD32 *src, int offset, int width, int dwords)
+{
+ CARD32 *srcp;
+ CARD32 bits;
+ int bitsleft, shift, usable;
+
+ while (dwords--) {
bitsleft = width - offset;
srcp = src + (offset >> 5);
shift = offset & 31;
usable = 32 - shift;
- if(bitsleft < 32) {
- if(bitsleft <= usable) {
- bits = SHIFT_L(*src,bitsleft) |
- (SHIFT_R(*srcp,shift) & XAAShiftMasks[bitsleft]);
- } else {
- bits = SHIFT_L(*src,bitsleft) |
- (SHIFT_L(srcp[1],usable) & XAAShiftMasks[bitsleft]) |
- (SHIFT_R(*srcp,shift) & XAAShiftMasks[usable]);
+ if (bitsleft < 32) {
+ if (bitsleft <= usable) {
+ bits = SHIFT_L(*src, bitsleft) |
+ (SHIFT_R(*srcp, shift) & XAAShiftMasks[bitsleft]);
+ }
+ else {
+ bits = SHIFT_L(*src, bitsleft) |
+ (SHIFT_L(srcp[1], usable) & XAAShiftMasks[bitsleft]) |
+ (SHIFT_R(*srcp, shift) & XAAShiftMasks[usable]);
}
}
- else if(shift)
- bits = SHIFT_R(*srcp,shift) | SHIFT_L(srcp[1],usable);
+ else if (shift)
+ bits = SHIFT_R(*srcp, shift) | SHIFT_L(srcp[1], usable);
else
bits = *srcp;
#ifdef TRIPLE_BITS
- if(dwords >= 2) {
- WRITE_BITS3(bits);
- dwords -= 2;
- } else if(dwords > 0) {
- WRITE_BITS2(bits);
- dwords--;
- } else {
- WRITE_BITS1(bits);
- }
+ if (dwords >= 2) {
+ WRITE_BITS3(bits);
+ dwords -= 2;
+ }
+ else if (dwords > 0) {
+ WRITE_BITS2(bits);
+ dwords--;
+ }
+ else {
+ WRITE_BITS1(bits);
+ }
#else
- WRITE_BITS(bits);
+ WRITE_BITS(bits);
#endif
- offset += 32;
- offset %= width;
- }
- return base;
+ offset += 32;
+ offset %= width;
+ }
+ return base;
}
-
static CARD32 *
-StippleOver32_Inverted(
- CARD32* base, CARD32* src,
- int offset, int width, int dwords
-){
- CARD32* srcp;
- CARD32 bits;
- int bitsleft, shift, usable;
-
- while(dwords--) {
+StippleOver32_Inverted(CARD32 *base, CARD32 *src,
+ int offset, int width, int dwords)
+{
+ CARD32 *srcp;
+ CARD32 bits;
+ int bitsleft, shift, usable;
+
+ while (dwords--) {
bitsleft = width - offset;
srcp = src + (offset >> 5);
shift = offset & 31;
usable = 32 - shift;
- if(bitsleft < 32) {
- if(bitsleft <= usable) {
- bits = SHIFT_L(*src,bitsleft) |
- (SHIFT_R(*srcp,shift) & XAAShiftMasks[bitsleft]);
- } else {
- bits = SHIFT_L(*src,bitsleft) |
- (SHIFT_L(srcp[1],usable) & XAAShiftMasks[bitsleft]) |
- (SHIFT_R(*srcp,shift) & XAAShiftMasks[usable]);
+ if (bitsleft < 32) {
+ if (bitsleft <= usable) {
+ bits = SHIFT_L(*src, bitsleft) |
+ (SHIFT_R(*srcp, shift) & XAAShiftMasks[bitsleft]);
+ }
+ else {
+ bits = SHIFT_L(*src, bitsleft) |
+ (SHIFT_L(srcp[1], usable) & XAAShiftMasks[bitsleft]) |
+ (SHIFT_R(*srcp, shift) & XAAShiftMasks[usable]);
}
}
- else if(shift)
- bits = SHIFT_R(*srcp,shift) | SHIFT_L(srcp[1],usable);
+ else if (shift)
+ bits = SHIFT_R(*srcp, shift) | SHIFT_L(srcp[1], usable);
else
bits = *srcp;
- bits = ~bits;
+ bits = ~bits;
#ifdef TRIPLE_BITS
- if(dwords >= 2) {
- WRITE_BITS3(bits);
- dwords -= 2;
- } else if(dwords > 0) {
- WRITE_BITS2(bits);
- dwords--;
- } else {
- WRITE_BITS1(bits);
- }
+ if (dwords >= 2) {
+ WRITE_BITS3(bits);
+ dwords -= 2;
+ }
+ else if (dwords > 0) {
+ WRITE_BITS2(bits);
+ dwords--;
+ }
+ else {
+ WRITE_BITS1(bits);
+ }
#else
- WRITE_BITS(bits);
+ WRITE_BITS(bits);
#endif
- offset += 32;
- offset %= width;
- }
- return base;
+ offset += 32;
+ offset %= width;
+ }
+ return base;
}
diff --git a/xorg-server/hw/xfree86/xaa/xaaTEGlyph.c b/xorg-server/hw/xfree86/xaa/xaaTEGlyph.c
index 049bb2cb3..2926c1df2 100644
--- a/xorg-server/hw/xfree86/xaa/xaaTEGlyph.c
+++ b/xorg-server/hw/xfree86/xaa/xaaTEGlyph.c
@@ -1,1077 +1,1083 @@
-
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xaa.h"
-#include "xaalocal.h"
-#include "xaacexp.h"
-#include "xf86.h"
-
-/* scanline function for TRIPLE_BITS_24BPP */
-static CARD32 *DrawTextScanline3(CARD32 *base, CARD32 *mem, int width);
-
-/* Loop unrolled functions for common font widths */
-static CARD32 *DrawTETextScanlineGeneric(CARD32 *base, unsigned int **glyphp,
- int line, int width, int glyphwidth);
-static CARD32 *DrawTETextScanlineWidth7(CARD32 *base, unsigned int **glyphp,
- int line, int width, int glyphwidth);
-static CARD32 *DrawTETextScanlineWidth10(CARD32 *base, unsigned int **glyphp,
- int line, int width, int glyphwidth);
-static CARD32 *DrawTETextScanlineWidth12(CARD32 *base, unsigned int **glyphp,
- int line, int width, int glyphwidth);
-static CARD32 *DrawTETextScanlineWidth14(CARD32 *base, unsigned int **glyphp,
- int line, int width, int glyphwidth);
-static CARD32 *DrawTETextScanlineWidth16(CARD32 *base, unsigned int **glyphp,
- int line, int width, int glyphwidth);
-static CARD32 *DrawTETextScanlineWidth18(CARD32 *base, unsigned int **glyphp,
- int line, int width, int glyphwidth);
-static CARD32 *DrawTETextScanlineWidth24(CARD32 *base, unsigned int **glyphp,
- int line, int width, int glyphwidth);
-
-
-#ifdef USEASSEMBLER
-# ifdef FIXEDBASE
-# ifdef MSBFIRST
-CARD32 *DrawTETextScanlineWidth6PMSBFirstFixedBase(CARD32 *base,
- unsigned int **glyphp, int line, int width, int glyphwidth);
-CARD32 *DrawTETextScanlineWidth8PMSBFirstFixedBase(CARD32 *base,
- unsigned int **glyphp, int line, int width, int glyphwidth);
-CARD32 *DrawTETextScanlineWidth9PMSBFirstFixedBase(CARD32 *base,
- unsigned int **glyphp, int line, int width, int glyphwidth);
-# else
-CARD32 *DrawTETextScanlineWidth6PLSBFirstFixedBase(CARD32 *base,
- unsigned int **glyphp, int line, int width, int glyphwidth);
-CARD32 *DrawTETextScanlineWidth8PLSBFirstFixedBase(CARD32 *base,
- unsigned int **glyphp, int line, int width, int glyphwidth);
-CARD32 *DrawTETextScanlineWidth9PLSBFirstFixedBase(CARD32 *base,
- unsigned int **glyphp, int line, int width, int glyphwidth);
-# endif
-# else
-# ifdef MSBFIRST
-CARD32 *DrawTETextScanlineWidth6PMSBFirst(CARD32 *base, unsigned int **glyphp,
- int line, int width, int glyphwidth);
-CARD32 *DrawTETextScanlineWidth8PMSBFirst(CARD32 *base, unsigned int **glyphp,
- int line, int width, int glyphwidth);
-CARD32 *DrawTETextScanlineWidth9PMSBFirst(CARD32 *base, unsigned int **glyphp,
- int line, int width, int glyphwidth);
-# else
-CARD32 *DrawTETextScanlineWidth6PLSBFirst(CARD32 *base, unsigned int **glyphp,
- int line, int width, int glyphwidth);
-CARD32 *DrawTETextScanlineWidth8PLSBFirst(CARD32 *base, unsigned int **glyphp,
- int line, int width, int glyphwidth);
-CARD32 *DrawTETextScanlineWidth9PLSBFirst(CARD32 *base, unsigned int **glyphp,
- int line, int width, int glyphwidth);
-# endif
-# endif
-#else
-static CARD32 *DrawTETextScanlineWidth6(CARD32 *base, unsigned int **glyphp,
- int line, int width, int glyphwidth);
-static CARD32 *DrawTETextScanlineWidth8(CARD32 *base, unsigned int **glyphp,
- int line, int width, int glyphwidth);
-static CARD32 *DrawTETextScanlineWidth9(CARD32 *base, unsigned int **glyphp,
- int line, int width, int glyphwidth);
-#endif
-
-#define glyph_scanline_func EXPNAME(XAAGlyphScanlineFunc)
-#define glyph_get_scanline_func EXPNAME(XAAGetGlyphScanlineFunc)
-
-
-GlyphScanlineFuncPtr glyph_scanline_func[32] = {
- DrawTETextScanlineGeneric, DrawTETextScanlineGeneric,
- DrawTETextScanlineGeneric, DrawTETextScanlineGeneric,
- DrawTETextScanlineGeneric,
-#ifdef USEASSEMBLER
-# ifdef FIXEDBASE
-# ifdef MSBFIRST
- DrawTETextScanlineWidth6PMSBFirstFixedBase,
- DrawTETextScanlineWidth7,
- DrawTETextScanlineWidth8PMSBFirstFixedBase,
- DrawTETextScanlineWidth9PMSBFirstFixedBase,
-# else
- DrawTETextScanlineWidth6PLSBFirstFixedBase,
- DrawTETextScanlineWidth7,
- DrawTETextScanlineWidth8PLSBFirstFixedBase,
- DrawTETextScanlineWidth9PLSBFirstFixedBase,
-# endif
-# else
-# ifdef MSBFIRST
- DrawTETextScanlineWidth6PMSBFirst,
- DrawTETextScanlineWidth7,
- DrawTETextScanlineWidth8PMSBFirst,
- DrawTETextScanlineWidth9PMSBFirst,
-# else
- DrawTETextScanlineWidth6PLSBFirst,
- DrawTETextScanlineWidth7,
- DrawTETextScanlineWidth8PLSBFirst,
- DrawTETextScanlineWidth9PLSBFirst,
-# endif
-# endif
-#else
- DrawTETextScanlineWidth6, DrawTETextScanlineWidth7,
- DrawTETextScanlineWidth8, DrawTETextScanlineWidth9,
-#endif
- DrawTETextScanlineWidth10,
- DrawTETextScanlineGeneric, DrawTETextScanlineWidth12,
- DrawTETextScanlineGeneric, DrawTETextScanlineWidth14,
- DrawTETextScanlineGeneric, DrawTETextScanlineWidth16,
- DrawTETextScanlineGeneric, DrawTETextScanlineWidth18,
- DrawTETextScanlineGeneric, DrawTETextScanlineGeneric,
- DrawTETextScanlineGeneric, DrawTETextScanlineGeneric,
- DrawTETextScanlineGeneric, DrawTETextScanlineWidth24,
- DrawTETextScanlineGeneric, DrawTETextScanlineGeneric,
- DrawTETextScanlineGeneric, DrawTETextScanlineGeneric,
- DrawTETextScanlineGeneric, DrawTETextScanlineGeneric,
- DrawTETextScanlineGeneric, DrawTETextScanlineGeneric
-};
-
-GlyphScanlineFuncPtr *glyph_get_scanline_func(void) {
- return glyph_scanline_func;
-}
-
-
-/********************************************************************
-
- Here we have TEGlyphRenders for a bunch of different color
- expansion types. The driver may provide its own renderer, but
- this is the default one which renders using lower-level primitives
- exported by the chipset driver.
-
-********************************************************************/
-
-/* This gets built for MSBFIRST or LSBFIRST with FIXEDBASE or not.
- A total of 4 versions */
-
-void
-EXPNAME(XAATEGlyphRenderer)(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- CARD32* base;
- GlyphScanlineFuncPtr GlyphFunc = glyph_scanline_func[glyphWidth - 1];
- int dwords = 0;
-
- if((bg != -1) && (infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) {
- (*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask);
- (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h);
- bg = -1;
- }
-
- (*infoRec->SetupForCPUToScreenColorExpandFill)(
- pScrn, fg, bg, rop, planemask);
-
- if(skipleft &&
- (!(infoRec->TEGlyphRendererFlags & LEFT_EDGE_CLIPPING) ||
- (!(infoRec->TEGlyphRendererFlags & LEFT_EDGE_CLIPPING_NEGATIVE_X) &&
- (skipleft > x)))) {
- /* draw the first character only */
-
- int count = h, line = startline;
- int width = glyphWidth - skipleft;
-
- if(width > w) width = w;
-
- (*infoRec->SubsequentCPUToScreenColorExpandFill)(
- pScrn, x, y, width, h, 0);
-
- base = (CARD32*)infoRec->ColorExpandBase;
-
- while(count--) {
- register CARD32 tmp = SHIFT_R(glyphs[0][line++],skipleft);
- WRITE_BITS(tmp);
- }
-
- w -= width;
- if((infoRec->TEGlyphRendererFlags & CPU_TRANSFER_PAD_QWORD) &&
- ((((width + 31) >> 5) * h) & 1)) {
- base = (CARD32*)infoRec->ColorExpandBase;
- base[0] = 0x00000000;
- }
- if(!w) goto THE_END;
- glyphs++;
- x += width;
- skipleft = 0; /* nicely aligned again */
- }
-
- w += skipleft;
- x -= skipleft;
- dwords = ((w + 31) >> 5) * h;
-
- (*infoRec->SubsequentCPUToScreenColorExpandFill)(
- pScrn, x, y, w, h, skipleft);
-
- base = (CARD32*)infoRec->ColorExpandBase;
-
-#ifndef FIXEDBASE
- if((((w + 31) >> 5) * h) <= infoRec->ColorExpandRange)
- while(h--) {
- base = (*GlyphFunc)(base, glyphs, startline++, w, glyphWidth);
- }
- else
-#endif
- while(h--) {
- (*GlyphFunc)(base, glyphs, startline++, w, glyphWidth);
- }
-
- if((infoRec->TEGlyphRendererFlags & CPU_TRANSFER_PAD_QWORD) &&
- (dwords & 1)) {
- base = (CARD32*)infoRec->ColorExpandBase;
- base[0] = 0x00000000;
- }
-
-THE_END:
-
- if(infoRec->TEGlyphRendererFlags & SYNC_AFTER_COLOR_EXPAND)
- (*infoRec->Sync)(pScrn);
- else SET_SYNC_FLAG(infoRec);
-}
-
-/********************************************************************
-
- This is the GlyphRenderer for TRIPLE_BITS_24BPP. It renders to a buffer
- with the non FIXEDBASE LSB_FIRST code before tripling, and possibly
- reversing the bits and sending them to the screen
-
-********************************************************************/
-
-void
-EXPNAME(XAATEGlyphRenderer3)(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- CARD32 *base, *mem;
- GlyphScanlineFuncPtr GlyphFunc = XAAGlyphScanlineFuncLSBFirst[glyphWidth - 1];
- int dwords = 0;
-
- if((bg != -1) &&
- ((infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY) ||
- ((infoRec->TEGlyphRendererFlags & RGB_EQUAL) &&
- (!CHECK_RGB_EQUAL(bg))))) {
- (*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask);
- (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h);
- bg = -1;
- }
-
- (*infoRec->SetupForCPUToScreenColorExpandFill)(
- pScrn, fg, bg, rop, planemask);
-
- if(skipleft) {
- /* draw the first character only */
-
- int count = h, line = startline;
- int width = glyphWidth - skipleft;
- CARD32 bits;
-
- if(width > w) width = w;
- (*infoRec->SubsequentCPUToScreenColorExpandFill)(
- pScrn, x, y, width, h, 0);
-
- base = (CARD32*)infoRec->ColorExpandBase;
-
- while(count--) {
- bits = SHIFT_R(glyphs[0][line++],skipleft);
- if (width >= 22) {
- WRITE_BITS3(bits);
- } else if (width >= 11) {
- WRITE_BITS2(bits);
- } else {
- WRITE_BITS1(bits);
- }
- }
-
- w -= width;
- if((infoRec->TEGlyphRendererFlags & CPU_TRANSFER_PAD_QWORD) &&
- ((((3 * width + 31) >> 5) * h) & 1)) {
- base = (CARD32*)infoRec->ColorExpandBase;
- base[0] = 0x00000000;
- }
- if(!w) goto THE_END;
- glyphs++;
- x += width;
- skipleft = 0; /* nicely aligned again */
- }
-
- dwords = ((3 * w + 31) >> 5) * h;
- mem = (CARD32*)malloc(((w + 31) >> 3) * sizeof(char));
- if (!mem) return;
-
- (*infoRec->SubsequentCPUToScreenColorExpandFill)(pScrn, x, y, w, h, 0);
-
- base = (CARD32*)infoRec->ColorExpandBase;
-
-# ifndef FIXEDBASE
- if((((3 * w + 31) >> 5) * h) <= infoRec->ColorExpandRange)
- while(h--) {
- (*GlyphFunc)(mem, glyphs, startline++, w, glyphWidth);
- base = DrawTextScanline3(base, mem, w);
- }
- else
-# endif
- while(h--) {
- (*GlyphFunc)(mem, glyphs, startline++, w, glyphWidth);
- DrawTextScanline3(base, mem, w);
- }
-
- free(mem);
-
- if((infoRec->TEGlyphRendererFlags & CPU_TRANSFER_PAD_QWORD) &&
- (dwords & 1)) {
- base = (CARD32*)infoRec->ColorExpandBase;
- base[0] = 0x00000000;
- }
-
-THE_END:
-
- if(infoRec->TEGlyphRendererFlags & SYNC_AFTER_COLOR_EXPAND)
- (*infoRec->Sync)(pScrn);
- else SET_SYNC_FLAG(infoRec);
-}
-
-
-#ifndef FIXEDBASE
-/* Scanline version of above gets built for LSBFIRST and MSBFIRST */
-
-void
-EXPNAME(XAATEGlyphRendererScanline)(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int bufferNo;
- CARD32* base;
- GlyphScanlineFuncPtr GlyphFunc = glyph_scanline_func[glyphWidth - 1];
-
- if((bg != -1) && (infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) {
- (*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask);
- (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h);
- bg = -1;
- }
-
- (*infoRec->SetupForScanlineCPUToScreenColorExpandFill)(
- pScrn, fg, bg, rop, planemask);
-
- if(skipleft &&
- (!(infoRec->TEGlyphRendererFlags & LEFT_EDGE_CLIPPING) ||
- (!(infoRec->TEGlyphRendererFlags & LEFT_EDGE_CLIPPING_NEGATIVE_X) &&
- (skipleft > x)))) {
- /* draw the first character only */
-
- int count = h, line = startline;
- int width = glyphWidth - skipleft;
-
- if(width > w) width = w;
-
- (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)(
- pScrn, x, y, width, h, 0);
-
- bufferNo = 0;
-
- while(count--) {
- register CARD32 tmp = SHIFT_R(glyphs[0][line++],skipleft);
- base = (CARD32*)infoRec->ScanlineColorExpandBuffers[bufferNo];
- WRITE_BITS(tmp);
- (*infoRec->SubsequentColorExpandScanline)(pScrn, bufferNo++);
- if(bufferNo >= infoRec->NumScanlineColorExpandBuffers)
- bufferNo = 0;
- }
-
- w -= width;
- if(!w) goto THE_END;
- glyphs++;
- x += width;
- skipleft = 0; /* nicely aligned again */
- }
-
- w += skipleft;
- x -= skipleft;
-
- (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)(
- pScrn, x, y, w, h, skipleft);
-
- bufferNo = 0;
-
- while(h--) {
- base = (CARD32*)infoRec->ScanlineColorExpandBuffers[bufferNo];
- (*GlyphFunc)(base, glyphs, startline++, w, glyphWidth);
- (*infoRec->SubsequentColorExpandScanline)(pScrn, bufferNo++);
- if(bufferNo >= infoRec->NumScanlineColorExpandBuffers)
- bufferNo = 0;
- }
-
-THE_END:
-
- SET_SYNC_FLAG(infoRec);
-}
-
-void
-EXPNAME(XAATEGlyphRendererScanline3)(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int bufferNo;
- CARD32 *base, *mem;
- GlyphScanlineFuncPtr GlyphFunc = XAAGlyphScanlineFuncLSBFirst[glyphWidth - 1];
-
- if((bg != -1) &&
- ((infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY) ||
- ((infoRec->TEGlyphRendererFlags & RGB_EQUAL) &&
- (!CHECK_RGB_EQUAL(bg))))) {
- (*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask);
- (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h);
- bg = -1;
- }
-
- (*infoRec->SetupForScanlineCPUToScreenColorExpandFill)(
- pScrn, fg, bg, rop, planemask);
-
- if(skipleft) {
- /* draw the first character only */
-
- int count = h, line = startline;
- int width = glyphWidth - skipleft;
- CARD32 bits;
-
- if(width > w) width = w;
-
- (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)(
- pScrn, x, y, width, h, 0);
-
- bufferNo = 0;
-
- while(count--) {
- base = (CARD32*)infoRec->ScanlineColorExpandBuffers[bufferNo];
- bits = SHIFT_R(glyphs[0][line++],skipleft);
- if (width >= 22) {
- WRITE_BITS3(bits);
- } else if (width >= 11) {
- WRITE_BITS2(bits);
- } else {
- WRITE_BITS1(bits);
- }
- (*infoRec->SubsequentColorExpandScanline)(pScrn, bufferNo++);
- if(bufferNo >= infoRec->NumScanlineColorExpandBuffers)
- bufferNo = 0;
- }
-
- w -= width;
- if(!w) goto THE_END;
- glyphs++;
- x += width;
- skipleft = 0; /* nicely aligned again */
- }
-
- w += skipleft;
- x -= skipleft;
- mem = (CARD32*)malloc(((w + 31) >> 3) * sizeof(char));
- if (!mem) return;
-
- (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)(
- pScrn, x, y, w, h, skipleft);
-
- bufferNo = 0;
-
- while(h--) {
- base = (CARD32*)infoRec->ScanlineColorExpandBuffers[bufferNo];
- (*GlyphFunc)(mem, glyphs, startline++, w, glyphWidth);
- DrawTextScanline3(base, mem, w);
- (*infoRec->SubsequentColorExpandScanline)(pScrn, bufferNo++);
- if(bufferNo >= infoRec->NumScanlineColorExpandBuffers)
- bufferNo = 0;
- }
-
- free(mem);
-
-THE_END:
-
- SET_SYNC_FLAG(infoRec);
-}
-
-#endif
-
-
-
-/********************************************************************
-
- TRIPLE_BITS_24BPP scanline rendering code.
-
-********************************************************************/
-
-
-
-static CARD32*
-DrawTextScanline3(
- CARD32 *base,
- CARD32 *mem,
- int width )
-{
-
- while(width > 32) {
- WRITE_BITS3(*mem);
- mem++;
- width -= 32;
- }
- if(width) {
- if (width >= 22) {
- WRITE_BITS3(*mem);
- } else if (width >= 11) {
- WRITE_BITS2(*mem);
- } else {
- WRITE_BITS1(*mem);
- }
- }
-
- return base;
-}
-
-
-/********************************************************************
-
- Generic TE scanline rendering code.
-
-********************************************************************/
-
-
-
-static CARD32*
-DrawTETextScanlineGeneric(
- CARD32 *base,
- unsigned int **glyphp,
- int line, int width, int glyphwidth )
-{
- CARD32 bits = (*glyphp)[line];
- int shift = glyphwidth;
-
- while(width > 32) {
- while(shift < 32) {
- glyphp++;
- bits |= SHIFT_L((*glyphp)[line], shift);
- shift += glyphwidth;
- }
- WRITE_BITS(bits);
- shift &= 31;
- if(shift)
- bits = SHIFT_R((*glyphp)[line],(glyphwidth - shift));
- else bits = 0;
- width -= 32;
- }
-
- if(width) {
- width -= shift;
- while(width > 0) {
- glyphp++;
- bits |= SHIFT_L((*glyphp)[line],shift);
- shift += glyphwidth;
- width -= glyphwidth;
- }
- WRITE_BITS(bits);
- }
-
- return base;
-}
-
-
-/********************************************************************
-
- Loop unrolled TE font scanline rendering code
-
-********************************************************************/
-
-
-#ifndef USEASSEMBLER
-static CARD32*
-DrawTETextScanlineWidth6(
- CARD32 *base,
- unsigned int **glyphp,
- int line, int width, int glyphwidth )
-{
- while (1) {
- unsigned int bits;
- bits = glyphp[0][line];
- bits |= SHIFT_L(glyphp[1][line],6);
- bits |= SHIFT_L(glyphp[2][line],12);
- bits |= SHIFT_L(glyphp[3][line],18);
- bits |= SHIFT_L(glyphp[4][line],24);
- bits |= SHIFT_L(glyphp[5][line],30);
- WRITE_IN_BITORDER(base, 0, bits);
- CHECKRETURN(1);
- bits = SHIFT_R(glyphp[5][line],2);
- bits |= SHIFT_L(glyphp[6][line],4);
- bits |= SHIFT_L(glyphp[7][line],10);
- bits |= SHIFT_L(glyphp[8][line],16);
- bits |= SHIFT_L(glyphp[9][line],22);
- bits |= SHIFT_L(glyphp[10][line],28);
- WRITE_IN_BITORDER(base, 1, bits);
- CHECKRETURN(2);
- bits = SHIFT_R(glyphp[10][line],4);
- bits |= SHIFT_L(glyphp[11][line],2);
- bits |= SHIFT_L(glyphp[12][line],8);
- bits |= SHIFT_L(glyphp[13][line],14);
- bits |= SHIFT_L(glyphp[14][line],20);
- bits |= SHIFT_L(glyphp[15][line],26);
- WRITE_IN_BITORDER(base, 2, bits);
- CHECKRETURN(3);
-#ifndef FIXEDBASE
- base += 3;
-#endif
- width -= 96;
- glyphp += 16;
- }
- return base;
-}
-#endif
-
-static CARD32*
-DrawTETextScanlineWidth7(
- CARD32 *base,
- unsigned int **glyphp,
- int line, int width, int glyphwidth )
-{
- while (1) {
- unsigned int bits;
- bits = glyphp[0][line];
- bits |= SHIFT_L(glyphp[1][line],7);
- bits |= SHIFT_L(glyphp[2][line],14);
- bits |= SHIFT_L(glyphp[3][line],21);
- bits |= SHIFT_L(glyphp[4][line],28);
- WRITE_IN_BITORDER(base, 0, bits);
- CHECKRETURN(1);
- bits = SHIFT_R(glyphp[4][line],4);
- bits |= SHIFT_L(glyphp[5][line],3);
- bits |= SHIFT_L(glyphp[6][line],10);
- bits |= SHIFT_L(glyphp[7][line],17);
- bits |= SHIFT_L(glyphp[8][line],24);
- bits |= SHIFT_L(glyphp[9][line],31);
- WRITE_IN_BITORDER(base, 1, bits);
- CHECKRETURN(2);
- bits = SHIFT_R(glyphp[9][line],1);
- bits |= SHIFT_L(glyphp[10][line],6);
- bits |= SHIFT_L(glyphp[11][line],13);
- bits |= SHIFT_L(glyphp[12][line],20);
- bits |= SHIFT_L(glyphp[13][line],27);
- WRITE_IN_BITORDER(base, 2, bits);
- CHECKRETURN(3);
- bits = SHIFT_R(glyphp[13][line],5);
- bits |= SHIFT_L(glyphp[14][line],2);
- bits |= SHIFT_L(glyphp[15][line],9);
- bits |= SHIFT_L(glyphp[16][line],16);
- bits |= SHIFT_L(glyphp[17][line],23);
- bits |= SHIFT_L(glyphp[18][line],30);
- WRITE_IN_BITORDER(base, 3, bits);
- CHECKRETURN(4);
- bits = SHIFT_R(glyphp[18][line],2);
- bits |= SHIFT_L(glyphp[19][line],5);
- bits |= SHIFT_L(glyphp[20][line],12);
- bits |= SHIFT_L(glyphp[21][line],19);
- bits |= SHIFT_L(glyphp[22][line],26);
- WRITE_IN_BITORDER(base, 4, bits);
- CHECKRETURN(5);
- bits = SHIFT_R(glyphp[22][line],6);
- bits |= SHIFT_L(glyphp[23][line],1);
- bits |= SHIFT_L(glyphp[24][line],8);
- bits |= SHIFT_L(glyphp[25][line],15);
- bits |= SHIFT_L(glyphp[26][line],22);
- bits |= SHIFT_L(glyphp[27][line],29);
- WRITE_IN_BITORDER(base, 5, bits);
- CHECKRETURN(6);
- bits = SHIFT_R(glyphp[27][line],3);
- bits |= SHIFT_L(glyphp[28][line],4);
- bits |= SHIFT_L(glyphp[29][line],11);
- bits |= SHIFT_L(glyphp[30][line],18);
- bits |= SHIFT_L(glyphp[31][line],25);
- WRITE_IN_BITORDER(base, 6, bits);
- CHECKRETURN(7);
-#ifndef FIXEDBASE
- base += 7;
-#endif
- width -= 224;
- glyphp += 32;
- }
- return base;
-}
-
-
-#ifndef USEASSEMBLER
-static CARD32*
-DrawTETextScanlineWidth8(
- CARD32 *base,
- unsigned int **glyphp,
- int line, int width, int glyphwidth )
-{
- while (1) {
- unsigned int bits;
- bits = glyphp[0][line];
- bits |= SHIFT_L(glyphp[1][line],8);
- bits |= SHIFT_L(glyphp[2][line],16);
- bits |= SHIFT_L(glyphp[3][line],24);
- WRITE_IN_BITORDER(base, 0, bits);
- CHECKRETURN(1);
- bits = glyphp[4][line];
- bits |= SHIFT_L(glyphp[5][line],8);
- bits |= SHIFT_L(glyphp[6][line],16);
- bits |= SHIFT_L(glyphp[7][line],24);
- WRITE_IN_BITORDER(base, 1, bits);
- CHECKRETURN(2);
-#ifndef FIXEDBASE
- base += 2;
-#endif
- width -= 64;
- glyphp += 8;
- }
- return base;
-}
-#endif
-
-#ifndef USEASSEMBLER
-static CARD32*
-DrawTETextScanlineWidth9(
- CARD32 *base,
- unsigned int **glyphp,
- int line, int width, int glyphwidth )
-{
- while (1) {
- unsigned int bits;
- bits = glyphp[0][line];
- bits |= SHIFT_L(glyphp[1][line],9);
- bits |= SHIFT_L(glyphp[2][line],18);
- bits |= SHIFT_L(glyphp[3][line],27);
- WRITE_IN_BITORDER(base, 0, bits);
- CHECKRETURN(1);
- bits = SHIFT_R(glyphp[3][line],5);
- bits |= SHIFT_L(glyphp[4][line],4);
- bits |= SHIFT_L(glyphp[5][line],13);
- bits |= SHIFT_L(glyphp[6][line],22);
- bits |= SHIFT_L(glyphp[7][line],31);
- WRITE_IN_BITORDER(base, 1, bits);
- CHECKRETURN(2);
- bits = SHIFT_R(glyphp[7][line],1);
- bits |= SHIFT_L(glyphp[8][line],8);
- bits |= SHIFT_L(glyphp[9][line],17);
- bits |= SHIFT_L(glyphp[10][line],26);
- WRITE_IN_BITORDER(base, 2, bits);
- CHECKRETURN(3);
- bits = SHIFT_R(glyphp[10][line],6);
- bits |= SHIFT_L(glyphp[11][line],3);
- bits |= SHIFT_L(glyphp[12][line],12);
- bits |= SHIFT_L(glyphp[13][line],21);
- bits |= SHIFT_L(glyphp[14][line],30);
- WRITE_IN_BITORDER(base, 3, bits);
- CHECKRETURN(4);
- bits = SHIFT_R(glyphp[14][line],2);
- bits |= SHIFT_L(glyphp[15][line],7);
- bits |= SHIFT_L(glyphp[16][line],16);
- bits |= SHIFT_L(glyphp[17][line],25);
- WRITE_IN_BITORDER(base, 4, bits);
- CHECKRETURN(5);
- bits = SHIFT_R(glyphp[17][line],7);
- bits |= SHIFT_L(glyphp[18][line],2);
- bits |= SHIFT_L(glyphp[19][line],11);
- bits |= SHIFT_L(glyphp[20][line],20);
- bits |= SHIFT_L(glyphp[21][line],29);
- WRITE_IN_BITORDER(base, 5, bits);
- CHECKRETURN(6);
- bits = SHIFT_R(glyphp[21][line],3);
- bits |= SHIFT_L(glyphp[22][line],6);
- bits |= SHIFT_L(glyphp[23][line],15);
- bits |= SHIFT_L(glyphp[24][line],24);
- WRITE_IN_BITORDER(base, 6, bits);
- CHECKRETURN(7);
- bits = SHIFT_R(glyphp[24][line],8);
- bits |= SHIFT_L(glyphp[25][line],1);
- bits |= SHIFT_L(glyphp[26][line],10);
- bits |= SHIFT_L(glyphp[27][line],19);
- bits |= SHIFT_L(glyphp[28][line],28);
- WRITE_IN_BITORDER(base, 7, bits);
- CHECKRETURN(8);
- bits = SHIFT_R(glyphp[28][line],4);
- bits |= SHIFT_L(glyphp[29][line],5);
- bits |= SHIFT_L(glyphp[30][line],14);
- bits |= SHIFT_L(glyphp[31][line],23);
- WRITE_IN_BITORDER(base, 8, bits);
- CHECKRETURN(9);
-#ifndef FIXEDBASE
- base += 9;
-#endif
- width -= 288;
- glyphp += 32;
- }
- return base;
-}
-#endif
-
-static CARD32*
-DrawTETextScanlineWidth10(
- CARD32 *base,
- unsigned int **glyphp,
- int line, int width, int glyphwidth )
-{
- while (1) {
- unsigned int bits;
- bits = glyphp[0][line];
- bits |= SHIFT_L(glyphp[1][line],10);
- bits |= SHIFT_L(glyphp[2][line],20);
- bits |= SHIFT_L(glyphp[3][line],30);
- WRITE_IN_BITORDER(base, 0, bits);
- CHECKRETURN(1);
- bits = SHIFT_R(glyphp[3][line],2);
- bits |= SHIFT_L(glyphp[4][line],8);
- bits |= SHIFT_L(glyphp[5][line],18);
- bits |= SHIFT_L(glyphp[6][line],28);
- WRITE_IN_BITORDER(base, 1, bits);
- CHECKRETURN(2);
- bits = SHIFT_R(glyphp[6][line],4);
- bits |= SHIFT_L(glyphp[7][line],6);
- bits |= SHIFT_L(glyphp[8][line],16);
- bits |= SHIFT_L(glyphp[9][line],26);
- WRITE_IN_BITORDER(base, 2, bits);
- CHECKRETURN(3);
- bits = SHIFT_R(glyphp[9][line],6);
- bits |= SHIFT_L(glyphp[10][line],4);
- bits |= SHIFT_L(glyphp[11][line],14);
- bits |= SHIFT_L(glyphp[12][line],24);
- WRITE_IN_BITORDER(base, 3, bits);
- CHECKRETURN(4);
- bits = SHIFT_R(glyphp[12][line],8);
- bits |= SHIFT_L(glyphp[13][line],2);
- bits |= SHIFT_L(glyphp[14][line],12);
- bits |= SHIFT_L(glyphp[15][line],22);
- WRITE_IN_BITORDER(base, 4, bits);
- CHECKRETURN(5);
-#ifndef FIXEDBASE
- base += 5;
-#endif
- width -= 160;
- glyphp += 16;
- }
- return base;
-}
-
-static CARD32*
-DrawTETextScanlineWidth12(
- CARD32 *base,
- unsigned int **glyphp,
- int line, int width, int glyphwidth )
-{
- while (1) {
- unsigned int bits;
- bits = glyphp[0][line];
- bits |= SHIFT_L(glyphp[1][line],12);
- bits |= SHIFT_L(glyphp[2][line],24);
- WRITE_IN_BITORDER(base, 0, bits);
- CHECKRETURN(1);
- bits = SHIFT_R(glyphp[2][line],8);
- bits |= SHIFT_L(glyphp[3][line],4);
- bits |= SHIFT_L(glyphp[4][line],16);
- bits |= SHIFT_L(glyphp[5][line],28);
- WRITE_IN_BITORDER(base, 1, bits);
- CHECKRETURN(2);
- bits = SHIFT_R(glyphp[5][line],4);
- bits |= SHIFT_L(glyphp[6][line],8);
- bits |= SHIFT_L(glyphp[7][line],20);
- WRITE_IN_BITORDER(base, 2, bits);
- CHECKRETURN(3);
-#ifndef FIXEDBASE
- base += 3;
-#endif
- width -= 96;
- glyphp += 8;
- }
- return base;
-}
-
-
-
-static CARD32*
-DrawTETextScanlineWidth14(
- CARD32 *base,
- unsigned int **glyphp,
- int line, int width, int glyphwidth )
-{
- while (1) {
- unsigned int bits;
- bits = glyphp[0][line];
- bits |= SHIFT_L(glyphp[1][line],14);
- bits |= SHIFT_L(glyphp[2][line],28);
- WRITE_IN_BITORDER(base, 0, bits);
- CHECKRETURN(1);
- bits = SHIFT_R(glyphp[2][line],4);
- bits |= SHIFT_L(glyphp[3][line],10);
- bits |= SHIFT_L(glyphp[4][line],24);
- WRITE_IN_BITORDER(base, 1, bits);
- CHECKRETURN(2);
- bits = SHIFT_R(glyphp[4][line],8);
- bits |= SHIFT_L(glyphp[5][line],6);
- bits |= SHIFT_L(glyphp[6][line],20);
- WRITE_IN_BITORDER(base, 2, bits);
- CHECKRETURN(3);
- bits = SHIFT_R(glyphp[6][line],12);
- bits |= SHIFT_L(glyphp[7][line],2);
- bits |= SHIFT_L(glyphp[8][line],16);
- bits |= SHIFT_L(glyphp[9][line],30);
- WRITE_IN_BITORDER(base, 3, bits);
- CHECKRETURN(4);
- bits = SHIFT_R(glyphp[9][line],2);
- bits |= SHIFT_L(glyphp[10][line],12);
- bits |= SHIFT_L(glyphp[11][line],26);
- WRITE_IN_BITORDER(base, 4, bits);
- CHECKRETURN(5);
- bits = SHIFT_R(glyphp[11][line],6);
- bits |= SHIFT_L(glyphp[12][line],8);
- bits |= SHIFT_L(glyphp[13][line],22);
- WRITE_IN_BITORDER(base, 5, bits);
- CHECKRETURN(6);
- bits = SHIFT_R(glyphp[13][line],10);
- bits |= SHIFT_L(glyphp[14][line],4);
- bits |= SHIFT_L(glyphp[15][line],18);
- WRITE_IN_BITORDER(base, 6, bits);
- CHECKRETURN(7);
-#ifndef FIXEDBASE
- base += 7;
-#endif
- width -= 224;
- glyphp += 16;
- }
- return base;
-}
-
-
-static CARD32*
-DrawTETextScanlineWidth16(
- CARD32 *base,
- unsigned int **glyphp,
- int line, int width, int glyphwidth )
-{
- while (1) {
- unsigned int bits;
- bits = glyphp[0][line];
- bits |= SHIFT_L(glyphp[1][line],16);
- WRITE_IN_BITORDER(base, 0, bits);
- CHECKRETURN(1);
- bits = glyphp[2][line];
- bits |= SHIFT_L(glyphp[3][line],16);
- WRITE_IN_BITORDER(base, 1, bits);
- CHECKRETURN(2);
- bits = glyphp[4][line];
- bits |= SHIFT_L(glyphp[5][line],16);
- WRITE_IN_BITORDER(base, 2, bits);
- CHECKRETURN(3);
- bits = glyphp[6][line];
- bits |= SHIFT_L(glyphp[7][line],16);
- WRITE_IN_BITORDER(base, 3, bits);
- CHECKRETURN(4);
-#ifndef FIXEDBASE
- base += 4;
-#endif
- width -= 128;
- glyphp += 8;
- }
- return base;
-}
-
-
-
-static CARD32*
-DrawTETextScanlineWidth18(
- CARD32 *base,
- unsigned int **glyphp,
- int line, int width, int glyphwidth )
-{
- while (1) {
- unsigned int bits;
- bits = glyphp[0][line];
- bits |= SHIFT_L(glyphp[1][line],18);
- WRITE_IN_BITORDER(base, 0, bits);
- CHECKRETURN(1);
- bits = SHIFT_R(glyphp[1][line],14);
- bits |= SHIFT_L(glyphp[2][line],4);
- bits |= SHIFT_L(glyphp[3][line],22);
- WRITE_IN_BITORDER(base, 1, bits);
- CHECKRETURN(2);
- bits = SHIFT_R(glyphp[3][line],10);
- bits |= SHIFT_L(glyphp[4][line],8);
- bits |= SHIFT_L(glyphp[5][line],26);
- WRITE_IN_BITORDER(base, 2, bits);
- CHECKRETURN(3);
- bits = SHIFT_R(glyphp[5][line],6);
- bits |= SHIFT_L(glyphp[6][line],12);
- bits |= SHIFT_L(glyphp[7][line],30);
- WRITE_IN_BITORDER(base, 3, bits);
- CHECKRETURN(4);
- bits = SHIFT_R(glyphp[7][line],2);
- bits |= SHIFT_L(glyphp[8][line],16);
- WRITE_IN_BITORDER(base, 4, bits);
- CHECKRETURN(5);
- bits = SHIFT_R(glyphp[8][line],16);
- bits |= SHIFT_L(glyphp[9][line],2);
- bits |= SHIFT_L(glyphp[10][line],20);
- WRITE_IN_BITORDER(base, 5, bits);
- CHECKRETURN(6);
- bits = SHIFT_R(glyphp[10][line],12);
- bits |= SHIFT_L(glyphp[11][line],6);
- bits |= SHIFT_L(glyphp[12][line],24);
- WRITE_IN_BITORDER(base, 6, bits);
- CHECKRETURN(7);
- bits = SHIFT_R(glyphp[12][line],8);
- bits |= SHIFT_L(glyphp[13][line],10);
- bits |= SHIFT_L(glyphp[14][line],28);
- WRITE_IN_BITORDER(base, 7, bits);
- CHECKRETURN(8);
- bits = SHIFT_R(glyphp[14][line],4);
- bits |= SHIFT_L(glyphp[15][line],14);
- WRITE_IN_BITORDER(base, 8, bits);
- CHECKRETURN(9);
-#ifndef FIXEDBASE
- base += 9;
-#endif
- width -= 288;
- glyphp += 16;
- }
- return base;
-}
-
-
-static CARD32*
-DrawTETextScanlineWidth24(
- CARD32 *base,
- unsigned int **glyphp,
- int line, int width, int glyphwidth )
-{
- while (1) {
- unsigned int bits;
- bits = glyphp[0][line];
- bits |= SHIFT_L(glyphp[1][line],24);
- WRITE_IN_BITORDER(base, 0, bits);
- CHECKRETURN(1);
- bits = SHIFT_R(glyphp[1][line],8);
- bits |= SHIFT_L(glyphp[2][line],16);
- WRITE_IN_BITORDER(base, 1, bits);
- CHECKRETURN(2);
- bits = SHIFT_R(glyphp[2][line],16);
- bits |= SHIFT_L(glyphp[3][line],8);
- WRITE_IN_BITORDER(base, 2, bits);
- CHECKRETURN(3);
-#ifndef FIXEDBASE
- base += 3;
-#endif
- width -= 96;
- glyphp += 4;
- }
- return base;
-}
-
-
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xaa.h"
+#include "xaalocal.h"
+#include "xaacexp.h"
+#include "xf86.h"
+
+/* scanline function for TRIPLE_BITS_24BPP */
+static CARD32 *DrawTextScanline3(CARD32 *base, CARD32 *mem, int width);
+
+/* Loop unrolled functions for common font widths */
+static CARD32 *DrawTETextScanlineGeneric(CARD32 *base, unsigned int **glyphp,
+ int line, int width, int glyphwidth);
+static CARD32 *DrawTETextScanlineWidth7(CARD32 *base, unsigned int **glyphp,
+ int line, int width, int glyphwidth);
+static CARD32 *DrawTETextScanlineWidth10(CARD32 *base, unsigned int **glyphp,
+ int line, int width, int glyphwidth);
+static CARD32 *DrawTETextScanlineWidth12(CARD32 *base, unsigned int **glyphp,
+ int line, int width, int glyphwidth);
+static CARD32 *DrawTETextScanlineWidth14(CARD32 *base, unsigned int **glyphp,
+ int line, int width, int glyphwidth);
+static CARD32 *DrawTETextScanlineWidth16(CARD32 *base, unsigned int **glyphp,
+ int line, int width, int glyphwidth);
+static CARD32 *DrawTETextScanlineWidth18(CARD32 *base, unsigned int **glyphp,
+ int line, int width, int glyphwidth);
+static CARD32 *DrawTETextScanlineWidth24(CARD32 *base, unsigned int **glyphp,
+ int line, int width, int glyphwidth);
+
+#ifdef USEASSEMBLER
+#ifdef FIXEDBASE
+#ifdef MSBFIRST
+CARD32 *DrawTETextScanlineWidth6PMSBFirstFixedBase(CARD32 *base,
+ unsigned int **glyphp,
+ int line, int width,
+ int glyphwidth);
+CARD32 *DrawTETextScanlineWidth8PMSBFirstFixedBase(CARD32 *base,
+ unsigned int **glyphp,
+ int line, int width,
+ int glyphwidth);
+CARD32 *DrawTETextScanlineWidth9PMSBFirstFixedBase(CARD32 *base,
+ unsigned int **glyphp,
+ int line, int width,
+ int glyphwidth);
+#else
+CARD32 *DrawTETextScanlineWidth6PLSBFirstFixedBase(CARD32 *base,
+ unsigned int **glyphp,
+ int line, int width,
+ int glyphwidth);
+CARD32 *DrawTETextScanlineWidth8PLSBFirstFixedBase(CARD32 *base,
+ unsigned int **glyphp,
+ int line, int width,
+ int glyphwidth);
+CARD32 *DrawTETextScanlineWidth9PLSBFirstFixedBase(CARD32 *base,
+ unsigned int **glyphp,
+ int line, int width,
+ int glyphwidth);
+#endif
+#else
+#ifdef MSBFIRST
+CARD32 *DrawTETextScanlineWidth6PMSBFirst(CARD32 *base, unsigned int **glyphp,
+ int line, int width, int glyphwidth);
+CARD32 *DrawTETextScanlineWidth8PMSBFirst(CARD32 *base, unsigned int **glyphp,
+ int line, int width, int glyphwidth);
+CARD32 *DrawTETextScanlineWidth9PMSBFirst(CARD32 *base, unsigned int **glyphp,
+ int line, int width, int glyphwidth);
+#else
+CARD32 *DrawTETextScanlineWidth6PLSBFirst(CARD32 *base, unsigned int **glyphp,
+ int line, int width, int glyphwidth);
+CARD32 *DrawTETextScanlineWidth8PLSBFirst(CARD32 *base, unsigned int **glyphp,
+ int line, int width, int glyphwidth);
+CARD32 *DrawTETextScanlineWidth9PLSBFirst(CARD32 *base, unsigned int **glyphp,
+ int line, int width, int glyphwidth);
+#endif
+#endif
+#else
+static CARD32 *DrawTETextScanlineWidth6(CARD32 *base, unsigned int **glyphp,
+ int line, int width, int glyphwidth);
+static CARD32 *DrawTETextScanlineWidth8(CARD32 *base, unsigned int **glyphp,
+ int line, int width, int glyphwidth);
+static CARD32 *DrawTETextScanlineWidth9(CARD32 *base, unsigned int **glyphp,
+ int line, int width, int glyphwidth);
+#endif
+
+#define glyph_scanline_func EXPNAME(XAAGlyphScanlineFunc)
+#define glyph_get_scanline_func EXPNAME(XAAGetGlyphScanlineFunc)
+
+GlyphScanlineFuncPtr glyph_scanline_func[32] = {
+ DrawTETextScanlineGeneric, DrawTETextScanlineGeneric,
+ DrawTETextScanlineGeneric, DrawTETextScanlineGeneric,
+ DrawTETextScanlineGeneric,
+#ifdef USEASSEMBLER
+#ifdef FIXEDBASE
+#ifdef MSBFIRST
+ DrawTETextScanlineWidth6PMSBFirstFixedBase,
+ DrawTETextScanlineWidth7,
+ DrawTETextScanlineWidth8PMSBFirstFixedBase,
+ DrawTETextScanlineWidth9PMSBFirstFixedBase,
+#else
+ DrawTETextScanlineWidth6PLSBFirstFixedBase,
+ DrawTETextScanlineWidth7,
+ DrawTETextScanlineWidth8PLSBFirstFixedBase,
+ DrawTETextScanlineWidth9PLSBFirstFixedBase,
+#endif
+#else
+#ifdef MSBFIRST
+ DrawTETextScanlineWidth6PMSBFirst,
+ DrawTETextScanlineWidth7,
+ DrawTETextScanlineWidth8PMSBFirst,
+ DrawTETextScanlineWidth9PMSBFirst,
+#else
+ DrawTETextScanlineWidth6PLSBFirst,
+ DrawTETextScanlineWidth7,
+ DrawTETextScanlineWidth8PLSBFirst,
+ DrawTETextScanlineWidth9PLSBFirst,
+#endif
+#endif
+#else
+ DrawTETextScanlineWidth6, DrawTETextScanlineWidth7,
+ DrawTETextScanlineWidth8, DrawTETextScanlineWidth9,
+#endif
+ DrawTETextScanlineWidth10,
+ DrawTETextScanlineGeneric, DrawTETextScanlineWidth12,
+ DrawTETextScanlineGeneric, DrawTETextScanlineWidth14,
+ DrawTETextScanlineGeneric, DrawTETextScanlineWidth16,
+ DrawTETextScanlineGeneric, DrawTETextScanlineWidth18,
+ DrawTETextScanlineGeneric, DrawTETextScanlineGeneric,
+ DrawTETextScanlineGeneric, DrawTETextScanlineGeneric,
+ DrawTETextScanlineGeneric, DrawTETextScanlineWidth24,
+ DrawTETextScanlineGeneric, DrawTETextScanlineGeneric,
+ DrawTETextScanlineGeneric, DrawTETextScanlineGeneric,
+ DrawTETextScanlineGeneric, DrawTETextScanlineGeneric,
+ DrawTETextScanlineGeneric, DrawTETextScanlineGeneric
+};
+
+GlyphScanlineFuncPtr *
+glyph_get_scanline_func(void)
+{
+ return glyph_scanline_func;
+}
+
+/********************************************************************
+
+ Here we have TEGlyphRenders for a bunch of different color
+ expansion types. The driver may provide its own renderer, but
+ this is the default one which renders using lower-level primitives
+ exported by the chipset driver.
+
+********************************************************************/
+
+/* This gets built for MSBFIRST or LSBFIRST with FIXEDBASE or not.
+ A total of 4 versions */
+
+void
+
+EXPNAME(XAATEGlyphRenderer) (ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft,
+ int startline, unsigned int **glyphs,
+ int glyphWidth, int fg, int bg, int rop,
+ unsigned planemask) {
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ CARD32 *base;
+ GlyphScanlineFuncPtr GlyphFunc = glyph_scanline_func[glyphWidth - 1];
+ int dwords = 0;
+
+ if ((bg != -1) && (infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) {
+ (*infoRec->SetupForSolidFill) (pScrn, bg, rop, planemask);
+ (*infoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h);
+ bg = -1;
+ }
+
+ (*infoRec->SetupForCPUToScreenColorExpandFill) (pScrn, fg, bg, rop,
+ planemask);
+
+ if (skipleft &&
+ (!(infoRec->TEGlyphRendererFlags & LEFT_EDGE_CLIPPING) ||
+ (!(infoRec->TEGlyphRendererFlags & LEFT_EDGE_CLIPPING_NEGATIVE_X) &&
+ (skipleft > x)))) {
+ /* draw the first character only */
+
+ int count = h, line = startline;
+ int width = glyphWidth - skipleft;
+
+ if (width > w)
+ width = w;
+
+ (*infoRec->SubsequentCPUToScreenColorExpandFill) (pScrn, x, y, width, h,
+ 0);
+
+ base = (CARD32 *) infoRec->ColorExpandBase;
+
+ while (count--) {
+ register CARD32 tmp = SHIFT_R(glyphs[0][line++], skipleft);
+
+ WRITE_BITS(tmp);
+ }
+
+ w -= width;
+ if ((infoRec->TEGlyphRendererFlags & CPU_TRANSFER_PAD_QWORD) &&
+ ((((width + 31) >> 5) * h) & 1)) {
+ base = (CARD32 *) infoRec->ColorExpandBase;
+ base[0] = 0x00000000;
+ }
+ if (!w)
+ goto THE_END;
+ glyphs++;
+ x += width;
+ skipleft = 0; /* nicely aligned again */
+ }
+
+ w += skipleft;
+ x -= skipleft;
+ dwords = ((w + 31) >> 5) * h;
+
+ (*infoRec->SubsequentCPUToScreenColorExpandFill) (pScrn, x, y, w, h,
+ skipleft);
+
+ base = (CARD32 *) infoRec->ColorExpandBase;
+
+#ifndef FIXEDBASE
+ if ((((w + 31) >> 5) * h) <= infoRec->ColorExpandRange)
+ while (h--) {
+ base = (*GlyphFunc) (base, glyphs, startline++, w, glyphWidth);
+ }
+ else
+#endif
+ while (h--) {
+ (*GlyphFunc) (base, glyphs, startline++, w, glyphWidth);
+ }
+
+ if ((infoRec->TEGlyphRendererFlags & CPU_TRANSFER_PAD_QWORD) &&
+ (dwords & 1)) {
+ base = (CARD32 *) infoRec->ColorExpandBase;
+ base[0] = 0x00000000;
+ }
+
+ THE_END:
+
+ if (infoRec->TEGlyphRendererFlags & SYNC_AFTER_COLOR_EXPAND)
+ (*infoRec->Sync) (pScrn);
+ else
+ SET_SYNC_FLAG(infoRec);
+}
+
+/********************************************************************
+
+ This is the GlyphRenderer for TRIPLE_BITS_24BPP. It renders to a buffer
+ with the non FIXEDBASE LSB_FIRST code before tripling, and possibly
+ reversing the bits and sending them to the screen
+
+********************************************************************/
+
+void
+
+EXPNAME(XAATEGlyphRenderer3) (ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft,
+ int startline, unsigned int **glyphs,
+ int glyphWidth, int fg, int bg, int rop,
+ unsigned planemask) {
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ CARD32 *base, *mem;
+ GlyphScanlineFuncPtr GlyphFunc =
+ XAAGlyphScanlineFuncLSBFirst[glyphWidth - 1];
+ int dwords = 0;
+
+ if ((bg != -1) &&
+ ((infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY) ||
+ ((infoRec->TEGlyphRendererFlags & RGB_EQUAL) &&
+ (!CHECK_RGB_EQUAL(bg))))) {
+ (*infoRec->SetupForSolidFill) (pScrn, bg, rop, planemask);
+ (*infoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h);
+ bg = -1;
+ }
+
+ (*infoRec->SetupForCPUToScreenColorExpandFill) (pScrn, fg, bg, rop,
+ planemask);
+
+ if (skipleft) {
+ /* draw the first character only */
+
+ int count = h, line = startline;
+ int width = glyphWidth - skipleft;
+ CARD32 bits;
+
+ if (width > w)
+ width = w;
+ (*infoRec->SubsequentCPUToScreenColorExpandFill) (pScrn, x, y, width, h,
+ 0);
+
+ base = (CARD32 *) infoRec->ColorExpandBase;
+
+ while (count--) {
+ bits = SHIFT_R(glyphs[0][line++], skipleft);
+ if (width >= 22) {
+ WRITE_BITS3(bits);
+ }
+ else if (width >= 11) {
+ WRITE_BITS2(bits);
+ }
+ else {
+ WRITE_BITS1(bits);
+ }
+ }
+
+ w -= width;
+ if ((infoRec->TEGlyphRendererFlags & CPU_TRANSFER_PAD_QWORD) &&
+ ((((3 * width + 31) >> 5) * h) & 1)) {
+ base = (CARD32 *) infoRec->ColorExpandBase;
+ base[0] = 0x00000000;
+ }
+ if (!w)
+ goto THE_END;
+ glyphs++;
+ x += width;
+ skipleft = 0; /* nicely aligned again */
+ }
+
+ dwords = ((3 * w + 31) >> 5) * h;
+ mem = (CARD32 *) malloc(((w + 31) >> 3) * sizeof(char));
+ if (!mem)
+ return;
+
+ (*infoRec->SubsequentCPUToScreenColorExpandFill) (pScrn, x, y, w, h, 0);
+
+ base = (CARD32 *) infoRec->ColorExpandBase;
+
+#ifndef FIXEDBASE
+ if ((((3 * w + 31) >> 5) * h) <= infoRec->ColorExpandRange)
+ while (h--) {
+ (*GlyphFunc) (mem, glyphs, startline++, w, glyphWidth);
+ base = DrawTextScanline3(base, mem, w);
+ }
+ else
+#endif
+ while (h--) {
+ (*GlyphFunc) (mem, glyphs, startline++, w, glyphWidth);
+ DrawTextScanline3(base, mem, w);
+ }
+
+ free(mem);
+
+ if ((infoRec->TEGlyphRendererFlags & CPU_TRANSFER_PAD_QWORD) &&
+ (dwords & 1)) {
+ base = (CARD32 *) infoRec->ColorExpandBase;
+ base[0] = 0x00000000;
+ }
+
+ THE_END:
+
+ if (infoRec->TEGlyphRendererFlags & SYNC_AFTER_COLOR_EXPAND)
+ (*infoRec->Sync) (pScrn);
+ else
+ SET_SYNC_FLAG(infoRec);
+}
+
+#ifndef FIXEDBASE
+/* Scanline version of above gets built for LSBFIRST and MSBFIRST */
+
+void
+
+EXPNAME(XAATEGlyphRendererScanline) (ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft,
+ int startline, unsigned int **glyphs,
+ int glyphWidth, int fg, int bg, int rop,
+ unsigned planemask) {
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int bufferNo;
+ CARD32 *base;
+ GlyphScanlineFuncPtr GlyphFunc = glyph_scanline_func[glyphWidth - 1];
+
+ if ((bg != -1) && (infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) {
+ (*infoRec->SetupForSolidFill) (pScrn, bg, rop, planemask);
+ (*infoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h);
+ bg = -1;
+ }
+
+ (*infoRec->SetupForScanlineCPUToScreenColorExpandFill) (pScrn, fg, bg, rop,
+ planemask);
+
+ if (skipleft &&
+ (!(infoRec->TEGlyphRendererFlags & LEFT_EDGE_CLIPPING) ||
+ (!(infoRec->TEGlyphRendererFlags & LEFT_EDGE_CLIPPING_NEGATIVE_X) &&
+ (skipleft > x)))) {
+ /* draw the first character only */
+
+ int count = h, line = startline;
+ int width = glyphWidth - skipleft;
+
+ if (width > w)
+ width = w;
+
+ (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill) (pScrn, x, y,
+ width, h, 0);
+
+ bufferNo = 0;
+
+ while (count--) {
+ register CARD32 tmp = SHIFT_R(glyphs[0][line++], skipleft);
+
+ base = (CARD32 *) infoRec->ScanlineColorExpandBuffers[bufferNo];
+ WRITE_BITS(tmp);
+ (*infoRec->SubsequentColorExpandScanline) (pScrn, bufferNo++);
+ if (bufferNo >= infoRec->NumScanlineColorExpandBuffers)
+ bufferNo = 0;
+ }
+
+ w -= width;
+ if (!w)
+ goto THE_END;
+ glyphs++;
+ x += width;
+ skipleft = 0; /* nicely aligned again */
+ }
+
+ w += skipleft;
+ x -= skipleft;
+
+ (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill) (pScrn, x, y, w, h,
+ skipleft);
+
+ bufferNo = 0;
+
+ while (h--) {
+ base = (CARD32 *) infoRec->ScanlineColorExpandBuffers[bufferNo];
+ (*GlyphFunc) (base, glyphs, startline++, w, glyphWidth);
+ (*infoRec->SubsequentColorExpandScanline) (pScrn, bufferNo++);
+ if (bufferNo >= infoRec->NumScanlineColorExpandBuffers)
+ bufferNo = 0;
+ }
+
+ THE_END:
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+void
+
+EXPNAME(XAATEGlyphRendererScanline3) (ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft,
+ int startline, unsigned int **glyphs,
+ int glyphWidth, int fg, int bg, int rop,
+ unsigned planemask) {
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int bufferNo;
+ CARD32 *base, *mem;
+ GlyphScanlineFuncPtr GlyphFunc =
+ XAAGlyphScanlineFuncLSBFirst[glyphWidth - 1];
+
+ if ((bg != -1) &&
+ ((infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY) ||
+ ((infoRec->TEGlyphRendererFlags & RGB_EQUAL) &&
+ (!CHECK_RGB_EQUAL(bg))))) {
+ (*infoRec->SetupForSolidFill) (pScrn, bg, rop, planemask);
+ (*infoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h);
+ bg = -1;
+ }
+
+ (*infoRec->SetupForScanlineCPUToScreenColorExpandFill) (pScrn, fg, bg, rop,
+ planemask);
+
+ if (skipleft) {
+ /* draw the first character only */
+
+ int count = h, line = startline;
+ int width = glyphWidth - skipleft;
+ CARD32 bits;
+
+ if (width > w)
+ width = w;
+
+ (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill) (pScrn, x, y,
+ width, h, 0);
+
+ bufferNo = 0;
+
+ while (count--) {
+ base = (CARD32 *) infoRec->ScanlineColorExpandBuffers[bufferNo];
+ bits = SHIFT_R(glyphs[0][line++], skipleft);
+ if (width >= 22) {
+ WRITE_BITS3(bits);
+ }
+ else if (width >= 11) {
+ WRITE_BITS2(bits);
+ }
+ else {
+ WRITE_BITS1(bits);
+ }
+ (*infoRec->SubsequentColorExpandScanline) (pScrn, bufferNo++);
+ if (bufferNo >= infoRec->NumScanlineColorExpandBuffers)
+ bufferNo = 0;
+ }
+
+ w -= width;
+ if (!w)
+ goto THE_END;
+ glyphs++;
+ x += width;
+ skipleft = 0; /* nicely aligned again */
+ }
+
+ w += skipleft;
+ x -= skipleft;
+ mem = (CARD32 *) malloc(((w + 31) >> 3) * sizeof(char));
+ if (!mem)
+ return;
+
+ (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill) (pScrn, x, y, w, h,
+ skipleft);
+
+ bufferNo = 0;
+
+ while (h--) {
+ base = (CARD32 *) infoRec->ScanlineColorExpandBuffers[bufferNo];
+ (*GlyphFunc) (mem, glyphs, startline++, w, glyphWidth);
+ DrawTextScanline3(base, mem, w);
+ (*infoRec->SubsequentColorExpandScanline) (pScrn, bufferNo++);
+ if (bufferNo >= infoRec->NumScanlineColorExpandBuffers)
+ bufferNo = 0;
+ }
+
+ free(mem);
+
+ THE_END:
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+#endif
+
+/********************************************************************
+
+ TRIPLE_BITS_24BPP scanline rendering code.
+
+********************************************************************/
+
+static CARD32 *
+DrawTextScanline3(CARD32 *base, CARD32 *mem, int width)
+{
+
+ while (width > 32) {
+ WRITE_BITS3(*mem);
+ mem++;
+ width -= 32;
+ }
+ if (width) {
+ if (width >= 22) {
+ WRITE_BITS3(*mem);
+ }
+ else if (width >= 11) {
+ WRITE_BITS2(*mem);
+ }
+ else {
+ WRITE_BITS1(*mem);
+ }
+ }
+
+ return base;
+}
+
+/********************************************************************
+
+ Generic TE scanline rendering code.
+
+********************************************************************/
+
+static CARD32 *
+DrawTETextScanlineGeneric(CARD32 *base,
+ unsigned int **glyphp,
+ int line, int width, int glyphwidth)
+{
+ CARD32 bits = (*glyphp)[line];
+ int shift = glyphwidth;
+
+ while (width > 32) {
+ while (shift < 32) {
+ glyphp++;
+ bits |= SHIFT_L((*glyphp)[line], shift);
+ shift += glyphwidth;
+ }
+ WRITE_BITS(bits);
+ shift &= 31;
+ if (shift)
+ bits = SHIFT_R((*glyphp)[line], (glyphwidth - shift));
+ else
+ bits = 0;
+ width -= 32;
+ }
+
+ if (width) {
+ width -= shift;
+ while (width > 0) {
+ glyphp++;
+ bits |= SHIFT_L((*glyphp)[line], shift);
+ shift += glyphwidth;
+ width -= glyphwidth;
+ }
+ WRITE_BITS(bits);
+ }
+
+ return base;
+}
+
+/********************************************************************
+
+ Loop unrolled TE font scanline rendering code
+
+********************************************************************/
+
+#ifndef USEASSEMBLER
+static CARD32 *
+DrawTETextScanlineWidth6(CARD32 *base,
+ unsigned int **glyphp,
+ int line, int width, int glyphwidth)
+{
+ while (1) {
+ unsigned int bits;
+
+ bits = glyphp[0][line];
+ bits |= SHIFT_L(glyphp[1][line], 6);
+ bits |= SHIFT_L(glyphp[2][line], 12);
+ bits |= SHIFT_L(glyphp[3][line], 18);
+ bits |= SHIFT_L(glyphp[4][line], 24);
+ bits |= SHIFT_L(glyphp[5][line], 30);
+ WRITE_IN_BITORDER(base, 0, bits);
+ CHECKRETURN(1);
+ bits = SHIFT_R(glyphp[5][line], 2);
+ bits |= SHIFT_L(glyphp[6][line], 4);
+ bits |= SHIFT_L(glyphp[7][line], 10);
+ bits |= SHIFT_L(glyphp[8][line], 16);
+ bits |= SHIFT_L(glyphp[9][line], 22);
+ bits |= SHIFT_L(glyphp[10][line], 28);
+ WRITE_IN_BITORDER(base, 1, bits);
+ CHECKRETURN(2);
+ bits = SHIFT_R(glyphp[10][line], 4);
+ bits |= SHIFT_L(glyphp[11][line], 2);
+ bits |= SHIFT_L(glyphp[12][line], 8);
+ bits |= SHIFT_L(glyphp[13][line], 14);
+ bits |= SHIFT_L(glyphp[14][line], 20);
+ bits |= SHIFT_L(glyphp[15][line], 26);
+ WRITE_IN_BITORDER(base, 2, bits);
+ CHECKRETURN(3);
+#ifndef FIXEDBASE
+ base += 3;
+#endif
+ width -= 96;
+ glyphp += 16;
+ }
+ return base;
+}
+#endif
+
+static CARD32 *
+DrawTETextScanlineWidth7(CARD32 *base,
+ unsigned int **glyphp,
+ int line, int width, int glyphwidth)
+{
+ while (1) {
+ unsigned int bits;
+
+ bits = glyphp[0][line];
+ bits |= SHIFT_L(glyphp[1][line], 7);
+ bits |= SHIFT_L(glyphp[2][line], 14);
+ bits |= SHIFT_L(glyphp[3][line], 21);
+ bits |= SHIFT_L(glyphp[4][line], 28);
+ WRITE_IN_BITORDER(base, 0, bits);
+ CHECKRETURN(1);
+ bits = SHIFT_R(glyphp[4][line], 4);
+ bits |= SHIFT_L(glyphp[5][line], 3);
+ bits |= SHIFT_L(glyphp[6][line], 10);
+ bits |= SHIFT_L(glyphp[7][line], 17);
+ bits |= SHIFT_L(glyphp[8][line], 24);
+ bits |= SHIFT_L(glyphp[9][line], 31);
+ WRITE_IN_BITORDER(base, 1, bits);
+ CHECKRETURN(2);
+ bits = SHIFT_R(glyphp[9][line], 1);
+ bits |= SHIFT_L(glyphp[10][line], 6);
+ bits |= SHIFT_L(glyphp[11][line], 13);
+ bits |= SHIFT_L(glyphp[12][line], 20);
+ bits |= SHIFT_L(glyphp[13][line], 27);
+ WRITE_IN_BITORDER(base, 2, bits);
+ CHECKRETURN(3);
+ bits = SHIFT_R(glyphp[13][line], 5);
+ bits |= SHIFT_L(glyphp[14][line], 2);
+ bits |= SHIFT_L(glyphp[15][line], 9);
+ bits |= SHIFT_L(glyphp[16][line], 16);
+ bits |= SHIFT_L(glyphp[17][line], 23);
+ bits |= SHIFT_L(glyphp[18][line], 30);
+ WRITE_IN_BITORDER(base, 3, bits);
+ CHECKRETURN(4);
+ bits = SHIFT_R(glyphp[18][line], 2);
+ bits |= SHIFT_L(glyphp[19][line], 5);
+ bits |= SHIFT_L(glyphp[20][line], 12);
+ bits |= SHIFT_L(glyphp[21][line], 19);
+ bits |= SHIFT_L(glyphp[22][line], 26);
+ WRITE_IN_BITORDER(base, 4, bits);
+ CHECKRETURN(5);
+ bits = SHIFT_R(glyphp[22][line], 6);
+ bits |= SHIFT_L(glyphp[23][line], 1);
+ bits |= SHIFT_L(glyphp[24][line], 8);
+ bits |= SHIFT_L(glyphp[25][line], 15);
+ bits |= SHIFT_L(glyphp[26][line], 22);
+ bits |= SHIFT_L(glyphp[27][line], 29);
+ WRITE_IN_BITORDER(base, 5, bits);
+ CHECKRETURN(6);
+ bits = SHIFT_R(glyphp[27][line], 3);
+ bits |= SHIFT_L(glyphp[28][line], 4);
+ bits |= SHIFT_L(glyphp[29][line], 11);
+ bits |= SHIFT_L(glyphp[30][line], 18);
+ bits |= SHIFT_L(glyphp[31][line], 25);
+ WRITE_IN_BITORDER(base, 6, bits);
+ CHECKRETURN(7);
+#ifndef FIXEDBASE
+ base += 7;
+#endif
+ width -= 224;
+ glyphp += 32;
+ }
+ return base;
+}
+
+#ifndef USEASSEMBLER
+static CARD32 *
+DrawTETextScanlineWidth8(CARD32 *base,
+ unsigned int **glyphp,
+ int line, int width, int glyphwidth)
+{
+ while (1) {
+ unsigned int bits;
+
+ bits = glyphp[0][line];
+ bits |= SHIFT_L(glyphp[1][line], 8);
+ bits |= SHIFT_L(glyphp[2][line], 16);
+ bits |= SHIFT_L(glyphp[3][line], 24);
+ WRITE_IN_BITORDER(base, 0, bits);
+ CHECKRETURN(1);
+ bits = glyphp[4][line];
+ bits |= SHIFT_L(glyphp[5][line], 8);
+ bits |= SHIFT_L(glyphp[6][line], 16);
+ bits |= SHIFT_L(glyphp[7][line], 24);
+ WRITE_IN_BITORDER(base, 1, bits);
+ CHECKRETURN(2);
+#ifndef FIXEDBASE
+ base += 2;
+#endif
+ width -= 64;
+ glyphp += 8;
+ }
+ return base;
+}
+#endif
+
+#ifndef USEASSEMBLER
+static CARD32 *
+DrawTETextScanlineWidth9(CARD32 *base,
+ unsigned int **glyphp,
+ int line, int width, int glyphwidth)
+{
+ while (1) {
+ unsigned int bits;
+
+ bits = glyphp[0][line];
+ bits |= SHIFT_L(glyphp[1][line], 9);
+ bits |= SHIFT_L(glyphp[2][line], 18);
+ bits |= SHIFT_L(glyphp[3][line], 27);
+ WRITE_IN_BITORDER(base, 0, bits);
+ CHECKRETURN(1);
+ bits = SHIFT_R(glyphp[3][line], 5);
+ bits |= SHIFT_L(glyphp[4][line], 4);
+ bits |= SHIFT_L(glyphp[5][line], 13);
+ bits |= SHIFT_L(glyphp[6][line], 22);
+ bits |= SHIFT_L(glyphp[7][line], 31);
+ WRITE_IN_BITORDER(base, 1, bits);
+ CHECKRETURN(2);
+ bits = SHIFT_R(glyphp[7][line], 1);
+ bits |= SHIFT_L(glyphp[8][line], 8);
+ bits |= SHIFT_L(glyphp[9][line], 17);
+ bits |= SHIFT_L(glyphp[10][line], 26);
+ WRITE_IN_BITORDER(base, 2, bits);
+ CHECKRETURN(3);
+ bits = SHIFT_R(glyphp[10][line], 6);
+ bits |= SHIFT_L(glyphp[11][line], 3);
+ bits |= SHIFT_L(glyphp[12][line], 12);
+ bits |= SHIFT_L(glyphp[13][line], 21);
+ bits |= SHIFT_L(glyphp[14][line], 30);
+ WRITE_IN_BITORDER(base, 3, bits);
+ CHECKRETURN(4);
+ bits = SHIFT_R(glyphp[14][line], 2);
+ bits |= SHIFT_L(glyphp[15][line], 7);
+ bits |= SHIFT_L(glyphp[16][line], 16);
+ bits |= SHIFT_L(glyphp[17][line], 25);
+ WRITE_IN_BITORDER(base, 4, bits);
+ CHECKRETURN(5);
+ bits = SHIFT_R(glyphp[17][line], 7);
+ bits |= SHIFT_L(glyphp[18][line], 2);
+ bits |= SHIFT_L(glyphp[19][line], 11);
+ bits |= SHIFT_L(glyphp[20][line], 20);
+ bits |= SHIFT_L(glyphp[21][line], 29);
+ WRITE_IN_BITORDER(base, 5, bits);
+ CHECKRETURN(6);
+ bits = SHIFT_R(glyphp[21][line], 3);
+ bits |= SHIFT_L(glyphp[22][line], 6);
+ bits |= SHIFT_L(glyphp[23][line], 15);
+ bits |= SHIFT_L(glyphp[24][line], 24);
+ WRITE_IN_BITORDER(base, 6, bits);
+ CHECKRETURN(7);
+ bits = SHIFT_R(glyphp[24][line], 8);
+ bits |= SHIFT_L(glyphp[25][line], 1);
+ bits |= SHIFT_L(glyphp[26][line], 10);
+ bits |= SHIFT_L(glyphp[27][line], 19);
+ bits |= SHIFT_L(glyphp[28][line], 28);
+ WRITE_IN_BITORDER(base, 7, bits);
+ CHECKRETURN(8);
+ bits = SHIFT_R(glyphp[28][line], 4);
+ bits |= SHIFT_L(glyphp[29][line], 5);
+ bits |= SHIFT_L(glyphp[30][line], 14);
+ bits |= SHIFT_L(glyphp[31][line], 23);
+ WRITE_IN_BITORDER(base, 8, bits);
+ CHECKRETURN(9);
+#ifndef FIXEDBASE
+ base += 9;
+#endif
+ width -= 288;
+ glyphp += 32;
+ }
+ return base;
+}
+#endif
+
+static CARD32 *
+DrawTETextScanlineWidth10(CARD32 *base,
+ unsigned int **glyphp,
+ int line, int width, int glyphwidth)
+{
+ while (1) {
+ unsigned int bits;
+
+ bits = glyphp[0][line];
+ bits |= SHIFT_L(glyphp[1][line], 10);
+ bits |= SHIFT_L(glyphp[2][line], 20);
+ bits |= SHIFT_L(glyphp[3][line], 30);
+ WRITE_IN_BITORDER(base, 0, bits);
+ CHECKRETURN(1);
+ bits = SHIFT_R(glyphp[3][line], 2);
+ bits |= SHIFT_L(glyphp[4][line], 8);
+ bits |= SHIFT_L(glyphp[5][line], 18);
+ bits |= SHIFT_L(glyphp[6][line], 28);
+ WRITE_IN_BITORDER(base, 1, bits);
+ CHECKRETURN(2);
+ bits = SHIFT_R(glyphp[6][line], 4);
+ bits |= SHIFT_L(glyphp[7][line], 6);
+ bits |= SHIFT_L(glyphp[8][line], 16);
+ bits |= SHIFT_L(glyphp[9][line], 26);
+ WRITE_IN_BITORDER(base, 2, bits);
+ CHECKRETURN(3);
+ bits = SHIFT_R(glyphp[9][line], 6);
+ bits |= SHIFT_L(glyphp[10][line], 4);
+ bits |= SHIFT_L(glyphp[11][line], 14);
+ bits |= SHIFT_L(glyphp[12][line], 24);
+ WRITE_IN_BITORDER(base, 3, bits);
+ CHECKRETURN(4);
+ bits = SHIFT_R(glyphp[12][line], 8);
+ bits |= SHIFT_L(glyphp[13][line], 2);
+ bits |= SHIFT_L(glyphp[14][line], 12);
+ bits |= SHIFT_L(glyphp[15][line], 22);
+ WRITE_IN_BITORDER(base, 4, bits);
+ CHECKRETURN(5);
+#ifndef FIXEDBASE
+ base += 5;
+#endif
+ width -= 160;
+ glyphp += 16;
+ }
+ return base;
+}
+
+static CARD32 *
+DrawTETextScanlineWidth12(CARD32 *base,
+ unsigned int **glyphp,
+ int line, int width, int glyphwidth)
+{
+ while (1) {
+ unsigned int bits;
+
+ bits = glyphp[0][line];
+ bits |= SHIFT_L(glyphp[1][line], 12);
+ bits |= SHIFT_L(glyphp[2][line], 24);
+ WRITE_IN_BITORDER(base, 0, bits);
+ CHECKRETURN(1);
+ bits = SHIFT_R(glyphp[2][line], 8);
+ bits |= SHIFT_L(glyphp[3][line], 4);
+ bits |= SHIFT_L(glyphp[4][line], 16);
+ bits |= SHIFT_L(glyphp[5][line], 28);
+ WRITE_IN_BITORDER(base, 1, bits);
+ CHECKRETURN(2);
+ bits = SHIFT_R(glyphp[5][line], 4);
+ bits |= SHIFT_L(glyphp[6][line], 8);
+ bits |= SHIFT_L(glyphp[7][line], 20);
+ WRITE_IN_BITORDER(base, 2, bits);
+ CHECKRETURN(3);
+#ifndef FIXEDBASE
+ base += 3;
+#endif
+ width -= 96;
+ glyphp += 8;
+ }
+ return base;
+}
+
+static CARD32 *
+DrawTETextScanlineWidth14(CARD32 *base,
+ unsigned int **glyphp,
+ int line, int width, int glyphwidth)
+{
+ while (1) {
+ unsigned int bits;
+
+ bits = glyphp[0][line];
+ bits |= SHIFT_L(glyphp[1][line], 14);
+ bits |= SHIFT_L(glyphp[2][line], 28);
+ WRITE_IN_BITORDER(base, 0, bits);
+ CHECKRETURN(1);
+ bits = SHIFT_R(glyphp[2][line], 4);
+ bits |= SHIFT_L(glyphp[3][line], 10);
+ bits |= SHIFT_L(glyphp[4][line], 24);
+ WRITE_IN_BITORDER(base, 1, bits);
+ CHECKRETURN(2);
+ bits = SHIFT_R(glyphp[4][line], 8);
+ bits |= SHIFT_L(glyphp[5][line], 6);
+ bits |= SHIFT_L(glyphp[6][line], 20);
+ WRITE_IN_BITORDER(base, 2, bits);
+ CHECKRETURN(3);
+ bits = SHIFT_R(glyphp[6][line], 12);
+ bits |= SHIFT_L(glyphp[7][line], 2);
+ bits |= SHIFT_L(glyphp[8][line], 16);
+ bits |= SHIFT_L(glyphp[9][line], 30);
+ WRITE_IN_BITORDER(base, 3, bits);
+ CHECKRETURN(4);
+ bits = SHIFT_R(glyphp[9][line], 2);
+ bits |= SHIFT_L(glyphp[10][line], 12);
+ bits |= SHIFT_L(glyphp[11][line], 26);
+ WRITE_IN_BITORDER(base, 4, bits);
+ CHECKRETURN(5);
+ bits = SHIFT_R(glyphp[11][line], 6);
+ bits |= SHIFT_L(glyphp[12][line], 8);
+ bits |= SHIFT_L(glyphp[13][line], 22);
+ WRITE_IN_BITORDER(base, 5, bits);
+ CHECKRETURN(6);
+ bits = SHIFT_R(glyphp[13][line], 10);
+ bits |= SHIFT_L(glyphp[14][line], 4);
+ bits |= SHIFT_L(glyphp[15][line], 18);
+ WRITE_IN_BITORDER(base, 6, bits);
+ CHECKRETURN(7);
+#ifndef FIXEDBASE
+ base += 7;
+#endif
+ width -= 224;
+ glyphp += 16;
+ }
+ return base;
+}
+
+static CARD32 *
+DrawTETextScanlineWidth16(CARD32 *base,
+ unsigned int **glyphp,
+ int line, int width, int glyphwidth)
+{
+ while (1) {
+ unsigned int bits;
+
+ bits = glyphp[0][line];
+ bits |= SHIFT_L(glyphp[1][line], 16);
+ WRITE_IN_BITORDER(base, 0, bits);
+ CHECKRETURN(1);
+ bits = glyphp[2][line];
+ bits |= SHIFT_L(glyphp[3][line], 16);
+ WRITE_IN_BITORDER(base, 1, bits);
+ CHECKRETURN(2);
+ bits = glyphp[4][line];
+ bits |= SHIFT_L(glyphp[5][line], 16);
+ WRITE_IN_BITORDER(base, 2, bits);
+ CHECKRETURN(3);
+ bits = glyphp[6][line];
+ bits |= SHIFT_L(glyphp[7][line], 16);
+ WRITE_IN_BITORDER(base, 3, bits);
+ CHECKRETURN(4);
+#ifndef FIXEDBASE
+ base += 4;
+#endif
+ width -= 128;
+ glyphp += 8;
+ }
+ return base;
+}
+
+static CARD32 *
+DrawTETextScanlineWidth18(CARD32 *base,
+ unsigned int **glyphp,
+ int line, int width, int glyphwidth)
+{
+ while (1) {
+ unsigned int bits;
+
+ bits = glyphp[0][line];
+ bits |= SHIFT_L(glyphp[1][line], 18);
+ WRITE_IN_BITORDER(base, 0, bits);
+ CHECKRETURN(1);
+ bits = SHIFT_R(glyphp[1][line], 14);
+ bits |= SHIFT_L(glyphp[2][line], 4);
+ bits |= SHIFT_L(glyphp[3][line], 22);
+ WRITE_IN_BITORDER(base, 1, bits);
+ CHECKRETURN(2);
+ bits = SHIFT_R(glyphp[3][line], 10);
+ bits |= SHIFT_L(glyphp[4][line], 8);
+ bits |= SHIFT_L(glyphp[5][line], 26);
+ WRITE_IN_BITORDER(base, 2, bits);
+ CHECKRETURN(3);
+ bits = SHIFT_R(glyphp[5][line], 6);
+ bits |= SHIFT_L(glyphp[6][line], 12);
+ bits |= SHIFT_L(glyphp[7][line], 30);
+ WRITE_IN_BITORDER(base, 3, bits);
+ CHECKRETURN(4);
+ bits = SHIFT_R(glyphp[7][line], 2);
+ bits |= SHIFT_L(glyphp[8][line], 16);
+ WRITE_IN_BITORDER(base, 4, bits);
+ CHECKRETURN(5);
+ bits = SHIFT_R(glyphp[8][line], 16);
+ bits |= SHIFT_L(glyphp[9][line], 2);
+ bits |= SHIFT_L(glyphp[10][line], 20);
+ WRITE_IN_BITORDER(base, 5, bits);
+ CHECKRETURN(6);
+ bits = SHIFT_R(glyphp[10][line], 12);
+ bits |= SHIFT_L(glyphp[11][line], 6);
+ bits |= SHIFT_L(glyphp[12][line], 24);
+ WRITE_IN_BITORDER(base, 6, bits);
+ CHECKRETURN(7);
+ bits = SHIFT_R(glyphp[12][line], 8);
+ bits |= SHIFT_L(glyphp[13][line], 10);
+ bits |= SHIFT_L(glyphp[14][line], 28);
+ WRITE_IN_BITORDER(base, 7, bits);
+ CHECKRETURN(8);
+ bits = SHIFT_R(glyphp[14][line], 4);
+ bits |= SHIFT_L(glyphp[15][line], 14);
+ WRITE_IN_BITORDER(base, 8, bits);
+ CHECKRETURN(9);
+#ifndef FIXEDBASE
+ base += 9;
+#endif
+ width -= 288;
+ glyphp += 16;
+ }
+ return base;
+}
+
+static CARD32 *
+DrawTETextScanlineWidth24(CARD32 *base,
+ unsigned int **glyphp,
+ int line, int width, int glyphwidth)
+{
+ while (1) {
+ unsigned int bits;
+
+ bits = glyphp[0][line];
+ bits |= SHIFT_L(glyphp[1][line], 24);
+ WRITE_IN_BITORDER(base, 0, bits);
+ CHECKRETURN(1);
+ bits = SHIFT_R(glyphp[1][line], 8);
+ bits |= SHIFT_L(glyphp[2][line], 16);
+ WRITE_IN_BITORDER(base, 1, bits);
+ CHECKRETURN(2);
+ bits = SHIFT_R(glyphp[2][line], 16);
+ bits |= SHIFT_L(glyphp[3][line], 8);
+ WRITE_IN_BITORDER(base, 2, bits);
+ CHECKRETURN(3);
+#ifndef FIXEDBASE
+ base += 3;
+#endif
+ width -= 96;
+ glyphp += 4;
+ }
+ return base;
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaTEText.c b/xorg-server/hw/xfree86/xaa/xaaTEText.c
index 2cc5fc1e6..a5ef44768 100644
--- a/xorg-server/hw/xfree86/xaa/xaaTEText.c
+++ b/xorg-server/hw/xfree86/xaa/xaaTEText.c
@@ -1,311 +1,295 @@
-
-/********************************************************************
-
- In this file we have GC level replacements for PolyText8/16,
- ImageText8/16, ImageGlyphBlt and PolyGlyphBlt for TE (fixed) fonts.
- The idea is that everything in this file is device independent.
- The mentioned GCOps are merely wrappers for XAAGlyphBltTEColorExpansion
- which calculates the boxes containing arbitrarily clipped text
- and passes them to the TEGlyphRenderer which will usually be a lower
- level XAA function which renders these clipped glyphs using
- the basic color expansion functions exported by the chipset driver.
- The TEGlyphRenderer itself may optionally be driver supplied to
- facilitate work-arounds/optimizations at a higher level than usual.
-
- v1.0 - Mark Vojkovich (mvojkovi@ucsd.edu)
-
-
-********************************************************************/
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include <X11/fonts/font.h>
-#include "scrnintstr.h"
-#include "dixfontstr.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-#include "gcstruct.h"
-#include "pixmapstr.h"
-
-
-static void XAAGlyphBltTEColorExpansion(ScrnInfoPtr pScrn, int xInit,
- int yInit, FontPtr font, int fg, int bg, int rop,
- unsigned int planemask, RegionPtr cclip, int nglyph,
- unsigned char* gBase, CharInfoPtr *ppci);
-
-
-/********************************************************************
-
- GC level replacements for PolyText8/16 and ImageText8/16
- for TE fonts when using color expansion.
-
-********************************************************************/
-
-
-int
-XAAPolyText8TEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- char *chars )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- unsigned long n;
-
- (*pGC->font->get_glyphs)(pGC->font, (unsigned long)count,
- (unsigned char *)chars, Linear8Bit, &n, infoRec->CharInfo);
-
- /* we have divorced XAAGlyphBltTEColorExpansion from the drawable */
- if(n) XAAGlyphBltTEColorExpansion(
- infoRec->pScrn, x + pDraw->x, y + pDraw->y,
- pGC->font, pGC->fgPixel, -1, pGC->alu, pGC->planemask,
- pGC->pCompositeClip, n, FONTGLYPHS(pGC->font), infoRec->CharInfo);
-
- return (x + (n * FONTMAXBOUNDS(pGC->font, characterWidth)));
-}
-
-
-int
-XAAPolyText16TEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- unsigned short *chars )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- unsigned long n;
-
- (*pGC->font->get_glyphs)(
- pGC->font, (unsigned long)count, (unsigned char *)chars,
- (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
- &n, infoRec->CharInfo);
-
- if(n) XAAGlyphBltTEColorExpansion(
- infoRec->pScrn, x + pDraw->x, y + pDraw->y,
- pGC->font, pGC->fgPixel, -1, pGC->alu, pGC->planemask,
- pGC->pCompositeClip, n, FONTGLYPHS(pGC->font), infoRec->CharInfo);
-
- return (x + (n * FONTMAXBOUNDS(pGC->font, characterWidth)));
-}
-
-
-void
-XAAImageText8TEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- char *chars )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- unsigned long n;
-
- if(!RegionNumRects(pGC->pCompositeClip))
- return;
-
- (*pGC->font->get_glyphs)(pGC->font, (unsigned long)count,
- (unsigned char *)chars, Linear8Bit, &n, infoRec->CharInfo);
-
- if(n) XAAGlyphBltTEColorExpansion(
- infoRec->pScrn, x + pDraw->x, y + pDraw->y,
- pGC->font, pGC->fgPixel, pGC->bgPixel, GXcopy, pGC->planemask,
- pGC->pCompositeClip, n, FONTGLYPHS(pGC->font), infoRec->CharInfo);
-}
-
-
-void
-XAAImageText16TEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- unsigned short *chars )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- unsigned long n;
-
- if(!RegionNumRects(pGC->pCompositeClip))
- return;
-
- (*pGC->font->get_glyphs)(
- pGC->font, (unsigned long)count, (unsigned char *)chars,
- (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
- &n, infoRec->CharInfo);
-
- if(n) XAAGlyphBltTEColorExpansion(
- infoRec->pScrn, x + pDraw->x, y + pDraw->y,
- pGC->font, pGC->fgPixel, pGC->bgPixel, GXcopy, pGC->planemask,
- pGC->pCompositeClip, n, FONTGLYPHS(pGC->font), infoRec->CharInfo);
-}
-
-
-
-/********************************************************************
-
- GC level replacements for ImageGlyphBlt and PolyGlyphBlt for
- TE fonts when using color expansion.
-
-********************************************************************/
-
-
-void
-XAAImageGlyphBltTEColorExpansion(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-
- if(!RegionNumRects(pGC->pCompositeClip))
- return;
-
- XAAGlyphBltTEColorExpansion(
- infoRec->pScrn, xInit + pDrawable->x, yInit + pDrawable->y,
- pGC->font, pGC->fgPixel, pGC->bgPixel, GXcopy, pGC->planemask,
- pGC->pCompositeClip, nglyph, (unsigned char*)pglyphBase, ppci);
-}
-
-void
-XAAPolyGlyphBltTEColorExpansion(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-
- if(!RegionNumRects(pGC->pCompositeClip))
- return;
-
- XAAGlyphBltTEColorExpansion(
- infoRec->pScrn, xInit + pDrawable->x, yInit + pDrawable->y,
- pGC->font, pGC->fgPixel, -1, pGC->alu, pGC->planemask,
- pGC->pCompositeClip, nglyph, (unsigned char*)pglyphBase, ppci);
-}
-
-
-
-
-/********************************************************************
-
- XAAGlyphBltTEColorExpansion -
-
- This guy computes the clipped pieces of text and sends it to
- the lower-level function which will handle acceleration of
- arbitrarily clipped text.
-
-********************************************************************/
-
-
-static void
-XAAGlyphBltTEColorExpansion(
- ScrnInfoPtr pScrn,
- int xInit, int yInit,
- FontPtr font,
- int fg, int bg,
- int rop,
- unsigned int planemask,
- RegionPtr cclip,
- int nglyph,
- unsigned char* gBase,
- CharInfoPtr *ppci )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int skippix, skipglyphs;
- int Left, Right, Top, Bottom;
- int LeftEdge, RightEdge, ytop, ybot;
- int nbox = RegionNumRects(cclip);
- BoxPtr pbox = RegionRects(cclip);
- unsigned int **glyphs = NULL;
- int glyphWidth = FONTMAXBOUNDS(font, characterWidth);
-
- /* find the size of the box */
- Left = xInit;
- Right = Left + (glyphWidth * nglyph);
- Top = yInit - FONTASCENT(font);
- Bottom = yInit + FONTDESCENT(font);
-
- /* get into the first band that may contain part of our string */
- while(nbox && (Top >= pbox->y2)) {
- pbox++; nbox--;
- }
-
- /* stop when the lower edge of the box is beyond our string */
- while(nbox && (Bottom > pbox->y1)) {
- LeftEdge = max(Left, pbox->x1);
- RightEdge = min(Right, pbox->x2);
-
- if(RightEdge > LeftEdge) { /* we have something to draw */
- unsigned int *fallbackBits = NULL;
- ytop = max(Top, pbox->y1);
- ybot = min(Bottom, pbox->y2);
-
- if((skippix = LeftEdge - Left)) {
- skipglyphs = skippix/glyphWidth;
- skippix %= glyphWidth;
- } else skipglyphs = 0;
-
- if(!glyphs) {
- int count;
- glyphs = (unsigned int**)(infoRec->PreAllocMem);
-
- for(count = 0; count < nglyph; count++) {
- glyphs[count] = (unsigned int*)
- FONTGLYPHBITS(gBase,*ppci++);
- if (!glyphs[count]) {
- /* Glyphs with NULL bits do exist in the wild.
- Replace with blank bits in that case */
-
- if (!fallbackBits) {
- int fontHeight = Bottom - Top + 1;
- fallbackBits = calloc(glyphWidth * fontHeight, 1);
- if (!fallbackBits)
- return;
- }
- glyphs[count] = fallbackBits;
- }
- }
-
- /* our new unrolled TE code only writes DWORDS at a time
- so it can read up to 6 characters past the last one
- we're displaying */
- glyphs[count + 0] = glyphs[0];
- glyphs[count + 1] = glyphs[0];
- glyphs[count + 2] = glyphs[0];
- glyphs[count + 3] = glyphs[0];
- glyphs[count + 4] = glyphs[0];
- glyphs[count + 5] = glyphs[0];
- }
-
- /* x, y, w, h, skipleft, skiptop, glyphp, glyphWidth, fg, bg, rop, pm */
-
- (*infoRec->TEGlyphRenderer)( pScrn,
- LeftEdge, ytop, RightEdge - LeftEdge, ybot - ytop,
- skippix, ytop - Top, glyphs + skipglyphs, glyphWidth,
- fg, bg, rop, planemask);
-
- free(fallbackBits);
- }
-
- nbox--; pbox++;
- }
-}
-
-
-
-
+
+/********************************************************************
+
+ In this file we have GC level replacements for PolyText8/16,
+ ImageText8/16, ImageGlyphBlt and PolyGlyphBlt for TE (fixed) fonts.
+ The idea is that everything in this file is device independent.
+ The mentioned GCOps are merely wrappers for XAAGlyphBltTEColorExpansion
+ which calculates the boxes containing arbitrarily clipped text
+ and passes them to the TEGlyphRenderer which will usually be a lower
+ level XAA function which renders these clipped glyphs using
+ the basic color expansion functions exported by the chipset driver.
+ The TEGlyphRenderer itself may optionally be driver supplied to
+ facilitate work-arounds/optimizations at a higher level than usual.
+
+ v1.0 - Mark Vojkovich (mvojkovi@ucsd.edu)
+
+********************************************************************/
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include <X11/fonts/font.h>
+#include "scrnintstr.h"
+#include "dixfontstr.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+
+static void XAAGlyphBltTEColorExpansion(ScrnInfoPtr pScrn, int xInit,
+ int yInit, FontPtr font, int fg, int bg,
+ int rop, unsigned int planemask,
+ RegionPtr cclip, int nglyph,
+ unsigned char *gBase,
+ CharInfoPtr * ppci);
+
+/********************************************************************
+
+ GC level replacements for PolyText8/16 and ImageText8/16
+ for TE fonts when using color expansion.
+
+********************************************************************/
+
+int
+XAAPolyText8TEColorExpansion(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ unsigned long n;
+
+ (*pGC->font->get_glyphs) (pGC->font, (unsigned long) count,
+ (unsigned char *) chars, Linear8Bit, &n,
+ infoRec->CharInfo);
+
+ /* we have divorced XAAGlyphBltTEColorExpansion from the drawable */
+ if (n)
+ XAAGlyphBltTEColorExpansion(infoRec->pScrn, x + pDraw->x, y + pDraw->y,
+ pGC->font, pGC->fgPixel, -1, pGC->alu,
+ pGC->planemask, pGC->pCompositeClip, n,
+ FONTGLYPHS(pGC->font), infoRec->CharInfo);
+
+ return (x + (n * FONTMAXBOUNDS(pGC->font, characterWidth)));
+}
+
+int
+XAAPolyText16TEColorExpansion(DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y, int count, unsigned short *chars)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ unsigned long n;
+
+ (*pGC->font->get_glyphs) (pGC->font, (unsigned long) count,
+ (unsigned char *) chars,
+ (FONTLASTROW(pGC->font) ==
+ 0) ? Linear16Bit : TwoD16Bit, &n,
+ infoRec->CharInfo);
+
+ if (n)
+ XAAGlyphBltTEColorExpansion(infoRec->pScrn, x + pDraw->x, y + pDraw->y,
+ pGC->font, pGC->fgPixel, -1, pGC->alu,
+ pGC->planemask, pGC->pCompositeClip, n,
+ FONTGLYPHS(pGC->font), infoRec->CharInfo);
+
+ return (x + (n * FONTMAXBOUNDS(pGC->font, characterWidth)));
+}
+
+void
+XAAImageText8TEColorExpansion(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ unsigned long n;
+
+ if (!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ (*pGC->font->get_glyphs) (pGC->font, (unsigned long) count,
+ (unsigned char *) chars, Linear8Bit, &n,
+ infoRec->CharInfo);
+
+ if (n)
+ XAAGlyphBltTEColorExpansion(infoRec->pScrn, x + pDraw->x, y + pDraw->y,
+ pGC->font, pGC->fgPixel, pGC->bgPixel,
+ GXcopy, pGC->planemask, pGC->pCompositeClip,
+ n, FONTGLYPHS(pGC->font),
+ infoRec->CharInfo);
+}
+
+void
+XAAImageText16TEColorExpansion(DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y, int count, unsigned short *chars)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ unsigned long n;
+
+ if (!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ (*pGC->font->get_glyphs) (pGC->font, (unsigned long) count,
+ (unsigned char *) chars,
+ (FONTLASTROW(pGC->font) ==
+ 0) ? Linear16Bit : TwoD16Bit, &n,
+ infoRec->CharInfo);
+
+ if (n)
+ XAAGlyphBltTEColorExpansion(infoRec->pScrn, x + pDraw->x, y + pDraw->y,
+ pGC->font, pGC->fgPixel, pGC->bgPixel,
+ GXcopy, pGC->planemask, pGC->pCompositeClip,
+ n, FONTGLYPHS(pGC->font),
+ infoRec->CharInfo);
+}
+
+/********************************************************************
+
+ GC level replacements for ImageGlyphBlt and PolyGlyphBlt for
+ TE fonts when using color expansion.
+
+********************************************************************/
+
+void
+XAAImageGlyphBltTEColorExpansion(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
+ if (!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ XAAGlyphBltTEColorExpansion(infoRec->pScrn, xInit + pDrawable->x,
+ yInit + pDrawable->y, pGC->font, pGC->fgPixel,
+ pGC->bgPixel, GXcopy, pGC->planemask,
+ pGC->pCompositeClip, nglyph,
+ (unsigned char *) pglyphBase, ppci);
+}
+
+void
+XAAPolyGlyphBltTEColorExpansion(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
+ if (!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ XAAGlyphBltTEColorExpansion(infoRec->pScrn, xInit + pDrawable->x,
+ yInit + pDrawable->y, pGC->font, pGC->fgPixel,
+ -1, pGC->alu, pGC->planemask,
+ pGC->pCompositeClip, nglyph,
+ (unsigned char *) pglyphBase, ppci);
+}
+
+/********************************************************************
+
+ XAAGlyphBltTEColorExpansion -
+
+ This guy computes the clipped pieces of text and sends it to
+ the lower-level function which will handle acceleration of
+ arbitrarily clipped text.
+
+********************************************************************/
+
+static void
+XAAGlyphBltTEColorExpansion(ScrnInfoPtr pScrn,
+ int xInit, int yInit,
+ FontPtr font,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask,
+ RegionPtr cclip,
+ int nglyph,
+ unsigned char *gBase, CharInfoPtr * ppci)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int skippix, skipglyphs;
+ int Left, Right, Top, Bottom;
+ int LeftEdge, RightEdge, ytop, ybot;
+ int nbox = RegionNumRects(cclip);
+ BoxPtr pbox = RegionRects(cclip);
+ unsigned int **glyphs = NULL;
+ int glyphWidth = FONTMAXBOUNDS(font, characterWidth);
+
+ /* find the size of the box */
+ Left = xInit;
+ Right = Left + (glyphWidth * nglyph);
+ Top = yInit - FONTASCENT(font);
+ Bottom = yInit + FONTDESCENT(font);
+
+ /* get into the first band that may contain part of our string */
+ while (nbox && (Top >= pbox->y2)) {
+ pbox++;
+ nbox--;
+ }
+
+ /* stop when the lower edge of the box is beyond our string */
+ while (nbox && (Bottom > pbox->y1)) {
+ LeftEdge = max(Left, pbox->x1);
+ RightEdge = min(Right, pbox->x2);
+
+ if (RightEdge > LeftEdge) { /* we have something to draw */
+ unsigned int *fallbackBits = NULL;
+
+ ytop = max(Top, pbox->y1);
+ ybot = min(Bottom, pbox->y2);
+
+ if ((skippix = LeftEdge - Left)) {
+ skipglyphs = skippix / glyphWidth;
+ skippix %= glyphWidth;
+ }
+ else
+ skipglyphs = 0;
+
+ if (!glyphs) {
+ int count;
+
+ glyphs = (unsigned int **) (infoRec->PreAllocMem);
+
+ for (count = 0; count < nglyph; count++) {
+ glyphs[count] = (unsigned int *)
+ FONTGLYPHBITS(gBase, *ppci++);
+ if (!glyphs[count]) {
+ /* Glyphs with NULL bits do exist in the wild.
+ Replace with blank bits in that case */
+
+ if (!fallbackBits) {
+ int fontHeight = Bottom - Top + 1;
+
+ fallbackBits = calloc(glyphWidth * fontHeight, 1);
+ if (!fallbackBits)
+ return;
+ }
+ glyphs[count] = fallbackBits;
+ }
+ }
+
+ /* our new unrolled TE code only writes DWORDS at a time
+ so it can read up to 6 characters past the last one
+ we're displaying */
+ glyphs[count + 0] = glyphs[0];
+ glyphs[count + 1] = glyphs[0];
+ glyphs[count + 2] = glyphs[0];
+ glyphs[count + 3] = glyphs[0];
+ glyphs[count + 4] = glyphs[0];
+ glyphs[count + 5] = glyphs[0];
+ }
+
+ /* x, y, w, h, skipleft, skiptop, glyphp, glyphWidth, fg, bg, rop, pm */
+
+ (*infoRec->TEGlyphRenderer) (pScrn,
+ LeftEdge, ytop, RightEdge - LeftEdge,
+ ybot - ytop, skippix, ytop - Top,
+ glyphs + skipglyphs, glyphWidth, fg,
+ bg, rop, planemask);
+
+ free(fallbackBits);
+ }
+
+ nbox--;
+ pbox++;
+ }
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaTables.c b/xorg-server/hw/xfree86/xaa/xaaTables.c
index dbeb4a269..35641da59 100644
--- a/xorg-server/hw/xfree86/xaa/xaaTables.c
+++ b/xorg-server/hw/xfree86/xaa/xaaTables.c
@@ -9,40 +9,71 @@
* bit order within a byte.
*/
-unsigned int byte_expand3[256] =
-{
- 0x000000, 0x000007, 0x000038, 0x00003F, 0x0001C0, 0x0001C7, 0x0001F8, 0x0001FF,
- 0x000E00, 0x000E07, 0x000E38, 0x000E3F, 0x000FC0, 0x000FC7, 0x000FF8, 0x000FFF,
- 0x007000, 0x007007, 0x007038, 0x00703F, 0x0071C0, 0x0071C7, 0x0071F8, 0x0071FF,
- 0x007E00, 0x007E07, 0x007E38, 0x007E3F, 0x007FC0, 0x007FC7, 0x007FF8, 0x007FFF,
- 0x038000, 0x038007, 0x038038, 0x03803F, 0x0381C0, 0x0381C7, 0x0381F8, 0x0381FF,
- 0x038E00, 0x038E07, 0x038E38, 0x038E3F, 0x038FC0, 0x038FC7, 0x038FF8, 0x038FFF,
- 0x03F000, 0x03F007, 0x03F038, 0x03F03F, 0x03F1C0, 0x03F1C7, 0x03F1F8, 0x03F1FF,
- 0x03FE00, 0x03FE07, 0x03FE38, 0x03FE3F, 0x03FFC0, 0x03FFC7, 0x03FFF8, 0x03FFFF,
- 0x1C0000, 0x1C0007, 0x1C0038, 0x1C003F, 0x1C01C0, 0x1C01C7, 0x1C01F8, 0x1C01FF,
- 0x1C0E00, 0x1C0E07, 0x1C0E38, 0x1C0E3F, 0x1C0FC0, 0x1C0FC7, 0x1C0FF8, 0x1C0FFF,
- 0x1C7000, 0x1C7007, 0x1C7038, 0x1C703F, 0x1C71C0, 0x1C71C7, 0x1C71F8, 0x1C71FF,
- 0x1C7E00, 0x1C7E07, 0x1C7E38, 0x1C7E3F, 0x1C7FC0, 0x1C7FC7, 0x1C7FF8, 0x1C7FFF,
- 0x1F8000, 0x1F8007, 0x1F8038, 0x1F803F, 0x1F81C0, 0x1F81C7, 0x1F81F8, 0x1F81FF,
- 0x1F8E00, 0x1F8E07, 0x1F8E38, 0x1F8E3F, 0x1F8FC0, 0x1F8FC7, 0x1F8FF8, 0x1F8FFF,
- 0x1FF000, 0x1FF007, 0x1FF038, 0x1FF03F, 0x1FF1C0, 0x1FF1C7, 0x1FF1F8, 0x1FF1FF,
- 0x1FFE00, 0x1FFE07, 0x1FFE38, 0x1FFE3F, 0x1FFFC0, 0x1FFFC7, 0x1FFFF8, 0x1FFFFF,
- 0xE00000, 0xE00007, 0xE00038, 0xE0003F, 0xE001C0, 0xE001C7, 0xE001F8, 0xE001FF,
- 0xE00E00, 0xE00E07, 0xE00E38, 0xE00E3F, 0xE00FC0, 0xE00FC7, 0xE00FF8, 0xE00FFF,
- 0xE07000, 0xE07007, 0xE07038, 0xE0703F, 0xE071C0, 0xE071C7, 0xE071F8, 0xE071FF,
- 0xE07E00, 0xE07E07, 0xE07E38, 0xE07E3F, 0xE07FC0, 0xE07FC7, 0xE07FF8, 0xE07FFF,
- 0xE38000, 0xE38007, 0xE38038, 0xE3803F, 0xE381C0, 0xE381C7, 0xE381F8, 0xE381FF,
- 0xE38E00, 0xE38E07, 0xE38E38, 0xE38E3F, 0xE38FC0, 0xE38FC7, 0xE38FF8, 0xE38FFF,
- 0xE3F000, 0xE3F007, 0xE3F038, 0xE3F03F, 0xE3F1C0, 0xE3F1C7, 0xE3F1F8, 0xE3F1FF,
- 0xE3FE00, 0xE3FE07, 0xE3FE38, 0xE3FE3F, 0xE3FFC0, 0xE3FFC7, 0xE3FFF8, 0xE3FFFF,
- 0xFC0000, 0xFC0007, 0xFC0038, 0xFC003F, 0xFC01C0, 0xFC01C7, 0xFC01F8, 0xFC01FF,
- 0xFC0E00, 0xFC0E07, 0xFC0E38, 0xFC0E3F, 0xFC0FC0, 0xFC0FC7, 0xFC0FF8, 0xFC0FFF,
- 0xFC7000, 0xFC7007, 0xFC7038, 0xFC703F, 0xFC71C0, 0xFC71C7, 0xFC71F8, 0xFC71FF,
- 0xFC7E00, 0xFC7E07, 0xFC7E38, 0xFC7E3F, 0xFC7FC0, 0xFC7FC7, 0xFC7FF8, 0xFC7FFF,
- 0xFF8000, 0xFF8007, 0xFF8038, 0xFF803F, 0xFF81C0, 0xFF81C7, 0xFF81F8, 0xFF81FF,
- 0xFF8E00, 0xFF8E07, 0xFF8E38, 0xFF8E3F, 0xFF8FC0, 0xFF8FC7, 0xFF8FF8, 0xFF8FFF,
- 0xFFF000, 0xFFF007, 0xFFF038, 0xFFF03F, 0xFFF1C0, 0xFFF1C7, 0xFFF1F8, 0xFFF1FF,
- 0xFFFE00, 0xFFFE07, 0xFFFE38, 0xFFFE3F, 0xFFFFC0, 0xFFFFC7, 0xFFFFF8, 0xFFFFFF
+unsigned int byte_expand3[256] = {
+ 0x000000, 0x000007, 0x000038, 0x00003F, 0x0001C0, 0x0001C7, 0x0001F8,
+ 0x0001FF,
+ 0x000E00, 0x000E07, 0x000E38, 0x000E3F, 0x000FC0, 0x000FC7, 0x000FF8,
+ 0x000FFF,
+ 0x007000, 0x007007, 0x007038, 0x00703F, 0x0071C0, 0x0071C7, 0x0071F8,
+ 0x0071FF,
+ 0x007E00, 0x007E07, 0x007E38, 0x007E3F, 0x007FC0, 0x007FC7, 0x007FF8,
+ 0x007FFF,
+ 0x038000, 0x038007, 0x038038, 0x03803F, 0x0381C0, 0x0381C7, 0x0381F8,
+ 0x0381FF,
+ 0x038E00, 0x038E07, 0x038E38, 0x038E3F, 0x038FC0, 0x038FC7, 0x038FF8,
+ 0x038FFF,
+ 0x03F000, 0x03F007, 0x03F038, 0x03F03F, 0x03F1C0, 0x03F1C7, 0x03F1F8,
+ 0x03F1FF,
+ 0x03FE00, 0x03FE07, 0x03FE38, 0x03FE3F, 0x03FFC0, 0x03FFC7, 0x03FFF8,
+ 0x03FFFF,
+ 0x1C0000, 0x1C0007, 0x1C0038, 0x1C003F, 0x1C01C0, 0x1C01C7, 0x1C01F8,
+ 0x1C01FF,
+ 0x1C0E00, 0x1C0E07, 0x1C0E38, 0x1C0E3F, 0x1C0FC0, 0x1C0FC7, 0x1C0FF8,
+ 0x1C0FFF,
+ 0x1C7000, 0x1C7007, 0x1C7038, 0x1C703F, 0x1C71C0, 0x1C71C7, 0x1C71F8,
+ 0x1C71FF,
+ 0x1C7E00, 0x1C7E07, 0x1C7E38, 0x1C7E3F, 0x1C7FC0, 0x1C7FC7, 0x1C7FF8,
+ 0x1C7FFF,
+ 0x1F8000, 0x1F8007, 0x1F8038, 0x1F803F, 0x1F81C0, 0x1F81C7, 0x1F81F8,
+ 0x1F81FF,
+ 0x1F8E00, 0x1F8E07, 0x1F8E38, 0x1F8E3F, 0x1F8FC0, 0x1F8FC7, 0x1F8FF8,
+ 0x1F8FFF,
+ 0x1FF000, 0x1FF007, 0x1FF038, 0x1FF03F, 0x1FF1C0, 0x1FF1C7, 0x1FF1F8,
+ 0x1FF1FF,
+ 0x1FFE00, 0x1FFE07, 0x1FFE38, 0x1FFE3F, 0x1FFFC0, 0x1FFFC7, 0x1FFFF8,
+ 0x1FFFFF,
+ 0xE00000, 0xE00007, 0xE00038, 0xE0003F, 0xE001C0, 0xE001C7, 0xE001F8,
+ 0xE001FF,
+ 0xE00E00, 0xE00E07, 0xE00E38, 0xE00E3F, 0xE00FC0, 0xE00FC7, 0xE00FF8,
+ 0xE00FFF,
+ 0xE07000, 0xE07007, 0xE07038, 0xE0703F, 0xE071C0, 0xE071C7, 0xE071F8,
+ 0xE071FF,
+ 0xE07E00, 0xE07E07, 0xE07E38, 0xE07E3F, 0xE07FC0, 0xE07FC7, 0xE07FF8,
+ 0xE07FFF,
+ 0xE38000, 0xE38007, 0xE38038, 0xE3803F, 0xE381C0, 0xE381C7, 0xE381F8,
+ 0xE381FF,
+ 0xE38E00, 0xE38E07, 0xE38E38, 0xE38E3F, 0xE38FC0, 0xE38FC7, 0xE38FF8,
+ 0xE38FFF,
+ 0xE3F000, 0xE3F007, 0xE3F038, 0xE3F03F, 0xE3F1C0, 0xE3F1C7, 0xE3F1F8,
+ 0xE3F1FF,
+ 0xE3FE00, 0xE3FE07, 0xE3FE38, 0xE3FE3F, 0xE3FFC0, 0xE3FFC7, 0xE3FFF8,
+ 0xE3FFFF,
+ 0xFC0000, 0xFC0007, 0xFC0038, 0xFC003F, 0xFC01C0, 0xFC01C7, 0xFC01F8,
+ 0xFC01FF,
+ 0xFC0E00, 0xFC0E07, 0xFC0E38, 0xFC0E3F, 0xFC0FC0, 0xFC0FC7, 0xFC0FF8,
+ 0xFC0FFF,
+ 0xFC7000, 0xFC7007, 0xFC7038, 0xFC703F, 0xFC71C0, 0xFC71C7, 0xFC71F8,
+ 0xFC71FF,
+ 0xFC7E00, 0xFC7E07, 0xFC7E38, 0xFC7E3F, 0xFC7FC0, 0xFC7FC7, 0xFC7FF8,
+ 0xFC7FFF,
+ 0xFF8000, 0xFF8007, 0xFF8038, 0xFF803F, 0xFF81C0, 0xFF81C7, 0xFF81F8,
+ 0xFF81FF,
+ 0xFF8E00, 0xFF8E07, 0xFF8E38, 0xFF8E3F, 0xFF8FC0, 0xFF8FC7, 0xFF8FF8,
+ 0xFF8FFF,
+ 0xFFF000, 0xFFF007, 0xFFF038, 0xFFF03F, 0xFFF1C0, 0xFFF1C7, 0xFFF1F8,
+ 0xFFF1FF,
+ 0xFFFE00, 0xFFFE07, 0xFFFE38, 0xFFFE3F, 0xFFFFC0, 0xFFFFC7, 0xFFFFF8,
+ 0xFFFFFF
};
/*
@@ -53,38 +84,69 @@ unsigned int byte_expand3[256] =
* byte.
*/
-unsigned int byte_reversed_expand3[256] =
-{
- 0x000000, 0x0000E0, 0x00001C, 0x0000FC, 0x008003, 0x0080E3, 0x00801F, 0x0080FF,
- 0x007000, 0x0070E0, 0x00701C, 0x0070FC, 0x00F003, 0x00F0E3, 0x00F01F, 0x00F0FF,
- 0x000E00, 0x000EE0, 0x000E1C, 0x000EFC, 0x008E03, 0x008EE3, 0x008E1F, 0x008EFF,
- 0x007E00, 0x007EE0, 0x007E1C, 0x007EFC, 0x00FE03, 0x00FEE3, 0x00FE1F, 0x00FEFF,
- 0xC00100, 0xC001E0, 0xC0011C, 0xC001FC, 0xC08103, 0xC081E3, 0xC0811F, 0xC081FF,
- 0xC07100, 0xC071E0, 0xC0711C, 0xC071FC, 0xC0F103, 0xC0F1E3, 0xC0F11F, 0xC0F1FF,
- 0xC00F00, 0xC00FE0, 0xC00F1C, 0xC00FFC, 0xC08F03, 0xC08FE3, 0xC08F1F, 0xC08FFF,
- 0xC07F00, 0xC07FE0, 0xC07F1C, 0xC07FFC, 0xC0FF03, 0xC0FFE3, 0xC0FF1F, 0xC0FFFF,
- 0x380000, 0x3800E0, 0x38001C, 0x3800FC, 0x388003, 0x3880E3, 0x38801F, 0x3880FF,
- 0x387000, 0x3870E0, 0x38701C, 0x3870FC, 0x38F003, 0x38F0E3, 0x38F01F, 0x38F0FF,
- 0x380E00, 0x380EE0, 0x380E1C, 0x380EFC, 0x388E03, 0x388EE3, 0x388E1F, 0x388EFF,
- 0x387E00, 0x387EE0, 0x387E1C, 0x387EFC, 0x38FE03, 0x38FEE3, 0x38FE1F, 0x38FEFF,
- 0xF80100, 0xF801E0, 0xF8011C, 0xF801FC, 0xF88103, 0xF881E3, 0xF8811F, 0xF881FF,
- 0xF87100, 0xF871E0, 0xF8711C, 0xF871FC, 0xF8F103, 0xF8F1E3, 0xF8F11F, 0xF8F1FF,
- 0xF80F00, 0xF80FE0, 0xF80F1C, 0xF80FFC, 0xF88F03, 0xF88FE3, 0xF88F1F, 0xF88FFF,
- 0xF87F00, 0xF87FE0, 0xF87F1C, 0xF87FFC, 0xF8FF03, 0xF8FFE3, 0xF8FF1F, 0xF8FFFF,
- 0x070000, 0x0700E0, 0x07001C, 0x0700FC, 0x078003, 0x0780E3, 0x07801F, 0x0780FF,
- 0x077000, 0x0770E0, 0x07701C, 0x0770FC, 0x07F003, 0x07F0E3, 0x07F01F, 0x07F0FF,
- 0x070E00, 0x070EE0, 0x070E1C, 0x070EFC, 0x078E03, 0x078EE3, 0x078E1F, 0x078EFF,
- 0x077E00, 0x077EE0, 0x077E1C, 0x077EFC, 0x07FE03, 0x07FEE3, 0x07FE1F, 0x07FEFF,
- 0xC70100, 0xC701E0, 0xC7011C, 0xC701FC, 0xC78103, 0xC781E3, 0xC7811F, 0xC781FF,
- 0xC77100, 0xC771E0, 0xC7711C, 0xC771FC, 0xC7F103, 0xC7F1E3, 0xC7F11F, 0xC7F1FF,
- 0xC70F00, 0xC70FE0, 0xC70F1C, 0xC70FFC, 0xC78F03, 0xC78FE3, 0xC78F1F, 0xC78FFF,
- 0xC77F00, 0xC77FE0, 0xC77F1C, 0xC77FFC, 0xC7FF03, 0xC7FFE3, 0xC7FF1F, 0xC7FFFF,
- 0x3F0000, 0x3F00E0, 0x3F001C, 0x3F00FC, 0x3F8003, 0x3F80E3, 0x3F801F, 0x3F80FF,
- 0x3F7000, 0x3F70E0, 0x3F701C, 0x3F70FC, 0x3FF003, 0x3FF0E3, 0x3FF01F, 0x3FF0FF,
- 0x3F0E00, 0x3F0EE0, 0x3F0E1C, 0x3F0EFC, 0x3F8E03, 0x3F8EE3, 0x3F8E1F, 0x3F8EFF,
- 0x3F7E00, 0x3F7EE0, 0x3F7E1C, 0x3F7EFC, 0x3FFE03, 0x3FFEE3, 0x3FFE1F, 0x3FFEFF,
- 0xFF0100, 0xFF01E0, 0xFF011C, 0xFF01FC, 0xFF8103, 0xFF81E3, 0xFF811F, 0xFF81FF,
- 0xFF7100, 0xFF71E0, 0xFF711C, 0xFF71FC, 0xFFF103, 0xFFF1E3, 0xFFF11F, 0xFFF1FF,
- 0xFF0F00, 0xFF0FE0, 0xFF0F1C, 0xFF0FFC, 0xFF8F03, 0xFF8FE3, 0xFF8F1F, 0xFF8FFF,
- 0xFF7F00, 0xFF7FE0, 0xFF7F1C, 0xFF7FFC, 0xFFFF03, 0xFFFFE3, 0xFFFF1F, 0xFFFFFF,
+unsigned int byte_reversed_expand3[256] = {
+ 0x000000, 0x0000E0, 0x00001C, 0x0000FC, 0x008003, 0x0080E3, 0x00801F,
+ 0x0080FF,
+ 0x007000, 0x0070E0, 0x00701C, 0x0070FC, 0x00F003, 0x00F0E3, 0x00F01F,
+ 0x00F0FF,
+ 0x000E00, 0x000EE0, 0x000E1C, 0x000EFC, 0x008E03, 0x008EE3, 0x008E1F,
+ 0x008EFF,
+ 0x007E00, 0x007EE0, 0x007E1C, 0x007EFC, 0x00FE03, 0x00FEE3, 0x00FE1F,
+ 0x00FEFF,
+ 0xC00100, 0xC001E0, 0xC0011C, 0xC001FC, 0xC08103, 0xC081E3, 0xC0811F,
+ 0xC081FF,
+ 0xC07100, 0xC071E0, 0xC0711C, 0xC071FC, 0xC0F103, 0xC0F1E3, 0xC0F11F,
+ 0xC0F1FF,
+ 0xC00F00, 0xC00FE0, 0xC00F1C, 0xC00FFC, 0xC08F03, 0xC08FE3, 0xC08F1F,
+ 0xC08FFF,
+ 0xC07F00, 0xC07FE0, 0xC07F1C, 0xC07FFC, 0xC0FF03, 0xC0FFE3, 0xC0FF1F,
+ 0xC0FFFF,
+ 0x380000, 0x3800E0, 0x38001C, 0x3800FC, 0x388003, 0x3880E3, 0x38801F,
+ 0x3880FF,
+ 0x387000, 0x3870E0, 0x38701C, 0x3870FC, 0x38F003, 0x38F0E3, 0x38F01F,
+ 0x38F0FF,
+ 0x380E00, 0x380EE0, 0x380E1C, 0x380EFC, 0x388E03, 0x388EE3, 0x388E1F,
+ 0x388EFF,
+ 0x387E00, 0x387EE0, 0x387E1C, 0x387EFC, 0x38FE03, 0x38FEE3, 0x38FE1F,
+ 0x38FEFF,
+ 0xF80100, 0xF801E0, 0xF8011C, 0xF801FC, 0xF88103, 0xF881E3, 0xF8811F,
+ 0xF881FF,
+ 0xF87100, 0xF871E0, 0xF8711C, 0xF871FC, 0xF8F103, 0xF8F1E3, 0xF8F11F,
+ 0xF8F1FF,
+ 0xF80F00, 0xF80FE0, 0xF80F1C, 0xF80FFC, 0xF88F03, 0xF88FE3, 0xF88F1F,
+ 0xF88FFF,
+ 0xF87F00, 0xF87FE0, 0xF87F1C, 0xF87FFC, 0xF8FF03, 0xF8FFE3, 0xF8FF1F,
+ 0xF8FFFF,
+ 0x070000, 0x0700E0, 0x07001C, 0x0700FC, 0x078003, 0x0780E3, 0x07801F,
+ 0x0780FF,
+ 0x077000, 0x0770E0, 0x07701C, 0x0770FC, 0x07F003, 0x07F0E3, 0x07F01F,
+ 0x07F0FF,
+ 0x070E00, 0x070EE0, 0x070E1C, 0x070EFC, 0x078E03, 0x078EE3, 0x078E1F,
+ 0x078EFF,
+ 0x077E00, 0x077EE0, 0x077E1C, 0x077EFC, 0x07FE03, 0x07FEE3, 0x07FE1F,
+ 0x07FEFF,
+ 0xC70100, 0xC701E0, 0xC7011C, 0xC701FC, 0xC78103, 0xC781E3, 0xC7811F,
+ 0xC781FF,
+ 0xC77100, 0xC771E0, 0xC7711C, 0xC771FC, 0xC7F103, 0xC7F1E3, 0xC7F11F,
+ 0xC7F1FF,
+ 0xC70F00, 0xC70FE0, 0xC70F1C, 0xC70FFC, 0xC78F03, 0xC78FE3, 0xC78F1F,
+ 0xC78FFF,
+ 0xC77F00, 0xC77FE0, 0xC77F1C, 0xC77FFC, 0xC7FF03, 0xC7FFE3, 0xC7FF1F,
+ 0xC7FFFF,
+ 0x3F0000, 0x3F00E0, 0x3F001C, 0x3F00FC, 0x3F8003, 0x3F80E3, 0x3F801F,
+ 0x3F80FF,
+ 0x3F7000, 0x3F70E0, 0x3F701C, 0x3F70FC, 0x3FF003, 0x3FF0E3, 0x3FF01F,
+ 0x3FF0FF,
+ 0x3F0E00, 0x3F0EE0, 0x3F0E1C, 0x3F0EFC, 0x3F8E03, 0x3F8EE3, 0x3F8E1F,
+ 0x3F8EFF,
+ 0x3F7E00, 0x3F7EE0, 0x3F7E1C, 0x3F7EFC, 0x3FFE03, 0x3FFEE3, 0x3FFE1F,
+ 0x3FFEFF,
+ 0xFF0100, 0xFF01E0, 0xFF011C, 0xFF01FC, 0xFF8103, 0xFF81E3, 0xFF811F,
+ 0xFF81FF,
+ 0xFF7100, 0xFF71E0, 0xFF711C, 0xFF71FC, 0xFFF103, 0xFFF1E3, 0xFFF11F,
+ 0xFFF1FF,
+ 0xFF0F00, 0xFF0FE0, 0xFF0F1C, 0xFF0FFC, 0xFF8F03, 0xFF8FE3, 0xFF8F1F,
+ 0xFF8FFF,
+ 0xFF7F00, 0xFF7FE0, 0xFF7F1C, 0xFF7FFC, 0xFFFF03, 0xFFFFE3, 0xFFFF1F,
+ 0xFFFFFF,
};
diff --git a/xorg-server/hw/xfree86/xaa/xaaWideLine.c b/xorg-server/hw/xfree86/xaa/xaaWideLine.c
index f73e04f17..b8a53c1c8 100644
--- a/xorg-server/hw/xfree86/xaa/xaaWideLine.c
+++ b/xorg-server/hw/xfree86/xaa/xaaWideLine.c
@@ -1,921 +1,924 @@
-/*
-
-XAAPolylinesWideSolid does not maintain a span list and subsequently does
-not follow the "touch-each-pixel-once" rules for wide lines and arcs.
-This means it can only be used in the case where we have
-miSpansEasyRop(pGC->alu). Since we clip spans on the fly, we
-limited usage of this function to one rect situations. This
-function is used only for solid lines.
-
- Adapted from miWideLine by Mark Vojkovich (mvojkovi@ucsd.edu)
-Original mi code written by Keith Packard.
-
-*/
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <math.h>
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "windowstr.h"
-#include "gcstruct.h"
-#include "regionstr.h"
-#include "miwideline.h"
-#include "mi.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-
-#define DRAW_POINT(pScrn, x, y) \
- if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, 1); \
- else XAAPointHelper(pScrn, x, y)
-
-#define FILL_RECT(pScrn, x, y, w, h) \
- if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); \
- else XAAFillRectHelper(pScrn, x, y, w, h)
-
-#define FILL_SPAN(pScrn, x, y, w) \
- if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, 1); \
- else XAASpanHelper(pScrn, x, y, w)
-
-
-#define CLIPSTEPEDGE(edgey,edge,edgeleft) \
- if (ybase == edgey) { \
- if (edgeleft) { \
- if (edge->x > xcl) \
- xcl = edge->x; \
- } else { \
- if (edge->x < xcr) \
- xcr = edge->x; \
- } \
- edgey++; \
- edge->x += edge->stepx; \
- edge->e += edge->dx; \
- if (edge->e > 0) { \
- edge->x += edge->signdx; \
- edge->e -= edge->dy; \
- } \
- }
-
-static void
-XAAPointHelper(ScrnInfoPtr pScrn, int x, int y)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- BoxPtr extents = infoRec->ClipBox;
-
- if((x >= extents->x1) && (x < extents->x2) &&
- (y >= extents->y1) && (y < extents->y2))
- (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, 1);
-}
-
-static void
-XAAFillRectHelper(ScrnInfoPtr pScrn, int x1, int y1, int dx, int dy)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- BoxPtr extents = infoRec->ClipBox;
- int x2 = x1 + dx;
- int y2 = y1 + dy;
-
- if(x1 < extents->x1) x1 = extents->x1;
- if(x2 >= extents->x2) x2 = extents->x2;
- if((dx = x2 - x1)<1) return;
- if(y1 < extents->y1) y1 = extents->y1;
- if(y2 >= extents->y2) y2 = extents->y2;
- if((dy = y2 - y1)<1) return;
-
- (*infoRec->SubsequentSolidFillRect)(pScrn, x1, y1, dx, dy);
-}
-
-
-static void
-XAASpanHelper(ScrnInfoPtr pScrn, int x1, int y, int width)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- BoxPtr extents = infoRec->ClipBox;
- int x2;
-
- if((y < extents->y1) || (y >= extents->y2)) return;
-
- x2 = x1 + width;
- if(x1 < extents->x1) x1 = extents->x1;
- if(x2 > extents->x2) x2 = extents->x2;
- width = x2 - x1;
-
- if(width > 0)
- (*infoRec->SubsequentSolidFillRect)(pScrn, x1, y, width, 1);
-
-}
-
-#define FixError(x, dx, dy, e, sign, step, h) { \
- e += (h) * dx; \
- x += (h) * step; \
- if(e > 0) { \
- x += e * sign/dy; \
- e %= dy; \
- if(e) { \
- x += sign; \
- e -= dy; \
- } \
- } \
-}
-
-
-static void
-XAAFillPolyHelper (
- GCPtr pGC,
- int y, /* start y coordinate */
- int overall_height, /* height of entire segment */
- PolyEdgePtr left, PolyEdgePtr right,
- int left_count, int right_count )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- BoxPtr extents = infoRec->ClipBox;
- int left_x, left_e, left_stepx, left_signdx, left_dy, left_dx;
- int right_x, right_e, right_stepx, right_signdx, right_dy, right_dx;
- int height, left_height, right_height;
- int xorg;
- Bool hardClip;
-
- if((y >= extents->y2) || ((y + overall_height) <= extents->y1))
- return;
-
- /* Muffle compiler */
- left_x = left_e = left_stepx = left_signdx = left_dy = left_dx = 0;
- right_x = right_e = right_stepx = right_signdx = right_dy = right_dx = 0;
-
- left_height = right_height = 0;
- xorg = 0;
-
- hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
-
- while ((left_count || left_height) && (right_count || right_height)) {
- if (!left_height && left_count) {
- left_height = left->height;
- left_x = left->x + xorg;
- left_stepx = left->stepx;
- left_signdx = left->signdx;
- left_e = left->e;
- left_dy = left->dy;
- left_dx = left->dx;
- left_count--;
- left++;
- }
- if (!right_height && right_count) {
- right_height = right->height;
- right_x = right->x + xorg + 1;
- right_stepx = right->stepx;
- right_signdx = right->signdx;
- right_e = right->e;
- right_dy = right->dy;
- right_dx = right->dx;
- right_count--;
- right++;
- }
-
- height = (left_height > right_height) ? right_height : left_height;
-
- left_height -= height;
- right_height -= height;
-
- if(hardClip && infoRec->SubsequentSolidFillTrap && (height > 6)) {
- int right_DX, left_DX;
-
- right_DX = (right_dx * right_signdx) + (right_stepx * right_dy);
- left_DX = (left_dx * left_signdx) + (left_stepx * left_dy);
-
- (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn, y, height,
- left_x, left_DX, left_dy, left_e,
- right_x - 1, right_DX, right_dy, right_e);
-
- FixError(left_x, left_dx, left_dy, left_e, left_signdx,
- left_stepx, height);
- FixError(right_x, right_dx, right_dy, right_e, right_signdx,
- right_stepx, height);
- y += height;
- continue;
- }
-
- while (height--) {
- if(right_x > left_x) {
- FILL_SPAN(infoRec->pScrn, left_x, y, right_x - left_x);
- }
- y++;
-
- left_x += left_stepx;
- left_e += left_dx;
- if (left_e > 0) {
- left_x += left_signdx;
- left_e -= left_dy;
- }
- right_x += right_stepx;
- right_e += right_dx;
- if (right_e > 0) {
- right_x += right_signdx;
- right_e -= right_dy;
- }
-
- }
- }
-}
-
-
-
-static void
-XAAWideSegment (
- GCPtr pGC,
- int x1, int y1, int x2, int y2,
- Bool projectLeft, Bool projectRight,
- LineFacePtr leftFace, LineFacePtr rightFace )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- double l, L, r;
- double xa, ya;
- double projectXoff, projectYoff;
- double k;
- double maxy;
- int x, y;
- int dx, dy;
- int finaly;
- PolyEdgePtr left, right;
- PolyEdgePtr top, bottom;
- int lefty, righty, topy, bottomy;
- int signdx;
- PolyEdgeRec lefts[2], rights[2];
- LineFacePtr tface;
- int lw = pGC->lineWidth;
- Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
-
- /* draw top-to-bottom always */
- if ((y2 < y1) || ((y2 == y1) && (x2 < x1))) {
- x = x1;
- x1 = x2;
- x2 = x;
-
- y = y1;
- y1 = y2;
- y2 = y;
-
- x = projectLeft;
- projectLeft = projectRight;
- projectRight = x;
-
- tface = leftFace;
- leftFace = rightFace;
- rightFace = tface;
- }
-
- dy = y2 - y1;
- signdx = 1;
- dx = x2 - x1;
- if (dx < 0)
- signdx = -1;
-
- leftFace->x = x1;
- leftFace->y = y1;
- leftFace->dx = dx;
- leftFace->dy = dy;
-
- rightFace->x = x2;
- rightFace->y = y2;
- rightFace->dx = -dx;
- rightFace->dy = -dy;
-
- if (!dy) {
- rightFace->xa = 0;
- rightFace->ya = (double) lw / 2.0;
- rightFace->k = -(double) (lw * dx) / 2.0;
- leftFace->xa = 0;
- leftFace->ya = -rightFace->ya;
- leftFace->k = rightFace->k;
- x = x1;
- if (projectLeft)
- x -= (lw >> 1);
- y = y1 - (lw >> 1);
- dx = x2 - x;
- if (projectRight)
- dx += ((lw + 1) >> 1);
- dy = lw;
- FILL_RECT(infoRec->pScrn, x, y, dx, dy);
- } else if (!dx) {
- leftFace->xa = (double) lw / 2.0;
- leftFace->ya = 0;
- leftFace->k = (double) (lw * dy) / 2.0;
- rightFace->xa = -leftFace->xa;
- rightFace->ya = 0;
- rightFace->k = leftFace->k;
- y = y1;
- if (projectLeft)
- y -= lw >> 1;
- x = x1 - (lw >> 1);
- dy = y2 - y;
- if (projectRight)
- dy += ((lw + 1) >> 1);
- dx = lw;
- FILL_RECT(infoRec->pScrn, x, y, dx, dy);
- } else {
- l = ((double) lw) / 2.0;
- L = sqrt((double)(dx*dx + dy*dy));
-
- if (dx < 0) {
- right = &rights[1];
- left = &lefts[0];
- top = &rights[0];
- bottom = &lefts[1];
- } else {
- right = &rights[0];
- left = &lefts[1];
- top = &lefts[0];
- bottom = &rights[1];
- }
- r = l / L;
-
- /* coord of upper bound at integral y */
- ya = -r * dx;
- xa = r * dy;
-
- projectXoff = -ya;
- projectYoff = xa;
-
- /* xa * dy - ya * dx */
- k = l * L;
-
- leftFace->xa = xa;
- leftFace->ya = ya;
- leftFace->k = k;
- rightFace->xa = -xa;
- rightFace->ya = -ya;
- rightFace->k = k;
-
- if (projectLeft)
- righty = miPolyBuildEdge (xa - projectXoff, ya - projectYoff,
- k, dx, dy, x1, y1, 0, right);
- else
- righty = miPolyBuildEdge (xa, ya,
- k, dx, dy, x1, y1, 0, right);
-
- /* coord of lower bound at integral y */
- ya = -ya;
- xa = -xa;
-
- /* xa * dy - ya * dx */
- k = - k;
-
- if (projectLeft)
- lefty = miPolyBuildEdge (xa - projectXoff, ya - projectYoff,
- k, dx, dy, x1, y1, 1, left);
- else
- lefty = miPolyBuildEdge (xa, ya,
- k, dx, dy, x1, y1, 1, left);
-
- /* coord of top face at integral y */
-
- if (signdx > 0) {
- ya = -ya;
- xa = -xa;
- }
-
- if (projectLeft) {
- double xap = xa - projectXoff;
- double yap = ya - projectYoff;
- topy = miPolyBuildEdge (xap, yap, xap * dx + yap * dy,
- -dy, dx, x1, y1, dx > 0, top);
- }
- else
- topy = miPolyBuildEdge(xa, ya, 0.0,
- -dy, dx, x1, y1, dx > 0, top);
-
- /* coord of bottom face at integral y */
-
- if (projectRight) {
- double xap = xa + projectXoff;
- double yap = ya + projectYoff;
- bottomy = miPolyBuildEdge (xap, yap, xap * dx + yap * dy,
- -dy, dx, x2, y2, dx < 0, bottom);
- maxy = -ya + projectYoff;
- } else {
- bottomy = miPolyBuildEdge (xa, ya, 0.0,
- -dy, dx, x2, y2, dx < 0, bottom);
- maxy = -ya;
- }
-
- finaly = ICEIL (maxy) + y2;
-
- if (dx < 0) {
- left->height = bottomy - lefty;
- right->height = finaly - righty;
- top->height = righty - topy;
- } else {
- right->height = bottomy - righty;
- left->height = finaly - lefty;
- top->height = lefty - topy;
- }
- bottom->height = finaly - bottomy;
- XAAFillPolyHelper (pGC, topy,
- bottom->height + bottomy - topy, lefts, rights, 2, 2);
- }
-}
-
-
-static void
-XAALineArcI (GCPtr pGC, int xorg, int yorg)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int x, y, e, ex;
- int slw = pGC->lineWidth;
- Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
-
- y = (slw >> 1) + 1;
- if (slw & 1)
- e = - ((y << 2) + 3);
- else
- e = - (y << 3);
- ex = -4;
- x = 0;
- while (y) {
- e += (y << 3) - 4;
- while (e >= 0) {
- x++;
- e += (ex = -((x << 3) + 4));
- }
- y--;
- slw = (x << 1) + 1;
- if ((e == ex) && (slw > 1))
- slw--;
-
- FILL_SPAN(infoRec->pScrn, xorg - x, yorg - y, slw);
-
- if ((y != 0) && ((slw > 1) || (e != ex))) {
- FILL_SPAN(infoRec->pScrn, xorg - x, yorg + y, slw);
- }
- }
-}
-
-
-static void
-XAALineArcD (
- GCPtr pGC,
- double xorg,
- double yorg,
- PolyEdgePtr edge1,
- int edgey1,
- Bool edgeleft1,
- PolyEdgePtr edge2,
- int edgey2,
- Bool edgeleft2 )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- double radius, x0, y0, el, er, yk, xlk, xrk, k;
- int xbase, ybase, y, boty, xl, xr, xcl, xcr;
- int ymin, ymax;
- Bool edge1IsMin, edge2IsMin;
- int ymin1, ymin2;
- Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
-
-
- xbase = floor(xorg);
- x0 = xorg - xbase;
- ybase = ICEIL (yorg);
- y0 = yorg - ybase;
-
- xlk = x0 + x0 + 1.0;
- xrk = x0 + x0 - 1.0;
- yk = y0 + y0 - 1.0;
- radius = ((double)pGC->lineWidth) / 2.0;
- y = floor(radius - y0 + 1.0);
- ybase -= y;
- ymin = ybase;
- ymax = 65536;
- edge1IsMin = FALSE;
- ymin1 = edgey1;
- if (edge1->dy >= 0) {
- if (!edge1->dy) {
- if (edgeleft1)
- edge1IsMin = TRUE;
- else
- ymax = edgey1;
- edgey1 = 65536;
- } else if ((edge1->signdx < 0) == edgeleft1)
- edge1IsMin = TRUE;
- }
- edge2IsMin = FALSE;
- ymin2 = edgey2;
- if (edge2->dy >= 0) {
- if (!edge2->dy) {
- if (edgeleft2)
- edge2IsMin = TRUE;
- else
- ymax = edgey2;
- edgey2 = 65536;
- } else if ((edge2->signdx < 0) == edgeleft2)
- edge2IsMin = TRUE;
- }
- if (edge1IsMin) {
- ymin = ymin1;
- if (edge2IsMin && (ymin1 > ymin2))
- ymin = ymin2;
- } else if (edge2IsMin)
- ymin = ymin2;
- el = radius * radius - ((y + y0) * (y + y0)) - (x0 * x0);
- er = el + xrk;
- xl = 1;
- xr = 0;
- if (x0 < 0.5) {
- xl = 0;
- el -= xlk;
- }
- boty = (y0 < -0.5) ? 1 : 0;
- if (ybase + y - boty > ymax)
- boty = ymax - ybase - y;
- while (y > boty) {
- k = (y << 1) + yk;
- er += k;
- while (er > 0.0) {
- xr++;
- er += xrk - (xr << 1);
- }
- el += k;
- while (el >= 0.0) {
- xl--;
- el += (xl << 1) - xlk;
- }
- y--;
- ybase++;
- if (ybase < ymin)
- continue;
- xcl = xl + xbase;
- xcr = xr + xbase;
- CLIPSTEPEDGE(edgey1, edge1, edgeleft1);
- CLIPSTEPEDGE(edgey2, edge2, edgeleft2);
- if(xcr >= xcl) {
- FILL_SPAN(infoRec->pScrn, xcl, ybase, xcr - xcl + 1);
- }
- }
- er = xrk - (xr << 1) - er;
- el = (xl << 1) - xlk - el;
- boty = floor(-y0 - radius + 1.0);
- if (ybase + y - boty > ymax)
- boty = ymax - ybase - y;
- while (y > boty) {
- k = (y << 1) + yk;
- er -= k;
- while ((er >= 0.0) && (xr >= 0)) {
- xr--;
- er += xrk - (xr << 1);
- }
- el -= k;
- while ((el > 0.0) && (xl <= 0)) {
- xl++;
- el += (xl << 1) - xlk;
- }
- y--;
- ybase++;
- if (ybase < ymin)
- continue;
- xcl = xl + xbase;
- xcr = xr + xbase;
- CLIPSTEPEDGE(edgey1, edge1, edgeleft1);
- CLIPSTEPEDGE(edgey2, edge2, edgeleft2);
- if(xcr >= xcl) {
- FILL_SPAN(infoRec->pScrn, xcl, ybase, xcr - xcl + 1);
- }
- }
-}
-
-
-static void
-XAALineArc (
- GCPtr pGC,
- LineFacePtr leftFace,
- LineFacePtr rightFace,
- double xorg,
- double yorg,
- Bool isInt )
-{
- int xorgi, yorgi;
- PolyEdgeRec edge1, edge2;
- int edgey1, edgey2;
- Bool edgeleft1, edgeleft2;
-
- if (isInt) {
- xorgi = leftFace ? leftFace->x : rightFace->x;
- yorgi = leftFace ? leftFace->y : rightFace->y;
- } else { /* Muffle compiler */
- xorgi = yorgi = 0;
- }
- edgey1 = 65536;
- edgey2 = 65536;
- edge1.x = 0; /* not used, keep memory checkers happy */
- edge1.dy = -1;
- edge2.x = 0; /* not used, keep memory checkers happy */
- edge2.dy = -1;
- edgeleft1 = FALSE;
- edgeleft2 = FALSE;
-
- if ((pGC->lineWidth > 2) &&
- ((pGC->capStyle == CapRound && pGC->joinStyle != JoinRound) ||
- (pGC->joinStyle == JoinRound && pGC->capStyle == CapButt))) {
- if (isInt) {
- xorg = (double) xorgi;
- yorg = (double) yorgi;
- }
-
- if (leftFace && rightFace)
- miRoundJoinClip (leftFace, rightFace, &edge1, &edge2,
- &edgey1, &edgey2, &edgeleft1, &edgeleft2);
- else if (leftFace)
- edgey1 = miRoundCapClip (leftFace, isInt, &edge1, &edgeleft1);
- else if (rightFace)
- edgey2 = miRoundCapClip (rightFace, isInt, &edge2, &edgeleft2);
-
- isInt = FALSE;
- }
-
- if (isInt) {
- if(pGC->lineWidth == 1) {
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
- DRAW_POINT(infoRec->pScrn, xorgi, yorgi);
- } else
- XAALineArcI(pGC, xorgi, yorgi);
- } else
- XAALineArcD(pGC, xorg, yorg, &edge1, edgey1, edgeleft1,
- &edge2, edgey2, edgeleft2);
-
-}
-
-
-static void
-XAALineJoin (
- GCPtr pGC,
- LineFacePtr pLeft,
- LineFacePtr pRight )
-{
- double mx = 0, my = 0;
- double denom = 0;
- PolyVertexRec vertices[4];
- PolySlopeRec slopes[4];
- int edgecount;
- PolyEdgeRec left[4], right[4];
- int nleft, nright;
- int y, height;
- int swapslopes;
- int joinStyle = pGC->joinStyle;
- int lw = pGC->lineWidth;
-
- if (lw == 1) {
- /* Lines going in the same direction have no join */
- if ((pLeft->dx >= 0) == (pRight->dx <= 0))
- return;
- if (joinStyle != JoinRound) {
- denom = - pLeft->dx * (double)pRight->dy + pRight->dx *
- (double)pLeft->dy;
- if (denom == 0.0)
- return; /* no join to draw */
- }
- if (joinStyle != JoinMiter) {
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
- DRAW_POINT(infoRec->pScrn, pLeft->x, pLeft->y);
- return;
- }
- } else {
- if (joinStyle == JoinRound) {
- XAALineArc(pGC, pLeft, pRight,(double)0.0, (double)0.0, TRUE);
- return;
- }
- denom = - pLeft->dx * (double)pRight->dy + pRight->dx *
- (double)pLeft->dy;
- if (denom == 0.0)
- return; /* no join to draw */
- }
-
- swapslopes = 0;
- if (denom > 0) {
- pLeft->xa = -pLeft->xa;
- pLeft->ya = -pLeft->ya;
- pLeft->dx = -pLeft->dx;
- pLeft->dy = -pLeft->dy;
- } else {
- swapslopes = 1;
- pRight->xa = -pRight->xa;
- pRight->ya = -pRight->ya;
- pRight->dx = -pRight->dx;
- pRight->dy = -pRight->dy;
- }
-
- vertices[0].x = pRight->xa;
- vertices[0].y = pRight->ya;
- slopes[0].dx = -pRight->dy;
- slopes[0].dy = pRight->dx;
- slopes[0].k = 0;
-
- vertices[1].x = 0;
- vertices[1].y = 0;
- slopes[1].dx = pLeft->dy;
- slopes[1].dy = -pLeft->dx;
- slopes[1].k = 0;
-
- vertices[2].x = pLeft->xa;
- vertices[2].y = pLeft->ya;
-
- if (joinStyle == JoinMiter) {
- my = (pLeft->dy * (pRight->xa * pRight->dy - pRight->ya * pRight->dx) -
- pRight->dy * (pLeft->xa * pLeft->dy - pLeft->ya * pLeft->dx ))/
- denom;
- if (pLeft->dy != 0)
- mx = pLeft->xa + (my - pLeft->ya) *
- (double) pLeft->dx / (double) pLeft->dy;
- else
- mx = pRight->xa + (my - pRight->ya) *
- (double) pRight->dx / (double) pRight->dy;
-
- /* check miter limit */
- if ((mx * mx + my * my) * 4 > SQSECANT * lw * lw)
- joinStyle = JoinBevel;
- }
-
- if (joinStyle == JoinMiter) {
- slopes[2].dx = pLeft->dx;
- slopes[2].dy = pLeft->dy;
- slopes[2].k = pLeft->k;
- if (swapslopes) {
- slopes[2].dx = -slopes[2].dx;
- slopes[2].dy = -slopes[2].dy;
- slopes[2].k = -slopes[2].k;
- }
- vertices[3].x = mx;
- vertices[3].y = my;
- slopes[3].dx = pRight->dx;
- slopes[3].dy = pRight->dy;
- slopes[3].k = pRight->k;
- if (swapslopes) {
- slopes[3].dx = -slopes[3].dx;
- slopes[3].dy = -slopes[3].dy;
- slopes[3].k = -slopes[3].k;
- }
- edgecount = 4;
- } else {
- double scale, dx, dy, adx, ady;
-
- adx = dx = pRight->xa - pLeft->xa;
- ady = dy = pRight->ya - pLeft->ya;
- if (adx < 0)
- adx = -adx;
- if (ady < 0)
- ady = -ady;
- scale = ady;
- if (adx > ady)
- scale = adx;
- slopes[2].dx = (dx * 65536) / scale;
- slopes[2].dy = (dy * 65536) / scale;
- slopes[2].k = ((pLeft->xa + pRight->xa) * slopes[2].dy -
- (pLeft->ya + pRight->ya) * slopes[2].dx) / 2.0;
- edgecount = 3;
- }
-
- y = miPolyBuildPoly (vertices, slopes, edgecount, pLeft->x, pLeft->y,
- left, right, &nleft, &nright, &height);
- XAAFillPolyHelper(pGC, y, height, left, right, nleft, nright);
-}
-
-
-void
-XAAPolylinesWideSolid (
- DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr pPts )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int x1, y1, x2, y2;
- Bool projectLeft, projectRight;
- LineFaceRec leftFace, rightFace, prevRightFace, firstFace;
- int first = TRUE;
- Bool somethingDrawn = FALSE;
- Bool selfJoin = FALSE;
- int xorg = pDrawable->x;
- int yorg = pDrawable->y;
- Bool hardClip = FALSE;
-
- if(!RegionNumRects(pGC->pCompositeClip))
- return;
-
- if(RegionNumRects(pGC->pCompositeClip) != 1) {
- miWideLine(pDrawable, pGC, mode, npt, pPts);
- return;
- }
-
- x2 = pPts->x;
- y2 = pPts->y;
- if (npt > 1) {
- if (mode == CoordModePrevious) {
- int nptTmp;
- register DDXPointPtr pPtsTmp;
-
- x1 = x2;
- y1 = y2;
- nptTmp = npt;
- pPtsTmp = pPts + 1;
- while (--nptTmp) {
- x1 += pPtsTmp->x;
- y1 += pPtsTmp->y;
- ++pPtsTmp;
- }
- if ((x2 == x1) && (y2 == y1))
- selfJoin = TRUE;
- } else if ((x2 == pPts[npt-1].x) && (y2 == pPts[npt-1].y))
- selfJoin = TRUE;
- }
-
- projectLeft = ((pGC->capStyle == CapProjecting) && !selfJoin);
- projectRight = FALSE;
-
- (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu,
- pGC->planemask);
-
- infoRec->ClipBox = &pGC->pCompositeClip->extents;
-
- if(infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL) {
- hardClip = TRUE;
- (*infoRec->SetClippingRectangle)(infoRec->pScrn,
- infoRec->ClipBox->x1, infoRec->ClipBox->y1,
- infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
- }
-
- x2 += xorg;
- y2 += yorg;
- while (--npt) {
- x1 = x2;
- y1 = y2;
- ++pPts;
- x2 = pPts->x;
- y2 = pPts->y;
- if (mode == CoordModePrevious) {
- x2 += x1;
- y2 += y1;
- } else {
- x2 += xorg;
- y2 += yorg;
- }
- if ((x1 != x2) || (y1 != y2)) {
- somethingDrawn = TRUE;
- if ((npt == 1) && (pGC->capStyle == CapProjecting) && !selfJoin)
- projectRight = TRUE;
- XAAWideSegment(pGC, x1, y1, x2, y2,
- projectLeft, projectRight, &leftFace, &rightFace);
- if (first) {
- if (selfJoin)
- firstFace = leftFace;
- else if (pGC->capStyle == CapRound) {
- if (pGC->lineWidth == 1) {
- DRAW_POINT(infoRec->pScrn, x1, y1);
- } else
- XAALineArc(pGC,&leftFace, (LineFacePtr) NULL,
- (double)0.0, (double)0.0,TRUE);
- }
- } else
- XAALineJoin (pGC, &leftFace, &prevRightFace);
-
- prevRightFace = rightFace;
- first = FALSE;
- projectLeft = FALSE;
- }
- if (npt == 1 && somethingDrawn) {
- if (selfJoin)
- XAALineJoin (pGC, &firstFace, &rightFace);
- else if (pGC->capStyle == CapRound) {
- if (pGC->lineWidth == 1) {
- DRAW_POINT(infoRec->pScrn, x2, y2);
- } else
- XAALineArc (pGC, (LineFacePtr) NULL, &rightFace,
- (double)0.0, (double)0.0,TRUE);
- }
- }
- }
- /* handle crock where all points are coincedent */
- if (!somethingDrawn) {
- projectLeft = (pGC->capStyle == CapProjecting);
- XAAWideSegment (pGC, x2, y2, x2, y2, projectLeft, projectLeft,
- &leftFace, &rightFace);
- if (pGC->capStyle == CapRound) {
- XAALineArc (pGC, &leftFace, (LineFacePtr) NULL,
- (double)0.0, (double)0.0, TRUE);
- rightFace.dx = -1; /* sleezy hack to make it work */
- XAALineArc (pGC, (LineFacePtr) NULL, &rightFace,
- (double)0.0, (double)0.0, TRUE);
- }
- }
-
- infoRec->ClipBox = NULL;
- if(hardClip)
- (*infoRec->DisableClipping)(infoRec->pScrn);
-
- SET_SYNC_FLAG(infoRec);
-}
+/*
+
+XAAPolylinesWideSolid does not maintain a span list and subsequently does
+not follow the "touch-each-pixel-once" rules for wide lines and arcs.
+This means it can only be used in the case where we have
+miSpansEasyRop(pGC->alu). Since we clip spans on the fly, we
+limited usage of this function to one rect situations. This
+function is used only for solid lines.
+
+ Adapted from miWideLine by Mark Vojkovich (mvojkovi@ucsd.edu)
+Original mi code written by Keith Packard.
+
+*/
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <math.h>
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "windowstr.h"
+#include "gcstruct.h"
+#include "regionstr.h"
+#include "miwideline.h"
+#include "mi.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+
+#define DRAW_POINT(pScrn, x, y) \
+ if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, 1); \
+ else XAAPointHelper(pScrn, x, y)
+
+#define FILL_RECT(pScrn, x, y, w, h) \
+ if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); \
+ else XAAFillRectHelper(pScrn, x, y, w, h)
+
+#define FILL_SPAN(pScrn, x, y, w) \
+ if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, 1); \
+ else XAASpanHelper(pScrn, x, y, w)
+
+#define CLIPSTEPEDGE(edgey,edge,edgeleft) \
+ if (ybase == edgey) { \
+ if (edgeleft) { \
+ if (edge->x > xcl) \
+ xcl = edge->x; \
+ } else { \
+ if (edge->x < xcr) \
+ xcr = edge->x; \
+ } \
+ edgey++; \
+ edge->x += edge->stepx; \
+ edge->e += edge->dx; \
+ if (edge->e > 0) { \
+ edge->x += edge->signdx; \
+ edge->e -= edge->dy; \
+ } \
+ }
+
+static void
+XAAPointHelper(ScrnInfoPtr pScrn, int x, int y)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ BoxPtr extents = infoRec->ClipBox;
+
+ if ((x >= extents->x1) && (x < extents->x2) &&
+ (y >= extents->y1) && (y < extents->y2))
+ (*infoRec->SubsequentSolidFillRect) (pScrn, x, y, 1, 1);
+}
+
+static void
+XAAFillRectHelper(ScrnInfoPtr pScrn, int x1, int y1, int dx, int dy)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ BoxPtr extents = infoRec->ClipBox;
+ int x2 = x1 + dx;
+ int y2 = y1 + dy;
+
+ if (x1 < extents->x1)
+ x1 = extents->x1;
+ if (x2 >= extents->x2)
+ x2 = extents->x2;
+ if ((dx = x2 - x1) < 1)
+ return;
+ if (y1 < extents->y1)
+ y1 = extents->y1;
+ if (y2 >= extents->y2)
+ y2 = extents->y2;
+ if ((dy = y2 - y1) < 1)
+ return;
+
+ (*infoRec->SubsequentSolidFillRect) (pScrn, x1, y1, dx, dy);
+}
+
+static void
+XAASpanHelper(ScrnInfoPtr pScrn, int x1, int y, int width)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ BoxPtr extents = infoRec->ClipBox;
+ int x2;
+
+ if ((y < extents->y1) || (y >= extents->y2))
+ return;
+
+ x2 = x1 + width;
+ if (x1 < extents->x1)
+ x1 = extents->x1;
+ if (x2 > extents->x2)
+ x2 = extents->x2;
+ width = x2 - x1;
+
+ if (width > 0)
+ (*infoRec->SubsequentSolidFillRect) (pScrn, x1, y, width, 1);
+
+}
+
+#define FixError(x, dx, dy, e, sign, step, h) { \
+ e += (h) * dx; \
+ x += (h) * step; \
+ if(e > 0) { \
+ x += e * sign/dy; \
+ e %= dy; \
+ if(e) { \
+ x += sign; \
+ e -= dy; \
+ } \
+ } \
+}
+
+static void
+XAAFillPolyHelper(GCPtr pGC, int y, /* start y coordinate */
+ int overall_height, /* height of entire segment */
+ PolyEdgePtr left, PolyEdgePtr right,
+ int left_count, int right_count)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ BoxPtr extents = infoRec->ClipBox;
+ int left_x, left_e, left_stepx, left_signdx, left_dy, left_dx;
+ int right_x, right_e, right_stepx, right_signdx, right_dy, right_dx;
+ int height, left_height, right_height;
+ int xorg;
+ Bool hardClip;
+
+ if ((y >= extents->y2) || ((y + overall_height) <= extents->y1))
+ return;
+
+ /* Muffle compiler */
+ left_x = left_e = left_stepx = left_signdx = left_dy = left_dx = 0;
+ right_x = right_e = right_stepx = right_signdx = right_dy = right_dx = 0;
+
+ left_height = right_height = 0;
+ xorg = 0;
+
+ hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
+
+ while ((left_count || left_height) && (right_count || right_height)) {
+ if (!left_height && left_count) {
+ left_height = left->height;
+ left_x = left->x + xorg;
+ left_stepx = left->stepx;
+ left_signdx = left->signdx;
+ left_e = left->e;
+ left_dy = left->dy;
+ left_dx = left->dx;
+ left_count--;
+ left++;
+ }
+ if (!right_height && right_count) {
+ right_height = right->height;
+ right_x = right->x + xorg + 1;
+ right_stepx = right->stepx;
+ right_signdx = right->signdx;
+ right_e = right->e;
+ right_dy = right->dy;
+ right_dx = right->dx;
+ right_count--;
+ right++;
+ }
+
+ height = (left_height > right_height) ? right_height : left_height;
+
+ left_height -= height;
+ right_height -= height;
+
+ if (hardClip && infoRec->SubsequentSolidFillTrap && (height > 6)) {
+ int right_DX, left_DX;
+
+ right_DX = (right_dx * right_signdx) + (right_stepx * right_dy);
+ left_DX = (left_dx * left_signdx) + (left_stepx * left_dy);
+
+ (*infoRec->SubsequentSolidFillTrap) (infoRec->pScrn, y, height,
+ left_x, left_DX, left_dy,
+ left_e, right_x - 1, right_DX,
+ right_dy, right_e);
+
+ FixError(left_x, left_dx, left_dy, left_e, left_signdx,
+ left_stepx, height);
+ FixError(right_x, right_dx, right_dy, right_e, right_signdx,
+ right_stepx, height);
+ y += height;
+ continue;
+ }
+
+ while (height--) {
+ if (right_x > left_x) {
+ FILL_SPAN(infoRec->pScrn, left_x, y, right_x - left_x);
+ }
+ y++;
+
+ left_x += left_stepx;
+ left_e += left_dx;
+ if (left_e > 0) {
+ left_x += left_signdx;
+ left_e -= left_dy;
+ }
+ right_x += right_stepx;
+ right_e += right_dx;
+ if (right_e > 0) {
+ right_x += right_signdx;
+ right_e -= right_dy;
+ }
+
+ }
+ }
+}
+
+static void
+XAAWideSegment(GCPtr pGC,
+ int x1, int y1, int x2, int y2,
+ Bool projectLeft, Bool projectRight,
+ LineFacePtr leftFace, LineFacePtr rightFace)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ double l, L, r;
+ double xa, ya;
+ double projectXoff, projectYoff;
+ double k;
+ double maxy;
+ int x, y;
+ int dx, dy;
+ int finaly;
+ PolyEdgePtr left, right;
+ PolyEdgePtr top, bottom;
+ int lefty, righty, topy, bottomy;
+ int signdx;
+ PolyEdgeRec lefts[2], rights[2];
+ LineFacePtr tface;
+ int lw = pGC->lineWidth;
+ Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
+
+ /* draw top-to-bottom always */
+ if ((y2 < y1) || ((y2 == y1) && (x2 < x1))) {
+ x = x1;
+ x1 = x2;
+ x2 = x;
+
+ y = y1;
+ y1 = y2;
+ y2 = y;
+
+ x = projectLeft;
+ projectLeft = projectRight;
+ projectRight = x;
+
+ tface = leftFace;
+ leftFace = rightFace;
+ rightFace = tface;
+ }
+
+ dy = y2 - y1;
+ signdx = 1;
+ dx = x2 - x1;
+ if (dx < 0)
+ signdx = -1;
+
+ leftFace->x = x1;
+ leftFace->y = y1;
+ leftFace->dx = dx;
+ leftFace->dy = dy;
+
+ rightFace->x = x2;
+ rightFace->y = y2;
+ rightFace->dx = -dx;
+ rightFace->dy = -dy;
+
+ if (!dy) {
+ rightFace->xa = 0;
+ rightFace->ya = (double) lw / 2.0;
+ rightFace->k = -(double) (lw * dx) / 2.0;
+ leftFace->xa = 0;
+ leftFace->ya = -rightFace->ya;
+ leftFace->k = rightFace->k;
+ x = x1;
+ if (projectLeft)
+ x -= (lw >> 1);
+ y = y1 - (lw >> 1);
+ dx = x2 - x;
+ if (projectRight)
+ dx += ((lw + 1) >> 1);
+ dy = lw;
+ FILL_RECT(infoRec->pScrn, x, y, dx, dy);
+ }
+ else if (!dx) {
+ leftFace->xa = (double) lw / 2.0;
+ leftFace->ya = 0;
+ leftFace->k = (double) (lw * dy) / 2.0;
+ rightFace->xa = -leftFace->xa;
+ rightFace->ya = 0;
+ rightFace->k = leftFace->k;
+ y = y1;
+ if (projectLeft)
+ y -= lw >> 1;
+ x = x1 - (lw >> 1);
+ dy = y2 - y;
+ if (projectRight)
+ dy += ((lw + 1) >> 1);
+ dx = lw;
+ FILL_RECT(infoRec->pScrn, x, y, dx, dy);
+ }
+ else {
+ l = ((double) lw) / 2.0;
+ L = sqrt((double) (dx * dx + dy * dy));
+
+ if (dx < 0) {
+ right = &rights[1];
+ left = &lefts[0];
+ top = &rights[0];
+ bottom = &lefts[1];
+ }
+ else {
+ right = &rights[0];
+ left = &lefts[1];
+ top = &lefts[0];
+ bottom = &rights[1];
+ }
+ r = l / L;
+
+ /* coord of upper bound at integral y */
+ ya = -r * dx;
+ xa = r * dy;
+
+ projectXoff = -ya;
+ projectYoff = xa;
+
+ /* xa * dy - ya * dx */
+ k = l * L;
+
+ leftFace->xa = xa;
+ leftFace->ya = ya;
+ leftFace->k = k;
+ rightFace->xa = -xa;
+ rightFace->ya = -ya;
+ rightFace->k = k;
+
+ if (projectLeft)
+ righty = miPolyBuildEdge(xa - projectXoff, ya - projectYoff,
+ k, dx, dy, x1, y1, 0, right);
+ else
+ righty = miPolyBuildEdge(xa, ya, k, dx, dy, x1, y1, 0, right);
+
+ /* coord of lower bound at integral y */
+ ya = -ya;
+ xa = -xa;
+
+ /* xa * dy - ya * dx */
+ k = -k;
+
+ if (projectLeft)
+ lefty = miPolyBuildEdge(xa - projectXoff, ya - projectYoff,
+ k, dx, dy, x1, y1, 1, left);
+ else
+ lefty = miPolyBuildEdge(xa, ya, k, dx, dy, x1, y1, 1, left);
+
+ /* coord of top face at integral y */
+
+ if (signdx > 0) {
+ ya = -ya;
+ xa = -xa;
+ }
+
+ if (projectLeft) {
+ double xap = xa - projectXoff;
+ double yap = ya - projectYoff;
+
+ topy = miPolyBuildEdge(xap, yap, xap * dx + yap * dy,
+ -dy, dx, x1, y1, dx > 0, top);
+ }
+ else
+ topy = miPolyBuildEdge(xa, ya, 0.0, -dy, dx, x1, y1, dx > 0, top);
+
+ /* coord of bottom face at integral y */
+
+ if (projectRight) {
+ double xap = xa + projectXoff;
+ double yap = ya + projectYoff;
+
+ bottomy = miPolyBuildEdge(xap, yap, xap * dx + yap * dy,
+ -dy, dx, x2, y2, dx < 0, bottom);
+ maxy = -ya + projectYoff;
+ }
+ else {
+ bottomy = miPolyBuildEdge(xa, ya, 0.0,
+ -dy, dx, x2, y2, dx < 0, bottom);
+ maxy = -ya;
+ }
+
+ finaly = ICEIL(maxy) + y2;
+
+ if (dx < 0) {
+ left->height = bottomy - lefty;
+ right->height = finaly - righty;
+ top->height = righty - topy;
+ }
+ else {
+ right->height = bottomy - righty;
+ left->height = finaly - lefty;
+ top->height = lefty - topy;
+ }
+ bottom->height = finaly - bottomy;
+ XAAFillPolyHelper(pGC, topy,
+ bottom->height + bottomy - topy, lefts, rights, 2, 2);
+ }
+}
+
+static void
+XAALineArcI(GCPtr pGC, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int x, y, e, ex;
+ int slw = pGC->lineWidth;
+ Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
+
+ y = (slw >> 1) + 1;
+ if (slw & 1)
+ e = -((y << 2) + 3);
+ else
+ e = -(y << 3);
+ ex = -4;
+ x = 0;
+ while (y) {
+ e += (y << 3) - 4;
+ while (e >= 0) {
+ x++;
+ e += (ex = -((x << 3) + 4));
+ }
+ y--;
+ slw = (x << 1) + 1;
+ if ((e == ex) && (slw > 1))
+ slw--;
+
+ FILL_SPAN(infoRec->pScrn, xorg - x, yorg - y, slw);
+
+ if ((y != 0) && ((slw > 1) || (e != ex))) {
+ FILL_SPAN(infoRec->pScrn, xorg - x, yorg + y, slw);
+ }
+ }
+}
+
+static void
+XAALineArcD(GCPtr pGC,
+ double xorg,
+ double yorg,
+ PolyEdgePtr edge1,
+ int edgey1,
+ Bool edgeleft1, PolyEdgePtr edge2, int edgey2, Bool edgeleft2)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ double radius, x0, y0, el, er, yk, xlk, xrk, k;
+ int xbase, ybase, y, boty, xl, xr, xcl, xcr;
+ int ymin, ymax;
+ Bool edge1IsMin, edge2IsMin;
+ int ymin1, ymin2;
+ Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
+
+ xbase = floor(xorg);
+ x0 = xorg - xbase;
+ ybase = ICEIL(yorg);
+ y0 = yorg - ybase;
+
+ xlk = x0 + x0 + 1.0;
+ xrk = x0 + x0 - 1.0;
+ yk = y0 + y0 - 1.0;
+ radius = ((double) pGC->lineWidth) / 2.0;
+ y = floor(radius - y0 + 1.0);
+ ybase -= y;
+ ymin = ybase;
+ ymax = 65536;
+ edge1IsMin = FALSE;
+ ymin1 = edgey1;
+ if (edge1->dy >= 0) {
+ if (!edge1->dy) {
+ if (edgeleft1)
+ edge1IsMin = TRUE;
+ else
+ ymax = edgey1;
+ edgey1 = 65536;
+ }
+ else if ((edge1->signdx < 0) == edgeleft1)
+ edge1IsMin = TRUE;
+ }
+ edge2IsMin = FALSE;
+ ymin2 = edgey2;
+ if (edge2->dy >= 0) {
+ if (!edge2->dy) {
+ if (edgeleft2)
+ edge2IsMin = TRUE;
+ else
+ ymax = edgey2;
+ edgey2 = 65536;
+ }
+ else if ((edge2->signdx < 0) == edgeleft2)
+ edge2IsMin = TRUE;
+ }
+ if (edge1IsMin) {
+ ymin = ymin1;
+ if (edge2IsMin && (ymin1 > ymin2))
+ ymin = ymin2;
+ }
+ else if (edge2IsMin)
+ ymin = ymin2;
+ el = radius * radius - ((y + y0) * (y + y0)) - (x0 * x0);
+ er = el + xrk;
+ xl = 1;
+ xr = 0;
+ if (x0 < 0.5) {
+ xl = 0;
+ el -= xlk;
+ }
+ boty = (y0 < -0.5) ? 1 : 0;
+ if (ybase + y - boty > ymax)
+ boty = ymax - ybase - y;
+ while (y > boty) {
+ k = (y << 1) + yk;
+ er += k;
+ while (er > 0.0) {
+ xr++;
+ er += xrk - (xr << 1);
+ }
+ el += k;
+ while (el >= 0.0) {
+ xl--;
+ el += (xl << 1) - xlk;
+ }
+ y--;
+ ybase++;
+ if (ybase < ymin)
+ continue;
+ xcl = xl + xbase;
+ xcr = xr + xbase;
+ CLIPSTEPEDGE(edgey1, edge1, edgeleft1);
+ CLIPSTEPEDGE(edgey2, edge2, edgeleft2);
+ if (xcr >= xcl) {
+ FILL_SPAN(infoRec->pScrn, xcl, ybase, xcr - xcl + 1);
+ }
+ }
+ er = xrk - (xr << 1) - er;
+ el = (xl << 1) - xlk - el;
+ boty = floor(-y0 - radius + 1.0);
+ if (ybase + y - boty > ymax)
+ boty = ymax - ybase - y;
+ while (y > boty) {
+ k = (y << 1) + yk;
+ er -= k;
+ while ((er >= 0.0) && (xr >= 0)) {
+ xr--;
+ er += xrk - (xr << 1);
+ }
+ el -= k;
+ while ((el > 0.0) && (xl <= 0)) {
+ xl++;
+ el += (xl << 1) - xlk;
+ }
+ y--;
+ ybase++;
+ if (ybase < ymin)
+ continue;
+ xcl = xl + xbase;
+ xcr = xr + xbase;
+ CLIPSTEPEDGE(edgey1, edge1, edgeleft1);
+ CLIPSTEPEDGE(edgey2, edge2, edgeleft2);
+ if (xcr >= xcl) {
+ FILL_SPAN(infoRec->pScrn, xcl, ybase, xcr - xcl + 1);
+ }
+ }
+}
+
+static void
+XAALineArc(GCPtr pGC,
+ LineFacePtr leftFace,
+ LineFacePtr rightFace, double xorg, double yorg, Bool isInt)
+{
+ int xorgi, yorgi;
+ PolyEdgeRec edge1, edge2;
+ int edgey1, edgey2;
+ Bool edgeleft1, edgeleft2;
+
+ if (isInt) {
+ xorgi = leftFace ? leftFace->x : rightFace->x;
+ yorgi = leftFace ? leftFace->y : rightFace->y;
+ }
+ else { /* Muffle compiler */
+ xorgi = yorgi = 0;
+ }
+ edgey1 = 65536;
+ edgey2 = 65536;
+ edge1.x = 0; /* not used, keep memory checkers happy */
+ edge1.dy = -1;
+ edge2.x = 0; /* not used, keep memory checkers happy */
+ edge2.dy = -1;
+ edgeleft1 = FALSE;
+ edgeleft2 = FALSE;
+
+ if ((pGC->lineWidth > 2) &&
+ ((pGC->capStyle == CapRound && pGC->joinStyle != JoinRound) ||
+ (pGC->joinStyle == JoinRound && pGC->capStyle == CapButt))) {
+ if (isInt) {
+ xorg = (double) xorgi;
+ yorg = (double) yorgi;
+ }
+
+ if (leftFace && rightFace)
+ miRoundJoinClip(leftFace, rightFace, &edge1, &edge2,
+ &edgey1, &edgey2, &edgeleft1, &edgeleft2);
+ else if (leftFace)
+ edgey1 = miRoundCapClip(leftFace, isInt, &edge1, &edgeleft1);
+ else if (rightFace)
+ edgey2 = miRoundCapClip(rightFace, isInt, &edge2, &edgeleft2);
+
+ isInt = FALSE;
+ }
+
+ if (isInt) {
+ if (pGC->lineWidth == 1) {
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
+
+ DRAW_POINT(infoRec->pScrn, xorgi, yorgi);
+ }
+ else
+ XAALineArcI(pGC, xorgi, yorgi);
+ }
+ else
+ XAALineArcD(pGC, xorg, yorg, &edge1, edgey1, edgeleft1,
+ &edge2, edgey2, edgeleft2);
+
+}
+
+static void
+XAALineJoin(GCPtr pGC, LineFacePtr pLeft, LineFacePtr pRight)
+{
+ double mx = 0, my = 0;
+ double denom = 0;
+ PolyVertexRec vertices[4];
+ PolySlopeRec slopes[4];
+ int edgecount;
+ PolyEdgeRec left[4], right[4];
+ int nleft, nright;
+ int y, height;
+ int swapslopes;
+ int joinStyle = pGC->joinStyle;
+ int lw = pGC->lineWidth;
+
+ if (lw == 1) {
+ /* Lines going in the same direction have no join */
+ if ((pLeft->dx >= 0) == (pRight->dx <= 0))
+ return;
+ if (joinStyle != JoinRound) {
+ denom = -pLeft->dx * (double) pRight->dy + pRight->dx *
+ (double) pLeft->dy;
+ if (denom == 0.0)
+ return; /* no join to draw */
+ }
+ if (joinStyle != JoinMiter) {
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
+
+ DRAW_POINT(infoRec->pScrn, pLeft->x, pLeft->y);
+ return;
+ }
+ }
+ else {
+ if (joinStyle == JoinRound) {
+ XAALineArc(pGC, pLeft, pRight, (double) 0.0, (double) 0.0, TRUE);
+ return;
+ }
+ denom = -pLeft->dx * (double) pRight->dy + pRight->dx *
+ (double) pLeft->dy;
+ if (denom == 0.0)
+ return; /* no join to draw */
+ }
+
+ swapslopes = 0;
+ if (denom > 0) {
+ pLeft->xa = -pLeft->xa;
+ pLeft->ya = -pLeft->ya;
+ pLeft->dx = -pLeft->dx;
+ pLeft->dy = -pLeft->dy;
+ }
+ else {
+ swapslopes = 1;
+ pRight->xa = -pRight->xa;
+ pRight->ya = -pRight->ya;
+ pRight->dx = -pRight->dx;
+ pRight->dy = -pRight->dy;
+ }
+
+ vertices[0].x = pRight->xa;
+ vertices[0].y = pRight->ya;
+ slopes[0].dx = -pRight->dy;
+ slopes[0].dy = pRight->dx;
+ slopes[0].k = 0;
+
+ vertices[1].x = 0;
+ vertices[1].y = 0;
+ slopes[1].dx = pLeft->dy;
+ slopes[1].dy = -pLeft->dx;
+ slopes[1].k = 0;
+
+ vertices[2].x = pLeft->xa;
+ vertices[2].y = pLeft->ya;
+
+ if (joinStyle == JoinMiter) {
+ my = (pLeft->dy * (pRight->xa * pRight->dy - pRight->ya * pRight->dx) -
+ pRight->dy * (pLeft->xa * pLeft->dy - pLeft->ya * pLeft->dx)) /
+ denom;
+ if (pLeft->dy != 0)
+ mx = pLeft->xa + (my - pLeft->ya) *
+ (double) pLeft->dx / (double) pLeft->dy;
+ else
+ mx = pRight->xa + (my - pRight->ya) *
+ (double) pRight->dx / (double) pRight->dy;
+
+ /* check miter limit */
+ if ((mx * mx + my * my) * 4 > SQSECANT * lw * lw)
+ joinStyle = JoinBevel;
+ }
+
+ if (joinStyle == JoinMiter) {
+ slopes[2].dx = pLeft->dx;
+ slopes[2].dy = pLeft->dy;
+ slopes[2].k = pLeft->k;
+ if (swapslopes) {
+ slopes[2].dx = -slopes[2].dx;
+ slopes[2].dy = -slopes[2].dy;
+ slopes[2].k = -slopes[2].k;
+ }
+ vertices[3].x = mx;
+ vertices[3].y = my;
+ slopes[3].dx = pRight->dx;
+ slopes[3].dy = pRight->dy;
+ slopes[3].k = pRight->k;
+ if (swapslopes) {
+ slopes[3].dx = -slopes[3].dx;
+ slopes[3].dy = -slopes[3].dy;
+ slopes[3].k = -slopes[3].k;
+ }
+ edgecount = 4;
+ }
+ else {
+ double scale, dx, dy, adx, ady;
+
+ adx = dx = pRight->xa - pLeft->xa;
+ ady = dy = pRight->ya - pLeft->ya;
+ if (adx < 0)
+ adx = -adx;
+ if (ady < 0)
+ ady = -ady;
+ scale = ady;
+ if (adx > ady)
+ scale = adx;
+ slopes[2].dx = (dx * 65536) / scale;
+ slopes[2].dy = (dy * 65536) / scale;
+ slopes[2].k = ((pLeft->xa + pRight->xa) * slopes[2].dy -
+ (pLeft->ya + pRight->ya) * slopes[2].dx) / 2.0;
+ edgecount = 3;
+ }
+
+ y = miPolyBuildPoly(vertices, slopes, edgecount, pLeft->x, pLeft->y,
+ left, right, &nleft, &nright, &height);
+ XAAFillPolyHelper(pGC, y, height, left, right, nleft, nright);
+}
+
+void
+XAAPolylinesWideSolid(DrawablePtr pDrawable,
+ GCPtr pGC, int mode, int npt, DDXPointPtr pPts)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int x1, y1, x2, y2;
+ Bool projectLeft, projectRight;
+ LineFaceRec leftFace, rightFace, prevRightFace, firstFace;
+ int first = TRUE;
+ Bool somethingDrawn = FALSE;
+ Bool selfJoin = FALSE;
+ int xorg = pDrawable->x;
+ int yorg = pDrawable->y;
+ Bool hardClip = FALSE;
+
+ if (!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ if (RegionNumRects(pGC->pCompositeClip) != 1) {
+ miWideLine(pDrawable, pGC, mode, npt, pPts);
+ return;
+ }
+
+ x2 = pPts->x;
+ y2 = pPts->y;
+ if (npt > 1) {
+ if (mode == CoordModePrevious) {
+ int nptTmp;
+ register DDXPointPtr pPtsTmp;
+
+ x1 = x2;
+ y1 = y2;
+ nptTmp = npt;
+ pPtsTmp = pPts + 1;
+ while (--nptTmp) {
+ x1 += pPtsTmp->x;
+ y1 += pPtsTmp->y;
+ ++pPtsTmp;
+ }
+ if ((x2 == x1) && (y2 == y1))
+ selfJoin = TRUE;
+ }
+ else if ((x2 == pPts[npt - 1].x) && (y2 == pPts[npt - 1].y))
+ selfJoin = TRUE;
+ }
+
+ projectLeft = ((pGC->capStyle == CapProjecting) && !selfJoin);
+ projectRight = FALSE;
+
+ (*infoRec->SetupForSolidFill) (infoRec->pScrn, pGC->fgPixel, pGC->alu,
+ pGC->planemask);
+
+ infoRec->ClipBox = &pGC->pCompositeClip->extents;
+
+ if (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL) {
+ hardClip = TRUE;
+ (*infoRec->SetClippingRectangle) (infoRec->pScrn,
+ infoRec->ClipBox->x1,
+ infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1,
+ infoRec->ClipBox->y2 - 1);
+ }
+
+ x2 += xorg;
+ y2 += yorg;
+ while (--npt) {
+ x1 = x2;
+ y1 = y2;
+ ++pPts;
+ x2 = pPts->x;
+ y2 = pPts->y;
+ if (mode == CoordModePrevious) {
+ x2 += x1;
+ y2 += y1;
+ }
+ else {
+ x2 += xorg;
+ y2 += yorg;
+ }
+ if ((x1 != x2) || (y1 != y2)) {
+ somethingDrawn = TRUE;
+ if ((npt == 1) && (pGC->capStyle == CapProjecting) && !selfJoin)
+ projectRight = TRUE;
+ XAAWideSegment(pGC, x1, y1, x2, y2,
+ projectLeft, projectRight, &leftFace, &rightFace);
+ if (first) {
+ if (selfJoin)
+ firstFace = leftFace;
+ else if (pGC->capStyle == CapRound) {
+ if (pGC->lineWidth == 1) {
+ DRAW_POINT(infoRec->pScrn, x1, y1);
+ }
+ else
+ XAALineArc(pGC, &leftFace, (LineFacePtr) NULL,
+ (double) 0.0, (double) 0.0, TRUE);
+ }
+ }
+ else
+ XAALineJoin(pGC, &leftFace, &prevRightFace);
+
+ prevRightFace = rightFace;
+ first = FALSE;
+ projectLeft = FALSE;
+ }
+ if (npt == 1 && somethingDrawn) {
+ if (selfJoin)
+ XAALineJoin(pGC, &firstFace, &rightFace);
+ else if (pGC->capStyle == CapRound) {
+ if (pGC->lineWidth == 1) {
+ DRAW_POINT(infoRec->pScrn, x2, y2);
+ }
+ else
+ XAALineArc(pGC, (LineFacePtr) NULL, &rightFace,
+ (double) 0.0, (double) 0.0, TRUE);
+ }
+ }
+ }
+ /* handle crock where all points are coincedent */
+ if (!somethingDrawn) {
+ projectLeft = (pGC->capStyle == CapProjecting);
+ XAAWideSegment(pGC, x2, y2, x2, y2, projectLeft, projectLeft,
+ &leftFace, &rightFace);
+ if (pGC->capStyle == CapRound) {
+ XAALineArc(pGC, &leftFace, (LineFacePtr) NULL,
+ (double) 0.0, (double) 0.0, TRUE);
+ rightFace.dx = -1; /* sleezy hack to make it work */
+ XAALineArc(pGC, (LineFacePtr) NULL, &rightFace,
+ (double) 0.0, (double) 0.0, TRUE);
+ }
+ }
+
+ infoRec->ClipBox = NULL;
+ if (hardClip)
+ (*infoRec->DisableClipping) (infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaalocal.h b/xorg-server/hw/xfree86/xaa/xaalocal.h
index 0780fb133..c028ef033 100644
--- a/xorg-server/hw/xfree86/xaa/xaalocal.h
+++ b/xorg-server/hw/xfree86/xaa/xaalocal.h
@@ -8,7 +8,6 @@
/* This file is very unorganized ! */
-
#include "gcstruct.h"
#include "regionstr.h"
#include "xf86fbman.h"
@@ -27,49 +26,44 @@
#define DO_PIXMAP_COPY 0x00000007
#define DO_SOLID 0x00000008
+typedef CARD32 *(*GlyphScanlineFuncPtr) (CARD32 *base, unsigned int **glyphp,
+ int line, int nglyph, int width);
-typedef CARD32 * (*GlyphScanlineFuncPtr)(
- CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width
-);
-
-typedef CARD32 *(*StippleScanlineProcPtr)(CARD32*, CARD32*, int, int, int);
+typedef CARD32 *(*StippleScanlineProcPtr) (CARD32 *, CARD32 *, int, int, int);
typedef void (*RectFuncPtr) (ScrnInfoPtr, int, int, int, int, int, int,
- XAACacheInfoPtr);
+ XAACacheInfoPtr);
typedef void (*TrapFuncPtr) (ScrnInfoPtr, int, int, int, int, int, int,
- int, int, int, int, int, int,
- XAACacheInfoPtr);
-
-
+ int, int, int, int, int, int, XAACacheInfoPtr);
typedef struct _XAAScreen {
- CreateGCProcPtr CreateGC;
- CloseScreenProcPtr CloseScreen;
- GetImageProcPtr GetImage;
- GetSpansProcPtr GetSpans;
- CopyWindowProcPtr CopyWindow;
- WindowExposuresProcPtr WindowExposures;
- CreatePixmapProcPtr CreatePixmap;
- DestroyPixmapProcPtr DestroyPixmap;
- ChangeWindowAttributesProcPtr ChangeWindowAttributes;
- XAAInfoRecPtr AccelInfoRec;
- Bool (*EnterVT)(int, int);
- void (*LeaveVT)(int, int);
- int (*SetDGAMode)(int, int, DGADevicePtr);
- void (*EnableDisableFBAccess)(int, Bool);
- CompositeProcPtr Composite;
- GlyphsProcPtr Glyphs;
+ CreateGCProcPtr CreateGC;
+ CloseScreenProcPtr CloseScreen;
+ GetImageProcPtr GetImage;
+ GetSpansProcPtr GetSpans;
+ CopyWindowProcPtr CopyWindow;
+ WindowExposuresProcPtr WindowExposures;
+ CreatePixmapProcPtr CreatePixmap;
+ DestroyPixmapProcPtr DestroyPixmap;
+ ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+ XAAInfoRecPtr AccelInfoRec;
+ Bool (*EnterVT) (int, int);
+ void (*LeaveVT) (int, int);
+ int (*SetDGAMode) (int, int, DGADevicePtr);
+ void (*EnableDisableFBAccess) (int, Bool);
+ CompositeProcPtr Composite;
+ GlyphsProcPtr Glyphs;
} XAAScreenRec, *XAAScreenPtr;
#define OPS_ARE_PIXMAP 0x00000001
#define OPS_ARE_ACCEL 0x00000002
typedef struct _XAAGC {
- GCOps *wrapOps;
- GCFuncs *wrapFuncs;
- GCOps *XAAOps;
- int DashLength;
- unsigned char* DashPattern;
+ GCOps *wrapOps;
+ GCFuncs *wrapFuncs;
+ GCOps *XAAOps;
+ int DashLength;
+ unsigned char *DashPattern;
unsigned long changes;
unsigned long flags;
} XAAGCRec, *XAAGCPtr;
@@ -91,1416 +85,1126 @@ typedef struct _XAAPixmap {
CARD32 pattern0;
CARD32 pattern1;
int fg;
- int bg;
+ int bg;
FBAreaPtr offscreenArea;
Bool freeData;
} XAAPixmapRec, *XAAPixmapPtr;
-
extern _X_EXPORT Bool
-XAACreateGC(
- GCPtr pGC
-);
+ XAACreateGC(GCPtr pGC);
extern _X_EXPORT Bool
-XAAInitAccel(
- ScreenPtr pScreen,
- XAAInfoRecPtr infoRec
-);
+ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec);
extern _X_EXPORT RegionPtr
-XAABitBlt(
- DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GC *pGC,
- int srcx,
- int srcy,
- int width,
- int height,
- int dstx,
- int dsty,
- void (*doBitBlt)(DrawablePtr, DrawablePtr, GCPtr, RegionPtr, DDXPointPtr),
- unsigned long bitPlane
-);
-
-extern _X_EXPORT void
-XAAScreenToScreenBitBlt(
- ScrnInfoPtr pScrn,
- int nbox,
- DDXPointPtr pptSrc,
- BoxPtr pbox,
- int xdir,
- int ydir,
- int alu,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAADoBitBlt(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GC *pGC,
- RegionPtr prgnDst,
- DDXPointPtr pptSrc
-);
-
-extern _X_EXPORT void
-XAADoImageWrite(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GC *pGC,
- RegionPtr prgnDst,
- DDXPointPtr pptSrc
-);
-
-extern _X_EXPORT void
-XAADoImageRead(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GC *pGC,
- RegionPtr prgnDst,
- DDXPointPtr pptSrc
-);
-
-extern _X_EXPORT void
-XAACopyWindow(
- WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgnSrc
-);
+XAABitBlt(DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GC * pGC,
+ int srcx,
+ int srcy,
+ int width,
+ int height,
+ int dstx,
+ int dsty,
+ void (*doBitBlt) (DrawablePtr, DrawablePtr, GCPtr, RegionPtr,
+ DDXPointPtr), unsigned long bitPlane);
-extern _X_EXPORT RegionPtr
-XAACopyArea(
- DrawablePtr pSrcDrawable,
- DrawablePtr pDstDrawable,
- GC *pGC,
- int srcx,
- int srcy,
- int width,
- int height,
- int dstx,
- int dsty
-);
+extern _X_EXPORT void
+
+XAAScreenToScreenBitBlt(ScrnInfoPtr pScrn,
+ int nbox,
+ DDXPointPtr pptSrc,
+ BoxPtr pbox,
+ int xdir, int ydir, int alu, unsigned int planemask);
extern _X_EXPORT void
-XAAValidateCopyArea(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw
-);
+
+XAADoBitBlt(DrawablePtr pSrc,
+ DrawablePtr pDst, GC * pGC, RegionPtr prgnDst, DDXPointPtr pptSrc);
+
+extern _X_EXPORT void
+
+XAADoImageWrite(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GC * pGC, RegionPtr prgnDst, DDXPointPtr pptSrc);
+
+extern _X_EXPORT void
+
+XAADoImageRead(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GC * pGC, RegionPtr prgnDst, DDXPointPtr pptSrc);
+
+extern _X_EXPORT void
+ XAACopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
+
+extern _X_EXPORT RegionPtr
+
+XAACopyArea(DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GC * pGC,
+ int srcx, int srcy, int width, int height, int dstx, int dsty);
extern _X_EXPORT void
-XAAValidatePutImage(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw
-);
+ XAAValidateCopyArea(GCPtr pGC, unsigned long changes, DrawablePtr pDraw);
extern _X_EXPORT void
-XAAValidateCopyPlane(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw
-);
+ XAAValidatePutImage(GCPtr pGC, unsigned long changes, DrawablePtr pDraw);
extern _X_EXPORT void
-XAAValidatePushPixels(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw
-);
+ XAAValidateCopyPlane(GCPtr pGC, unsigned long changes, DrawablePtr pDraw);
extern _X_EXPORT void
-XAAValidateFillSpans(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw
-);
+ XAAValidatePushPixels(GCPtr pGC, unsigned long changes, DrawablePtr pDraw);
extern _X_EXPORT void
-XAAValidatePolyGlyphBlt(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw
-);
+ XAAValidateFillSpans(GCPtr pGC, unsigned long changes, DrawablePtr pDraw);
extern _X_EXPORT void
-XAAValidateImageGlyphBlt(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw
-);
+ XAAValidatePolyGlyphBlt(GCPtr pGC, unsigned long changes, DrawablePtr pDraw);
extern _X_EXPORT void
-XAAValidatePolylines(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw
-);
+ XAAValidateImageGlyphBlt(GCPtr pGC, unsigned long changes, DrawablePtr pDraw);
+extern _X_EXPORT void
+ XAAValidatePolylines(GCPtr pGC, unsigned long changes, DrawablePtr pDraw);
extern _X_EXPORT RegionPtr
-XAACopyPlaneColorExpansion(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GCPtr pGC,
- int srcx,
- int srcy,
- int width,
- int height,
- int dstx,
- int dsty,
- unsigned long bitPlane
-);
-
-
-extern _X_EXPORT void
-XAAPushPixelsSolidColorExpansion(
- GCPtr pGC,
- PixmapPtr pBitMap,
- DrawablePtr pDrawable,
- int dx,
- int dy,
- int xOrg,
- int yOrg
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapColorExpandMSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapColorExpand3MSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapColorExpandMSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapColorExpand3MSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapColorExpandLSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapColorExpand3LSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapColorExpandLSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapColorExpand3LSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-
-extern _X_EXPORT void
-XAAWriteBitmapScanlineColorExpandMSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapScanlineColorExpand3MSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapScanlineColorExpandMSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapScanlineColorExpand3MSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapScanlineColorExpandLSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapScanlineColorExpand3LSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapScanlineColorExpandLSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapScanlineColorExpand3LSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int skipleft,
- int fg, int bg,
- int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAWritePixmap (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int rop,
- unsigned int planemask,
- int transparency_color,
- int bpp, int depth
-);
-
-extern _X_EXPORT void
-XAAWritePixmapScanline (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int rop,
- unsigned int planemask,
- int transparency_color,
- int bpp, int depth
-);
-
-typedef void (*ClipAndRenderRectsFunc)(GCPtr, int, BoxPtr, int, int);
-
-
-extern _X_EXPORT void
-XAAClipAndRenderRects(
- GCPtr pGC,
- ClipAndRenderRectsFunc func,
- int nrectFill,
- xRectangle *prectInit,
- int xorg, int yorg
-);
-
-
-typedef void (*ClipAndRenderSpansFunc)(GCPtr, int, DDXPointPtr, int*,
- int, int, int);
-
-extern _X_EXPORT void
-XAAClipAndRenderSpans(
- GCPtr pGC,
- DDXPointPtr ppt,
- int *pwidth,
- int nspans,
- int fSorted,
- ClipAndRenderSpansFunc func,
- int xorg,
- int yorg
-);
-
-
-extern _X_EXPORT void
-XAAFillSolidRects(
- ScrnInfoPtr pScrn,
- int fg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox
-);
-
-extern _X_EXPORT void
-XAAFillMono8x8PatternRects(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int pat0, int pat1,
- int xorg, int yorg
-);
-
-extern _X_EXPORT void
-XAAFillMono8x8PatternRectsScreenOrigin(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int pat0, int pat1,
- int xorg, int yorg
-);
-
-
-extern _X_EXPORT void
-XAAFillColor8x8PatternRectsScreenOrigin(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorigin, int yorigin,
- XAACacheInfoPtr pCache
-);
-
-extern _X_EXPORT void
-XAAFillColor8x8PatternRects(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorigin, int yorigin,
- XAACacheInfoPtr pCache
-);
-
-extern _X_EXPORT void
-XAAFillCacheBltRects(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- XAACacheInfoPtr pCache
-);
-
-extern _X_EXPORT void
-XAAFillCacheExpandRects(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillImageWriteRects(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAPolyFillRect(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nrectFill,
- xRectangle *prectInit
-);
-
-
-extern _X_EXPORT void
-XAATEGlyphRendererMSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
-
-extern _X_EXPORT void
-XAATEGlyphRenderer3MSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
-
-extern _X_EXPORT void
-XAATEGlyphRendererMSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
-extern _X_EXPORT void
-XAATEGlyphRenderer3MSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
+XAACopyPlaneColorExpansion(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx,
+ int srcy,
+ int width,
+ int height,
+ int dstx, int dsty, unsigned long bitPlane);
+
+extern _X_EXPORT void
+
+XAAPushPixelsSolidColorExpansion(GCPtr pGC,
+ PixmapPtr pBitMap,
+ DrawablePtr pDrawable,
+ int dx, int dy, int xOrg, int yOrg);
+
+extern _X_EXPORT void
+
+XAAWriteBitmapColorExpandMSBFirstFixedBase(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop, unsigned int planemask);
+
+extern _X_EXPORT void
+
+XAAWriteBitmapColorExpand3MSBFirstFixedBase(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop, unsigned int planemask);
+
+extern _X_EXPORT void
+
+XAAWriteBitmapColorExpandMSBFirst(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop, unsigned int planemask);
+
+extern _X_EXPORT void
+
+XAAWriteBitmapColorExpand3MSBFirst(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop, unsigned int planemask);
+
+extern _X_EXPORT void
+
+XAAWriteBitmapColorExpandLSBFirstFixedBase(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop, unsigned int planemask);
+
+extern _X_EXPORT void
+
+XAAWriteBitmapColorExpand3LSBFirstFixedBase(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop, unsigned int planemask);
+
+extern _X_EXPORT void
+
+XAAWriteBitmapColorExpandLSBFirst(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop, unsigned int planemask);
+
+extern _X_EXPORT void
+
+XAAWriteBitmapColorExpand3LSBFirst(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop, unsigned int planemask);
+
+extern _X_EXPORT void
+
+XAAWriteBitmapScanlineColorExpandMSBFirst(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop, unsigned int planemask);
+
+extern _X_EXPORT void
+
+XAAWriteBitmapScanlineColorExpand3MSBFirst(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop, unsigned int planemask);
+
+extern _X_EXPORT void
+
+XAAWriteBitmapScanlineColorExpandMSBFirstFixedBase(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask);
extern _X_EXPORT void
-XAATEGlyphRendererLSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
-
-
+
+XAAWriteBitmapScanlineColorExpand3MSBFirstFixedBase(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask);
+
extern _X_EXPORT void
-XAATEGlyphRenderer3LSBFirstFixedBase (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
-
+
+XAAWriteBitmapScanlineColorExpandLSBFirst(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop, unsigned int planemask);
+
extern _X_EXPORT void
-XAATEGlyphRendererLSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
+
+XAAWriteBitmapScanlineColorExpand3LSBFirst(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop, unsigned int planemask);
extern _X_EXPORT void
-XAATEGlyphRenderer3LSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
+XAAWriteBitmapScanlineColorExpandLSBFirstFixedBase(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask);
extern _X_EXPORT void
-XAATEGlyphRendererScanlineMSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
+
+XAAWriteBitmapScanlineColorExpand3LSBFirstFixedBase(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int skipleft,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask);
extern _X_EXPORT void
-XAATEGlyphRendererScanline3MSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
+
+XAAWritePixmap(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int rop,
+ unsigned int planemask,
+ int transparency_color, int bpp, int depth);
extern _X_EXPORT void
-XAATEGlyphRendererScanlineLSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
+
+XAAWritePixmapScanline(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth,
+ int rop,
+ unsigned int planemask,
+ int transparency_color, int bpp, int depth);
+
+typedef void (*ClipAndRenderRectsFunc) (GCPtr, int, BoxPtr, int, int);
extern _X_EXPORT void
-XAATEGlyphRendererScanline3LSBFirst (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h, int skipleft, int startline,
- unsigned int **glyphs, int glyphWidth,
- int fg, int bg, int rop, unsigned planemask
-);
+XAAClipAndRenderRects(GCPtr pGC,
+ ClipAndRenderRectsFunc func,
+ int nrectFill, xRectangle *prectInit, int xorg, int yorg);
-extern _X_EXPORT CARD32 *(*XAAGlyphScanlineFuncMSBFirstFixedBase[32])(
- CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width
-);
+typedef void (*ClipAndRenderSpansFunc) (GCPtr, int, DDXPointPtr, int *,
+ int, int, int);
-extern _X_EXPORT CARD32 *(*XAAGlyphScanlineFuncMSBFirst[32])(
- CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width
-);
+extern _X_EXPORT void
-extern _X_EXPORT CARD32 *(*XAAGlyphScanlineFuncLSBFirstFixedBase[32])(
- CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width
-);
+XAAClipAndRenderSpans(GCPtr pGC,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ int fSorted,
+ ClipAndRenderSpansFunc func, int xorg, int yorg);
-extern _X_EXPORT CARD32 *(*XAAGlyphScanlineFuncLSBFirst[32])(
- CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width
-);
+extern _X_EXPORT void
+
+XAAFillSolidRects(ScrnInfoPtr pScrn,
+ int fg, int rop,
+ unsigned int planemask, int nBox, BoxPtr pBox);
+
+extern _X_EXPORT void
+
+XAAFillMono8x8PatternRects(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox, int pat0, int pat1, int xorg, int yorg);
-extern _X_EXPORT GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncMSBFirstFixedBase(void);
+extern _X_EXPORT void
+
+XAAFillMono8x8PatternRectsScreenOrigin(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int pat0, int pat1, int xorg, int yorg);
+
+extern _X_EXPORT void
+
+XAAFillColor8x8PatternRectsScreenOrigin(ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorigin, int yorigin,
+ XAACacheInfoPtr pCache);
+
+extern _X_EXPORT void
+
+XAAFillColor8x8PatternRects(ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorigin, int yorigin, XAACacheInfoPtr pCache);
+
+extern _X_EXPORT void
+
+XAAFillCacheBltRects(ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox, int xorg, int yorg, XAACacheInfoPtr pCache);
+
+extern _X_EXPORT void
+
+XAAFillCacheExpandRects(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox, int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT void
+
+XAAFillImageWriteRects(ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox, int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT void
+
+XAAPolyFillRect(DrawablePtr pDraw,
+ GCPtr pGC, int nrectFill, xRectangle *prectInit);
+
+extern _X_EXPORT void
+
+XAATEGlyphRendererMSBFirstFixedBase(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft,
+ int startline, unsigned int **glyphs,
+ int glyphWidth, int fg, int bg, int rop,
+ unsigned planemask);
+
+extern _X_EXPORT void
+
+XAATEGlyphRenderer3MSBFirstFixedBase(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft,
+ int startline, unsigned int **glyphs,
+ int glyphWidth, int fg, int bg, int rop,
+ unsigned planemask);
+
+extern _X_EXPORT void
+
+XAATEGlyphRendererMSBFirst(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft,
+ int startline, unsigned int **glyphs, int glyphWidth,
+ int fg, int bg, int rop, unsigned planemask);
+
+extern _X_EXPORT void
+
+XAATEGlyphRenderer3MSBFirst(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft,
+ int startline, unsigned int **glyphs,
+ int glyphWidth, int fg, int bg, int rop,
+ unsigned planemask);
+
+extern _X_EXPORT void
+
+XAATEGlyphRendererLSBFirstFixedBase(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft,
+ int startline, unsigned int **glyphs,
+ int glyphWidth, int fg, int bg, int rop,
+ unsigned planemask);
+
+extern _X_EXPORT void
+
+XAATEGlyphRenderer3LSBFirstFixedBase(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft,
+ int startline, unsigned int **glyphs,
+ int glyphWidth, int fg, int bg, int rop,
+ unsigned planemask);
+
+extern _X_EXPORT void
+
+XAATEGlyphRendererLSBFirst(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft,
+ int startline, unsigned int **glyphs, int glyphWidth,
+ int fg, int bg, int rop, unsigned planemask);
+
+extern _X_EXPORT void
+
+XAATEGlyphRenderer3LSBFirst(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft,
+ int startline, unsigned int **glyphs,
+ int glyphWidth, int fg, int bg, int rop,
+ unsigned planemask);
+
+extern _X_EXPORT void
+
+XAATEGlyphRendererScanlineMSBFirst(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft,
+ int startline, unsigned int **glyphs,
+ int glyphWidth, int fg, int bg, int rop,
+ unsigned planemask);
+
+extern _X_EXPORT void
+
+XAATEGlyphRendererScanline3MSBFirst(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft,
+ int startline, unsigned int **glyphs,
+ int glyphWidth, int fg, int bg, int rop,
+ unsigned planemask);
+
+extern _X_EXPORT void
+
+XAATEGlyphRendererScanlineLSBFirst(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft,
+ int startline, unsigned int **glyphs,
+ int glyphWidth, int fg, int bg, int rop,
+ unsigned planemask);
+
+extern _X_EXPORT void
+
+XAATEGlyphRendererScanline3LSBFirst(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft,
+ int startline, unsigned int **glyphs,
+ int glyphWidth, int fg, int bg, int rop,
+ unsigned planemask);
+
+extern _X_EXPORT CARD32 *(*XAAGlyphScanlineFuncMSBFirstFixedBase[32]) (CARD32
+ *base,
+ unsigned
+ int
+ **glyphp,
+ int line,
+ int
+ nglyph,
+ int
+ width);
+
+extern _X_EXPORT CARD32 *(*XAAGlyphScanlineFuncMSBFirst[32]) (CARD32 *base,
+ unsigned int
+ **glyphp,
+ int line,
+ int nglyph,
+ int width);
+
+extern _X_EXPORT CARD32 *(*XAAGlyphScanlineFuncLSBFirstFixedBase[32]) (CARD32
+ *base,
+ unsigned
+ int
+ **glyphp,
+ int line,
+ int
+ nglyph,
+ int
+ width);
+
+extern _X_EXPORT CARD32 *(*XAAGlyphScanlineFuncLSBFirst[32]) (CARD32 *base,
+ unsigned int
+ **glyphp,
+ int line,
+ int nglyph,
+ int width);
+
+extern _X_EXPORT GlyphScanlineFuncPtr
+ *XAAGetGlyphScanlineFuncMSBFirstFixedBase(void);
extern _X_EXPORT GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncMSBFirst(void);
-extern _X_EXPORT GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncLSBFirstFixedBase(void);
+extern _X_EXPORT GlyphScanlineFuncPtr
+ *XAAGetGlyphScanlineFuncLSBFirstFixedBase(void);
extern _X_EXPORT GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncLSBFirst(void);
extern _X_EXPORT void
-XAAFillColorExpandRectsLSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandRects3LSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandRectsLSBFirstFixedBase(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandRects3LSBFirstFixedBase(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandRectsMSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandRects3MSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandRectsMSBFirstFixedBase(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandRects3MSBFirstFixedBase(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillScanlineColorExpandRectsLSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillScanlineColorExpandRects3LSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillScanlineColorExpandRectsMSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillScanlineColorExpandRects3MSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandSpansLSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT 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
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandSpansLSBFirstFixedBase(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT 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
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandSpansMSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT 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
-);
-
-extern _X_EXPORT void
-XAAFillColorExpandSpansMSBFirstFixedBase(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT 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
-);
-
-extern _X_EXPORT void
-XAAFillScanlineColorExpandSpansLSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT 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
-);
-
-extern _X_EXPORT void
-XAAPutImage(
- DrawablePtr pDraw,
- GCPtr pGC,
- int depth,
- int x,
- int y,
- int w,
- int h,
- int leftPad,
- int format,
- char *pImage
-);
-
-extern _X_EXPORT void
-XAAFillScanlineColorExpandSpansMSBFirst(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT 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 _X_EXPORT CARD32 *(*XAAStippleScanlineFuncMSBFirstFixedBase[6])(
- CARD32* base, CARD32* src, int offset, int width, int dwords
-);
-
-extern _X_EXPORT CARD32 *(*XAAStippleScanlineFuncMSBFirst[6])(
- CARD32* base, CARD32* src, int offset, int width, int dwords
-);
-
-extern _X_EXPORT CARD32 *(*XAAStippleScanlineFuncLSBFirstFixedBase[6])(
- CARD32* base, CARD32* src, int offset, int width, int dwords
-);
-
-extern _X_EXPORT CARD32 *(*XAAStippleScanlineFuncLSBFirst[6])(
- CARD32* base, CARD32* src, int offset, int width, int dwords
-);
-
-extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFuncMSBFirstFixedBase(void);
-extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFuncMSBFirst(void);
-extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFuncLSBFirstFixedBase(void);
-extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFuncLSBFirst(void);
-extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFunc3MSBFirstFixedBase(void);
-extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFunc3MSBFirst(void);
-extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFunc3LSBFirstFixedBase(void);
-extern _X_EXPORT StippleScanlineProcPtr *XAAGetStippleScanlineFunc3LSBFirst(void);
+
+XAAFillColorExpandRectsLSBFirst(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT void
+
+XAAFillColorExpandRects3LSBFirst(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT void
+
+XAAFillColorExpandRectsLSBFirstFixedBase(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT void
+
+XAAFillColorExpandRects3LSBFirstFixedBase(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT void
+
+XAAFillColorExpandRectsMSBFirst(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT void
+
+XAAFillColorExpandRects3MSBFirst(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT void
+
+XAAFillColorExpandRectsMSBFirstFixedBase(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT void
+
+XAAFillColorExpandRects3MSBFirstFixedBase(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT void
+
+XAAFillScanlineColorExpandRectsLSBFirst(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT void
+
+XAAFillScanlineColorExpandRects3LSBFirst(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT void
+
+XAAFillScanlineColorExpandRectsMSBFirst(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT void
+
+XAAFillScanlineColorExpandRects3MSBFirst(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT void
+
+XAAFillColorExpandSpansLSBFirst(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT 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);
+
+extern _X_EXPORT void
+
+XAAFillColorExpandSpansLSBFirstFixedBase(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT 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);
+
+extern _X_EXPORT void
+
+XAAFillColorExpandSpansMSBFirst(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT 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);
+
+extern _X_EXPORT void
+
+XAAFillColorExpandSpansMSBFirstFixedBase(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT 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);
+
+extern _X_EXPORT void
+
+XAAFillScanlineColorExpandSpansLSBFirst(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT 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);
+
+extern _X_EXPORT void
+
+XAAPutImage(DrawablePtr pDraw,
+ GCPtr pGC,
+ int depth,
+ int x, int y, int w, int h, int leftPad, int format, char *pImage);
+
+extern _X_EXPORT void
+
+XAAFillScanlineColorExpandSpansMSBFirst(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT 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 _X_EXPORT CARD32 *(*XAAStippleScanlineFuncMSBFirstFixedBase[6]) (CARD32
+ *base,
+ CARD32
+ *src,
+ int
+ offset,
+ int
+ width,
+ int
+ dwords);
+
+extern _X_EXPORT CARD32 *(*XAAStippleScanlineFuncMSBFirst[6]) (CARD32 *base,
+ CARD32 *src,
+ int offset,
+ int width,
+ int dwords);
+
+extern _X_EXPORT CARD32 *(*XAAStippleScanlineFuncLSBFirstFixedBase[6]) (CARD32
+ *base,
+ CARD32
+ *src,
+ int
+ offset,
+ int
+ width,
+ int
+ dwords);
+
+extern _X_EXPORT CARD32 *(*XAAStippleScanlineFuncLSBFirst[6]) (CARD32 *base,
+ CARD32 *src,
+ int offset,
+ int width,
+ int dwords);
+
+extern _X_EXPORT StippleScanlineProcPtr
+ *XAAGetStippleScanlineFuncMSBFirstFixedBase(void);
+extern _X_EXPORT StippleScanlineProcPtr
+ *XAAGetStippleScanlineFuncMSBFirst(void);
+extern _X_EXPORT StippleScanlineProcPtr
+ *XAAGetStippleScanlineFuncLSBFirstFixedBase(void);
+extern _X_EXPORT StippleScanlineProcPtr
+ *XAAGetStippleScanlineFuncLSBFirst(void);
+extern _X_EXPORT StippleScanlineProcPtr
+ *XAAGetStippleScanlineFunc3MSBFirstFixedBase(void);
+extern _X_EXPORT StippleScanlineProcPtr
+ *XAAGetStippleScanlineFunc3MSBFirst(void);
+extern _X_EXPORT StippleScanlineProcPtr
+ *XAAGetStippleScanlineFunc3LSBFirstFixedBase(void);
+extern _X_EXPORT StippleScanlineProcPtr
+ *XAAGetStippleScanlineFunc3LSBFirst(void);
extern _X_EXPORT int
-XAAPolyText8TEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- char *chars
-);
+
+XAAPolyText8TEColorExpansion(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars);
extern _X_EXPORT int
-XAAPolyText16TEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- unsigned short *chars
-);
-
-extern _X_EXPORT void
-XAAImageText8TEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- char *chars
-);
-
-extern _X_EXPORT void
-XAAImageText16TEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- unsigned short *chars
-);
-
-extern _X_EXPORT void
-XAAImageGlyphBltTEColorExpansion(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase
-);
-
-extern _X_EXPORT void
-XAAPolyGlyphBltTEColorExpansion(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase
-);
+XAAPolyText16TEColorExpansion(DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y, int count, unsigned short *chars);
+
+extern _X_EXPORT void
+
+XAAImageText8TEColorExpansion(DrawablePtr pDraw,
+ GCPtr pGC, int x, int y, int count, char *chars);
+
+extern _X_EXPORT void
+
+XAAImageText16TEColorExpansion(DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y, int count, unsigned short *chars);
+
+extern _X_EXPORT void
+
+XAAImageGlyphBltTEColorExpansion(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase);
+
+extern _X_EXPORT void
+
+XAAPolyGlyphBltTEColorExpansion(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase);
extern _X_EXPORT int
-XAAPolyText8NonTEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- char *chars
-);
+
+XAAPolyText8NonTEColorExpansion(DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y, int count, char *chars);
extern _X_EXPORT int
-XAAPolyText16NonTEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- unsigned short *chars
-);
-
-extern _X_EXPORT void
-XAAImageText8NonTEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- char *chars
-);
-
-extern _X_EXPORT void
-XAAImageText16NonTEColorExpansion(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x, int y,
- int count,
- unsigned short *chars
-);
-
-extern _X_EXPORT void
-XAAImageGlyphBltNonTEColorExpansion(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase
-);
-
-extern _X_EXPORT void
-XAAPolyGlyphBltNonTEColorExpansion(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase
-);
-
-
-extern _X_EXPORT void XAANonTEGlyphRenderer(
- ScrnInfoPtr pScrn,
- int x, int y, int n,
- NonTEGlyphPtr glyphs,
- BoxPtr pbox,
- int fg, int rop,
- unsigned int planemask
-);
-
-extern _X_EXPORT void
-XAAFillSolidSpans(
- ScrnInfoPtr pScrn,
- int fg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth, int fSorted
-);
-
-extern _X_EXPORT void
-XAAFillMono8x8PatternSpans(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth, int fSorted,
- int patx, int paty,
- int xorg, int yorg
-);
-
-extern _X_EXPORT void
-XAAFillMono8x8PatternSpansScreenOrigin(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth, int fSorted,
- int patx, int paty,
- int xorg, int yorg
-);
-
-extern _X_EXPORT void
-XAAFillColor8x8PatternSpansScreenOrigin(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth, int fSorted,
- XAACacheInfoPtr,
- int xorigin, int yorigin
-);
-
-extern _X_EXPORT void
-XAAFillColor8x8PatternSpans(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth, int fSorted,
- XAACacheInfoPtr,
- int xorigin, int yorigin
-);
-
-extern _X_EXPORT void
-XAAFillCacheBltSpans(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr points,
- int *widths,
- int fSorted,
- XAACacheInfoPtr pCache,
- int xorg, int yorg
-);
-
-extern _X_EXPORT void
-XAAFillCacheExpandSpans(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-);
-
-extern _X_EXPORT void
-XAAFillSpans(
- DrawablePtr pDrawable,
- GC *pGC,
- int nInit,
- DDXPointPtr pptInit,
- int *pwidth,
- int fSorted
-);
-
-
-extern _X_EXPORT void
-XAAInitPixmapCache(
- ScreenPtr pScreen,
- RegionPtr areas,
- pointer data
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapToCache(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int fg, int bg
-);
-
-extern _X_EXPORT void
-XAAWriteBitmapToCacheLinear(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int fg, int bg
-);
-
-extern _X_EXPORT void
-XAAWritePixmapToCache(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int bpp, int depth
-);
-
-extern _X_EXPORT void
-XAAWritePixmapToCacheLinear(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *src,
- int srcwidth,
- int bpp, int depth
-);
-
-extern _X_EXPORT void
-XAASolidHorVertLineAsRects(
- ScrnInfoPtr pScrn,
- int x, int y, int len, int dir
-);
-
-extern _X_EXPORT void
-XAASolidHorVertLineAsTwoPoint(
- ScrnInfoPtr pScrn,
- int x, int y, int len, int dir
-);
-
-extern _X_EXPORT void
-XAASolidHorVertLineAsBresenham(
- ScrnInfoPtr pScrn,
- int x, int y, int len, int dir
-);
-
+
+XAAPolyText16NonTEColorExpansion(DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y,
+ int count, unsigned short *chars);
+
+extern _X_EXPORT void
+
+XAAImageText8NonTEColorExpansion(DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y, int count, char *chars);
+
+extern _X_EXPORT void
+
+XAAImageText16NonTEColorExpansion(DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y,
+ int count, unsigned short *chars);
+
+extern _X_EXPORT void
+
+XAAImageGlyphBltNonTEColorExpansion(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase);
+
+extern _X_EXPORT void
+
+XAAPolyGlyphBltNonTEColorExpansion(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int xInit, int yInit,
+ unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase);
+
+extern _X_EXPORT void XAANonTEGlyphRenderer(ScrnInfoPtr pScrn,
+ int x, int y, int n,
+ NonTEGlyphPtr glyphs,
+ BoxPtr pbox,
+ int fg, int rop,
+ unsigned int planemask);
+
+extern _X_EXPORT void
+
+XAAFillSolidSpans(ScrnInfoPtr pScrn,
+ int fg, int rop,
+ unsigned int planemask,
+ int n, DDXPointPtr ppt, int *pwidth, int fSorted);
+
+extern _X_EXPORT void
+
+XAAFillMono8x8PatternSpans(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted,
+ int patx, int paty, int xorg, int yorg);
+
+extern _X_EXPORT void
+
+XAAFillMono8x8PatternSpansScreenOrigin(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted,
+ int patx, int paty, int xorg, int yorg);
+
+extern _X_EXPORT void
+
+XAAFillColor8x8PatternSpansScreenOrigin(ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted,
+ XAACacheInfoPtr,
+ int xorigin, int yorigin);
+
+extern _X_EXPORT void
+
+XAAFillColor8x8PatternSpans(ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted,
+ XAACacheInfoPtr, int xorigin, int yorigin);
+
+extern _X_EXPORT void
+
+XAAFillCacheBltSpans(ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr points,
+ int *widths,
+ int fSorted, XAACacheInfoPtr pCache, int xorg, int yorg);
+
+extern _X_EXPORT void
+
+XAAFillCacheExpandSpans(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted, int xorg, int yorg, PixmapPtr pPix);
+
+extern _X_EXPORT void
+
+XAAFillSpans(DrawablePtr pDrawable,
+ GC * pGC,
+ int nInit, DDXPointPtr pptInit, int *pwidth, int fSorted);
+
+extern _X_EXPORT void
+ XAAInitPixmapCache(ScreenPtr pScreen, RegionPtr areas, pointer data);
extern _X_EXPORT void
-XAAPolyRectangleThinSolid(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int nRectsInit,
- xRectangle *pRectsInit
-);
+XAAWriteBitmapToCache(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src, int srcwidth, int fg, int bg);
extern _X_EXPORT void
-XAAPolylinesWideSolid (
- DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr pPts
-);
+
+XAAWriteBitmapToCacheLinear(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src, int srcwidth, int fg, int bg);
+
+extern _X_EXPORT void
+
+XAAWritePixmapToCache(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src, int srcwidth, int bpp, int depth);
+
+extern _X_EXPORT void
+
+XAAWritePixmapToCacheLinear(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned char *src,
+ int srcwidth, int bpp, int depth);
extern _X_EXPORT void
-XAAFillPolygonSolid(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
-);
+ XAASolidHorVertLineAsRects(ScrnInfoPtr pScrn, int x, int y, int len, int dir);
+
+extern _X_EXPORT void
+
+XAASolidHorVertLineAsTwoPoint(ScrnInfoPtr pScrn,
+ int x, int y, int len, int dir);
+
+extern _X_EXPORT void
+
+XAASolidHorVertLineAsBresenham(ScrnInfoPtr pScrn,
+ int x, int y, int len, int dir);
+
+extern _X_EXPORT void
+
+XAAPolyRectangleThinSolid(DrawablePtr pDrawable,
+ GCPtr pGC, int nRectsInit, xRectangle *pRectsInit);
+
+extern _X_EXPORT void
+
+XAAPolylinesWideSolid(DrawablePtr pDrawable,
+ GCPtr pGC, int mode, int npt, DDXPointPtr pPts);
extern _X_EXPORT void
-XAAFillPolygonStippled(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
-);
+XAAFillPolygonSolid(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int shape, int mode, int count, DDXPointPtr ptsIn);
extern _X_EXPORT void
-XAAFillPolygonTiled(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
-);
+XAAFillPolygonStippled(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int shape, int mode, int count, DDXPointPtr ptsIn);
+
+extern _X_EXPORT void
+
+XAAFillPolygonTiled(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int shape, int mode, int count, DDXPointPtr ptsIn);
extern _X_EXPORT int
-XAAIsEasyPolygon(
- DDXPointPtr ptsIn,
- int count,
- BoxPtr extents,
- int origin,
- DDXPointPtr *topPoint,
- int *topY, int *bottomY,
- int shape
-);
-
-extern _X_EXPORT void
-XAAFillPolygonHelper(
- ScrnInfoPtr pScrn,
- DDXPointPtr ptsIn,
- int count,
- DDXPointPtr topPoint,
- int y,
- int maxy,
- int origin,
- RectFuncPtr RectFunc,
- TrapFuncPtr TrapFunc,
- int xorg,
- int yorg,
- XAACacheInfoPtr pCache
-);
-
-extern _X_EXPORT void
-XAAPolySegment(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int nseg,
- xSegment *pSeg
-);
-
-extern _X_EXPORT void
-XAAPolyLines(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr pptInit
-);
-
-extern _X_EXPORT void
-XAAPolySegmentDashed(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int nseg,
- xSegment *pSeg
-);
-
-extern _X_EXPORT void
-XAAPolyLinesDashed(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr pptInit
-);
-
-
-extern _X_EXPORT void
-XAAWriteMono8x8PatternToCache(ScrnInfoPtr pScrn, XAACacheInfoPtr pCache);
-
-extern _X_EXPORT void
-XAAWriteColor8x8PatternToCache(
- ScrnInfoPtr pScrn,
- PixmapPtr pPix,
- XAACacheInfoPtr pCache
-);
-
-extern _X_EXPORT void
-XAARotateMonoPattern(
- int *pat0, int *pat1,
- int xoffset, int yoffset,
- Bool msbfirst
-);
+
+XAAIsEasyPolygon(DDXPointPtr ptsIn,
+ int count,
+ BoxPtr extents,
+ int origin,
+ DDXPointPtr * topPoint, int *topY, int *bottomY, int shape);
+
+extern _X_EXPORT void
+
+XAAFillPolygonHelper(ScrnInfoPtr pScrn,
+ DDXPointPtr ptsIn,
+ int count,
+ DDXPointPtr topPoint,
+ int y,
+ int maxy,
+ int origin,
+ RectFuncPtr RectFunc,
+ TrapFuncPtr TrapFunc,
+ int xorg, int yorg, XAACacheInfoPtr pCache);
+
+extern _X_EXPORT void
+ XAAPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pSeg);
+
+extern _X_EXPORT void
+
+XAAPolyLines(DrawablePtr pDrawable,
+ GCPtr pGC, int mode, int npt, DDXPointPtr pptInit);
+
+extern _X_EXPORT void
+
+XAAPolySegmentDashed(DrawablePtr pDrawable,
+ GCPtr pGC, int nseg, xSegment * pSeg);
+
+extern _X_EXPORT void
+
+XAAPolyLinesDashed(DrawablePtr pDrawable,
+ GCPtr pGC, int mode, int npt, DDXPointPtr pptInit);
+
+extern _X_EXPORT void
+ XAAWriteMono8x8PatternToCache(ScrnInfoPtr pScrn, XAACacheInfoPtr pCache);
+
+extern _X_EXPORT void
+
+XAAWriteColor8x8PatternToCache(ScrnInfoPtr pScrn,
+ PixmapPtr pPix, XAACacheInfoPtr pCache);
+
+extern _X_EXPORT void
+
+XAARotateMonoPattern(int *pat0, int *pat1,
+ int xoffset, int yoffset, Bool msbfirst);
extern _X_EXPORT void XAAComputeDash(GCPtr pGC);
-extern _X_EXPORT void XAAMoveDWORDS_FixedBase(
- register CARD32* dest,
- register CARD32* src,
- register int dwords
-);
+extern _X_EXPORT void XAAMoveDWORDS_FixedBase(register CARD32 *dest,
+ register CARD32 *src,
+ register int dwords);
-extern _X_EXPORT void XAAMoveDWORDS_FixedSrc(
- register CARD32* dest,
- register CARD32* src,
- register int dwords
-);
+extern _X_EXPORT void XAAMoveDWORDS_FixedSrc(register CARD32 *dest,
+ register CARD32 *src,
+ register int dwords);
-extern _X_EXPORT void XAAMoveDWORDS(
- register CARD32* dest,
- register CARD32* src,
- register int dwords
-);
+extern _X_EXPORT void XAAMoveDWORDS(register CARD32 *dest,
+ register CARD32 *src, register int dwords);
extern _X_EXPORT int
-XAAGetRectClipBoxes(
- GCPtr pGC,
- BoxPtr pboxClippedBase,
- int nrectFill,
- xRectangle *prectInit
-);
+
+XAAGetRectClipBoxes(GCPtr pGC,
+ BoxPtr pboxClippedBase,
+ int nrectFill, xRectangle *prectInit);
extern _X_EXPORT void
-XAASetupOverlay8_32Planar(ScreenPtr);
+ XAASetupOverlay8_32Planar(ScreenPtr);
extern _X_EXPORT void
-XAAPolyFillArcSolid(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs);
-
-extern _X_EXPORT XAACacheInfoPtr
-XAACacheTile(ScrnInfoPtr Scrn, PixmapPtr pPix);
+ XAAPolyFillArcSolid(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs);
+
+extern _X_EXPORT XAACacheInfoPtr XAACacheTile(ScrnInfoPtr Scrn, PixmapPtr pPix);
extern _X_EXPORT XAACacheInfoPtr
XAACacheMonoStipple(ScrnInfoPtr Scrn, PixmapPtr pPix);
@@ -1508,8 +1212,10 @@ XAACacheMonoStipple(ScrnInfoPtr Scrn, PixmapPtr pPix);
extern _X_EXPORT XAACacheInfoPtr
XAACachePlanarMonoStipple(ScrnInfoPtr Scrn, PixmapPtr pPix);
-typedef XAACacheInfoPtr (*XAACachePlanarMonoStippleProc)(ScrnInfoPtr, PixmapPtr);
-extern _X_EXPORT XAACachePlanarMonoStippleProc XAAGetCachePlanarMonoStipple(void);
+typedef XAACacheInfoPtr(*XAACachePlanarMonoStippleProc) (ScrnInfoPtr,
+ PixmapPtr);
+extern _X_EXPORT XAACachePlanarMonoStippleProc
+XAAGetCachePlanarMonoStipple(void);
extern _X_EXPORT XAACacheInfoPtr
XAACacheStipple(ScrnInfoPtr Scrn, PixmapPtr pPix, int fg, int bg);
@@ -1521,13 +1227,14 @@ extern _X_EXPORT XAACacheInfoPtr
XAACacheColor8x8Pattern(ScrnInfoPtr Scrn, PixmapPtr pPix, int fg, int bg);
extern _X_EXPORT void
-XAATileCache(ScrnInfoPtr pScrn, XAACacheInfoPtr pCache, int w, int h);
-
+ XAATileCache(ScrnInfoPtr pScrn, XAACacheInfoPtr pCache, int w, int h);
+
extern _X_EXPORT void XAAClosePixmapCache(ScreenPtr pScreen);
void XAAInvalidatePixmapCache(ScreenPtr pScreen);
extern _X_EXPORT Bool XAACheckStippleReducibility(PixmapPtr pPixmap);
-extern _X_EXPORT Bool XAACheckTileReducibility(PixmapPtr pPixmap, Bool checkMono);
+extern _X_EXPORT Bool XAACheckTileReducibility(PixmapPtr pPixmap,
+ Bool checkMono);
extern _X_EXPORT int XAAStippledFillChooser(GCPtr pGC);
extern _X_EXPORT int XAAOpaqueStippledFillChooser(GCPtr pGC);
@@ -1537,94 +1244,67 @@ extern _X_EXPORT void XAAMoveInOffscreenPixmaps(ScreenPtr pScreen);
extern _X_EXPORT void XAAMoveOutOffscreenPixmaps(ScreenPtr pScreen);
extern _X_EXPORT void XAARemoveAreaCallback(FBAreaPtr area);
extern _X_EXPORT void XAAMoveOutOffscreenPixmap(PixmapPtr pPix);
-extern _X_EXPORT Bool XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec);
+extern _X_EXPORT Bool XAAInitStateWrap(ScreenPtr pScreen,
+ XAAInfoRecPtr infoRec);
extern _X_EXPORT void
-XAAComposite (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst,
- CARD16 width,
- CARD16 height);
+XAAComposite(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
extern _X_EXPORT Bool
-XAADoComposite (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst,
- CARD16 width,
- CARD16 height);
-
-
-extern _X_EXPORT void
-XAAGlyphs (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pDst,
- PictFormatPtr maskFormat,
- INT16 xSrc,
- INT16 ySrc,
- int nlist,
- GlyphListPtr list,
- GlyphPtr *glyphs);
-extern _X_EXPORT Bool
-XAADoGlyphs (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pDst,
- PictFormatPtr maskFormat,
- INT16 xSrc,
- INT16 ySrc,
- int nlist,
- GlyphListPtr list,
- GlyphPtr *glyphs);
+XAADoComposite(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
+extern _X_EXPORT void
+XAAGlyphs(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc, int nlist, GlyphListPtr list, GlyphPtr * glyphs);
+
+extern _X_EXPORT Bool
+
+XAADoGlyphs(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc, int nlist, GlyphListPtr list, GlyphPtr * glyphs);
/* helpers */
extern _X_EXPORT void
-XAA_888_plus_PICT_a8_to_8888 (
- CARD32 color,
- CARD8 *alphaPtr, /* in bytes */
- int alphaPitch,
- CARD32 *dstPtr,
- int dstPitch, /* in dwords */
- int width,
- int height
-);
+ XAA_888_plus_PICT_a8_to_8888(CARD32 color, CARD8 *alphaPtr, /* in bytes */
+ int alphaPitch, CARD32 *dstPtr, int dstPitch, /* in dwords */
+ int width, int height);
extern _X_EXPORT Bool
-XAAGetRGBAFromPixel(
- CARD32 pixel,
- CARD16 *red,
- CARD16 *green,
- CARD16 *blue,
- CARD16 *alpha,
- CARD32 format
-);
+XAAGetRGBAFromPixel(CARD32 pixel,
+ CARD16 *red,
+ CARD16 *green, CARD16 *blue, CARD16 *alpha, CARD32 format);
extern _X_EXPORT Bool
-XAAGetPixelFromRGBA (
- CARD32 *pixel,
- CARD16 red,
- CARD16 green,
- CARD16 blue,
- CARD16 alpha,
- CARD32 format
-);
+
+XAAGetPixelFromRGBA(CARD32 *pixel,
+ CARD16 red,
+ CARD16 green, CARD16 blue, CARD16 alpha, CARD32 format);
/* XXX should be static */
extern _X_EXPORT GCOps XAAFallbackOps;
@@ -1694,7 +1374,7 @@ extern _X_EXPORT CARD32 XAAReverseBitOrder(CARD32 data);
((pGC->planemask & infoRec->FullPlanemask) != infoRec->FullPlanemask))
#define IS_OFFSCREEN_PIXMAP(pPix)\
- ((XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pPix)))->offscreenArea)
+ ((XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pPix)))->offscreenArea)
#define PIXMAP_IS_SHARED(pPix)\
((XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pPix)))->flags & SHARED_PIXMAP)
@@ -1719,7 +1399,6 @@ extern _X_EXPORT CARD32 XAAReverseBitOrder(CARD32 data);
_prev = _pLink; \
_pLink = _pLink->next; \
}}
-
#define SWAP_BITS_IN_BYTES(v) \
(((0x01010101 & (v)) << 7) | ((0x02020202 & (v)) << 5) | \
@@ -1733,27 +1412,26 @@ extern _X_EXPORT CARD32 XAAReverseBitOrder(CARD32 data);
*/
typedef struct {
- int Num512x512;
- int Current512;
- XAACacheInfoPtr Info512;
- int Num256x256;
- int Current256;
- XAACacheInfoPtr Info256;
- int Num128x128;
- int Current128;
- XAACacheInfoPtr Info128;
- int NumMono;
- int CurrentMono;
- XAACacheInfoPtr InfoMono;
- int NumColor;
- int CurrentColor;
- XAACacheInfoPtr InfoColor;
- int NumPartial;
- int CurrentPartial;
- XAACacheInfoPtr InfoPartial;
- DDXPointRec MonoOffsets[64];
- DDXPointRec ColorOffsets[64];
+ int Num512x512;
+ int Current512;
+ XAACacheInfoPtr Info512;
+ int Num256x256;
+ int Current256;
+ XAACacheInfoPtr Info256;
+ int Num128x128;
+ int Current128;
+ XAACacheInfoPtr Info128;
+ int NumMono;
+ int CurrentMono;
+ XAACacheInfoPtr InfoMono;
+ int NumColor;
+ int CurrentColor;
+ XAACacheInfoPtr InfoColor;
+ int NumPartial;
+ int CurrentPartial;
+ XAACacheInfoPtr InfoPartial;
+ DDXPointRec MonoOffsets[64];
+ DDXPointRec ColorOffsets[64];
} XAAPixmapCachePrivate, *XAAPixmapCachePrivatePtr;
-
-#endif /* _XAALOCAL_H */
+#endif /* _XAALOCAL_H */
diff --git a/xorg-server/hw/xfree86/xaa/xaarop.h b/xorg-server/hw/xfree86/xaa/xaarop.h
index edfd75aec..f2acde075 100644
--- a/xorg-server/hw/xfree86/xaa/xaarop.h
+++ b/xorg-server/hw/xfree86/xaa/xaarop.h
@@ -8,7 +8,6 @@
MS triadic raster op. The function will return which components
(S-P) need to be enabled.
-
int XAAHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg, int pm, int *rop)
For use with 8x8 opaque pattern fills. You give it the foreground,
@@ -17,7 +16,6 @@
appropriate MS triadic raster op. The function will return which
components (S-P) need to be enabled.
-
ROP_PAT - Means to enable 8x8 mono patterns (all bits
set for solid patterns). Set the foreground and
background as returned by the function.
@@ -294,8 +292,10 @@
#define NO_SRC_ROP(rop) \
((rop == GXnoop) || (rop == GXset) || (rop == GXclear) || (rop == GXinvert))
-extern _X_EXPORT int XAAHelpSolidROP(ScrnInfoPtr pScrn, int *fg, int pm, int *rop);
-extern _X_EXPORT int XAAHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg, int pm, int *rop);
+extern _X_EXPORT int XAAHelpSolidROP(ScrnInfoPtr pScrn, int *fg, int pm,
+ int *rop);
+extern _X_EXPORT int XAAHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg,
+ int pm, int *rop);
/* XXX These four should be static, but it breaks the 6.7.0 ABI. */
extern _X_EXPORT int XAACopyROP[16];
@@ -308,4 +308,4 @@ extern _X_EXPORT int XAAGetCopyROP_PM(int i);
extern _X_EXPORT int XAAGetPatternROP(int i);
extern _X_EXPORT int XAAGetPatternROP_PM(int i);
-#endif /* _XAAROP_H */
+#endif /* _XAAROP_H */